Skip to content

Instantly share code, notes, and snippets.

View jcalvert's full-sized avatar

Jonathan Calvert jcalvert

View GitHub Profile
@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 / 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 / none
Created February 24, 2012 15:08
none
-gem 'httparty'
+#gem 'httparty'
@jcalvert
jcalvert / app.rb
Created March 2, 2012 20:18
Sinatra IP filter?
before do
unless ['10','192','127'].include? request.ip.to_s.gsub /(.*?)\..*/,'\\1'
halt(404, "Not found") #I should probably throw 403, but in this case it's sensitive and I'd rather make like a hole.
end
end
@jcalvert
jcalvert / unicron.rb
Created March 5, 2012 22:05
AR Sinatra filters
before do
request[:connection] = ActiveRecord::Base.connection_pool.checkout
end
after do
ActiveRecord::Base.connection_pool.checkin(request[:connection]) if request[:connection]
end
module Multiball
module Multicaster
def multi_method(proxied_thing, *args)
args.each do |method|
define_method method do |*method_args|
Multiball.servers.values.each{|value| value.send(proxied_thing).send method, method_args}
end
end
end
@jcalvert
jcalvert / sort-out.rb
Created March 19, 2012 15:23
candidate's sample code. ouch. sql injection
require 'rubygems'
require 'sequel'
require 'sqlite3'
def readFile(filePath)
#Creating file handler
STDOUT.sync = true
fileObj = File.open(filePath)
begin
#Making use of in-memory database for faster and better performace
db = Sequel.sqlite
@jcalvert
jcalvert / rake output
Created June 5, 2012 15:42
Nested with_options
GET /:locale/services/foo/:name {:action=>"config", :controller=>"services/foo"}
GET /:locale/services/bar/:name {:action=>"config", :controller=>"services/bar"}
function ssh_connection() {
if [[ -n $SSH_CONNECTION ]]; then
echo "%{$fg_bold[red]%}(ssh) "
fi
}
PROMPT=$'\n$(ssh_connection)%{$fg_bold[green]%}%n@%m%{$reset_color%}:%{$fg_bold[blue]%}%2/%{$reset_color%}:$ '
ZSH_THEME_PROMPT_RETURNCODE_PREFIX="%{$fg_bold[red]%}"
ZSH_THEME_GIT_PROMPT_PREFIX=" $fg[white]‹ %{$fg_bold[yellow]%}"
Glad:
To be off subversion!!!!!!!!
To feel finally over a significant hump.
That we've got some traction to improving our process.
Sad:
That we have yet to realize that e-Release is silly.
Corollary: that we're not quite ready for something like CI/CD
That I didn't get to work on new stuff rather than fixing bugs.