Skip to content

Instantly share code, notes, and snippets.

@jelsas
jelsas / stream_sucker.sh
Created May 12, 2011 13:27
Twitter stream sucker. Drinks from the Gardenhose.
#!/bin/sh
#
# A Twitter stream sucker. Writes one file per hour, containing all the tweets from the
# sample stream (aka "gardenhose").
#
# Use Ctrl-C to stop collecting.
#
# Note: This is not intended to be a robust tool for collecting Twitter data. Use at your
# own risk, and play nice: http://dev.twitter.com/pages/streaming_api_concepts
@jelsas
jelsas / .screenrc
Created March 10, 2011 13:33
.screenrc file that adds ctrl-arrow window switching, a nice status & a few other things
# the following two lines give a two-line status, with the current window highlighted
#hardstatus alwayslastline "%= %3n %t%? [%h]%? %="
#caption always "%= %-w%L>%{= BW}%n*%t%{-}%52<%+w %L="
hardstatus alwayslastline
hardstatus string '%{= kG}[%{G}%H%? %1`%?%{g}][%= %{= kw}%-w%{+b yk} %n*%t%?(%u)%? %{-}%+w %=%{g}][%{B}%m/%d %{W}%C%A%{g}]'
defscrollback 3000
@jelsas
jelsas / calc.py
Created December 10, 2010 17:02
Simple command-line calculator for streams of data
#!/usr/bin/python
'''
A command-line calculator over streams of numbers.
Requires numpy for 'hist' and 'median'.
For example:
# create a file with 100 random numbers, 1 per line
$ jot -r 100 > /tmp/random
@jelsas
jelsas / indri_dependence_model_query.py
Created September 1, 2010 19:18
Functions to build full dependence model queries for Indri http://lemurproject.org/indri
'''
Functions to build full dependence model queries for Indri http://lemurproject.org/indri.
See "A Markov Random Field Model for Term Dependencies" by Metzler & Croft
http://ciir.cs.umass.edu/pubfiles/ir-387.pdf
'''
import re
nonword_chars = re.compile(r'\W+')
def powerset(l):
@jelsas
jelsas / format_yahoo_letor_submission.py
Created April 23, 2010 18:19
Formats a submission file suitable for upload to the Yahoo LETOR Challenge
#!/usr/bin/python
# This script takes the predictions and input vectors
# (eg. set1.test.txt) and produces a file suitable for
# submission to the Yahoo LETOR Challenge web interface.
#
# The PREDICTIONS_FILE should just be a list of scores,
# one per line, corresponding to the lines in INPUT_FILE
from itertools import izip, groupby
@jelsas
jelsas / packed_enum.tex
Created January 20, 2010 15:10
latex ENUMERATE that takes up less space
% This is a drop-in replacement for \begin{enumerate}...\end{enumerate} in LaTeX. Just include it in
% your preamble and use \begin{packed_enum} instead.
\newenvironment{packed_enum}{
\begin{enumerate}
\setlength{\itemsep}{2.5pt}
\setlength{\parskip}{0pt}
\setlength{\parsep}{0pt}
}{\end{enumerate}}