View rails_routing_invalid_chars_fix.rb
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
# Fix for a Rails - Ruby 1.9 bug | |
# Rails Router, now that it's UTF-8 default, blows up when routing requests | |
# with invalid chars in the URL; it should properly return a 400 error | |
# Have to monkey-patch the fix in, since it's not scheduled for release until | |
# Rails 4.0. | |
# Adapted Andrew White (pixeltrix)'s fix at | |
# https://github.com/rails/rails/commit/3fc561a1f71edf1c2bae695cafa03909d24a5ca3, | |
# but edited to work in 3.0.x. | |
# 3.1.x, 3.2.x compatibility unknown | |
require 'action_dispatch/routing/route_set' |
View redis_connection_pool.rb
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
# Implement a Redis Connection Pool | |
# | |
# Convenience methods | |
# Instead of having to write: | |
# redis_pool.perform {|redis| redis.get('key')} | |
# The following can be used | |
# redis_pool.get('key') | |
# | |
# This applies to all Redis methods except quit. RedisPool#quit calls quit | |
# on all instances of Redis already in the pool |
View LICENSE
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
Copyright 2014 Kickstarter, Inc. | |
Released under an MIT License. |
View Berksfile
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
source "https://supermarket.getchef.com" | |
cookbook "apt" | |
cookbook "chef_handler" | |
cookbook "yum" | |
cookbook "simulator", git: "git@github.com:riotgameseurope/simulator.git" |
View r191.txt
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
ruby 1.9.1p243 (2009-07-16 revision 24175) [x86_64-linux] | |
curb (0.6.2.1) | |
em-http-request (0.2.5) | |
eventmachine (0.12.10) | |
typhoeus (0.1.13) | |
user system total real Memory (Kb) | |
4kb std | |
0.000000 0.000000 3.010000 ( 22.408594) 24,484 |
View Rails JSON Sessions
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
# Typically this would go in a file in /config/initializers. Note you'll also need | |
# the json gem (ideally native) and then specify this in your environment: | |
# ActiveSupport::JSON.backend = 'JSONGem' | |
# A bit of Rails magic to change the way the session is "marshalled". Essentially | |
# this bit of monkeypatching makes the MemCacheStore use JSON instead of the | |
# default Ruby marshalling in order to share data seamlessly with the node.js | |
# portion of the app. | |
# TODO: combine with a persistent store or convert to redis to better preserve | |
# sessions for lurkers |
View ngrams-and-tire.rb
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
# An example of using ngram analysis in ElasticSearch with the Tire rubygem | |
# ========================================================================== | |
# The original, raw example: https://gist.github.com/988923 | |
require 'rubygems' | |
require 'tire' | |
require 'yajl/json_gem' | |
class URL | |
def initialize(attributes={}) |
View devise_mailer.rb
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
##HACK - dmp - we must return an unserialized version of resource | |
##so copy devise's method and use a finder for resource | |
require "devise" | |
require Rails.root.join("lib/resque/mailer") | |
Devise::Mailers::Helpers.send(:alias_method, :old_initialize_from_record, :initialize_from_record) | |
module Devise | |
module Mailers | |
module Helpers |
View am_pm_time_select.rb
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
# modified from Bruno Miranda's original found here: http://brunomiranda.com/past/2007/6/2/displaying_12_hour_style_time_select/ | |
# usage: <%= form.time_select :the_time, { :twelve_hour => true } %> | |
module ActionView | |
module Helpers | |
class DateTimeSelector | |
def select_hour_with_twelve_hour_time | |
datetime = @datetime | |
options = @options |
View gist:1408381
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
# Ruby 1.9.3 | |
ruby-1.9.3-p0 ~/projects/jruby $ ruby -v bench/bench_fiber_ring.rb 5 100 1000 | |
ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-darwin10.8.0] | |
bench/bench_fiber_ring.rb:23: warning: mismatched indentations at 'end' with 'def' at 21 | |
100 fibers / 1000 passes: 0.150000 0.000000 0.150000 ( 0.155022) | |
100 fibers / 1000 passes: 0.150000 0.000000 0.150000 ( 0.153985) | |
100 fibers / 1000 passes: 0.150000 0.000000 0.150000 ( 0.153822) | |
100 fibers / 1000 passes: 0.150000 0.000000 0.150000 ( 0.152370) | |
100 fibers / 1000 passes: 0.160000 0.000000 0.160000 ( 0.155857) |
OlderNewer