Skip to content

Instantly share code, notes, and snippets.

View dstrelau's full-sized avatar

Dean Strelau dstrelau

View GitHub Profile
#!/usr/bin/env ruby
#
# mongrel_process_memory - A munin plugin to monitor memory size of
# each individual mongrel process
# Copyright (C) 2007 Ben VandenBos and Avvo, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2
# as published by the Free Software Foundation.
#
#!/usr/bin/env ruby
#
# mongrel_process_memory - A munin plugin to monitor memory size of
# each individual mongrel process
# Copyright (C) 2007 Ben VandenBos and Avvo, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2
# as published by the Free Software Foundation.
#
@dstrelau
dstrelau / backup_user.sql
Created February 20, 2009 16:58
mysql backups with duplicity
CREATE USER 'backup'@'localhost';
GRANT SELECT, LOCK TABLES ON *.* TO 'backup'@'localhost';
== 0. Create and checkout local development branch
You've probably done this already.
git checkout master # now on master
git checkout -b development origin/development # track remote dev branch
== 1. Adding features for bug 12000
This is optional, but highly encouraged. You can just develop right on your
@dstrelau
dstrelau / config.ru
Created March 26, 2009 21:16
Basic Hoptoad Notifier as Rack Middleware
require 'rack/hoptoad_notifier'
use Rack::HoptoadNotifier do |config|
config[:api_key] = 'XXXXXXXX'
end
@dstrelau
dstrelau / configurable.rb
Created June 17, 2009 20:38
Configurable - make any object configurable
require 'ostruct'
module Configurable
def config
@config ||= OpenStruct.new
yield @config if block_given?
end
def respond_to?(sym)
@config.respond_to?(sym) || super(sym)
end
@dstrelau
dstrelau / user.rb
Created July 8, 2009 21:34
contexts for active record validations
class User < ActiveRecord::Base
include ValidationContexts
validation_context :default, :signup do
validates_uniqueness_of :email, :allow_blank => true
validates_presence_of :email
end
validation_context :signup do
validates_confirmation_of :password
$ ruby -v
ruby 1.8.7 (2009-06-12 patchlevel 174) [i686-darwin9.8.0]
$ rake -v
(in /Users/dstrelau/proj)
/Users/dstrelau/.rvm/ruby-1.8.6-p369/bin/ruby -I"lib:test"
[...]
[~] rvm install 1.8.6 -d
++ which curl
+ rvm_curl=/usr/bin/curl
+ '[' 0 -ne 0 ']'
+ rvm_curl='/usr/bin/curl -O -L -s'
+ '[' -z '' -a -z 1.8.6 ']'
+ rvm_implementation=ruby
+ niceness=0
++ whoami
+ '[' dstrelau = root ']'
[~] gem env
RubyGems Environment:
- GEM PATHS:
- /Users/dstrelau/.gem/ruby/1.8.7
- /Users/dstrelau/.gem/ruby/1.8
- /Users/dstrelau/.rvm/ruby-1.8.7-p174/lib/ruby/gems/1.8
[~] rvm use 1.8.7
[~] gem env
RubyGems Environment:
- GEM PATHS: