Skip to content

Instantly share code, notes, and snippets.

View Hainish's full-sized avatar

William Budington Hainish

View GitHub Profile

Keybase proof

I hereby claim:

  • I am hainish on github.
  • I am legind (https://keybase.io/legind) on keybase.
  • I have a public key ASDaovI-hi51KbddS-wQy0LhSRuR4YMsvBYdXBs1ptpsVwo

To claim this, I am signing this object:

#!/bin/bash
if [ "$1" == "awesome" ]; then
for x in `seq 1 8`; do
xfconf-query -c xfce4-keyboard-shortcuts -p "/xfwm4/custom/<Super><Shift>$x" -n -t string -s "move_window_workspace_${x}_key"
xfconf-query -c xfce4-keyboard-shortcuts -p "/xfwm4/custom/<Primary><Alt>KP_$x" -r
xfconf-query -c xfce4-keyboard-shortcuts -p "/xfwm4/custom/<Super>$x" -n -t string -s "workspace_${x}_key"
xfconf-query -c xfce4-keyboard-shortcuts -p "/xfwm4/custom/<Primary>F$x" -r
done
@Hainish
Hainish / pilindrome.rs
Last active November 12, 2017 19:02
pilindrome
fn main() {
let mut n = 2_i32;
let mut prob = 1_f64;
loop {
let this_prob = 1_f64 - (1_f64 / 10_f64.powi(n / 2));
prob *= this_prob;
println!("{}", 1_f64 - prob);
n += 1
}
}
@Hainish
Hainish / erdos-woods.py
Created September 15, 2016 07:21
Proof that 16 is an Erdős-Woods number
from fractions import gcd
k = 16
a = 0
while True:
ew = True
for i in xrange(a+1, a+k):
if gcd(i, a) == 1 and gcd(i, a+k) == 1:
ew = False
@Hainish
Hainish / fetchtest.go
Last active May 5, 2016 20:46 — forked from jehiah/fetchtest.go
Ensure we close connections (no KeepAlives)
package main
import (
"bufio"
"errors"
"flag"
"fmt"
"net/http"
"os"
"sync"
@Hainish
Hainish / webshims_asset_compile.rake
Created May 4, 2015 20:58
Create symlinks for non-digest webshim assets in /public/
# Rails4 doesn't create un-fingerprinted assets anymore, but we
# need a couple for webshims inclusion. Let's try to hook in and make
# symlinks.
# Lifted from team-umlaut/umlaut
require 'pathname'
# Every time assets:precompile is called, trigger webshims:create_non_digest_assets afterwards.
#!/usr/bin/python
import fileinput
import re
import subprocess
contents = ""
for line in fileinput.input():
contents = contents + line
from_address = re.match('(From )([^\s]+) ', contents).group(2)

Keybase proof

I hereby claim:

  • I am Hainish on github.
  • I am legind (https://keybase.io/legind) on keybase.
  • I have a public key whose fingerprint is 977A 04EC 512A 9D0D B4A5 6E0E CDCA E8ED 6842 C592

To claim this, I am signing this object:

@Hainish
Hainish / rake_completion.sh
Created October 2, 2012 22:11
rake bash completion
# bash completion for rake
# Installation: cat rake_completion.sh >> ~/.bashrc
# Or, maybe: cat rake_completion.sh > /etc/bash_completion.d/rake
# checksecs is the number of seconds between checking for new rake tasks
checksecs=600
export COMP_WORDBREAKS=${COMP_WORDBREAKS/\:/}
if [[ "`which md5`" != "" ]]; then