Skip to content

Instantly share code, notes, and snippets.

View atomicptr's full-sized avatar
A programmer is a machine that turns coffee into code.

Christopher Kaster atomicptr

A programmer is a machine that turns coffee into code.
View GitHub Profile
@atomicptr
atomicptr / luaxer.clj
Created July 30, 2025 19:26
A Lua lexer in Clojure written for fun
(ns luaxer.core
(:require
[cheshire.core :as json]
[clojure.string :as string]))
(defn- lexer-error [message pos]
(throw (ex-info (str "Lexer Error: " message) {:position pos})))
(defn- lexer [source]
(let [source (string/trim source)
@atomicptr
atomicptr / neovim-server.sh
Last active July 15, 2025 09:37
Bash script that enables seamless reuse of a single Neovim instance for external applications like Defold/Godot/etc. It automatically opens files (with optional line numbers) in an existing Neovim server, launching a new one if none is found, and focuses the corresponding window.
#!/usr/bin/env bash
if [[ "$#" -ne 2 && "$#" -ne 3 ]]; then
echo "Usage: $0 <class> <file> [line]"
echo " <class>: The window class for ghostty/Neovim"
echo " <file>: The file to open"
echo " [line]: Optional. The line number to open the file at"
exit 1
fi
@atomicptr
atomicptr / judo2json.js
Last active September 3, 2024 13:04
(Web scraping) Japanese Judo techniques to JSON
import * as cheerio from "cheerio";
const url = "https://kdkjudo.org/%E6%8A%80/%E6%9F%94%E9%81%93-%E6%8A%80%E5%90%8D%E7%A7%B0%E4%B8%80%E8%A6%A7/";
const main = async () => {
const resp = await fetch(url);
const html = await resp.text();
const $ = cheerio.load(html);
@atomicptr
atomicptr / pixel_camera.odin
Last active April 8, 2024 16:51
Simple pixel camera for Odin and Raylib
package camera
import "core:fmt"
import "core:math"
import rl "vendor:raylib"
PixelCamera :: struct {
screen_width: i32,
screen_height: i32,
virtual_screen_width: i32,
@atomicptr
atomicptr / errors.lua
Last active December 20, 2023 04:42
Implementation of Go-like errors in Lua 5.1+
--[[
Go-like errors for Lua
Copyright (c) 2023 Christopher Kaster
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
@atomicptr
atomicptr / filler-delete.py
Last active November 23, 2022 08:34
Filler Delete Script
#!/usr/bin/env python3
# Currently this is used for Detective Conan if you want to use this for another show just edit the "fillers"
# variable below
import re
import os
import sys
# copied from https://www.animefillerlist.com/shows/detective-conan
@atomicptr
atomicptr / vendor.py
Created November 5, 2022 09:54
Use a vendor directory with Python
# In some scenarios for instance when using Python as a plugin language you can't just pip install something, instead
# you need to put the dependencies in a vendor directory instead which however usually means that you have to adjust paths
# sometimes even in the dependency which is a pain, wouldn't it be nice to just "import DEPENDENCY" like if you just had
# installed it via pip install?
# To do this, put into your entry point (for instance the primary __init__.py the following piece of code RIGHT
# at the start:
import os
import sys
@atomicptr
atomicptr / anki-dictionary-switcher.html
Last active August 6, 2022 07:50
Anki Dictionary Switcher
<!--
# Anki Dictionary Switcher
https://gist.github.com/atomicptr/3c7bf0bb21cbe9cbbf1ee40574800c7f
Switch between multiple dictionaries (added by Yomichan for instance) instead of seeing all of them at once.
Keep in mind you need to edit your HTML structure to look like what we have here:
-->
@atomicptr
atomicptr / VirtualizedList.tsx
Created June 5, 2022 06:51
React virtualized list component with dynamic row height
import React, { CSSProperties, ReactNode, RefObject, useEffect, useRef } from "react";
import AutoSizer from "react-virtualized-auto-sizer";
import { ListChildComponentProps, VariableSizeList } from "react-window";
interface VirtualizedListProps {
count: number;
subtractFromHeight?: number;
defaultRowHeight?: number;
renderItems: (rowRef: RefObject<HTMLDivElement>, index: number, style?: CSSProperties) => ReactNode;
}
@atomicptr
atomicptr / dauntless-builder-french-import.js
Last active May 28, 2022 17:35
Dauntless Builder French i18n importer
const fs = require("fs");
const fsp = require("fs").promises;
const https = require("https");
const path = require("path");
const yaml = require("js-yaml");
const mapEn = require("../.map/names.json");
const dataEn = require("../public/data.json");
const language = "fr";