Skip to content

Instantly share code, notes, and snippets.

View themartorana's full-sized avatar

Dave Martorana themartorana

View GitHub Profile
#
#
def create_table_for_unrelated_model(model, database_name):
from django.db import connections, transaction
from django.core.management.sql import custom_sql_for_model
from django.core.management.color import no_style
connection = connections[database_name]
cursor = connection.cursor()
@themartorana
themartorana / gist:851307
Created March 2, 2011 17:18
Get request.context and request.template support back in TestCase using Jinja2
from jinja2 import Template as Jinja2Template
from django.test import signals
#note - this code can be run only once
ORIGINAL_JINJA2_RENDERER = Jinja2Template.render
def instrumented_render(template_object, *args, **kwargs):
context = dict(*args, **kwargs)
signals.template_rendered.send(
sender=template_object,
template=template_object,
@themartorana
themartorana / gist:976694
Created May 17, 2011 15:29
/etc/rc.local
We couldn’t find that file to show.
@themartorana
themartorana / gist:976701
Created May 17, 2011 15:31
/etc/rc.local.stage1
#!/bin/bash -e
if [ -f /etc/cron.d/initialrunner ]; then
    rm /etc/cron.d/initialrunner
fi
# Update the server
apt-get update -y
aptitude -yf full-upgrade
aptitude install -y git
@themartorana
themartorana / gist:976705
Created May 17, 2011 15:32
/etc/cron.d/initialrunner
We couldn’t find that file to show.
@themartorana
themartorana / build.py
Created May 17, 2011 15:54
build.py
import os, sys
import datetime
import base64
import cloudservers
import cloudlb
import urllib2
#import paramiko
from time import sleep
@themartorana
themartorana / gist:1339600
Created November 4, 2011 15:34
Settings for Sublime Text 2
/* User File Prefs */
{
"auto_match_enabled": true,
"color_scheme": "Packages/Color Scheme - Default/Monokai Bright.tmTheme",
"draw_minimap_border": true,
"ensure_newline_at_eof_on_save": true,
"font_face": "Monaco",
"font_size": 12,
"scroll_past_end": true,
"tab_size": 4,
@themartorana
themartorana / gist:2727865
Created May 18, 2012 22:17
InnoDB Tweaks
innodb_flush_log_at_trx_commit = 0
innodb_support_xa = 0
★★★★★ We heard your feedback - Domino! Free now has less ads! Next update will have even fewer. Upgrade to the paid version to get rid of ads forever! ★★★★★
The reviews are in!
* "Crazy addictive!" - adjote
* "Best Domino game out there." - redvision4
* "Only issue is that it is completely addictive!" - Name_me
* "Players who enjoy a game of dominoes should give this one a try" - 148apps.com
* "Simply awesome." - Angel Pizarro
@themartorana
themartorana / anything_really.sh
Created August 2, 2012 19:31
Time your shell scripts
#!/bin/sh
START=`date +%s%N`
# Do stuff here
END=`date +%s%N`
ELAPSED=`echo "scale=8; ($END - $START) / 1000000000" | bc`