(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
require 'transproc/all' | |
require 'json' | |
json = <<-EOS | |
{ | |
"links": { | |
"self": "http://example.com/posts", | |
"next": "http://example.com/posts?page[offset]=2", | |
"last": "http://example.com/posts?page[offset]=10" | |
}, |
require "./compiler/crystal/**" | |
while line = gets | |
compiler = Crystal::Compiler.new | |
program = Crystal::Program.new | |
program.target_machine = compiler.target_machine | |
prelude = program.normalize(Crystal::Require.new("prelude")) |
# Ruby Wishlist | |
## Removals | |
* finalize! method for classes | |
* Remove constant_finding/loading at runtime, it always breaks. | |
## Module.freeze | |
Remove the ability to dynamically change code at runtime |
require "rspec/exit_matchers/version" | |
# expect { exit(1) }.to exit_with_status(1) | |
module RSpec | |
module ExitMatchers | |
class ExitWithStatus | |
def initialize(expected_status) | |
@expected_status = expected_status | |
end |
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
# activerecord-3.0.0/lib/active_record/connection_adapters/mysql_adapter.rb | |
# Maps logical Rails types to MySQL-specific data types. | |
def type_to_sql(type, limit = nil, precision = nil, scale = nil) | |
return super unless type.to_s == 'integer' | |
case limit | |
when 1; 'tinyint' | |
when 2; 'smallint' | |
when 3; 'mediumint' | |
when nil, 4, 11; 'int(11)' # compatibility with MySQL default |
Let's build our own code reloader for Rails, shall we?
Run this inside rails/railties
:
$ grep -rn "eager_load_paths" .
You should get the results from Rails::Engine::Configuration
and Rails::Engine
. As you know, each Rails application is actually a Rails::Engine
and Rails::Engine::Configuration
is that thing wrapped inside Rails.application.config
block.
class FacebookCommentNotifer | |
def initialize(comment) | |
@comment = comment | |
end | |
def save | |
@comment.save && post_to_wall | |
end | |
private |
RSpec.configure do |config| | |
# disable the `should` syntax... | |
config.expect_with :rspec do |c| | |
c.syntax = :expect | |
end | |
config.mock_with :rspec do |c| | |
c.syntax = :expect | |
end | |
end |
def create_very_rails | |
project = Project.create project_params | |
if project.persisted? | |
sync_new project | |
redirect_to project | |
else | |
redirect_to edit_project_path(project) | |
end | |
end |