Skip to content

Instantly share code, notes, and snippets.

View asauber's full-sized avatar

Andrew Sauber asauber

View GitHub Profile
@asauber
asauber / goose-house-logo.svg
Last active October 28, 2016 02:36
Goose House Logo
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@asauber
asauber / decrypt.py
Created July 15, 2016 19:57
Decrypt a jrnl journal
#!/usr/bin/env python3
from Crypto.Cipher import AES
import hashlib
import sys
import argparse
import getpass
parser = argparse.ArgumentParser()
parser.add_argument("filepath", help="journal file to decrypt")
@asauber
asauber / gist:b597f95dc1bb90d53892fee078b68ef1
Created April 6, 2016 19:11
delete all keys from memcache that match a substring
mcinspect delete $(mcinspect list | grep <substring> | awk -F'|' '{ print $4 }')
@asauber
asauber / read_ints_into_list_append.py
Created May 26, 2015 15:07
Fast way to read integers from file in Python
from datetime import datetime
import fileinput
start = datetime.now()
L = []
for line in fileinput.input():
L.append(int(line))
print 'time to read 8000000 ints into list using append: ', datetime.now() - start
@asauber
asauber / ds
Last active August 29, 2015 14:20 — forked from mlegenhausen/ds
#!/bin/sh
find $1 -type f -print0 | xargs -0 stat -f'%z' | awk '{b+=$1} END {print b}' | awk '{ sum=$1 ; hum[1024**3]="GB";hum[1024**2]="MB";hum[1024]="KB"; for (x=1024**3; x>=1024; x/=1024){ if (sum>=x) { printf "%.2f %s\n",sum/x,hum[x];break } }}'
@asauber
asauber / oscillator.js
Last active August 29, 2015 14:15
demonstration of numeric integration with animation
function simulate() {
var theCanvas = document.getElementById("the-canvas");
var theContext = theCanvas.getContext('2d');
theContext.translate(theCanvas.width / 2, theCanvas.height / 2);
var radius = 60;
var amplitude = theCanvas.height / 2 - radius - 10;
var sinBall = {
x: 0,
@asauber
asauber / subsetsum.cpp
Last active August 29, 2015 14:12
Dynamic Programming Example (C++)
/*
How many ways can the set of numbers from 1 to N be partitioned into two
subsets in such a way that the sum of both subsets is equal?
Hint 1. For each partitioning, the sum of each subset will be the same value
Hint 2. This value is the sum from 1 to N divided by 2. (N * (N + 1) / 2) / 2
Hint 3. The problem has been reduced to, "How many subsets of a given set sum
to a specific value?". Note that once we have this number of subsets, we
@asauber
asauber / subsetsum.py
Created December 28, 2014 05:59
Dynamic Programming Example
'''
How many ways can the set of numbers from 1 to N be partitioned into two
subsets in such a way that the sum of both subsets is equal?
Hint 1. For each partitioning, the sum of each subset will be the same value
Hint 2. This value is the sum from 1 to N divided by 2. (N * (N + 1) / 2) / 2
Hint 3. The problem has been reduced to, "How many subsets of a given set sum
to a specific value?". Note that once we have this number of subsets, we
@asauber
asauber / Makefile
Last active August 29, 2015 14:11
World Wide Daemon
CC = gcc
CFLAGS = -Wall -O3 --std=c11
CDEBUGFLAGS = -Wall -O0 --std=c11 -g
wwd: main.c
$(CC) $(CFLAGS) -o $@ $<
@asauber
asauber / download_floss_weekly.sh
Created December 10, 2014 15:26
Download all FLOSS Weekly episodes, in reverse order, skipping those that are already downloaded
#!/bin/bash
wget_floss_n () {
floss_number=$(printf "%04d\n" $1)
wget -nc http://www.podtrac.com/pts/redirect.mp3/twit.cachefly.net/audio/floss/floss$floss_number/floss$floss_number.mp3
}
latest_show=$(wget http://twit.tv/show/floss-weekly -O - | grep "show-title" | egrep -o "\d+" | sort -ru | head -n 1)
for n in $(seq $latest_show -1 1)