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
require 'thread' | |
# Borrowed from https://github.com/ruby/ruby/blob/ruby_1_9_3/lib/thread.rb#L140 | |
# and modified for a last in first out processing | |
# | |
# | |
class StackQueue < Queue | |
# Last in first out Queue | |
# | |
# Retrieves data from the queue. If the queue is empty, the calling thread is | |
# suspended until data is pushed onto the queue. If +non_block+ is true, the |
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
require 'em-synchrony/thread' | |
module AWS | |
module Core | |
class SessionSigner | |
@create_mutex = EM::Synchrony::Thread::Mutex.new | |
end | |
end | |
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
# Tested on DelayedJob 2.1 | |
class MyRecurringDelayedJob | |
def perform | |
# ...some slow code | |
end | |
def success(job) | |
MyRecurringDelayedJob.schedule_job(job) | |
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
class FoosController < ApplicationController | |
# GET /foos | |
# GET /foos.xml | |
def index | |
@foos = Foo.all | |
Foo.bad_method #should raise NoMethodError | |
respond_to do |format| | |
format.html # index.html.erb | |
format.xml { render :xml => @foos } | |
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
/Users/joshmckin/test_mysq_gem/config/initializers/em_mysql2_adapter.rb:16:in `resume': dead fiber called (FiberError) | |
from /Users/joshmckin/test_mysq_gem/config/initializers/em_mysql2_adapter.rb:16:in `block in query' | |
from /Users/joshmckin/.rvm/gems/ruby-1.9.2-p180/gems/eventmachine-0.12.10/lib/em/deferrable.rb:141:in `call' | |
from /Users/joshmckin/.rvm/gems/ruby-1.9.2-p180/gems/eventmachine-0.12.10/lib/em/deferrable.rb:141:in `set_deferred_status' | |
from /Users/joshmckin/.rvm/gems/ruby-1.9.2-p180/gems/eventmachine-0.12.10/lib/em/deferrable.rb:180:in `fail' | |
from /Users/joshmckin/.rvm/gems/ruby-1.9.2-p180/gems/mysql2-0.2.11/lib/active_record/connection_adapters/em_mysql2_adapter.rb:38:in `rescue in notify_readable' | |
from /Users/joshmckin/.rvm/gems/ruby-1.9.2-p180/gems/mysql2-0.2.11/lib/active_record/connection_adapters/em_mysql2_adapter.rb:33:in `notify_readable' | |
from /Users/joshmckin/.rvm/gems/ruby-1.9.2-p180/gems/eventmachine-0.12.10/lib/eventmachine.rb:256:in `run_machine' | |
from /Users/joshmckin/.rvm/gem |
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
module Mysql2 | |
module Fibered | |
class Client < ::Mysql2::Client | |
def query(sql, opts={}) | |
if ::EM.reactor_running? | |
super(sql, opts.merge(:async => true)) | |
deferrable = ::EM::DefaultDeferrable.new | |
::EM.watch(self.socket, Watcher, self, deferrable).notify_readable = true | |
fiber = Fiber.current | |
deferrable.callback do |result| |
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 QueuedMessage < Aws::Sqs | |
def queued_messages | |
@queued_messages ||= [] | |
@queued_messages | |
end | |
def initialize(aws_access_key_id = AWS_ACCESS_KEY_ID, aws_secret_access_key = AWS_SECRET_ACCESS_KEY, params = {}) | |
super(aws_access_key_id, aws_secret_access_key,params) | |
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
rake aborted! | |
undefined method `desc' for #<Bundler::GemHelper:0x00000101d83ab8> | |
/Users/joshmckin/.rvm/gems/ruby-1.9.2-p0/gems/bundler-1.0.10/lib/bundler/gem_helper.rb:24:in `install' | |
/Users/joshmckin/.rvm/gems/ruby-1.9.2-p0/gems/bundler-1.0.10/lib/bundler/gem_helper.rb:9:in `install_tasks' | |
/Users/joshmckin/Ventanex/vtx_operations/Rakefile:21:in `<top (required)>' | |
/Users/joshmckin/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.9.0/lib/rake/rake_module.rb:25:in `load' | |
/Users/joshmckin/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.9.0/lib/rake/rake_module.rb:25:in `load_rakefile' | |
/Users/joshmckin/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.9.0/lib/rake/application.rb:495:in `raw_load_rakefile' | |
/Users/joshmckin/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.9.0/lib/rake/application.rb:78:in `block in load_rakefile' |
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
def self.guessing_game(values=[2.5,10.95,55.25],multi_sum=4,total_goal=79.65) | |
results = nil | |
total_amount = 0.0 | |
length = values.length | |
((multi_sum ** length) / (multi_sum)).times do |i| | |
total = 0 | |
possible = [] | |
total_amount = 0.0.to_d # use decimal for accuracy |
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
in the layout file | |
<% cache("header_cache_#{session_user.id}") do %> | |
some dynamic navigation and large select box | |
<%end%> | |
in the controller | |
expire_fragment("header_cache_#{session_user.id}") |
NewerOlder