Thursday, February 28, 2008

Ubuntu Brainstorm

For those looking to improve Ubuntu further, take a look at this recently created site:

http://brainstorm.ubuntu.com/


W

Wednesday, February 27, 2008

Ubuntu Freeze Ups

In case anyone is running a dual core 64-bit machine with a nVidia graphics card, check out this bug:

https://bugs.launchpad.net/ubuntu/+source/linux-restricted-modules-2.6.22/+bug/145112

You just might end up with system freezes... T.T


W

Sunday, February 24, 2008

Eclipse: To Upper/Lower case

Ever wanted to highlight a word and change everything to upper/lower case in eclipse?

Upper: CTRL + SHIFT + x
Lower: CTRL + SHIRT + y

Enjoy!


W

Saturday, February 16, 2008

Ubuntu: Find and remove files

In certain cases, you want to remove some files, which all have the same name, but perhaps in different folders. And if you're lazy like me, you don't want to go through all the directories and delete it manually. Well, here's a neat little command I found:

>find . -name file_name -print0 | xargs -0 rm

This will find all the files and remove them recursively. If you want to use a regular expression instead of a file name directly, you can use the -regex option instead of the -name option.


W

Ubuntu + No-Ip

If you're running no-ip to update your IP address, you can get it on Ubuntu as well. Use this very helpful tutorial:

http://ubuntulinuxhowto.blogspot.com/2006/06/dynamic-dns-no-ip.html


W

Friday, February 15, 2008

Ubuntu Java Applets

When surfing websites, there are often times when you come across Java Applets. In Firefox, it will ask you to download a plugin. This downloads something called IcedTea.

Well, apparently, it doesn't quite work with a 64-bit machine. I'm not sure about 32-bit machines, but at least on my machine (a 64-bit), it doesn't work. I finally came across a bug that was reported on Ubuntu... and luckily, a fix!

>sudo apt-get build-dep icedtea-java7-plugin
> sudo apt-get -b source icedtea-java7-plugin icedtea-java7-bin icedtea-java7-jre icedtea-java7-jdk
> sudo dpkg -i icedtea-java7-*deb

Word of warning though, this takes a very long time. And by very, I really do mean VERY. After you execute the second line, go for lunch or take a nap. Hopefully it'll be done by the time you get back ;)

After executing the last line, I got a software update message from Ubuntu for the IcedTea plugin. I hit install, and it updated everything for me, and everything works.

To test if it worked, try this:

www.java.com/en/download/help/testvm.xml


W

Ubuntu Screensavers

It's usually very normal to use a screensaver... they're pretty! Well... don't try with Ubuntu's pre-installed screensavers. There may be incompatibility with my computer which caused this, but I'm not sure.

What happened was that when I set my screensaver to braid (I was browsing the screensavers), my Ubuntu froze. I couldn't do anything. Not even Ctrl + Alt + F1 would bring me to a console. I ended up having to press the Shutdown button on my computer! Then when I got back in and tried to change the screensaver back to blank, it would freeze because it was generating the preview for braid... ARGH!!! Also, whenever the screensaver would come on, it would also freeze Ubuntu!

I spent a while trying to figure out how to change the screensaver back to blank... with no luck, but at least I found many people were having the same problems. I then decided to just look around myself and BINGO!

> gedit ~/.gconf/apps/gnome-screensaver/%gconf.xml

Change the screensaver property back to:

screensaver-none

This changes the screensaver back to blank... which I had no problems with to begin with... never touching this thing again unless I know it's ok.


W

Wednesday, February 13, 2008

Ubuntu + Eclipse: Round 2

Ok... so apparently, I was having all sorts of problems with my first installation of Eclipse 3.3. I was getting a whole crap load of exceptions in the logs. Also, every so often, my Eclipse would freeze, then shut down on me without notice, sometimes bringing down Ubuntu as well. Not to mention it didn't save any unsaved data (ARGH!!!).

