Skip to content

Instantly share code, notes, and snippets.

View michaelsproul's full-sized avatar

Michael Sproul michaelsproul

View GitHub Profile
@michaelsproul
michaelsproul / caddy.conf
Created January 16, 2018 11:45
Caddy Supervisord
[program:caddy]
command=/home/caddy/sproul.xyz/start.sh
directory=/home/caddy/sproul.xyz
user=caddy
environment=HOME="/home/caddy",USER="caddy"
@michaelsproul
michaelsproul / wa-results.txt
Created July 15, 2017 01:25
Western Australia Senate Results (as of 15/07/2017)
=== Elected ===
Mathias CORMANN (Liberal) [521540 votes]
Sue LINES (Australian Labor Party) [379352 votes]
Rachel SIEWERT (The Greens (WA)) [139395 votes]
Michaelia CASH (Liberal) [416033 votes]
Glenn STERLE (Australian Labor Party) [272937 votes]
Dean SMITH (Liberal) [310808 votes]
Patrick DODSON (Australian Labor Party) [170055 votes]
Linda REYNOLDS (Liberal) [206560 votes]
Chris BACK (Liberal) [105249 votes]
@michaelsproul
michaelsproul / bitcoin-data-dir.md
Last active July 3, 2017 08:34
Seamlessly move Bitcoin data directory

I just moved my bitcoin data out of ~/.bitcoin by using the -datadir flag to bitcoind.

$ bitcoind -daemon -datadir=/external-drive/btc

However, I found that I now needed to pass -datadir=/external-drive/btc to bitcoin-cli in order for the passwordless authentication to succeed.

Rather than passing the flag every time, you can also change where bitcoind will stash the authentication cookie (which is what enables passwordless auth). Moving it back to ~/.bitcoin/.cookie does the trick, like so:

@michaelsproul
michaelsproul / btc.ksy.yaml
Last active November 9, 2017 07:44
Kaitai Struct parser for Bitcoin Transactions
# Bitcoin Transaction
# Spec: https://en.bitcoin.it/wiki/Transaction
meta:
id: btc_txn
endian: le
file-extension: txn
seq:
# Bitcoin version, usually 1.
- id: version
type: u4
@michaelsproul
michaelsproul / zfsautoimport.plist
Last active April 2, 2017 00:54
Slightly broken script to automatically import ZFS pools from an external HDD on OS X
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC -//Apple Computer//DTD PLIST 1.0//EN http://www.apple.com/DTDs/PropertyList-1.0.dtd >
<plist version="1.0">
<dict>
<key>Label</key>
<string>zfsautoimport</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/bin/zpool</string>
<string>import</string>
@michaelsproul
michaelsproul / hack_refind.md
Created February 11, 2017 07:22
Installing rEFInd from macOS Sierra recovery mode

Installing rEFInd from macOS Sierra recovery mode

Today I installed Linux on my Mac, on an external hard-drive. I encountered only one undocumented hitch, which I'm detailing here for my own reference and in case anyone else runs into it.

Basically, the steps I followed were:

  1. Boot Devuan installer from USB
  2. Install Devuan to external disk (I went with the "use the whole disk" option)
  3. Try to boot Devuan by holding Alt key... doesn't work... search a little, work out that I need the rEFInd bootloader
@michaelsproul
michaelsproul / csv_impl_trait.rs
Created January 8, 2017 01:57
impl Iterator and csv::Reader don't play nice
pub fn parse_preferences_file<T: Read>(reader: &mut csv::Reader<T>, groups: &[Group],
candidates: &[CandidateId], constraints: &Constraints)
-> impl Iterator<Item=IOBallot>> {
reader.decode::<PrefRow>()
.map(|raw| parse_single_ballot(raw, groups, candidates, constraints))
)
}
@michaelsproul
michaelsproul / family_first.md
Last active November 19, 2016 10:54
What if Family First weren't part of the SA senate election?

Here's the result when Family First ARE included in the count:

  1. Simon BIRMINGHAM (Liberal)
  2. Penny WONG (Australian Labor Party)
  3. Cory BERNARDI (Liberal)
  4. Nick XENOPHON (Nick Xenophon Team)
  5. Don FARRELL (Australian Labor Party)
  6. Anne RUSTON (Liberal)
  7. Stirling GRIFF (Nick Xenophon Team)
  8. Alex GALLACHER (Australian Labor Party)
@michaelsproul
michaelsproul / insert_after_main.py
Created February 16, 2016 05:34
Insert code after C main function...
#!/usr/bin/env python3
# You probably shouldn't use this, it is guaranteed awful... Although it did work for me...
import re
import os
import sys
MAIN_REGEX = re.compile(rb".*int.*main.*\(.*int.*argc.*\).*")
BRACE_REGEX = re.compile(rb".*{.*")