Skip to content

Instantly share code, notes, and snippets.

View saulshanabrook's full-sized avatar
🏊

Saul Shanabrook saulshanabrook

🏊
View GitHub Profile
@saulshanabrook
saulshanabrook / shelve_recursive_memoization.py
Created July 24, 2014 18:17
recursive persistent memoization with python
import shelve
import functools
def cache(filename):
def decorating_function(user_function):
def wrapper(*args, **kwds):
key = str(hash(functools._make_key(args, kwds, typed=False)))
@saulshanabrook
saulshanabrook / Dockerfile
Last active August 29, 2015 14:04
docker python unicode read bug
FROM python:3
ADD . /code/
WORKDIR /code/
# ENV LANG C.UTF-8 if this is uncluded, no error
RUN python open_file.py
@saulshanabrook
saulshanabrook / README.md
Created October 13, 2014 14:53
Dynamic DNS on Cloudflare

Sets a cloudflare subdomain to your IP every 15 minutes.

$ brew install jq
$ crontab -e
# add this ->
30 * * * * /Users/canada/Documents/update-ip.sh
@saulshanabrook
saulshanabrook / analysis.ipnb
Last active August 29, 2015 14:11
Colgate Sounds Scape Analysis
This file has been truncated, but you can view the full file.
{
"metadata": {
"name": "",
"signature": "sha256:7be03c2818d177cfe7b64eb1a0a1b7b108fb5b5a5764e3f27e4261fe691ac9ed"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
Operations to perform:
Synchronize unmigrated apps: floppyforms, rest_framework_bulk, admin_export, impersonate, rest_framework, localflavor, rosetta, django_filters, naviance_sso, dajax, ldap_groups, customers, grappelli, compressor, djangobower, raven_compat, dajaxice, pagination, ckeditor, scaffold_report, autocomplete_light, djcelery, widget_tweaks, responsive_dashboard, massadmin, constance
Apply all migrations: administration, benchmark_grade, counseling, discipline, attendance, schedule, custom_field, contenttypes, simple_import, sis, sessions, reversion, work_study, auth, admissions, report_builder, standard_test, engrade_sync, database, admin, alumni, grades, default, benchmarks, volunteer_track
Synchronizing apps without migrations:
Creating tables...
Creating table ldap_groups_ldapgroup_groups
Creating table ldap_groups_ldapgroup
Creating table celery_taskmeta
Creating table celery_tasksetmeta
Creating table djcelery_intervalschedule
@saulshanabrook
saulshanabrook / slides.md
Last active August 29, 2015 14:14
Colgate CS Tea Talk

class: center, middle

Scraping Colgate for fun and for profit


Problem


from visual import *
c = 3e08
v = vector(0.5*c, 0, 0.9*c)
t = 0
dt = 1e-9
gamma_x = 1/sqrt(1 - (v.x/c)**2)
gamma_y = 1/sqrt(1 - (v.y/c)**2)
gamma_z = 1/sqrt(1 - (v.z/c)**2)
#function to increase resolution of shape from ints to floats from http://stackoverflow.com/a/477610
def drange(start, stop, step):
@saulshanabrook
saulshanabrook / find_non_unique.py
Last active August 29, 2015 14:16
Looks for all instances of a model with certain field duplicated
def find_non_unique(model, *fields):
from collections import defaultdict
d = defaultdict(list)
for instance in model.objects.all():
d[tuple(getattr(instance, field) for field in fields)].append(instance)
return filter(lambda dups: len(dups)>1, d.values())
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.