Skip to content

Instantly share code, notes, and snippets.

View j4mie's full-sized avatar

Jamie Matthews j4mie

View GitHub Profile
@j4mie
j4mie / heathens.py
Created June 17, 2009 20:37
Twitter Heathens: Find people you follow who don't follow you back
# By twitter.com/j4mie
#
# Like this: http://blog.davidziegler.net/post/107429458/see-which-twitterers-don-t-follow-you-back-in-less-than
# ..but with API pagination (in case you have more than 100 friends or followers).
# Needs this: http://code.google.com/p/python-twitter/
# ..which needs this: http://cheeseshop.python.org/pypi/simplejson
import twitter, getpass, sys
def page_function(function):
Too big for a gist, converted to a full repository: http://github.com/j4mie/marvin/
#!/bin/bash
# Convert a directory of .markdown files to HTML and PDF.
# Requires: markdown and htmldoc
for i in $( ls *.markdown );
do
echo Compiling $i
name=$( echo $i | sed 's/.markdown//' )
# Get website password at command line in Mac OS X
security 2>&1 >/dev/null find-internet-password -gs twitter.com | grep password | sed 's/password: "\(.*\)"/\1/'
// A bookmarklet to extract the short 'flic.kr' url from a Flickr photo page,
// and display it in a prompt dialog box ready to be copied to the clipboard.
javascript:var links = document.getElementsByTagName('link'); for (link in links) { href=links[link].href; if (href && href.match('/flic\.kr/')) { prompt("flic.kr url:", href); }}
@j4mie
j4mie / sqail
Created October 17, 2009 17:03
#!/usr/bin/python
# sqail by Jamie Matthews [email protected]
# 20th February 2009
# "tail -f" an sqlite table - monitor all inserts
# Usage: ./sqail dbfile tablename
# Prints the rowid of the row followed by a colon, then a
Command to check whether a server returns a different headers for a HEAD request than a GET.
site=http://www.facebook.com; diff <(curl -I ${site}) <(curl -i ${site} | sed '/^\r$/ q')
# Concatenate a set of CSV files passed as arguments. The headers of all
# the files must match. Output will be a single header row, followed
# by all the rows from all the CSV files.
import sys
if len(sys.argv) == 1:
sys.exit("No arguments supplied")
buffer = []
#!/usr/bin/python
import sys, random
if len(sys.argv) < 2:
print("Please supply number of letters to generate")
sys.exit(1)
try:
letters_to_generate = int(sys.argv[1])
except:
print("Argument must be a number")
# Print all permutations formed by concatenating every word in a
# list with every other word in the same list. Good for generating
# idea/project/company names from a list of relevant words. The list
# will be sorted by word length.
from itertools import permutations
words = "spam eggs beans".split()
perms = ["".join(permutation) for permutation in permutations(words, 2)]
print "\n".join(sorted(perms, lambda a, b: len(a) - len(b)))