Skip to content

Instantly share code, notes, and snippets.

View gregorynicholas's full-sized avatar
💀
alter.

gregory nicholas gregorynicholas

💀
alter.
View GitHub Profile
# encoding: utf-8
import logging
import re
import sys
import os
from traceback import *
from root import DEVELOPMENT_PROJECT_ROOT
# generate nice traceback with optional textmate links
def format_nice_traceback(traceback):
import logging
from google.appengine.api import memcache
from google.appengine.api import apiproxy_stub_map
from google.appengine.datastore import datastore_pb
"""Provides a shim that caches datastore Get calls.
Example code:
import datastore_get_cache
(function($) {
$.fn.clippy = function(text, bgcolor) {
if (!bgcolor) {
var node = $(this);
while (node.css('background-color') == 'transparent' && node.length) {
node = node.parent();
}
if (!node.length) {
bgcolor = '#ffffff';
} else {
@abachman
abachman / gist:78702
Created March 13, 2009 18:55
A bash script for listing directory trees (with color)
#!/usr/bin/env bash
#
# This script produces a complete tree structure for the directory
# in which it is running.
#
# FROM
# http://www.sun.com/bigadmin/scripts/submittedScripts/lstree.sh.txt
#
# Modifications by Adam Bachman
#
@evocateur
evocateur / fixconsolas
Created March 15, 2009 00:15
Fix Consolas's line-height on OS X
#!/bin/bash
#
# Requires ftxdumperfuser from http://developer.apple.com/textfonts/download/
#
# Usage: fixconsolas [files ...]
# When called with no arguments, it attempts to operate on every TrueType
# file in the current directory.
#
# References:
# http://bandes-storch.net/blog/2008/12/21/consolas-controlled/#comment-2042
@csytan
csytan / dbextras.py
Created May 9, 2009 09:12
appengine db extras
from google.appengine.ext import db
from django.utils import simplejson
### Functions ###
def fetch_references(entities, attr):
"""Fetches and sets ReferenceProperty attributes in one db call"""
keys = []
for entity in entities:
key = getattr(entity, '_' + attr)
require 'digest/md5'
def gfm(text)
# Extract pre blocks
extractions = {}
text.gsub!(%r{<pre>.*?</pre>}m) do |match|
md5 = Digest::MD5.hexdigest(match)
extractions[md5] = match
"{gfm-extraction-#{md5}}"
end
import base64
from django.utils import simplejson
import urllib
from google.appengine.api import urlfetch
def track(event, properties=None):
"""
A simple function for asynchronously logging to the mixpanel.com API on App Engine
(Python) using RPC URL Fetch object.
@param event: The overall event/category you would like to log this data under
"""
A helper for the app engine blobstore API and Django.
Works with the appengine patch:
http://code.google.com/p/app-engine-patch/
Taken and inspired by:
http://appengine-cookbook.appspot.com/recipe/blobstore-get_uploads-helper-function-for-django-request/
Usage:
@bkeating
bkeating / howto-filemerge-git-osx.md
Created March 11, 2010 21:36
HOWTO: Using FileMerge (opendiff) with Git on OSX

HOWTO: Using FileMerge (opendiff) with Git on OSX

FileMerge (opendiff) can really come in handy when you need to visually compare merging conflicts. Other times it's just a nice visual way to review your days work.

The following method works by creating a simple bash script (git-diff-cmd.sh) that sets us up with the proper command line arguments for Git to pass off files to FileMerge.