Skip to content

Instantly share code, notes, and snippets.

Michael Sproul michaelsproul

Block or report user

Report or block michaelsproul

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
michaelsproul /
Created Sep 3, 2019
Callin' a generic function with different type arguments based on runtime values
macro_rules! type_dispatch {
[ $value:expr => primitive_type ] $($rest:tt)*) => {
match $value {
"bool" => type_dispatch!($function, ($($arg),*), $base_ty, <$($param_ty,)* bool>, $($rest)*),
"uint8" => type_dispatch!($function, ($($arg),*), $base_ty, <$($param_ty,)* u8>, $($rest)*),
"uint16" => type_dispatch!($function, ($($arg),*), $base_ty, <$($param_ty,)* u16>, $($rest)*),
michaelsproul /
Last active May 7, 2019
Experiments with generic-array and BeaconState
use generic_array::*;
use std::marker::PhantomData;
use typenum::Unsigned;
use typenum::{U1024, U4096, U512, U8192};
type Hash = [u8; 32];
type Crosslink = u64;
trait FixedArray<T> {
// Not using `std::Default` for brevity.
View excel_tax.xlsx
IF(EXACT($C12, "Sell"), IF($E12 - $I12 < VLOOKUP($K12, $A$1:$N$146, 5) - SUMIF($H$2:$H11, $H12, $I$2:$I11) - SUMIF($K$2:$K11, $K12, $L$2:$L11), $E12 - $I12, VLOOKUP($K12, $A$1:$N$146, 5) - SUMIF($H$2:$H11, $H12, $I$2:$I11) - SUMIF($K$2:$K11, $K12, $L$2:$L11)), "")
michaelsproul /
Last active Jul 19, 2018
Notes on Matrix <-> Slack Integration
michaelsproul /
Last active Jul 16, 2018
Find types of caps used in a capDL spec
grep '.type = CDL_' capdl_spec.c | sed 's/.*\(\.type = CDL_[[:alnum:]]*\).*/\1/' | sort | uniq
michaelsproul / constraints.txt
Last active Feb 18, 2018
Populus and Vyper setup
View constraints.txt
View caddy.conf
michaelsproul / wa-results.txt
Created Jul 15, 2017
Western Australia Senate Results (as of 15/07/2017)
View wa-results.txt
=== 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 /
Last active Jul 3, 2017
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 / btc.ksy.yaml
Last active Nov 9, 2017
Kaitai Struct parser for Bitcoin Transactions
View btc.ksy.yaml
# Bitcoin Transaction
# Spec:
id: btc_txn
endian: le
file-extension: txn
# Bitcoin version, usually 1.
- id: version
type: u4
You can’t perform that action at this time.