Skip to content

Instantly share code, notes, and snippets.

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') }
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?"
# 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 = {
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
@ashaw
ashaw / git-hashtags.rb
Created February 14, 2011 19:08
git-hashtags
#!/usr/bin/env ruby
commit =`git log -n 1 --oneline`
commit =~ /^([a-z0-9]+).+?#([A-Za-z0-9\._-]+)(?:$| )/
sha,tag = $1,$2
if tag
`git tag #{tag} #{sha}`
commit_without_tag = commit.gsub(/#{sha}/,'').gsub(/##{tag}/,'').strip
`git commit --amend -m "#{commit_without_tag}"`
end
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" ,
//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)) + ')';
(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);
(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);
(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);