Javascript Show Caller Function

arguments.callee.caller.toString()

Posted in Programming | Tagged | Leave a comment

I Thank You Lord

I thank you Lord for all your blessings to me
I thank you Lord for all the trials that comes my way
I thank you Lord for all the strength when my weakness puts me down
I thank you Lord I am safe in your hands

I thank you Lord for the life I have
For the strength and the courage to carry on
I thank you Lord for the friends I meet
For the warmth they’ve comforted us on coldest days
Many things, many times I’ve missed the mark
You have never forsaken me as your child

I thank you Lord for the days of my life
For the laughter and the tears and the pain
I thank you Lord for your guiding hand
I have missed the way but you came to hold my hand

(Words and music by Raymond S. Usbal on 20 June 2011)

Posted in Inspirational, Poetry, Worship | Tagged | Leave a comment

How to get next MySQL insert id

function getMysqlInsertID($tablename)
{
$next_increment = 0;
$qShowStatus = "SHOW TABLE STATUS LIKE '$tablename'";
$qShowStatusResult = mysql_query($qShowStatus) or die ( "Query failed: " . mysql_error() . "<br/>" . $qShowStatus );

$row = mysql_fetch_assoc($qShowStatusResult);
$next_increment = $row['Auto_increment'];
return $next_increment;
}

Posted in MySQL, PHP | Tagged , | Leave a comment

mysqldump results to wrong characters

Try the following:

$ mysqldump -u<user> -p dbsource tablein --where="products_id >= 20000028 and products_id <= 25531404" --default-character-set=UTF8 > dumpfile.sql

$ mysql -u<user> -p dbtarget --default-character-set=UTF8  < dumpfile.sql

Posted in MySQL | Tagged , | Leave a comment

Run php as cronjob with safe_mode setting

/usr/bin/php -d safe_mode=Off script_to_run.php

Posted in PHP | Tagged , | Leave a comment

How to use SQL where like in()

SELECT column
FROM table
WHERE column LIKE '%like1%' OR
column LIKE '%like2%' OR column LIKE '%etc2%'

can be written simply as

SELECT column
FROM table
WHERE column REGEXP 'like1|like2|etc'

Posted in MySQL, SQL | Tagged , , | Leave a comment

Add custom directory to Python module search path

Ubuntu:

Add .pth file to /usr/local/lib/python2.6/dist-packages/
/usr/local/lib/python2.6/dist-packages/workarea.python.modules.pth

.pth file contains the path to your modules
/home/raymond/workarea/python/modules

Modifying Python’s Search Path

Posted in Programming, python | Tagged , , | Leave a comment

Linux Time Synchronization

# ntpdate pool.ntp.org
12 Nov 11:39:23 ntpdate[13390]: the NTP socket is in use, exiting

If the socket error shows, it means that your computer’s time is already synchronized by ntp service.

Posted in Linux, Linux Administration | Tagged , | Leave a comment

ctags for php

$ cd /path/to/phpcode
$ ctags -f /output/tags \
-h ".php" -R \
--exclude="\.svn" \
--totals=yes \
--tag-relative=yes \
--PHP-kinds=+cf \
--regex-PHP='/abstract class ([^ ]*)/\1/c/' \
--regex-PHP='/interface ([^ ]*)/\1/c/' \
--regex-PHP='/(public |static |abstract |protected |private )+function ([^ (]*)/\2/f/'

exuberant ctags with PHP in Vim

Posted in Editor, PHP, vim | Tagged , | Leave a comment

PHP deprecated eregi, ereg_replace, split replacement

Deprecated
      eregi($pattern, $haystack);
Replacement
      preg_match('/' . $pattern . '/i', $haystack);

Deprecated
      ereg_replace($pattern, $replacement, $haystack);
Replacement
      preg_replace('/' . $pattern . '/', $replacement, $haystack);

Deprecated
      split("[:,]", "1:2,3:4,5:6");
Replacement
      preg_split("/[:,]/", "1:2,3:4,5:6");

Differences from POSIX regex

Posted in PHP | Tagged , , | Leave a comment