Skip to content

Instantly share code, notes, and snippets.

View asayers's full-sized avatar

Alex Sayers asayers

View GitHub Profile
@asayers
asayers / gist:4963897
Created February 15, 2013 22:00
Accepts a dict and returns a list of the keys, ordered according to their values.
def rank(hash):
ranking = []
for v in set(sorted(hash.itervalues())):
ranking.extend([key for key, val in hash.items() if val == v])
return ranking
@asayers
asayers / ssh-menu.sh
Created July 11, 2013 14:19
Uses dmenu to display hosts defined in .ssh/config. Connects to selection in a new urxvt terminal.
#! /bin/bash
nohup urxvt -e ssh $(cat ~/.ssh/config | grep "Host " | cut -d " " -f 2 | dmenu) &> /dev/null &
OK, let me try to explain the Higgs boson. To give a good explanation requires a lot of background, and I'm going to try not to half-ass it.
There are 4 forces of nature: gravity, the electroweak nuclear force, the strong nuclear force, and something called hypercharge. Electromagnetism is actually a combination of two of these forces: the electroweak and hypercharge forces, it's intimately related to the Higgs, and we'll get there.
Each force acts at a distance between particles that are charged under the relevant force by exchanging "force carriers." You can picture this as two people throwing a ball back and forth; the momentum carried by the ball will push each person around. This doesn't explain why forces can be attractive, but the picture isn't bad to start with. The important point is: a force requires a particle to carry it.
I'll pretty much ignore gravity for now, since that's a difficult one to deal with. It's a very weak force, so we can't create or see the force carriers - the gravitons - eas
@asayers
asayers / keybase.md
Last active November 18, 2016 07:13

Keybase proof

I hereby claim:

  • I am asayers on github.
  • I am asayers (https://keybase.io/asayers) on keybase.
  • I have a public key whose fingerprint is DC0A 51B9 2A28 E900 9214 D988 37FA 7503 FEA4 345D

To claim this, I am signing this object:

#!/bin/sh -eu
list_hosts () { echo "localhost"; sed -n 's/Host //p' "$HOME/.ssh/config"; }
SELECTION=$(list_hosts | dmenu -i)
case "$SELECTION" in
"localhost") exec st tmux ;;
*) exec st mosh "$SELECTION" tmux ;;
esac
#!/bin/bash -eu
LIST=${1:-todo.txt}
pushd "$HOME/.todo"
git pull
vim "$LIST"
LC_ALL=C sort "$LIST" -o "$LIST"
git add "$LIST"
git commit -m "Update list $LIST"
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
-- timeOfDay (1:20) => TimeOfDay 1 20 0
-- timeOfDay (1:20:36) => TimeOfDay 1 20 36000000
-- timeOfDay (1:20:36.1) => TimeOfDay 1 20 36100000
timeOfDay :: [TimePart] -> TimeOfDay
timeOfDay xs = undefined
newtype TimePart = TimePart Int deriving (Num)
@asayers
asayers / clippy_lint.sh
Last active December 31, 2018 19:10
Mangles the output of `cargo clippy` into GCC lint format, for consumption by vim/kak/etc.
cargo clippy 2>&1 | gawk 'match($0, / --> (.*)/, arr) { print arr[1] " " prev } { prev=$0 }'