Tuesday, May 27, 2008

Comma Separated Numbers

I found a neat little function that will separate large numbers by thousands using a comma or any specified delimiter:

http://api.rubyonrails.org/classes/ActionView/Helpers/NumberHelper.html#M000997

Gotta love RoR... they simplify everything!


W

Monday, May 26, 2008

Ubuntu: .docx files

OpenOffice is amazing when it comes to opening up .doc files created from Microsoft Word. However, there's a slight problem when it comes to opening .docx. Simply put, OpenOffice doesn't recognize it!

Don't worry though... there's always a solution! Check this out and follow the instructions posted by stuporglue.

Enjoy!


W

Thursday, May 22, 2008

Remote Host Identification has Changed

I just reinstalled our main server. When I try to ssh into it I got an error:

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that the RSA host key has just been changed.

Please contact your system administrator.
Add correct host key in /home/user/.ssh/known_hosts to get rid of this message.
Offending key in /home/user/.ssh/known_hosts:1
RSA host key for ras.mydomain.com has changed and you have requested strict checking.
Host key verification failed.

-----------------------------------------------------------

The reason behind this is because your local computer still has the old RSA host key stored in /home/your_account/.ssh/known_hosts.

The easiest way to solve this problem is simply delete that file or you can delete the host entry in the file.


Joseph

Saturday, May 17, 2008

Time Ago

Ever wanted to show the user that something happened so many minutes/hours/days/etc ago? Apparently, RoR makes it super simple to do this. There is a method called:

time_ago_in_words

Simply include the time (from now) that you want to calculate - perhaps a created_at/updated_at field.

Easy!


W

Friday, May 16, 2008

Software Freedom Day

September 20th, 2008 is Software Freedom Day! If your interested in promoting and celebrating software freedom, check this out:

http://www.softwarefreedomday.org/


W

Wednesday, May 14, 2008

Alternating Table Row Colours

When listing data out in a table, it's always nice to have alternating row colours. This makes it infinitely easier to scan the table and much more enjoyable.

RoR makes it really simple to alternate row colours. A cycle function is given to aid in this task, and it simply cycles between the values given. By using this, you can specify your alternating class names here.

If you have more than one table, remember to call the reset_cycle function to reset the cycle.

Easy!


W

Saturday, May 10, 2008

VMware Server: Adding a new HDD

I'm running WinXP through VMware Server (as it comes free and is in the Ubuntu repos!!!). It runs really, really well and am completely satisified with it. However, I wanted to add a new HDD to my VM.

Well, I did the obvious, which was to power down my VM and edit the settings. I went to go add a new vitual HDD and pre-allocated it (all the defaults).

I then powered on my VM and lo-and-behold, no new disk! What?!?!?! Well, I found a very nice little tutorial on YouTube that teaches you how to do it properly. Apparently, there's a few extra steps required inside of WinXP to detect and setup the newly added disk:

http://www.youtube.com/watch?v=z3GciNMYLlo

Hopefully, this'll help anyone that is stuck.


W

Friday, May 9, 2008

Ubuntu + Compiz Fusion plugins

Gutsy Gibbon already has Compiz Fusion packaged with it, but apparently, there are numerous plugins that can be added on as well!

This guy has written a lovely script to get you started:

http://ubuntuforums.org/showthread.php?t=620000

Enjoy!


W

Thursday, May 8, 2008

Support ODF

I've recently been reading more and more material about open formats. Apparently, there's been a ripple in the pond, as Microsoft is trying to push through their own format, which is obviously inferior and not much of a standard at all (again, the usual Microsoft bullying antics).

I found an interesting link I'd like to share if anyone is passionate about this fight. It's to get your government to support the OpenDocument Format. I'd just like to share this with you guys:

http://www.fsf.org/campaigns/odf-letter-template


W

Favicon

You know those websites that are able to have a little icon in the address bar? That's pretty cool huh? I thought so too, so I decided to add one.

Apparently, IE seems to have managed to screw it up... surprise surprise.

According to W3C, it's very simple to add one:

http://www.w3.org/2005/10/howto-favicon

Works like a charm in better browsers. However, in IE, they seem to mess everything up. Funny how IE is the one that first introduced this too! Anyways, to get around the IE problem, just create a favicon.ico in your root directory. This will definitely not look as nice as the PNG... but for compatibility, too bad! :P

IE is really screwing their users over... sigh...


W

Wednesday, May 7, 2008

Ubuntu + Ekiga

Ubuntu comes bundled with Ekiga, which is a VoIP program. It is something like Skype. I wanted to test this out and see how well it worked. I had a little bit of a problem configuring it though and would like to share my solution.

