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
#!/usr/bin/ruby | |
# cronjob set up like this: | |
# */5 * * * * /var/cron/twitter.rb 12571852 > /var/www/davideisinger.com/twitter.txt | |
# */5 * * * * /var/cron/twitter.rb 14090058 > /var/www/sarahbetheisinger.com/twitter.txt | |
require 'rubygems' | |
require 'net/http' | |
require 'json' | |
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
curdate = "" | |
data = File.open("fights.txt").read | |
data.gsub!(/^(Month|Name|Red|Gray).*\n/, '') | |
data.gsub!(/\t/, '","') | |
data.gsub!(/^/, '"').gsub!(/$/, '"') | |
data.gsub!(/(\w+), (\w+)/, "\\2 \\1") | |
data.gsub!(/(,"")*$/, '') | |
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
# http://www.fmwconcepts.com/imagemagick/autocolor/index.php | |
mkdir optimized | |
title="Happy Hour" | |
n=1 | |
for file in DSC* | |
do | |
convert $file -resize "800x600>" resized.jpg | |
~/Projects/scripts/autocolor -m none resized.jpg optimized.jpg |
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
#!/usr/bin/ruby | |
require 'rubygems' | |
require 'git' | |
log = "~/gitlog.txt" | |
tmp = "/tmp/gitlog" | |
commit = Git.open('.').log.first | |
message = [ | |
commit.date.strftime('%D'), |
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
User.find(:all, :conditions => ["created_at >= ?", Time.local(2009, 1, 26)]).each do |u| | |
if u.speaker | |
puts "#{u.created_at.to_date} #{u.speaker.name}" | |
end | |
end | |
Speaker.all.last(20).map {|s| s.talks.any? && s.talks.first.creator.speaker.name } | |
Speaker.all.each do |s| | |
puts s.name + "\t\t" + s.claim_code unless s.claim_code.blank? |
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
#!/usr/bin/ruby | |
require 'rubygems' | |
require 'activesupport' | |
require 'git' | |
AUTHORS = ['deisinger', 'David Eisinger'] | |
Git.open('.').log(300).select { |commit| | |
AUTHORS.include?(commit.author.name) and commit.message.strip.match(/^(Merge|git-svn)/).nil? |
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 Test::Unit::TestCase | |
def self.should_sum_total_ratings | |
klass = model_class | |
context "finding total ratings" do | |
setup do | |
@ratable = Factory(klass.to_s.downcase) | |
end | |
should "have zero total ratings if no rated talks" do |
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
#!/usr/bin/ruby | |
# Download all MP3 files linked from a given URL | |
require "open-uri" | |
url = ARGV.first | |
data = open(url) | |
data.read.scan(/href="(.*mp3)"/).each do |filename| |
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
Activity.record_timestamps = false | |
Post.all.each do |post| | |
if post.published? | |
post.create_activity(:updated_at => post.updated_at) | |
end | |
end | |
Comment.all.each do |comment| | |
obj = comment.commentable |
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
dups = Notification.undelivered.all(:select => "user_id, about_id, about_type, COUNT(*) AS dup_count", | |
:group => "user_id, about_id, about_type HAVING dup_count > 1") | |
dups.each do |dup| | |
notes = Notification.find_all_by_user_id_and_about_id_and_about_type(dup.user_id, dup.about_id, dup.about_type) | |
notes[1..-1].each(&:destroy) | |
end |
OlderNewer