Category Archives: Others

Excel – Set Default Date Format

In the Data Validation dialog box, click Settings tab, and then choose Custom from the Allow drop down list, then enter this formula: =AND(ISNUMBER(B2),LEFT(CELL(“format”,B2),1)=”D”)

Posted in Others | Leave a comment

Only one Perl instance – lock script

Use File::NFSLock to get an exclusive lock on the script itself: use Fcntl qw(LOCK_EX LOCK_NB); use File::NFSLock; # Try to get an exclusive lock on myself. my $lock = File::NFSLock->new($0, LOCK_EX|LOCK_NB); die “$0 is already running!\n” unless $lock; Alternatively use … Continue reading

Posted in Others | Tagged | Leave a comment

php – check if Internet Explorer

if(preg_match(‘/(?i)msie [1-9]\.0/’,$_SERVER[‘HTTP_USER_AGENT’])) { do/say something } else { do/say something else } Though the above won’t work for IE 11. As $_SERVER[‘HTTP_USER_AGENT’]  returns a string containing the ‘Trident’ substring for IE, we will look for this text to determine if … Continue reading

Posted in Others | Tagged | Leave a comment

HTML – center an image vertically & horizontally

<body> <table id=”table-foo”> <tr><td> <img sr=”foo.png” /> </td></tr> </table> </body> <style type=”text/css”> html, body { height: 100%; } #table-foo { width: 100%; height: 100%; text-align: center; vertical-align: middle; } #table-foo img { display: block; margin: 0 auto; } </style>

Posted in Others | Tagged , | 1 Comment