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 | |
from fabric.api import run, cd, env, abort | |
from fabric.contrib.console import confirm | |
from fabric.context_managers import prefix | |
from fabric.tasks import Task | |
env.hosts = ['[email protected]'] | |
env.settings = ['staging', 'production'] |
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 | |
# encoding: utf-8 | |
""" | |
Invalidate Johnny Cache's cache for given models outside "normal Django" | |
(e.g. in a management command). | |
""" | |
from johnny.cache import invalidate | |
from johnny.middleware import QueryCacheMiddleware |
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
# Lean and Mean Serial/Parallel DSL for CoffeeScript | |
# - based of https://gist.github.com/1090670 by timcameronryan, | |
# https://gist.github.com/1091019 by walling | |
serial = (spec) -> | |
steps = (func for key, func of spec when key != 'catch') | |
next = (err, args...) -> | |
return spec.catch(err) if err | |
steps.shift().apply(next, args) if steps.length > 0 | |
next null |
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 sh | |
sudo curl -L http://3.narf.pl/iTunes.icns > /Applications/iTunes.app/Contents/Resources/iTunes.icns | |
echo 'relog, remove itunes from dock, go to /Applications and drag it back' |
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
lame -m s -a --preset 64 --lowpass 3.4 --highpass 0.42 in.mp3 out.mp3 | |
# https://twitter.com/#!/marcoarment/status/51790511643697153 |
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
""" | |
Here's how to run a command from Python piping a string in to stdin and reading the | |
output back in to another string. It took me way too long to work this out. | |
""" | |
from subprocess import Popen, PIPE | |
output = Popen( | |
['java', '-jar', 'yuicompressor-2.4.2.jar', '--type=css'], | |
stdin=PIPE, stdout=PIPE |
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() { | |
var iPhone = /AppleWebKit.*Mobile/.test(navigator.userAgent), | |
iPhoneApp = iPhone && !(/Mobile.*Safari/.test(navigator.userAgent)); | |
if (iPhone && !iPhoneApp) { | |
setTimeout(function() { window.scrollTo(0, 1); }, 0); | |
} | |
}); |
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 -*- | |
from django.db import models | |
class LtreeField(models.CharField): | |
"""Field implementation of PostgreSQL ltree type""" | |
def __init__(self, *args, **kwds): | |
super(LtreeField, self).__init__(max_length=128, *args, **kwds) |
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 codecs, sys | |
try: | |
infile, outfile = sys.argv[1], sys.argv[2] | |
except IndexError: | |
sys.stderr.write('usage: %s input_file output_file\n' % sys.argv[0]) | |
sys.exit(1) | |
nfo = codecs.open(infile, encoding='utf-8').read() | |
codecs.open(outfile, 'w', encoding='cp437').write(nfo) |
NewerOlder