11.09.2013

How to Install RVM, Ruby and Rails

For my reference:
http://yakiloo.com/using-rvm/
http://ryanbigg.com/2010/12/ubuntu-ruby-rvm-rails-and-you/
http://rvm.io/rvm/best-practices

For this installation I followed what’s called single user installation, which is the recommended way of installation, this is an isolated install within a user's $HOME, not for root.

Install RVM

1. Install prerequisites
$ sudo yum install sqlite-devel nodejs openssl
2. Set rvm_path
$ echo 'rvm_path="$HOME/.rvm"' >> ~/.rvmrc
3. Install RVM as a single user ( background info: https://rvm.io/rvm/install)
$  \curl -L https://get.rvm.io | bash -s stable
4. At this point, RVM should have been installed, check if rvm was installed correctly by loading it then checking it’s type:
$ source ~/.rvm/scripts/rvm
$ type rvm | head -n 1
rvm is a function
5. Make sure that the latest version is installed
$ rvm get stable
6. Run the rvm requirements to get all the dependencies for RVM, this might prompt for your password when it needed to install missing packages:
$ rvm requirements
Checking requirements for fedora.
Installing requirements for fedora.
Updating system
Installing required packages: patch, gcc-c++, patch, readline-devel, zlib-devel, libyaml-devel, libffi-devel, openssl-devel, autoconf, automake, libtool, bisondelacs password required for '/usr/bin/env PATH=/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/usr/local/bin/Aptana_Studio_3:/auto/home3/delacs/bin:/auto/home3/delacs/.rvm/bin:/sbin yum install -y patch gcc-c++ patch readline-devel zlib-devel libyaml-devel libffi-devel openssl-devel autoconf automake libtool bison': 
....................................................................................................................................................................................................................
Requirements installation successful.

Install Ruby

7. Now let’s install Ruby:
$ rvm install 2.0.0
8. The above command should install RubyGems with it, if in case there is an issue such that RubyGems was not able to install due to some checksum error, go to one version below the latest, e.g.,
$ rvm rubygems latest
9. Let’s tell RVM to use Ruby 2.0.0 as our default
$ rvm use ruby-2.0.0-p247 --default
Using /home/samdc/.rvm/gems/ruby-2.0.0-p247
10. Let’s check the version of Ruby in our environment
$ ruby -v
ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-linux]

Install Rails

11. First, let’s set our gems environment, due to some contraints (I think it’s the corporate firewall preventing installation of certs) Add these lines to your ~/.gemrc:
:ssl_verify_mode: 0
:sources:
- http://rubygems.org/
- http://gems.github.com
gem: --no-rdoc --no-ri
The last line is to not install rdoc and ri

12. Let’s install Rails. We wan’t to make use of GemSets so we can easily manage versioning in our installs. Create a gemset:
$ rvm gemset create RailsDev
gemset created RailsDev => /auto/home3/delacs/.rvm/gems/ruby-2.0.0-p247@RailsDev
13. Let’s use that GemSet:
$ rvm gemset use RailsDev
Using ruby-2.0.0-p247 with gemset RailsDev
Let’s check if we are using that gemset
$ rvm gemset name
RailsDev
14. Now let’s install all gems that we need
$ gem install rails --version 4.0.1
15. Lets verify the installation
$ rails -v
Rails 4.0.1
16. To make use of this RVM environment, we can specify 2 files in the project’s root folder:
$ cat .ruby-gemset
RailsDev

$ cat .ruby-version
ruby-2.0.0-p247
To learn more about RVM and its environment, refer to these posts: http://yakiloo.com/using-rvm/ http://stackoverflow.com/questions/15708916/use-rvmrc-or-ruby-version-file-to-set-a-project-gemset-with-rvm

17. To make use of automatic install of rubies, you can specify a flag in ~/.rvmrc
rvm_install_on_use_flag=1
18. You also make bootstrapping a project happen via cd into the project directory, by adding this to ~/.rvmrc
export rvm_project_rvmrc=1
19. To access webrick from another system, firewall needs to be opened up for port 3000 as follows:
$ sudo firewall-cmd --permanent --zone=public --add-port=3000/tcp
$ sudo systemctl restart firewalld.service

10.15.2013

Open up Firewall of Fedora Core 19

Here's the whole write up on FirewallD.
How you would open up http and https, or specific ports for your box:
$ sudo firewall-cmd --permanent --zone=public --add-service=http
$ sudo firewall-cmd --permanent --zone=public --add-service=https
Restart the firewall:
$ sudo systemctl restart firewalld.service
Or on specific ports:
$ sudo firewall-cmd --permanent --zone=public --add-port=9393/tcp
Restart the firewall:
$ sudo systemctl restart firewalld.service

