Skip to content

Instantly share code, notes, and snippets.

@dsc
dsc / pack.py
Created November 14, 2009 23:55
BitString - A file-like class for writing bits
""" BitString - A file-like object for reading/writing bits.
"""
try:
from cStringIO import StringIO
except:
from StringIO import StringIO
def binlen(n):
@dsc
dsc / bitly.sh
Created February 12, 2010 19:03
bitly.sh -- shorten URLs without an API key
#!/bin/bash
# @author dsc@less.ly
if test "$1"; then
LONG_URL="$1"
else
read LONG_URL
fi
BITLY="http://bit.ly/?s=&keyword=&url="
@dsc
dsc / uri.py
Created February 23, 2010 02:12
A simple URI Encoding/Decoding commandline tool.
#!/usr/bin/env python
# encoding: utf-8
""" A simple URI Encoding/Decoding commandline tool.
"""
__author__ = 'David Schoonover <dsc@less.ly>'
__date__ = '2009-06-05'
__version__ = (0, 0, 1)
import sys, select, urllib
@dsc
dsc / make-monetdb.sh
Created February 23, 2010 18:35
Downloads, Builds and Installs MonetDB -- http://monetdb.com
#!/bin/bash
### MonetDB Installer for RHEL5 ###
# Script needs to be run as root if any any packages need installing.
# For more info, see:
# - http://monetdb.cwi.nl/MonetDB/Documentation/Linux-Installation.html#Linux-Installation
# MonetDB RPM's for RHEL5:
@dsc
dsc / Can you be sure it has understood you completely?.txt
Created February 25, 2010 03:14
Dictionary of the Khazars - Milorad Pavic
'You see,' [the devil] says to me casually, 'the moth is way up there by the
white wall of the doorway, and it is visible only because it moves. From here it
almost looks like a bird high up in the sky, if you think of the wall as the
sky. That's probably how the moth sees the wall, and only we know it is wrong.
But it doesn't know that we know. It doesn't even know we exist. You try to
communicate with it, if you can. Can you tell it anything in a way it
understands; can you be sure it has understood you completely?'
'I don't know,' I replied. 'Can you?'
@dsc
dsc / unshorten.sh
Created March 15, 2010 18:17
unshorten.sh -- undo tiny-ing, bitly-ing, shady-ing, etc
#!/bin/bash
# usage:
# unshorten.sh 'http://bit.ly/95U1UY'
# echo 'http://bit.ly/95U1UY' | unshorten.sh
#
# author: dsc@less.ly
if test "$1"; then
@dsc
dsc / flickr-stats-export.sh
Created March 16, 2010 04:59
Downloads your Flickr stats.
#!/bin/bash
function usage () {
echo
echo "Usage: $0 USERNAME COOKIES"
echo
echo "Easiest Way to Get Your Cookies:"
echo " I recommend you use firebug on a visit to http://www.flickr.com and copy the value of the Cookie header from your first request."
}
@dsc
dsc / chain.js
Created March 22, 2010 00:34
Async chained callback pattern.
(function(){
/**
* Function.asyncChain( fn, [...] ) -> Function
*
* Takes any number of callback functions and returns a scheduler function
* which manages the chain. Each supplied callback to should take one
* argument, the scheduler, to execute with no arguments when it completes.
*
* Example:
@dsc
dsc / pylons.sh
Created March 29, 2010 12:50
pylons.sh -- fiddles with pylons
#! /bin/bash
function halp () {
cat <<-HALP
pylons -- Starts a Pylons app, creating logs and saving a pidfile.
Usage: $( basename $0 ) [INI_FILE]
If INI_FILE is not 'development.ini', stdout and stderr are redirected
@dsc
dsc / stress.py
Created July 19, 2010 20:40
Modified stress.py for testing Cassandra
#!/usr/bin/env python
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0