Skip to content

Instantly share code, notes, and snippets.

@ciaranarcher
ciaranarcher / spec_helper.rb
Created August 3, 2012 09:23
Rolling back all transactions during tests.
# Always rollback transactions for all databases
RSpec.configure do |c|
c.around(:each) do |example|
Sequel.transaction(SIASquirrel.databases.values, :rollback=>:always) { example.run }
end
end
module MyPrinter
def self.print(str, times=1)
p ((str + ' ') * times).strip
end
end
module X
VERSION = '0.0.1'
end
# -*- encoding: utf-8 -*-
$:.push File.expand_path("../lib", __FILE__)
require "sia_squirrel/version"
Gem::Specification.new do |s|
s.name = "x"
s.version = X::VERSION
s.authors = ["Ciaran Archer"]
s.email = ["[email protected]"]
s.homepage = "http://x.x.com"
@ciaranarcher
ciaranarcher / gist:3181851
Created July 26, 2012 12:50
TB Deployment Error
13:49:17,411 INFO [org.jboss.as.server.deployment] (MSC service thread 1-1) JBAS015876: Starting deployment of "hermes-knob.yml"
13:49:17,442 INFO [org.torquebox.core] (MSC service thread 1-1) evaling: C:\dev\repos\hermes\torquebox.rb
13:49:17,442 ERROR [org.torquebox.core.runtime] (MSC service thread 1-1) Error during evaluation: require 'rubygems'
require 'torquebox-configure'
TorqueBox::Configuration::GlobalConfiguration.load_configuration( %q{C:\dev\repos\hermes\torquebox.rb} ).to_java: org.jruby.exceptions.RaiseException: (LoadError) Could not find blankslate (= 2.1.2.4) amongst [bundler-1.1.4, bundler-1.1.3, rake-0.9.2.2, rake-0.8.7, torquebox-2.0.3, torquebox-backstage-1.0.3, torquebox-cache-2.0.3-java, torquebox-capistrano-support-2.0.3, torquebox-configure-2.0.3-java, torquebox-core-2.0.3-java, torquebox-messaging-2.0.3-java, torquebox-naming-2.0.3-java, torquebox-no-op-2.0.3, torquebox-rake-support-2.0.3, torquebox-security-2.0.3-java, torquebox-stomp-2.0.3, torquebox-transactions-2.0.3, torquebox
@ciaranarcher
ciaranarcher / minesweeper.rb
Created July 20, 2012 14:51 — forked from stubotnik/minesweeper.rb
Minesweeper Kata
module Minesweeper
class Game
attr_reader :fields
def initialize
@fields = []
@allow_input = true
##
# This is the ugly work-around for working with gems from local source.
# Comment in as required, and then run 'bundle update'.
###
# gem 'sia_squirrel', :path => 'c:/dev/repos/gems/sia_squirrel', :require => 'sia_squirrel'
# gem 'sia_beaver', :path => 'c:/dev/repos/gems/sia_beaver', :require => 'sia_beaver'
# gem 'sia_crypto', :path => 'c:/dev/repos/gems/sia_crypto', :require => 'sia_crypto'
gem 'sia_squirrel'
gem 'sia_beaver'
gem 'sia_crypto'
class Grid
attr_accessor :values
def initialize(dimension)
@values = []
(1..dimension).each do |i|
@values << (1..dimension).map{ ('A'..'Z').to_a[rand(26)] }
end
end
@ciaranarcher
ciaranarcher / gist:2994151
Created June 26, 2012 07:37
Hash Publishing Error
# code
queue = TorqueBox::Messaging::Queue.new('/queues/metrics/script_timing')
p params
p params.class
queue.publish params
# output
08:35:06,177 INFO [stdout] (http--127.0.0.1-8080-1) {"scriptname"=>"test", "server"=>"1"}
08:35:06,178 INFO [stdout] (http--127.0.0.1-8080-1) Hash
class ScriptTimingMsgProcessor < TorqueBox::Messaging::MessageProcessor
p "ScriptTimingMsgProcessor class loaded"
def on_message(body)
# The body will be of whatever type was published by the Producer
# the entire JMS message is available as a member variable called message()
p 'ScriptTimingMsgProcessor::on_message() called with ' + body.to_s
end
def on_error(exception)