Skip to content

Instantly share code, notes, and snippets.

View arielvalentin's full-sized avatar

Ariel Valentin arielvalentin

View GitHub Profile
@arielvalentin
arielvalentin / A. Tiered compilation
Last active December 9, 2015 23:18
JRuby 1.7 startup with JDK 7
[torquebox@n3 myapp]$ uname -a
Linux n3 2.6.32-279.14.1.el6.x86_64 #1 SMP Mon Oct 15 13:44:51 EDT 2012 x86_64 x86_64 x86_64 GNU/Linux
[torquebox@n3 myapp]$ java -version
java version "1.7.0_09"
Java(TM) SE Runtime Environment (build 1.7.0_09-b05)
Java HotSpot(TM) 64-Bit Server VM (build 23.5-b02, mixed mode)
[torquebox@n3 myapp]$ file `which /etc/alternatives/java`
/etc/alternatives/java: symbolic link to `/usr/lib/jvm/jre-1.7.0-oracle.x86_64/bin/java'
@arielvalentin
arielvalentin / hornetq-jms.xml
Created August 20, 2013 03:10
Torquebox Messaging JMS Exception "There is no queue with name"
<configuration xmlns="urn:hornetq"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:hornetq /schema/hornetq-jms.xsd">
<!-- Connection factory stuff -->
<queue name="DissemQueue">
<entry name="/queues/DissemQueue"/>
</queue>
</configuration>
@arielvalentin
arielvalentin / config.ru
Last active December 21, 2015 18:48
Enable profiling for jruby apps deployed to torquebox
require 'rubygems'
require 'rack'
require 'jruby/profiler'
app = lambda {|env|
profile_data = JRuby::Profiler::profile do
output = (0..50).map do |i|
50 * i
end
puts output
@arielvalentin
arielvalentin / jruby_timeout.rb
Last active December 23, 2015 09:29 — forked from jorgenpt/jruby_timeout.rb
Don't use this
# Workaround for IO.popen.readlines being allowed to block indefinitely even if
# wrapped in a Timeout::timeout call.
#
# Test case:
# $ time jruby -rtimeout -e "timeout(1) { IO.popen('sleep 10').readlines }"
# * Propagating errors executed in the block
# * Thread.raise experiences a TypeError because it cannot convert a java Exception into a ruby Error so I've added handling any errors raised from the java code to be propagated correctly
# * Renamed some variables so that they matched
require 'timeout'
@arielvalentin
arielvalentin / manually_add_to_classpath.log
Last active January 2, 2016 04:39
Starting MiniAccumuloCluster via JRuby
→ jruby manually_add_to_classpath.rb
/var/folders/4m/jqf69nlx38s5hyqp10y9_bvc0000gp/T/d20140107-525-wdgmbz
grabbed zookeeper
crated table
wrote record
created a scanner
anger
wtf
@arielvalentin
arielvalentin / gem_home_issue.sh
Last active January 2, 2016 18:58
JRuby Build Error
# well...
arielvalentin@kimura:~/dev/repos/jruby
git:(1.7.5-424-gc4ecd6b)
→ GEM_HOME=./lib/ruby/gems/shared/ bin/jruby -S bin/rake test:mri19 --trace
...
5012 tests, 874184 assertions, 0 failures, 0 errors, 9 skips
** Execute test:mri19
@arielvalentin
arielvalentin / Gemfile
Last active January 3, 2016 23:19 — forked from mkristian/Gemfile
source 'https://rubygems.org'
# Specify your gem's dependencies in vtd-xml.gemspec
gemspec
# needed to build the gem but fails when it is part of the gems
gem "ruby-maven", '~> 3.1.1.0'
@arielvalentin
arielvalentin / httpd.conf
Last active September 12, 2015 08:31
Sample Apache mod_proxy_balancer config for torquebox
<VirtualHost *:443>
#mod_ssl options and Certs ...
<Proxy *>
AddDefaultCharset Off
Order deny,allow
Allow from all
</Proxy>
@arielvalentin
arielvalentin / console.log
Created July 29, 2014 23:48
JRuby 1.7.4 AWS Euca SDK Open SSL Error
java.lang.RuntimeException: org.jruby.exceptions.RaiseException: (SSLError) jar:file:/var/lib/storm/supervisor/stormdist/test_rsync-4-1406677418/stormjar.jar!/gems/gems/aws-sdk-euca-1.8.5/ca-bundle.crt
at backtype.storm.utils.DisruptorQueue.consumeBatchToCursor(DisruptorQueue.java:107) ~[storm-core-0.9.1-incubating.jar:0.9.1-incubating]
at backtype.storm.utils.DisruptorQueue.consumeBatchWhenAvailable(DisruptorQueue.java:78) ~[storm-core-0.9.1-incubating.jar:0.9.1-incubating]
at backtype.storm.disruptor$consume_batch_when_available.invoke(disruptor.clj:77) ~[storm-core-0.9.1-incubating.jar:0.9.1-incubating]
at backtype.storm.daemon.executor$eval3918$fn__3919$fn__3931$fn__3978.invoke(executor.clj:745) ~[na:na]
at backtype.storm.util$async_loop$fn__384.invoke(util.clj:433) ~[na:na]
at clojure.lang.AFn.run(AFn.java:24) [clojure-1.4.0.jar:na]
at java.lang.Thread.run(Unknown Source) [na:1.7.0_60]
org.jruby.exceptions.RaiseException: (SSLError) jar:file:/var/li
@arielvalentin
arielvalentin / exceptions.rb
Created August 5, 2014 03:20
Sample code Throwable vs RubyException
# The following block logs java.lang.Throwable correctly: http://www.slf4j.org/api/org/slf4j/Logger.html#error(java.lang.String,%20java.lang.Throwable)
begin
Java::ComGoogleCommonBase::Preconditions.check_argument(false, "I don't like you")
rescue => e
logger = Java::OrgSlf4j::LoggerFactory.get_logger('logger')
logger.error("This works", e)
end
# However RubyException is not a throwable and treats it as a java.lang.Object: http://www.slf4j.org/api/org/slf4j/Logger.html#error(java.lang.String,%20java.lang.Object...)
begin
raise "error"