Skip to content

Instantly share code, notes, and snippets.

View jcalvert's full-sized avatar

Jonathan Calvert jcalvert

View GitHub Profile
@jcalvert
jcalvert / none
Created February 24, 2012 15:08
none
-gem 'httparty'
+#gem 'httparty'
@jcalvert
jcalvert / README.md
Created February 16, 2012 22:44
Make polymorphic routes support scoped parameters

If you are scoped you can do simple form_for now.

If your routes are say like this:

 scope ':organization', :context => do
   resources :employees
 end
@jcalvert
jcalvert / log
Created December 19, 2011 22:07
torquebox
71vzn91:~ jcalvert$ torquebox run -b 0.0.0.0
[WARNING] jcalvert-knob.yml has not been deployed. Starting TorqueBox anyway.
=========================================================================
JBoss Bootstrap Environment
JBOSS_HOME: /Users/jcalvert/.rvm/gems/jruby-1.6.5/gems/torquebox-server-2.0.0.beta1-java/jboss
JAVA: /System/Library/Frameworks/JavaVM.framework/Home/bin/java
@jcalvert
jcalvert / server.log
Created December 19, 2011 21:59
server log of things taking forever to load etc
16:34:27,353 INFO [org.jboss.as.cmp.subsystem.CmpSubsystemAdd] (ServerService Thread Pool -- 38) Activating EJB CMP Subsystem
16:34:27,361 INFO [org.jboss.as.jacorb] (ServerService Thread Pool -- 44) Activating JacORB Subsystem
16:34:27,367 INFO [org.jboss.as.clustering] (ServerService Thread Pool -- 43) JBAS010300: Activating Infinispan subsystem.
16:34:27,392 INFO [org.jboss.as.security] (ServerService Thread Pool -- 58) Activating Security Subsystem
16:34:27,400 INFO [org.jboss.as.naming] (ServerService Thread Pool -- 52) JBAS011800: Activating Naming Subsystem
16:34:27,406 INFO [org.jboss.as.osgi] (ServerService Thread Pool -- 53) JBAS011910: Activating OSGi Subsystem
16:34:27,466 INFO [org.jboss.as.webservices] (ServerService Thread Pool -- 62) JBAS015537: Activating WebServices Extension
16:34:27,492 INFO [org.torquebox.core.as] (ServerService Thread Pool -- 64) Welcome to TorqueBox AS - http://torquebox.org/
16:34:27,494 INFO [org.jboss.as.security] (MSC service thread 1-6) Picketbox version=4
@jcalvert
jcalvert / gist:1498251
Created December 19, 2011 18:19
torque stack trace
13:16:29,375 INFO [org.jboss.as.server.deployment] (MSC service thread 1-1) Starting deployment of "Auth-knob.yml"
13:16:29,375 INFO [org.jboss.as.server.controller] (DeploymentScanner-threads - 1) Replacement of deployment "Auth-knob.yml" by deployment "Auth-knob.yml" was rolled back with failure message {"JBAS014671: Failed services" => {"jboss.deployment.unit.\"Auth-knob.yml\".STRUCTURE" => "org.jboss.msc.service.StartException in service jboss.deployment.unit.\"Auth-knob.yml\".STRUCTURE: Failed to process phase STRUCTURE of deployment \"Auth-knob.yml\""}}
13:16:29,376 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-1) MSC00001: Failed to start service jboss.deployment.unit."Auth-knob.yml".STRUCTURE: org.jboss.msc.service.StartException in service jboss.deployment.unit."Auth-knob.yml".STRUCTURE: Failed to process phase STRUCTURE of deployment "Auth-knob.yml"
at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:121) [jboss-as-server-7.1.0.Beta1.jar:]
@jcalvert
jcalvert / 1.9.2 perf
Created December 16, 2011 17:52
ARJDBC Postgres perf changes
ruby-1.9.2-p290 :001 > u = User.last.name
=> "Jon Calvert"
ruby-1.9.2-p290 :002 > require 'benchmark'
=> nil
ruby-1.9.2-p290 :003 > Benchmark.bm do | x|
ruby-1.9.2-p290 :004 > x.report do
ruby-1.9.2-p290 :005 > 1000.times do
ruby-1.9.2-p290 :006 > u = User.last.name
ruby-1.9.2-p290 :007?> end
ruby-1.9.2-p290 :008?> end
@jcalvert
jcalvert / adapter.rb
Created December 15, 2011 23:41
arjdbc + postgres = slow?
alias_chained_method :columns, :query_cache, :pg_columns
def pg_columns(table_name, name=nil)
val = nil
Benchmark.bm do |r|
r.report do
schema_name = @config[:schema_search_path]
if table_name =~ /\./
parts = table_name.split(/\./)
table_name = parts.pop
@jcalvert
jcalvert / gist:1482292
Created December 15, 2011 18:46
jruby-head gem install fail
71vzn91:tmp jcalvert$ rvm use jruby-1.6.5
Using /Users/jcalvert/.rvm/gems/jruby-1.6.5
71vzn91:tmp jcalvert$ gem install bundler
Successfully installed bundler-1.0.21
1 gem installed
71vzn91:tmp jcalvert$ rvm use jruby-head
Using /Users/jcalvert/.rvm/gems/jruby-head
71vzn91:tmp jcalvert$ gem install bundler
JRuby limited openssl loaded. http://jruby.org/openssl
gem install jruby-openssl for full support.
@jcalvert
jcalvert / gist:1351347
Created November 9, 2011 12:57
pet image snippet
Dir.glob('/mnt/smb/images/pp_uploads/*').each do |glob|
hid = glob.split("/").last
next unless hid == "2882"
Dir.glob("#{glob}/*").each do |cglob|
client_id=cglob.split("/").last
Dir.glob("#{cglob}/*").each do |plob|
patient_id =plob.split("/").last
if(Patient.where(:id => patient_id).nil? || Patient.where(:id => patient_id).empty?)
next
end
@jcalvert
jcalvert / boolean_scope.rb
Created October 22, 2011 22:54
Boolean class method companions for named_scopes
module ActiveRecord
module NamedScope
module ClassMethods
alias_method :original_scope, :scope
def scope(name, scope_options = {})
original_scope(name, scope_options)
boolean_scope = lambda do
send(name).any?
end
singleton_class.send(:redefine_method, "#{name}?".to_sym, &boolean_scope)