So... I scrapped it! I removed Eclipse from my system... which took FOREVER. I did:

>sudo apt-get remove --purge eclipse
>sudo apt-get autoremove
>sudo apt-get autoclean

Then I went into /usr/lib and /usr/share to make sure the eclipse folder was gone. I then removed my workspace .eclipse folder. After this, I went into Synaptic package manager and completely removed all Eclipse packages and Sun Java 6 packages. And by all, I mean EVERYTHING!

I then reinstalled Eclipse and Sun Java 6 about 5 or 6 times using Synaptic, with no luck. Eclipse 3.2 wouldn't even start up. It kept complaining about a BundleException. No idea what that was. I finally gave up with Synaptic and went back to apt-get.

>sudo apt-get update
>sudo apt-get dist-upgrade
>sudo apt-get eclipse
>sudo apt-get sun-java6-jdk

Then I added /usr/lib/jvm/java-6-sun to the beginning of the lists in:

>sudo -b gedit /etc/jvm
>sudo -b gedit /etc/eclipse/java_home

I then ran eclipse using the following:

>eclipse -clean

which gave me an error:

searching for compatible vm...
testing /usr/lib/jvm/java-6-sun...found
Could not create /usr/local/lib/eclipse/.eclipseextension. Please run as root:
touch /usr/local/lib/eclipse/.eclipseextension
chmod 2775 /usr/local/lib/eclipse/.eclipseextension
chown root:staff /usr/local/lib/eclipse/.eclipseextension

So I did:

>sudo touch /usr/local/lib/eclipse/.eclipseextension
>sudo chmod 2775 /usr/local/lib/eclipse/.eclipseextension
>sudo chown root:staff /usr/local/lib/eclipse/.eclipseextension

Then ran again:

>eclipse -clean

This time, Eclipse 3.2 started up with no exceptions in the logs! YAY!

Not done yet... will try to install Aptana + RadRails + SubClipse now... wish me luck!

UPDATE:
After installing Aptana, everything seems to be running fine. Eclipse did not shut down on me... so I continued to install RadRails.

After installing RadRails, I checked the logs, and I got several exceptions. As I continued to use Eclipse, I continued to get a whole load of errors. However, Everything continued to work fine. I'm not sure what the error messages are, but they weren't bothering me, so I decided not to bother them!

Next came SubClipse. This installed without problems as well! And now I'm happily coding away again! Yay! Nightmare over! ...for now...


W

Ubuntu Firefox Fonts

After moving to Ubuntu, our website was completely out of alignment when using Firefox. We had set our default the usual:

font-family: Arial, Helvetica, sans-serif;

Of course, Arial is a MS font. We decided that as a linux user, you would be expected to know how to tweak your computer, and hence it is reasonable to expect a linux user to know how to change their fonts.

To use Arial in your Firefox, do the following:

>sudo apt-get install msttcorefonts

and wait for a while. Maybe go have a coffee ;)

Afterwards, log out and log back in so that the new fonts can be loaded.

Next, you have to let Firefox know you want to use Arial. Go to:

Edit > Preferences > Content > Fonts & Colors > Advanced

Then change what you want to Arial. I set my serif and sans-serif to Arial. This seemed to do the trick, at least for our website.


W

Tuesday, February 12, 2008

attachment_fu - Controller and View

Upload Image - after all the hard work trying configuring the damn thing, this is where it pays dividends. To create an upload form, all we need are three lines:

<% form_for(:photo, @photo, :url => some_path,
:html => { :multipart => true }) do |f| %>

<%= f.file_field :uploaded_data %> <%= submit_tag "Upload" %>

<% end %>

make sure multipart is set to true, or else it won't work.
Over to the controller side, you just do what you normally do with other create actions

def create

@photo = Photo.new params[:photo]
if @photo.save ... yayaya

and the rest will be handled by attachment_fu

Listing Images - once again, three lines

<% for pic in @photo %>
<%= link_to image_tag(pic.public_filename(:thumb)), pic.public_filename %>
<% end %>

