How to tell which Linux distro you’re running

Update:

Thanks to Jayen, there is a better way:

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 9.10
Release: 9.10
Codename: karmic

$ cat /etc/issue
Debian GNU/Linux squeeze/sid \n \l

Or


$ cat /proc/version
Linux version 2.6.32-trunk-686 (Debian 2.6.32-5) (ben@decadent.org.uk) (gcc version 4.3.4 (Debian 4.3.4-6) ) #1 SMP Sun Jan 10 06:32:16 UTC 2010

Source: Which Linux Distro are you using??

Profile backup – Mozilla FireFox and Thunderbird

At work, a colleague is struggling to get his pc up and running for a few days now. To add insult to injury, he also lost some of his Microsoft Outlook back up emails.
Seeing what happened to him, I shall back up my files and emails too.

I use Mozilla Thunderbird (2.0.0.22), and I found a very nice tool to back up the emails (a.k.a profile). It’s called MozBackup.
mozbackup-screenshot

I thought I should share this with others who use Thunderbird too.

PHP: number of days between two dates

It’s Saturday, what am I doing in front of the computer? I should be out and enjoy life. ^o^

A colleague asked to customize a theme for his blog using WordPress. Because I didn’t have any good plan this Saturday, learning PHP sound like a logical and useful choice. Well, I bribed myself with a bottle of Tui.

Then, I found an interesting PHP related post by Chorn Sokun entitled “PHP date diff“. The author was trying to calculate the number days between two give dates. At the end of the post, he asked “What would you do instead?”

Here is my answer.

< ?php
/*
 * Function to calculate the number of days between
 * two given dates.
 * Assumption:
 *              $date2 > $date1
 *              Date format: mm/dd/yyyy e.g.: 31/07/2009
 * Author: kenno
 * Date: July 4, 2009
 */
function number_of_days($date1, $date2) {
$date1Array = explode('/', $date1);
$date1Epoch = mktime(0, 0, 0, $date1Array[1],
$date1Array[0], $date1Array[2]);

$date2Array = explode('/', $date2);
$date2Epoch = mktime(0, 0, 0, $date2Array[1],
$date2Array[0], $date2Array[2]);

$date_diff = $date2Epoch - $date1Epoch;
return round($date_diff / 60 / 60 / 24);
}

echo number_of_days("04/7/2009", "12/7/2009"); // 8
?>

Now, it’s my turn to ask. How could I make it better? How would you do it? :)

Update:

Added the abs( ) to round up the number of days to integer as suggested by Sokun.
Added round( ) to round up the number of days on line 21. I confused round( ) with abs( ).

Relocate the URL of SVN Repository

Recently, SVN has been installed on a local Debian box at work. This could have been done a bit earlier in my opinion, but well it’s better be a little late than never.

The SVN server is accessed via a LAN ip: 192.168.0.126. Because we didn’t setup static IP on the router, the IP of the server keeps changing from time to time. Here’s how one can change or relocate to the new URL.

With command line, just type:

svn switch --relocate OLD_URL NEW_URL

Using Tortoise SVN on Windows:

svn_relocate

Credit: How to change the URL of your SVN repository