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
  • 05:15 (UTC +12:00)
View GitHub Profile
@rob-mcgrail
rob-mcgrail / colourize.rb
Created December 18, 2011 12:28
Terminal color methods for String
module Colourize
colour_codes = {
:black => 30, :white => 37, :red => 31, :green => 32,
:yellow => 33, :blue => 34, :magenta => 35, :cyan => 36
}
text_effects = {
:blink => 5, :underline => 4, :bright => 1
}
@rob-mcgrail
rob-mcgrail / ipd.rb
Created December 18, 2011 12:37
iterative pd
start_time = Time.now
STDOUT.sync = true
$running = true
$generationcount = 0
def clear
print "\e[2J"; print "\e[0;0f"
end
# 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
@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
@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 / 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 / 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 / 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 / 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 / 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|