When using the configuration assistant, I was stuck at step 5, which told me that I had a symmetric NAT. If you don't run into this problem, then the configuration should go smoothly and you should have no problems. Anyways, back to my problem. Ekiga cannot run with a symmetric NAT. If you find any scripts to run in order to get Ekiga working, DO NOT run it. I tried one that I found on a wiki, and I lost my internet connection. It basically changed my iptables. No worries though if you did... just reboot your machine and everything will be reset back to a working state.

The script was made for older versions of Ekiga (much older) and is now of no use. The easiest way to get Ekiga working is to use port triggering on your router:

Service Name: STUN (or anything you like)
Triggering Port: 3478 (UDP)
Inbound Ports: 5000-5100 (UDP)

This should do it. Rerun step 5, and it should not report a Cone NAT. This is now acceptable and you can continue with the configuration.

Enjoy!


W

Tuesday, May 6, 2008

CSS: z-index

I ran into this problem with stacking order. It seems pretty simple to me, but Internet Explorer has managed to screw it up... again! I don't blame them if IE6 has problems, but for goodness sakes, fix it in IE7!! But alas, that's not to be and I'm stuck here with some crappy options. Actually, I don't mind... my users will though.

Basically, I have a few divs, and they're going to overlap. With proper z-index, everything is fine. However, without it, I can't implement what I want to do. So in the end, it's the users who suffer... that is if they use IE. I ended up using conditional comments (awesome stuff!) to do what I want to do if the user is not on IE.

Apparently, they say that IE8 fixes this and that it will be completely standards compliant, but my question is when will that be released and when will all the users no longer be using anything earlier than IE8... it's definitely going to be a long wait...

Damn IE sucks!


W

Saturday, May 3, 2008

Deployment: Part 3

We finally have everything up and running... at least the basics. However, we needed something more, such as starting/stopping/restarting our other servers. This was easily achieved using our own custom tasks in deploy.rb.

However, there was one odd one, which was backgrounDRb. To start the server, you must use:

./script/backgroundrb start -e production

The first problem we encountered was that after Capistrano had finished executing, the backgrounDRb daemon would disappear. After some research, an easy fix was found, which was to run the script through the nohup function:

nohup ./script/backgroundrb start -e production

This enabled backgroundrb to exist after Capistrano was complete. There was also another oddity that I found through research which I also implemented, which was to cd to the root directory before executing the script:

cd path/to/root && nohup ./script/backgroundrb start -e production

I never tested whether or not I could run the script without cd-ing... but the above command works for me without a problem, so why fix something that's not broken?

Next came environment problems. Backgroundrb was, for some odd reason, accessing the database in the development environment. However, I was clearly running the script in production!

Looking through the code, I realized that in bdrb_config.rb, it was setting the ENV["RAIL_ENV"] using the -e flag (which I stated production). However, when the master and meta workers were initialized, they were loading the rails environment without checking the ENV["RAILS_ENV"]. They were using the config file instead!

To fix this problem, simply change line 262 of master_worker.rb and line 350 of meta_worker.rb from:

run_env = CONFIG_FILE[:backgroundrb][:environment] || 'development'

to:

run_env = ENV["RAILS_ENV"] || CONFIG_FILE[:backgroundrb][:environment] || 'development'

This should check all the possible places that the environment could have been set and now everything should be running in the production environment!

Hope this helps anyone that was just as stumped as I was!


W

Friday, May 2, 2008

VMware on Hardy

There is currently no vmware package for hardy (DAMNIT!!). So we gotta do it the hard way.

1. apt-get the following

sudo apt-get install build-essential linux-headers-`uname -r`
sudo apt-get install xinetd

2. download the vmware tarball

just goto the website, it's constantly changing so I wouldn't bother posting it.

3. Get your FREE registration number (this used to cost a fortune, lucky us)

http://register.vmware.com/content/registration.html

4. Extract the tarball somewhere and run it by doing

tar -zxvf xxx.tar.gz
go into the directory
sudo ./vmware-install.pl

5. Now it'll ask you bunch of questions, just keep pressing enter. After awhile, it'll start compiling and fail :)

6. This has something to do with hardy's kernel, but don't worry, there's a patch for it.

wget http://uruz.org/files/vmware-any-any-update-116.tgz
tar -xvzf vmware-any-any-update116.tgz
cd vmware-any-any-update116
sudo ./runme.pl

7. VMware should start compiling and asks you more questions after (just keep pressing enter)

8. Once you've configured your vmware server, you need to link up some libraries

sudo ln -sf /lib/libgcc_s.so.1 /usr/lib/vmware/lib/libgcc_s.so.1/libgcc_s.so.1
sudo ln -sf /usr/lib/libpng12.so.0 /usr/lib/vmware/lib/libpng12.so.0/libpng12.so.0

9. And that's it, you can launch it by typing vmware on your console


J