Skip to content

Instantly share code, notes, and snippets.

View antiface's full-sized avatar

A.G. antiface

View GitHub Profile
@jcsalterego
jcsalterego / hashtag_wordle.py
Created January 28, 2009 13:07
Script to generate word list from search results
#!/usr/bin/env python
#
# Generates non-unique word list from Twitter Search meeting certain
# criteria (as set in the configuration, below).
#
# EXAMPLE (word wrap inserted for ease of reading):
#
# $ python hashtag_wordle.py
# Fetching http://search.twitter.com/search.json?q=%23spinuzzi-project&rpp=30&page=1...
# Fetching http://search.twitter.com/search.json?q=%23spinuzzi-project&rpp=30&page=2...
http://search.twitter.com/search.json?q=%40human_bot
{
"results": [{
"text": "@human_bot Are you feeling okay? Sounds like you've been smoking some crack with the way you've been talking lately.",
"to_user_id": 5740619,
"to_user": "human_bot",
"from_user": "taboularasa",
"id": 1306533155,
"""
walk through related tags on twitter.
start it with something like python twitterwalk.py sxsw
"""
import sys, re
from twitter import Twitter
if len(sys.argv) > 1:
import random
class Markov(object):
def __init__(self, open_file):
self.cache = {}
self.open_file = open_file
self.words = self.file_to_words()
self.word_size = len(self.words)
self.database()
@mnot
mnot / RSS.py
Created October 29, 2009 12:48
RSS.py: work with RSS channels as data structures
#!/usr/bin/env python
"""
RSS.py
Classes for working with RSS channels as arbitrary data structures.
Requires Python 2.2 or newer and PyXML 0.7.1 or newer.
ChannelBase - Base class for RSS Channels.
CollectionChannel - RSS Channel modeled as a URI-per-entry
@endolith
endolith / peakdet.m
Last active February 14, 2024 21:27
Peak detection in Python [Eli Billauer]
function [maxtab, mintab]=peakdet(v, delta, x)
%PEAKDET Detect peaks in a vector
% [MAXTAB, MINTAB] = PEAKDET(V, DELTA) finds the local
% maxima and minima ("peaks") in the vector V.
% MAXTAB and MINTAB consists of two columns. Column 1
% contains indices in V, and column 2 the found values.
%
% With [MAXTAB, MINTAB] = PEAKDET(V, DELTA, X) the indices
% in MAXTAB and MINTAB are replaced with the corresponding
% X-values.
# print a user's tweets
import simplejson
import re
import urllib2
import string
me = urllib2.urlopen('http://twitter.com/statuses/user_timeline/peteskomoroch.json?count=200')
for tweet in simplejson.loads(me.read()):
print tweet['text'].encode('utf-8')
# poll a search term every 60 seconds and print tweets out
import time
import simplejson
import re
import urllib2
import urllib
last_id = False
while True:
import gaerun
from google.appengine.ext import db
from google.appengine.api import urlfetch
from google.appengine.api import memcache
import simplejson
import logging
class User(db.Model):
name = db.StringProperty()
import nltk
import random
class Categorizer(object):
def __init__(self, categories):
self.categories = categories
def prep_seed(self, content):
"""Convert seed content into nltk.Text"""
raw = nltk.clean_html(content)