This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
##---------------------------------------------------------------- | |
## HSTORE: PostgreSQL key-value store column type | |
##---------------------------------------------------------------- | |
# Double-quotes the value, escaping embedded double-quotes. This is NOT the | |
# same as db quoting (which uses apostrophes), and any value here must also | |
# be quote()'ed before sending to the database. | |
sub double_quote { | |
my ($self, $v) = @_; | |
$v =~ s/"/\\"/g; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# http://avdi.org/talks/confident-code-2010-01-12/confident-code.html | |
# Narrative structure: Four Parts | |
#========================================================== | |
# Gather input: | |
# Coerce | |
param.to_s #to_i #to_sym Array() ... use liberally! | |
messages = Array(messages) | |
# Decorators |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'rubygems' | |
require 'nokogiri' | |
class Cleaner | |
def read | |
f = File.open("nelson.xml") | |
@doc = Nokogiri::XML(f) | |
f.close | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'active_support' | |
class MyLogger < ActiveSupport::BufferedLogger | |
SEVERITY_NAME = %w( DEBUG INFO WARN ERROR FATAL UNKNOWN ) | |
def custom_line(severity, message) | |
# Customized Log Format! | |
message = [Time.now.strftime("%Y-%m-%d %H:%M:%S"), ENV['BL_JOB_ID']||$$, SEVERITY_NAME[severity], message].join("\t") | |
end | |
def add(severity, message = nil, progname = nil, &block) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Update the system first | |
sudo ntpdate ntp.ubuntu.com | |
sudo apt-get update | |
sudo apt-get upgrade | |
# Ubuntu stuff | |
sudo apt-get -y install git-core openssh-server openssh-client build-essential wget ntp-simple | |
# be aware: vim vim-ruby installed x crap :( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Inspired by http://blog.fiveruns.com/2008/9/24/rails-automation-at-slicehost | |
apt-get update | |
apt-get upgrade -y | |
apt-get -y install build-essential libssl-dev libreadline5-dev zlib1g-dev | |
apt-get -y install mysql-server libmysqlclient15-dev mysql-client | |
apt-get -y install ruby ruby1.8-dev irb ri rdoc libopenssl-ruby1.8 | |
RUBYGEMS="rubygems-1.3.0" |
NewerOlder