This gist is part of a blog post. Check it out at:
http://jasonrudolph.com/blog/2011/08/09/programming-achievements-how-to-level-up-as-a-developer
| # = Icebox : Caching for HTTParty | |
| # | |
| # Cache responses in HTTParty models [http://github.com/jnunemaker/httparty] | |
| # | |
| # === Usage | |
| # | |
| # class Foo | |
| # include HTTParty | |
| # include HTTParty::Icebox | |
| # cache :store => 'file', :timeout => 600, :location => MY_APP_ROOT.join('tmp', 'cache') |
This gist is part of a blog post. Check it out at:
http://jasonrudolph.com/blog/2011/08/09/programming-achievements-how-to-level-up-as-a-developer
| #!/usr/bin/env ruby | |
| # 2011-10-10 20:57:53 +1000 | |
| def merge_sort(a) | |
| return a if a.size <= 1 | |
| l, r = split_array(a) | |
| result = combine(merge_sort(l), merge_sort(r)) | |
| end |
| # rbenv install | |
| ## Assumptions | |
| You are using homebrew. | |
| ## What to install? | |
| * https://github.com/sstephenson/rbenv.git |
| #!/usr/bin/env ruby | |
| require './injection' | |
| require 'pry' | |
| class CallTracker < BasicObject | |
| attr_reader :tracked_calls | |
| def initialize | |
| @tracked_calls = ::Hash.new { |h, k| h[k] = 0 } |
Work in progress, I'll write this up properly when I'm done.
Almost all credit goes to @maxogden for putting me on to this and pointing me in the right direction for each of these items.
Prerequisites:
| module Views | |
| class Rat < SimpleDelegator | |
| begin | |
| include Decorator | |
| rescue NameError => e | |
| end | |
| def initialize(data) | |
| super OpenStruct.new(attributes[data]) | |
| end |
| require "active_support" | |
| require "active_support/key_generator" | |
| require "json" | |
| # Based on https://gist.github.com/mattetti/7624413 | |
| module JsonSessionSerializer | |
| def self.load(value) | |
| begin | |
| JSON.parse(value) | |
| rescue JSON::ParserError |