Skip to content

Instantly share code, notes, and snippets.

View silentbicycle's full-sized avatar

Scott Vokes silentbicycle

  • Fastly (@fastly)
  • Grand Rapids, MI
View GitHub Profile
@silentbicycle
silentbicycle / space_padness.c
Last active April 19, 2021 17:33
uninitialized memory caused by struct padding
$ cat space_padness.c
/*
* Copyright (c) 2016 Scott Vokes <vokes.s@gmail.com>
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
@silentbicycle
silentbicycle / shift.py
Created January 17, 2015 22:07
shift-and and shift-or in python
# shift-and / shift-or
def to_bin(n, width=32):
"Pad a binary number to WIDTH bits wide"
s = bin(n).replace("0b", "")
return (("%0" + str(width) + "d") % int(s))
# pg 20
def shift_and(pattern, text, trace=False):
m = len(pattern)
@silentbicycle
silentbicycle / gist:d8278c49599e3cd68042
Created November 12, 2014 14:26
ugly GNU make hackery
include fake_init
all: actual_target
fake_init:
@echo run before everything else
actual_target:
@echo real work happens here
@silentbicycle
silentbicycle / pirate.cow
Created July 14, 2014 22:43
pirate.cow
$eye = chop($eyes);
$the_cow = <<"EOC";
$thoughts A__^
$thoughts ($eye#)\\_______
(__)\\ )\\/\\
$tongue ||----w |
J| |V
EOC
@silentbicycle
silentbicycle / cable_clip.scad
Created March 25, 2014 23:55
3D-printable cable clip
USB_A_w = 12; // USB-A clip width
h = 2;
th = 3;
w = 73.25;
d = 30;
ith = .4*d - th;
union() {
// end
@silentbicycle
silentbicycle / linear-time-indexing-sort.c
Last active January 3, 2016 01:29
simple linear-time sorting algorithm, using a flattened linked-list index
/*
* Copyright (c) 2014 Scott Vokes <vokes.s@gmail.com>
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
@silentbicycle
silentbicycle / handwarmer.c
Created January 2, 2014 17:53
handwarmer.c
/*
* Copyright (c) 2014 Scott Vokes <vokes.s@gmail.com>
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
@silentbicycle
silentbicycle / gist:7853896
Last active December 30, 2015 16:19
Setlist for The Mountain Goats at the Ladies Literary Club, Grand Rapids, MI 2009-11-04
Setlist for The Mountain Goats at the Ladies Literary Club,
Grand Rapids, MI, 2009-11-04
https://dl.dropboxusercontent.com/u/76615635/tmg-2009-11-04-GRMI-LLC.mp3
Handball
Old College Try
Psalms 40:2
Has Thou Considered the Tetrapod
Genesis 3:23
Genesis 30:3
@silentbicycle
silentbicycle / pirate.cow
Created September 9, 2013 22:02
Pirate cow, for cowsay(1). Goes in /usr/local/share/cows/ or wherever your cowsay install puts it.
$eye = chop($eyes);
$the_cow = <<"EOC";
$thoughts A__^
$thoughts ($eye#)\\_______
(__)\\ )\\/\\
$tongue ||----w |
J| |V
EOC
@silentbicycle
silentbicycle / rfcify
Created August 12, 2013 18:47
If you MUST sound like an IETF RFC (using cat is RECOMMENDED)
#!/bin/sh
sed -e "s/must/MUST/" \
-e "s/must not/MUST NOT/" \
-e "s/required/REQUIRED/" \
-e "s/shall/SHALL/" \
-e "s/shall not/SHALL NOT/" \
-e "s/should/SHOULD/" \
-e "s/should not/SHOULD NOT/" \
-e "s/recommended/RECOMMENDED/" \
-e "s/may/MAY/" \