Skip to content

Instantly share code, notes, and snippets.

Avatar

Brad Robertson bradrobertson

  • Toronto, ON, Canada
View GitHub Profile
@bradrobertson
bradrobertson / challenge.rb
Created Aug 19, 2011
Find by sql in ActiveRecord
View challenge.rb
def self.open_for_participant(contact_id, group_id = nil)
find_by_sql(<<-SQL)
SELECT challenges.* FROM challenges
LEFT OUTER JOIN challenge_participants ON challenge_participants.challenge_id = challenges.id
AND challenge_participants.contact_id = #{contact_id}
WHERE (EXISTS (
SELECT 1 FROM group_challenges
JOIN group_contacts ON group_challenges.group_id = group_contacts.group_id
#{"JOIN groups on group_challenges.group_id = groups.id" if group_id}
@bradrobertson
bradrobertson / database.yml
Created Nov 23, 2010
This works for server and migrations, but now duplicates my trinidad.yml config
View database.yml
development:
adapter: jdbc
driver: com.mysql.jdbc.Driver
jndi: java:/comp/env/jdbc/VeloUl
url: jdbc:mysql://localhost:3306/velo_ultralite_development
username: root
password:
timeout: 5000
@bradrobertson
bradrobertson / database.yml
Created Nov 23, 2010
this works for trinidad server but not with migrations (stack trace below)
View database.yml
development:
adapter: jdbc
jndi: java:/comp/env/jdbc/VeloUl
database: velo_ultralite_development
username: root
password:
timeout: 5000
# When running rake db:migrate, I get the following:
@bradrobertson
bradrobertson / database.yml
Created Nov 23, 2010
This works for rake db:migrate
View database.yml
development:
adapter: mysql
database: velo_ultralite_development
username: root
password:
timeout: 5000
@bradrobertson
bradrobertson / trinidad.yml
Created Nov 16, 2010
Config whereby log4j.properties is not correctly loaded and applied
View trinidad.yml
---
port: 8080 # port where trinidad is running
ajp: # ajp configuration section
port: 8009
jruby_min_runtimes: 1 # min number of runtimes
jruby_max_runtimes: 1 # max number of runtimes
web_apps:
default:
@bradrobertson
bradrobertson / trinidad.yml
Created Nov 16, 2010
Config whereby log4j.properties is correctly loaded and applied
View trinidad.yml
---
port: 8080 # port where trinidad is running
ajp: # ajp configuration section
port: 8009
jruby_min_runtimes: 1 # min number of runtimes
jruby_max_runtimes: 1 # max number of runtimes
extensions:
logging:
@bradrobertson
bradrobertson / trinidad.yml
Created Nov 16, 2010
Sample trinidad config
View trinidad.yml
---
port: 8080 # port where trinidad is running
ajp: # ajp configuration section
port: 8009
jruby_min_runtimes: 1 # min number of runtimes
jruby_max_runtimes: 1 # max number of runtimes
extensions:
logging:
@bradrobertson
bradrobertson / gist:669165
Created Nov 9, 2010
Shell interaction showing my deploy directory being deleted
View gist:669165
# remote machine
admin@velo.uat:/mnt/apps/velo-ul$ ls -l
total 12
lrwxrwxrwx 1 app admin 41 2010-11-09 09:40 current -> /mnt/apps/velo-ul/releases/20101109143915
drwxrwxr-x 40 app admin 4096 2010-11-09 09:39 releases
drwxrwxr-x 9 app admin 4096 2010-11-02 15:25 shared
drwxr-xr-x 3 app admin 4096 2010-11-02 11:35 tomcat.8080
# local machine
brad-robertsons-macbook-pro:trunk bradrobertson$ cap staging deploy:stop
@bradrobertson
bradrobertson / gist:669150
Created Nov 9, 2010
trinidad daemon config
View gist:669150
#! /bin/sh
# Generic script for running ruby scripts as daemons using
# jsvc and a java class to control the daemon.
#
# Contains common parameters and start/stop
# Things you'll need to set on a per script/daemon basis:
# SCRIPT_NAME - Path to the ruby script which creates a Daemon
# object for jsvc to control
# APP_NAME - Name of your application
@bradrobertson
bradrobertson / gist:659821
Created Nov 2, 2010
Attempt at patching trinidad to take APP_PATH into account when loading config
View gist:659821
# command_line_parser_spec.rb
it "respects web_app_dir if applicable when loading config" do
args = "--dir #{MOCK_WEB_APP_DIR} --config".split
options = subject.parse(args)
options[:config].should == "#{MOCK_WEB_APP_DIR}/config/trinidad.yml"
end
# command_line_parser.rb (line 32)
You can’t perform that action at this time.