Monday, July 31, 2006

MySQL - Socket error

On my Linux box, MySQL had been working fine.

Then, just a few days ago out of the blue for no apparent reason I started getting the following error.

Can't connect to local MySQL server through socket '/tmp/mysql.sock'

Now, we can't really say it is for no reason, obviously something in my system had changed. I am always messing around with that OS, without really understanding it.

Anyway, I found some great info here.
http://security.linux.com/article.pl?sid=04/08/19/1422204&tid=73&tid=35

I will have to go through all the info there and understand and implement it, but for now I only did the following three lines worth.

chown -R root /usr/local/mysql
chown -R mysql /usr/local/mysql/var
chgrp -R mysql /usr/local/mysql

And it worked! Problem solved for now.

Sunday, July 30, 2006

PHP - Numeric validation from forms

In the case where $quantity is a string like "aaa"
settype( $quantity, "integer" )

returns TRUE and $quantity becomes zero.

It is better to use is_numeric( $quantity )
This returns FALSE if $quantity is a string or blank.

Javascript - NaN

NaN means "not a number".

You cannot perform == or != operations against NaN.

NaN is not a string. And it is not a number either (duh!)

You
must use the function isNaN() to test for it.


In the beginning there was...

... me, and no doubt many others with a nagging feeling that they are constantly reinventing the wheel.

Enough, I say. Time to start enjoying life, not solving the same technical issues over and over.

I will employ this blog as a diary for any tech problems I solve, work-related or otherwise. Software, hardware, networks, settings, the whole shebang, including possibly any issues about the shebang line in Perl. Ha!

Looking back, I have had some modest success over the years solving these kinds of problems but now it just represents too many years of not taking notes.

And the beauty of blogs is that they allow you to write from anywhere and reference from anywhere.

Osaka

I've been making business trips to Osaka this month.

I really like that city, big wide boulevards and generally less crowded than Tokyo.

For some reason it has a bit of a "rough" image, in fact the Kansai area generally has this, but I find the people are very kind and kind of gentle. I like the softly lilting melodic tone of their accent.

Thursday, July 13, 2006

First-aid for net-surfing addiction

If you find yourself surfing to the same sites over and over out of reflexive instinct here is a solution.

Edit your hosts file.

What is the hosts file? It is a local DNS resolution file that your browser looks into first, before actually going out onto the internet to do the DNS resolution. It works the same way on both Windows and Linux.

On Windows it is located here (the file has no extension):
%SystemRoot%\system32\drivers\etc\hosts

On Linux it is simply here:
/etc

Add lines similar to the following, to the bottom of your hosts file.
0.0.0.0 www.siteiamaddictedto.com
0.0.0.0 www.baneofmyexistence.com

The 0.0.0.0 null IP address is an invalid destination. Hence when you try to surf to the site that is responsible for the loss of your last three jobs and your last two divorces your browser will go, yes exactly, nowhere!

Poof! A bright future as a responsible adult is yours at last.

Internet Explorer already has a facility within the browser settings to block sites. However Firefox and other browsers do not have this. The hosts file is used by all browsers so all you have to do is set it here and it will apply to all of them.