trk7's blog

    • About
Illustration of a bird flying.
  • 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…

    June 15, 2011
  • gzip/bzip2 taking too long to compress large files

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

    May 3, 2011
  • 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`…

    April 20, 2011
  • 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…

    April 12, 2011
  • 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…

    April 7, 2011
  • 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.

    March 29, 2011
  • 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.

    March 21, 2011
  • SSMTP, Crontab gotchas

    I had a few cron entries that did not run and for a long a time I had no idea why. I had the MAILTO variable set at the top of the crontab and I was expecting to be mailed the output of the cron entries. I was surprised when that did not happen. Looking…

    January 24, 2011
  • Using GNU grep to output just the match(es) and not the entire line containing the match(es)

    echo “hello there.” | grep -o “ello t” ello t The flag ‘o’ (not Zero) does the trick. From the man page: -o, –only-matching Show only the part of a matching line that matches PATTERN. I couldn’t find that flag as an option in the BSD Grep man page. So this might only be available…

    January 24, 2011
  • PHP, MongoDB, findAndModify

    findAndModify is not supported by the current version of the PHP MongoDB driver, so I had to use the following code $feed = $db->command(array(‘findAndModify’ => ‘feedList’, ‘query’ => array(‘$where’ => new MongoCode(‘ function(){ return ((this.inProgress == false) || (currentTime >= (this.lastUpdated + this.updateFrequency)))); }’, array(‘currentTime’ => $start))), ‘update’ => array(‘$set’ => array(‘inProgress’ => true)))); Where:…

    October 21, 2010
←Previous Page
1 … 3 4 5 6 7 … 13
Next Page→

trk7's blog

Proudly powered by WordPress