Skip to content

Instantly share code, notes, and snippets.

@io41
io41 / paginated_collection.js
Created February 22, 2011 10:10 — forked from zerowidth/paginated_collection.js
Pagination with Backbone.js
// includes bindings for fetching/fetched
var PaginatedCollection = Backbone.Collection.extend({
initialize: function() {
_.bindAll(this, 'parse', 'url', 'pageInfo', 'nextPage', 'previousPage');
typeof(options) != 'undefined' || (options = {});
this.page = 1;
typeof(this.perPage) != 'undefined' || (this.perPage = 10);
},
fetch: function(options) {
# Add this self removing snippet to someone's .bashrc, or .zshrc. #DELETEME
# So next time they ssh in, or open a terminal... NYAN CAT!! #DELETEME
CONF_FILE=$HOME/.bashrc #DELETEME
(sleep 15 && killall telnet > /dev/null 2>&1) & #DELETEME
telnet miku.acm.uiuc.edu #DELETEME
reset #DELETEME
clear #DELETEME
sed '/#DELETEME/d' $CONF_FILE > /tmp/$(basename $CONF_FILE) #DELETEME
cat /tmp/$(basename $CONF_FILE) > $CONF_FILE #DELETEME
rm -f /tmp/$(basename $CONF_FILE) #DELETEME
@io41
io41 / maildirtocouch.py
Created December 21, 2011 23:28 — forked from faried/maildirtocouch.py
Store messages in a Maildir into a couchdb database.
#!/usr/bin/env python
"""Store messages in a Maildir into a couchdb database."""
import couchdb
from mailbox import Maildir
from optparse import OptionParser
import os
from pprint import pprint
import sys
from uuid import uuid4
import functools
import inspect
# OMG, what have I done!? (Don't read this bit. Ever.)
class inject(object):
@classmethod
def require(__cls, *args):
def decorator(func):
functools.wraps(func)
#!/bin/sh
# Save this in a file in an empty dir, then run.
__global=./
__object=__mytype
__object_id=my-id
# All events go here
exec 10>$__global/post_config_events
@io41
io41 / gist:1688530
Created January 27, 2012 12:19
ipython / pdb++ setup on OS X
#!/bin/sh
backup()
{
[ -e "$1" ] && mv "$1" "$1.backup.$(date +%s)"
}
backup ~/.pdbrc.py
cat > ~/.pdbrc.py <<EOF
import pdb
class Config(pdb.DefaultConfig):
__profile_d()
{
# i.e. __profile_d_mysql_ssl/foo/bar
local d=$1
[ "$d" ] || exit 0
if [ "${d%__profile_d*}" ]; then
echo "$d"
exit 0
fi
# i.e. foo/bar

Create a public gist:

antimuon:~$ traceroute patents.com
traceroute: Warning: patents.com has multiple addresses; using 199.16.153.11
traceroute to patents.com (199.16.153.11), 64 hops max, 52 byte packets
1 10.0.1.1 (10.0.1.1) 8.736 ms 5.836 ms 4.002 ms
2 * * *
3 83-169-179-86-isp.superkabel.de (83.169.179.86) 41.602 ms 38.353 ms 39.961 ms
4 88-134-192-56-dynip.superkabel.de (88.134.192.56) 13.402 ms 9.123 ms 7.756 ms
5 88-134-204-150-dynip.superkabel.de (88.134.204.150) 11.027 ms 8.134 ms 13.547 ms
6 83-169-128-22.static.superkabel.de (83.169.128.22) 12.880 ms 23.179 ms 26.520 ms
7 88-134-201-117-dynip.superkabel.de (88.134.201.117) 9.068 ms 11.654 ms 10.706 ms
@io41
io41 / hack.sh
Created April 2, 2012 07:38 — forked from erikh/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2281433/hack.sh | sh
#