sticking in the :thumb will grab all the thumbnails, leaving it out will grab the bigger version

example:

photo.public_filename #=> /photo/2/file.jpg
photo.public_filename(:thumb) #=> /photo/2/file_thumb.jpg

Delete Image - it's just like any other objects

@photo = Photo.find(id)
@photo.destroy


J

attachment_fu - configurations

In our model, we'll use the has_attachment command to hook into attachment_fu.

example:

has_attachment :content_type => :image,
:storage => :file_system,
:max_size => 500.kilobytes,
:resize_to => '320x200>',
:thumbnails => { :thumb => '100x100>' }
:processor => 'Rmagick'

validates_as_attachment

Let's look at each option in detail

for storage, you have three options, :db_system (default), :file_system, or :S3. If you are using :db_system, attachment_fu will convert and save the image to your db as a BLOB (binary large object). If :file_system is used, the file will be saved to your hard disk. If :S3 is used, image will be saved to Amazon's S3 server.

:max_size lets you specific the maximum size of the photo, and there's also a :min_size which works the other way

:resize_to - resize your image to an acceptable width and height like facebook :) It takes a string called the Geometry String, which has the format:

< width > x < height > + - < x > + - < y > { % @ ! < > }

where any of the field can be omitted.

By default, width and height are the maximum value. If you enter something like '300x500' the image will expand or contract to fit the width and height value while maintaining the aspect ratio of the image.

If you want to enforce the image size to be exactly the size you specify, you can append an exclamation mark in the end like so: '300x500!'

You can also specify either the width '300' or the height 'x500' where the missing parameter will be chosen to maintain the aspect ratio

You can append % to specify percentage width and height ('110%' - increase, '90%' - decrease, '110%x90%' = increase width, decrease, height)

You can use @ to specify the maximum area in pixels of an image (I don't see how this is gonna be useful)

You can use < or > to change the dimensions of the image only if its width or height exceeds the geometry specification. < resizes the image only if both of its dimensions are less than the geometry specification. For example, if you specify '300x500>' and the image size is '250x250', the image size will not change. However if the image is '1000x1000', the it'll be resized to '300x300' and vice versa.

Finally x and y are offsets for width and height. + causes x and y to be measured from the left or top edges and - measures from the right or bottom edges. And they are always measured in pixels.

:thumbnails - a set of thumbnails to generate, specified by a has of filename suffixes and resizing options. You can omitted it if you don't want thumbnails. Generating multiple thumbnails will look something like this

:thumbnails => { :thumb_big => '500x500', :thumb_small => '100x100' }

:thumbnail_class - set what class to use for thumbnails (defaulted to whatever model you are in) However, you can generate a seperate model with seperate set of validations

:processor - 'ImageScience', 'Rmagick', or 'MiniMagick'. I like Rmagick cause it has the most features, but MiniMagick is less of a memory hog.

:path_prefix - Path to store the uploaded files, which defaults to public/your_table_name
If you are using S3 backend, it defaults to just your_table_name

validates_as_attachment does all the validations for you, so you have nothing to worry about :)


J

attachment_fu - Installation and Setup

attachment_fu plugin is the complete package in handling images for your website. It handles image upload, resize, generate thumbnails, storing image info to database and saving the file to physical disk drive

to install attachment_fu, we type

~$ .script/plugin install http://svn.techno-weenie.net/projects/plugins/attachment_fu/

if you don't have imagemagick and rmagick installed

~$ sudo apt-get install imagemagick
~$ dpkg -l | grep magick
~$ sudo apt-get install libmagick9-dev
~$ sudo gem install rmagick -v=1.15.12

window users: you can go download the imagemagick executable and install rmagick by doing gem install rmagick -v=1.15.12

now let's generate a model to test it out

~$ .script/generate model photo

open up the migration file and enter the following

