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
| diff --git a/lib/erlang/apps/beehive/src/bh_rest/rest_server.erl b/lib/erlang/apps/beehive/src/bh_rest/rest_server.erl | |
| index e767a73..df26bfd 100644 | |
| --- a/lib/erlang/apps/beehive/src/bh_rest/rest_server.erl | |
| +++ b/lib/erlang/apps/beehive/src/bh_rest/rest_server.erl | |
| @@ -217,17 +217,24 @@ generalize_request_path(Path) -> | |
| atomize_keys(Data) -> | |
| + erlang:display(Data), |
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 ConsistentHashing | |
| module JenkinsOneAtATime | |
| extend self | |
| def hash_to_unit_circle(key) | |
| hash(key)/0xffffffff.to_f | |
| end | |
| def hash(key) | |
| hash = 0 |
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
| From 26916c011b5134d542632c98bd90fbe4769fa280 Mon Sep 17 00:00:00 2001 | |
| From: Jacob Dunphy <jacob.dunphy@gmail.com> | |
| Date: Thu, 25 Mar 2010 13:11:28 -0700 | |
| Subject: [PATCH] ! Add RubyInline as a dependency | |
| --- | |
| Rakefile | 1 + | |
| 1 files changed, 1 insertions(+), 0 deletions(-) | |
| diff --git a/Rakefile b/Rakefile |
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 'rubygems' | |
| require 'httparty' | |
| require 'json' | |
| class LoggedRequest | |
| attr_reader :response_time, :path, :status | |
| def initialize(request) | |
| if request =~ /\"[A-Z]{3,4}\ (.+)\ HTTP/ | |
| @path = $1.gsub('//', '/') |
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 'active_support/memoizable' | |
| module ActionDispatch | |
| module Http | |
| class Headers < ::Hash | |
| extend ActiveSupport::Memoizable | |
| def initialize(*args) | |
| if args.size == 1 && args[0].is_a?(Hash) | |
| super() |
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
| def id_is(attribute) | |
| (file, line) = caller.first.split(':') | |
| class_eval(<<-EOS, file, line.to_i) | |
| def #{attribute}=(value) | |
| #{attribute} = value.to_i | |
| end | |
| attr_reader #{attribute.inspect} | |
| alias :id #{attribute.inspect} |
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 Module | |
| %23 Declare an attribute accessor with an initial default return value. | |
| # | |
| # To give attribute <tt>:age</tt> the initial value <tt>25</tt>: | |
| # | |
| # class Person | |
| # attr_accessor_with_default :age, 25 | |
| # end | |
| # | |
| # some_person.age |
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 | |
| require 'fileutils' | |
| dirs = Dir.glob(ARGV[0] ? "#{ARGV[0]}/*" : '*') | |
| dirs.each do |dir| | |
| if File.directory?(dir) | |
| puts "Updating #{dir}" | |
| FileUtils.cd dir |
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
| def aliased_table_name_for(name, suffix = nil) | |
| if !parent.table_joins.blank? && parent.table_joins.to_s.downcase =~ %r{join(\s+\w+)?\s+#{active_record.connection.quote_table_name name.downcase}\son} | |
| @join_dependency.table_aliases[name] += 1 | |
| end | |
| unless @join_dependency.table_aliases[name].zero? | |
| # if the table name has been used, then use an alias | |
| name = active_record.connection.table_alias_for "#{pluralize(reflection.name)}_#{parent_table_name}#{suffix}" | |
| table_index = @join_dependency.table_aliases[name] | |
| @join_dependency.table_aliases[name] += 1 |
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 'benchmark' | |
| runs = 10000 | |
| runner = "Benchmark.bm do |x|" | |
| ARGV.each do |arg| | |
| runner << " | |
| x.report(\"#{arg.tr('"',"'")}\") do | |
| runs.times do | |
| #{arg} | |
| end |