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 MyModule < Module | |
attr_reader :description | |
def initialize(description, *args, &b) | |
@description = description | |
super(*args, &b) | |
end | |
end | |
class Foo | |
include MyModule.new('has SPECIAL ivar') {|mod| |
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
# coding: utf-8 | |
Delayed::Worker.destroy_failed_jobs = false | |
Delayed::Worker.sleep_delay = 5 | |
Delayed::Worker.max_attempts = 1 | |
Delayed::Worker.max_run_time = 1.hours | |
Delayed::Worker.delay_jobs = !Rails.env.test? | |
if Rails.env.development? | |
Delayed::Worker.lifecycle.before(:perform) do | |
puts "Reloading Rails app..." |
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
# vim:set ft=nginx: | |
worker_processes 2; | |
pid /Users/moro/.nginx/nginx.pid; | |
error_log /Users/moro/.nginx/error.log; | |
events { | |
worker_connections 1024; | |
} | |
http { |
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 EachActual | |
class Proxy | |
def initialize(collection, attr = nil) | |
@actual = attr ? collection.map(&:attr) : collection | |
end | |
def should(matcher = nil) | |
@actual.each do |obj| | |
obj.should matcher | |
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
# coding: utf-8 | |
$: << File.dirname(__FILE__) + '/terminal' | |
$: << File.dirname(__FILE__) + '/logic_device' | |
require 'terminal' | |
require 'xor' | |
require 'and' | |
describe LogicDevice do | |
RSpec::Matchers.define :compute do |*data, expect| |
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 'pp' | |
require 'json' | |
require 'net/https' | |
https = Net::HTTP.new('api.github.com', 443) | |
https.use_ssl = true | |
https.ca_path = '/etc/ssl/certs' | |
https.verify_mode = OpenSSL::SSL::VERIFY_PEER | |
https.verify_depth = 5 |
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 IncludeWithArgs | |
def self.extended(mod) | |
Kernel.send(:define_method, mod.name) do |*args| | |
Module.new do | |
include mod | |
define_method :args do args end | |
private :args | |
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
require 'bundler/setup' | |
require 'sinatra/base' | |
require 'thin' | |
require 'eventmachine' | |
class MyApp < Sinatra::Base | |
get '/hi' do | |
response[:content_type] = 'text/plain' | |
'hi' | |
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 Symbol | |
def <<(args) | |
lambda {|x| x.send(self, *args) } | |
end | |
end | |
p [{:a => 1}].find(&:key? << :a) # => {:a => 1} | |
p [{:a => 1}].find(&:key? << :b) # => nil | |
p [["abc", "efg"], ["foo", "bar"]].map(&:join << "-") # => ["abc-efg", "foo-bar"] |
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 'digest/sha1' | |
module SecureCookieViolationProtect | |
extend ActiveSupport::Concern | |
included do | |
before_filter do | |
return true unless request.ssl? | |
return true if secure_cookie_token(session[:token]) == cookies[:secure_cookie_token] |