Skip to content

Instantly share code, notes, and snippets.

View jhamrick's full-sized avatar

Jessica B. Hamrick jhamrick

View GitHub Profile
@jhamrick
jhamrick / custom.css
Last active October 7, 2020 15:34
IPython customizations
/* Solarized color pallet */
.solarized.base03 { color: #002b36; }
.solarized.base02 { color: #073642; }
.solarized.base01 { color: #586e75; }
.solarized.base00 { color: #657b83; }
.solarized.base0 { color: #839496; }
.solarized.base1 { color: #93a1a1; }
.solarized.base2 { color: #eee8d5; }
.solarized.base3 { color: #fdf6e3; }
.solarized.solar-yellow { color: #b58900; }
@jhamrick
jhamrick / assign_qualification.py
Created August 4, 2014 22:11
Assign qualifications on amazon turk
#!/usr/bin/env python
from argparse import ArgumentParser, ArgumentDefaultsHelpFormatter
from boto.mturk.connection import MTurkConnection
import os
if __name__ == "__main__":
parser = ArgumentParser(
formatter_class=ArgumentDefaultsHelpFormatter)
@jhamrick
jhamrick / keep_assigning_hits.py
Created June 11, 2014 04:03
Extend HITs as assignments are completed
#!/usr/bin/env python
"""Extend HITs as assignments are completed.
If a HIT takes up a lot of bandwidth, then you may only want to have a
few workers doing it at a time. This script monitors how many
assignments are currently being worked on, and as they are completed,
extends the HIT with new assignments until a specified upper limit is
reached.
@jhamrick
jhamrick / About koans
Created April 10, 2014 05:10
This is a proof-of-concept for writing Python koans (https://github.com/gregmalcolm/python_koans) in an IPython notebook, based on the original about_strings.py (https://github.com/gregmalcolm/python_koans/blob/master/python2/koans/about_strings.py) koan.
{
"metadata": {
"name": "",
"signature": "sha256:68dde4e98d73981470a2678c04c4a291b230afea11aa551a38bac92ec836e42e"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
@jhamrick
jhamrick / enigma.py
Last active December 29, 2015 01:18 — forked from ivanov/enigma.py
# A template to demonstrate why we need to profile
# This instance written by Paul Ivanov (XXX: put your name / github id here)
import numpy as np
import random
def where_is_the_bottleneck(x):
return [random.randint(0, 100) for i in xrange(x)]
@jhamrick
jhamrick / convert_cpo_to_sso.py
Last active December 21, 2015 21:39
Convert "towers of blocks" CPO files to SSO files.
"""Convert 'tower of blocks' CPO files to SSO files."""
# Standard
import os
import re
import colorsys
import sys
import pickle
# External
from path import path
import numpy as np
@jhamrick
jhamrick / indices.ipynb
Created July 7, 2013 19:35
Timing various methods of constructing list combinations.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
def update_docstring(name, olddoc):
# make sure it has a docstring
if olddoc is None:
return None
# new docstring
prefix = "%s: " % name
if len(olddoc.split(": ")) > 1:
newdoc = prefix + olddoc.split(": ")[1]
else:
@jhamrick
jhamrick / omnigraffle-export_app_name.patch
Created April 15, 2013 23:58
omnigraffle-export: look for OmniGraffle Professional 5 if OmniGraffle 5 does not exist
From 1ebff43a47eea78643a903d85b13c91eb94d1e76 Mon Sep 17 00:00:00 2001
From: "Jessica B. Hamrick" <jhamrick@berkeley.edu>
Date: Mon, 15 Apr 2013 16:51:38 -0700
Subject: [PATCH] Look for OmniGraffle Professional 5 if OmniGraffle 5 does not
exist
---
omnigraffle_export/omnigraffle.py | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
@jhamrick
jhamrick / demise_of_for_loops.py
Created April 5, 2013 17:08
Script demonstrating speed differences between NumPy and native Python for loops.
from timeit import Timer
import numpy as np
import math
def timer(*funcs):
# find the maximum function name length
if len(funcs) > 1:
maxlen = max(*[len(func) for func in funcs])
elif len(funcs) == 1:
maxlen = len(funcs[0])