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
| ActiveRecord::Base.logger = Logger.new(STDOUT) | |
| ActiveRecord::Base.connection_pool.clear_reloadable_connections! |
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
| mysql> SELECT 5 / NULL; | |
| +----------+ | |
| | 5 / NULL | | |
| +----------+ | |
| | NULL | | |
| +----------+ | |
| 1 row in set (0.00 sec) |
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
| >> c.preview_channels_json | |
| => ["{\"id\":1,\"network_label\":\"Facebook\"}", "{\"id\":720703596,\"network_label\":\"Twitter\"}"] | |
| >> c.preview_channels_json.to_json | |
| => "[\"{\\\"id\\\":1,\\\"network_label\\\":\\\"Facebook\\\"}\",\"{\\\"id\\\":720703596,\\\"network_label\\\":\\\"Twitter\\\"}\"]" | |
| >> c.preview_channels_json.to_json.to_json | |
| => "\"[\\\"{\\\\\\\"id\\\\\\\":1,\\\\\\\"network_label\\\\\\\":\\\\\\\"Facebook\\\\\\\"}\\\",\\\"{\\\\\\\"id\\\\\\\":720703596,\\\\\\\"network_label\\\\\\\":\\\\\\\"Twitter\\\\\\\"}\\\"]\"" | |
| >> c.preview_channels_json.to_json.to_json.to_json | |
| => "\"\\\"[\\\\\\\"{\\\\\\\\\\\\\\\"id\\\\\\\\\\\\\\\":1,\\\\\\\\\\\\\\\"network_label\\\\\\\\\\\\\\\":\\\\\\\\\\\\\\\"Facebook\\\\\\\\\\\\\\\"}\\\\\\\",\\\\\\\"{\\\\\\\\\\\\\\\"id\\\\\\\\\\\\\\\":720703596,\\\\\\\\\\\\\\\"network_label\\\\\\\\\\\\\\\":\\\\\\\\\\\\\\\"Twitter\\\\\\\\\\\\\\\"}\\\\\\\"]\\\"\"" |
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
| # Wrap write_attribute to remember original attribute value. | |
| def write_attribute_with_dirty(attr, value) | |
| attr = attr.to_s | |
| # The attribute already has an unsaved change. | |
| if changed_attributes.include?(attr) | |
| old = changed_attributes[attr] | |
| changed_attributes.delete(attr) unless field_changed?(attr, old, value) | |
| else | |
| old = clone_attribute_value(:read_attribute, attr) |
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 'activesupport' | |
| require 'harvest' | |
| harvest = Harvest(:email => "lulz", | |
| :password => "lulz", | |
| :sub_domain => "lulz") | |
| project = harvest.projects.find(:all).first |
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
| # BEFORE | |
| >> a = User.new; a.valid? | |
| >> a.errors.to_json | |
| => "[["name", "can't be blank"], ["password_confirmation", "can't be blank"], ["password", "can't be blank"], ["password", "is too short (minimum is 6 characters)"], ["email", "can't be blank"], ["email", "is too short (minimum is 6 characters)"], ["email", "should look like an email address."]]" | |
| # config/initializers/sane_errors_to_json.rb | |
| module ActiveRecord | |
| class Errors | |
| def to_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
| class ActionMailer::Base | |
| cattr_accessor :delayed_mail_handler | |
| class << self | |
| def method_missing_with_delayed_mail_handling(name, *args) | |
| if @@delayed_mail_handler | |
| @@delayed_mail_handler.to_s.classify.constantize.handle_mail(self, name, *args) | |
| else |
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 Time | |
| def with_interval_of(interval) | |
| @interval = interval | |
| self | |
| end | |
| def succ | |
| @interval ||= 1 | |
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 Array | |
| def detect_index(&block) | |
| each_with_index do |e, i| | |
| return i if yield e | |
| end | |
| end | |
| 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
| ~/projects/[project](master) $ git pull | |
| Current branch master is up to date. | |
| ~/projects/[project](master) $ script/plugin install git://github.com/technoweenie/relative_time_helpers.git/ | |
| Initialized empty Git repository in /Users/nik/projects/[project]/vendor/plugins/relative_time_helpers/.git/ | |
| fatal: bad revision 'HEAD' | |
| refusing to pull with rebase: your working tree is not up-to-date |