Skip to content

Instantly share code, notes, and snippets.

View ttonyh's full-sized avatar

Tony Habash ttonyh

  • Los Angeles, CA
View GitHub Profile
@clmrb
clmrb / enum.js
Last active February 3, 2026 21:37
JavaScript enum function with working JSDoc autocompletion
/**
* @description
* Creates a frozen enumeration object where each key maps to its own string value.
* This is useful for defining a set of constant string values that can be referenced by name.
* This also avoids defining an object with duplicated string values manually.
* @template {string} T
* @param {...T} values
* @returns {{ [K in T]: K }}
* @example
* const Colors = Enum('Red', 'Green', 'Blue');
@lxe
lxe / bun-middleware.ts
Last active November 15, 2025 14:12
bun-middleware.ts
// TODO: somehow enforce ordering at compile time
type WriteOnly<T> = {
-readonly [K in keyof T]: T[K]; // TODO: Typescript can't block setters like this natively :)
};
type RouteHandler<T extends string> = ( // TODO: Extract from Bun... I think it has this built in
req: Bun.BunRequest<T>,
server: Bun.Server,
) => Response | Promise<Response>;
@khronokernel
khronokernel / electron_patcher.py
Last active February 11, 2026 07:02
Electron and Chrome patcher to force OpenGL rendering
"""
electron_patcher.py: Enforce 'use-angle@1' in Chrome and Electron applications
Version 1.0.0 (2024-08-11)
"""
import enum
import json
from pathlib import Path
@NoobGajen
NoobGajen / EndeavourOS to Arch Linux.MD
Last active January 3, 2026 17:15 — forked from sun-jiao/endeavour-to-arch-guide.MD
Converting EndeavourOS to ArchLinux

First of all, uninstall the eos-hooks package, which keeps changing the data of /etc/os-release from a hook while installing base packages.

sudo pacman -R eos-hooks

Reinstall the base package group:

sudo pacman -Syyu --noconfirm archlinux-keyring bash bzip2 lsb-release coreutils file filesystem findutils gawk gcc-libs gettext glibc grep gzip iproute2 iputils licenses pacman pciutils procps-ng psmisc sed shadow systemd systemd-sysvcompat tar util-linux xz linux
@Stono
Stono / gzip-compressor.yaml
Last active December 17, 2024 18:39
Gzip compression EnvoyFilter
apiVersion: networking.istio.io/v1alpha3
kind: EnvoyFilter
metadata:
annotations:
description: Ensures all Sidecars are capable of returning a gzip response
name: Enable Gzip
name: enable-gzip
namespace: istio-system
spec:
configPatches:
choco list --limit-output
# Extract name and find corresponding winget package
| ForEach-Object -Parallel {
$chocoName = $_.Split('|')[0]
Get-WinGetPackage $chocoName -Count 1 |% {
@{
'chocoName' = $chocoName
'wingetPackage' = $_.Name
}
}
@kconner
kconner / macOS Internals.md
Last active March 4, 2026 17:23
macOS Internals

macOS Internals

Understand your Mac and iPhone more deeply by tracing the evolution of Mac OS X from prelease to Swift. John Siracusa delivers the details.

Starting Points

How to use this gist

You've got two main options:

" IdeaVim Wiki https://github.com/JetBrains/ideavim/wiki
" Find more examples here: https://jb.gg/share-ideavimrc
" The Essential IdeaVim Remaps https://towardsdatascience.com/the-essential-ideavim-remaps-291d4cd3971b
let mapleader=" "
""" Common settings
set showmode
set scrolloff=5
" Do incremental searching.
@getify
getify / 1-CalendarItem.js
Last active March 21, 2024 09:11
an illustration (non-trivial example) of many newer JS class features
// abstract class, not intended to be instantiated directly
class CalendarItem {
static #UNSET = Symbol("unset")
static #isUnset(v) {
return v === this.#UNSET;
}
static {
for (let [idx,msg] of [
"ID is already set.",
"ID is unset.",
@vividn
vividn / npmTimeMachine
Created December 7, 2021 14:45
npmTimeMachine
#!/usr/bin/env bash
# npmTimeMachine
# Quickly get package versions where they would have been on a certain date
# Can be useful for getting out of dependency hell by slowly working your way forward in time
# as if you had stayed up to date in the first place.
#
# The script will run and find the appropriate package versions based on public npm publish data
#
# Usage: