Upgrading Ubuntu Breeze “server” to Dapper

•June 13, 2006 • Leave a Comment

While Ubuntu 5.10 (Breezy) has a user friendly GUI interface to upgrade to 6.06 (Dapper), those of us live in commandline world are not so lucky. But who cares? Here is a few simple steps to get the Dapper upgrade:

  1. apt-get update
  2. apt-get upgrade (to get your Breezy up-to-date first)
  3. Open /etc/apt/source.list
  4. Change all “breeze” to “dapper” in source.list
  5. apt-get update
  6. apt-get dist-upgrade

That’s about it! Now you have a Dapper server!

Sooooofa King Low

•June 12, 2006 • Leave a Comment

Yes, try to read out that tagline and see what you head….

Sofa King Ad

PHP Session Maximum Lifetime … arrgh!

•May 4, 2006 • Leave a Comment

Developed a PHP application recently and it performs flawlessly during testing stage. So, I guess! When it went live, I started receiving users complaints that they were kicked out half-way filling the forms. I tested it again, and everything went on smoothly. But users’ problem persist.

After scanning through web server’s log files, a pattern was found! The time between user login and being kicked out is exactly 45 minutes! This fact points the problem directly at the session management part of my program! I use PEAR HTTP::Session for session management and have the session expiry time set to 4 hours and idle time set to 1 hour:

HTTP_Session::setExpire(time() + 60*60*4);
HTTP_Session::setIdle(time() + 60*60);

That obviously has no effect on the 45 minutes maximum lifetime a session can have. After some more investigations, culprit was found. The problem lies in the PHP Session configuration option “session.gc_maxlifetime” in php.ini. Ignoring the fact that a session’s lifetime was set to 4 hours, PHP still look into php.ini for a maximum lifetime a session can have. And the default value, you guess it, is 1440 … i.e. 45 minutes! That’s ugly! Well, I don’t want to touch anything the default value set by PHP or ISP, so here’s my fix that save the day:

// Before including PEAR HTTP::Session
ini_set(’session.gc_maxlifetime’, ‘28800′); // Set maxlifetime to 4 hours, overwriting php.ini’s value

That’s it!

Bulk delete from Postfix queue

•January 20, 2006 • 1 Comment

To delete a message in Postfix queue, I normally find out the message id first from “postqueue -p” (or simply “mailq”) command. Once the message id is known, I simply issue the following command to delete that particular message (assume the message id is BA4491827DE):

# postsuper -d BA4491827DE

