Skip to content

Instantly share code, notes, and snippets.

@jronallo
jronallo / collection_guides_quicksearch.js
Created Nov 3, 2012
jQuery snippet for experimental quicksearch filtering on http://www.lib.ncsu.edu/findingaids
View collection_guides_quicksearch.js
/* Copyright 2012 North Carolina State University
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
@jronallo
jronallo / Gemfile
Created Feb 11, 2012 — forked from simi/Gemfile
Refinery + Twitter Bootstrap WIP
View Gemfile
source 'https://rubygems.org'
gem 'rails', '3.2.1'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'sqlite3'
View students-jumping-in-front-of-memorial-bell-tower.html
<!-- An RDFa 1.1 version of the data presented in the article
"HTML5 Microdata and Schema.org" at
<http://journal.code4lib.org/articles/6400>.
The article is licensed under a Creative Commons Attribution 3.0 United
States License. This example code should be consired a remix thereof. -->
<div id="main" role="main" class="container_12" vocab="http://schema.org/" resource="" typeof="ItemPage">
<h2 id="page_name" property="name">
Students jumping in front of Memorial Bell Tower
</h2>
<div class="grid_5" resource="http://www.freebase.com/m/026twjv">
@jronallo
jronallo / ccwd_microdata.rb
Created Jan 30, 2012
Parse the microdata from Web Data Commons and output a little information.
View ccwd_microdata.rb
#!/usr/bin/env ruby
# ccwd_microdata.rb /path/to/ccrdf.html-microdata.nq
require 'pp'
require 'rubygems'
require 'rdf'
require 'rdf/nquads'
if !ARGV[0]
puts "must supply path to nquads file"
@jronallo
jronallo / bad_itemtype.html
Created Jan 5, 2012
The itemtype here should have the full schema.org URL, but a parser should be more tolerant of such bad data.
View bad_itemtype.html
<html>
<head><title>Title of Page</title></head>
<body>
<div itemscope itemtype="CollectionPage">
<span itemprop="name">Name</span>
</div>
</body>
</html>
@jronallo
jronallo / markdown_outline.rb
Created Dec 31, 2011
simple commandline tool to output an outline from a markdown document to the terminal
View markdown_outline.rb
#!/usr/bin/env ruby
# markdown outline
# simple commandline tool to output an outline from a markdown document to the terminal
require 'rubygems'
require 'redcarpet'
class OutlineRenderer < Redcarpet::Render::HTML
attr_accessor :outline
View compare_raw_enhanced.rb
#!/usr/bin/env ruby
if !ARGV[0] or !ARGV[1]
puts "You must specify the raw and enhanced directories. Try again!"
exit
end
# first we find the full path of the arguments in case we're only given
# partial paths.
raw_input_file_path = File.expand_path(ARGV[0])
@jronallo
jronallo / gist:708769
Created Nov 21, 2010
overriding Sunspot::Indexer.prepare to have different id field value
View gist:708769
# in Rails place this in config/initializers/sunspot_indexer_prepare.rb
Sunspot::Indexer.module_eval do
alias :old_prepare :prepare
def prepare(model)
document = old_prepare(model)
document.fields_by_name(:id).first.value = document.fields_by_name(:filename).first.value
document
end
end
View application_helper.rb
# performs an XSLT transform given a path to a stylesheet and a document
def xslt(stylesheet_file_path, document, params={})
require 'nokogiri'
document = Nokogiri::XML(document)
stylesheet_file = render(stylesheet_file_path)
stylesheet = Nokogiri::XSLT(stylesheet_file)
stylesheet.apply_to(Nokogiri::XML(document.to_xml), params)
end
View net_ldap_overrides.rb
class Net::LDAP
def initialize(args = {})
@host = args[:host] || DefaultHost
@port = args[:port] || DefaultPort
@verbose = false # Make this configurable with a switch on the class.
@auth = args[:auth] || DefaultAuth
@base = args[:base] || DefaultTreebase
encryption args[:encryption] # may be nil