Skip to content

Instantly share code, notes, and snippets.

View bernd's full-sized avatar

Bernd Ahlers bernd

View GitHub Profile
@bernd
bernd / broken_boolean_coercion.rb
Last active December 10, 2015 00:38
Show broken boolean coercion with the mongoid gem loaded. See: https://github.com/solnic/virtus/issues/132
require 'virtus'
require 'minitest/spec'
require 'minitest/autorun'
class A
include Virtus
attribute :foo, Boolean
end
describe 'without mongoid' do
require 'eventmachine'
require 'json'
require 'net/http'
EM.run do
uri = URI('http://guest:guest@0.0.0.0:15672/api/overview')
req = Net::HTTP::Get.new(uri.request_uri)
req.basic_auth(uri.user, uri.password)
EM::PeriodicTimer.new(1) do
class Controller
def create
creator = OrganizationCreator.new(FeedWriter.new(self))
creator.create_for(current_user, params[:organization])
end
def create_organization_succeeded(organization)
redirect_to '/foo', :notice => 'success'
end
end
@bernd
bernd / backtrace.txt
Created November 12, 2012 18:31
Webmachine Reel SystemStackError
E, [2012-11-12T19:31:43.657071 #21162] ERROR -- : Reel::Server crashed!
SystemStackError: stack level too deep
/home/bernd/.rvm/gems/ruby-1.9.3-p327/gems/celluloid-0.12.3/lib/celluloid/tasks/task_fiber.rb:44
@bernd
bernd / install-oracle-java7-ubuntu.sh
Created November 8, 2012 15:45
Install Oracle Java 7 on Ubuntu 12.04
#!/bin/sh
sudo apt-get install python-software-properties
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java7-installer
@bernd
bernd / validation.rb
Created August 23, 2012 09:27
Validate hash via ActiveModel::Validations
require 'bundler/setup'
require 'active_model'
class ParamValidation
include ActiveModel::Validations
validates :page, :format => /\d+/
attr_accessor :page
@bernd
bernd / sensu-port.diff
Created July 20, 2012 13:17
Sensu port diff
diff --git lib/sensu/client.rb lib/sensu/client.rb
index 87b5351..9f28172 100644
--- lib/sensu/client.rb
+++ lib/sensu/client.rb
@@ -222,14 +222,14 @@ module Sensu
def setup_sockets
@logger.debug('binding client tcp socket')
- EM::start_server('127.0.0.1', 3030, Sensu::Socket) do |socket|
+ EM::start_server('127.0.0.1', @settings[:client_port], Sensu::Socket) do |socket|
@bernd
bernd / gist:3061056
Created July 6, 2012 15:59
perl fpm-cookery recipe
class PerlFileProperties < FPM::Cookery::Recipe
description 'Perl module representing properties of a disk file'
name 'libfile-properties-perl'
version '0.02'
revision 0
source "http://search.cpan.org/CPAN/authors/id/W/WO/WOHL/File-Properties-#{version}.tar.gz"
homepage "http://search.cpan.org/~wohl/File-Properties-#{version}/"
def build
@bernd
bernd / collectd-redis.conf
Created April 2, 2012 08:23
collectd redis metrics in ruby
LoadPlugin exec
<Plugin exec>
Exec "nobody:nogroup" "/path/to/collectd-redis.rb" "127.0.0.1" "6379"
</Plugin>
@bernd
bernd / capy-test.rb
Created October 6, 2011 14:55
Simple test with a capybara server.
require 'open-uri'
require 'capybara/rspec'
app = lambda do |env|
[200, {'Content-Type' => 'text/plain'}, ['Hello rat!']]
end
Capybara.app = app
server = Capybara::Server.new(Capybara.app).boot