Skip to content

Instantly share code, notes, and snippets.

View paulsmith's full-sized avatar
😀
Hi, friends

Paul Smith paulsmith

😀
Hi, friends
View GitHub Profile
@paulsmith
paulsmith / gist:54275
Created January 28, 2009 23:56
wrap a series of bash commands
#!/bin/bash
prog=$(basename $0)
logger="logger -t $prog"
# Logs to syslog and stderr
gripe () {
$logger -s "$*"
}
@paulsmith
paulsmith / echo.c
Created October 7, 2009 18:40
Unix is C—a preforking echo server inspired by tomayko.com and jacobian.org’s recent “* is Unix” posts
/**
* A simple preforking echo server in C.
*
* Building:
*
* $ gcc -Wall -o echo echo.c
*
* Usage:
*
* $ ./echo
import urllib, re
from pprint import pprint as pp
from datetime import datetime, timedelta
from geopy.geocoders import Google
import MySQLdb
from time import sleep
bcpd_arc_url = "http://maps.baltimorepolice.org/servlet/com.esri.esrimap.Esrimap?ServiceName=BaltimorePolice&CustomService=Query&ClientVersion=3.1&Form=True&Encode=False"
districts={"Northwest":
@paulsmith
paulsmith / example_output.txt
Created November 3, 2009 16:24
A toy Markov chain generator, primed with magazine-length article text by The Nation's Chris Hayes
Rush Limbaugh all tore into him as nominee, could completely
alter the structure of her considerable enthusiasm into
persuading even the rare greater red horse that make solar cells,
a Ways and Means they are also, by and large ways, in gentler,
politer interactions with ministers and churches. That's really
how I first came into this thinking it was easy to surmise that
the mainstream of his shot-up airplane that paralyzed his right
arm paralyzed. Or the story of the world over, and scapegoating
the brown-skinned Other who is seeking an exemption in the
country--and board chair Hank Dittmar, an expert on ...
@paulsmith
paulsmith / markov.clj
Created November 9, 2009 20:56
Another toy Markov chain generator, this time in Clojure
(def state (ref {}))
(def nonword "\n")
(defn get-words
[]
(loop [words []]
(let [line (read-line)]
(if (nil? line)
words
FF 3.5
| Run | String(fn) | fn + "" |
|-----+-------------+-----------|
| 1 | 0.658 | 0.617 | (time in sec.)
| 2 | 0.666 | 0.617 |
| 3 | 0.651 | 0.61 |
| 4 | 0.651 | 0.611 |
| 5 | 0.653 | 0.621 |
|-----+-------------+-----------|
import urllib, re
from pprint import pprint as pp
from datetime import datetime, timedelta
from geopy.geocoders import Google
import MySQLdb
from time import sleep
bcpd_arc_url = "http://maps.baltimorepolice.org/servlet/com.esri.esrimap.Esrimap?ServiceName=BaltimorePolice&CustomService=Query&ClientVersion=3.1&Form=True&Encode=False"
districts={"Northwest":
#!/bin/bash
set -e -x
export DEBIAN_FRONTEND=noninteractive
apt-get update && apt-get install -y siege
siege -c 100 --time=10m --user-agent="Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.2pre) Gecko/20100207 Ubuntu/9.10 (karmic) Namoroka/3.6.2pre" http://ec2-174-129-96-143.compute-1.amazonaws.com/index.html
shutdown -h now
#!/usr/bin/env python
"""
Tallies up the geocoded tweets and geo-enabled users in your Twitter social graph / friend
timeline, at most for the last 3,200 friend tweets (as rate-limited by the Twitter API)
Prints some stats to stderr, the geocoded tweets in JSON format to stdout
I would execute it like so:
$ ./geo_tweet_stats.py username password | tee geotweets.json
#!/usr/bin/env python
import urllib, os, time, glob, urlparse, errno, sys, getpass, re
from xml.dom.minidom import parseString as parse
API_PATH = '/api/read'
MAX_NUM_PER_REQUEST = 50
class BadLogin(Exception): pass
def make_api_url(tumblr):