Skip to content

Instantly share code, notes, and snippets.

View linyows's full-sized avatar

Tomohisa Oda linyows

View GitHub Profile
@linyows
linyows / deploy.rb
Created November 1, 2011 05:32 — forked from alkema/deploy.rb
Capistrano task for a Node.js app with github Forever and NPM.
set :application, "appname"
set :deploy_to, "/var/www"
set :scm, :git
set :repository, "git@github.com:user/app.git"
default_run_options[:pty] = true
set :user, "www-data"
set :domain, "foo.tld"
set :normalize_asset_timestamps, false
@linyows
linyows / deploy.rb
Created November 1, 2011 05:32 — forked from dakatsuka/deploy.rb
Capistrano recipe for Node.js + upstart
# This program is free software. It comes without any warranty, to
# the extent permitted by applicable law. You can redistribute it
# and/or modify it under the terms of the Do What The Fuck You Want
# To Public License, Version 2, as published by Sam Hocevar. See
# http://sam.zoy.org/wtfpl/COPYING for more details.
set :application, "nodeapp"
set :scm, :git
set :repository, "git://github.com:hogehoge/foobar.git"
set :branch, "master"
@linyows
linyows / nginx.conf
Created January 10, 2012 05:24 — forked from sax/nginx.conf
unicorn + nginx on launchd
user sax staff;
worker_processes 1;
daemon off;
error_log /var/log/nginx/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
pid /var/run/nginx.pid;
@linyows
linyows / taifu
Created February 25, 2012 05:44 — forked from katsuma/taifu
taifu will add youtube sound to your iTunes library silently
#!/usr/bin/env ruby
# usage:
# taifu http://www.youtube.com/watch?v=KPWfBfFFrwsx
# taifu depends on VLC.app and rb-appscript gem
require 'rubygems'
require 'appscript'
require 'fileutils'
@linyows
linyows / colorize.pl
Created June 16, 2012 05:22 — forked from Cside/colorize.pl
colorize keywords of logs.
#!/usr/bin/env perl
=head1 Examples
$ tail -f access_log | perl colorize.pl
$ plackup app.psgi 2>&1 | perl colorize.pl
=cut
use strict;
# 2. Include Sweeping module in your controller(s) to have cache_sweeper
# method to be avaliable, or right in ApplicationController so it will be
# available in all controllers inheriting from it.
class ApplicationController < ActionController::Base
include ActionController::Caching::Sweeping
# ...
end
class ApplicationController < ActionController::Base
...
# FORCE to implement content_for in controller
def view_context
super.tap do |view|
(@_content_for || {}).each do |name,content|
view.content_for name, content
end
end
end
# -*- mode: ruby -*-
# vi: set ft=ruby :
# David Lutz's Multi VM Vagrantfile
# inspired from Mark Barger's https://gist.github.com/2404910
boxes = [
{ :name => :web, :role => 'web_dev', :ip => '192.168.33.1', :ssh_port => 2201, :http_fwd => 9980, :cpus =>4, :shares => true },
{ :name => :data, :role => 'data_dev', :ip => '192.168.33.2', :ssh_port => 2202, :mysql_fwd => 9936, :cpus =>4 },
{ :name => :railsapp, :role => 'railsapp_dev', :ip => '192.168.33.3', :ssh_port => 2203, :http_fwd => 9990, :cpus =>1}
]

Vagrant Setup

This tutorial guides you through creating your first Vagrant project.

We start with a generic Ubuntu VM, and use the Chef provisioning tool to:

  • install packages for vim, git
  • create user accounts, as specified in included JSON config files
  • install specified user dotfiles (.bashrc, .vimrc, etc) from a git repository

Afterwards, we'll see how easy it is to package our newly provisioned VM

shared_context "for_extending" do
context "extended with MyModule" do
before(:all){ subject.extend(MyModule) }
it "should define #some_method" do
subject.should respond_to(:some_method)
end
yield
end
end