Skip to content

Instantly share code, notes, and snippets.

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)
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
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!"
# 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 / 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
jronallo / bad_itemtype.html
Created Jan 5, 2012
The itemtype here should have the full URL, but a parser should be more tolerant of such bad data.
View bad_itemtype.html
<head><title>Title of Page</title></head>
<div itemscope itemtype="CollectionPage">
<span itemprop="name">Name</span>
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"
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" at
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="" resource="" typeof="ItemPage">
<h2 id="page_name" property="name">
Students jumping in front of Memorial Bell Tower
<div class="grid_5" resource="">
jronallo / Gemfile
Created Feb 11, 2012 — forked from simi/Gemfile
Refinery + Twitter Bootstrap WIP
View Gemfile
source ''
gem 'rails', '3.2.1'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://'
gem 'sqlite3'
jronallo / collection_guides_quicksearch.js
Created Nov 3, 2012
jQuery snippet for experimental quicksearch filtering on
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 / markdown.xml
Created Dec 2, 2012 — forked from lg0/markdown.xml
Markdown Syntax Highlighting for Sublime text 2
View markdown.xml
<!-- copy this to YOUR_THEME.tmTheme-->
<string>diff: deleted</string>