Skip to content

Instantly share code, notes, and snippets.

View xwmx's full-sized avatar

William Melody xwmx

View GitHub Profile
God.watch do |w|
w.name = "apache2"
w.interval = 30.seconds # default
w.start = "apache2ctl start"
w.stop = "apache2ctl stop"
w.restart = "apache2ctl restart"
w.start_grace = 10.seconds
w.restart_grace = 10.seconds
w.pid_file = "/var/run/apache2.pid"
w.behavior(:clean_pid_file)
# http://thewebfellas.com/blog/2008/2/12/a-simple-faith-monitoring-by-god
God.watch do |w|
w.name = "mysqld"
w.interval = 30.seconds # default
w.start = "service mysqld start"
w.stop = "service mysqld stop"
w.restart = "service mysqld restart"
w.start_grace = 20.seconds
w.restart_grace = 20.seconds
w.pid_file = "/var/run/mysqld/mysqld.pid"
@xwmx
xwmx / url_dsl.rb
Created December 14, 2009 20:01 — forked from defunkt/url_dsl.rb
require 'open-uri'
# url dsl -- the ultimate url dsl!
#
# You just can't beat this:
#
# $ irb -r url_dsl
# >> include URLDSL
# => Object
# >> http://github.com/defunkt.json
# smoother space switching animations for snow leopard
$ sudo defaults write /Library/Preferences/com.apple.windowserver Compositor -dict deferredUpdates 0
#!/usr/bin/env ruby
# -*- ruby -*-
require 'rubygems'
require 'daemon-spawn'
RAILS_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
class DelayedJobWorker < DaemonSpawn::Base
def start(args)
ENV['RAILS_ENV'] ||= args.first || 'development'
# http://www.loc.gov/standards/iso639-2/ascii_8bits.html
ISO_639_2 = [
["aar", "", "aa", "Afar", "afar"],
["abk", "", "ab", "Abkhazian", "abkhaze"],
["ace", "", "", "Achinese", "aceh"],
["ach", "", "", "Acoli", "acoli"],
["ada", "", "", "Adangme", "adangme"],
["ady", "", "", "Adyghe; Adygei", "adyghé"],
["afa", "", "", "Afro-Asiatic languages", "afro-asiatiques, langues"],
@xwmx
xwmx / loc.rb
Created January 17, 2010 04:53
# Library of Congress Main Classes and Subclasses
{
"A" => {
:name => "General Works",
:subclasses => {
"AC" => "Collections; Series; Collected works",
"AE" => "Encyclopedias",
"AG" => "Dictionaries and other general reference works",
"AI" => "Indexes",
"AM" => "Museums. Collectors and collecting",
require 'rubygems'
require 'nokogiri'
include Nokogiri
class PostCallbacks < XML::SAX::Document
def start_element(element, attributes)
puts "start element: #{element}"
puts "attributes: #{attributes.inspect}"
end
require 'open3'
class RbST
@@executable_path = File.expand_path(File.join(File.dirname(__FILE__), "rst2parts"))
@@executables = {
:html => File.join(@@executable_path, "rst2html.py"),
:latex => File.join(@@executable_path, "rst2latex.py")
}