Skip to content

Instantly share code, notes, and snippets.

fidothe /
Created Mar 30, 2021
An attempt to provide a minimal reproduction of a threading-related JRuby problem

While working on I hit errors in production using a semi-experimental branch ( in a threaded XML-processing program.

The errors were the same NoMethodError: undefined method __jcreate_meta!' as in, and the program structure is almost identical save for some loading indirection thanks to the use of autoload.

I am running it in a CI-type environment where 20+ EC2 instances are spun up to process a large amount of data. Most, but not all, runs I'd have one instance's process crash with the error.

Creating an instance of the problem class (, EgClass in this reproduction case) on the main thread, rather than in the worker threads, has made the problem vanish entirely.

View gsub.log
jruby [master] $ benchmark bench/core/string/bench_gsub.rb
Warming up --------------------------------------
gsub-string 83.418k i/100ms
gsub-regex 120.922k i/100ms
gsub-regex-block 82.905k i/100ms
gsub-string 96.724k i/100ms
gsub-regex 128.786k i/100ms
gsub-regex-block 83.732k i/100ms
gsub-string 100.446k i/100ms
fidothe / rake-spec_ruby_fast-1.8u131.log
Last active Oct 18, 2019
log from running jruby -S rake spec:ruby:fast on a fresh checkout using JDK 1.8
View rake-spec_ruby_fast-1.8u131.log
MSPEC: {:compile_mode=>"OFF", :format=>"d", :spec_target=>":fast", :jruby_opts=>"-I. --dev", :jit_threshold=>20, :jit_max=>-1, :objectspace_enabled=>true, :thread_pooling=>false, :reflection=>false}
rm -rf rubyspec_temp
JAVA options: {:dir=>"/work/jruby", :maxmemory=>"1024M", :resultproperty=>"spec.status.OFF", :fork=>"true", :failonerror=>"true", :classname=>"org.jruby.Main"}
$ /work/jruby/bin/jruby -J-ea -J-Djruby.launch.inproc=false -J-Djruby.compile.mode=OFF -J-Djruby.jit.threshold=20 -J-Djruby.jit.max=-1 -J-Djruby.objectspace.enabled=true -J-Djruby.thread.pool.enabled=false -J-Djruby.reflection=false -J-Demma.coverage.out.file=target/test-results/coverage.emma -J-Demma.coverage.out.merge=true -J-Demma.verbosity.level=silent -J-XX:MaxMetaspaceSize=512M /work/jruby/spec/mspec/bin/mspec-ci -f d :fast
jruby (2.5.7) 2019-10-18 29935ad Java HotSpot(TM) 64-Bit Server VM 25.131-b11 on 1.8.0_131-b11 [darwin-x86_64]
/work/jruby/spec/ruby/core/module/attr_spec.rb:38: warning: optional boolean argum
fidothe / eg.rb
Last active Oct 14, 2019
Shows StackOverflow
View eg.rb
require 'saxon/loader'
require 'saxon/item_type'
fidothe / eg.rb
Created Jun 27, 2016
application process
View eg.rb
# The code smell: disjoint radio buttons reveal that some values that
# should have hung together didn't, and that there were also dependent
# fields (the data protection checkbox and the application form link)
# which were hanging around and being a little bit problematic
# A solution is to use one field that can hold several values, unlike the
# boolean which can only hold two.
# We can also introduce a VALUE OBJECT that represents this field and can
# also tell us which (if any) of the dependent fields are needed.
fidothe /
Last active Nov 29, 2015
Attempting to read a number out of an FFI struct-in-a-struct
use std::ffi::CString;
extern crate libc;
/* structs and enums-hiding-structs taken from libdvdread:;a=blob;f=src/dvdread/dvd_reader.h;h=9c7be9d0d2dcaa7dd003b43ecc00fc791ffec657;hb=refs/heads/master;a=blob;f=src/dvdread/ifo_read.h;h=97f4179f0ce95d00d1db0df136a0111a574e71a2;hb=refs/heads/master;a=blob;f=src/dvdread/ifo_types.h;h=33f03467b375025ac78c0294e42c321df924ffae;hb=refs/heads/master
pub enum DVDReader {}
pub enum DVDFile {}
fidothe /
Last active Jul 26, 2017
How to build Torch with CUDA extensions with a Ubuntu 14.04 g2.* instance on EC2

I got Torch + CUDA working on a Ubuntu 14.04 g2.2xlarge EC2 instance using these instructions. Get the latest CUDA install package by consulting and grabbing the most recent. (7.0 at time of writing).

I also made a public AMI with this, plus Dan Hon's char-rnn fork pre-installed.

It's ami-9bcadbab, or dreaming-prose-public, in the us-west-2 (Oregon) region. You should be able to copy it to another region if you need to. You can launch an instance in the EC2 console at this URL:

You'll need a g2.2xlarge or g2.8xlarge instance or there'll be no CUDA for you...

fidothe / spec-dowser.rb
Created Jun 26, 2015
dowsing for spec ordering issues
View spec-dowser.rb
# encoding: utf-8
SEED = 6514
BASE_CMD = "bundle exec rspec --fail-fast --seed #{SEED}"
all_potential_files = Dir['spec/controllers/**/*_spec.rb', 'spec/features/**/*_spec.rb']
definitely_involved = ['spec/controllers/concerns/x.rb', 'spec/features/y.rb']
potential_files = all_potential_files.to_a - definitely_involved
def attempt(files)
fidothe / pdfx.rb
Last active Nov 19, 2020
Worked example for creating a PDF/X-1a:2003 document with Prawn
View pdfx.rb
require 'prawn'
require 'prawn/measurements'
# I have a small collection of links to the resources I used to figure all
# this out:
module PDFX
class PageBox
include Prawn::Measurements
attr_reader :bleed_mm
fidothe / action.rb
Created Mar 18, 2015
poss other approach to apps loading problem
View action.rb
require 'api/application'
module Api
module Controllers
module Urls
class Add
include Api::Action
def call(params)