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 MLS | |
| extend self | |
| GRID = ("A".."Z").to_a | |
| SQUARE = ("0".."9").to_a | |
| SUB = ("a".."z").to_a | |
| lat = 180.0 | |
| PARTS = [[18, GRID], [10, SQUARE], [24, SUB], [10, SQUARE]] | |
| PARTS.map! { |div, part| [lat = lat / div, part] } |
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
| "SortedSet" behaves like "Array (sorted after every insert)" and "(insert in place)". | |
| Rehearsal --------------------------------------------------------------------- | |
| Array (unsorted) 0.120000 0.000000 0.120000 ( 0.120734) | |
| Set (unsorted) 0.000000 0.000000 0.000000 ( 0.000302) | |
| Array (sorted once) 0.130000 0.000000 0.130000 ( 0.121996) | |
| Array (sorted after every insert) 0.350000 0.000000 0.350000 ( 0.355280) | |
| SortedSet 0.120000 0.030000 0.150000 ( 0.151816) | |
| Array (insert in place) 0.090000 0.000000 0.090000 ( 0.093471) | |
| ------------------------------------------------------------ total: 0.840000sec |
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
| if (!this.RubyScript) | |
| RubyScript = {}; | |
| RubyScript.Base = function() { | |
| function alloc(klass) { | |
| var obj = new klass; | |
| obj.ivars = {}; | |
| obj.meta = null; | |
| return obj; | |
| }; |
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 Base; end | |
| class Controller < Base | |
| @@hello = :controller | |
| end | |
| class Base | |
| @@hello = :base | |
| 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
| require 'camping' | |
| Camping.goes :Async | |
| module Async | |
| def service(*a) | |
| return super unless respond_to?(:async?) | |
| EM.next_tick do | |
| send(@method, *a) |
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/Mojo/Base.pm b/lib/Mojo/Base.pm | |
| index 0fabd9a..19f5f87 100644 | |
| --- a/lib/Mojo/Base.pm | |
| +++ b/lib/Mojo/Base.pm | |
| @@ -8,6 +8,7 @@ require feature if $] >= 5.010; | |
| # No imports because we get subclassed, a lot! | |
| require Carp; | |
| +require Scalar::Util; | |
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 'camping' | |
| require 'camping/session' | |
| require 'rack/csrf' | |
| Camping.goes :E | |
| module E | |
| use Rack::Csrf | |
| include Camping::Session | |
| 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
| if defined?(Foo::THIS) && Foo::THIS == $0 | |
| p 'foo is executing' | |
| 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
| require 'camping' | |
| Camping.goes :Ex | |
| module Ex | |
| use Rack::MethodOverride | |
| end | |
| module Ex::Helpers | |
| SUPPORTED = %w[get post] |
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 'benchmark' | |
| def bitmask | |
| 2 ** 32 - 1 | |
| end | |
| def bitmask_with_assignment | |
| overshoot = 2 ** 32 | |
| overshoot - 1 |