This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import pymongo | |
from urlparse import urlparse | |
MONGO_URL = os.environ.get('MONGOHQ_URL') | |
if MONGO_URL: | |
# Get a connection | |
conn = pymongo.Connection(MONGO_URL) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# See https://gist.github.com/3830479 for disable_ and restore_ functions | |
from unittest import TestCase | |
class Test(TestCase): | |
@classmethod | |
def class_setup(cls): | |
disable_transaction_methods() | |
# ... import test fixtures |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.db import connections | |
from django.db import transaction | |
def disable_transaction_methods(): | |
from django.test.testcases import disable_transaction_methods | |
for db in connections: | |
transaction.enter_transaction_management(using=db) | |
transaction.managed(True, using=db) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from intercom import Intercom | |
from intercom import User | |
... | |
Intercom.api_key = 'xxx' | |
Intercom.api_id = 'yyy' | |
... | |
user = User.find_by_email('[email protected]') | |
user.custom_data['age'] = 42 user.save() | |
... | |
user.created_at # datetime object |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*** tough-cookie/lib/cookie.js ***/ | |
/* I added the following to the end of the file for testing purposes */ | |
memstore = require('./memstore'); | |
module.exports.memorystore = memstore.MemoryCookieStore; | |
/*** jsonstore.js ***/ | |
var tough = require('tough-cookie'); | |
// ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(python2.7)django-exceptional $ pip install --upgrade django-exceptional | |
Downloading/unpacking django-exceptional | |
Downloading django-exceptional-0.1.5.tar.gz | |
Running setup.py egg_info for package django-exceptional | |
Installing collected packages: django-exceptional | |
Running setup.py install for django-exceptional | |
Successfully installed django-exceptional | |
Cleaning up... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
watchmedo shell-command --patterns="*.less" --command=\ | |
'LESS=`echo "${watch_src_path}" | sed s/.less/.css/`; \ | |
echo compile: "${watch_src_path}";\ | |
lessc "${watch_src_path}" "${LESS}"; \ | |
if [ "$?" -eq "0" ]; then echo wrote: "${LESS}"; fi' $* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pathfinder | |
# only search top 2 levels of the directory tree | |
paths = pathfinder.pathfind(".", depth=2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import csv | |
from xlrd import open_workbook | |
def excel_to_csv(excel_file, include=None): | |
""" | |
Convert the data in the excel_file to CSV. If | |
include is specified, only those named columns | |
will be included in the CSV. | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import re | |
def increpl(matchobj): | |
""" | |
Replace the include statement with the contnet of the file. | |
""" | |
inc = matchobj.group(1) | |
return parse(inc) |