OCD-free ruby-1.9.2-p180 on Ubuntu 10.10

Posted on March 18, 2011

It’s been software lifespans since my last post, I think the mainstream ruby version back then was ruby-1.8.7, Ruby Version Manager (RVM) http://rvm.beginrescueend.com was unheard of, captcha solved spammer issues and I didn’t like ubuntu. A lot of versions have bumped, I just hope I’ve bumped my version of self forward. So here I am again trying to “write” after several skipped milestones.

Getting back on topic, I’ve used RVM since last year mainly for work. Once I’ve set it up it’s easy to forget the small steps I took to make ruby-1.9.2 OCD-free and then squirm when I install it on my personal netbook. If you’re like me, it’s quite annoying to see familiar errors :

$ irb
Readline was unable to be required, if you need completion or history install readline then reinstall the ruby.
You may follow 'rvm notes' for dependencies and/or read the docs page http://rvm.beginrescueend.com/packages/readline/ . Be sure you 'rvm remove X ; rvm install X' to re-compile your ruby with readline support after obtaining the readline libraries.

Afer reading the rvm notes and experiencing dejavu, I realized a step or two has been added before achieving an OCD-free ruby-1.9.2-p180. Now I have to remove it ( rvm remove ruby-1.9.2-p180 ), wait, install the missing package, wait, then install ruby-1.9.2-p180 again, and then the final wait.

If only I’ve noted something like this before: https://gist.github.com/876589

$ bash < <( curl http://rvm.beginrescueend.com/releases/rvm-install-head )
$ echo “[[ -s ‘$HOME/.rvm/scripts/rvm’ ]] && . ‘$HOME/.rvm/scripts/rvm’” >> ~/.bashrc
$ source ~/.bashrc
$ sudo su
#apt-get install build-essential bison openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev
$rvm install ruby-1.9.2-p180

As of writing, I’m just waiting for compilation to complete. Yes, my netbook is slow (1.33GHz).

tags: Linux, Ruby category: tips Comments (0) Create Comment

Install CDR King Zen PC Camera on Linux

Posted on June 20, 2009

I bought a CDR King Zen PC Camera / Webcam for my cousin on his birthday. He’s primarily a m$ windows user so there was no problem getting it to work on windoze. But due to his trouble with viruses, frequent crashes, slow response and having to reformat so frequently, I convinced him to install PCLinuxOS 2009.1 on his laptop, well I did the installation but I got his consent =). If only I had forseen that he will be a linux convert, then I would have bought him the same linux friendly webcam I use, an A4Tech PK-35N.

Here are the steps I took to get working the Cdr King Zen PC Camera (ACM-662) or
Microdia PC Camera (SN9C201 OV7660) as PCLinuxOS detects it.

$ lsusb
Bus 001 Device 003: ID 0c45:627b Microdia PC Camera (SN9C201 OV7660)
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 002 Device 002: ID 15d9:0a4c
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

After confirming that it’s a Microdia PC Camera, get the proprietary drivers. We’ll need git-core and ctags installed first to perform this step.

$ su
$ apt-get install git-core ctags
$ exit
$ git clone http://repo.or.cz/r/microdia.git
$ cd microdia
$ make
$ su
$ insmod ./sn9c20x.ko

Finally, open up kopete or any webcam application you have installed to see it working.

tags: Linux category: linux distro Comments (604) Create Comment

Wirble on Windoze without Rails

Posted on February 09, 2009

Although Linux is a clear choice among all Operating Systems I’ve tried, unfortunately I have to use windoze xp when running Ruby Watir. One good feature I miss from Linux is Wirble on the console. I’ve been thinking how cool it is to have Wirble run on the command line when I explore Watir objects.

I never thought it was possible on windoze until i found this post by Alexey:


I modified some steps to make it work for my non-rails irb console:

1. First, install wirble and the win32console gem

gem install wirble win32console

2. I copied Alexey’s w.rb and saved it to c:\some\location

#— for wirble
require ‘rubygems’ rescue nil
require ‘win32/console/ansi’
ENV[‘IRB_HISTORY_FILE’] = “c:\.irb_history”
#load rubygems and wirble
require ‘wirble’
#load wirble

3. then I created a wirble.bat batch file for convenience to load the w.rb

echo off
irb -r c:\some\location\w.rb

4. Finally, open wirble.bat and enjoy the pretty colors

I also have a shortcut of wirble.bat on my quick launch toolbar and added c:\some\location to my system variable path so I can just type “wirble” in the Run window.

tags: Ruby category: tips Comments (28) Create Comment

PCLinuxOS distro hopper stopper, 2009 Beta 1 is out

Posted on October 19, 2008

I stopped distro hopping over 2 years ago since I found PCLinuxOS, I’ve hopped from Ubuntu and it’s variants – Kubuntu and Xubuntu, I’ve also tried openSUSE, Mint, Mandriva, Dreamlinux, Debian, Sabayon and many other flavors I downloaded, burned and installed.

