Skip to content

Instantly share code, notes, and snippets.

@jronallo
jronallo / commandline use
Last active August 29, 2015 13:57
pandoc does not convert poster images into data-URIs when using --self-contained
$ ~/.cabal/bin/pandoc --version
pandoc 1.12.3.3
$ ~/.cabal/bin/pandoc -w dzslides --standalone --self-contained ~/tmp/pandoc-poster-image-test.md > ~/tmp/pandoc-poster-image-test.html
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
# 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
@jronallo
jronallo / gist:708769
Created November 21, 2010 14:19
overriding Sunspot::Indexer.prepare to have different id field value
# 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
#!/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 / markdown_outline.rb
Created December 31, 2011 03:08
simple commandline tool to output an outline from a markdown document to the terminal
#!/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
jronallo / bad_itemtype.html
Created January 5, 2012 14:10
The itemtype here should have the full schema.org URL, but a parser should be more tolerant of such bad data.
<html>
<head><title>Title of Page</title></head>
<body>
<div itemscope itemtype="CollectionPage">
<span itemprop="name">Name</span>
</div>
</body>
</html>
@jronallo
jronallo / ccwd_microdata.rb
Created January 30, 2012 01:40
Parse the microdata from Web Data Commons and output a little information.
#!/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 / students-jumping-in-front-of-memorial-bell-tower.html
Created February 9, 2012 16:28 — forked from niklasl/students-jumping-in-front-of-memorial-bell-tower.html
An HTML5+RDFa1.1 version of an example article by Jason Ronallo
<!-- 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 / Gemfile
Created February 11, 2012 22:27 — forked from simi/Gemfile
Refinery + Twitter Bootstrap WIP
source 'https://rubygems.org'
gem 'rails', '3.2.1'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'sqlite3'