Skip to content

Instantly share code, notes, and snippets.

View jcalvert's full-sized avatar

Jonathan Calvert jcalvert

View GitHub Profile
@jcalvert
jcalvert / gist:1289854
Created October 15, 2011 17:11
Nokogiri fail
Nokogiri::XML::XPath::SyntaxError: s0:definitions/s0:binding/s0:operation
from nokogiri/XmlXpathContext.java:122:in `evaluate'
from /Users/jcalvert/.rvm/gems/jruby-1.6.3/gems/nokogiri-1.5.0-java/lib/nokogiri/xml/node.rb:159:in `xpath'
from org/jruby/RubyArray.java:2344:in `collect'
from /Users/jcalvert/.rvm/gems/jruby-1.6.3/gems/nokogiri-1.5.0-java/lib/nokogiri/xml/node.rb:150:in `xpath'
from /Users/jcalvert/.rvm/gems/jruby-1.6.3/gems/wasabi-2.0.0/lib/wasabi/parser.rb:76:in `parse_operations'
from /Users/jcalvert/.rvm/gems/jruby-1.6.3/gems/wasabi-2.0.0/lib/wasabi/parser.rb:41:in `parse'
from /Users/jcalvert/.rvm/gems/jruby-1.6.3/gems/wasabi-2.0.0/lib/wasabi/document.rb:117:in `parse'
from /Users/jcalvert/.rvm/gems/jruby-1.6.3/gems/wasabi-2.0.0/lib/wasabi/document.rb:103:in `parser'
from /Users/jcalvert/.rvm/gems/jruby-1.6.3/gems/wasabi-2.0.0/lib/wasabi/document.rb:25:in `endpoint'
@jcalvert
jcalvert / CXF_Spring_JRuby.rb
Created October 15, 2011 16:46
Ruby SOAP Performance
require 'java'
require './cxf-deps.jar'
require './client.jar'
require 'benchmark'
context = com.vetstreet.Context.instance
hello_dao = context.get_bean "helloDao"
Benchmark.bm do |x|
x.report do
t = []
1000.times do
@jcalvert
jcalvert / Context.java
Created October 15, 2011 08:10
JRuby + CXF
package com.vetstreet;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.context.support.ClassPathXmlApplicationContext;
/**
* If we pull this JAR in via JRuby, we don't get the sexy OSGI Blueprint magic, so let's
* boot the context and provide accessors. Make it a singleton so we don't go blasting out contexts.
* @author jcalvert
*
@jcalvert
jcalvert / gist:1228041
Created September 20, 2011 00:56
Vetstreet is looking for developers

Vetstreet is looking for developers

Vetstreet is looking for solid software developers in the DC Metro area to work in our downtown Silver Spring office. We have a diverse, interesting, collaborative work environment, delivering software services to veterinarians and their clients.

The interesting bits:

  • We're a polyglot shop. Java and Ruby are our greatest needs right now. If you can do both, awesome. We have Perl and .NET hanging around too. SQL all around.
  • Experience is preferred, but junior candidates OK.
  • You should feel relatively comfortable jumping into different things; some back end, some front end.
  • Most important is that you're smart and enthusiastic.
@jcalvert
jcalvert / gist:1210479
Created September 12, 2011 02:36
to_hash
class Array
def to_hash
Hash[self.zip(map{|i| yield i})] if block_given?
end
end
@jcalvert
jcalvert / Npetest.java
Created August 31, 2011 21:57
Find the NullPointerException!
public abstract class AbstractLoader {
protected LoadJob loadJob;
public AbstractLoader(LoadJob loadJob)
{
this.loadJob = loadJob;
int foo = 0; //Doing stuff
String bar = "foobar";
this.load1();
@jcalvert
jcalvert / gist:1147082
Created August 15, 2011 16:12
dalli vs memcached
ruby-1.9.2-p290 :001 > require 'dalli'
=> true
ruby-1.9.2-p290 :002 > require 'memcached'
=> true
ruby-1.9.2-p290 :003 > Dalli::Client.new('localhost:11211').get('[email protected]')
=> "\x04\bi\x02 \v"
ruby-1.9.2-p290 :004 > Memcached.new('localhost:11211').get('[email protected]')
=> 2848
ruby-1.9.2-p290 :005 >
@jcalvert
jcalvert / gist:1146918
Created August 15, 2011 14:55
memcachestats
[jcalvert@aws-smm-01 sinatra-magic-mirror]$ memcached-tool localhost:11211 stats
#localhost:11211 Field Value
accepting_conns 1
auth_cmds 0
auth_errors 0
bytes 630343442
bytes_read 453062735
bytes_written 1109137
cas_badval 0
cas_hits 0
@jcalvert
jcalvert / gist:1001100
Created May 31, 2011 19:19
BAMF Row object Monkeypatch
class BAMFCSV::Table::Row
def [](key)
field_key=@header_map[key]
if(!field_key.nil?)
@fields[field_key]
end
end
def []=(key,value)
if(self[key].nil?)
@jcalvert
jcalvert / gist:1000620
Created May 31, 2011 14:45
BAMFCSV vs FasterCSV
require 'benchmark'
require 'bamfcsv'
require 'csv'
glob,totalsize,rows,filetime,bamftime,fastertime=Dir.glob("*.csv"),0,[],Benchmark::Tms.new,Benchmark::Tms.new,Benchmark::Tms.new
content=nil
glob.each{|file|
filetime.add!{Benchmark.measure{ content = IO.read(file).rstrip.force_encoding("ISO-8859-1") }}
totalsize+=content.size
bamftime.add!{Benchmark.measure{BAMFCSV.parse(content){|row| rows << row}}}