Skip to content

Instantly share code, notes, and snippets.

View rduarte's full-sized avatar
🏠
Working from home

Ricardo Duarte rduarte

🏠
Working from home
View GitHub Profile
ricardoduarte ~ $ sudo brew install postgresql
==> Downloading ftp://ftp.ossp.org/pkg/lib/uuid/uuid-1.6.2.tar.gz
######################################################################## 100,0%
==> ./configure --disable-debug --without-perl --without-php --without-pgsql --p
==> make
==> make install
/usr/local/Cellar/ossp-uuid/1.6.2: 11 files, 364K, built in 17 seconds
==> Downloading http://ftp9.us.postgresql.org/pub/mirrors/postgresql/source/v9.0
######################################################################## 100,0%
==> ./configure --disable-debug --prefix=/usr/local/Cellar/postgresql/9.0.1 --en
sudo tar -C /opt -xvjf FileZilla_3.2.7.1_i586-linux-gnu.tar.bz2
# Para um novo projeto, crie esta estrutura
[dev-user1] $ mkdir projeto
[dev-user1] $ cd projeto
[dev-user1] $ git init
[dev-user1] $ touch README
[dev-user1] $ git add .
[dev-user1] $ git commit -am "Initial commit"
# Crie no servidor um repositório do tipo bare para "guardar" os commits
[bare-server1] $ mkdir -p /git/projeto
@rduarte
rduarte / gist:443876
Created June 18, 2010 16:39
Instalando Ruby + Rubygems + Rails + Git + Fluxo básico do GIT

Este how-to é para Ubuntu e deve funcionar em qualquer distribuição Linux baseada em Debian. Para outros sistemas operacionais, help-yourself!

Instalando Ruby

$ sudo apt-get install ruby irb ri rdoc ruby1.8-dev libzlib-ruby libyaml-ruby libreadline-ruby libncurses-ruby libcurses-ruby libruby libruby-extras libfcgi-ruby1.8 build-essential libopenssl-ruby libdbm-ruby libdbi-ruby libdbd-sqlite3-ruby libsqlite3-dev libsqlite3-ruby libxml-ruby libxml2-dev

Instalando o RubyGems

$ wget http://rubyforge.org/frs/download.php/60718/rubygems-1.3.5.tgz
$ tar -xvzf rubygems-1.3.5.tgz
$ cd rubygems-1.3.5
$ sudo ruby setup.rb

class User < ActiveRecord::Base
def name=(name)
self[:name] = name.downcase
end
def name
self[:name].capitalize
end
end
git push origin nova-funcionalidade
# /app/controllers/timesheets_controller.rb
class TimesheetsController < ApplicationController
has_scope :by_employee
has_scope :by_place
def index
@timesheets = apply_scopes(Timesheet).all
end
end
capify .
# [add] writing `./Capfile'
# [skip] `./Capfile' already exists
# [add] writing `./config/deploy.rb'
# [done] capified!
function base62_encode($num){
$chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$base = 62;
$result = '';
while($num >= $base) {
$r = $num%$base;
$result = $chars[$r].$result;
$num = $num/$base;
}
# app/models/customer.rb
class Customer < ActiveRecord::Base
has_one :user
delegate :login, :login=, :password, :password=, :to => :user
end
# app/models/user.rb
class User < ActiveRecord::Base
belongs_to :customer
end