This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head><title>Title of Page</title></head> | |
<body> | |
<div itemscope itemtype="CollectionPage"> | |
<span itemprop="name">Name</span> | |
</div> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- 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"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
source 'https://rubygems.org' | |
gem 'rails', '3.2.1' | |
# Bundle edge Rails instead: | |
# gem 'rails', :git => 'git://github.com/rails/rails.git' | |
gem 'sqlite3' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- copy this to YOUR_THEME.tmTheme--> | |
<dict> | |
<key>name</key> | |
<string>diff: deleted</string> | |
<key>scope</key> | |
<string>markup.deleted</string> | |
<key>settings</key> | |
<dict> | |
<key>background</key> | |
<string>#EAE3CA</string> |
OlderNewer