class CreatePhotos < ActiveRecord::Migration
def self.up create_table :photos do |t|
t.column :user_id, :integer
t.column :parent_id, :integer
t.column :content_type, :string
t.column :filename, :string
t.column :thumbnail, :string
t.column :size, :integer
t.column :width, :integer
t.column :height, :integer
end
end

def self.down
drop_table :photos end
end

:user_id - I'm assuming these photos belong to someone, you can replace it with another model_id depending on the relationship

:parent_id - don't touch, it's reserved for attachment_fu

:content_type - specify the content type of your data, default is image, but it can also be audio, or video the rest are pretty self explanatory, and we'll revisit these fields in a moment. now save your file, and do a quick rake db:migrate


J

Ubuntu and MP3s

Using the prepacakged Rhythmbox Music Player, I attempted to import my MP3s. However, I got a GStreamer plugin error that it couldn't handle MP3s.

For MP3 support, do the following:

>sudo apt-get install gstreamer*

Now start your Rhythmbox again. ;)

Rhytmbox also supposedly supports syncing with your iPod. I have yet to try, and will report on this issue once I have tried it out.


W

Ubuntu Input Languages

For those that want to be able to type in Chinese, Japanese, or Korean, Ubuntu comes with a prepackaged application called SCIM. There is, however, a trick needed to get it working properly.

Go to System > Administration > Language Support. Then select the languages you want. Check the Enable support to enter complex characters. If it s already checked, you must uncheck it, click Apply, then recheck it. Hit Apply now. Log out and log back in.

Now you should see a little icon in the top right that looks like a keyboard. That's good. Supposedly, you can now hit Control + Space, and it should toggle through your input options. However, in Ubuntu 7.10, it doesn't.

Do the following:

>sudo gedit /etc/X11/xinit/xinput.d/scim

Change:

GTK_IM_MODULE=xim
QT_IM_MODULE=xim

To:

GTK_IM_MODULE="scim"
QT_IM_MODULE="scim"

Save and exit. Log out and log back in.

Now, when you're at an input, you can simply hit Control + Space, and it will toggle through your input options.

Enjoy!


W

attachment_fu

attachment_fu plugin is the complete package in handling images for your website.
It handles image upload, resize, generate thumbnails, storing image info to database
and saving the file to physical disk drive

to install attachment_fu, we type

~$ .script/plugin install http://svn.techno-weenie.net/projects/plugins/attachment_fu/

if you don't have imagemagick and rmagick installed

~$ sudo apt-get install imagemagick
~$ dpkg -l | grep magick
~$ sudo apt-get install libmagick9-dev
~$ sudo gem install rmagick -v=1.15.12

window users: you can go download the imagemagick executable
and install rmagick by doing gem install rmagick -v=1.15.12

now let's generate a model to test it out

~$ .script/generate model photo

open up the migration file and enter the following

class CreatePhotos < ActiveRecord::Migration
def self.up create_table :photos do |t|
t.column :user_id, :integer
t.column :parent_id, :integer
t.column :content_type, :string
t.column :filename, :string
t.column :thumbnail, :string
t.column :size, :integer
t.column :width, :integer
t.column :height, :integer
end
end

def self.down
drop_table :photos end
end

:user_id - I'm assuming these photos belong to someone, you can replace it with another model_id depending on the relationship

:parent_id - don't touch, it's reserved for attachment_fu

:content_type - specify the content type of your data, default is image, but it can also be audio, or video the rest are pretty self explanatory, and we'll revisit these fields in a moment. now save your file, and do a quick rake db:migrate

In our model, we'll use the has_attachment command to hook into attachment_fu.

example:

has_attachment :content_type => :image,
:storage => :file_system,
:max_size => 500.kilobytes,
:resize_to => '320x200>',
:thumbnails => { :thumb => '100x100>' }
:processor => 'Rmagick'

validates_as_attachment

Let's look at each option in detail

for storage, you have three options, :db_system (default), :file_system, or :S3. If you are using :db_system, attachment_fu will convert and save the image to your db as a BLOB (binary large object). If :file_system is used, the file will be saved to your hard disk. If :S3 is used, image will be saved to Amazon's S3 server.

