autocmd BufWritePre * :%s/\s\+$//e
(add-hook 'before-save-hook 'delete-trailing-whitespace)
import time | |
from contextlib import contextmanager | |
@contextmanager | |
def easyprofile(msg): | |
before = time.time() | |
yield | |
print '%s took %0.2fsec' % (msg, time.time() - before) |
#!/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) |
# -*- 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) |
$(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); | |
} | |
}); |
""" | |
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 |
lame -m s -a --preset 64 --lowpass 3.4 --highpass 0.42 in.mp3 out.mp3 | |
# https://twitter.com/#!/marcoarment/status/51790511643697153 |
#!/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' |
# 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 |