If there is only one message to delete, I can live with that. However, when there’s a bunch of messages (e.g. from a particular domain) you need to delete from the queue, the above method simply too much of a hassle (well, unless you want to delete *everything*, which would be #postsuper -d ALL). Postfix does not have a function for doing that. Luckily, a search on Google yielded this Perl script that does exactly what I want, removing message(s) from queue based on my keyword. Here is the content of that Perl script called “delete-from-mailq”:

#!/usr/bin/perl

$REGEXP = shift || die “no email-adress given (regexp-style, e.g. bl.*\@yahoo.com)!”;

@data = qx;
for (@data) {
if (/^(\w+)(\*|\!)?\s/) {
$queue_id = $1;
}
if($queue_id) {
if (/$REGEXP/i) {
$Q{$queue_id} = 1;
$queue_id = “”;
}
}
}

open(POSTSUPER,”|postsuper -d -”) || die “couldn’t open postsuper” ;

foreach (keys %Q) {
print POSTSUPER “$_\n”;
};
close(POSTSUPER);

Save the above script to a file say “delete-queue” in your home directory, and make it excutable:

# chmod 755 delete-queue

Usage

Delete all queued messages from or to the domain “iamspammer.com”

  • ./delete-queue iamspammer.com

Delete all queued messages to specific address “bogususer@mydomain.com”

  • ./delete-queue bogususer@mydomain.com

Delete all queued messages that begin with the word “bush” in the e-mail address:

  • ./delete-queue bush*\@whateverdomain.com

Delete all queued messages that contain the word “biz” in the e-mail address:

  • ./delete-queue biz

As simple as that! Now I have more time playing with other toys than deleting Postfix queue…

Bin Laden’s Message to Bush

•January 19, 2006 • Leave a Comment

Osama Bin Laden himself decided to send George Bush a letter in his own hand writing to let him know he was still in the game.

Bush opened the letter and it appeared to contain a single line of coded message:

370HSSV-0773H

Bush was baffled, so he e-mailed it to Condi Rice. Condi and her aides had no clue either, so they sent it to the FBI. No one could solve it at the FBI so it went to the CIA, then to the NSA. With no clue as to its meaning they eventually asked Britain’s MI6 for help.

Within a minute MI6 cabled the White House with this reply:

“Tell the President he’s holding the message upside down.”

Doing Algebra in your head?

•January 18, 2006 • Leave a Comment

Cover of Inner AlgebraOk, I admit it. I have not solved a single algebra equation after high school. Of all math classes I took, algebra is the subject I like the most, and was enjoying solving problems. The love for algebra gradually slip away when I attending university as I was major in an area totally unrelated to mathematics (particularly the use of algebra). Then, when I saw this site “Inner Algebra – How To Do Algebra In Your Head”, it suddenly calls upon my inner self about a long lost interest for the word starts with “A”…Algebra! Inner Algebra is a book written by Aaron Maxwell. In contrast to doing math on paper that we do normally, this book teaches techniques that help people to do the math mentally and thus making math easy. Sounds interesting! You may read the entire book at the author’s site, or show your support to the author by buying it from one of the online bookstores.

Reference: http://hilomath.com/inneralgebra/html/

A Linux distribution for graphic professionals?

•January 16, 2006 • Leave a Comment

A Linux distribution made specifically for imaging professionals and graphic artist? You heard it, and that’s exactly what Grafpup Linux is for. Built upon Puppy Linux, Grafpup Linux collected some of the best open source image processing and graphic editing software and packaged them in an amazing size of around 75MB! So, what’s exactly under the hook? Here’s a short list:

  • Gimp – the image editor of choice for Linux
  • Inkscape – one of the best Vector drawing programs around
  • Scribus – a complete desktop publishing solution
  • Nvu – a WYSIWYG web design application
  • Bluefish – a powerful code base web development tool used to quickly generate html, php, pear among others.
  • Gxine media player – playing back movies and music

Of course, there are a lot more applications that can be added when needed, such as OpenOffice.org 2.0.

Grafpup Linux can be run as live CD, and all your works will remain in your hard disk even after rebooting.

Resources:

MySQL Handling of UTF-8 Characters

•January 13, 2006 • Leave a Comment

While upgrading to MySQL 4.1, I noticed that Asian characters in UTF-8 were displayed as “?” in the PHP output. After some net searching, found that it’s due to MySQL’s default Collation setting. See, my MySQL built uses “latin1_general_ci” as default character set for connection even my database tables were setup in UTF-8. As a result, the quick work around without recompiling MySQL would be to tell MySQL that we are actually using UTF-8 to communicate with each other. So, here’s my MySQL connection codes using PEAR::DB: Continue reading ‘MySQL Handling of UTF-8 Characters’

Weather Forecasting Stone

•January 13, 2006 • Leave a Comment

Amazing stone!

Weather Forecasting Stone

Postfix Mail Queue Management

•January 13, 2006 • Leave a Comment

List queued messages:
# /usr/bin/mailq

Delete a queued message:
# postsuper -d mail_id

Delete all queued messages:
# postsuper -d ALL

Delete messages in deferred queue:
# postsuper -d ALL deferred

Holding mail from delivery:
# postsuper -h queue_id

Releasing hold messages:
# postsuper -H queue_id

Force sending of all queued messages:
# postfix flush

References: