I hereby claim:
- I am rubysolo on github.
- I am rubysolo (https://keybase.io/rubysolo) on keybase.
- I have a public key whose fingerprint is DAC3 8223 1D35 4CF9 65F4 DB74 4392 7357 9969 D06E
To claim this, I am signing this object:
| ActiveSupport::Notifications.subscribe 'halted_callback.action_controller' do |name, start, finish, id, payload| | |
| Rails.logger.warn { '=' * 80 } | |
| Rails.logger.warn { "HALTED CALLBACK: #{ payload[:filter] }" } | |
| end |
| unless defined?(Rails) | |
| # minimum viable implementation of Rails | |
| class Rails | |
| class << self | |
| def root | |
| Pathname.new(File.expand_path('../..', __FILE__)) | |
| end | |
| def env | |
| 'test'.tap do |e| |
I hereby claim:
To claim this, I am signing this object:
| defrecord Card, suit: nil, rank: nil | |
| defmodule Cards do | |
| def create do | |
| lc suit inlist [:H, :D, :C, :S], | |
| rank inlist [:A, 2, 3, 4, 5, 6, 7, 8, 9, 10, :J, :Q, :K] do | |
| Card.new suit: suit, rank: rank, points: score(rank) | |
| end | |
| end |
| falafel = require 'falafel' | |
| fs = require 'fs' | |
| raw = process.argv[2] | |
| cooked = raw.replace(/\.js$/, '-trace.js') | |
| counter = 0 | |
| src = fs.readFileSync(raw, encoding: 'utf8') | |
| tracied = falafel src, (node) -> |
| module Enumerable | |
| def remove(other) | |
| base = self.dup | |
| other.each { |i| base.delete_at(base.index(i) || base.length) } | |
| base | |
| end | |
| end | |
| irb(main):008:0> [1,1,2,3].remove([1,2]) | |
| => [1, 3] |
| # inside config.before(:suite) | |
| ActiveRecord::Base.subclasses.each do |model_class| | |
| columns = model_class.columns.map { |c| c.name.to_sym } | |
| missing = columns - model_class.instance_methods | |
| missing.each do |column| | |
| model_class.send(:define_method, column) { |*args| super(*args) } | |
| end | |
| end |
| defmodule Ring do | |
| def run(member_count, loop_count, message) do | |
| log(:ringleader, "building ring with #{ member_count - 1 } more nodes...") | |
| next_pid = spawn_link(__MODULE__, :build_ring, [member_count - 2, self]) | |
| log(:ringleader, "sending initial message to #{ inspect(next_pid) }...") | |
| next_pid <- {:message, message, loop_count} | |
| message_loop(next_pid) | |
| end |
| collection = [:a, :b, :c] | |
| collection.each_with_index.each_with_object({}) do |(item, index), hash| | |
| hash[item] = index | |
| end | |
| # => {:a=>0, :b=>1, :c=>2} |
| # An experiment in higher-order (?) messages in Ruby. | |
| class Message | |
| attr_reader :name | |
| attr_reader :arguments | |
| def initialize(name, *arguments) | |
| @name = name | |
| @arguments = arguments | |
| end |