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 requests | |
import pyquery | |
import re | |
import sys | |
import urllib | |
SEARCH_URL = 'http://ajax.googleapis.com/ajax/services/search/web' | |
def unquote_all(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
from django.conf import settings | |
used_queues = set() | |
for route, q_dict in settings.CELERY_ROUTES.items(): | |
module, task = route.rsplit('.', 1) | |
mod = __import__(module, globals(), locals(), [task]) | |
try: | |
t = getattr(mod, task) | |
except AttributeError: |
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
def kill_queries(query='', db_alias='default'): | |
from django.db import connections | |
import re | |
connection = connections[db_alias] | |
cursor = connection.cursor() | |
cursor.execute("SHOW PROCESSLIST") | |
for row in cursor.fetchall(): | |
current = row[-1] | |
if current and re.search(query, current): |
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
function open_module() { | |
mate `python -c "import $1 as mod; print (mod.__file__[:-12] if '__init__' in mod.__file__ else mod.__file__[:-1])"` | |
} |
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
def get_exception_side_effect(num_of_exceptions, exception_class=Exception): | |
def side_effect(*args, **kwargs): | |
side_effect.calls += 1 | |
if side_effect.calls > num_of_exceptions: | |
return Mock() | |
else: | |
raise exception_class | |
side_effect.calls = 0 | |
return side_effect |
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
#!/usr/bin/env python | |
import subprocess | |
import sys | |
from boto.ec2.connection import EC2Connection | |
from chef import ChefAPI, Node | |
base_command = "knife ec2 server create" |
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
brew install -v node | |
Warning: LLVM was requested, but this formula is reported to not work with LLVM: | |
Error: undefined method `reason' for true:TrueClass | |
Please report this bug: | |
https://github.com/mxcl/homebrew/wiki/checklist-before-filing-a-new-issue | |
/usr/local/Library/Homebrew/formula.rb:322:in `handle_llvm_failure' | |
/usr/local/Library/Homebrew/formula.rb:252:in `brew' | |
/usr/local/Library/Homebrew/build.rb:53:in `install' | |
/usr/local/Library/Homebrew/build.rb:27 |
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 random | |
import subprocess | |
days = ["Thursday", "Friday"] | |
def main(): | |
day_of_week = random.choice(days) | |
subprocess.call("say %s" % day_of_week, shell=True) | |
if __name__ == "__main__": |
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 Image | |
import cStringIO | |
from django.core.files.base import ContentFile | |
from django.db.models import ImageField | |
from django.db.models.fields.files import ImageFieldFile | |
class JPEGImageFieldFile(ImageFieldFile): | |
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 Image | |
import cStringIO | |
import os | |
from django.core.files.base import ContentFile | |
from django.db.models import ImageField | |
from django.db.models.fields.files import ImageFieldFile | |
class JPEGFieldFile(ImageFieldFile): |