Skip to content

Instantly share code, notes, and snippets.

View zhrkvl's full-sized avatar

Zahar Koval zhrkvl

View GitHub Profile
@zhrkvl
zhrkvl / debugger-repl.md
Created May 6, 2026 09:19
Debugging agent for claude code, save as `~/.claude/agents/debugger-repl.md`

name: debugger-repl description: "Use this agent when you need to extract runtime information that cannot be determined from static code analysis alone, such as variable values at specific execution points, runtime control flow paths, memory states, or dynamic behavior during test execution. This agent drives an interactive debugger (GDB, LLDB, etc.) session to answer specific questions about program behavior.\n\nWhen to invoke (heuristic): Reach for this agent after ~3 failed static-analysis attempts at falsifying a hypothesis about runtime behavior. If the question is runtime in nature — "why is X empty", "why does Y not fire", "what value does Z have at this point", "what order do these initializers run in" — and grep/read have not resolved it within 3 tries, stop grepping and delegate. Continuing static analysis past that point typically burns 5–10× the parent context for diminishing returns. Cost of an extra Agent call is small; cost of a wrong-layer fix you commit because static anal

@zhrkvl
zhrkvl / kek.hs
Last active October 17, 2020 09:23
Monad & monad transformer complete example
import Control.Monad.Trans.State
import Control.Monad.Trans.Except
data StackState a = StackState
{ stackData :: [a]
, stackDoneOps :: Int
, stackOpsLimit :: Int
} deriving (Show)
newStackState :: Int -> StackState a
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.*;
public class WordStatLineIndex {
public static final char[] buf = new char[256];
@zhrkvl
zhrkvl / Vector.cpp
Last active October 13, 2017 23:27
template<typename T>
class Vector {
private:
T *array;
size_t cap;
size_t end; // last element pointer
public:
Vector() : Vector(1) {}
explicit Vector(size_t initialCap) {
template<typename T, size_t n, size_t m>
using matrix = array<array<T, m>, n>;
template<typename T, size_t n >
matrix<T, n, n> get_one_matrix()
{
matrix<T, n, n> res;
for (size_t i = 0; i < n; i++)
for (size_t j = 0; j < n; j++)
res[i][j] = 0;
@zhrkvl
zhrkvl / sqrt_mo.cpp
Last active February 24, 2017 06:49
int bl_sz = 1;
class query
{
int l;
int r;
int id;
}
bool comp(const query& a, const query& b)
10000
/berq/az/
/berq/hqa/cyx/
/berq/hqa/dove/mxfm/
/berq/hqa/dove/puxu/es/
/berq/hqa/dove/puxu/xqe/
/berq/hqa/mti/
/berq/hqa/qoqc/
/berq/hqa/tcc/
/berq/pll/si/eh/dq/oa/
This file has been truncated, but you can view the full file.
10000
/afu/
/cu/flj/bj/dk/
/cu/flj/bj/yh/ishm/
/cu/flj/lp/mbasj/prjhq/ij/hwq/
/cu/flj/lp/mbasj/prjhq/ij/iap/n/hxp/
/cu/flj/lp/mbasj/prjhq/ij/ri/
/cu/flj/lp/mbasj/prjhq/ij/syvf/wil/aek/
/cu/flj/lp/mbasj/prjhq/ij/syvf/wil/buw/is/
const int P = max(rand(), 239017) | 1;
const int N = 500020;
const int MOD1 = 1000000007;
const int MOD2 = 1000000009;
array<pair<int, int>, N> p;
bool initp()
{
ll gcd(ll x, ll y)
{
while(x > 0 && y > 0)
{
if (x > y)
x = x % y;
else
y = y % x;
}