Author: k7

  • Backgrounded PHP jobs in ‘STOPPED’ state

    This could be specific to the PHP package from Ubuntu. Please consider the following a disclaimer. $ php -v PHP 5.3.5-1ubuntu7.2 with Suhosin-Patch (cli) (built: May 2 2011 23:00:17) Copyright (c) 1997-2009 The PHP Group Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies with Xdebug v2.1.0, Copyright (c) 2002-2010, by Derick Rethans $ cat /etc/lsb-release…

  • Parrallel processing from the bash commandline

    for i in `seq 1 40`; do echo $i; /tmp/script.sh >> /tmp/script.out 2>&1 & done Note the lack of ‘;’ before ‘done’. The ‘&’ indicates the end of the statement.

  • Checking for the existence of domains from commandline in Bash

    while read line; do wget –quiet –spider –timeout=10 $line; if [ $? -ne 0 ]; then echo $line; fi; done < "/tmp/domains.txt" /tmp/domains.txt would hold the list of domain names separated by newline. Note this is just a quick hack and not entirely reliable.

  • myisamcheck running out of tmp space

    Recently I was running myisamcheck on an entire database housed inside a vserver. And, by default vserver mounts a 16MB ramfs on /tmp. This obviously is not an ideal solution when you are running a DB server that has a few tables that are around 20GB. So I had to specify a different directory for…

  • gzip/bzip2 taking too long to compress large files

    Use pbzip2. I have noticed significant reduction in time while compressing files larger than 1GB.

  • Getting rid of MySQL Warning: Truncated incorrect DOUBLE value

    If you come across a cryptic warning like this: | Warning | 1292 | Truncated incorrect DOUBLE value: ‘xxxxxxx’ on running a MySQL query, it could be caused by using a numeric value against a CHAR/VARCHAR column. —assuming `name` is a CHAR/VARCHAR column —the following query might cause warnings SELECT * FROM `t1` where `name`…

  • PHP as a replacement for sed/awk

    I had gotten sick of not being able to do what I wanted to do with sed/awk – partly because I am not too familiar with those – and, was investigating replacements for those. Many people seem to be using perl and since I wasn’t too familiar with Perl as well, I started thinking about…

  • Regular Expression to check for comma separated list of Integers

    //get rid of all kinds of spaces $IDs = preg_replace(‘/s+/’, ”, $inputIDs); if(!preg_match(”/^\d+$|^(\d+,)+\d+$/”, $IDs)) { echo “Invalid Input”; } You could use the validated IDs above in a SQL like the this: SELECT * FROM t1 WHERE id IN($IDs) Disclaimer: I am not going to be responsible for any kind of SQL injection resulting from…

  • Pentaho Spoon error

    If you get an error like this: Error connecting to database: (using class org.gjt.mm.mysql.Driver) Unknown initial character set index ‘192’ received from server. Initial client character set can be forced via the ‘characterEncoding’ property. Then in the database connection settings, do as highlighted in the screenshot below.

  • Bulk Insert while using PDO

    If you are looking to Bulk Insert while using PDO and want to use bound parameters (to prevent SQL injection), please have a look at this solution here: http://stackoverflow.com/questions/4629022/how-to-insert-an-array-into-a-single-mysql-prepared-statement-w-php-and-pdo Quite simple and does the job.