Skip to content

Instantly share code, notes, and snippets.

View tommorris's full-sized avatar

Tom Morris tommorris

View GitHub Profile
@tommorris
tommorris / gist:17139
Created October 16, 2008 14:03
My .vimrc file
".vimrc - tommorris.org
:set formatoptions=l
:set lbr
:set wrap
:set autoindent
:set softtabstop=2
:set hlsearch
:colorscheme evening
:syntax enable
@tommorris
tommorris / gist:19739
Created October 25, 2008 13:04
syslog after os x freezeup
Oct 24 08:49:53 localhost kernel[0]: npvhash=4095
Oct 24 08:49:48 localhost com.apple.launchctl.System[2]: fsck_hfs: Volume is journaled. No checking performed.
Oct 24 08:49:48 localhost com.apple.launchctl.System[2]: fsck_hfs: Use the -f option to force checking.
Oct 24 08:49:53 localhost com.apple.launchctl.System[2]: launchctl: Please convert the following to launchd: /etc/mach_init.d/chum.plist
Oct 24 08:49:53 localhost com.apple.launchctl.System[2]: launchctl: Please convert the following to launchd: /etc/mach_init.d/dashboardadvisoryd.plist
Oct 24 08:49:53 localhost com.apple.launchctl.System[2]: launchctl: Please convert the following to launchd: /etc/mach_init.d/pilotfish.plist
Oct 24 08:49:53 localhost com.apple.launchd[1] (com.apple.distccdConfigd): Unknown key: SHAuthorizationRight
Oct 24 08:49:53 localhost com.apple.launchd[1] (org.cups.cupsd): Unknown key: SHAuthorizationRight
Oct 24 08:49:53 localhost com.apple.launchd[1] (org.ntp.ntpd): Unknown key: SHAuthorizationRight
Oct 24 08:49:53
@tommorris
tommorris / gist:20397
Created October 28, 2008 14:55
resplayer - ruby resumable mp3 player
# resplayer - Ruby Resumable Player
# Copyright (c) Tom Morris 2008.
# General Public License - http://www.gnu.org/copyleft/gpl.html
require 'rubygems'
require 'digest/sha1'
require 'yaml'
require 'mp3info'
def construct_time(str)
nums = str.scan(/(\d+)/)
require 'ping'
fe_rules = Array.new
fe_rules << Proc.new do
`wlanconfig ath0 list ap`.split("\n")[1..-1].map {|i| i.split}.each {|net|
if net[1] == "00:1c:10:87:57:eb"
true
elsif net[0] == "GRANGE"
[true, "Kensington Square, London"]
import sys
from BeautifulSoup import BeautifulSoup, Tag
css = ""
doc_file = open(sys.argv[1])
doc_string = '\n'.join(doc_file.readlines())
doc = BeautifulSoup(doc_string)
for i in doc.findAll("style"):
css = css + str("".join(i.contents)) + "\n"
i.extract()
/* JeniT's RDFa jQuery sample code */
rdf = $('#content p:first').rdf();
rdf
.where('?book dc:creator ?author')
.where('?author foaf:surname ?surname')
.filter('surname', /^A/)
.where('?book dc:titiel ?title')
.optional('?book dc:identifier ?isbn')
.each(function() {
@tommorris
tommorris / gist:26235
Created November 18, 2008 19:46
a fun little Ruby time one-liner
puts "it's a wednesday or a thursday between 10am and 11pm" if [3,4].member?(Time.now.wday) && (10..22).member?(Time.now.hour)
require 'rexml/document'
# Get command line params
filename = ARGV[0]
username = `whoami`.strip
filename = "/Users/" + username + "/Library/Application\ Support/Cultured\ Code/Things/Database.xml"
unless ARGV[1].nil?
qry = ARGV[1].strip
else
qry = nil
#!/usr/bin/env ruby
require 'rubygems'
require 'xml'
class Tasks
end
class Things
def initialize(filename = "/Users/" + `whoami`.strip + "/Library/Application\ Support/Cultured\ Code/Things/Database.xml")
@doc = LibXML::XML::Document.file filename if File.exists? filename
@tommorris
tommorris / gist:29150
Created November 25, 2008 22:55
Linux (ALSA) command line alarm clock
#!/usr/bin/env ruby
# Linux (ALSA) command line alarm clock
# written in Ruby, but you can use any language you like.
# store original volume and set volume to 100%
original_volume = `amixer get Master | grep 'Front Left' | cut -d ' ' -f 6`.chop.to_i
`amixer set Master front 65536`
# I'm using 'Alarm Clock 2' from http://www.pacdv.com/sounds/domestic_sounds.html