Friday, 30 March 2012

String Interpolation in Ruby

To display the contents of a variable using puts, use the syntax
#{variable_to_display}

For example, to if x=5, to display "The value of X is 5", do: 
x=5
puts "The value of X is #{x}"  

To test this, save the above two lines to a file called string_interp.rb  and then do
 ruby string_interp.rb  


Saturday, 24 March 2012

Building Shoes in Linux

Shoes is a lightweight GUI toolkit for Ruby, website here. I couldn't get the download working, so built it from source using the instructions here.

A couple of notes - I built against Ruby 1.9.3 (this doesn't appear to have been updated in the Wiki instructions yet). Also, if you want to rebuild from source more than once, you have to do a
 rake clean  

before executing
 rake  

a second time.

Friday, 23 March 2012

Installing Rails 3.2 into Linux Mint (and other Linux distributions)


1) Install RVM:
  bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)   


2) Install or update RubyGems:
 gem update --system  


3) Install Rails:
 gem install rails  


That's it! Any problems, let me know below.

RVM Installation Problems in Linux Mint

I was having problems installing RVM into Linux Mint, it seems that somehow RVM is/was broken for Ubuntu distros. I was having issues with RVM saying that it couldn't fetch the ruby source, and curl errors as well. Purging and reinstalling RVM:

Remove RVM:
 sudo apt-get --purge remove ruby-rvm  
 sudo rm -rf /usr/share/ruby-rvm /etc/rvmrc /etc/profile.d/rvm.sh  

Close terminal window and open a new one then reinstall RVM with:
 bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)  

as per this StackOverflow answer solved my problems.

Thursday, 22 March 2012

Changing the Primary Monitor in Linux Mint, and Persisting the Change

In a previous post, I explained how to switch the primary monitor in Linux Mint, using a small script. This change however, does not persist when you reboot your machine. If you haven't already, take a look at that post, as you will need to run the script to get the names of your monitors, which are required for this example.


To make the primary monitor change permanent, go to Menu -> Other -> Startup Applications, and click Add. Give the startup program a name, like "Set Primary Monitor", then in the Command box, enter:


 xrandr --output monitorName --primary  


where monitorName is the name of the monitor you wish to use as the primary monitor, as listed in the script from this post. My command for example, looked like this:


 xrandr --output DVI-I-2 --primary  


Your Add Startup Program window should look something like this:




Click Add, and you're done! Let me know if this works for you below!