10.09.2013

How to Install RVM, Ruby and Sinatra

For my reference:
http://yakiloo.com/using-rvm/
http://ryanbigg.com/2010/12/ubuntu-ruby-rvm-rails-and-you/
http://rvm.io/rvm/best-practices

For this installation I followed what’s called single user installation, which is the recommended way of installation, this is an isolated install within a user's $HOME, not for root.

Install RVM

1. Set rvm_path
$ echo 'rvm_path="$HOME/.rvm"' >> ~/.rvmrc
2. Install RVM as a single user ( background info: https://rvm.io/rvm/install)
$  \curl -L https://get.rvm.io | bash -s stable
3. At this point, RVM should have been installed, check if rvm was installed correctly by loading it then checking it’s type:
$ source ~/.rvm/scripts/rvm
$ type rvm | head -n 1
rvm is a function
4. Make sure that the latest version is installed
$ rvm get stable
5. Run the rvm requirements to get all the dependencies for RVM, this might prompt for your password when it needed to install missing packages:
$ rvm requirements
Checking requirements for fedora.
Installing requirements for fedora.
Updating system
Installing required packages: patch, gcc-c++, patch, readline-devel, zlib-devel, libyaml-devel, libffi-devel, openssl-devel, autoconf, automake, libtool, bisondelacs password required for '/usr/bin/env PATH=/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/usr/local/bin/Aptana_Studio_3:/auto/home3/delacs/bin:/auto/home3/delacs/.rvm/bin:/sbin yum install -y patch gcc-c++ patch readline-devel zlib-devel libyaml-devel libffi-devel openssl-devel autoconf automake libtool bison': 
....................................................................................................................................................................................................................
Requirements installation successful.

Install Ruby

6. Now let’s install Ruby:
$ rvm install 1.9.3
7. The above command should install RubyGems with it, if in case there is an issue such that RubyGems was not able to install due to some checksum error, go to one version below the latest, e.g.,
$ rvm rubygems 2.1.8
8. Let’s tell RVM to use Ruby 1.9.3 as our default
$ rvm use ruby-1.9.3-p448 --default
Using /auto/home3/delacs/.rvm/gems/ruby-1.9.3-p448
9. Let’s check the version of Ruby in our environment
$ ruby -v
ruby 1.9.3p448 (2013-06-27 revision 41675) [x86_64-linux]

Install Sinatra

10. First, let’s first set our gem environment, due to some contraints (I think it’s our firewall preventing installation of certs) Add these lines to your ~/.gemrc:
:sources:
- http://rubygems.org/
- http://gems.github.com
gem: --no-rdoc --no-ri
The last line is to not install rdoc and ri

11. Let’s install Sinatra. We wan’t to make use of GemSets so we can easily manage versioning in our installs. Create a gemset:
$ rvm gemset create SinatraDev
gemset created SinatraDev => /auto/home3/delacs/.rvm/gems/ruby-1.9.3-p448@SinatraDev
12. Let’s use that GemSet:
$ rvm gemset use SinatraDev
Using ruby-1.9.3-p448 with gemset SinatraDev
Let’s check if we are using that gemset
$ rvm gemset name
SinatraDev
13. Now let’s install all gems that we need
$ gem install sinatra -v 1.4.3
$ gem install shotgun -v 0.9
14. To make use of this RVM environment, we can specify 2 files in the project’s root folder:
$ cat .ruby-gemset
SinatraDev
 
$ cat .ruby-version
ruby-1.9.3-p448
To learn more about RVM and its environment, refer to these posts: http://yakiloo.com/using-rvm/ http://stackoverflow.com/questions/15708916/use-rvmrc-or-ruby-version-file-to-set-a-project-gemset-with-rvm 15. To make use of automatic install of rubies, you can specify a flag in ~/.rvmrc
rvm_install_on_use_flag=1
16. You also make bootstrapping a project happen via cd into the project directory, by adding this to ~/.rvmrc
export rvm_project_rvmrc=1
17. To access webrick from another system, firewall needs to be opened up for port 9393 as follows:
$ sudo firewall-cmd --permanent --zone=public --add-port=9393/tcp
$ sudo systemctl restart firewalld.service
18. Start WEBrick using shotgun:
$ shotgun main.rb --host mymachine.domain.com

How to add Launcher in Gnome for Fedora 19

Create a .desktop file:
$ sudo vi /usr/share/applications/aptana-studio-3.desktop
Add this content:
[Desktop Entry]
Name=Aptana Studio 3
Exec=/usr/local/bin/Aptana_Studio_3/aptana
Icon=/usr/local/bin/Aptana_Studio_3/icon.xpm
Type=Application
Categories=Development

10.03.2013

VNC Server Setup on Fedora 19

I followed this post to setup my VNC Server. Specific to my setup I had to update my /etc/systemd/system/vncserver@:1.service so that it will wait for autofs for my home directory:
After=syslog.target network.target autofs.service
Then I had to open up the ports for VNC as follows:
$ sudo firewall-cmd --permanent --zone=public --add-service=vnc-server

9.24.2013

Bash Keyboard Shortcuts

Ctrl + A        Go to the beginning of the line you are currently typing on
Ctrl + E        Go to the end of the line you are currently typing on
Ctrl + L        Clears the Screen, similar to the clear command
Ctrl + U        Clears the line before the cursor position. If you are at the end of the line, clears the entire line.
Ctrl + H        Same as backspace
Ctrl + R        Let’s you search through previously used commands
Ctrl + C        Kill whatever you are running
Ctrl + D        Exit the current shell
Ctrl + Z        Puts whatever you are running into a suspended background process. fg restores it.
Ctrl + W        Delete the word before the cursor
Ctrl + K        Clear the line after the cursor
Ctrl + T        Swap the last two characters before the cursor
Esc + T         Swap the last two words before the cursor
Alt + F         Move cursor forward one word on the current line
Alt + B         Move cursor backward one word on the current line
Tab             Auto-complete files and folder names

9.19.2013

Vi Text Editor My Frequently Used Commands

h              move cursor one character to left
j              move cursor one line down
k              move cursor one line up
l              move cursor one character to right
w              move cursor one word to right
b              move cursor one word to left
0              move cursor to beginning of line
$              move cursor to end of line
nG             move cursor to line n
1G             move cursor to 1st line
G              move cursor to last line
control-f      scroll forward one screen
control-b      scroll backward one screen

gx             jump to method definition

zi             switch folding on or off
za             toggle current fold open/closed
zc             close current fold
zR             open all folds
zM             close all folds
zv             expand folds to reveal cursor

i              insert to left of current cursor position (end with ESC)
a              append to right of current cursor position (end with ESC)
dw             delete current word (end with ESC)
cw             change current word (end with ESC)
r              change current character
~              change case (upper-, lower-) of current character

dd             delete current line
D              delete portion of current line to right of the cursor
x              delete current character
dgg            delete current line to the top of the file
jdG            delete all lines below current line
ma             mark currrent position
d`a            delete everything from the marked position to here
`a             go back to the marked position
p              dump out at current place your last deletion (``paste'')

u              undo the last command 
.              repeat the last command 

J              combine (``join'') next line with this one

:w             write file to disk, stay in vi
:q!            quit VI, do not write file to disk,
ZZ             write file to disk, quit vi

:r filename    read in a copy of the specified file to the current
               buffer

/string        search forward for string (end with Enter)
?string        search backward for string (end with Enter)
n              repeat the last search (``next search'')
N              repeat the last search backward
/\cstring      case insensitive prepend with \c

:s/s1/s2       replace (``substitute'') (the first) s1 in this line by s2
:lr/s/s1/s2/g  replace all instances of s1 in the line range lr by s2
               (lr is of form 'a,b', where a and b are either explicit
               line numbers, or . (current line) or $ (last line)
:map k s       map the key k to a string of vi commands s (see below)
:abb s1 s2     expand the string s1 in append/insert mode to a string 
               s2 (see below)
%              go to the "mate," if one exists, of this parenthesis
               or brace or bracket (very useful for programmers!)

:%s/foo/bar/g  replace every 'foo' with a 'bar'
:!command      execute a command from vi
:%!perltidy    format perl code using perltidy from within vi
:%!perltidy -l=0    ignore line length 
:noh           remove search highlighting
:sp            to split window horizontally
:vsp           to split window vertically
<ctrl-w>h|j|k|l to navigate between split windows
<ctrl-w>q      to quit split window 

Comment/Uncomment:
Press Ctrl+V and go down until the last commented line and press x, that will delete all the # characters vertically.

For commenting a block of text is almost the same: First, go to the first line you want to comment, press Ctrl+V, and select until the last line. Second, press Shift+I, then #, then Esc.

Indent several lines at once:
Press Ctrl+V and go down until the last line to be indented, press Shift+>

Cut/Copy and Paste:
Position the cursor where you want to begin cutting.
Press v (or upper case V if you want to cut whole lines).
Move the cursor to the end of what you want to cut.
Press d to cut or y to copy.
Move to where you would like to paste.
Press P to paste before the cursor, or p to paste after.
Copy and paste can be performed with the same steps, only pressing y instead of d in step 4.
The name of the mark used is related to the operation (d:delete or y:yank).