Skip to content

Instantly share code, notes, and snippets.

View hading's full-sized avatar

Howard Ding hading

  • TriCo Libraries
  • PA, USA
View GitHub Profile
#It is possible to change the class in the Rails ext.
#As a preface, note that ActiveFedora lets you do ActiveFedora::Base::AnySubclass.find('any:pid')
#This will work even if the fedora rels-ext doesn't assert the correct model. It's also essential
#for changing the class.
#Note that all of this is quite fiddly and it's likely best to avoid it if possible. I've tried some things that
#seem spiritually equivalent to the below and not had them work.
#create an ActiveFedora::Base object and verify that there are no Medusa::Set objects
1.9.3p194 :011 > x = ActiveFedora::Base.create(:pid => 'my:pid')
=> #<ActiveFedora::Base pid:"my:pid", >
@hading
hading / gist:2898333
Created June 8, 2012 22:12
etd department extraction
#!/usr/bin/env ruby
require 'pdf-reader'
class Extracter
def main
Dir['*.pdf'].each do |pdf|
puts "Analyzing #{pdf}"
reader = PDF::Reader.new(pdf)
lines = reader.pages.collect {|p| p.text.lines.collect {|l| l.strip}}.flatten
lines.each_with_index do |line, i|
@hading
hading / process.rb
Created August 25, 2011 19:15 — forked from kennethkalmer/process.rb
RuoteAMQP error handling example
Ruote.process_definition :name => 'Test' do
sequence do
# Loop, depending on the amqp participant to set 'completed' once it has successfully processed the
# workitem.
_loop :break_if => "${f:completed}" do
# This remote participant will either set a field called 'completed' to true when it is done,
# or set 'error' with the exception.
amqp_participant :activity => "Do something"
# Copyright 2011© MaestroDev. All rights reserved.
module Maestro
#
# An error class for error emitted by the "remote side" and received here.
#
class ReceiveError < RuntimeError
attr_reader :fei