:max_size lets you specific the maximum size of the photo, and there's also a :min_size which works the other way

:resize_to - resize your image to an acceptable width and height like facebook :) It takes a string called the Geometry String, which has the format:

\x\+-\+-\{%@!\<\>}

where any of the field can be omitted.

By default, width and height are the maximum value. If you enter something like '300x500' the image will expand or contract to fit the width and height value while maintaining the aspect ratio of the image.

If you want to enforce the image size to be exactly the size your specify, you can append an exclamation mark in the end '300x500!'

You can also specify either the width '300' or the height 'x500' where the missing parameter will be chosen to maintain the aspect ratio

You can append % to specify percentage width and height ('110%' - increase, '90%' - decrease, '110%x90%' = increase width, decrease, height)

You can use @ to specify the maxium area in pixels of an image (I don't see how this is gonna be useful)

You can use > or <>' and the image size is '250x250', the image size will not change. However if the image is '1000x1000', the it'll be resized to '300x300' and vice versa.

Finally x and y are offsets for width and height. + causes x and y to be measured from the left or top edges and - measures from the right or bottom edges. And they are always measured in pixels. That took long enough, let's move on

:thumbnails - a set of thumbnails to generate, specified by a has of filename suffixes and resizing options. You can omitted it if you don't want thumbnails. Generating multiple thumbnails will look something like this

:thumbnails => { :thumb_big => '500x500', :thumb_small => '100x100' }

:thumbnail_class - set what class to use for thumbnails (defaulted to whatever model you are in) However, you can generate a seperate model with seperate set of validations

:processor - 'ImageScience', 'Rmagick', or 'MiniMagick'. I like Rmagick cause it has the most features.

:path_prefix - Path to store the uploaded files, which defaults to public/your_table_name
If you are using S3 backend, it defaults to just your_table_name

validates_as_attachment does all the validations for you, so you have nothing to worry about :)

This post is getting way too long. I'll have a seperate post for view and controller


J

Ubuntu + Eclipse 3.3 (Europa)

When using

> sudo apt-get install eclipse

there are several problems. Firstly, eclipse doesn't inherently use Sun's Java. This results in a "slow Eclipse". Secondly, using this command gives you Eclipse 3.2, not 3.3.

So, this is what I did:

Download Eclipse 3.3 straight from the Eclipse website (I got the classic version). Extract the tarball, and you have a working, standalone Eclipse 3.3.

However, it is not integrated into Ubuntu and it's still not using Sun's Java. Follow the instructions from the first post of this thread.

Eclipse should now be integrated into Ubuntu, but this is still version 3.2.

We will now overwrite 3.2 with our downloaded 3.3:

