Sometimes relationships need to be flexible, and that's where we look to polymorphism. Say we want to implement:
- A
Person
- A
Company
- A
PhoneNumber
that can connect to aPerson
or aCompany
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc | |
. ~/.bashrc | |
mkdir ~/local | |
mkdir ~/node-latest-install | |
cd ~/node-latest-install | |
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1 | |
./configure --prefix=~/local | |
make install # ok, fine, this step probably takes more than 30 seconds... | |
curl https://www.npmjs.org/install.sh | sh |
Jbuilder.encode do |json| | |
json.content format_content(@message.content) | |
json.(@message, :created_at, :updated_at) | |
json.author do |json| | |
json.name @message.creator.name.familiar | |
json.email_address @message.creator.email_address_with_name | |
json.url url_for(@message.creator, format: :json) | |
end |
gem 'sinatra' | |
group :development,:test do | |
gem 'rspec' | |
gem 'rack-test' | |
end |
#!/usr/bin/env ruby | |
require 'benchmark' | |
REGEXPS = [ | |
/^no such file to load -- (.+)$/i, | |
/^Missing \w+ (?:file\s*)?([^\s]+.rb)$/i, | |
/^Missing API definition file in (.+)$/i, | |
/^cannot load such file -- (.+)$/i, | |
] |
#!/usr/bin/env bash | |
uninstall() { | |
list=`gem list --no-versions` | |
for gem in $list; do | |
gem uninstall $gem -aIx | |
done | |
gem list | |
gem install bundler | |
} |
You wanna serve up static files, but are bored by the usual trick of:
python -m SimpleHTTPServer
This is pretty simple but why type this every time? Let's use Pow for some zero-effort web serving. If you have Pow already set up, then just drop the provided config.ru
file into the root of your static files. Then link your directory into ~/.pow
so Pow can see it and that's it!
Let's say you have a directory with mockups you wanna show people, they are in ~/Dropbox/Mockups/ then you might do this:
# autoload concerns | |
module YourApp | |
class Application < Rails::Application | |
config.autoload_paths += %W( | |
#{config.root}/app/controllers/concerns | |
#{config.root}/app/models/concerns | |
) | |
end | |
end |
Steps to set up a Rails development environment on OS X:
ruby -e "$(curl -fsSkL raw.github.com/mxcl/homebrew/go)"
curl -L https://get.rvm.io | bash -s stable
source $HOME/.rvm/scripts/rvm
rvm install --disable-binary 1.9.3
rvm use --default 1.9.3
# config/application.rb | |
module YourApp | |
class Application < Rails::Application | |
config.autoload_paths += %W(#{config.root}/lib/devise) | |
# rest of the file | |
end | |
end |