Skip to content

Instantly share code, notes, and snippets.

@ordinaryzelig
ordinaryzelig / rails_admin_rspec_failures
Last active May 11, 2017 20:02
after fix for updating haml version, these are the rspec failures
Failures:
1) RailsAdmin Config DSL Edit Section has_many with nullable foreign key allow to remove element
Failure/Error: visit edit_path(model_name: 'Team', id: @team.id)
Capybara::Poltergeist::JavascriptError:
One or more errors were raised in the Javascript code on the page. If you don't care about these errors, you can ignore them by setting js_errors: false in your Poltergeist configuration (see documentation for details).
SyntaxError: JSON Parse error: Unrecognized token '&'
SyntaxError: JSON Parse error: Unrecognized token '&'

(steps on soap box)

I think Ruby's Object#tap method is abused. I see code like this all the time:

obj = SomeClass.new.tap do |o|
  o.blah = true
end
{
"token" => "02999FA70DA28B16C1F48D99D07ECEB7.sbg-vm-fe02",
"transaction" => {
"account" => {
"brand" => "PAYPAL"
},
"channel" => "52275ebaf361f20a76b038ba4c806991",
"criterions" => [
[0] {
"name" => "mode",
@ordinaryzelig
ordinaryzelig / .ruby-version
Last active August 29, 2015 14:01
Test cases for thread-safety in mocking libraries (http://redningja.com/dev/parallel-tests-with-single-database/)
ruby-2.0.0-p353

dbrady_trainline

Build a bot that triggers searches on http://thetrainline.com and returns the results in a specific format.

Input

  • The bot should respond to ComThetrainline.find(from, to, departure_at).
  • Assume that the parameters from and to will be EXACTLY what you need.
  • departure_at will be a Ruby DateTime object.
{
1 => "Highlander",
2 => "Reece's Peanut Butter Cops",
3 => "blind mice",
4 => "ninja turtles",
}
class Asdf
URL = 'http://asdf.com'
def build_url(extra_stuff)
URL << extra_stuff
end
end
10.times do |idx|
puts Asdf.new.build_url("?idx=#{idx}")
require 'sequel'
require 'pg'
db_config = {
adapter: 'postgres',
host: 'localhost',
database: 'asdf',
max_connections: 10,
}
15:52:50 pathfinder.1 | 2013-07-15T20:52:50Z 80536 TID-oxsyqylsc SearchService::CompositeSearchBuilder JID-b5377063eba252d41b97e3b8 INFO: fail: 60.003 sec
15:52:50 pathfinder.1 | 2013-07-15T20:52:50Z 80536 TID-oxsyqylsc WARN: {"retry"=>false, "queue"=>"pathfinding", "backtrace"=>true, "timeout"=>60, "class"=>"SearchService::CompositeSearchBuilder", "args"=>[{"start_latitude"=>50.7678, "start_longitude"=>6.091499, "end_latitude"=>52.525592, "end_longitude"=>13.369545, "vehicle_flags"=>7, "third_party_id"=>1, "created_at"=>nil, "updated_at"=>nil, "uuid"=>"7356fa77-2f26-46b4-a798-0e01709fec1f", "departure_time"=>"2013-07-17"}], "jid"=>"b5377063eba252d41b97e3b8"}
15:52:50 pathfinder.1 | 2013-07-15T20:52:50Z 80536 TID-oxsyqylsc WARN: execution expired
15:52:50 pathfinder.1 | 2013-07-15T20:52:50Z 80536 TID-oxsyqylsc WARN: /Users/ningja/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/monitor.rb:185:in `lock'
15:52:50 pathfinder.1 | /Users/ningja/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/monitor.rb:185:in `mon_enter'
15:52:5