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
require "benchmark/ips" | |
require "date" | |
base = Date.new(Date.today.year) | |
Benchmark.ips do |x| | |
x.compare! | |
x.report("int 1") { base + (100) } | |
x.report("int 2") { base + (100 - 1) } | |
x.report("int 3") { base + (100 - 1 - 1) } | |
x.report("int 4") { base + (100 - 1 - 1 - 1) } |
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
require 'benchmark/ips' | |
require 'bigdecimal' | |
VALUES = ['100.123', 100.123, '100', 100, Rational(1), Rational(4,1), Rational(0.3), BigDecimal.new('758.3'), 13289301283 ** 2, 0xf5] | |
module Hanami | |
module Utils | |
module Kernel | |
NUMERIC_MATCHER = /\A([\d\/\.\+iE]+|NaN|Infinity)\z/.freeze | |
def self.BigDecimalGem(arg) |
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
require 'benchmark/ips' | |
thing = 102 | |
Benchmark.ips do |x| | |
x.report('block') do | |
case thing | |
when -> (a) { a < 100 && a.even? } then 1 | |
when -> (a) { a > 100 && a.odd? } then 2 | |
else 3 | |
end |
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
## View Hierarchy | |
Web::Views::Home::WithPartial | |
Web::Views::Home::AnotherSubclass < Web::Views::Home::WithPartial | |
## Add some debug code | |
# in view/rendering/registry.rb | |
def initialize(*args) | |
puts "Creating registry #{object_id} for #{args}" |
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
gem 'activerecord', '3.2.13' | |
require 'active_record' | |
require 'minitest/autorun' | |
require 'logger' | |
ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: ':memory:') | |
ActiveRecord::Base.logger = Logger.new(STDOUT) | |
ActiveRecord::Schema.define do |
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
require 'uri' | |
require 'pry' | |
module Lotus | |
module Helpers | |
# Helper methods to generate asset-paths | |
# | |
# @since 0.6.0 | |
# @api public |
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
require 'rubygems' | |
require 'withings' | |
include Withings | |
Withings.consumer_secret = 'ABCD' | |
Withings.consumer_key = 'EFGH' | |
user_id = 12345 | |
token = '5678' |
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
[code language="ruby"] | |
puts "hello world" | |
[/code] |