<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Gary Tay</title>
	<atom:link href="http://www.garytay.net/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.garytay.net</link>
	<description>Technology, Review and Rants.</description>
	<lastBuildDate>Sun, 23 Oct 2011 10:50:24 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Javascript &#8220;popup&#8221; announcements via Div and PHP</title>
		<link>http://www.garytay.net/2011-10-23/javascript-popup-announcements-div-php/</link>
		<comments>http://www.garytay.net/2011-10-23/javascript-popup-announcements-div-php/#comments</comments>
		<pubDate>Sun, 23 Oct 2011 10:10:53 +0000</pubDate>
		<dc:creator>Gary Tay</dc:creator>
				<category><![CDATA[Codes]]></category>

		<guid isPermaLink="false">http://www.garytay.net/?p=46</guid>
		<description><![CDATA[My friend&#8217;s company has recently been hit by frauds claiming to be her franchises. To protect her company and image she asked me to code a notification for her site. However announcements like theses are kind of ugly and irritating after a while and also nowadays browsers block out popups for browsers so we can&#8217;t [...]]]></description>
			<content:encoded><![CDATA[<p>My friend&#8217;s company has recently been hit by frauds claiming to be her franchises. To protect her company and image she asked me to code a notification for her site.</p>
<p>However announcements like theses are kind of ugly and irritating after a while and also nowadays browsers block out popups for browsers so we can&#8217;t put it into another page.</p>
<p>Then I came up with a nice solution, this not-so-elegantly coded in-line DIV announcement is simple and only uses standard javascript and CSS. Add in a little PHP to cause it to pop out only on 1st page view and no longer gets in the way after that.</p>
<p><a title="DIV notification demo" href="http://www.garytay.net/announcement_demo.php" target="_blank"> Click this link for DEMO.</a> or <a href="http://www.jiang.edu.sg" target="_blank">visit actual site.</a></p>
<p>Download the code: <a href="http://www.garytay.net/wp-content/uploads/2011/10/announcement_demo.zip">Div announcement script demo code</a></p>
<div id="attachment_48" class="wp-caption aligncenter" style="width: 410px"><a href="http://www.garytay.net/wp-content/uploads/2011/10/j_notification.jpg"><img class="size-full wp-image-48" title="j_notification" src="http://www.garytay.net/wp-content/uploads/2011/10/j_notification.jpg" alt="Sample announcement div" width="400" height="480" /></a><p class="wp-caption-text">Announcement on page</p></div>
<h2>INSTRUCTIONS</h2>
<p><strong>The code for your DIV</strong></p>
<p>&lt;div style=&#8221;height:<span style="color: #ff0000;"><strong>570px</strong></span>; width:<span style="color: #ff0000;"><strong>440px</strong></span>; border:1px solid #DDD; padding:8px; top:10px; left:50%; margin-left:<span style="color: #ff0000;">-220px</span>; position:absolute; background-color:#FFFFFF;&#8221; id=&#8221;<span style="color: #ff0000;">announcement</span>&#8220;&gt;<span style="color: #0000ff;">My Announcement goes here</span>&lt;/div&gt;</p>
<p>The <strong><span style="color: #ff0000;">red attributes</span></strong> can be modified to your required<span style="color: #ff0000;"><strong> id/height/width</strong></span>. Also note the &#8220;margin-left&#8221; should be set to exactly <strong>HALF</strong> of the width that you changed, that would bring the announcement into the center of the screen.</p>
<p><strong>The code for closing the DIV (Button)<br />
</strong></p>
<p>&lt;input type=&#8221;button&#8221; onclick=&#8221;document.getElementById(&#8216;<span style="color: #ff0000;">announcement</span>&#8216;).style.display=&#8217;none&#8217;;&#8221; value=&#8221;Close announcement&#8221;/&gt;</p>
<p>Make sure the <strong>getElementById</strong> is your DIV id for the main announcement.</p>
<p>&nbsp;</p>
<p><strong>The PHP for loading the DIV at first visit. </strong><em>This needs to be place before any output on your script (ie before &lt;html&gt;).</em></p>
<p>&lt;?php<br />
//Part 1 placed before any output on screen.<br />
session_start();</p>
<p>if($_SESSION[load_notice]!=1)<br />
{<br />
$_SESSION[load_notice]=1;<br />
$output_notice =1;<br />
}<br />
php?&gt;</p>
<p><strong>The 2nd part of the script should be placed any where near the top after the body block.</strong></p>
<p><strong></strong>&lt;?php<br />
//Part 2 Announcement code<br />
if($output_notice==1)<br />
{<br />
?&gt;</p>
<p>INSERT YOUR ANNOUNCEMENT DIV CODE HERE.</p>
<p>&lt;?php<br />
} //End if<br />
?&gt;</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.garytay.net/2011-10-23/javascript-popup-announcements-div-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Masking your gmail account alias when replying emails</title>
		<link>http://www.garytay.net/2011-07-27/masking-your-gmail-account-alias-when-replying-emails/</link>
		<comments>http://www.garytay.net/2011-07-27/masking-your-gmail-account-alias-when-replying-emails/#comments</comments>
		<pubDate>Wed, 27 Jul 2011 04:25:00 +0000</pubDate>
		<dc:creator>Gary Tay</dc:creator>
				<category><![CDATA[Codes]]></category>

		<guid isPermaLink="false">http://www.garytay.net/?p=44</guid>
		<description><![CDATA[When sending email out from an email domain forwarded to gmail (Send mail as), gmail appends the orginal (gmail) email into the header files of the email (it could be your private gmail account) along with the reply email. In order to hide/mask that email use this workaround. Goto Mail Settings. Click &#8220;edit info&#8221; for [...]]]></description>
			<content:encoded><![CDATA[<p>When sending email out from an email domain forwarded to gmail (Send mail as), gmail appends the orginal (gmail) email into the header files of the email (it could be your private gmail account) along with the reply email.</p>
<p>In order to hide/mask that email use this workaround.</p>
<ul>
<li>Goto Mail Settings.</li>
<li>Click &#8220;edit info&#8221; for Alias.</li>
<li>Click &#8220;Next Step&#8221; (to skip the Names screen).</li>
<li>Choose the “Send through xxx.com <strong>SMTP</strong> servers (recommended for professional domains&#8230;”</li>
<li>For <strong>SMTP</strong> Server, type “<strong>smtp</strong>.<strong>gmail</strong>.com” and choose port 465.</li>
<li>Type your <strong>GMAIL</strong> username and your <strong>GMAIL</strong> password in the respective fields</li>
<li>Check the box “Always use a secure connection”</li>
<li>Save Changes and you’re done!</li>
</ul>
<p>Copied with permission from danieltsou.com.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.garytay.net/2011-07-27/masking-your-gmail-account-alias-when-replying-emails/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Youtube &amp; Vimeo URL preg_match</title>
		<link>http://www.garytay.net/2011-06-29/youtube-vimeo-url-preg_match/</link>
		<comments>http://www.garytay.net/2011-06-29/youtube-vimeo-url-preg_match/#comments</comments>
		<pubDate>Wed, 29 Jun 2011 04:11:24 +0000</pubDate>
		<dc:creator>Gary Tay</dc:creator>
				<category><![CDATA[Codes]]></category>

		<guid isPermaLink="false">http://www.garytay.net/?p=38</guid>
		<description><![CDATA[Quick reference for Grabbing video IDs from Youtube and Vimeo. *Note $string is the string containing youtube or vimeo link, can also contain rubbish. ** Note2: Video ID will be return in $output. Different PregMatch will result in Video ID being located differently in $output. Youtube There&#8217;s 2 formats, the latter youtu.be was launch fairly [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Quick reference for Grabbing video IDs from Youtube and Vimeo.</strong></p>
<p>*Note $string is the string containing youtube or vimeo link, can also contain rubbish.<br />
** Note2: Video ID will be return in $output. Different PregMatch will result in Video ID being located differently in $output.</p>
<p><span style="text-decoration: underline;"><strong>Youtube</strong></span></p>
<p>There&#8217;s 2 formats, the latter youtu.be was launch fairly recently. Both formats uses the same video ID so it&#8217;s just 2 different extraction methods.</p>
<p><span style="text-decoration: underline;"><strong>URL Format 1 (Traditional </strong><strong>http://www.youtube.com/watch?v=zWw-823VTY0</strong><strong>)</strong></span></p>
<p><code>preg_match_all('#(http://www.youtube.com)?/(v/([-|~_0-9A-Za-z]+)|watch\?v\=([-|~_0-9A-Za-z]+)&amp;?.*?)#i',$string,$output);</code></p>
<p><strong>$output[4][0]</strong> will contain the Video ID.</p>
<p><span style="text-decoration: underline;"><strong>URL Format 2 (New http://youtu.be/asdasdasd)</strong></span></p>
<p><code>preg_match_all('#(http://youtu.be/)([-|~_0-9A-Za-z]+)#i',$string,$output);</code></p>
<p><strong>$output[2][0]</strong> will contain the Video ID.</p>
<p><span style="text-decoration: underline;"><strong>Vimeo (http://player.vimeo.com/video/1234567)</strong></span></p>
<p><code>preg_match_all('#(http://vimeo.com)/([0-9]+)#i',$string,$output);</code></p>
<p><strong>$output[2][0]</strong> will contain the Video ID.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.garytay.net/2011-06-29/youtube-vimeo-url-preg_match/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[Solution] The original puzzle Zebra Puzzle by Einstein</title>
		<link>http://www.garytay.net/2010-12-03/solution-the-original-puzzle-zebra-puzzle-by-einstein/</link>
		<comments>http://www.garytay.net/2010-12-03/solution-the-original-puzzle-zebra-puzzle-by-einstein/#comments</comments>
		<pubDate>Fri, 03 Dec 2010 02:52:01 +0000</pubDate>
		<dc:creator>Gary Tay</dc:creator>
				<category><![CDATA[Puzzles]]></category>

		<guid isPermaLink="false">http://www.garytay.net/?p=18</guid>
		<description><![CDATA[My &#8220;Tetris&#8221; style solution to Einstein&#8217;s Zebra Puzzle. Using visualization to solve instead of pure logic. Excel : http://www.garytay.net/files/einstein_quiz.xlsx HTML : http://www.garytay.net/files/einstein_quiz.htm]]></description>
			<content:encoded><![CDATA[<p style="text-align: left;">My &#8220;Tetris&#8221; style solution to Einstein&#8217;s Zebra Puzzle. Using visualization to solve instead of pure logic.</p>
<p>Excel : <a href="http://www.garytay.net/files/einstein_quiz.xlsx">http://www.garytay.net/files/einstein_quiz.xlsx</a></p>
<p>HTML : <a href="http://www.garytay.net/files/einstein_quiz.htm">http://www.garytay.net/files/einstein_quiz.htm</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.garytay.net/2010-12-03/solution-the-original-puzzle-zebra-puzzle-by-einstein/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Social Website Programming &#8211; Walls, Friends and other personal lists</title>
		<link>http://www.garytay.net/2010-11-23/php-social-website-programming-walls-friends-and-other-personal-lists/</link>
		<comments>http://www.garytay.net/2010-11-23/php-social-website-programming-walls-friends-and-other-personal-lists/#comments</comments>
		<pubDate>Mon, 22 Nov 2010 16:48:29 +0000</pubDate>
		<dc:creator>Gary Tay</dc:creator>
				<category><![CDATA[Codes]]></category>

		<guid isPermaLink="false">http://www.garytay.net/2010-11-23/php-social-website-programming-walls-friends-and-other-personal-lists/</guid>
		<description><![CDATA[Recently completed a social media website that has several facebook/twitter aspects, one of the main concerns is something known as the super-user, a user that&#8217;s so popular that each action by this user will impact thousands of other connected users on the site. Designing for scalability and speed for this range of users require some [...]]]></description>
			<content:encoded><![CDATA[<p>Recently completed a social media website that has several facebook/twitter aspects, one of the main concerns is something known as the super-user, a user that&#8217;s so popular that each action by this user will impact thousands of other connected users on the site. Designing for scalability and speed for this range of users require some special thinking.</p>
<p>I&#8217;ve came up with a theory that &#8220;Normal&#8221; MySQL tables would be severally taxed if we let the DB classes run each time a user refreshes his or her walls.</p>
<p>Databases are &#8220;usually&#8221; meant for storing data (usually) in 3rd normal form but social sites tend to have many lists such as friends, messages (listed into walls),a term i&#8217;ve regarded as &#8220;relationship&#8221; data. The problem with this data is that it&#8217;s repetitive and somewhat useless beyond the scope of the individual. Making sense not to store such data into table but into the person&#8217;s record (row) as longtext/blob, and retrieving when needed, this blob isn&#8217;t indexed in any way so it&#8217;s just sitting in the row minding it&#8217;s own business until needed.</p>
<p>PHP seems to have a solution for that http://www.php.net/manual/en/function.serialize.php unfortunately that solution isn&#8217;t viable in this circumstance.</p>
<p><u>Imagine this scenerio</u><br />
1) Users have many (many) friends<br />
2) When the user updates his wall, his friends wall get updated (friends in thousands?!) with the same message<br />
3) Running a PHP script that pulls out ALL his friends&#8217; wall and updating it then returning the new data back into their wall would probably result in hitting the memory max and stopping the script. Having something like this run on the server would introduce tons of load spikes.<br />
4) PHP arrays are heavy in memory and SLOW, searching and moving data in-out of arrays are slow too.<br />
5) Serialized PHP arrays are hard to read and even harder to manipulate in DB w/o screwing up the formatting.<br />
<u>So what do you do?</u><br />
1) Maintain all &#8220;non-relationship&#8221; data in 3rd normal form in their respective tables. Use primary keys (auto increments).<br />
2) The primary user table would have several &#8220;blob&#8221;s to store things like list of friends, personal wall in the following format</p>
<p><code>'1','2','3','4','525235'</code></p>
<p>3) Use CSV to maintain user&#8217;s friends and wall. CSV being just &#8220;string&#8221; would be easily manipulated in PHP and in SQL, you can append directly to the front of several thousand friends&#8217; wall with just a single SQL statement</p>
<p><code></p>
<p>$friend_list = SELECT friends FROM user_table; //Pseudo text, returns friend's list in '1','2','555','666' format which is directly pumped into the next SQL statement</p>
<p>UPDATE user_table SET wall = REPLACE(TRIM(BOTH ',' FROM CONCAT_WS(',','\'".$message_id."\'', wall)), ',,', ',') WHERE uid IN (".$friend_list.")");<br />
</code></p>
<p>4) In PHP to make things even simplier use this CSVList class (shameless created by me) to manipulate the CSV string</p>
<p>Download it here: <a href="http://www.phpclasses.org/package/6218-PHP-Manipulate-a-list-of-entries-in-a-string-of-separa.html">http://www.phpclasses.org/package/6218-PHP-Manipulate-a-list-of-entries-in-a-string-of-separa.html</a></p>
<p>The above class allow quick search for a variable in the CSV, mimics SQL LIKE (% X %), exports CSV and in array, exports a certain range in the CSV (aka LIMIT 20,30 &#8211; useful for pagination), counts no of variables in the CSV and some other stuff, so it&#8217;s worth checking it out. By itself, it&#8217;s possible to handle very high range of variables, 20-30 times higher then if the variables were stored in a simple (standard/non-assoc) php array. It&#8217;s alot faster then looping through an array to check for existence or matches of a variable.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.garytay.net/2010-11-23/php-social-website-programming-walls-friends-and-other-personal-lists/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Google Charts</title>
		<link>http://www.garytay.net/2008-01-29/google-charts/</link>
		<comments>http://www.garytay.net/2008-01-29/google-charts/#comments</comments>
		<pubDate>Tue, 29 Jan 2008 13:02:50 +0000</pubDate>
		<dc:creator>Gary Tay</dc:creator>
				<category><![CDATA[Codes]]></category>

		<guid isPermaLink="false">http://www.garytay.net/2008-01-29/google-charts/</guid>
		<description><![CDATA[I&#8217;ve been playing around with google charts for a while now&#8230; Google charts allow creation of charts via URL (returns a image) Sample : http://chart.apis.google.com/chart? chs=500x150&#38;chd=t:40.0,20.0,10.0,58.0,95.0 &#38;cht=lc&#38;chxt=x,y &#38;chxl=0:%7CSep%7COct%7CNov%7CDec%7CJan%7C1:%7C%7CGary%27s%20Ego Good for webdesigners and coders! To see more visit http://code.google.com/apis/chart/]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been playing around with google charts for a while now&#8230;</p>
<p>Google charts allow creation of charts via URL (returns a image)</p>
<p>Sample :<br />
<img src="http://chart.apis.google.com/chart?chs=500x150&amp;chd=t:40.0,20.0,10.0,58.0,95.0&amp;cht=lc&amp;chxt=x,y&amp;chxl=0:%7CSep%7COct%7CNov%7CDec%7CJan%7C1:%7C%7CGary%27s%20Ego" /><br />
<code>http://chart.apis.google.com/chart?<br />
chs=500x150&amp;chd=t:40.0,20.0,10.0,58.0,95.0<br />
&amp;cht=lc&amp;chxt=x,y<br />
&amp;chxl=0:%7CSep%7COct%7CNov%7CDec%7CJan%7C1:%7C%7CGary%27s%20Ego</code></p>
<p>Good for webdesigners and coders!</p>
<p>To see more visit <a href="http://code.google.com/apis/chart/">http://code.google.com/apis/chart/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.garytay.net/2008-01-29/google-charts/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP tricks Part 1</title>
		<link>http://www.garytay.net/2007-10-26/php-tricks/</link>
		<comments>http://www.garytay.net/2007-10-26/php-tricks/#comments</comments>
		<pubDate>Fri, 26 Oct 2007 14:47:16 +0000</pubDate>
		<dc:creator>Gary Tay</dc:creator>
				<category><![CDATA[Codes]]></category>

		<guid isPermaLink="false">http://www.garytay.net/2007-10-26/php-tricks/</guid>
		<description><![CDATA[I&#8217;m going to post a few php tricks here and there for my audience (if there&#8217;s any) to have fun with. Trick 1 : Triple Equal &#8220;===&#8221; Usage : if($a===$b) Reason : === is used to make like easier for the (advanced) php programmer. It forces a comparison within the same type thus eliminating some [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m going to post a few php tricks here and there for my audience (if there&#8217;s any) to have fun with.</p>
<p><strong>Trick 1 : Triple Equal &#8220;===&#8221;</strong><br />
Usage : if($a===$b)<br />
Reason : === is used to make like easier for the (advanced) php programmer. It forces a comparison within the same type thus eliminating some programming checking codes.</p>
<pre class="wp-code-highlight prettyprint">
$input = 1;

if($input == true)
{
    echo &quot;input is not boolean true but it passed anyway!&quot;;
}

if($input === true)
{
   echo &quot;input needs to be boolean true to pass this if statement&quot;;
}

//What's so useful?

if($_GET[something]===0)
{
    echo &quot;My form recieved exactly a 0, not a blank, not a false... but a 0!&quot;;
}elseif(!$_GET[something])
{
   echo &quot;could be a null,blank or false&quot;;
}</pre>
<p><strong>Trick 2 : echo comma</strong><br />
Usage : echo $a,$b,$c,$d;<br />
Reason : Less memory usage, less cpu cycles, faster output to screen and&#8230; bragging rights.</p>
<pre class="wp-code-highlight prettyprint">
$a = &quot;hel&quot;;
$b = &quot;lo&quot;;
$c = &quot; wor&quot;;
$d = &quot;ld&quot;;

echo $a.$b.$c.$d;
//What actually happens is that the string is buffered (added) together
// before sending to output

// $a .=$b     adds &quot;hel&quot;+&quot;lo&quot;
// $a .=$c     adds &quot;hello&quot;+&quot; wor&quot;
// $a .=$d     adds &quot;hello wor&quot;+&quot;ld&quot;
// echo $a     echos out &quot;hello world&quot;

echo $a,$b,$c,$d;
//What actually happens is that the string is not added but sent directly to output
// echo $a   =&amp;gt; echos out &quot;hel&quot;
// echo $b   =&amp;gt; echos out &quot;lo&quot;
// echo $c   =&amp;gt; echos out &quot; wor&quot;
// echo $d   =&amp;gt; echos out &quot;ld&quot;</pre>
<p>That&#8217;s all for this week&#8230; till i have time to blog again&#8230; cheers</p>
]]></content:encoded>
			<wfw:commentRss>http://www.garytay.net/2007-10-26/php-tricks/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Downsize is good research!</title>
		<link>http://www.garytay.net/2007-08-15/downsize-is-good-research/</link>
		<comments>http://www.garytay.net/2007-08-15/downsize-is-good-research/#comments</comments>
		<pubDate>Wed, 15 Aug 2007 10:02:57 +0000</pubDate>
		<dc:creator>Gary Tay</dc:creator>
				<category><![CDATA[Rants]]></category>

		<guid isPermaLink="false">http://www.garytay.net/2007-08-15/downsize-is-good-research/</guid>
		<description><![CDATA[I&#8217;ve switch jobs and now working on server software. The job revolves around writing programs that is squeezed onto a 7mb compressed linux image file. Imagine the entire OS + Web server + database = 7mb&#8230; ha! Thus the stripping (of codes) begins.. PHP -&#62; Stripped till barebone Database -&#62; From MySQL to SQLite3 Web [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve switch jobs and now working on server software.<br />
The job revolves around writing programs that is squeezed onto a 7mb compressed linux image file.</p>
<p>Imagine the entire OS + Web server + database = 7mb&#8230; ha!</p>
<p>Thus the stripping (of codes) begins..</p>
<p>PHP -&gt; Stripped till barebone<br />
Database -&gt; From MySQL to SQLite3<br />
Web Server -&gt; Apache to  mini_httpd</p>
<p>The setup is so bare&#8230; i&#8217;m writing the http headers, cookies and session from scratch!</p>
<p>Thus begins my research on LMSP (Linux-Mini_httpd-Sqlite3-Php).<br />
LAMP seems so much easier&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.garytay.net/2007-08-15/downsize-is-good-research/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Vertifying NRIC via PHP (codes)</title>
		<link>http://www.garytay.net/2007-06-28/vertifying-nric-via-php-codes/</link>
		<comments>http://www.garytay.net/2007-06-28/vertifying-nric-via-php-codes/#comments</comments>
		<pubDate>Thu, 28 Jun 2007 07:33:59 +0000</pubDate>
		<dc:creator>Gary Tay</dc:creator>
				<category><![CDATA[Codes]]></category>

		<guid isPermaLink="false">http://www.garytay.net/2007-06-28/vertifying-nric-via-php-codes/</guid>
		<description><![CDATA[In response to my good friend&#8217;s post : http://www.yoman.com.sg/2007/5/29/validates_nric_of I present to you the same codes written in PHP $nric = $_GET[nric]; if(is_NRIC($nric)) {echo &#34;Correct NRIC&#34;;} else {echo &#34;Your NRIC is wrong&#34;;} function is_NRIC($nric) { if(strlen($nric)==9) { $nric = strtoupper($nric); $prefix = substr($nric,0,1); $postfix = substr($nric,8,1); $ic_number = substr($nric,1,7); $weight = array(2,7,6,5,4,3,2); $lookup[S] = array(J,Z,I,H,G,F,E,D,C,B,A); [...]]]></description>
			<content:encoded><![CDATA[<p>In response to my good friend&#8217;s post :</p>
<p><a href="http://www.yoman.com.sg/2007/5/29/validates_nric_of">http://www.yoman.com.sg/2007/5/29/validates_nric_of</a></p>
<p>I present to you the same codes written in PHP</p>
<pre class="wp-code-highlight prettyprint">$nric = $_GET[nric];

if(is_NRIC($nric))
{echo &quot;Correct NRIC&quot;;}
else
{echo &quot;Your NRIC is wrong&quot;;}

function is_NRIC($nric)
{
	if(strlen($nric)==9)
	{
		$nric = strtoupper($nric);
		$prefix = substr($nric,0,1);
		$postfix = substr($nric,8,1);
		$ic_number = substr($nric,1,7);

		$weight = array(2,7,6,5,4,3,2);
		$lookup[S] = array(J,Z,I,H,G,F,E,D,C,B,A);
		$lookup[T] = array(G,F,E,D,C,B,A,J,Z,I,H);
		$lookup[F] = array(X,W,U,T,R,Q,P,N,M,L,K);
		$lookup[G] = array(R,Q,P,N,M,L,K,X,W,U,T);

		for($i=0;$weight[$i];$i++)
		{
		$num+=substr($ic_number,$i,1)*$weight[$i];
		}

		$num %= 11;

		if($lookup[$prefix][$num]==$postfix)
		{
			return true;
		}else
		{
			return false;
		}

	}

}</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.garytay.net/2007-06-28/vertifying-nric-via-php-codes/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>1st!</title>
		<link>http://www.garytay.net/2007-06-27/hello-world/</link>
		<comments>http://www.garytay.net/2007-06-27/hello-world/#comments</comments>
		<pubDate>Thu, 28 Jun 2007 03:38:31 +0000</pubDate>
		<dc:creator>Gary Tay</dc:creator>
				<category><![CDATA[Rants]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[I&#8217;ve shifted servers from the lousy netfirms account (too slow, bad php support), to my new servers at ASO . Everything seems well again. Stay tune while i whip out new stuff!]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve shifted servers from the lousy netfirms account (too slow, bad php support), to my new servers at <a href="http://www.asmallorange.com" title="ASO" target="_blank">ASO</a> . Everything seems well again. Stay tune while i whip out new stuff!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.garytay.net/2007-06-27/hello-world/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

