Skip to content

Instantly share code, notes, and snippets.

View jdunck's full-sized avatar

Jeremy Dunck jdunck

View GitHub Profile
@jdunck
jdunck / shell.py
Created April 13, 2012 18:15
unpickleable why?
import wat
from pickle import dumps
try:
wat.b()
except Exception, the_exc:
exc = the_exc
print dumps(exc)
def get_access_token_from_code(code):
"""
Given a code retrieved from a signed request (*not* from a callback
querystring), resolve the access token.
"""
try:
return _get_access_token_from_code(code)
except GraphAPIError:
time.sleep(1)
return _get_access_token_from_code(code)
Running migrations for notifications:
- Migrating forwards to 0005_auto__del_deliveryfrequency__add_deliveryfrequencyconfiguration.
> notifications:0005_auto__del_deliveryfrequency__add_deliveryfrequencyconfiguration
DEBUG 2012-05-01 17:17:09,394 generic south execute "DROP TABLE `notifications_deliveryfrequency` CASCADE;" with params "[]"
DEBUG 2012-05-01 17:17:09,396 generic south execute "CREATE TABLE `notifications_deliveryfrequencyconfiguration` (`id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY, `create_ts` datetime NOT NULL DEFAULT '2012-05-01 17:17:09', `modify_ts` datetime NOT NULL DEFAULT '2012-05-01 17:17:09', `frequency` smallint UNSIGNED NOT NULL UNIQUE, `last_delivered_ts` datetime NOT NULL DEFAULT '2000-01-01 00:00:00');" with params "[]"
DEBUG 2012-05-01 17:17:09,396 generic south execute "SET FOREIGN_KEY_CHECKS=1;" with params "[]"
DEBUG 2012-05-01 17:17:09,396 generic south execute "DROP TABLE `notifications_deliveryfrequency` CASCADE;" with params "[]"
DEBUG 2012-05-01 17:17:09,410 generic
class BasicItemFallback(object):
def __init__(self, property_name):
self.property_name = property_name
def __get__(self, obj, type=None):
return getattr(obj.item, self.property_name)
def __set__(self, obj, value):
# or maybe raise?
setattr(obj.item, self.property_name)
if settings.IS_DEV or settings.IS_TEST:
KeyValueStore = RedisKeyValueStore
else:
KeyValueStore = DynamoKeyValueStore
@jdunck
jdunck / suspend-disk.sh
Created June 26, 2012 20:07
Tweak mac suspend behavior.
#!/bin/bash
sudo pmset -a hibernatemode 3
@jdunck
jdunck / gist:3020950
Created June 29, 2012 22:11
Red Rock (Mountain View) tasting schedule
We're thrilled to announce our coffee tastings for the second half of the year. Coffee Tastings are held on Saturday mornings from 10:00-11:30am. They cost $20, which also scores you a 12oz bag of coffee.
July 21 - Coffee Tasting 101: Introductory Tasting
August 4 - Espresso Tasting
August 25 - 1 Coffee 5 Ways
September 15 - Coffee Tasting 101: Introductory Tasting
October 6 - Coffee Tasting 201: Cupping
October 27 - 1 Coffee 5 Ways
November 17 - Espresso Tasting
December 8 - Coffee Tasting 101: Introductory Tasting
@jdunck
jdunck / sentry-manifests-init.pp
Created July 14, 2012 01:18
puppet for sentry w/ mysql
define sentry::server(
$dir,
$user = 'sentry',
$sentry_version = '3.7.1',
$sentry_domain = 'some.host.com',
$sentry_web_host = '0.0.0.0',
$sentry_web_port = '9000',
$sentry_udp_host = '0.0.0.0',
$sentry_udp_port = '9001',
$sentry_num_workers = '20',
# from http://artificialcode.blogspot.com/2009/08/10-ways-to-let-people-know-your-bad.html
def api_entry_point():
try:
obj.method()
except:
#lets not bother the developer with this exception. He should quit out immediately!
import sys
sys.exit(0)
@jdunck
jdunck / test_cache.py
Created August 24, 2012 07:05 — forked from onyxfish/test_cache.py
Python unittest-based cache testing rig for Varnish + Wordperss
#!/usr/bin/env python
import cookielib
import json
import re
import random
import unittest
import requests
from wordpress_xmlrpc import Client, WordPressComment, WordPressPost