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 "mongo_mapper" | |
| MongoMapper.database = 'test_db' | |
| class Person | |
| include MongoMapper::Document | |
| key :first_name, String | |
| key :last_name, String |
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 'open-uri' | |
| # url dsl -- the ultimate url dsl! | |
| # | |
| # You just can't beat this: | |
| # | |
| # $ irb -r url_dsl | |
| # >> include URLDSL | |
| # => Object | |
| # >> http://github.com/defunkt.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
| #!/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() |
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 |
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
| #!/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
| 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 | |
| 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
| 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 'git' | |
| log = "~/gitlog.txt" | |
| tmp = "/tmp/gitlog" | |
| commit = Git.open('.').log.first | |
| message = [ | |
| commit.date.strftime('%D'), |