Skip to content

Instantly share code, notes, and snippets.

View billdueber's full-sized avatar

Bill Dueber billdueber

View GitHub Profile
@billdueber
billdueber / thread_pool_failure.rb
Last active August 29, 2015 14:02
Demonstration of MRI thread pools failing to do all their work
require 'concurrent'
require 'thread'
# A simple safe array implementation.
class SafeArray
def initialize
@write_mutex = Mutex.new
@arr = []
end
def <<(x)
@billdueber
billdueber / _setup.sh
Last active August 29, 2015 14:06
Lotus::Utils JRuby-Head failures
$ git clone http://github.com/lotus/utils
Cloning into 'utils'...
remote: Counting objects: 830, done.
remote: Total 830 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (830/830), 137.72 KiB | 0 bytes/s, done.
Resolving deltas: 100% (441/441), done.
Checking connectivity... done.
$ cd utils
$ chruby jruby_head
@billdueber
billdueber / marc_serialization_bench.rb
Created October 9, 2014 16:55
Ruby MARC serialization / deserialization benchmark
require 'benchmark'
require 'marc'
require 'msgpack'
require 'json'
unless defined? JRUBY_VERSION
require 'oj'
end
@billdueber
billdueber / gist:b2def26222d17f01e002
Created November 6, 2014 15:00
Govdocs Emumchron test cases
v.1
pt.1
pt.13
1973
1
v.2*
v. 1-2
v. 3
v.5 1968
v.2 1942-1945
@billdueber
billdueber / gist:96d605b5dd5e75da9e22
Created December 3, 2014 19:23
Shopping list for my mom

Sorry you had to ask over and over again

I could make chicken schnitzel one night if you'd like; Nadav bitches about it, but the rest of us like it. The older boys will always fall back on pasta with pesto, and Shai would eat penne with parm grated over it every meal if we let him. Which we kinda do, now that I think about it. Pizza is always good, too, obviously.

The younger boys both eat the strawberry tube yogurt two at a time, which is why I asked for so many of those.

Stuff you should probably get at TJs

@billdueber
billdueber / blacklight_toy_index.rb
Last active August 29, 2015 14:14
traject translation of blacklight solrmarc
gem 'traject', '2.0.pre' # from the dev-2.0 branch
$:.unshift '.'
require 'library_stdnums'
require 'traject/macros/marc21_semantics'
extend Traject::Macros::Marc21Semantics
require 'traject/macros/marc_format_classifier'
extend Traject::Macros::MarcFormats
@billdueber
billdueber / results.txt
Created February 9, 2015 18:43
Ruby-marc about half as fast as marc4j doing MARC21 and MARC-XML under Traject
jruby 1.7.18 (1.9.3p551) 2014-12-22 625381c on Java HotSpot(TM) 64-Bit Server VM 1.8.0-b132 +jit [darwin-x86_64]
Rehearsal ------------------------------------------------
marc4j w/bin 19.640000 1.000000 20.640000 ( 8.313000)
ruby w/bin 22.470000 0.600000 23.070000 ( 14.930000)
marc4j w/xml 12.950000 1.130000 14.080000 ( 6.189000)
@billdueber
billdueber / gist:7b8e60587e71c2009ced
Created February 13, 2015 18:37
FastXMLWriter vs XMLWriter
require 'benchmark'
require 'benchmark/ips'
require 'marc'
require 'marc/fastxmlwriter'
record = MARC::Reader.new('test/one.dat').first
puts RUBY_DESCRIPTION
@billdueber
billdueber / index.rb
Last active August 29, 2015 14:16
Unrolling traject ToFieldStep loop
require 'library_stdnums'
require 'traject/macros/marc21_semantics'
extend Traject::Macros::Marc21Semantics
require 'traject/macros/marc_format_classifier'
extend Traject::Macros::MarcFormats
require 'traject/solr_json_writer'
require 'traject/marc_reader'
@billdueber
billdueber / threaded_read.rb
Created February 25, 2015 17:33
Threaded MARC reads
require 'concurrent'
require 'thread'
require 'json'
require 'stringio'
require 'marc'
require 'benchmark'
# OK. Try to read in a line, and then have another thread transform it, and expose
# via #each.