Wednesday, June 25, 2008

Advanced Configuration in Firefox 3

Everyone can customize a lot of options in Firefox through the "Tools>Options" or "Edit>Preferences" menus.

Well the other way is to make customizations through the advanced configuration interface by typing "about:config" in the address bar. You will see the interesting warning message. well, just be careful while you are about changing values.


Here you can make a lot of configurations like:
  • browser.download.manager.closeWhenDone set it to true to automatically close the download window when the download is complete
  • browser.download.dir sets your download directory
  • browser.urlbar.maxRichResults sets the number of suggested URLs that appear when you start typing in the address bar
  • zoom.maxPercent and zoom.minPercent to alter the maximum and minimum limits of zooming

You can find some configurations explained at ghacks, eriwen's blog and many other locations online. most configurations are self explanatory though.

Using the advanced configuration can be preferable to some people, specially software developers like myself. I already liked it.

Tuesday, June 24, 2008

Downloading Rails Casts

Rails casts is hosting Ruby on Rails video tutorials. It explains a lot of tips for development and how different rails components work. I highly recommend it for rails starters.

I wanted to download all the previous episodes, that needed me to open the page of each episode, find the link for the mov file, and click save as. So i created a bash script to visit the links of the episodes and do the job automatically

get_rails_casts.sh:

#!/bin/bash
for ((i=$1;i<=$2;i+=1)); do
wget http://railscasts.com/episodes/$i -O- | grep -oi 'http://media.railscasts.com/videos/[a-z_0-9]*.mov' >> links
done
while read LINE ; do wget "$LINE" ; done < links

Now the script can be used to download any range of episodes. below i'm calling it to download episodes from the episode #1 to episode #115

./get_rails_casts.sh 1 115

Sunday, June 22, 2008

Setting Up RubyOnRails Development Environment on Ubuntu 8.04 Hardy

I started a new fresh installation of Ubuntu 8.04 (Hardy).. i needed to prepare my machine for RubyOnRails development. Below are the steps i need to make:

Installing Ruby, Rails, MySQL

Install MySQL

apt-get install mysql-server mysql-client 

Install Ruby (1.8.6) and gems

apt-get install build-essential ruby irb rdoc ri ruby1.8-dev libzlib-ruby libopenssl-ruby1.8 rubygems libmysql-ruby1.8

Update gem

gem update --system
rm /usr/bin/gem
ln -s /usr/bin/gem1.8 /usr/bin/gem

Install Rails & Mongrels

gem install rails mongrel mongrel_cluster

Installing rails 1.2.5 (needed in my project)

gem install rails -v 1.2.5 --include-dependencies

Move the mongrel_rails, rails and rake to the /bin directory

ln -s /var/lib/gems/1.8/bin/mongrel_rails /bin/
ln -s /var/lib/gems/1.8/bin/rake /bin/
ln -s /var/lib/gems/1.8/bin/rails /bin/

This makes us done with the basic ruby and rails installation.

Installing RMagick

Rmagick is an image processing library that is needed by some rails projects (including mine). Remove conflicting packages in case there were previously installed, install the right version of the libraries and then get rmagick through gem

sudo apt-get remove --purge librmagick-ruby-doc librmagick-ruby1.8
sudo apt-get install libmagick9-dev ruby1.8-dev
sudo gem install rmagick

Downloading and Installing Aptana Studio

download the compressed distribution of Aptana for Linux from aptana download page

Aptana is an eclipse based IDE. We need to install JRE in order to run aptana

sudo apt-get install sun-java6-jdk
sudo update-java-alternatives -s java-6-sun
sudo update-java-alternatives -s java-6-sun


sudo vim /etc/jvm

add this line at the top of the file

/usr/lib/jvm/java-6-sun


sudo vim /etc/profile

and this line at the beginning of the file

export JAVA_HOME=/usr/lib/jvm/java-6-sun

Installing RadRails

  • start aptana studio
  • navigate to "help" > "software update" > "find and install"
  • select "search for new features to install" and hit "Next"
  • select "Aptana: RadRails Development Environment and click Next
  • follow the wizard to the end of the installation then restart aptana studio

upon restart, if you get the "unable to detect ruby install" error, you need to setup the ruby interpreter in aptana

  • Open "Window" > "Preferences"
  • goto "Ruby" > "Installed Interpreters"
  • click "add"
  • set the "RubyVM home directory" to "/usr/bin" and the name to anything ("ruby1.8" would be fine)
  • click "ok" and select the new added interpreter

This should make the machine ready for developers to start being productive.

Monday, June 02, 2008

Heads Up With Radiant CMS

Radiant is an open source RubyOnRails based Content Management System, designed for relatively small websites. One of the nice things about radiant is that it the templates themselves are stored in the database like ordinary content, making all interactions with the site once it is deployed through the administration interface.
In radiant, a page can be composed of several named parts. Parts of the interface that is shared among several layouts (like navigation bar, footer, header) can be stored in snippents. Using snippets, layouts and page parts helps the site creators to elegantly build and maintain their website.
Some features that is beyond a CMS, like having a page that sends emails or a form that stores data somewhere, can be obtained through radiant extensions.
let's start a new radiant project:

first you need to install the radiant gem
gem install radiant --include-dependencies

then create a new radiant project specifying the database engine used.
radiant --database mysql mysite

Now you have the project created.
Create a new database and set the database connection paramaters in the database.yml, then bootstrap
rake development db:bootstrap

This will start creating all necessary database tables and relations. then it will ask you for the administrator credentials.
Create the admin user (press enter for defaults).
Name (Administrator):
Username (admin):
Password (radiant):

After creating the admin account you will be asked about the type of database templates to be used.
Select a database template:
1. Empty
2. Simple Blog
3. Styled Blog
[1-3]:

  • The Empty project template creates a project with no initial pages at all. once you start the server and try to open the site, you will be forwarded to the administration login page. You'll need to create all layouts, snippets, pages from scratch
  • The Simple Blog template creates a simple plain text website with blog structure set and two simple posts and with nearly no stile at all.
  • The Styled Blog template creates a project that has the blog part setup like the previous type. but it is more rich with stylesheet and nice display. Of course you will need to override the current initial implementations with you own.

After you created the project. start the server
ruby script/server -e development

Then check the new created website at http://localhost:3000
and check the administration interface at http://localhost:3000/admin

Yo can check the demo at radiant website to see a real working example.