Wednesday, May 16, 2012

More Emails for Testing

Problem: Email is usually used as login username. There are times when you want to test a system by using several email accounts. And you usually need a lot more than the number of your existing email accounts. Now you think of opening another account from email providers.

Solution: With gmail, you can have only one account and use it with different addresses.

Here's how:
Assuming your email is myemail@gmail.com

Emails sent to the following:
myemail+001@gmail.com
myemail+002@gmail.com
myemail+003@gmail.com
myemail+010@gmail.com
... and so on

will be all sent to myemail@gmail.com.

Got the point?
Enjoy testing...

Wednesday, May 9, 2012

How to Check for null value in FreeMarker Template

Here it is:

<#if variable??>
    not null
<#else>
    it is null or is missing
</#if>

Monday, April 30, 2012

Modify SVN Ignore List in Eclipse/STS

You can edit the ignore list of SVN in Eclipse IDE or SpringSource Tool Suite but it is not obvious in the user interface.

Here's how:

Right-click on the project
Click Team > Show Properties
Right click the row containing svn:ignore and click Modify Property

Happy Editing...

Friday, February 17, 2012

Rename Set Featured Image in Wordpress

Posts in Wordpress can have their own featured image when enabled.
Now, here's a way to modify both the 'Featured Image' title and the 'Set Featured Image' link text.

Just add the follwing code to your theme's functions.php

function customizeFeaturedImageLinkTitle( $content ) {
  return $content = str_replace( __('Set featured image'), __('Set DefaultMessage image'), $content);
}

function customizeFeaturedImageTitle($translated) {
  return str_ireplace('Featured Image', 'DefaultMessage Image', $translated);
}

add_filter('gettext','catalogph_customizeFeaturedImageTitle');
add_filter('ngettext','catalogph_customizeFeaturedImageTitle');

Tuesday, January 31, 2012

How to Disable Context Menu on jsTree

To disable the jsTree context menu, just add the following option:

"disableContextMenu" : true

Just wondering why it is so hard to find this online.

Monday, October 17, 2011

Determining if a Checkbox is Checked Using jQuery

A checkbox can be checked initially by using

<input type="checkbox" id="yourCheckBox" name="yourCheckBox" checked="checked" />

or

$("#yourCheckBox").attr('checked', true);


When one of the code above is used, the following two lines of code can fail in retrieving the correct value of the checkbox:

$('#yourCheckBox').attr("checked")

and

$('#yourCheckBox').val()


A better way is to use the following jQuery code instead:

$('#yourCheckBox').is(":checked")

My office mate and I took almost an hour to figure out that bug in our project code.

Saturday, October 8, 2011

Using and Creating a MySQL Dump

To use a database dump:
mysql -u <username> -p  <database_schema> < schema_dump.sql

To create a dump for the whole database:
mysqldump -u <username> -p  <database_schema> > schema_dump.sql

To create a dump of only a specific table of the database:
mysqldump -u <username> -p <database_schema> <table_name> > table_dump.sql

To create a compressed dump all of the databases on your MySQL:
mysqldump --all-databases -p | bzip2 -c > databasebackup.sql.bz2

Just make sure to enter the correct values on the parts enclosed between < and >.