Skip to content

Instantly share code, notes, and snippets.

View lenny's full-sized avatar

Lenny Marks lenny

  • American Physical Society
  • Long Island, NY
  • 13:21 (UTC -04:00)
View GitHub Profile
class ExpensiveOperation
def self.lookup(question)
"This goes to the database"
end
end
class UsesExpensiveOperation
def initialize
@cache = {}
end
When I select the following previous correspondence items:
| type | date | filename |
| CTA | 01Jan09 | EMAIL |
When /^I select the following previous correspondence items:$/ do |table|
checkboxes = PreviousCorrespondenceSteps.get_checkboxes_for(table)
checkboxes.each {|b| b.set(true) }
config.after_initialize do
MVOR::Gateway.use_3ds_test_gateway
end
config.after_initialize do
AppConfig.payment_gateway_mode = :test
end
Daemon 0
LogFacility -
LogLevel 5
ListenHTTP
Address lenny.ridge
Port 3001
Service
URL "/MyApp1/.*"
@lenny
lenny / active_record_spec_helper.rb
Created November 20, 2010 18:32
spec helper for inclusion by specs that don't need/depend on the entire rails environment. In JRuby, specs that don't load entire rails env run significantly faster.
unless self.class.const_defined?('APP_ROOT')
APP_ROOT = File.expand_path(File.dirname(__FILE__) + '/../../../../../')
end
puts "#{File.basename(__FILE__)}: APP_ROOT: #{APP_ROOT}"
require File.expand_path("#{File.dirname(__FILE__)}/no_rails_env_spec_helper")
unless self.class.const_defined?('Rails')
require 'benchmark'
@lenny
lenny / v1.rb
Created August 24, 2011 20:45
rspec macros
1 require File.dirname(__FILE__) + "/spec_helper"
2
3 require 'email'
4
5 describe Email do
6 describe '.normalize', ' should strip email down to core address' do
7 def self.normalized(original, options)
8 it %{normalizes '#{original}' as '#{options[:should_be]}'} do
9 Email.normalize(original).should == options[:should_be]
10 end
@lenny
lenny / gist:1278231
Created October 11, 2011 14:30
script/tomcat-console to run Rails console from a WAR
#!/usr/bin/env jruby
raise "Must specify CATALINA_HOME" unless ENV['CATALINA_HOME']
ENV['GEM_HOME'] ||= File.expand_path('../../gems', __FILE__)
require File.expand_path('../../../META-INF/init', __FILE__)
# expected by rails/commands
APP_PATH = File.expand_path('../../config/application', __FILE__)
@lenny
lenny / java_properties.rb
Created October 24, 2011 14:54
Ruby wrapper around Java Properties
# More rubyish/convenient interface to Java Properties(e.g. Loading connection config from properties file)
class JavaProperties
def initialize(name)
input_stream =
Java::Java.lang.Thread.currentThread.contextClassLoader.getResourceAsStream(name)
if input_stream
@properties = Java::java.util.Properties.new
@properties.load(input_stream)
input_stream.close
@lenny
lenny / TxCallback.java
Created December 21, 2011 19:22
ruby block interface for anonymous class
public interface TxCallback {
public Object execute(TransactionHolder txHolder) throws Exception;
}