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
| $ phantomjs test.js | |
| error: ReferenceError: Can't find variable: foo | |
| finished | |
| error: ReferenceError: Can't find variable: asdasd |
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
| # Example code provided for https://github.com/librato/librato-metrics/issues/14 | |
| # | |
| # We configured it like so: | |
| # | |
| # Loco2::Metrics.queue_constructor = Librato::Metrics::Queue.method(:new) | |
| # Loco2::Metrics.logger = Rails.logger | |
| # Loco2::Metrics.exception_handler = Airbrake.method(:notify) | |
| require 'thread' | |
| require 'timeout' |
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
| AF | Afghanistan | |
|---|---|---|
| AX | Åland Islands | |
| AL | Albania | |
| DZ | Algeria | |
| AS | American Samoa | |
| AD | Andorra | |
| AO | Angola | |
| AI | Anguilla | |
| AQ | Antarctica | |
| AG | Antigua and Barbuda |
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
| $ rvm jruby | |
| $ cat ext/faye_websocket_mask/extconf.rb | |
| unless defined?(RUBY_ENGINE) and RUBY_ENGINE == 'jruby' | |
| require 'mkmf' | |
| extension_name = 'faye_websocket_mask' | |
| dir_config(extension_name) | |
| create_makefile(extension_name) | |
| end | |
| $ gem build faye-websocket.gemspec |
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
| # People were asking what I meant by "single class per action". Here's an | |
| # example. | |
| # | |
| # I've not tried this out at all, or tried to implement it or use it. I | |
| # might be wrong. It's just an idea. Please don't hate on me :) | |
| # | |
| # Why do I wish for something like this? I can imagine being able to unit | |
| # test it without all the ceremony we have to perform currently. Also, I | |
| # feel that it adheres better to the single responsibility principle, and | |
| # potentially allows more flexibility for code re-use. |
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
| $ ruby test_foo.rb | |
| Run options: | |
| # Running tests: | |
| #<Method: FooTest(MiniTest::Assertions)#skip> | |
| S | |
| Finished tests in 0.000864s, 1157.4516 tests/s, 0.0000 assertions/s. |
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' | |
| class Foo1 | |
| def foo | |
| "bar" | |
| end | |
| end | |
| class Foo2 | |
| module Other |
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 test_defining_attribute_methods_is_threadsafe | |
| klass = Class.new(ActiveRecord::Base) | |
| klass.table_name = "posts" | |
| 100.times.map { |i| | |
| Thread.new { klass.define_attribute_methods } | |
| }.join | |
| 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
| # No EM loop | |
| # Send message on web socket and block waiting for next message from client | |
| result = client.send('{"action":"visible", id: 23}') | |
| # Handle the response | |
| do_something(result) |
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_record' | |
| ActiveRecord::Base.establish_connection(:adapter => 'sqlite3', :database => ':memory:') | |
| ActiveRecord::Schema.define do | |
| create_table :posts, :id => false do |t| | |
| t.integer :foo | |
| end | |
| end |