Skip to content

Instantly share code, notes, and snippets.

View cbeer's full-sized avatar

Chris Beer cbeer

View GitHub Profile
@cbeer
cbeer / apim-listener.xml
Created February 26, 2012 19:17
Fedora API-M JMS -> Camel -> JMS bridge
<?xml version="1.0" encoding="UTF-8"?>
<blueprint
xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.osgi.org/xmlns/blueprint/v1.0.0
http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd">
<camelContext xmlns="http://camel.apache.org/schema/blueprint" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:access="http://www.fedora.info/definitions/1/0/access/">
@cbeer
cbeer / script.rb
Created January 27, 2012 22:00
Fedora (pre-akubra) llstore -> Pairtree
require 'rubygems'
require 'pairtree'
require 'find'
require 'fileutils'
pairtree = Pairtree.at('.', :create => true)
Find.find('data/objects') do |x|
next if File.directory? x
f = x.split("/").last
@cbeer
cbeer / gist:1406418
Created November 29, 2011 20:43
Exclude models from the Rails identity map
require 'active_record/identity_map'
module ActiveRecord
module IdentityMap
class << self
alias_method :add_without_exclude, :add
def exclusions
@exclusions ||= []
end
@cbeer
cbeer / catalog_controller.rb
Created November 3, 2011 19:07
WGBH gated discovery solr helper logic example
class CatalogController < ...
include AmericanArchive::SolrHelper::Authz
end
require 'rubygems'
require 'parslet'
require 'parslet/convenience'
class Duration < Parslet::Parser
rule(:integer) { match('[0-9]').repeat(1, 2) }
rule(:space) { match('\s').repeat(1) }
rule(:space?) { space.maybe }
rule(:q) { str('?') }
@cbeer
cbeer / gist:1042791
Created June 23, 2011 15:40
solrconfig.xml
<requestHandler name="search" class="solr.SearchHandler" default="true" >
<lst name="defaults">
[...]
<str name="sort">score desc, pub_date_sort desc, title_sort asc</str>
[...]
</lst>
</requestHandler>
@cbeer
cbeer / fedora-rewrite-map
Created June 11, 2011 15:12
Apache mod_rewrite script handler that maps Fedora URI requests to filesystem paths (as possible)
#!/usr/bin/env ruby
require 'rubygems'
require 'rubydora'
require 'trollop'
opts = Trollop::options do
version "fedora-rewrite-map 0.0.1 (c) 2011 Chris Beer"
banner <<-EOS
./app <-- "your app directory"
./app/controllers
./app/helpers
./app/models
./app/views
./config
./config/environments
./config/initializers
./coverage
./db
xml.title( document.to_semantic_values[:title][0] || document[:id] )
xml.link(catalog_url(document[:id]))
xml.author( document.to_semantic_values[:author][0] ) if document.to_semantic_values[:author][0]
(function($) {
$.fn.sync = function(target, options) {
media = this;
var settings = {
'begin' : 'begin_seconds',
'end' : 'end_seconds',
'on' : function() { $(this).trigger('sync-on'); },
'off' : function() { $(this).trigger('sync-off'); },
'time' : function() { return this.currentTime },
'poll' : false,