Skip to content

Instantly share code, notes, and snippets.

@inky
inky / .htaccess
Created February 13, 2009 22:25
.htaccess copypasta
<Files ~ "^[\._]ht">
Order allow,deny
Deny from all
Satisfy All
</Files>
Options -Indexes +FollowSymLinks +ExecCGI
AddHandler php5-script .php
AddHandler cgi-script .py
@inky
inky / reset.css
Created February 13, 2009 22:26
CSS Reset
html, body, div, span, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, b, cite, code,
del, dfn, em, i, img, ins, kbd, q, samp,
strike, strong, sub, sup, tt, var,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td
{margin:0; padding:0; border:0; outline:0; font-size:100%;
vertical-align:baseline; background:transparent;}
@inky
inky / flickrtags.py
Created February 13, 2009 22:28
Flickr-style tag normalisation
import string
tag_chars = string.lowercase + string.digits
valid_char = lambda c: c in tag_chars
normalize = lambda tag: filter(valid_char, str(tag).lower())
@inky
inky / git-empty-branch.sh
Created February 20, 2009 17:57
Create an empty git branch (kinda dodgy)
git symbolic-ref HEAD refs/heads/$newbranch
rm .git/index
git clean -fdx
#
# git-add files, then git-commit to finish creating the branch
#
ssh -N -f -D $port $host
#
# socks proxy: localhost:$port
#
git branch -d oldbranch
git push origin :oldbranch
class Something:
#
# ...
# class definition
# ...
#
@property
def sort_value(self):
return self.some_important_variable
def map_results(fields, rows):
keys = [f.split('.')[-1] for f in fields]
return tuple(dict(zip(keys, row)) for row in rows)
# >>> fields = ('x.id', 'y.name', 'spork')
# >>> rows = [(1, 2, 3), (4, 5, 6)]
# >>> for row in map_results(fields, rows):
# ... print row
# ...
# {'id': 1, 'name': 2, 'spork': 3}
>>> import twitter # http://code.google.com/p/python-twitter/
>>> t = twitter.Api(username='abc', password='def')
>>> status = t.PostUpdate('hurr I am tweet')
>>> print 'http://twitter.com/%s/status/%d' % (status.user.screen_name, status.id)
@inky
inky / copyright fold
Created April 8, 2009 22:46
Hiding license headers in vim