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
URL = 'http://httpbin.org/status/200' | |
def check(status_code, headers, content): | |
assert status_code == 200 | |
assert headers['Content-Length'] == '0' | |
assert headers['Content-Type'] == 'text/html; charset=utf-8' | |
assert headers['Connection'] == 'close' | |
print 'OK' |
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
(pypyenv)jonas@jonas-Serval-Professional:~/workspace/gitstats.ep.io$ time pypy run.py /home/jonas/workspace/django-cms | |
real 0m2.493s | |
user 0m2.376s | |
sys 0m0.100s |
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
# -*- coding: utf-8 -*- | |
# SOURCE: http://www.iso.org/iso/country_codes/iso_3166_code_lists.htm | |
from django.utils.translation import ugettext_lazy as _ | |
COUNTRIES = [ | |
(_(u"Afghanistan"), u"AF"), | |
(_(u"Åland Islands"), u"AX"), | |
(_(u"Albania"), u"AL"), | |
(_(u"Algeria"), u"DZ"), | |
(_(u"American Samoa"), u"AS"), |
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
""" | |
Bundles the iterable `l` into an iterable of tuples of length `x`, filling the last one with `f` if necessary. | |
Examples: | |
In [13]: list(bundle([1,2,3,4,5,6], 3, None)) | |
Out[13]: [(1, 2, 3), (4, 5, 6)] | |
In [14]: list(bundle([1,2,3,4,5,6], 2, None)) | |
Out[14]: [(1, 2), (3, 4), (5, 6)] |
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 re | |
GOOD = { | |
"#abc": ['abc'], | |
"#abc,#123": ['abc', '123'], | |
"567": ['567'], | |
"abc,123": ['abc', '123'], | |
"abc,#611": ['abc', '611'], | |
"#aaff33": ['aaff33'], | |
"9923cc": ['9923cc'], |
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.utils.decorators import method_decorator | |
def cbv_decorator(decorator): | |
""" | |
Turns a normal view decorator into a class-based-view decorator. | |
Usage: | |
@cbv_decorator(login_required) | |
class MyClassBasedView(View): |
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 contextlib import contextmanager | |
from django.contrib.messages.storage.base import BaseStorage, Message | |
from django.test.client import RequestFactory | |
from django.utils.decorators import method_decorator | |
class TestMessagesBackend(BaseStorage): | |
def __init__(self, request, *args, **kwargs): | |
self._loaded_data = [] | |
super(TestMessagesBackend, self).__init__(request, *args, **kwargs) | |
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/sh | |
run_tests() | |
{ | |
COMMAND TO RUN YOUR TESTS | |
if [ "$?" != "0" ] | |
then | |
notify-send "BUILD FAILED" -i "error" | |
else | |
notify-send "Build Successful" | |
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
from multiprocessing import Process | |
from django.core import serializers | |
from django.core.management import call_command | |
from StringIO import StringIO | |
def dump_database(): | |
sio = StringIO() | |
call_command('dumpdata', stdout=sio, natural=True) | |
return sio.getvalue() |
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
xrandr: Failed to get size of gamma for output default | |
Screen 0: minimum 320 x 175, current 1920 x 1080, maximum 1920 x 1080 | |
default connected 1920x1080+0+0 0mm x 0mm | |
1920x1080 50.0* 51.0 | |
1680x1050 52.0 | |
1600x1024 53.0 | |
1440x900 54.0 | |
1400x1050 55.0 | |
1360x768 56.0 57.0 | |
1280x1024 58.0 59.0 |