Skip to content

Instantly share code, notes, and snippets.

@ciaranarcher
ciaranarcher / gist:1399612
Created November 28, 2011 08:28
torquecheck
>>>>> Environment <<<<<<
TORQUEBOX_HOME: C:\dev\torquebox\torquebox-2.x
JRUBY_HOME: C:\dev\torquebox\torquebox-2.x\jruby
JBOSS_HOME: C:\dev\torquebox\torquebox-2.x\jboss
>>>>> Ruby <<<<<<
Version: 1.9.2
Platform: java
>>>>> TorqueBox Server <<<<<<
@ciaranarcher
ciaranarcher / block.rb
Created January 17, 2012 11:17
Question on blocks
@responder.respond do |r|
r.do_something
@responder.bad_request! # using @responder in it's own block, is this frowned upon?
end
@ciaranarcher
ciaranarcher / validation.rb
Created January 18, 2012 10:32
Example Request Validation
req = Request.new(params)
req.validate_params_as do |conditions|
conditions[:scriptingtimingid] = :numeric
conditions[:script_name] = :string
conditions[:completed_on] = :time
end
req.validate?
@ciaranarcher
ciaranarcher / 1_version
Created January 18, 2012 13:02
Backstage Error
C:\dev\torquebox\backstage>echo %JRUBY_OPTS%
--1.9
@ciaranarcher
ciaranarcher / warden_example.rb
Created January 26, 2012 14:40
Warden Example - Basic HTTP Auth
Warden::Manager.before_failure do |env, opts|
# Sinatra/Padrino is very sensitive to the request method and
# since authentication could fail on any type of method, we need
# to set it for the failure app so it is routed to the correct block.
env['REQUEST_METHOD'] = "POST"
end
Warden::Strategies.add(:basic_http) do
def valid?
# Check if valid and store an instance var
Ciaran-Archers-MacBook-Pro:roman-numerals carcher$ jasmine-node spec --coffee
F
Failures:
1) TestClass should be created
Message:
TypeError: object is not a function
Stacktrace:
TypeError: object is not a function
@ciaranarcher
ciaranarcher / gist:2988953
Created June 25, 2012 14:24
TB Messaging Error
# create queue
Padrino.after_load do
#
# Create message queues
##
TorqueBox::Messaging::Queue.start '/queues/metrics/scripttiming'
p '/queues/metrics/scripttiming queue started in Padrino.'
end
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)
@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 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