This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'twitter' | |
tweets = Twitter.user_timeline("andymboyle").collect {|r| r['text'] }.reverse | |
tweets = tweets.collect {|r| r.gsub(/(^|\s+)(?:I|me)([[:punct:]]|\s+|$)/i,'\1you\2') } | |
tweets = tweets.collect {|r| r.gsub(/(^|\s+)my([[:punct:]]|\s+|$)/i,'\1your\2') } | |
tweets = tweets.collect {|r| r.gsub(/(^|\s+)mine([[:punct:]]|\s+|$)/i,'\1yours\2') } | |
tweets = tweets.collect {|r| r.gsub(/(^|\s+)am([[:punct:]]|\s+|$)/i,'\1are\2') } | |
tweets = tweets.collect {|r| r.gsub(/(^|\s+)we'll([[:punct:]]|\s+|$)/i,'\1you\'ll\2') } | |
tweets = tweets.collect {|r| r.gsub(/(^|\s+)I'd([[:punct:]]|\s+|$)/i,'\1you\'d\2') } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'benchmark' | |
Benchmark.bm do |x| | |
x.report do | |
t = "Holy shit! I THINK I JUST SAW A ZUNE. This is a sign from the elder gods that means my trip shall bring me good fortune, right?" | |
t = t.gsub(/(^|\s+)(?:I|me)([[:punct:]]|\s+|$)/i,' you ') | |
end | |
x.report do | |
t = "Holy shit! I THINK I JUST SAW A ZUNE. This is a sign from the elder gods that means my trip shall bring me good fortune, right?" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# much of this copied from | |
# http://adam.heroku.com/past/2010/3/19/consuming_the_twitter_streaming_api/ | |
require 'eventmachine' | |
require 'em-http' | |
require 'json' | |
class AndyMZork | |
MATCH_PREFIX = /(^|\s+)/ | |
MATCH_SUFFIX = /([[:punct:]]|\s+|$)/ | |
MATCHERS = { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Conversation | |
attr_reader :convo | |
def initialize(tweet) | |
tweet.to_s =~ /(\d+)$/ | |
@tweet_id = $1 || raise("#{$1} is not a valid tweet") | |
@convo = [] | |
end | |
def run |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class USCode | |
SEARCH_ENDPOINT = "http://uscode.house.gov/uscode-cgi/fastweb.exe?search" | |
@@search_params = { | |
:view => "uscview", | |
:db2 => "t01t04" , | |
:db3 => "t05t08" , | |
:db4 => "t09t12" , | |
:db5 => "t13t16" , | |
:db6 => "t17t20" , | |
:db7 => "t21t25" , |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//love this thing @tysone made to randomly generate only pretty colors | |
var random_color = 'rgb(' + (Math.floor(Math.random() * 256)) + ',' + (Math.floor(Math.random() * 182)) + ',' + (Math.floor(Math.random() * 230)) + ')'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(){ | |
var $$ = function(query){ | |
!!(query && query.nodeType == 1) ? | |
this.dom = query | |
: | |
this.dom = document.getElementById(query); | |
}; | |
$$.prototype.remove = function(){ | |
this.dom.parentNode.removeChild(this.dom); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(){ | |
var $$ = function(query){ | |
!!(query && query.nodeType == 1) ? | |
this.dom = query | |
: | |
this.dom = document.getElementById(query); | |
}; | |
$$.prototype.remove = function(){ | |
this.dom.parentNode.removeChild(this.dom); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(){ | |
var $$ = function(query){ | |
!!(query && query.nodeType == 1) ? | |
this.dom = query | |
: | |
this.dom = document.getElementById(query); | |
}; | |
$$.prototype.remove = function(){ | |
this.dom.parentNode.removeChild(this.dom); |