Skip to content

Instantly share code, notes, and snippets.

SingleLine:
A
B
C
ManyLines:
C
B
A
# After reading this comment
# http://avdi.org/devblog/2010/08/02/using-and-and-or-in-ruby/#comment-1098 ,
#
# I became aware of a cool idiom for Ruby.
#
# I've seen this in a lot of cases:
if (variable = expression_or_method(options))
variable.calculate_something
do_other_stuff(variable)
mv /etc/yum.conf /etc/yum.conf.5.4
sed s/release=5.4/release=5.5/ /etc/yum.conf.5.4 > /etc/yum.conf
yum -y remove ruby
yum -y install gcc gcc-c++ kernel-devel zlib-devel openssl-devel readline readline-devel bison gettext-devel expat-devel curl-devel
COMPILE_PATH=/tmp/install
mkdir -p $COMPILE_PATH
cd $COMPILE_PATH
namespace :vlad do
desc "installs Bundler if it is not already installed"
remote_task :install_bundler do
run "sh -c 'if [ -z `which bundle` ]; then echo Installing Bundler; sudo gem install bundler --pre; fi'"
end
desc "run 'bundle install' to install Bundler's packaged gems for the current deploy and cache the config and lock files for the next releases"
remote_task :bundle_install do
run "cd #{latest_release} && bundle install #{shared_path}/bundle --without development test"
class Pumphouse::Model
extend ActiveModel::Naming
def self.connection=(*args)
@connection = Cassandra.new(*args)
end
def self.connection
@connection
end
/subscriber/xxx/messages
/subscriber/xxx/messages/received
/subscriber/xxx/messages/sent
/subscriber/xxx/messages/tagged/ttt
/subscriber/xxx/messages/received/tagged/ttt
/subscriber/xxx/messages/sent/tagged/ttt
/subscriber/xxx/messages/between/yyy
# Edit this Gemfile to bundle your application's dependencies.
source 'http://rubygems.org'
git 'git://github.com/rails/rails.git', :glob => "{*/,}*.gemspec"
gem 'rails', '3.0.0.beta1'
class Message
extend ActiveModel::Naming
include ActiveModel::Serializers::Xml
include ActiveModel::Serializers::JSON
def self.for_subscriber(subscriber_id)
# nasty!
5.times.collect { Message.new }
end
module ColumnReader
def column_reader(column_name, options = {})
name = options.delete(:as) || column_name.to_s.pluralize
column = columns_hash[column_name.to_s]
self.module_eval %{
def self.#{name}
query = scoped.arel.project(arel_table[:#{column_name}])
connection.select_all(query.to_sql).collect do |value|
jermey.davis
birdie.zboncak
duane.bradtke
mona.mcclure
angela.rath
raquel.marvin
gustave.maggio
viva.yost
abner.koelpin
jeff.welch