View solread_monkeypatch.rb
require 'solr_ead/indexer' # make sure it's here to patch
class SolrEad::Indexer
include RSolr
include SolrEad::Behaviors
# Batch the components in blocks of 50. In real life, we'll want do error checking:
# if a batch-index throws an error, do them one at a time, logging the bad one(s)

Install using a template:

This is slighly different in that it installs the gems inside the app directory in yourappname/.bundle and uses native libxml2 to compile nokogiri.

$ ruby -v # need a 2.3 or later
   => 2.4.0
$ rails -v # 
   => 5.0.2

Install a skeleton Rails app with Hyrax

(from Seth Johnson)

$ ruby -v
    => ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-linu

$ rails -v
    => Rails 5.0.2
View build_an_iterator_1.rb
# A simpler example: create an object which takes
# in a file name and allows you to iterate over
# only the comments (lines that start with '#')
# Obviously, it'd be pretty easy to do this inline, but it's just an
# example. One could also imagine it returning every set of
# contiguous comment lines as a single comment, or even being smart enough to
# do C-style /* ... */ comments and extract those.
# The point is that you've got that all hidden in a class, and the user
View taghosts
#!/usr/bin/env ruby
require 'optparse'
ACTIVE_SERVERS = '/l/local/active-servers'
def alltags
alltags = [] do |line|
tokens = line.split(/\s+/)
View marc_html.rb
# encoding: UTF-8
require 'slim'
require 'marc'
# Get a record somehow. Here, I just nab the marc-in-json from the HT catalog and use that.
require 'json'
require 'open-uri'
rec = MARC::Record.new_from_hash(JSON.parse(open('').read))
View emtest.rb
require 'traject'
include Traject::Macros::Marc21
r =
r <<'001', '12345')
r <<'245', ' ', ' ', ['a', 'My Title'])
context =
View include.rb
module A
def hello
puts "Hello from A"
def goodbye
puts "Goodbye from A"
class B
View each_rescue.rb
class A
include Enumerable
def each
(1..10).each do |i|
raise"SIX") if i == 6
yield i
View marc-threadedreader.rb
require 'concurrent'
require 'thread'
require 'marc'
class MARC::ThreadedReader < MARC::Reader
include Enumerable
include Concurrent::Async
def initialize(file, options={})