Skip to content

Instantly share code, notes, and snippets.

@bbozo
bbozo / exception trace.txt
Created November 14, 2012 09:34
Zeus server crashes when a file is modified and zeus server is still loading
$ zeus start
Starting Zeus server
[ready] [crashed] [running] [connecting] [waiting]
boot
└── default_bundle
├── development_environment
│ └── prerake
└── test_environment
class ExampleController < ApplicationController
def some_post_action
@some_model = SomeModel.some_factory_method(params).
validate(:make_one_particular_and_unique_thingy_go_red_and_stop_save)
...
end
end
@bbozo
bbozo / Gemfile.lock test-thingies
Created February 25, 2013 16:40
Minitest, callbacks of same type in same context get clobbered
$ grep -re test -e should Gemfile.lock
remote: git://github.com/bbozo/minitest-colorize.git
minitest-colorize (0.0.4.1)
minitest (>= 2.0)
rack-test (~> 0.6.1)
rack-test (>= 0.5.4)
minitest (4.5.0)
minitest-matchers (1.2.0)
minitest (>= 2.5.0)
minitest-rails (0.5.1)
class UserController < ApplicationController
def create
@user = SomeUserForm.new(params[:user]) do |f|
f.user = User.new
f.email = Email.new
end
return unless post?
if @user.save
@bbozo
bbozo / sample_output.txt
Created March 20, 2013 07:10
Why A.perform and A.new.perform aren't the same thing, from http://blog.codeclimate.com/blog/2012/11/14/why-ruby-class-methods-resist-refactoring/ - A.perform is not threadsafe (unless it calls A.new.perform, heh), B.perform is
All A outputs:
AA
A
AAAAAAAAAA
AAA
AAAA
AAAAA
AAAAAA
AAAAAAA
AAAAAAAA
@bbozo
bbozo / find_ips_from_maxmind_csv.rb
Last active December 17, 2015 00:49
finds IP addresses from MaxMinds GeoLite city CSV dump
require 'csv'
# address = '245.245.245.245'
address = '24.24.24.24'
def ip_address_to_int address
( o1, o2, o3, o4 ) = address.split('.').map(&:to_i)
16777216 * o1 + 65536 * o2 + 256 * o3 + o4
@bbozo
bbozo / Gemfile.lock jruby
Last active December 20, 2015 15:49
HTTP server service for Torquebox, http_parser.rb gem problem
GEM
remote: https://rubygems.org/
specs:
actionmailer (3.2.14)
actionpack (= 3.2.14)
mail (~> 2.5.4)
actionpack (3.2.14)
activemodel (= 3.2.14)
activesupport (= 3.2.14)
builder (~> 3.0.0)
@bbozo
bbozo / Gemfile.lock
Created August 25, 2013 08:26
Device security extension problem under Rails 4
GIT
remote: https://github.com/airblade/paper_trail.git
revision: c441a5de2d61042126bb042c3c18012fca3af32b
branch: rails4
specs:
paper_trail (2.7.2)
activerecord (~> 4.0)
railties (~> 4.0)
GIT
@bbozo
bbozo / em_jruby_issue.rb
Created November 20, 2013 20:32
EventMachine with JRuby, running reactor inside a thread doesn't work
require 'eventmachine'
Thread.new{ EM.run }
until EM.reactor_running?; sleep 0.1; end
EM.add_periodic_timer(1){ puts "tick" }
sleep 5
bbozo@vilma:~/dev/0000_dallywagging/rabbitmq$ rvm use ruby
Using /home/bbozo/.rvm/gems/ruby-2.0.0-p247
bbozo@vilma:~/dev/0000_dallywagging/rabbitmq$ ruby amqp_hello.rb
Connecting to RabbitMQ. Running 1.1.1 version of the gem...
amqpgem.examples.hello_world
================================================================================
foo
roko
Received a message: Hello, world!. Disconnecting...
tick