This file contains 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
## Anyone care to explain why using Time.now and Time.zone.now result in two different times in the db? | |
>> e = Event.create(:title => "Test2", :url => "http://tests.com", :length => 60, :starts_at => Time.now + 1.day) | |
=> #<Event id: 4, user_id: nil, title: "Test2", url: "http://tests.com", starts_at: "2008-09-23 16:05:14", length: 60, category_id: nil, format_id: nil, advertisment_type: nil, highlight_type: nil, created_at: "2008-09-22 20:05:14", updated_at: "2008-09-22 20:05:14", permalink: "test2", description: nil, popularity: 0.0, promoted: false> | |
>> Time.now + 1.day | |
=> Tue Sep 23 16:05:26 -0400 2008 | |
>> e = Event.create(:title => "Test2", :url => "http://tests.com", :length => 60, :starts_at => Time.zone.now + 1.day) | |
=> #<Event id: 5, user_id: nil, title: "Test2", url: "http://tests.com", starts_at: "2008-09-23 20:05:43", length: 60, category_id: nil, format_id: nil, advertisment_type: nil, highlight_type: nil, created_at: "2008-09-22 20:05:43", updated_at: "2008-09-22 20:05:43", permalink: "test |
This file contains 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
########## Why does the yield output outside the content_tag block? | |
# Method | |
def submit(*args) | |
@template.content_tag(:div, :class => "save_actions") { | |
super(*args) + (yield).to_s | |
} | |
end | |
This file contains 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
#### spec_factory.rb | |
require 'factory_girl' | |
Factory.sequence :login do |n| | |
"bob#{n}" | |
end | |
Factory.sequence :email do |n| | |
"person#{n}@example.com" | |
end |
This file contains 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
# Specs | |
describe "process" do | |
before(:each) do | |
@starling = mock(Starling) | |
Starling.should_receive(:new).and_return(@starling) | |
@queue = Tweetbot::Queue.new | |
end | |
This file contains 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/env ruby | |
def mem_usage | |
`ps -o rss= -p #{$$}`.to_i | |
end | |
count = (ARGV[0] || 5).to_i | |
puts "current process id is #{$$}" | |
puts "Memory before anything: #{mem_usage}" |
This file contains 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/env ruby | |
def mem_usage | |
`ps -o rss= -p #{$$}`.to_i | |
end | |
@count = (ARGV[0] || 5).to_i | |
puts "current process id is #{$$}" | |
puts "Memory before anything: #{mem_usage}" |
This file contains 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 Mailer < ActionMailer::ARMailer | |
def setup_template(name, email) | |
site = SiteSetting.find(:first) | |
from site.admin_email.to_s | |
self.mailer_name = 'shared' | |
self.template = 'email' | |
options = { 'site' => site } | |
yield options if block_given? | |
This file contains 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
1) | |
NoMethodError in 'UserMailer should create a new email row when sending an email' | |
You have a nil object when you didn't expect it! | |
The error occurred while evaluating nil.render_subject | |
/Users/josh/Code/HandCrafted/bootstrap/app/models/mailer.rb:16:in `setup_template' | |
/Users/josh/Code/HandCrafted/bootstrap/app/models/user_mailer.rb:23:in `setup_user_notification_email' | |
/Users/josh/Code/HandCrafted/bootstrap/app/models/user_mailer.rb:9:in `activation' | |
/Library/Ruby/Gems/1.8/gems/actionmailer-2.1.1/lib/action_mailer/base.rb:446:in `__send__' | |
/Library/Ruby/Gems/1.8/gems/actionmailer-2.1.1/lib/action_mailer/base.rb:446:in `create!' | |
/Library/Ruby/Gems/1.8/gems/actionmailer-2.1.1/lib/action_mailer/base.rb:439:in `initialize' |
This file contains 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/env ruby | |
require 'rubygems' | |
require 'mysql' | |
require 'highline/import' | |
database = ARGV[0] + "_production" | |
username = ARGV[0] + "_dba" | |
password = ask("Enter the password for the new database: ") { |q| q.echo = "*" } | |
root_password = ask("Enter your root database password: ") { |q| q.echo = "*" } | |
This file contains 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
this.loadCSS(this.doc,"/stylesheet/style.css"); | |
html = "<div id='events'>" | |
html += "<div class=\'vevent clearfix\'>\n <div class=\'header clearfix\'>\n <abbr class=\'dtstart\' title=\'2008-09-10\'>Wed - Feb 11, 2009 @ 01:00PM CST<\/abbr>\n <span class=\'starts_in\'>Starts in 5 days<\/span>\n <\/div>\n <div class=\'voting\'>\n <div class=\'vote_count\'>\n <span class=\'vote_number\'>1<\/span>\n <span>vote<\/span>\n <\/div>\n <div class=\'vote_action\'>\n <div class=\'voteup\'>\n <span><a href=\"http://calfeed.local/events/25-test-8/vote\">vote up<\/a><\/span>\n <\/div>\n <\/div>\n <\/div>\n <div class=\'body\'>\n <h3 class=\'summary\'>\n <a href=\"/events/25-test-8\" class=\"url\">Test<\/a>\n <\/h3>\n <div class=\'description\'>\n <p>Apple / (test.com) – Test <a href=\"/events/25-test-8\">read more<\/a><\/p>\n <\/div>\n <div class=\'tools clearfix\'>\n <ul>\n <li class=\'comments_count\'><a href=\"/events/25-test- |
OlderNewer