Skip to content

Instantly share code, notes, and snippets.

View goldsmith's full-sized avatar

Jon Goldsmith goldsmith

View GitHub Profile
This file has been truncated, but you can view the full file.
(dp1
(I32
I54
tp2
(lp3
(I29
cnumpy.core.multiarray
scalar
p4
(cnumpy
import cPickle as pickle
import heapq
from itertools import combinations, izip
import os
import numpy as np
from matplotlib import pyplot as plt
from matplotlib import image as mpimg
import networkx as nx
import cPickle as pickle
import heapq
from itertools import combinations, izip
import os
import numpy as np
from matplotlib import pyplot as plt
from matplotlib import image as mpimg
import networkx as nx
@goldsmith
goldsmith / Gruntfile.js
Created August 15, 2014 22:06
PurgeCDN Grunt task
grunt.registerTask('purgecdn', 'Purge MaxCDN pull zone', function() {
var done = this.async();
grunt.config.requires('maxcdn');
var maxcdn = grunt.config('maxcdn');
var api = new MaxCDN(
maxcdn.companyAlias, maxcdn.consumerKey, maxcdn.consumerSecret
);
@goldsmith
goldsmith / groupby_anagram.py
Last active August 29, 2015 14:03
Write a program that takes a list of words and groups together the anagrams.
"""
Write a program that takes a list of words and groups together the anagrams.
"""
from collections import Counter, defaultdict
def group_by(col, hashfn=None):
if not hashfn:
hashfn = hash # builtin hash
group = defaultdict(list)
@goldsmith
goldsmith / keybase.md
Created May 14, 2014 23:22
Keybase identity proof

Keybase proof

I hereby claim:

  • I am goldsmith on github.
  • I am goldsmith (https://keybase.io/goldsmith) on keybase.
  • I have a public key whose fingerprint is 52AD 06AE 2EA9 2955 75C6 1BFD DE6B 00FC B529 3513

To claim this, I am signing this object:

@goldsmith
goldsmith / numpy_os_x_10_9.sh
Last active January 6, 2024 07:25
How to install Numpy and Scipy on Mac OS X Mavericks (10.9) using Pip.
# set up flags for Numpy C extentions compiling
export CFLAGS="-arch i386 -arch x86_64"
export FFLAGS="-m32 -m64"
export LDFLAGS="-Wall -undefined dynamic_lookup -bundle -arch i386 -arch x86_64"
export CC=gcc-4.2
export CXX="g++ -arch i386 -arch x86_64"
pip install numpy
# success!
@goldsmith
goldsmith / postgres_path.sh
Created October 29, 2013 23:42
A short shell program to add all Postgres commands in the default Mac OS X PostgreSQL to your $PATH. This probably will be done automatically, so check before running it.
# replace 9.3 with whatever version of PostgreSQL you have installed
# you can also link the commands to /usr/bin/ if you prefer
# before
########
# $ psql
# -bash: psql: command not found
for i in /Library/PostgreSQL/9.3/bin/*; do
t=${i##*/};
@goldsmith
goldsmith / python_mavericks_guide.sh
Last active June 3, 2020 12:18
When I upgraded my Mac to OS X Mavericks, a lot of utilities (like Python, virtualenv, Xcode) broke, and it was pretty stressful trying to get it all set back up. Hopefully this guide can spare you some of that pain.Note: I'm by no means a Linux or Mac expert, so please fork and let me know if anything is redundant, incorrect, or missing!
# A guide to prevent pain and suffering while upgrading to OS X Mavericks
# This will vary greatly depending on system set up, so read the instructions carefully
# Back up Virtulenvs
####################
# Very important!
# For each virtualenv you have, run "pip freeze > requirements.txt" while in the activated virtualenv
# in order to prevent loss of dependencies during the upgrade.
@goldsmith
goldsmith / labrinth.py
Created August 20, 2013 04:49
Short python program that modifies and calls itself.
import os, subprocess
ITERATIONS = 5
def transform(line):
return "ITERATIONS = " + str(int(line.split()[2]) - 1) + "\n" if line.startswith("ITERATIONS") else line
with open(os.path.abspath(__file__), "r+") as f:
new = ''.join(map(transform, f.readlines()))
f.seek(0)