Skip to content

Instantly share code, notes, and snippets.

View rob-mcgrail's full-sized avatar
🐟
codin

Rob McGrail rob-mcgrail

🐟
codin
  • Haunt
  • New Zealand
  • 19:39 (UTC +13:00)
View GitHub Profile
@rob-mcgrail
rob-mcgrail / fedora-record-killer.rb
Created July 18, 2012 04:04
Killing fedora records
require 'ostruct'
require 'rubygems'
require 'rest_client'
require 'nokogiri'
SOLR_ROOT = 'http://solr:8983'
FEDORA_ROOT = 'username:password@fedora:8080/fedora'
require 'sinatra'
require 'redis'
$redis = Redis.new
get '/s' do
'Enter a URL: <form method="post" action="s"><input type="text" name="url"><input type="submit" value="Shorten"></form>'
end
post '/s' do
@rob-mcgrail
rob-mcgrail / sso_auth.rb
Created April 17, 2012 21:45
Getting hash of cookies for TKI SSO
class SSOAuth
require 'rubygems'
require 'mechanize'
def self.get_cookies(url)
h = {}
agent = Mechanize.new
agent.get(url) do |page|
if page.forms.first
agent.submit(page.forms.first)
agent.cookies.each do |c|
@rob-mcgrail
rob-mcgrail / ncea-convert.rb
Created April 16, 2012 05:11
Url conversion heroku app to help a content manager migration
require 'sinatra'
require 'haml'
class String
def proper
self.split(/\s+/).each{ |word| word.capitalize! }.join(' ')
end
end
@rob-mcgrail
rob-mcgrail / nginx.conf
Created April 3, 2012 00:29
Quick development drupal config for nginx
# /var/www/drupal/drupal-x.x/ all work with php-fastcgi
user www-data;
worker_processes 4;
pid /var/run/nginx.pid;
events {
worker_connections 768;
# multi_accept on;
}
@rob-mcgrail
rob-mcgrail / SympaSession.pm
Created March 7, 2012 20:13
Modified SympaSessions
# SympaSession.pm - This module includes functions managing HTTP sessions in Sympa
#
# Sympa - SYsteme de Multi-Postage Automatique
# Copyright (c) 1997, 1998, 1999, 2000, 2001 Comite Reseau des Universites
# Copyright (c) 1997,1998, 1999 Institut Pasteur & Christophe Wolfhugel
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
@rob-mcgrail
rob-mcgrail / frbr-tki.owl
Created February 13, 2012 22:49
FRBR inspired model for catalog profile
<?xml version="1.0"?>
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:protege="http://protege.stanford.edu/plugins/owl/protege#"
xmlns:xsp="http://www.owl-ontologies.com/2005/08/07/xsp.owl#"
xmlns:frbr="http://purl.org/vocab/frbr/core#"
xmlns:j.0="http://web.resource.org/cc/"
xmlns:owl="http://www.w3.org/2002/07/owl#"
xmlns:tki="http://mms.tki.org.nz/catalogue.owl#"
xmlns:lom="http://www.owl-ontologies.com/lom.owl#"
@rob-mcgrail
rob-mcgrail / tki-profile.owl.xml
Created January 20, 2012 01:53
Owl model of TKI Metadata Profile
<?xml version="1.0"?>
<rdf:RDF
xmlns:j.0="http://www.owl-ontologies.com/Ontology1326838630.owl#profile:"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:protege="http://protege.stanford.edu/plugins/owl/protege#"
xmlns:xsp="http://www.owl-ontologies.com/2005/08/07/xsp.owl#"
xmlns:owl="http://www.w3.org/2002/07/owl#"
xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
xmlns="http://www.owl-ontologies.com/Ontology1326838630.owl#"
xmlns:swrl="http://www.w3.org/2003/11/swrl#"
@rob-mcgrail
rob-mcgrail / compare.rb
Created January 11, 2012 22:51
Site Upgrade Comparisonator
require 'rubygems'
require 'anemone'
require 'redis'
require 'trollop'
require 'highline'
$term = HighLine.new
opts = Trollop::options do
opt :redis, "Select redis store", :default => 1
# Author: Pieter Noordhuis
# Description: Simple demo to showcase Redis PubSub with EventMachine
#
# Update 7 Oct 2010:
# - This example does *not* appear to work with Chrome >=6.0. Apparently,
# the WebSocket protocol implementation in the cramp gem does not work
# well with Chrome's (newer) WebSocket implementation.
#
# Requirements:
# - rubygems: eventmachine, thin, cramp, sinatra, yajl-ruby