Skip to content

Instantly share code, notes, and snippets.

View jemerick's full-sized avatar

Jason Emerick jemerick

View GitHub Profile
@mikelikespie
mikelikespie / refresh_css.js
Created October 27, 2010 18:31
This refreshes all the css on a page by changing the query string
/*
Add a bookmark to this
javascript:(function(){var c=document.getElementsByTagName("link");for(var d=0;d<c.length;d++){var a=c[d];if(a.rel=='stylesheet'||a.type=="text/css"){var e="css_buster_"+Math.floor(Math.random()*1000000000);var g=a.href.split("?",2);var f;if(g.length>1){var b=g[1].indexOf("&")==-1;if(b){f=e}else{f=g[1]+"&"+e}}else{f=e}a.href=g[0]+"?"+f}}})();
*/
(function() {
var links = document.getElementsByTagName('link');
for (var i = 0; i < links.length; i++) {
var l = links[i];
if (l.rel == 'stylesheet' || l.type == 'text/css') {
@alanjrogers
alanjrogers / UIWebViewNoScroll.m
Created October 29, 2010 22:49
Disabling a UIWebView's scroll
- (void)webViewDidFinishLoad:(UIWebView *)webView
{
if (webView.subviews.count > 0)
{
id aView = [webView.subviews objectAtIndex:0];
if ([aView respondsToSelector:@selector(setScrollEnabled:)])
{
((UIScrollView*)aView).scrollEnabled = NO;
}
import csv
import simplegeo
OAUTH_TOKEN = '[insert_oauth_token_here]'
OAUTH_SECRET = '[insert_oauth_secret_here]'
CSV_FILE = '[insert_csv_file_here]'
LAYER = '[insert_layer_name_here]'
client = simplegeo.Client(OAUTH_TOKEN, OAUTH_SECRET)
@dcramer
dcramer / debug.py
Created March 24, 2011 21:25
Django Debug Toolbar On-Demand
from django.conf import settings
from django.conf.urls.defaults import include, patterns
from django.http import HttpResponse
from django.utils.encoding import smart_unicode
if 'debug_toolbar' not in settings.INSTALLED_APPS:
class DebugMiddleware(object):
pass
else:
import debug_toolbar.urls
"""
Patches the database wrapper and template engine to throw an exception if a query is executed inside of a template.
In your urls.py, enable it like so:
>>> import monkey
>>> monkey.patch_templates()
"""
import logging
@rcreasey
rcreasey / solo_data_bags.rb
Created May 12, 2011 05:21
Using data bags with chef-solo
From: Brian Akins < brian@akins.org>
To: chef < chef@lists.opscode.com>
Subject: [chef] Data bag implementation for chef-solo
Date: Tue, 1 Feb 2011 10:42:05 -0500
We often use chef-solo for quick testing, etc. This is our extremely simple implementation of data bags for chef-solo. Add "data_bag_path /some/dir/data_bags" to your solo.rb and add this into your libraries:
if Chef::Config[:solo]
class Chef
module Mixin
module Language
@bltravis
bltravis / customssnfield.py
Created May 30, 2011 17:59
A custom model field to provide transparent encryption/decryption of U.S. Social Security Numbers, using PyCrypto
from Crypto.Cipher import AES
import binascii
import re
ssn_re = re.compile(r"^\d{3}[-\ ]?\d{2}[-\ ]?\d{4}$")
class EncryptedSSNField(models.CharField):
description = _('Adds transparent encryption/decryption (AES256 using pyCrypto) for US Social Security Numbers in the database.')
__metaclass__ = models.SubfieldBase
anonymous
anonymous / bootstrap.sh
Created June 2, 2011 17:19
Django on Heroku with Celery and Sentry
virtualenv --no-site-packages .
source bin/activate
bin/pip install Django psycopg2 django-sentry
bin/pip freeze > requirements.txt
bin/django-admin.py startproject mysite
cat >.gitignore <<EOF
bin/
include/
lib/
EOF
@leah
leah / json-response.py
Created October 5, 2011 19:08
JSONResponse classes
import re
import simplejson
from django.http import HttpResponse
from django.conf import settings
class JSONResponse(HttpResponse):
def __init__(self, request, data):
indent = 2 if settings.DEBUG else None
//
// NSURLConnection+Blocks.h
// SteveHolt
//
// Created by Eric Florenzano on 10/19/11.
// Copyright (c) 2011 Boilerplate Inc. All rights reserved.
//
#import <Foundation/Foundation.h>