Skip to content

Instantly share code, notes, and snippets.

View stepankuzmin's full-sized avatar
🥡

Stepan Kuzmin stepankuzmin

🥡
View GitHub Profile
@stepankuzmin
stepankuzmin / grug.md
Last active July 25, 2025 08:41
The Grug Sub Agent `.claude/agents/grug.md`

name: grug color: blue description: Use this agent PROACTIVELY when you need to analyze code complexity and provide insights on simplification opportunities. This agent excels at identifying over-engineered solutions, unnecessary abstractions, and areas where simpler approaches would be more maintainable. Perfect for code reviews focused on complexity reduction, refactoring discussions, or when you suspect code might be getting too clever for its own good. Examples:\n\n\nContext: The user wants to review recently written code.\nuser: "I just implemented a new feature. Can you review it?"\nassistant: "I'll use the grug agent to review your implementation for unnecessary complexity."\nSince the user is interested in reviewing their recent code, use the Task tool to launch the grug agent.\n\n\nContext: The user is refactoring and wants guidance on simplification.\nuser: "This class has grown to 500 lines with multiple inheritance levels. Help me simplify i

circleci@2e14e81afaa0:~$ cat diagnostics_2e14e81afaa0.txt
=== RUNNER DIAGNOSTICS ===
Date: Thu May 29 08:14:25 AM UTC 2025
Hostname: 2e14e81afaa0
=== SYSTEM INFO ===
Kernel: 6.8.0-1024-aws
OS: Ubuntu 22.04.3 LTS
@stepankuzmin
stepankuzmin / get-tile-bounds.ts
Created May 7, 2025 09:33
Get tile bounds from XYZ
export function lngFromMercatorX(x: number): number {
return x * 360 - 180;
}
export function latFromMercatorY(y: number): number {
const y2 = 180 - y * 360;
return 360 / Math.PI * Math.atan(Math.exp(y2 * Math.PI / 180)) - 90;
}
function getBounds(tileID: CanonicalTileID): [number, number, number, number] {
@stepankuzmin
stepankuzmin / keymap.json
Last active February 19, 2025 10:01
Zed editor configuration
// Zed keymap
//
// For information on binding keys, see the Zed
// documentation: https://zed.dev/docs/key-bindings
//
// To see the default key bindings run `zed: open default keymap`
// from the command palette.
[
{
"context": "Pane",
@stepankuzmin
stepankuzmin / hover.js
Created January 30, 2025 11:46
Feature-based hover in Mapbox GL JS
map.on('style.load', () => {
map.addSource('point', {
type: 'geojson',
data: {
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"id": 1,
"properties": {},
@stepankuzmin
stepankuzmin / gist:1aa7dc8a903e6e02df917ec34a3cafbb
Created January 9, 2025 17:16
Summarize privacytests.org
const d = await fetch('https://privacytests.org/index.json').then(r => r.json());
let results = [];
for (const t of d.all_tests) {
let passed = 0;
for (const s1 in t.testResults) {
for (const s2 in t.testResults[s1]) {
if (t.testResults[s1][s2].passed) passed += 1;
}
}
@stepankuzmin
stepankuzmin / extract-from-mbtiles.js
Created October 30, 2024 15:31
Extract tile from mbtiles
/* eslint-disable handle-callback-err */
import fs from 'fs';
import zlib from 'zlib';
import MBTiles from '@mapbox/mbtiles';
const z = 0;
const x = 0;
const y = 0;
// tippecanoe -f -z0 -o admin.mbtiles admin.geojson
@stepankuzmin
stepankuzmin / logOffscreenCanvasContext.js
Created October 15, 2024 15:06
Log OffscreenCanvas rendering Context in the browser console
export function logOffscreenCanvasContext(context, scaleFactor = 1) {
const canvas = document.createElement('canvas');
canvas.width = context.canvas.width;
canvas.height = context.canvas.height;
const ctx = canvas.getContext('2d');
ctx.drawImage(context.canvas, 0, 0);
const displayWidth = canvas.width * scaleFactor;
const displayHeight = canvas.height * scaleFactor;
@stepankuzmin
stepankuzmin / evented.ts
Last active July 10, 2024 15:23
Strongly Typed Evented class with on() and fire()
export type EventData = {
[key: string]: unknown;
};
export class Event<Type extends string = string, Data extends EventData | void = void> {
target: unknown;
readonly type: Type;
/**
* Virtual property to ensure that events with different data types are not compatible.
@stepankuzmin
stepankuzmin / migrate.js
Created June 11, 2024 15:21
Migrate code to `gl-matrix` v4
import babel from '@babel/core';
import traverse from '@babel/traverse';
import generator from '@babel/generator';
function capitalizeFirstLetter(string) {
return string.charAt(0).toUpperCase() + string.slice(1);
}
function migrate() {
const input = `