Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View nok-ko's full-sized avatar

KP nok-ko

View GitHub Profile
@nok-ko
nok-ko / Trie.ts
Created July 10, 2023 03:00
Trie implementation
// src/Trie.ts
// pronounced "try"
/**
* Bespoke implementation of the Trie data structure.
* Used to do prefix search on shell builtins and, in the future,
* nodes in the virtual filesystem.
*/
export default class Trie<T> {
children: Trie<T>[];
value: T | null;
@nok-ko
nok-ko / periodic_crosshair
Last active June 1, 2023 00:55
Periodic Crosshair Hider, featuring `rpn` (ab)use
// periodic_crosshair.cfg
// Nokko — Xonotic script to periodically turn your crosshair off
// DOES count shots even when weapon is on cooldown, since it's not that easy
// to check the current weapon and whether it's ready to fire.
// Think of it as being wired directly to the "trigger" of the current weapon.
/////////////////////////
// !! USER SETTINGS !! //
/////////////////////////
/**
An implementation of the recursive backtracker maze
generation algorithm in C. Implemented recursively.
Author: nokko
Date: March 2nd
Look on my works, ye mighty, and cringe at my horrible code.
Credit to Jamis Buck for teaching me this wonderful algorithm.
(https://weblog.jamisbuck.org/2010/12/27/maze-generation-recursive-backtracking)
"""
Quickly time a function.
"""
import timeit
def quick_timeit(fname, case="", number=1000):
return timeit.timeit(stmt=f"{fname}({case})", setup=f"from __main__ import {fname}", number=number)
# usage:
## def some_fn(x,y): return x + y + min(x,y)
@nok-ko
nok-ko / bastard_scraper.py
Last active March 18, 2024 01:03
"The Gods are Bastards" Scraper
import urllib.request, os
from urllib.request import HTTPError
from bs4 import BeautifulSoup
from itertools import count
from textdistance import levenshtein, jaccard
"""
bastard_scraper.py
brought to you by: nokko
NOTE: TGaB is a large work, totalling 2,812,577 words as of Chapter 15-76