Skip to content

Instantly share code, notes, and snippets.

@calebperkins
calebperkins / keybase.md
Created December 6, 2016 19:09
Keybase

Keybase proof

I hereby claim:

  • I am calebperkins on github.
  • I am calebperkins (https://keybase.io/calebperkins) on keybase.
  • I have a public key ASBoBi9gFBaGiJ7B8t8Kh1gCs-KowURv9jsWf5SwCgucvgo

To claim this, I am signing this object:

@calebperkins
calebperkins / gist:c4f810acbf55a1d767e3
Created December 4, 2014 01:46
Minimum transactions
import collections
# input: list of transactions in form (a, b, amount) corresponding to "a owes b amount"
def min_transactions(transactions):
# build map of users to change in wealth
wealth = collections.defaultdict(int)
for lendee, lender, amount in transactions:
wealth[lendee] -= amount
wealth[lender] += amount
@calebperkins
calebperkins / safari-cache
Created October 13, 2013 02:11
View all the images stored in Safari's cache.
#!/bin/sh
# View all the images stored in Safari's cache.
echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\"" > ~/Desktop/cache.html
echo " \"http://www.w3.org/TR/html4/strict.dtd\">" >> ~/Desktop/cache.html
echo "<html lang=\"en\">" >> ~/Desktop/cache.html
echo " <head>" >> ~/Desktop/cache.html
echo " <meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\">" >> ~/Desktop/cache.html
echo " <title>Cached Images</title>" >> ~/Desktop/cache.html