Sunday, December 1, 2013

How to install Ruby with Rbenv and tools in Ubuntu 13.10 / Mint 16

Install some basics
$ sudo apt-get install zlib1g zlib1g-dev build-essential sqlite3 libsqlite3-dev openssl libssl-dev curl git libmagick++-dev

Use git to install rbenv and the ruby-build plugin
$ git clone https://github.com/sstephenson/rbenv.git ~/.rbenv
$ git clone git://github.com/sstephenson/ruby-build.git .rbenv/plugins/ruby-build

Mint
$ echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
$ echo 'eval "$(rbenv init -)"' >> ~/.bash_profile

Ubuntu
$ echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
$ echo 'eval "$(rbenv init -)"' >> ~/.bashrc

Close and reopen terminal
$ type rbenv
Should return rbenv is a function at the prompt

List Ruby versions known to rbenv
$ rbenv install -l

Install the version you require and set it as global
rbenv install 2.0.0-p353
rbenv rehash
rbenv global 2.0.0-p353

Add ssh key
ssh-keygen
ssh-agent /bin/bash
ssh-add ~/.ssh/id_rsa
cat ~/.ssh/id_rsa.pub
Copy & paste result as a new ssh key to your Github / Bitbucket account

Add git global config
git config --global push.default simple
git config --global user.name "name surname"
git config --global user.email email@example.com
git config --global color.ui auto

gem install bundler
Restart terminal to use bundle command within a project folder

Pre-load environment for fast rails commands
gem install zeus
Restart terminal to use zeus commands
  • zeus start
  • zeus test xxx
  • zeus s
  • zeus rake



Sunday, February 10, 2013

Sublime Text 3 Quick Install and Setup for Rails on Linux

Sublime Text 3 Beta is now open to non-registered users (27 June 2013).
Sublime Package Control for ST3 is currently in Alpha.

Install ST3


Download latest deb build from http://www.sublimetext.com/3
Install (double click) then copy / paste your licence
If you have a conflict with ST2 then remove it (see below) or download the tarball

sudo apt-get remove --purge sublime-text-2
sudo apt-get autoremove

Install Package Control

http://wbond.net/sublime_packages/package_control/installation#ST3

cd /home/username/.config/sublime-text-3/Packages
git clone https://github.com/wbond/sublime_package_control.git "Package Control"
cd "Package Control"
git checkout python3


Add some Basic User Settings (adjust according to your preferences)
Preferences > Settings - User
{
"color_scheme": "Packages/RailsCasts Colour Scheme/RailsCastsColorScheme.tmTheme",
"detect_indentation": false,
"font_face": "Consolas",
"font_size": 13,
"ignored_packages":
[
"Vintage"
],
"scroll_past_end": false,
"tab_size": 2,
"translate_tabs_to_spaces": true,
"trim_trailing_white_space_on_save": true,
"word_wrap": true
}

Use Package Control to install a Theme
Popular packages are: RailsCasts Colour Scheme, Theme - Soda, Solarized Color Scheme

Update your Preferences > Settings - User to swap
Use Package Control to install syntax highlighting
Haml, Sass, Less, Coffeescript select them as defaults for the corresponding filetypes (click on the current filetype at the bottom right of ST3 window).

ERB Insert and Toggle Commands
https://github.com/eddorre/SublimeERB

Add to User Keybinding File
[
  { "keys": ["ctrl+shift+."], "command": "erb" }
]

Run Tests in the console
Install RubyTest https://github.com/maltize/sublime-text-2-ruby-tests

You must run Sublime Text 3 from the command line (subl)

control shift t Run all tests in the file
control shift e Run last test

There are issues with Colour output and esc characters - you may prefer to use the linux terminal

Create a plugin to Open file in browser
Tools > New plugin...

Copy code below / paste / save as OpenBrowser.py
# OpenBrowser.py
import sublime, sublime_plugin
import webbrowser

class OpenBrowserCommand(sublime_plugin.TextCommand):
   def run(self,edit):
      url = self.view.file_name()
      webbrowser.open_new(url)

Add to User Keybindings to Open file in new browserPreferences > Key Bindings - User

Copy code below / paste / save
[
  { "keys": ["ctrl+shift+b"], "command": "open_browser" }
]