The first thing that drew me to the linux community was pretty embarrassing – the 3D desktop effects! My focus back then was eye-candy and the bragging rights to say “I use Linux, can your PC do this?”. PCLinuxOS had the best 3D desktop effects that ran out of the box. After a few months, my focus changed to stability, power and ease of use. Still hopping around, I kept coming back to PCLinuxOS. Hardware detection was superb, I was doing everything in PCLinuxOS – office documents, browsing, image editing, programming, etc., even Ruby was installed by default! Everything just works.

It’s been quite a while since PCLinuxOS has made a major release because it’s a rolling distro, you get the latest version just by upgrading everything from synaptic. Initially I was excited to try out and even install the 2009 beta 1 release. I downloaded the iso from http://distrowatch.com and tried it using VirtualBox.

After a few minutes of playing around and trying to find bugs I realized there was no need to jump into this release, after all it’s a beta. I figured I wasn’t missing much features from my current PCLinuxOS 2007 installation. Everything seemed so familiar, the only noticeable change was the Mandriva inspired graphics. I’m looking forward to the next beta release, try to find a bug and hopefully contribute to a more solid PCLinuxOS 2009 final release.

tags: PCLinuxOS category: linux distro Comments (10) Create Comment

Daemonize Your Gems in PCLinuxOS

Posted on October 04, 2008

I found Mikel Lindsaar’s tip on how to daemonize gems, Tip #2 – Daemonize Your Gems! http://tinyurl.com/daqbac

His instructions are targetted at Mac users. This is how I accomplished the same thing in my PCLinuxOS installation. Even though PCLinuxOS has a /etc/rc.local directory which Mikel had to create, I opted only to modify files in my home “~” folder. Since PCLinuxOS uses KDE, this means that anything inside the directory ~/.kde/Autostart/ will be run, it can be a soft link or a shell script. I already have a simple script.sh to run conky on start-up, so all I had to do is add the “gem server” command:

conky -a top_right
gem server --daemon

If you don’t have an existing script file, just created a new one in ~/.kde/Autostart/ and name it any_thing_you_like.sh and remember to place #!/bin/bash on the very first line of the code:

gem server --daemon

The next time your PCLinuxOS starts, gem server is automatically started! Just browse to http://localhost:8808/.

Hope this helps someone.

tags: PCLinuxOS category: tips Comments (15) Create Comment

Ruby Tk requires Tcl

Posted on September 24, 2008

I wanted to play with the tk library as an introduction to ruby gui programming when I ran into this error:

>> require ‘tk’
RuntimeError: Can’t find a usable init.tcl in the following directories:
/usr/lib/tcl8.4 /usr/lib/tcl8.4 /lib/tcl8.4 /usr/library /library /tcl8.4.13/library /usr/lib/tcl8.4
This probably means that Tcl wasn’t installed properly.
from /usr/lib/ruby/1.8/tk.rb:1102:in `initialize’
from /usr/lib/ruby/1.8/tk.rb:1102:in `new’
from /usr/lib/ruby/1.8/tk.rb:1102
from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require’
from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require’
from (irb):1

In PCLinuxOS 2007 Tcl isn’t installed by default. This is very surprising since I’d expect any *nix based OS to have at least an old version of Tcl installed. This, however is easily solved by installing Tcl, I used synaptic. After the download is finished, just like that, you can now use use ruby tk for gui programming.

>> require ‘tk’
/usr/lib/ruby/1.8/tk.rb:29: warning: already initialized constant WidgetClassNames
/usr/lib/ruby/1.8/tk.rb:30: warning: already initialized constant TkExtlibAutoloadModule
/usr/lib/ruby/1.8/tk.rb:40: warning: already initialized constant Tk_IDs
/usr/lib/ruby/1.8/tk.rb:43: warning: already initialized constant Tk_CMDTBL
/usr/lib/ruby/1.8/tk.rb:48: warning: already initialized constant Tk_WINDOWS
=> true

tags: Ruby category: programming Comments (130) Create Comment

Fixtures Tips

Posted on September 15, 2008

1. How to add multiline text entries

Here’s the first working solution that came to mind, this would be very hard to maintain:

body: "
Hi this is the about section \n
My name is andro \n
this shoule be multiline \n

Until I found http://railsforum.com/viewtopic.php?id=3722, this is probably the best solution I’ve found so far – just use a pipe!

body: |
Hi this is the about section
My name is andro
this shoule be multiline

2. How to change created_at to a previous date

Since Ruby on Rails 2.x created_at and updated_at are no longer needed. It takes the current timestamp upon loading the fixtures with the command

rake db:fixtures:load

This poses a problem since I wanted to have created_at dates that are past dates.

So i tried the old way of doing it:

created_at: <%= Time.now – 5.months %>

which doesn’t work. The new way of doing it is:

created_at: <%= 5.months.ago.to_s(:db) %>

tags: RubyonRails category: tips Comments (14) Create Comment

Failed to build gem native extention in PCLinuxOS

Posted on August 29, 2008

I can’t install gems after I did a fresh install of PCLinuxOS:

[root@localhost andoy]# gem install RedCloth
Building native extensions.  This could take a while...
ERROR:  Error installing RedCloth:
        ERROR: Failed to build gem native extension.
