Category: quickfixes

  • 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.

  • 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…

  • 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…

  • 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:…

  • GNU sed, replace search string with contents of a file

    Say, I want to replace the text “replace me” in all the .txt files in the current directory with the contents of modified.js file find . -name “*.txt” -print0 | xargs -0 sed -i -e ‘s/replace me/cat modified.js/e’ Notice the ‘/e’ at the end and that seems to do the trick.

  • jQuery empty(),remove() and Thickbox

    I am a great fan of thickbox and I have used it for a long time. Recently I came across a situation where trying to close a modal that had a table with around 7000 rows (each 8 columns) crashed the tab in Chrome and took a very long time in Firefox. I went through…

  • Munin: Could not open required defaults file: /root/.my.cnf

    For some reason I kept getting this error (even when the file was readable by all) in one of the munin (mysql slave) plugins that I had written. So this was the solution that worked for me; under the [mysql*] section in /etc/munin/plugin-conf.d/munin-node I added this: env.mysqlopts -u{user} -p{password} and in my plugin I did…

  • Fixing: “unknown terminal type” in shell

    Assuming you are using bash Add the following to ~/.bash_profile TERM=vt100 export TERM and then from shell source ~/.bash_profile Note: ‘vt100’ could be replaced with something similar in /usr/share/terminfo/