Skip to content

Instantly share code, notes, and snippets.

View jonhoo's full-sized avatar
🤦‍♂️
Permanent 418 status code.

Jon Gjengset jonhoo

🤦‍♂️
Permanent 418 status code.
View GitHub Profile
@jonhoo
jonhoo / userChrome.css
Created June 5, 2018 05:34
Firefox tabs-on-bottom
@namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul");
/* tabs on bottom of window */
#navigator-toolbox { -moz-box-ordinal-group: 10; }
#TabsToolbar { -moz-box-ordinal-group: 10; }
#PopupAutoCompleteRichResult {
margin-top: -35vh;
/*
position: fixed;
bottom: 74px;
@jonhoo
jonhoo / blacklist-ca-certs.sh
Created May 12, 2018 18:46
Scripts for managing SSL blacklist
#!/usr/bin/bash
echo "==> Clear blacklist"
sudo rm /etc/ca-certificates/trust-source/blacklist/*.pem
echo "==> Regenerate CA list"
sudo update-ca-trust
echo "==> Blacklisting all"
for f in /etc/ca-certificates/extracted/cadir/*.pem; do
sudo cp "$f" "/etc/ca-certificates/trust-source/blacklist/$(basename "$f")"
done
@jonhoo
jonhoo / raft.go
Created March 16, 2016 22:33
Raft pseudocode
// This file gives pseudocode for the complete operation of a Raft peer,
// including the fast backtracking optimization. The implementation here is
// currently 0-indexed, as this simplifies the implementation in many cases.
// This implementation also does not discuss locks at all, which will be vital
// in any real implementation.
//
// ============================================================================
// The following data needs to be persisted
// ============================================================================
@jonhoo
jonhoo / go-test-many.sh
Last active October 19, 2023 16:33
Script for running go tests many times in parallel, printing the current status, and logging errors
#!/bin/bash
#
# Script for running `go test` a bunch of times, in parallel, storing the test
# output as you go, and showing a nice status output telling you how you're
# doing.
#
# Normally, you should be able to execute this script with
#
# ./go-test-many.sh
#
@jonhoo
jonhoo / README.md
Last active July 19, 2021 10:49
Distributed RWMutex in Go
@jonhoo
jonhoo / README.md
Created April 15, 2015 21:06
Go slices and `interface{}`s

When passing Go slices through interface{} values, beware that this slows your application down. If possible, you should instead be passing around pointers to slices, and dereference them after the cast:

$ go test -c
$ ./x.test -test.bench . -test.run Benchmark -test.benchtime 3s
BenchmarkInterfaceSlice		30000000	        148 ns/op
BenchmarkInterfaceSlicePtr	300000000	       14.0 ns/op
$ go tool pprof -text -cum x.test slice.out | grep -vE 'testing|goexit|Benchmark'
4420ms of 4610ms total (95.88%)
Dropped 16 nodes (cum <= 23.05ms)
@jonhoo
jonhoo / PKGBUILD
Created February 26, 2015 15:57
Updated PKGBUILD for source-code-pro-1.017R
# Maintainer: Manuel Mendez <mmendez534@gmail.com>
# Contributor: Jon Gjengset <jon@tsp.io>
pkgname=source-code-pro-fonts-powerline
pkgver=1.017
pkgrel=3
pkgdesc="A set of monospaced fonts (TTF & OTF) designed for coding environments"
arch=('any')
license=('custom:OFL')
url='http://sourceforge.net/projects/sourcecodepro.adobe/'
@jonhoo
jonhoo / PKGBUILD
Created January 13, 2015 21:28
mutt-like PKGBUILD for mutt-slang
# $Id: PKGBUILD 207672 2014-03-13 00:02:32Z bisson $
# Maintainer: Sean Greenslade <sean at seangreenslade dot com>
# Contributor: tobias [tobias [at] archlinux.org]
# Contributor: Gaetan Bisson <bisson@archlinux.org>
pkgbase=mutt
pkgname=${pkgbase}-slang
pkgver=1.5.23
pkgrel=2
pkgdesc='Small but very powerful text-based mail client'
@jonhoo
jonhoo / README.md
Created January 8, 2015 22:50
Plot commit activity across all local git repositories

These scripts will find all git repositories on the local machine, find all commits made by some user (specified as arguments to find-commits), and plot the number of commits, lines added, and lines removed over time. Commits that add or remove over 10000 lines will be ignored (for huge data files and such).

To run:

$ ./find-commits.sh jon@thesquareplanet.com jon@tsp.io > commits.txt
$ cat commits.txt | ./draw-commits.sh
@jonhoo
jonhoo / laundry.sh
Last active August 29, 2015 14:06
Sidney Pacific Laundryview CLI
#!/bin/bash
if [[ $# -ne 1 ]]; then
echo "$0 <machine>"
exit 1
fi
rem=""
mtype=""
state=""
state() {