ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

First thing in the morning, I got this mysql server error. ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) Apparently, /tmp/mysql.sock is missing. I know that’s the right path, but the file is not there. I restarted the mysql server by press the “Start MySQL Server” button, but it’s not running. I ran mysqld, but it gave me more errors and failed to start. I ended up making it work by providing a my.cnf file, which I hadn’t needed. ...

November 28, 2011 · 1 min · birdchan

Carrots

November 17, 2011 · 0 min · birdchan

Math problem

Math problems are getting much trickier nowadays…

November 14, 2011 · 1 min · birdchan

PHP command line memory limit error

Very often, when data size gets bigger and bigger, some scripts will break due to default memory limit. I got the following error today. Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 72 bytes) in /someDir/myScript.php on line 15 Segmentation fault: 11 I checked my php help. I am using version 5.3.6. $ php -h Usage: php [options] [-f] [--] [args...] php [options] -r [--] [args...] php [options] [-B ] -R [-E ] [--] [args...] php [options] [-B ] -F [-E ] [--] [args...] php [options] -- [args...] php [options] -a -a Run as interactive shell -c | Look for php.ini file in this directory -n No php.ini file will be used -d foo[=bar] Define INI entry foo with value 'bar' -e Generate extended information for debugger/profiler -f Parse and execute . -h This help -i PHP information -l Syntax check only (lint) -m Show compiled in modules -r Run PHP without using script tags -B Run PHP before processing input lines -R Run PHP for every input line -F Parse and execute for every input line -E Run PHP after processing all input lines -H Hide any passed arguments from external tools. -s Output HTML syntax highlighted source. -v Version number -w Output source with stripped comments and whitespace. -z Load Zend extension . args... Arguments passed to script. Use -- args when first argument starts with - or script is read from stdin --ini Show configuration file names --rf Show information about function . --rc Show information about class . --re Show information about extension . --ri Show configuration for extension . Looks like -d with do it. So I ran the following: php -d memory_limit=512M myScript.php It worked fine. If you can afford to change your php.ini file, use - -ini to see where your php.ini file is, then make your changes accordingly. You can also use -n to ignore your php.ini file, but then you will be using default parameters which may be even harder to debug. ...

November 11, 2011 · 2 min · birdchan

Validate line by line

Here is a good compilation of codes doing string format validation in C#, VB.NET, Java, Javascript, PHP, Perl, Python, and Ruby. It’s a good reference page. http://answers.oreilly.com/topic/224-how-to-search-line-by-line-with-a-regular-expression/

November 11, 2011 · 1 min · birdchan

Stop UTF 8 with javascript

Below is how you can detect non-ascii characters with javascript. s = $("#something").val(); for (var i=0; n = 128) { alert('Invalid character '' + String.fromCharCode(c) + '''); return false; // or throw an error } } Of course if you have to take in non-ascii values, then be prepared to set up your environments first. The links below will help. http://us.php.net/manual/en/function.base64-encode.php http://pureform.wordpress.com/2008/03/23/make-your-website-completely-utf-8-friendly/

November 9, 2011 · 1 min · birdchan

max_allowed_packet error during mysqldump

Got a “max_allowed_packet” error during mysqldump. This happened after I added a longblob to one of my tables. Below is the error: mysqldump --routines --user=root -p localDB > backup.mysql.txt mysqldump: Error 2020: Got packet bigger than 'max_allowed_packet' bytes when dumping table `table2` at row: 86 It turns out max_allowed_packet is set to something less than whatever is in my row 86. Longblob can go up to 4Gb so I will need to override the max_allowed_packet value. I found the following way the easiest to re-enable the dump. ...

November 8, 2011 · 1 min · birdchan

Quantum Levitation

[youtube &w=560&h=315] It’s no longer something we read from scientific novels. Amazing! BTW, I have no idea how that guy just picks up the superconductor. It is supposed to be extremely cold, right?

November 8, 2011 · 1 min · birdchan

launchctl list

Here is what the output of “launchctl list” means: list [-x] [label] With no arguments, list all of the jobs loaded into launchd in three columns. The first column displays the PID of the job if it is running. The second column displays the last exit status of the job. If the number in this column is negative, it repre- sents the negative of the signal which killed the job. Thus, "-15" would indicate that the job was terminated with SIGTERM. The third column is the job's label. So when you run “launchctl list | grep something”, the columns correspond to: 1. PID (if it’s running) 2. last exit status code 3. process name ...

November 2, 2011 · 1 min · birdchan

Gmail app on iphone

Here is the link: http://itunes.apple.com/app/gmail/id422689480?mt=8

November 2, 2011 · 1 min · birdchan