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
| EM.run do | |
| t = Time.now | |
| Fiber.new{ sleep(1) }.resume | |
| Fiber.new{ sleep(1) }.resume | |
| puts Time.now - t | |
| # 2 seconds have elapsed. No concurrency is achieved. | |
| EM.stop | |
| 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
| class Blah | |
| @counter = 0 | |
| @incr: -> | |
| return @counter += 1 | |
| constructor: | |
| @counter = 0 |
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
| module User::Ascents | |
| extend ActiveSupport::Concern | |
| included do | |
| has_many :fun_ascents, :class_name => "Ascent" | |
| end | |
| def self.extended(object) | |
| object.singleton_class.send(:include, self) | |
| 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
| module User::Ascents | |
| def self.extended(object) | |
| object.singleton_class.class_eval do | |
| has_many :fun_ascents, :class_name => "Ascent" | |
| 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
| $ sudo RAILS_ENV=staging bundle exec god -c config/god/resque.rb -D | |
| I [2011-11-13 04:46:05] INFO: Loading config/god/resque.rb | |
| I [2011-11-13 04:46:05] INFO: Syslog enabled. | |
| I [2011-11-13 04:46:05] INFO: Using pid file directory: /home/sender/sender_staging/current/tmp/pids | |
| I [2011-11-13 04:46:05] INFO: Started on drbunix:///tmp/god.17165.sock | |
| I [2011-11-13 04:46:05] INFO: resque-00 move 'unmonitored' to 'init' | |
| I [2011-11-13 04:46:05] INFO: resque-00 moved 'unmonitored' to 'init' | |
| I [2011-11-13 04:46:05] INFO: resque-00 [trigger] process is running (ProcessRunning) | |
| I [2011-11-13 04:46:05] INFO: resque-00 move 'init' to 'up' | |
| I [2011-11-13 04:46:05] INFO: resque-00 registered 'proc_exit' event for pid 8972 |
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 "iconv" | |
| def sanitize_utf8(string) | |
| string = string.encode("UTF-8", :invalid => :replace, :undef => :replace) | |
| begin | |
| string.blank? # Assume you're using ActiveSupport | |
| rescue ArgumentError => e | |
| if e.message == "invalid byte sequence in UTF-8" | |
| Thread.current["iconv"] ||= Iconv.new('UTF-8//IGNORE', 'UTF-8') | |
| string = Thread.current["iconv"].iconv(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 "active_support" | |
| module RoleA | |
| def self.extended(object) | |
| object.singleton_class.class_eval do | |
| puts "blah" | |
| puts object.inspect | |
| include ActiveSupport::Callbacks | |
| define_callbacks :save |
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
| # ruby-1.9.3-p0 | |
| # Run in IRB... | |
| require "thread" | |
| q = Queue.new | |
| q.pop # fatal: deadlock detected | |
| q.pop # blocks properly |
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
| <table class="normalize-size"> | |
| <<<<<<< HEAD | |
| <tbody> | |
| <tr> | |
| <td><%= t("oa.users.system.display_name") %></td> | |
| <td><%= user.display_name %></td> | |
| </tr> | |
| <tr> |
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 "spec_helper" | |
| class RecordWrapper | |
| def initialize(record) | |
| @record = record | |
| end | |
| end | |
| module RelationWrapping |