Skip to content

Instantly share code, notes, and snippets.

View bbrowning's full-sized avatar

Ben Browning bbrowning

  • Red Hat
  • Cambridge, MA
View GitHub Profile
source 'https://rubygems.org'
gem 'jruby-openssl', '0.9.3'
@bbrowning
bbrowning / instructions.md
Last active December 20, 2015 23:49
OpenShift pre_build hook to allow Windows developers to deploy to OpenShift
  1. Make sure your Gemfile.lock is not committed to your OpenShift git repository.

  2. Copy the pre_build file to .openshift/action_hooks/pre_build

  3. Add .openshift/action_hooks/pre_build to git, set the executable bit, and push your changes

    git add .openshift/action_hooks/pre_build git update-index --chmod=+x .openshift/action_hooks/pre_build git commit -m "Add bundle_install in pre_build hook" git push

class MessagingStatsService
def start
Thread.new do
until @done
queues.each do |queue|
counter = org.hornetq.api.core.management.MessageCounterInfo.from_json(queue.list_message_counter)
puts "Queue #{queue.name} count: #{counter.count} countDelta: #{counter.count_delta} depth: #{counter.depth} depth_delta: #{counter.depth_delta}"
end
end
require 'erb'
NUM_THREADS = 400
puts "Thread with string"
threads = NUM_THREADS.times.map {
Thread.new do
'1'
end
}
@bbrowning
bbrowning / output
Last active December 12, 2015 07:59
bbrowning@bbrowning-mbp:~$ curl -I http://localhost:8080/posts/
HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Set-Cookie: foobar=k5wDvCA2jZvAlwqb2HgFMdsX; Domain=foobar.com; Expires=Fri, 08-Feb-2013 18:17:44 GMT; Path=/baz; Secure; HttpOnly
X-UA-Compatible: IE=Edge
ETag: "903b327bb0b526d7d9b6b4d8344fc56f"
Cache-Control: max-age=0, private, must-revalidate
X-Request-Id: 9cac85c7ee32c524896767ff8ce730ca
X-Runtime: 0.796000
Content-Type: text/html;charset=utf-8
@bbrowning
bbrowning / proxy.diff
Created February 4, 2013 17:14
Maven RubyGems proxy fix
diff --git a/gem-proxy/src/main/java/de/saumya/mojo/proxy/Controller.java b/gem-proxy/src/main/java/de/saumya/mojo/proxy/Controller.java
index a9a46b5..0e54554 100644
--- a/gem-proxy/src/main/java/de/saumya/mojo/proxy/Controller.java
+++ b/gem-proxy/src/main/java/de/saumya/mojo/proxy/Controller.java
@@ -31,7 +31,7 @@ public class Controller {
private static final String SHA1 = ".sha1";
- private static final String RUBYGEMS_URL = "http://rubygems.org/gems";
+ private static final String RUBYGEMS_URL = "https://rubygems.org/gems";
@bbrowning
bbrowning / highspeedpublish.rb
Created January 8, 2013 19:59
Example of publishing messages at a high speed with TorqueBox
queue = TorqueBox::Messaging::Queue.new('/queue/foo')
options = { :startup_timeout => 500, :persistent => false, :tx => false }
normalized_options = queue.normalize_options(options)
queue.wait_for_destination(options[:startup_timeout]) do
queue.with_session(options) do |session|
# loop here and publish each message
5.times { session.publish(queue, Time.now.to_s, normalized_options) }
end
end
TORQUEBOX_SERVER=standalone.xml
TORQUEBOX_HOME=/opt/torquebox
RUN=yes
diff --git a/gems/jruby-openssl/Rakefile b/gems/jruby-openssl/Rakefile
index c854e2a..c7cddfc 100644
--- a/gems/jruby-openssl/Rakefile
+++ b/gems/jruby-openssl/Rakefile
@@ -38,7 +38,7 @@ task :java_compile do
end
sh "javac @pkg/compile_options @pkg/compile_classpath @pkg/compile_sourcefiles"
- sh "jar cf ../../lib/ruby/shared/jopenssl.jar -C pkg/classes/ ."
+ sh "jar cf lib/shared/jopenssl.jar -C pkg/classes/ ."
bbrowning@bbrowning-mbp:~/tmp/rails3.2_basic$ time jruby -S bundle install
...
Your bundle is complete! It was installed into /Users/bbrowning/Downloads/torquebox-current/jruby/lib/ruby/gems/1.8
real 0m51.642s
user 0m51.210s
sys 0m3.595s
bbrowning@bbrowning-mbp:~/tmp/rails3.2_basic$ rm Gemfile.lock
bbrowning@bbrowning-mbp:~/tmp/rails3.2_basic$ time jruby -X-C -S bundle install
...