Skip to content

Instantly share code, notes, and snippets.

View terrycojones's full-sized avatar

Terry Jones terrycojones

View GitHub Profile
@terrycojones
terrycojones / gist:1991029
Created March 7, 2012 05:02
Smallest natural number with no English wikipedia page
import itertools, requests
for i in itertools.count():
r = requests.get('http://en.wikipedia.org/wiki/%d' % i)
if r.status_code == 404:
print i
break
ii ca-certificates-java 20100406ubuntu1 Common CA certificates (JKS keystore)
ii java-common 0.34 Base of all Java packages
ii libaccess-bridge-java 1.26.2-3 Java Access Bridge for GNOME
ii libaccess-bridge-java-jni 1.26.2-3 Java Access Bridge for GNOME (jni bindings)
ii libantlr-java 2.7.7-15ubuntu1 language tool for constructing recognizers,
ii libbackport-util-concurrent-java 3.1-2ubuntu2 backport of java.util.concurrent to Java 1.4
ii libcommons-beanutils-java 1.8.2-1 utility for manipulating JavaBeans
ii libcommons-codec-java 1.4-2 encoder and decoders such as Base64 and hexa
ii l
#nyc
#occupy
@terrycojones
terrycojones / gist:1893729
Created February 23, 2012 16:54
Talk - a little story from Barry Yourgrau's book "The Sadness of Sex"
Talk
A man develops a highly sohisticated way of communicating.
It's a language of arcane and inspired symbols, dedicated to the
art of being witty. It has exquisitely abstruse features. No one
can understand the man, but that doesn't perturb him. He goes
for long walks, and then sits in a scenic area of the park and tells
himself cunning, subtle, utterly brilliant little jokes at which he
chuckles and wipes his eyes and shakes his head, knocked out
by his own genius.
#!/bin/sh
echo "IP address limit:"
curl -s http://twitter.com/account/rate_limit_status.json | python -c '\
import sys, pprint, simplejson
d = simplejson.loads(sys.stdin.read())
for k, v in d.items():
print "\t%s: %s" % (k, v)'
;;; -*-Emacs-Lisp-*-
(defun ls-dir-to-list (dir dotfiles omit.&..)
"Return a list containing the file names found in directory DIR.
If DOTFILES is t, files that start with a period will be included
\(this implies \"ls -a\"\). If OMIT.&.. is also t, the special
directories \".\" and \"..\" will not be returned."
(interactive "P")
(save-excursion
>>> import random
>>> random.random()
0.029650172560125809
>>> a = []
>>> for _ in range(10):
... a.append(random.random())
...
>>> a
[0.91210492275504895, 0.22509397965651112, 0.16240150096214034, 0.13481671367764725, 0.845419365903325, 0.28331432867986228, 0.37570713121626798, 0.75618618732045528, 0.16750228011314672, 0.19512649502603097]
>>> s = set(a)
#!/bin/sh
echo "IP address limit:"
curl -s http://twitter.com/account/rate_limit_status.json | python -c '\
import sys, pprint, simplejson
d = simplejson.loads(sys.stdin.read())
for k, v in d.items():
print "\t%s: %s" % (k, v)'
from fom.session import Fluid
fdb = Fluid()
fdb.login('username', 'password')
fdb.values.put(
query='fluiddb/about = "unidentified monkey"',
values = {
'taxonomy/ncbi/Division': 'Primates',
'taxonomy/ncbi/Lineage': [
def collectURLs(tweets):
"""
Extract all mentioned URLs from a set of tweets.
@param tweets: A C{dict} of tweets, as returned by L{getHistoricalTweets}.
@return: A C{dict} with mentioned URL keys and values a time-sorted list
of tweet URLs.
"""
URLs = defaultdict(list)
for id, tweet in tweets.iteritems():