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
| # Force the underlying store for a Set to be an OrderedHash. | |
| class OrderedSet < Set | |
| def initialize(enum = nil, &block) | |
| @hash ||= ActiveSupport::OrderedHash.new | |
| super | |
| 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
| # Memcache wrapping in a declarative fashion. | |
| # | |
| # Usage example: | |
| # | |
| # class << self | |
| # extend Utils::MemoizableWithMC | |
| # | |
| # def get_host_details(id) | |
| # select('host_first_name, host_last_name, host_email').find(id) | |
| # 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
| #!/usr/bin/env ruby | |
| # http://en.wikipedia.org/wiki/RADIX-50 | |
| class String | |
| R50_CHARS = " ABCDEFGHIJKLMNOPQRSTUVWXYZ$.%0123456789" | |
| R50_LOOKUP = {}.tap { |h| String::R50_CHARS.split(//).each_with_index { |c, i| h[c] = i } } | |
| R50_CLEAN = /[[:upper:]|[:digit:]| |.|$|%]/ | |
| def radix50 | |
| [].tap do |r| | |
| self.upcase.scan(R50_CLEAN).inject([]) do |m, c| | |
| m << R50_LOOKUP[c] |
NewerOlder