<?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/"
	>

<channel>
	<title>TwinArrow</title>
	<atom:link href="http://www.twinarrow.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.twinarrow.com</link>
	<description>Musings about the web and web technology</description>
	<pubDate>Tue, 24 Mar 2009 21:29:26 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Apache Mime Types for Office 2007 Files</title>
		<link>http://www.twinarrow.com/2009/03/apache-mime-types-for-office-2007-files/</link>
		<comments>http://www.twinarrow.com/2009/03/apache-mime-types-for-office-2007-files/#comments</comments>
		<pubDate>Tue, 24 Mar 2009 07:00:15 +0000</pubDate>
		<dc:creator>Huy Tong</dc:creator>
		
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.twinarrow.com/?p=121</guid>
		<description><![CDATA[Jon had posted up a link to an Excel file he created with the extension .xlsx, an Office 2007 file, on to his site. The upload was fine and all until you wanted to download it, in IE. He was telling me why the Excel file was saving to a zip document instead of the [...]]]></description>
			<content:encoded><![CDATA[<p>Jon had posted up a link to an Excel file he created with the extension .xlsx, an Office 2007 file, on to his <a href="http://www.3hoopsfans.com/" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.3hoopsfans.com');" target="_blank">site</a>. The upload was fine and all until you wanted to download it, in IE. He was telling me why the Excel file was saving to a zip document instead of the xlsx document. I wasn&#8217;t sure what he was talking about because I&#8217;m on a Mac and Macs don&#8217;t have IE. Good thing I have a virtual machine running with IE7 on it. I thought he was talking gibberish but what he said was true. It was saving the Excel as a zip. I opened the zip to find worksheets and style data so I guess this new Microsoft file type is pretty much a zip file so that probably made IE confused.</p>
<p><span id="more-121"></span></p>
<p>I went to look around for solutions for Apache mime type configurations for Office 2007 file extensions and found this solution and added it to his .htaccess file:</p>
<p><script type="text/javascript" src="/scripts/shBrushPlain.js"></script></p>
<pre class="brush: plain">
AddType application/vnd.ms-word.document.macroEnabled.12 docm
AddType application/vnd.openxmlformats-officedocument.wordprocessingml.document docx
AddType application/vnd.ms-word.template.macroEnabled.12 dotm
AddType application/vnd.openxmlformats-officedocument.wordprocessingml.template dotx
AddType application/vnd.ms-powerpoint.template.macroEnabled.12 potm
AddType application/vnd.openxmlformats-officedocument.presentationml.template potx
AddType application/vnd.ms-powerpoint.addin.macroEnabled.12 ppam
AddType application/vnd.ms-powerpoint.slideshow.macroEnabled.12 ppsm
AddType application/vnd.openxmlformats-officedocument.presentationml.slideshow ppsx
AddType application/vnd.ms-powerpoint.presentation.macroEnabled.12 pptm
AddType application/vnd.openxmlformats-officedocument.presentationml.presentation pptx
AddType application/vnd.ms-excel.addin.macroEnabled.12 xlam
AddType application/vnd.ms-excel.sheet.binary.macroEnabled.12 xlsb
AddType application/vnd.ms-excel.sheet.macroEnabled.12 xlsm
AddType application/vnd.openxmlformats-officedocument.spreadsheetml.sheet xlsx
AddType application/vnd.ms-excel.template.macroEnabled.12 xlt
AddType application/vnd.openxmlformats-officedocument.spreadsheetml.template xltx
</pre>
<p>This solved the issue and Jon couldn&#8217;t be any happier.</p>
<p>Source: <a href="http://dogma.swiftspirit.co.za/archives/183" onclick="javascript:pageTracker._trackPageview('/outbound/article/dogma.swiftspirit.co.za');" target="_blank">http://dogma.swiftspirit.co.za/archives/183</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.twinarrow.com/2009/03/apache-mime-types-for-office-2007-files/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Facebook Puzzle: Hoppity Hop!</title>
		<link>http://www.twinarrow.com/2009/03/facebook-puzzle-hoppity-hop/</link>
		<comments>http://www.twinarrow.com/2009/03/facebook-puzzle-hoppity-hop/#comments</comments>
		<pubDate>Mon, 23 Mar 2009 20:47:42 +0000</pubDate>
		<dc:creator>Huy Tong</dc:creator>
		
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.twinarrow.com/?p=113</guid>
		<description><![CDATA[I love puzzles, especially coding puzzles. Here is one that I found on Facebook&#8217;s jobs page for Hoppity Hop!. It is similar to one I had to solve during a job interview last year but it&#8217;s a little different because this one has to be run via the Command Line Interface. This is the easiest [...]]]></description>
			<content:encoded><![CDATA[<p>I love puzzles, especially coding puzzles. Here is one that I found on Facebook&#8217;s jobs page for <a href="http://www.facebook.com/careers/puzzles.php?puzzle_id=7" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.facebook.com');" target="_blank">Hoppity Hop!</a>. It is similar to one I had to solve during a job interview last year but it&#8217;s a little different because this one has to be run via the Command Line Interface. This is the easiest puzzle that Facebook posted, if you want to see the other puzzles, head on over to: <a href="http://www.facebook.com/careers/puzzles.php" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.facebook.com');" target="_blank">http://www.facebook.com/careers/puzzles.php</a>.</p>
<p><span id="more-113"></span></p>
<p>Here is Facebook&#8217;s description for the puzzle:</p>
<blockquote><p>
To help test whether your puzzle submissions fit the guidelines, try this simple test puzzle. Your solution must follow the guidelines like any other puzzle. Write a program that takes as input a single argument on the command line. This argument must be a file name, which contains a single positive integer. The program should read this file and obtain the integer within, and then output a sequence of strings based upon the number (details below).
</p></blockquote>
<p>Here is my solution to the puzzle:</p>
<p><script type="text/javascript" src="/scripts/shBrushPhp.js"></script></p>
<pre class="brush: php">&lt;?php
/*
Huy Tong
Facebook Hoppity Hop! puzzle
*/

/* make sure that an argument was passed */
if (isset($argv[1])) {
	/* argument 1 should be the file name */
	$file = $argv[1];

	/* check if that file exists */
	if (file_exists($file)) {
		/* get the number inside the file */
		$n = (int)trim(file_get_contents($file));

		/* check if the file containted the right data type */
		if (is_numeric($n)) {
			for ($i=1;$i<$n;$i++) {
				if ((($i % 3) == 0) &#038;&#038; (($i % 5) == 0)) {
					/* the number is divisible by 3 and 5 */
					print "Hop\n";
				} else if (($i % 3) == 0) {
					/* the number is divisible by 3 */
					print "Hoppity\n";
				} else if (($i % 5) == 0) {
					/* the number is divisible by 5 */
					print "Hophop\n";
				} else {
					/* do nothing */
				}
			}
		} else {
			print "The file must contain an integer.\n";
		}
	} else {
		print "The file you are trying to access, ".$file.", does not exist.\n";
	}
} else {
	print "Please enter a file name to use in the argument.\n";
}
?&gt;
</pre>
<p>Here is the sample data file, I named it <code>num.txt</code> but you can name it whatever you want because it is called via the command line.</p>
<p><script type="text/javascript" src="/scripts/shBrushPlain.js"></script></p>
<pre class="brush: plain">
15
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.twinarrow.com/2009/03/facebook-puzzle-hoppity-hop/feed/</wfw:commentRss>
		</item>
		<item>
		<title>SEO Friendly Pop-Up Windows</title>
		<link>http://www.twinarrow.com/2009/03/seo-friendly-pop-up-windows/</link>
		<comments>http://www.twinarrow.com/2009/03/seo-friendly-pop-up-windows/#comments</comments>
		<pubDate>Sat, 21 Mar 2009 06:17:47 +0000</pubDate>
		<dc:creator>Huy Tong</dc:creator>
		
		<category><![CDATA[SEO]]></category>

		<guid isPermaLink="false">http://www.twinarrow.com/?p=95</guid>
		<description><![CDATA[I&#8217;ve seen plenty of sites out there who are still using javascript:openWindow(); to open up a smaller pop-up window. Though the method works very effectively, it makes the spiders unable to crawl the content of that pop-up window. Spiders aren&#8217;t able to follow JavaScript links so your pop-up window content won&#8217;t make it to the [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve seen plenty of sites out there who are still using <code>javascript:openWindow();</code> to open up a smaller pop-up window. Though the method works very effectively, it makes the spiders unable to crawl the content of that pop-up window. Spiders aren&#8217;t able to follow JavaScript links so your pop-up window content won&#8217;t make it to the search engines&#8217; indexes at all.</p>
<p><span id="more-95"></span></p>
<p>My solution is quite simple, we&#8217;re still going to use our old pop up window code but we&#8217;re not going to put it in the <code>href</code> attribute but rather on the <code>onclick</code> attribute. Example:<br />
<script src="/scripts/shBrushJScript.js" type="text/javascript"></script><script src="/scripts/shBrushXml.js" type="text/javascript"></script></p>
<pre class="brush: js">&lt;script type="text/javascript"&gt;
function openWindow() {
	window.open ("my_new_page.html","mynewwindow");
}
&lt;/script&gt;</pre>
<pre class="brush: xhtml">&lt;a href="my_new_page.html" onclick="javascript:openWindow();return false;"&gt;Link&lt;/a&gt;</pre>
<p>Note that we are now having the page we want to link to in the <code>href</code> attribute. On the <code>onclick</code>, I added our <code>openWindow</code> function with a <code>return false;</code> attached to it. If you attach <code>return false;</code> onto any link, it&#8217;ll stop the browser from taking you to a new page. Your <code>openWindow()</code> function will still run, therefor, a new pop-up window opens.</p>
<p>We can also make our <code>openWindow()</code> function more modular by making it accept any link:</p>
<pre class="brush: js">&lt;script type="text/javascript"&gt;
function openWindow(url) {
	window.open (url,"mynewwindow");
}
&lt;/script&gt;</pre>
<pre class="brush: xhtml">&lt;a href="my_new_page.html" onclick="javascript:openWindow(this);return false;"&gt;Link&lt;/a&gt;</pre>
<p>I added the <code>this</code> argument into the <code>openWindow()</code> function. <code>this</code> tells the function to pass the <code>href</code> attribute into the function.</p>
<p>If you want to learn more on how to modify the pop-up window&#8217;s width, height, etc., head on over to <a href="http://www.javascript-coder.com/window-popup/javascript-window-open.phtml" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.javascript-coder.com');" target="_blank">http://www.javascript-coder.com/window-popup/javascript-window-open.phtml</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.twinarrow.com/2009/03/seo-friendly-pop-up-windows/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Bullet Madness at Stylegala</title>
		<link>http://www.twinarrow.com/2009/03/bullet-madness-at-stylegala/</link>
		<comments>http://www.twinarrow.com/2009/03/bullet-madness-at-stylegala/#comments</comments>
		<pubDate>Fri, 20 Mar 2009 16:15:00 +0000</pubDate>
		<dc:creator>Huy Tong</dc:creator>
		
		<category><![CDATA[Design]]></category>

		<guid isPermaLink="false">http://www.twinarrow.com/?p=87</guid>
		<description><![CDATA[Looking for some quick bullets for your unordered list for your design? The folks over at Stylegala compiled a list of bullet images sent in by users that you can save to your site and use. Head over to http://www.stylegala.com/features/bulletmadness/ to check them out. This list also serves as a good inspiration for those who [...]]]></description>
			<content:encoded><![CDATA[<p>Looking for some quick bullets for your unordered list for your design? The folks over at Stylegala compiled a list of bullet images sent in by users that you can save to your site and use. Head over to <a href="http://www.stylegala.com/features/bulletmadness/" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.stylegala.com');" target="_blank">http://www.stylegala.com/features/bulletmadness/</a> to check them out. This list also serves as a good inspiration for those who are looking for that special bullet because we all know that a circle is just too plain.</p>
<p><span id="more-87"></span></p>
<p>What&#8217;s the best way to utilize these bullets in your HTML code? There is the <code>list-style-image: url(PATH_TO_IMAGE);</code> CSS declaration but I never find myself using that. I prefer setting a background to the list item and set the background to not repeat. You have a better control over how your image is aligned to the text. You can&#8217;t do that with <code>list-style-image</code>. My style for the ul tag might look something like this:</p>
<p><script src="/scripts/shBrushCss.js"></script></p>
<pre class="brush: css">
ul { list-style-type: none}
ul li { list-style-type: none;background: url(/images/bullet.gif) no-repeat top left; }
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.twinarrow.com/2009/03/bullet-madness-at-stylegala/feed/</wfw:commentRss>
		</item>
		<item>
		<title>jQuery: External links open up in a new window</title>
		<link>http://www.twinarrow.com/2009/03/jquery-external-links-open-up-in-a-new-window/</link>
		<comments>http://www.twinarrow.com/2009/03/jquery-external-links-open-up-in-a-new-window/#comments</comments>
		<pubDate>Thu, 12 Mar 2009 20:51:29 +0000</pubDate>
		<dc:creator>Huy Tong</dc:creator>
		
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.twinarrow.com/?p=72</guid>
		<description><![CDATA[I&#8217;ve received many bug tickets from Disney QA stressing that external links NEED to be opened in a new window or tab. The site that I am working on have many articles that have hard coded links and most of them don&#8217;t open up in a new window. I have 3 ways to solve this [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve received many bug tickets from Disney QA stressing that external links NEED to be opened in a new window or tab. The site that I am working on have many articles that have hard coded links and most of them don&#8217;t open up in a new window. I have 3 ways to solve this issue.</p>
<p><span id="more-72"></span></p>
<ul>
<li>Have the editors manually go through and insert the HTML code to <em>target=&#8221;_blank.&#8221;</em></li>
<li>Use PHP and Regular Expressions to go through each article and insert <em>target=&#8221;_blank&#8221;</em> into links that does not have it.</li>
<li>Use Javascript to scan the page for links that doesn&#8217;t match the domain and add <em>target=&#8221;_blank&#8221;</em> to those links on the fly.</li>
</ul>
<p>As the title points out, I chose to go with the Javascript method. jQuery is awesome and it&#8217;s my go to Javascript framework of choice. The function that I used traverses through all anchor tags, checks if the link matches the current hostname, if it doesn&#8217;t, it attaches a <em>target=&#8221;_blank&#8221;</em> to that link.</p>
<p><script type="text/javascript" src="/scripts/shBrushJScript.js"></script></p>
<pre class="brush: js">
$(document).ready(function() {
	$("a[href^=http]").each(function(){
		if(this.href.indexOf(location.hostname) == -1) {
			$(this).attr({
				target: "_blank"
			});
		}
	})
});</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.twinarrow.com/2009/03/jquery-external-links-open-up-in-a-new-window/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Server Issues Resolved</title>
		<link>http://www.twinarrow.com/2009/03/server-issues-resolved/</link>
		<comments>http://www.twinarrow.com/2009/03/server-issues-resolved/#comments</comments>
		<pubDate>Sun, 08 Mar 2009 21:55:08 +0000</pubDate>
		<dc:creator>Huy Tong</dc:creator>
		
		<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://www.twinarrow.com/?p=68</guid>
		<description><![CDATA[The server issue with user logins is fixed by Dave. All the users can now log in with their old credentials and will be able to log into the server. Read more about what he did here: http://gravstar.com/node/34.
]]></description>
			<content:encoded><![CDATA[<p>The server issue with user logins is fixed by Dave. All the users can now log in with their old credentials and will be able to log into the server. Read more about what he did here: <a href="http://gravstar.com/node/34" onclick="javascript:pageTracker._trackPageview('/outbound/article/gravstar.com');" target="_blank">http://gravstar.com/node/34</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.twinarrow.com/2009/03/server-issues-resolved/feed/</wfw:commentRss>
		</item>
		<item>
		<title>How to pair your Bluetooth headset to the PS3</title>
		<link>http://www.twinarrow.com/2009/03/how-to-pair-your-bluetooth-headset-to-the-ps3/</link>
		<comments>http://www.twinarrow.com/2009/03/how-to-pair-your-bluetooth-headset-to-the-ps3/#comments</comments>
		<pubDate>Tue, 03 Mar 2009 16:42:27 +0000</pubDate>
		<dc:creator>Huy Tong</dc:creator>
		
		<category><![CDATA[Gaming]]></category>

		<guid isPermaLink="false">http://www.twinarrow.com/?p=55</guid>
		<description><![CDATA[Online voice chatting rocks, especially when you are beating your opponent in Street Fighter 4 of course. Many people don&#8217;t know that they can just pair any Bluetooth headset to the PS3 and just chat away. I&#8217;m sure many of you have one lying around somewhere that you thought was cool to use with your [...]]]></description>
			<content:encoded><![CDATA[<p>Online voice chatting rocks, especially when you are beating your opponent in Street Fighter 4 of course. Many people don&#8217;t know that they can just pair any Bluetooth headset to the PS3 and just chat away. I&#8217;m sure many of you have one lying around somewhere that you thought was cool to use with your phone but that phase just died out. That sure happened to me. Online chatting was not something I was concerned about before but more and more games are supporting it now.</p>
<p><span id="more-55"></span></p>
<p>The steps to do this is simple but tricky at the same time, it requires you to know how to enable pairing on your Bluetooth headset by making it discoverable. If you don&#8217;t know how to do this, go to the headset&#8217;s manufacturer&#8217;s website and find documentation for it. Once you figure out how to make your device discoverable, go to the Playstation&#8217;s section and look for &#8220;Manage Bluetooth Devices&#8221; after &#8220;Accessory Settings.&#8221; In this section, you can add headsets, keyboards and mice. Go ahead with this process and make sure that you turn the pairing option on your headset on before you press the &#8220;Start Scanning&#8221; button.</p>
<p>Once the Playstation has found your headset, it will ask you for a passkey for the device. The standard passkey for most Bluetooth headsets is <em>0000</em>. Once you enter that in, the set up process will be complete. You should see your device on the screen and it will say that your headset is an audio device. If you are still stuck in the scanning screen (the scanning process should take no longer than a minute), that means your device is not in discoverable mode, go back and check if you followed the instructions correctly.</p>
<p>You&#8217;re not done yet! I thought the whole pairing process was completed and tried to use it in Street Fighter 4, it didn&#8217;t work. I then went back into options and went through each option item again and a menu item labeled &#8220;Audio Device Settings.&#8221; Go in and change the audio input and output to your headset. Save and now you are done setting up your device.</p>
<p>If you have the official Sony Bluetooth headset for the PS3, I don&#8217;t think you have to go through this process but my friend Eddie had to. I wasn&#8217;t sure why because the documentation said that if you just plug the device into the Playstation&#8217;s USB port, they will pair automatically. That&#8217;s the same way you would pair your Playstation controller to the PS3.</p>
<p>Wikipedia has a list of headsets compatible with the PS3 [<a href="http://en.wikipedia.org/wiki/List_of_Bluetooth_headsets_compatible_with_PlayStation_3" onclick="javascript:pageTracker._trackPageview('/outbound/article/en.wikipedia.org');" target="_blank">http://en.wikipedia.org/wiki/List_of_Bluetooth_headsets_compatible_with_PlayStation_3</a>] but I believe that most headsets will work. I would refer to this list to see which headsets are considered problematic such as some of the Motorola ones.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.twinarrow.com/2009/03/how-to-pair-your-bluetooth-headset-to-the-ps3/feed/</wfw:commentRss>
		</item>
		<item>
		<title>XKCD: NP-Complete Problem</title>
		<link>http://www.twinarrow.com/2009/03/xkcd-np-complete-problem/</link>
		<comments>http://www.twinarrow.com/2009/03/xkcd-np-complete-problem/#comments</comments>
		<pubDate>Mon, 02 Mar 2009 18:07:25 +0000</pubDate>
		<dc:creator>Huy Tong</dc:creator>
		
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.twinarrow.com/2009/03/27/</guid>
		<description><![CDATA[I was browsing through the job section on Craigslist one day and one of the job postings caught my attention. I read through their job listing and one of their requirements was to solve a problem programmatically from xkcd. This is a first that I’ve seen for job postings and I think it’s pretty awesome. [...]]]></description>
			<content:encoded><![CDATA[<p>I was browsing through the job section on Craigslist one day and one of the job postings caught my attention. I read through their <a href="http://www.tablexi.com/talks/2007/11/19/table-xi-is-hiring-again" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.tablexi.com');">job listing</a> and one of their requirements was to <a href="http://www.tablexi.com/exercise/" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.tablexi.com');">solve a problem programmatically</a> from <a href="http://www.xkcd.com/" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.xkcd.com');">xkcd</a>. This is a first that I’ve seen for job postings and I think it’s pretty awesome. You are looking for a programmer so why not test out their skills before you hire them.</p>
<p><span id="more-27"></span></p>
<p>I decided to give this problem a go. Not that I’m trying to apply for this job or anything. I just want to find a way to solve it. It was really hard to start off because there are so many ways to approach it. One, I can brute force the program to make it go through every possible combinations there are and find out the answer through there. Or second, create an easy algorithm that goes through and provides the answer as quickly as possible.</p>
<p>I decided to go with <span class="caps">PHP</span> (because it’s what I know best) and went with the second method. I’ve been working on this on and off for about a day or two and today I’ve got it working (through the help of others of course).</p>
<blockquote><p>The <a href="/np/">answer</a> to the problem above is:</p>
<p>1 mixed fruit, 2 hot wings, 1 sampler plate</p>
<p>7 mixed fruits</p></blockquote>
<p>One of the things I had to do was multiply the target price and each menu item price by 100 so that I won’t run into calculation errors. The solution of 7 mixed fruits didn’t come up until I did it that way.</p>
<p>Here is the source to the script:<br />
<script type="text/javascript" src="/scripts/shBrushPhp.js"></script></p>
<pre class="brush: php">&lt;?php
set_time_limit(0);
$n = new twinarrowTest('menu.txt');

class twinarrowTest
{
	var $n_items;
	var $file;
	var $menu_items;
	var $menu_prices;
	var $target_price;
	var $order;
	var $max_order;
	var $orders_tried;
	var $solutions_found;

	public function __construct($file)
	{
		if (file_exists($file)) {
			$this-&gt;file = $file;
			$this-&gt;prep();
			$this-&gt;process();
		} else {
			die("The file you are trying to call does not exist.");
		}
	}

	private function prep()
	{
		$handle = fopen($this-&gt;file, "r");
		$contents = fread($handle, filesize($this-&gt;file));
		$lines = explode("\n",$contents);
		fclose($handle);

		$this-&gt;target_price = str_replace('$','',$lines[0])*100;

		array_shift($lines);
		$this-&gt;n_items = count($lines);

		for ($i=0;$i&lt;count($lines);$i++) {
			$n = explode(',',$lines[$i]);
			$this-&gt;menu_items[] = $n[0];
			$this-&gt;menu_prices[] = str_replace('$','',$n[1])*100;
		}
	}

	private function process()
	{
		$size = 1;
		for ($i=0;$i&lt;$this-&gt;n_items;$i++) {
			$this-&gt;max_order[$i] = $this-&gt;target_price/$this-&gt;menu_prices[$i];
			if ($this-&gt;target_price % $this-&gt;menu_prices[$i]!=0)
				$this-&gt;order[$i]++;
			$size *= ($this-&gt;max_order[$i]+1);
		}

		$this-&gt;recursive(0);

		if ($this-&gt;solutions_found &gt; 0) {
			echo "&lt;br /&gt;&lt;br /&gt;There are &lt;strong&gt;".$this-&gt;solutions_found."&lt;/strong&gt; solutions.";
		} else {
			echo "There are no solutions found using your data set.";
		}

	}

	private function recursive($slot) {
		if ($slot &gt;= $this-&gt;n_items) {
			$this-&gt;check();
		} else {
			for ($this-&gt;order[$slot]=0;$this-&gt;order[$slot]&lt;=$this-&gt;max_order[$slot];$this-&gt;order[$slot]++) {
				$this-&gt;recursive($slot+1);
			}
		}
	}

	private function check() {
		$this-&gt;orders_tried++;
		$total = 0;
		for ($i=0;$i&lt;$this-&gt;n_items;$i++) {
			$total += $this-&gt;menu_prices[$i]*$this-&gt;order[$i];
		}

		if ($total == $this-&gt;target_price) {
			$t_array = array();
			for ($i=0;$i&lt;$this-&gt;n_items;$i++) {
				if ($this-&gt;order[$i] != 0) {
					$t_array[] = $this-&gt;order[$i].' '.$this-&gt;menu_items[$i];
				}
			}
			echo implode(", ",$t_array)."&lt;br /&gt;";
			$this-&gt;solutions_found++;
		}
	}
}

?&gt;</pre>
<p><em>*NOTE: this is an old post that I decided to put back up in case it might help someone out.</em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.twinarrow.com/2009/03/xkcd-np-complete-problem/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Server Problems</title>
		<link>http://www.twinarrow.com/2009/02/server-problems/</link>
		<comments>http://www.twinarrow.com/2009/02/server-problems/#comments</comments>
		<pubDate>Fri, 27 Feb 2009 07:08:50 +0000</pubDate>
		<dc:creator>Huy Tong</dc:creator>
		
		<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://www.twinarrow.com/?p=25</guid>
		<description><![CDATA[We are having some difficulties here on our server. The front end side is fine so our sites are appearing and working as they should. The problem is authentication for the users who are in our jail directory. This all started to happen after Dave upgraded the server&#8217;s software from Etch to Lenny so he&#8217;s [...]]]></description>
			<content:encoded><![CDATA[<p>We are having some difficulties here on our server. The front end side is fine so our sites are appearing and working as they should. The problem is authentication for the users who are in our jail directory. This all started to happen after Dave upgraded the server&#8217;s software from Etch to Lenny so he&#8217;s in charge of finding out what&#8217;s wrong and fixing it. Server management can be a pain in the butt but I&#8217;m glad that I&#8217;m not the one to deal with it in this case.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.twinarrow.com/2009/02/server-problems/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Spruce up your 404 page</title>
		<link>http://www.twinarrow.com/2009/02/spruce-up-your-404-page/</link>
		<comments>http://www.twinarrow.com/2009/02/spruce-up-your-404-page/#comments</comments>
		<pubDate>Thu, 26 Feb 2009 06:53:37 +0000</pubDate>
		<dc:creator>Huy Tong</dc:creator>
		
		<category><![CDATA[SEO]]></category>

		<guid isPermaLink="false">http://www.twinarrow.com/?p=11</guid>
		<description><![CDATA[404 pages are probably the number 1 reason why people are leaving your site. Sometimes your users are reaching 404 pages because you have a bad link that needs fixing on your site and other times, it&#8217;s from old search engine caches. You should be glad that people are clicking on your pages from search [...]]]></description>
			<content:encoded><![CDATA[<p>404 pages are probably the number 1 reason why people are leaving your site. Sometimes your users are reaching 404 pages because you have a bad link that needs fixing on your site and other times, it&#8217;s from old search engine caches. You should be glad that people are clicking on your pages from search engines, it means that the content you have/had interested them. If that is the case, you should offer them a reason to stay on your site instead of hitting back and go to a competitor&#8217;s site.</p>
<p><span id="more-11"></span></p>
<p>I know that I have tons of dead links that are coming from the search engines because I&#8217;ve messed with this site plenty of times with my different blog installations. I don&#8217;t worry about them too much because the content that I had on here weren&#8217;t that great to salvage. I&#8217;m starting to write more how-to&#8217;s and tips that I&#8217;ve implemented a very useful tool offered by Google.</p>
<p>It&#8217;s called &#8220;Enhance 404 pages&#8221; as a part of the <a href="https://www.google.com/webmasters/tools/" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.google.com');">Google Webmaster Tools</a> package. Go ahead and log into your Google Webmaster Tool account. Click on the Tools link on the left hand navigation and Enhance 404 pages should appear under that link. All you have to do is copy the javascript code that they supply onto your 404 page and that&#8217;s it. The next time that someone goes to a dead link on your site, Google will try its best to find alternative content that matches what the user was trying to access. They also include a site search for the page the user was trying to access.</p>
<p>The only drawback is that the information they are getting is from their cache of your site. I&#8217;ve implemented the code onto my site but I probably won&#8217;t see it working properly for a while because of all the new content that is on this new installation of Wordpress. If you have an established site, it should work for you right off the bat.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.twinarrow.com/2009/02/spruce-up-your-404-page/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
