Skip to content

Instantly share code, notes, and snippets.

@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
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 / 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
@ciaranarcher
ciaranarcher / 1_version
Created January 18, 2012 13:02
Backstage Error
C:\dev\torquebox\backstage>echo %JRUBY_OPTS%
--1.9
@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 / 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 / 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 / profile_example.rb
Created November 23, 2011 10:44
Profiling Example
profile_data = JRuby::Profiler.profile do
results = SIA::SIAModels::Client.get_all
results.each do |c|
puts "#{c[:clientid]} #{c[:firstname]} #{c[:status]} #{c[:customersince]} #{c[:emailactive]}"
end
end
profile_printer = JRuby::Profiler::GraphProfilePrinter.new(profile_data)
profile_printer.printProfile(STDOUT)
@ciaranarcher
ciaranarcher / client.rb
Created November 22, 2011 14:59
AR Benchmark Example
class Client < DatabaseSIA
# set a non-defualt primary key
set_primary_key :clientid
end
@ciaranarcher
ciaranarcher / base.rb
Created November 22, 2011 13:45
Base Database Module
require "singleton"
module SIA
# Singleton class to enable database access for those occasions where a model will just not do.
# @author Ciaran Archer
class Database
include Singleton
@databases = nil
# Setup database connections with configuration file.