Skip to content

Instantly share code, notes, and snippets.

@jmcnevin
jmcnevin / gist:3374017
Created August 16, 2012 22:04
Double escaping?
jruby-1.6.7.2 :045 > "Foo\nBar".to_yaml
=> "--- ! 'Foo\n\n Bar'\n...\n"
jruby-1.6.7.2 :046 > "Foo\r\nBar".to_yaml
=> "--- ! \"Foo\\r\\nBar\"\n...\n"
@jmcnevin
jmcnevin / gist:3248482
Created August 3, 2012 15:10
Torquebox first request of the morning
14:31:32,316 INFO [fp2] (http-/0.0.0.0:8080-3)
Started GET "/" for 75.73.242.192 at 2012-08-03 14:31:32 +0000
14:31:32,451 INFO [fp2] (http-/0.0.0.0:8080-3) Processing by HomeController#show as HTML
14:41:33,983 INFO [fp2] (http-/0.0.0.0:8080-2)
Started GET "/" for 75.73.242.192 at 2012-08-03 14:41:33 +0000
14:41:34,090 INFO [fp2] (http-/0.0.0.0:8080-2) Processing by HomeController#show as HTML
14:41:34,169 INFO [fp2] (http-/0.0.0.0:8080-2) Redirected to http://xxx:8080/dashboard
14:41:34,173 INFO [fp2] (http-/0.0.0.0:8080-2) Completed 302 Found in 75ms (ActiveRecord: 20.0ms)
@jmcnevin
jmcnevin / gist:3184344
Created July 26, 2012 20:35
Benchmarking rails asset precompilation - Rails 3.2.6, Jruby 1.6.7.2
No compression (config.assets.compress = false):
225.51s user 17.87s system 159% cpu 2:32.16 total
With compression (config.assets.compress = true):
time EXECJS_RUNTIME=RubyRhino bundle exec rake assets:precompile
real 8m49.087s
@jmcnevin
jmcnevin / server.log
Created July 3, 2012 17:19
Torquebox startup
=========================================================================
JBoss Bootstrap Environment
JBOSS_HOME: /opt/torquebox/jboss
JAVA: java
JAVA_OPTS: -server -XX:+UseCompressedOops -XX:+TieredCompilation -Xms3098m -Xmx3098m -XX:MaxPermSize=512m -Djava.net.preferIPv4Stack=true -Dorg.jboss.resolver.warning=true -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000 -Djboss.modules.system.pkgs=org.jboss.byteman -Djava.awt.headless=true -Djboss.server.default.config=standalone.xml -Xss2048k
@jmcnevin
jmcnevin / gist:3018328
Created June 29, 2012 14:42
Bootstrap Ubuntu 12.04 LTS
knife bootstrap IP_ADDRESS -N NODE_NAME -d ubuntu12.04-gems
@jmcnevin
jmcnevin / gist:2781931
Created May 24, 2012 14:36
Worker class that will mark all methods as TorqueBox backgroundable
# In a worker class, all defined public methods will be marked to run in the
# background
class Worker
include TorqueBox::Messaging::Backgroundable
def self.method_added(method_name)
return if method_name.to_s =~ /^__a?sync/ # avoid infinite loop
return unless public_method_defined?(method_name)
always_background method_name
end
@jmcnevin
jmcnevin / gist:2558928
Created April 30, 2012 14:48
Installing REE with RVM, Homebrew, XCode 4.3+ on OS X Lion
# Rather than going nuclear and downgrading Xcode or using some other big GCC installer,
# this worked for me...
# From https://github.com/mxcl/homebrew/wiki/Custom-GCC-and-cross-compilers
brew install https://raw.github.com/Homebrew/homebrew-dupes/master/apple-gcc42.rb
# Path may vary slightly...
export CC=/usr/local/Cellar/apple-gcc42/4.2.1-5666.3/bin/gcc-4.2
# If you've attempted to install REE previously and it failed...
[default] [Thu, 15 Sep 2011 18:06:01 +0200] INFO: Processing execute[extract-jruby] action nothing (jruby::default line 16)
: stdout
[default] [Thu, 15 Sep 2011 18:06:01 +0200] INFO: Processing remote_file[/tmp/jruby-bin-1.6.4.tar.gz] action create (jruby::default line 24)
: stdout
[default] [Thu, 15 Sep 2011 18:06:57 +0200] INFO: Chef Run complete in 57.277101 seconds
: stdout
[default] [Thu, 15 Sep 2011 18:06:57 +0200] INFO: Running report handlers
: stdout
[default] [Thu, 15 Sep 2011 18:06:57 +0200] INFO: Report handlers complete
: stdout
<html>
<head>
<style>
div {
border: 1px solid black;
margin-right: 10px;
padding: 10px;
}
#col1,#col2 {
float: left;
@jmcnevin
jmcnevin / deploy.rb
Created March 24, 2011 19:04
Rails 3, Devise, Resque, Capistrano, and static resque-web assets
# I'm currently using Devise along with Resque's resque-web UI. I have resque-web running
# as an embedded rack application inside of my main Rails app with the following line in my
# my routes.rb file:
#
# mount Resque::Server.new, :at => "/resque"
#
# This makes resque-web expect its static assets to be found in your site's /public/resque
# folder, where they won't be.
#
# The answer is to copy or symlink to those assets which are found in the gem's own public