Skip to content

Instantly share code, notes, and snippets.

@haliphax
haliphax / generate.py
Last active June 3, 2026 07:32
STL generator for breakaway stacks
#!/usr/bin/env -S uv run --script
# /// script
# dependencies = ["numpy-stl"]
# ///
"""
This script is for creating stacks of more-or-less flat meshes that have
symmetrical top and bottom faces (e.g. Multiboard). The gap (default 0.2mm)
should be set to your slicer's layer height. The resulting file should be
printed with 3 walls, 15% infill, with ironing of all top surfaces enabled.
@haliphax
haliphax / gwskills.py
Last active January 28, 2026 07:12
Guild Wars Reforged skill template code parser
"""
Parse Guild Wars Reforged skill template codes
See https://wiki.guildwars.com/wiki/Skill_template_format for reference and
profession/attribute/skill indexes.
"""
# stdlib
from dataclasses import dataclass
from typing import Any, Generator
@haliphax
haliphax / random-string.js
Created October 30, 2023 21:17
generate random string
/** printable ASCII characters */
const ascii = [];
for (let i = 33; i <= 126; ascii.push(String.fromCharCode(i++)));
/** generate random string */
const randomString = limit => {
const result = [];
for (let i = 0; i < limit; i++) {
const index = Math.floor(Math.random() * (126 - 33) + 33);
@haliphax
haliphax / 11ty-transform-htmlMinify.ts
Created August 3, 2023 19:17
Eleventy - HTML and inline script minifier transform
import { UserConfig } from "@11ty/eleventy";
import { DOMParser } from "@xmldom/xmldom";
import { transform } from "esbuild";
import { minify } from "html-minifier";
/** cache for content of script tags with an ID */
const scriptCache = new Map<string, string>();
/** DOM parser for navigating the rendered document; warnings are ignored */
const parser = new DOMParser({ errorHandler: { warning: () => {} } });
@haliphax
haliphax / install-gitmoji-hook.sh
Last active September 11, 2023 04:55
Gitmoji CLI commit hook
#!/usr/bin/env bash
# install gitmoji as a commit hook
#
# - uses https://www.npmjs.com/package/gitmoji-cli
# - does not require global module installation
# - skips hook if message already starts with gitmoji
root="$(git rev-parse --show-toplevel)"
hook="$root/.git/hooks/prepare-commit-msg"

Keybase proof

I hereby claim:

  • I am haliphax on github.
  • I am haliphax (https://keybase.io/haliphax) on keybase.
  • I have a public key ASC0LFekXGTz3OedyiQZMCgD_CiApPRAvykdZJCJsqv5wgo

To claim this, I am signing this object:

@haliphax
haliphax / merge-on-comment.yml
Created April 14, 2023 05:59
Merge pull request with "merge" comment
# Merges a pull request (if able) when a comment is added by a collaborator,
# contributor, or owner with the word "merge" as its only content
name: Merge on comment
on:
issue_comment:
types: [created]
jobs:
@haliphax
haliphax / split_graphemes.py
Last active February 2, 2026 20:29
Split a string into grapheme clusters
"""
Unicode utility for splitting a string into grapheme clusters
This gist was further developed into https://github.com/haliphax/giraph
"""
# stdlib
import logging
from os import environ
from sys import stdout
@haliphax
haliphax / settings.json
Created May 2, 2022 15:06
Vim mode-dependent relative line numbers for VS Code
// plugins used:
// - https://marketplace.visualstudio.com/items?itemName=vscodevim.vim
// - https://marketplace.visualstudio.com/items?itemName=hoovercj.vscode-settings-cycler
{
"editor.lineNumbers":"relative",
"settings.cycle":[
{
"id":"lineNumber",
"overrideWorkspaceSettings":false,
@haliphax
haliphax / LongestContiguousClickstream.cs
Created April 21, 2022 16:37
Find longest common contiguous click stream between two user records
var user0 = new string[] { "/a", "/b", "/c", "/d", "/e", "/f" };
var user1 = new string[] { "/b", "/c", "/e", "/f" };
var user2 = new string[] { "/a", "/b", "/d", "/e", "/f" };
var user3 = new string[] { "/a", "/c", "/d", "/e", "/f" };
var user4 = new string[] { "/a", "/b", "/c", "/d", "/e", "/f" };
var user5 = new string[] { "/a", "/b", "/e", "/f" };
var user6 = new string[] { "/a", "/b", "/c", "/e", "/f" };
var user7 = new string[] { "/c", "/d", "/e", "/f" };
var user8 = new string[] { "/d", "/e", "/f" };
var user9 = new string[] { "/b", "/c", "/e", "/f" };