Skip to content

Instantly share code, notes, and snippets.

View billdueber's full-sized avatar

Bill Dueber billdueber

View GitHub Profile
@iconara
iconara / worker_pool.rb
Created February 29, 2012 09:22
Simple JRuby worker pool using j.u.c.Executors
# encoding: utf-8
require 'java'
module JUC
java_import 'java.util.concurrent.Executors'
java_import 'java.util.concurrent.TimeUnit'
end
@ordinaryzelig
ordinaryzelig / minitest_spec_expectations.md
Last active December 10, 2022 13:34
How to write MiniTest::Spec expectations

I'm a fan of MiniTest::Spec. It strikes a nice balance between the simplicity of TestUnit and the readable syntax of RSpec. When I first switched from RSpec to MiniTest::Spec, one thing I was worried I would miss was the ability to add matchers. (A note in terminology: "matchers" in MiniTest::Spec refer to something completely different than "matchers" in RSpec. I won't get into it, but from now on, let's use the proper term: "expectations").

Understanding MiniTest::Expectations

Let's take a look in the code (I'm specifically referring to the gem, not the standard library that's built into Ruby 1.9):

# minitest/spec.rb

module MiniTest::Expectations
@baroquebobcat
baroquebobcat / mirah_repl.rb
Created May 1, 2012 03:53
Mirah REPL -- hacked together
#
# Mirah REPL -- hacked to bits
#
# assuming your ruby is jruby,
# $ gem install mirah
# $ ruby -rubygems repl.rb
# m> class Foo
# m> def bar
# m> 12
# m> end
@jrochkind
jrochkind / gist:3812536
Created October 1, 2012 15:34
bean shell for one way of getting an indexable date out of MARC
import org.marc4j.marc.Record;
import org.marc4j.marc.DataField;
import org.marc4j.marc.Subfield;
import org.solrmarc.tools.Utils;
// define the base level indexer so that its methods can be called from the script.
// note that the SolrIndexer code will set this value before the script methods are called.
org.solrmarc.index.SolrIndexer indexer = null;
// Max estimation -- biggest delta of unknown dates that we'll take the
require "thread"
class BoundedQueue
def initialize(max_size = :infinite)
@lock = Mutex.new
@items = []
@item_available = ConditionVariable.new
@max_size = max_size
@space_available = ConditionVariable.new
end
@revmischa
revmischa / install-plenv.sh
Last active July 12, 2022 02:25
Set up plenv, install perl, cpanm, carton, set up environment
#!/bin/bash
# installs plenv, perl, carton, cpanminus, sets up environment in .bash_profile
# from https://github.com/tokuhirom/plenv#readme
PLENV_PERL_VERSION='5.18.1'
if [[ -n "$PERL_MB_OPT" ]]; then
echo "You must unset your local::lib environment variables first"