Skip to content

Instantly share code, notes, and snippets.

cagerton / diff.ts
Created Sep 24, 2020
Git based diff utility for NodeJS
View diff.ts
import {join} from 'path';
import fs from "fs";
import os from "os";
import {spawnSync} from "child_process";
* Use the local `git` executable to render a diff between two strings.
* This is intended for test/development environments. Consider using
* `jsdiff` if you need to compare potentially malicious strings.
cagerton /
Created Jun 10, 2020
Test Certificate Generator


This is handy for genrating transient keys and certificates used for unit tests.

Notable files generated by running

  • ca.pem - This is the root CA which should be added to the test client's trust store.
  • server.key - This is your server's secret key.
  • server.pem - This is your server's certificate, good for and *
  • expired.pem - This is an expired version of the server certificate.
  • ca - This directory contains the ca secrets and internals.
cagerton / yolo_redis.ts
Created Jan 27, 2020
Redis cluster demo example
View yolo_redis.ts
import {spawn} from 'child_process';
import fs from 'fs';
import os from 'os';
function mkConfigs(port: number) {
return `
port ${port}
cluster-enabled yes
cluster-config-file nodes-${port}.conf
cagerton /
Created May 15, 2019
Simple example for using udmx to control a monoprice rgbaw-uv dmx light
Simple rgb color fade tested with the monoprice rgbawuv
Requires python3.7 for the async coroutine syntax; should be trivial to backport though
cagerton / no_push_f_master.rb
Last active Jan 11, 2020
pre receive hook
View no_push_f_master.rb
#!/usr/bin/env ruby
# pre-receive hook to block 'push -f' on master
# For Phabricator, save this as:
# $REPO/hooks/pre-receive-phabricator.d/no_push_f_master.rb
# Remember to chmod +x
# Ref:
args = STDIN.readline.chomp.split(" ")
$oldrev, $newrev, $refspec = args
cagerton /
Created Aug 6, 2014
this saves 3 months of vpn setup
from flask import Flask, redirect, render_template, url_for, request
from flask_bootstrap import Bootstrap
import redis
import json
app = Flask(__name__)
r = redis.Redis()
cagerton /
Last active Aug 29, 2015
Simple script to fetch an ssh host key.
#!/usr/bin/env python2.7
"""Usage: <host> [<port>]"""
import paramiko, docopt
opt = docopt.docopt(__doc__)
host = opt['<host>']
port = int(opt['<port>'] or 22)
t = paramiko.Transport((host, port))
cagerton / hijack_touch.js
Created Dec 13, 2013
Generate click events on touchstart; kill the mouse events that the browser cooks 200+ms afterwards.
View hijack_touch.js
(function touchJack(){
var lastTouch = 0;
document.addEventListener("touchstart", function(e){
lastTouch =;
var touch = e.touches[0],
synth_event = document.createEvent("MouseEvents");
synth_event.initMouseEvent("click", true, true, window,
0, touch.screenX, touch.screenY, touch.clientX, touch.clientY,
View packages.sls
# Postgres 9.3 packages salt state
# Created 9/9/13
# author: Micah Hausler,
cagerton /
Last active Dec 25, 2015
Little python3.3 script to show information about ssh public keys from key files or known_hosts files.

SSH key info for pubkeys, known_hosts, and github users

Usage: hosts [<FILE>] key [<FILE>...] github <user>

$ github cagerton