Skip to content

Instantly share code, notes, and snippets.

View chuckadams's full-sized avatar

Chuck Adams chuckadams

View GitHub Profile
@chuckadams
chuckadams / slurp_npm.py
Created April 25, 2016 18:25
Slurp npm registry into a plain text format
#!/usr/bin/env python
import sys
import urllib
import ijson
if len(sys.argv) < 2:
url = 'http://registry.npmjs.org/-/all'
else:
@chuckadams
chuckadams / slurp_npm.py
Created May 6, 2016 19:52
read the npm database and shove it into sqlite. requires ijson (pip install --user ijson)
#!/usr/bin/env python
from __future__ import print_function
import argparse
import logging
import os, os.path
import re
import sqlite3
import sys
@chuckadams
chuckadams / .emacs
Last active December 4, 2018 13:01
My .emacs file
;;
;; .emacs file of Chuck Adams <cja987@gmail.com>
;;
;; Anyone is free to use any part of this file, and I try to keep it
;; helpfully commented, but they should know that I haven't kept
;; portability foremost. It's really only designed to work on my
;; machine, with its own set of customizations. Caveat Hacker.
;;
;;;;;;;;;;;;;;;; First Things First
@chuckadams
chuckadams / ic_behavior.js
Created April 22, 2020 18:12
JavaScript V8 inline cache behavior differences
main()
function main() {
monomorphic()
polymorphic()
megamorphic()
}
function bench(label, people) {
#!/bin/sh
if [ -z $1 ]; then
stamp=$(mktemp /tmp/stamp.XXXXXXXX)
trap 'rm $stamp' EXIT
emacs $HOME/bin
find $HOME/bin/ -type f -cnewer $stamp | xargs -r chmod +x
exit 0
fi
@chuckadams
chuckadams / singleton.ts
Created May 21, 2020 17:44
dependent types in typescript
type Maybe<a> = { val: a, tag = "some" } | { tag: "none" }
function isSome<A, Ma: Maybe<a>>(m: Ma): Ma["val"] is A {
return m.tag == "some";
}
@chuckadams
chuckadams / tricks.ts
Last active September 13, 2020 17:52
Stupid Typescript tricks
//// Exact types
type Exact<TExpected, TActual extends TExpected> = TExpected extends TActual ? TExpected: never;
type Foo = { x: number };
function acceptT<T extends Foo>(input: Exact<Foo, T>) {}
//// JSON Schema Type
type JSONSchema<T> = T extends number
? {
@chuckadams
chuckadams / gist:16ab2b111f68025b5e6894dbea4bcde5
Created January 1, 2023 20:41
docker-compose with caddyfile
version: '3.4'
services:
caddy:
image: caddy:2
restart: "unless-stopped"
ports:
- "80:80"
- "443:443"
volumes:
- .docker/caddy/Caddyfile:/etc/caddy/Caddyfile
@chuckadams
chuckadams / .inputrc
Created August 19, 2023 02:14
minimal sane .inputrc
"\e[A": history-search-backward
"\e[B": history-search-forward
set show-all-if-ambiguous on
set completion-ignore-case on
@chuckadams
chuckadams / hyperkey.ahk
Created August 19, 2023 04:53
hyper key for autohotkey
#NoEnv ; recommended for performance and compatibility with future
autohotkey releases.
#UseHook
#InstallKeybdHook
#SingleInstance force
SendMode Input