/usr/bin/ruby extconf.rb install RedCloth
can't find header files for ruby.

To solve this, just install the development package for ruby, while I’m at it, I’ll also install the documentation.

In synaptic:

  1. search for ruby-devel and ruby-doc
  2. right-click ‘Mark for installtion’
  3. Apply

Or from konsole as root:

apt-get install ruby-devel ruby-doc

I just waited until the download finished and voila!

[root@localhost andoy]# gem install RedCloth
Building native extensions.  This could take a while...
Successfully installed RedCloth-4.0.3
1 gem installed
Installing ri documentation for RedCloth-4.0.3...
Installing RDoc documentation for RedCloth-4.0.3...

Hope this helps someone.

tags: PCLinuxOS category: tips Comments (341) Create Comment

How to hide all backup files, my ruby noob version

Posted on August 15, 2008

I love using Kate (KDE Advance text editor), I use it to type my emails when I have no network access, it’s where I open and study all sorts of source code (ruby, python, php, java). By default, saving or editing in Kate creates a visible backup file (with the suffix “~”). Which I think is totally annoying! I didn’t want to see these backup files.

If you’re a noob like me, you probably haven’t changed the default setting for Kate to hide backups (it must have a prefix “.” to be hidden). Thanks to devnet in IRC freenode #pclinuxos-support, I found out it’s just a minor configuration:

Settings > Configure Kate > Open/Save > Backup on Save > Prefix should be “.” (without the quotes).

Now every time I save, backup files should now be hidden. What about the old and visible backup files? Well.. there are a lot of shell scripts out there to do mass renaming. But I wanted to try my ruby skill on this. Here is my code:

require 'find'
  if ARGV.size < 1
      puts "USAGE: ruby hide_backup_files.rb <DIR>\n<DIR>: The directory tree to traverse. Ex. /home/user"
dir = ARGV0 unless FileTest.directory?(dir) puts ‘Please use a valid directory.’ exit end Find.find(dir) do |path| name = File.basename(path) next if name0 == ?. # skip it if it’s already hidden if FileTest.file?(path)
  1. if it’s a backup file (with suffix ~ ), rename it as a hidden file
    if name =~ /~\z/
    dir = File.dirname(path)
    puts “done hidding => #{path}” if File.rename(“#{dir}/#{name}”, “#{dir}/.#{name}”)

tags: Linux category: programming Comments (89) Create Comment

Necessary access to logs and documentation

Posted on July 16, 2008

tail -f log/development.log

The tail command is very helpful. It is very important for a newbie like me to view and understand logs.

If I want to save the logs for later viewing starting from the time I tailed, I redirect the output to a text file:

tail -f log/development.log > ~/Desktop/some_file_name.txt

Tail is not available in windoze but one can install software to do just this. In my personal experience, the logs tells a lot about what your doing wrong, instead of relying on the online tutorials or screencasts that are usually outdated. It is through looking at the logs that I was able to find out why the tutorial wasn’t working the way I wanted it. You see I usually have several resources and try to mix them up together. Even though the tutorial has a warning that, this will not work in rails 2.x, still my curiosity wanted to make it work.

Sure I could googlize, but sometimes I see it as an advantage to be offline than being online, as this forces me to understand the inner workings of rails and really get on reading the documentation. There’s this feature of NetBeans IDE I appreciate, it makes documentation accessible. I actually found this out by accident, I just have to press Ctrl Shift then click on the method i would like to find out how to use, and a window will open to show a nice looking docu.

tags: RubyonRails category: tips Comments (20) Create Comment

Roughly Rolling with Ruby on Rails - the newbie perspective

Posted on July 15, 2008

I have been following the Ruby on Rails community for a while but haven’t really committed time to invest hard hours on learning Ruby on Rails. I was in the hype! Yeah… but not really coding until now.

Ofcourse meaning to jump into learning Ruby on Rails isn’t enough. Being recently unemployed became a blessing in disguise – it gave me the opportunity to get started on it. A goal has been set. This would be my first time to invest in learning rails. To achieve this, I set out to build this blog. There are a lot of resources out there that allows a newbie like me to get started, here are my personal favorites:


I believe one must be comfortable with coding basic Ruby to start on Rails. It’s a good thing I’m not entirely new to Ruby. I have been using Ruby in my previous employment ranging with the following Ruby gems – WATIR, Selenium, Capistrano and SOAP4r. But there are still so much to learn and love in Ruby.

The first question that popped in my head – should I jump right in rails 1.x or 2.x? Well, I went ahead with rails 2.1 although learning 1.x would be advantageous when maintaining old code, I figured every RoR developer’s goal would be to migrate from 1.x to 2.x, simply because it is better.

The second question. What IDE should I use? Coming from an industry where Java is the norm, I thought an IDE is a neccessity. Aptana/Radrails is great, so is Netbeans. But for my journey, I’m breaking away from depending on the IDE and stick with my favorite text editor – Kate (KDE Advance Text Editor). For Gnome fans, I tried Gedit and it proves to be a great alternative. I just prefer Kate over Gedit even thought Gedit can be installed in KDE.

tags: RubyonRails category: programming Comments (8) Create Comment