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
""" | |
print out all the emojis to spam your friends Slack clients | |
""" | |
import requests | |
api_token = 'your-api-token' | |
text = ' '.join([':{}:'.format(e) for e in requests.get('https://slack.com/api/emoji.list?token={}'.format(token)).json()['emoji'].keys()]) | |
print(text) |
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
fs = require 'fs', | |
xml2js = require 'xml2js' | |
coverage = | |
modules: [] | |
filename = 'coverage.xml' | |
parser = new xml2js.Parser() | |
fs.readFile __dirname + '/' + filename, (err, data) -> |
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
# checkout master from n days ago | |
git checkout `git rev-list -n 1 --before="7 days ago" master` |
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.core.cache import cache | |
# inside get() or your view function | |
cache_key = 'dummy-csv-export-status' | |
dummy_data = cache.get(cache_key) | |
if not dummy_data: | |
dummy_data = ['ready'] + ['processing' for i in range(9)] | |
cache.set(cache_key, dummy_data) |
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 sys | |
import pkg_resources | |
""" | |
List python packages installed in a directory (such as with pip install --target my_dir) | |
python list-target.py /path/to/my_dir # can be relative or absolute | |
""" | |
try: | |
target_dir = sys.argv[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
/* from http://stackoverflow.com/a/17514460 */ | |
li { | |
list-style-type: disc; | |
list-style-position: inside; | |
text-indent: -1em; | |
padding-left: 1em; | |
} |
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
# my.conf | |
[mysqld] | |
autocommit = 1 | |
transaction-isolation = READ-COMMITTED | |
# settings.py | |
DATABASES = { | |
..., | |
'OPTIONS': { | |
'init_command': 'SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED', |
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
'.source.python': | |
'Django context_data': | |
'prefix': 'context_data' | |
'body': 'def get_context_data(self, **kwargs):\n\tcontext_data = super(, self).get_context_data(**kwargs)\nreturn context_data' |
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 inspect | |
def decorate_all_tests_in_class(decorator, prefix='test_', **kwargs): | |
def decorate_the_class(cls): | |
for name, m in inspect.getmembers(cls, inspect.ismethod): | |
if name.startswith(prefix): | |
setattr(cls, name, decorator(**kwargs)(m)) | |
return cls | |
return decorate_the_class |
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
""" | |
myapp/mymodule.py: | |
from django.core.cache import cache | |
def set_cache(): | |
cache.set('foo', 'bar') | |
def get_cache(): | |
return cache.get('foo') |