Skip to content

Instantly share code, notes, and snippets.

#!/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'
@dce
dce / Warrior X-Fit Spreadsheet Import
Created December 15, 2008 20:58
Warrior X-Fit Fight Data Conversion
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!(/(,"")*$/, '')
# 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
@dce
dce / gist:54714
Created January 29, 2009 20:11
SpeakerRate User Activity Report
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?
@dce
dce / gitlog.rb
Created April 2, 2009 20:01
gitlog.rb
#!/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?
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
#!/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|
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
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
@dce
dce / after-use
Created August 27, 2009 18:52 — forked from defunkt/after-use
#!/usr/bin/osascript
run_command("cd ~/Projects/resque")
run_command("redis-server redis.conf")
open_tab()
run_command("cd ~/Projects/resque")
run_command("shotgun config.ru")
open_tab()