D, Y = 8, 0
8===D-- ( Y )
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' | |
| Benchmark.bmbm do |b| | |
| b.report("single") do | |
| 10_000.times do | |
| 'some string' | |
| end | |
| end | |
| b.report("double") do | |
| 10_000.times do | |
| "some string" |
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
| /* yes - output a string repeatedly until killed | |
| Copyright (C) 1991-1997, 1999-2004, 2007-2011 Free Software Foundation, Inc. | |
| This program is free software: you can redistribute it and/or modify | |
| it under the terms of the GNU General Public License as published by | |
| the Free Software Foundation, either version 3 of the License, or | |
| (at your option) any later version. | |
| This program is distributed in the hope that it will be useful, | |
| but WITHOUT ANY WARRANTY; without even the implied warranty of |
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
| irb(main):034:0> D, Y = 8, 0 | |
| => [8, 0] | |
| irb(main):035:0> 8===D-- ( Y ) | |
| => true |
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 self.underscore_hash(hash) | |
| hash.inject({}) do |underscored, (key, value)| | |
| value = underscore_hash(value) if value.is_a?(Hash) | |
| value = value.map { |v| underscore_hash(v) } if value.is_a?(Array) | |
| underscored[key.underscore] = value | |
| underscored | |
| 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
| module PostFile | |
| def post_file(url, file_path, field_name = 'file') | |
| file_name = File.basename(file_path) | |
| boundary = "AaB03x" | |
| data = <<EOF | |
| --#{boundary}\r | |
| Content-Disposition: form-data; name="#{field_name}"; filename="#{file_name}"\r | |
| \r | |
| #{File.read(file_path)}\r | |
| --#{boundary}--\r |
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
| ary = [ | |
| {:sort_me => 1, :expected_order => 1}, | |
| {:sort_me => 2, :expected_order => 7}, | |
| {:sort_me => 2, :expected_order => 8}, | |
| {:sort_me => 1, :expected_order => 2}, | |
| {:sort_me => 1, :expected_order => 3}, | |
| {:sort_me => 1, :expected_order => 4}, | |
| {:sort_me => 1, :expected_order => 5}, | |
| {:sort_me => 1, :expected_order => 6}, | |
| ].sort! { |a,b| a[:sort_me] <=> b[:sort_me] } |
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
| static VALUE | |
| rb_ary_shuffle_bang(ary) | |
| VALUE ary; | |
| { | |
| long i = RARRAY(ary)->len; | |
| rb_ary_modify(ary); | |
| while (i) { | |
| long j = rb_genrand_real()*i; | |
| VALUE tmp = RARRAY(ary)->ptr[--i]; |
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 'riot' | |
| context "Something" do | |
| setup do | |
| D = 8 | |
| end | |
| asserts("big") { 8==D } | |
| asserts("bigger") { 8===D } |
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 'riot' | |
| context "Something" do | |
| setup do | |
| D = 8 | |
| end | |
| asserts("something") { 8==D } | |
| asserts("something else") { 8===D } |