Skip to content

Instantly share code, notes, and snippets.

jronallo / commandline use
Last active Aug 29, 2015
pandoc does not convert poster images into data-URIs when using --self-contained
View commandline use
$ ~/.cabal/bin/pandoc --version
$ ~/.cabal/bin/pandoc -w dzslides --standalone --self-contained ~/tmp/ > ~/tmp/pandoc-poster-image-test.html
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
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'
You can’t perform that action at this time.