Skip to content

Instantly share code, notes, and snippets.

" I'm so over vi
set nocompatible
" The one true encoding
set encoding=utf-8
" We have a fast connection
set ttyfast
" I back up other ways
@nwjsmith
nwjsmith / proc_composition.rb
Created September 22, 2010 18:12 — forked from headius/proc_composition.rb
Composable procs
class Proc
def <<(other)
case other
when Proc
Proc.new do |*args|
call(other.call(*args))
end
else
call(other)
end

Writing Commit Messages

One line summary (< 50c)

Longer description (wrap at 72c)

Summary

ruby-1.9.2-rc1 > f = Father.new
=> #<Father id: nil, name: nil, created_at: nil, updated_at: nil>
ruby-1.9.2-rc1 > f.name = "Dave"
=> "Dave"
ruby-1.9.2-rc1 > s = Son.new :name => "Nate"
=> #<Son id: nil, name: "Nate", father_id: nil, created_at: nil, updated_at: nil>
ruby-1.9.2-rc1 > f.son
f.son_ids f.sons f.sons= f.son_ids=
ruby-1.9.2-rc1 > f.sons << s
=> [#<Son id: nil, name: "Nate", father_id: nil, created_at: nil, updated_at: nil>]
" Use Vim settings, rather than Vi settings
set nocompatible
" Use The Pope's awesome pathogen.vim to load plugins
call pathogen#runtime_append_all_bundles()
" Automatically detect filetypes
filetype on
" Use syntax highlighting
# Credit to Brandon Keepers
# http://opensoul.org/2007/2/9/automatically-backing-up-your-remote-database-on-deploy
require 'yaml'
desc "Backup the remote production database"
task :backup, :roles => :db, :only => { :primary => true } do
filename = "#{application}.dump.#{Time.now.to_i}.sql.bz2"
file = "/tmp/#{filename}"
env = ENV['RAILS_ENV'] || 'development'
on_rollback { delete file }
We couldn’t find that file to show.
Run the following commands
==========================
wget "http://kernel.org/pub/software/scm/git/git-1.7.0.1.tar.bz2"
tar xvf git-1.7.0.1.tar.bz2
mkdir $HOME/local/
cd git-1.7.0.1
./configure --prefix=$HOME/local/
make
make install
We couldn’t find that file to show.
byte * fib(byte *prev, byte *curr, int n)
{
byte *next;
// Fib(0) = 0
if (n == 0) { return prev; }
next = sum(prev, curr);
if (n > 2) {
return fib(curr, next, n - 1);
} else {
return next;