Skip to content

Instantly share code, notes, and snippets.

@nragaz
nragaz / YUI Charts from Tables - Line, Pie
Created February 21, 2009 19:03
Load this file to convert table.yui-line and table.yui-pie to line and pie charts using JS and Flash.
/*
Converts well-formed HTML tables with class 'yui-line' or 'yui-pie'
to Flash charts, using YUI Loader and YUI charts.
Tables for pie charts look like:
+--------------------------------------------------+
| | Total |
+-------------------------------------+------------+
| Item 1 | 16 |
We couldn’t find that file to show.
def rails_gems
gemrc = {
:verbose => true,
:gem => '--no-ri --no-rdoc',
:update_sources => true,
:sources => [
'http://rubygems.org'
]
}
gemrc.merge!(configuration[:rubygems]) if configuration[:rubygems]
@nragaz
nragaz / all.god
Created July 12, 2010 03:16
God configs for starting Resque and Unicorn
PID_DIR = '/srv/myapp/shared/pids'
RAILS_ENV = ENV['RAILS_ENV'] = 'production'
RAILS_ROOT = ENV['RAILS_ROOT'] = '/srv/myapp/current'
BIN_PATH = "/home/rails/.rvm/gems/ree-1.8.7-2010.02/bin"
God.log_file = "#{RAILS_ROOT}/log/god.log"
God.log_level = :info
%w(unicorn resque).each do |config|
God.load "#{RAILS_ROOT}/config/god/#{config}.god"
CURRENT_RUBY = 'ree-1.8.7-2010.02'
RUBY_PATH = "/home/rails/.rvm/rubies/#{CURRENT_RUBY}"
GEM_HOME = "/home/rails/.rvm/gems/#{CURRENT_RUBY}"
ssh_options[:paranoid] = false
ssh_options[:forward_agent] = true
default_run_options[:pty] = true
set :stages, %w(staging production)
@nragaz
nragaz / unicorn.rb
Created July 12, 2010 03:34
unicorn.rb
# unicorn_rails -c /srv/myapp/current/config/unicorn.rb -E production -D
rails_env = ENV['RAILS_ENV'] || 'production'
working_directory (rails_env == 'production' ? "/srv/myapp/current" : `pwd`.gsub("\n", ""))
worker_processes (rails_env == 'production' ? 10 : 4)
preload_app true
timeout 30
if rails_env == 'production'
@nragaz
nragaz / rails.history.js
Created January 16, 2011 23:43
Add callbacks to remote links in Rails to manage browser history using pageState and replaceState
function historySupport() {
return !!(window.history && window.history.pushState !== undefined);
}
function pushPageState(state, title, href) {
if (historySupport()) {
history.pushState(state, title, href);
}
}
@nragaz
nragaz / weekday_hours.sql
Created March 16, 2011 03:21
Calculate M-F hours between 2 times in MySQL
@new := reports.downloaded_at,
@old := pages.created_at,
@oldWeek := WEEK(@old, 2),
@newWeek := WEEK(@new, 2),
@weekends := @newWeek - @oldWeek,
@weekendSecs := @weekends * 172800,
@oldWeekSaturday := STR_TO_DATE( CONCAT(DATE_FORMAT(@old, '%X%V'), ' Saturday'), '%X%V %W %h-%i-%s'),
@extraFirstWeekSecs := TIME_TO_SEC( TIMEDIFF(@old, @oldWeekSaturday) ),
@extraFirstWeekSecs := (@extraFirstWeekSecs > 0) * @extraFirstWeekSecs,
@newWeekSaturday := STR_TO_DATE( CONCAT(DATE_FORMAT(@new, '%X%V'), ' Saturday'), '%X%V %W %h-%i-%s'),
@nragaz
nragaz / consumer.rb
Created March 22, 2011 17:33
Consumer class to wrap Active Resource for OAuth
# Example usage:
#
# class Account < ActiveResource::Base
# self.site = "http://localhost:3000"
# end
#
# consumer = Consumer.new( user.access_token, Account )
# consumer.find(1) # => equivalent to Account.find(1), but with OAuth
class Consumer
diff --git a/activerecord/test/cases/attribute_methods_test.rb b/activerecord/test/cases/attribute_methods_test.rb
index 276e4be..fd85fb7 100644
--- a/activerecord/test/cases/attribute_methods_test.rb
+++ b/activerecord/test/cases/attribute_methods_test.rb
@@ -130,23 +130,6 @@ class AttributeMethodsTest < ActiveRecord::TestCase
assert_equal ActiveSupport::TimeZone["Pacific Time (US & Canada)"], record.written_on.time_zone
end
end
-
- def test_read_attributes_after_type_cast_on_datetime