Skip to content

Instantly share code, notes, and snippets.

View Kequc's full-sized avatar

Kequc

View GitHub Profile
@Kequc
Kequc / print-weekly-surprise.py
Last active October 21, 2025 16:36
Generate random things and print them once a week
#!/usr/bin/env python3
import os, io, json, random, datetime, subprocess, ssl, urllib.request
from PIL import Image, ImageDraw, ImageFont
# ---------------- CONFIG ----------------
DPI = 300
PAPER = os.getenv("PAPER", "A4").upper() # 'A4' or 'LETTER'
def mm_px(mm): return round(mm / 25.4 * DPI)
@Kequc
Kequc / fix-dts.ts
Created October 4, 2025 21:50
Fix build output of tsc .d.ts files when written with valid ecmascript.
import { readdir, readFile, writeFile } from 'node:fs/promises';
import { join } from 'node:path';
async function walk(dir: string) {
for (const e of await readdir(dir, { withFileTypes: true })) {
const p = join(dir, e.name);
if (e.isDirectory()) {
await walk(p);
} else if (e.isFile() && p.endsWith('.d.ts')) {
const src = await readFile(p, 'utf8');
extends Node
enum TERRAIN_SHAPE { NONE, FLAT, PEAK, DROP, SLANT }
const QUAD_UVS: = PoolVector2Array([Vector2(0, 0), Vector2(1, 0), Vector2(1, 1), Vector2(0, 1)])
// My custom shader for implementing dithered alpha
shader_type spatial;
render_mode blend_mix,depth_draw_opaque,cull_disabled,diffuse_burley,specular_schlick_ggx;
// Texture maps
uniform sampler2D texture_albedo : hint_albedo;
uniform sampler2D texture_masks : hint_white;
uniform sampler2D texture_normal : hint_normal;
// Parameters
{
"env": {
"node": true,
"es6": true
},
"extends": "eslint:recommended",
"parserOptions": {
"sourceType": "module",
"ecmaVersion": 8
},
0000000000000000000000000111111111111111100000000000000000000000000000000000000000000000000000000000
0000000000000000000111111111111111111111111111111110000000000000000000000000000000000000000000000000
0000000000000111111111111111111111111111111111111111111111111100000000000000000000000000000000000000
0000000111111111111111111111111111111111111111111111111111111111111111110000000000000000000000000000
0000011111111111111111111111111111111111111111111111111111111111111111111111111111000000000000000000
0000011111111111111111111111111111111111122222222222222221111111111111111111111111111110000000000000
0000011111111111111111111111111222222222222222233333333333333333331111111111111111111111000000000000
0000111111111111111111222222222222222223333333333333333333333333333333333333311111111111000000000000
0000111111111111122222222222222333333333333333333333333333333333333333333333333333111111100000000000
0000111111111111122222333333333333333333333333333333333333333333333333333333333333311111100000000000
@Kequc
Kequc / current.js
Last active June 2, 2016 20:18
Callback hell example
router.post('/:id/title-image', (req, res, next) => {
lwip.open(req.file.buffer, 'jpg', (err, image) => {
if (err) { next(err); return; }
let ratio = (image.width() > 960 ? (960 / image.width()) : 1);
image.scale(ratio, (err, image) => {
if (err) { next(err); return; }
image.crop(image.width(), Math.min((image.width() / 2), image.height()), (err, image) => {
if (err) { next(err); return; }
image.toBuffer('jpg', { quality: 80 }, (err, buffer) => {
////
..........
.....................
..T.......T....T...........T...
..........................................
...........T........................................
.....T................T...............T........................
.........T......................
////
.........................................................
..............T........................................................
............................T..................T....................................
.T....................T.......................................T..................................
.....................T.....T...................T.........................................T........
............................................
@Kequc
Kequc / origin.js
Last active September 24, 2015 08:15
Find da memory leak
// `domains` is a global containing valid domains grouped by keys
// this module is instantiated via require at the top of some file and
// the following is run once per request:
// Origin.foundKey(blah, blah);
// some origin stuff
var _ = require('underscore');