Some notes

and more perishable info...

Missing Keybindings in Mac OS X Lion

| Comments

I was used to have these keybindings in my Textmate installation in Snow Leopard and I was missing them in Lion.

Put this in /Users//Library/KeyBindings/DefaultKeyBinding.dict

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# cat /Users/fer/Library/KeyBindings/DefaultKeyBinding.dict 
{
/* home */
"\UF729" = "moveToBeginningOfLine:";
"$\UF729" = "moveToBeginningOfLineAndModifySelection:";

/* Cmd-Left */
"@\UF702" = "moveToBeginningOfLine:";
"$@\UF702" = "moveToBeginningOfLineAndModifySelection:";

/* Cmd-Right */
"@\UF703" = "moveToEndOfLine:";
"$@\UF703" = "moveToEndOfLineAndModifySelection:";

/* end */
"\UF72B" = "moveToEndOfLine:";
"$\UF72B" = "moveToEndOfLineAndModifySelection:";

/* page up/down */
"\UF72C" = "pageUp:";
"\UF72D" = "pageDown:";
}

Installing OctoPress

| Comments

Installing Octopress

Octopress is a framework designed by Brandon Mathis for Jekyll, the blog aware static site generator powering Github Pages. To start blogging with Jekyll, you have to write your own HTML templates, CSS, Javascripts and set up your configuration. But with Octopress All of that is already taken care of. Simply clone or fork Octopress, install dependencies and the theme, and you’re set.

1
2
3
4
git clone git://github.com/imathis/octopress.git ; cd octopress
gem install bundler rake --no-rdoc --no-ri
bundle install
bundle exec rake install

Here you have some clues to start blogging:

1
2
3
4
5
bundle exec rake new_post["title"]
bundle exec rake new_page["title"]
bundle exec rake generate
bundle exec rake watch
bundle exec rake preview

Install and Deploy Rails Apps Easily in Mac OS X Lion

| Comments

Why Rails

Rails is a web-application framework that includes everything needed to create database-backed web applications according to the Model-View-Control pattern.

This guide does not only involve installing ruby sucessfully in Lion. It also explains how to serve a whole project on the cloud easily.

Although all this might sound a little bit tough, this tutorial can be also followed as a step-by-step guide.

These are the instructions to install Ruby and Rails in your Lion system.

Steps

  • Install XCode (it includes git and the rest of tool for compiling Ruby sources)
  • Install HomeBrew
  • Install Ruby through RVM
  • Create Rails App
  • Deployment to Heroku

Install HomeBrew

Homebrew makes the installation of UNIX tools (or other occasional utilities that Apple didn’t include with OS X) easier than MacPorts or Fink.

Its installation is simple and avoids lots of manual and noisy installations of needed tools during development, e.g.: postgresql, imagemagick, etc):

1
2
mkdir -p /usr/local/Cellar # some homebrew fixes by doing this (https://github.com/mxcl/homebrew/wiki/installation)
/usr/bin/ruby -e "$(curl -fsSL https://raw.github.com/gist/323731)"

Install RVM

RVM is a tool that makes it super easy to install, manage and work with multiple versions of Ruby, interpreters and sets of Gems.

Uh. And what the heck is “Gems”? Gems is a package manager for the Ruby programming language that provides a standard format for distributing Ruby programs and libraries (yep!, as Python has eggs, as node.js uses npm, or as PHP comes with PEAR).

The gem command is used to build, upload, download, and install Gem packages.

With RVM you can have 1.8.7 and 1.9.2 live together without any issues. You can even swap back and forth from 1.8.7 to 1.9.2 as you see fit.

To install RVM in your system, run this:

1
bash < <(curl -s https://rvm.beginrescueend.com/install/rvm)

Now it’s time for echoing to .bash_profile our new environment and installing ruby:

1
2
3
4
5
echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function' >> ~/.bash_profile
source $HOME/.bash_profile
# Install ruby
rvm install 1.9.2
rvm use ruby-1.9.2

From now on, just refer RVM to the version of ruby you want to run:

1
2
3
4
5
rvm use ruby-1.9.2
gem install rails      # Your friend from now on 
gem install bundler    # Run bundle install inside your rails projects!
gem install heroku     # Deployment 
gem install taps       # Migrations on heroku

Probably, this would be also a good moment to install some extra tools through brew:

1
brew install ack wget curl redis memcached libmemcached colordiff imagemagick pg

This remarkable package manager is written in Ruby too, which means you cam make your own homebrew formula (here you have a hint on how to) in case you need a custom source for a specific package.

Create your Rails App

Let’s create an empty Rails project to play with. Just run in your terminal

1
2
3
4
rvm use ruby-1.9.2

cd $HOME/Desktop; rails new myproject
cd myproject; rails s

Now you should see something at http://localhost:3000!

Deploying to Heroku

If you don’t have an account yet, here you have some reasons to register then:

  • It’s free in case you don’t need many resources
  • It’s suitable for small projects and demos. Check its features.

Get to your app path and run:

1
2
3
4
bundle install
git init
git add .
git commit -m "new app"  # To commit changes: git add . ; git commit -a -m "Fixed" ; git push

Git uses SSH as its secure transport protocol. And Heroku uses Git, so you’ll need to generate a public SSH key and upload it to Heroku. Some details are described in this Heroku article.

Time to deploy our app:

1
2
3
heroku create ; git push master heroku 
# Check production logs with: heroku logs --tail 
heroku open