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" }
]

Monday, September 17, 2012

Install pgAdmin for PostgreSQL 9.2 on Ubuntu 12.04


The Ubuntu 12.04 package manager will install pgadmin3 version 1.14 which does not support PostgreSQL 9.2.

Warning:
The server you are connecting to is not a version that is supported by this release of pgAdmin III.
pgAdmin III may not function as expected.
Supported server versions are 8.2 to 9.1.

Remove the current pgAdmin version


sudo apt-get remove pgadmin3


Install pgAdmin version 1.16 using a ppa


sudo apt-add-repository ppa:voronov84/andreyv
sudo apt-get update
sudo apt-get install pgadmin3


Update: If you are having trouble with the method above (see comments below) try the .deb install.

pgAdmin 1.16 (amd64)
pgAdmin 1.16 (i386)


Saturday, September 15, 2012

Replace PostgreSQL 9.1 with 9.2 in Ubuntu 12.04

Recently released PostgreSQL 9.2 comes with a heap of new features and improvements over 9.1.

These are the steps I took to remove 9.1 and install PostgreSQL 9.2 in Ubuntu 12.04.

Warning: This procedure is suitable for test and development environments only as it will wipe out all 9.1 databases


1. List currently installed postgres packages


sudo dpkg -l | grep postgres


2. Remove postgresql-9.1

*these packages were on my system

sudo apt-get --purge remove postgresql postgresql-9.1 postgresql-client-9.1 postgresql-client-common postgresql-common postgresql-doc postgresql-doc-9.1


3. Install postgresql-9.2 with official ppa


sudo add-apt-repository ppa:pitti/postgresql
sudo apt-get update
sudo apt-get install postgresql-9.2

If you cannot add the repository
sudo: add-apt-repository: command not found

Install this package

sudo apt-get install python-software-properties


4. Check postgresql is set to the default port 5432


sudo netstat -lp | grep postgresql


5. Reset to default port if necessary


sudo gedit /etc/postgresql/9.2/main/postgresql.conf

port = 5432 *change the port value in the conf file

sudo /etc/init.d/postgresql reload


6. Setup your project database / user and database.yml


PostgreSQL Setup for Rails Development (skip to step 2)