Skip to content

Instantly share code, notes, and snippets.

require 'rubygems'
require 'bundler/setup'
require 'my_private_gem/deploy'
# Configure loudmouth
MyPrivateGem::Deploy.configure(:application1)
@localshred
localshred / app.js
Created November 10, 2010 06:48
Experimentations in sinatra-style node.js
var util = require('util'),
http = require('http'),
router = require('./router');
console.log('creating server');
var app = http.createServer();
console.log('registering app');
router.registerApp(app);
@localshred
localshred / style_guide.md
Created July 26, 2010 19:27
A general collection of ruby style guidelines that I tend to follow

My Ruby Style Guide

General Syntax rules

Class names should be full camel-case:

class AtlasGuide
end

Method names should be underscored:

# find all the books in the db
books = Book.all
book_names.each do |book_title|
# gets the proper book from the books array
book_record = books.detect{|book| book.name =~ book_title }
# ...
end
book_names.each do |book_title|
chapters = agent.page.links_with(:href => book_title)
chapter_id = 0
chapters.each do |ch|
chapter_id += 1
ch.click
content = agent.page.search(".result-text-style-normal").map(&:text).map(&:strip).to_s
passage_text = Passager.new(content, 0)
passage_text.passages.each do |p|
Verse.create!(:body => p, :chapter_id => chapter_id)
$ thor spec:integration ad_events
Running integration specs matching filter 'ad_events_spec.rb'
/usr/local/lib/ruby19/site_ruby/1.9.1/rubygems.rb:14: warning: already initialized constant VERSION
/usr/local/lib/ruby19/site_ruby/1.9.1/rubygems.rb:14: warning: already initialized constant RubyGemsVersion
/usr/local/lib/ruby19/site_ruby/1.9.1/rubygems.rb:194: warning: already initialized constant MUTEX
/usr/local/lib/ruby19/site_ruby/1.9.1/rubygems.rb:196: warning: already initialized constant RubyGemsPackageVersion
/usr/local/lib/ruby19/site_ruby/1.9.1/rubygems.rb:202: warning: already initialized constant WIN_PATTERNS
/usr/local/lib/ruby19/site_ruby/1.9.1/rubygems.rb:1079: warning: already initialized constant MARSHAL_SPEC_DIR
/usr/local/lib/ruby19/site_ruby/1.9.1/rubygems.rb:1084: warning: already initialized constant YAML_SPEC_DIR
/usr/local/lib/ruby19/site_ruby/1.9.1/rubygems/version.rb:72: warning: already initialized constant VERSION_PATTERN
$ cap shell
* executing `shell'
====================================================================
Welcome to the interactive Capistrano shell! This is an experimental
feature, and is liable to change in future releases. Type 'help' for
a summary of how to use the shell.
--------------------------------------------------------------------
cap> which bundle
[establishing connection(s) to mydomain.com]
error: failed: "sh -c 'which bundle'" on mydomain.com
@localshred
localshred / deploy.rb
Created February 4, 2010 23:03 — forked from richievos/bundler_cap.rb
Using Bundler 0.9.1 with Capistrano
# ...
namespace :bundler do
task :create_symlink, :roles => :app do
shared_dir = File.join(shared_path, 'bundle')
release_dir = File.join(current_release, '.bundle')
run("mkdir -p #{shared_dir} && ln -s #{shared_dir} #{release_dir}")
end
task :bundle_new_release, :roles => :app do
$ cap deploy:cold
* executing `deploy:cold'
* executing `deploy:update'
** transaction: start
* executing `deploy:update_code'
executing locally: "git ls-remote [email protected]:/home/git/myapp.git HEAD"
* executing "git clone -q [email protected]:/home/git/myapp.git /var/www/myapp/releases/20100204223421 && cd /var/www/myapp/releases/20100204223421 && git checkout -q -b deploy 14dd2843341cd0984afb147050a02228ee7eae02 && (echo 14dd2843341cd0984afb147050a02228ee7eae02 > /var/www/myapp/releases/20100204223421/REVISION)"
servers: ["mydomain.com"]
[mydomain.com] executing command
command finished
class LibraryController > ApplicationController
...
def index
@file_tree = AudioLib.build_tree
end
...
end