>sudo cp -R ~/Desktop/eclipse/* /usr/lib/eclipse/

Now that we have 3.3 installed and integrated into Ubuntu, there is one more step to do. When doing software updates, Eclipse needs to create and install new files. This can be troublesome with the wrong permissions. I went through a number of hacks, none of which worked, so I finally settled for opening up all permissions in the Eclipse install directory:

>sudo chmod 777 -R /usr/lib/eclipse

Voila! After this is complete, you may start to use Eclipse and install other plugins.


W

Monday, February 11, 2008

Ubuntu Ruby Gems

From a previous post on moving to Ubuntu by J, there was a mention of installing Ruby Gems.

Well, I came across an error when executing:

> sudo gem update --system

It complained of a Gem::GemNotFoundException. I found a quick fix for this which was to do the following:

> sudo gem update
> sudo gem update --system

This seemed to do the trick.

After the update though, there was another error when executing:

>gem -v

to check the version. The error was "uninitialized constant Gem::GemRunner (NameError)". Another quick fix for this one was to add an extra line to /usr/bin/gem

require 'rubygems/gem_runner'

after

require 'rubygems'

Probably more problems and solutions to come later ^^


W

Ubuntu sources.list

Just an extension to a previous post by J about installing applications in Ubuntu. If the sources in sources.list are giving you troubles, take a look at this Gutsy Gibbon help guide.

Scroll down to the Manual Method for Adding Repositories. After following this, everything installed correctly.

Also, to be noted is that my previous source list all had Canadian mirrors. These mirrors are sometimes not up to date, slow, or down.


W

Ubuntu Dual Display

When I first installed Ubuntu, I checked out the visual effects. I was anticipating many cool features. I set it to the highest setting, and everything worked fine. I then did

> sudo apt-get install compizconfig-settings-manager

to get the configuration settings manager. This allows you to customize your desktop effects. All was going well, until I decided to get my dual screen setup running... Big mistake!

Turns out, my xorg.conf wasn't set properly. I tried using the Screen and Graphics configuration window provided by Ubuntu, but could not get it to work. What was happening was that I couldn't turn on ANY desktop effects at all. I did, however, see my dual screens displayed, but I wanted the cool effects!

After mucking around for a bit, I finally found a configuration that worked for my setup.

I added a few options to my graphics card device to support Twinview (instead of using Xinerama). TwinView allows you to extend your desktop to the 2nd monitor while treating it as the same window. After hooking everything up, logged out, then in, and everything worked like a charm.

Here's what I have in my xorg.conf:

Section "Device"
Identifier "card0"
Driver "nvidia"
VendorName "nVidia Corporation"
Boardname "geForce 7600 GT"
Busid "PCI:1:0:0"
Option "NoLogo" "0"
Option "RenderAccel" "true"
Option "HWcursor"
Option "CursorShadow"
Option "CursorShadowAlpha" "32"
Option "CursorShadowXOffset" "3"
Option "CursorShadowYOffset" "3"
Option "AllowGLXWithComposite" "true"
Option "TwinView"
Option "MetaModes" "1600x1200,1024x768; 1600x1200,1600x1200; 1600x1200; 1280x1024,1280x1024; 1280x1024; 1024x768,1024x768; 1024x768; 800x600,800x600; 800x600"
Option "TwinViewOrientation" "RightOf"
Option "SecondMonitorHorizSync" "UseEdidFreqs"
Option "SecondMonitorVertRefresh" "UseEdidFreqs"
EndSection

Section "Screen"
Identifier "screen0"
Device "card0"
Defaultdepth 24
Monitor "LCD MAG"
SubSection "Display"
Depth 24
Modes "1600x1200@60" "1400x1050@60" "1280x960@75" "1280x1024@60" "1280x960@60" "1280x1024@75" "1152x864@75" "1024x768@60" "1024x768@70" "1024x768@75" "832x624@75" "800x600@60" "800x600@75" "800x600@72" "800x600@56" "640x480@75" "640x480@72" "640x480@60"
EndSubSection
EndSection

Section "ServerLayout"
Identifier "twinview"
Screen 0 "screen0" 0 0
Inputdevice "Generic Keyboard"
Inputdevice "Configured Mouse"
Option "Xinerama" "0"
EndSection

The "LCD MAG" is my primary monitor.

For more information, take a look at Dual Monitors and Twinview Example.

Just to let you know, I have a nVidia GeForce 7600 GT. Twinview is used with nVidia. If you have another graphics card, you're on your own :P


W

Saturday, February 9, 2008

Firefox bug in Ubuntu

I just installed ubuntu version 7.10 desktop edition,
whenever I try to bookmark a page or save a file with firefox

it returns the following error

XML Parsing Error: not well-formed

not sure what caused it, but in order to fix you problem
you can simple reinstall by doing

~$ sudo apt-get --purge --reinstall install firefox

hope this helps


J

Friday, February 8, 2008

Moving to Ubuntu, ditching windows

We are trying to install juggernaut, a ruby push server which allows real time conversation with users (something like google chat). However, the gem doesn't seem to work in windows environment, so to hell with it, we are moving our stuff to ubuntu.

why ubuntu? I don't know, it was a random choice :)

if you install ubuntu without internet connection,
the entire source list will be commented out

if that's the case, we need to edit it by doing
~$ sudo vi /etc/apt/sources.list

uncomment all the links inside, save and exit

now we will update the list

Before we start installing rails and all its gems
we need to update our current libs and software to the latest version first

~$ sudo apt-get update
~$ sudo apt-get dist-upgrade (this will take awhile)

now we will install openssh so you can access your box from else where

~$ sudo apt-get install openssh-server openssh-client

we also need subversion to check in our work and install plugins

~$ sudo apt-get install subversion

to install postgres

~$ sudo apt-get install postgresql
~$ sudo apt-get install pgadmin3

~$ sudo su postgres -c psql template1
template1 =# ALTER USER postgres WITH PASSWORD 'something'
template1 =# \q

this will alter the password within the database, now we do the same for ubuntu

~$ sudo passwd -d postgres
~$ sudo su postgres -c passwd

now we setup the postgres admin pack for loggin and monitoring within pgAdmin

~$ sudo su postgres -c psql < /usr/share/postgresq/8.2/contrib/adminpack.sql

now we edit the configuration file

~$ sudo vi /etc/postgresql/8.2/main/postgresql.conf

uncomment password_encryption = on

save with :wq

tired yet? if not, we are now ready to install ruby and rails

to install ruby we do

~$ sudo apt-get install ruby rdoc irb libyaml-ruby libzlib-ruby ri libopenssl-ruby

then we will install rubygems, apt-get will give you version 0.8.x or something outdated, don't panic, we'll get the gem to update itself

~$ sudo apt-get install rubygems
~$ sudo gem update --system

now we'll install rails and it's dependencies

~$ sudo gem install rails --include-dependencies

and that's it, you can pretty much stop here and relax, but for those who wants to install some of the essential gems, please keep reading

everyone know webrick sucks, so we'll install mongrel

~$ sudo apt-get install build-essential
~$ sudo apt-get install ruby1.8-dev
~$ sudo gem install mongrel

in order to connect to the db, we need to install the postgres driver

~$ sudo gem install postgres-pr

for fast debugger, we'll also need ruby-debug-ide

~$ sudo gem install ruby-debug-ide

TzInfo

~$ sudo gem install tzinfo

ImageMagick and RMagick

~$ sudo apt-get install imagemagick
~$ dpkg -l | grep magick (if you don't do this, rmagick won't know it's installed)

~$ sudo apt-get install libmagick9-dev
~$ sudo gem install rmagick -v=1.15.12

and finally for the stuff we want :)
JUGGERNAUT!!!

~$ sudo gem install json
~$ sudo gem install eventmachine
~$ sudo gem install juggernaut

J

Monday, February 4, 2008

the importance of .to_i

many times we'll use data fetched from a database in condition statements. And alot of times (at least I do) we'll assume data returned are numeric types of some kind because that's how it's specified in the database schema.

Big mistake!! .to_i should always be attached to numeric variables when used if you don't want little bugs creep out of nowhere.

One of my function acted all weird because I was comparing "1" with 1 :)

Another common place to make mistake is retrieving params variables, they will always return string values and it's up to you to convert them to your desired types.


J

Saturday, February 2, 2008

IE 6 Hidden Inputs

There are often times when you need to use hidden inputs, whatever the reason is. As the name suggests, these are hidden inputs, and should NOT be displayed.

However, as usual, IE 6 decides to go against common sense and do something strange. In this case, IE 6 seems to reserve some space for hidden inputs. You end up with odd blank spaces here and there, depending where you put your hidden inputs.

It took me a while to figure out it was the hidden inputs (after pulling out my hair several times). I used a very simple hack to get rid of them afterwards:

position: absolute;
left: 9999px;

That zips the hidden inputs off the page and out of sight, even in IE 6!


W