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
Dear Zendesk, | |
On behalf of the internet, and for the greater good of mankind, this is a request to | |
politely ask you to change the default theme of your support emails. | |
Currently every support email notification, for the majority of your customers, | |
includes a complete dump of the entire conversation. And due to the way you | |
have constructed the HTML in your email, most email clients fail to realise | |
it is duplicated text and do not remove it. |
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_video_info(path): | |
"""Uses ffmpeg to determine information about a video. This has not been broadly | |
tested and your milage may vary""" | |
from decimal import Decimal | |
import subprocess | |
import re | |
process = subprocess.Popen(['/usr/bin/ffmpeg', '-i', path], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) | |
stdout, stderr = process.communicate() |
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
class dict_as_class(dict): | |
"""Proper replacement for UserDict | |
Allows a dictionary to be used like a class. Really messy, thrown | |
together in a few minutes as a quick replacement, will probably | |
tidy this up later""" | |
def __setattr__(self, k, v): | |
if k in self.keys(): |
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
# default sub orders before first sub end | |
with patch_today(2013, 1, 1, 1, 1, 1) as pt: | |
i = UserSubscription.objects.create_orders() | |
self.assertEquals(len(i['orders_created']), 0) | |
# default sub orders after first sub end | |
with patch_today(2013, 1, 6, 1, 1, 1) as pt: | |
# create | |
i = UserSubscription.objects.create_orders() | |
self.assertEquals(len(i['orders_created']), 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
def extend_instance(instance, *bases, **kwargs): | |
""" | |
Apply subclass (mixin) to a class object or its instance | |
By default, the mixin is placed at the start of bases | |
to ensure its called first as per MRO. If you wish to | |
have it injected last, which is useful for monkeypatching, | |
then you can specify 'last=True'. See here: | |
http://stackoverflow.com/a/10018792/1267398 |
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
for k in ['host', 'port', 'database', 'user', 'password']: | |
if k in dbconfig: | |
if type(dbconfig[k]) in (str, unicode): | |
match = pat.match(dbconfig[k]) | |
if match and match.groups(): | |
envvar = match.groups()[0] | |
if envvar in os.environ: | |
dbconfig[k] = os.environ[envvar] | |
if k != 'password': |
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 extend_instance(instance, *bases, **kwargs): | |
""" | |
Apply subclass (mixin) to a class object or its instance | |
By default, the mixin is placed at the start of bases | |
to ensure its called first as per MRO. If you wish to | |
have it injected last, which is useful for monkeypatching, | |
then you can specify 'last=True'. See here: | |
http://stackoverflow.com/a/10018792/1267398 | |
:attr cls: Target 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
#!/usr/bin/env python | |
""" | |
Embed files into C arrays | |
Hacky solution because xxd didn't have enough features | |
""" | |
from __future__ import with_statement | |
from __future__ import print_function |
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
class FormFieldQuerySetMixin(object): | |
""" | |
Adds support for changing RelatedField queryset | |
easily without having to patch __init__. | |
def get_FIELDNAME_queryset(self): | |
pass | |
""" |
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 sys | |
import subprocess | |
def sanitypatch(): | |
""" | |
Quick hack to install any package we want in coderpad... | |
Because real coders use pytest, amirite? | |
""" | |
print("applying coderpad sanity patch...") |