<?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>Talk In Code</title>
	<atom:link href="http://www.talkincode.com/feed" rel="self" type="application/rss+xml" />
	<link>http://www.talkincode.com</link>
	<description>Code tips, snippets and resources.</description>
	<lastBuildDate>Wed, 22 Jun 2011 16:29:45 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Take a break from coding with online bingo</title>
		<link>http://www.talkincode.com/take-a-break-from-coding-with-online-bingo-1222.html</link>
		<comments>http://www.talkincode.com/take-a-break-from-coding-with-online-bingo-1222.html#comments</comments>
		<pubDate>Thu, 16 Jun 2011 15:37:20 +0000</pubDate>
		<dc:creator>content</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://www.talkincode.com/?p=1222</guid>
		<description><![CDATA[Dealing with code can be a pretty taxing business simply because you are constantly focused on the job at hand and you are likely to face long hours at the screen doing nothing but work. However, you need to know when to tell yourself to relax and start enjoying being at the screen in between [...]]]></description>
			<content:encoded><![CDATA[<p>Dealing with code can be a pretty taxing business simply because you are constantly focused on the job at hand and you are likely to face long hours at the screen doing nothing but work. However, you need to know when to tell yourself to relax and start enjoying being at the screen in between periods of work.</p>
<p>If you get some spare time at your screen then you might want to start getting involved in online bingo. There are a lot of different online bingo sites out there and their main aim is to help you have fun while giving you a hope of winning some excellent cash prizes.</p>
<p>If you <a href="http://www.ohmybingo.com/cheeky_bingo">play Cheeky Bingo</a>, for instance, you could put yourself in with a shout of winning jackpots every single day just by signing up. The site offers free games with cash prizes as well as games that you have to pay to enter, but which offer more lucrative prizes.</p>
<p>Take your mind off some of that troublesome and complicated code by enjoying the entertainment you can tap into online. For a better idea of the kind of promotions that appear on some of the best bingo sites online, have a look at ohmybingo.com.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.talkincode.com/take-a-break-from-coding-with-online-bingo-1222.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Holy Wars, aka Vi vs Emacs</title>
		<link>http://www.talkincode.com/holy-wars-aka-vi-vs-emacs-1220.html</link>
		<comments>http://www.talkincode.com/holy-wars-aka-vi-vs-emacs-1220.html#comments</comments>
		<pubDate>Mon, 29 Mar 2010 09:48:51 +0000</pubDate>
		<dc:creator>content</dc:creator>
				<category><![CDATA[Unix/Linux]]></category>
		<category><![CDATA[emacs]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[nano]]></category>
		<category><![CDATA[text editor]]></category>
		<category><![CDATA[vi]]></category>

		<guid isPermaLink="false">http://www.talkincode.com/?p=1220</guid>
		<description><![CDATA[As a long-time Windows user, there was always something which confused me when it came to learning my trade on Linux based systems &#8211; the sheer amount of choice in apps on offer to fulfill a single task. Which leads me on to the next thing &#8211; the nigh-on-religious wars which have erupted around these [...]]]></description>
			<content:encoded><![CDATA[<p>As a long-time Windows user, there was always something which confused me when it came to learning my trade on Linux based systems &#8211; the sheer amount of choice in apps on offer to fulfill a single task. Which leads me on to the next thing &#8211; the nigh-on-religious wars which have erupted around these apps.</p>
<p>Case in point: text editors. When I first went to edit a file in a pure Linux text console, I thought I would try out vi. When I found my head spinning after just a few minutes of trying to edit one line of a config file, I gave up and tried emacs. When I got overwhelmed by the sheer amount of stuff bolted into the text editor, I thought that I would go for the Linux text mode equivalent of Notepad, nano. I edited the file and moved onto the next thing I had to do.</p>
<p>But it really got me thinking. There is always a place for an alternative application in a given area &#8211; vi and emacs both do the same thing (edit plain text) but offer 2 very different ways of doing this, and both are highly configurable and so on and so forth. But what this doesn&#8217;t explain is the vitriolic debate which springs up around the users of each.</p>
<p>You don&#8217;t see this on other platforms &#8211; Windows users typically have to put up with Notepad until they discover something like Notepad++ and OS X users have Textmate (which seems to be very popular on that platform). However, you don&#8217;t get the users of UltraEdit insulting the entire families of those who use Notepad++. You don&#8217;t get arguments which have raged for 20+ years. In short, its all a bit more civilized.</p>
<p>So I get to my point &#8211; out of all these text editors on Linux, which one do you use and why? Functionality? The way the app looks? The price (or lack of it)?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.talkincode.com/holy-wars-aka-vi-vs-emacs-1220.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Google Code is 5 today!</title>
		<link>http://www.talkincode.com/google-code-is-5-today-1217.html</link>
		<comments>http://www.talkincode.com/google-code-is-5-today-1217.html#comments</comments>
		<pubDate>Sat, 20 Mar 2010 12:53:02 +0000</pubDate>
		<dc:creator>content</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[google code]]></category>
		<category><![CDATA[open source]]></category>

		<guid isPermaLink="false">http://www.talkincode.com/?p=1217</guid>
		<description><![CDATA[Google Code has turned the grand old age of 5 today, having been launched on the 17th March 2005. I&#8217;d like to say well done! While some people may think Google Code is yet another SourceForge clone, they&#8217;re only half right. What Google Code brought to the table was more than just project hosting, it [...]]]></description>
			<content:encoded><![CDATA[<p>Google Code has turned the grand old age of 5 today, having been launched on the 17th March 2005. I&#8217;d like to say well done!</p>
<p>While some people may think Google Code is yet another SourceForge clone, they&#8217;re only half right. What Google Code brought to the table was more than just project hosting, it was a whole ethos of development which is now sweeping the world as if it were a brand new concept: open source.</p>
<p>With the Summer of Code schemes run by Google to promote open source development in universities, hosting of all of their own APIs on the service (going from a handful to a few dozen by now), along with the code for all their open source projects (now numbering in the hundreds), Google Code has shown off the more ethical side of the advertising giant.</p>
<p>So happy birthday Google Code, long may you prosper and others follow in your path!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.talkincode.com/google-code-is-5-today-1217.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Quick tips: Parallel Loading</title>
		<link>http://www.talkincode.com/quick-tips-parallel-loading-1215.html</link>
		<comments>http://www.talkincode.com/quick-tips-parallel-loading-1215.html#comments</comments>
		<pubDate>Mon, 15 Mar 2010 17:55:11 +0000</pubDate>
		<dc:creator>content</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[http]]></category>
		<category><![CDATA[speed]]></category>

		<guid isPermaLink="false">http://www.talkincode.com/?p=1215</guid>
		<description><![CDATA[&#8220;Parallel loading&#8221; is what I like to call the feature of all modern web browsers &#8211; to request multiple files at the same time. For instance, when you load this web page the first thing to be grabbed is the raw HTML file. The HTML file then links over to a variety of files such [...]]]></description>
			<content:encoded><![CDATA[<p>&#8220;Parallel loading&#8221; is what I like to call the feature of all modern web browsers &#8211; to request multiple files at the same time. For instance, when you load this web page the first thing to be grabbed is the raw HTML file. The HTML file then links over to a variety of files such as CSS files, JavaScript code and images used in the design. In the old days, a browser would have pretty much lined each one of these up and waited until one had finished before requesting the next. Not now though!</p>
<p>No, modern browsers are better behaved. They tend to begin requesting CSS files before the HTML file has finished loading, grabbing images left, right and centre and a whole lot more. Sounds great, doesn&#8217;t it ? Well, kinda.</p>
<p>One big pitfall of this is that you could be dealing with a lot of overhead from the raw HTTP requests in themselves. They are composed of data too, and take resources to manage (both client- and server-side). If you have dozens of images on one page, a CSS file or two and maybe a few JavaScript files, this can quickly bring a server to it&#8217;s knees with heavy traffic.</p>
<p>Lots of techniques exist to optimise your page load experience which are beyond the scope of this quick post. However, I would recommend reading up on the following:</p>
<ul>
<li>CSS sprites<br />
You may well have heard of these &#8211; a CSS sprite just means putting multiple images into one image file and using background positioning tricks to display each individual image. The benefit is great here since you make less HTTP requests and your file sizes will drop (less image header info).</li>
<li>Compiling multiple CSS and JavaScript files into one file<br />
This is pretty simple. Just whack all your JavaScript into one file (if possible) and the same with your CSS. This is more difficult to implement if you have a defined build and deployment system, but well worth trying.</li>
<li>Reduce the keep-alive on your HTTP server<br />
If you are serving lots of files, try to reduce the keep-alive timeout of HTTP connections. Keeping a connection alive for 15 seconds after it was opened may sound like it would reduce overhead (less connections need to be opened) but just thing of how a few dozen connections sitting around idle will sap your server resources. Better to kill &#8216;em early!</li>
<li>Don&#8217;t serve content from domains with cookie data<br />
Every time you make a request to a file on a web server which has cookie data associated with it, that cookie data gets sent in the request too. Chances are you don&#8217;t need to know if the user was logged in just to retrieve your site&#8217;s logo, so try running was is known as a &#8220;CDN&#8221; &#8211; Content Delivery Network. Google it and see!</li>
<li>Utilise caching well<br />
Caching is awesome. Well, if you don&#8217;t mess up. Try setting far-future expires times (such as 1st Jan 2038) on unchanging content such as CSS files, JavaScript files and images. The browser won&#8217;t even make the request in the first place, then! If you do need to change one of these pieces of content, a simple trick can avoid the cache not updating: append a query string to the URL. So for http://www.example.com/cssfile.css, change it to http://www.example.com/cssfile.css?v=1. When you update it, update the links to it to say http://www.example.com/cssfile.css?v=2 &#8211; that way the caching will not interfere.</li>
</ul>
<p>That should be enough to be going on with!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.talkincode.com/quick-tips-parallel-loading-1215.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Is HipHop really worth it?</title>
		<link>http://www.talkincode.com/is-hiphop-really-worth-it-1213.html</link>
		<comments>http://www.talkincode.com/is-hiphop-really-worth-it-1213.html#comments</comments>
		<pubDate>Tue, 09 Mar 2010 17:08:47 +0000</pubDate>
		<dc:creator>content</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Unix/Linux]]></category>
		<category><![CDATA[c++]]></category>
		<category><![CDATA[facebook]]></category>
		<category><![CDATA[hiphop]]></category>

		<guid isPermaLink="false">http://www.talkincode.com/?p=1213</guid>
		<description><![CDATA[In case you missed the news, a few months ago Facebook announced on their developer blog that they were releasing a piece of software to the wider community. That piece of software is called &#8216;HipHop&#8217; and is one of the many technologies Facebook run behind the scenes to keep one of the world&#8217;s most popular [...]]]></description>
			<content:encoded><![CDATA[<p>In case you missed the news, a few months ago Facebook announced on their developer blog that they were releasing a piece of software to the wider community. That piece of software is called &#8216;HipHop&#8217; and is one of the many technologies Facebook run behind the scenes to keep one of the world&#8217;s most popular sites up and running.</p>
<p>But what does it do? In short, HipHop translates PHP code into C++ code, which can then be compiled into native machine code. This, in theory, should remove a bottleneck or two from PHP itself &#8211; namely the interpreter &#8211; as a good deal of slow, interpreted code can be compiled into uber-fast native code. Well, in theory.</p>
<p>While there is a performance increase (just Google for benchmarks, there are bound to be dozens by now) I think that it simply does not justify the end for most PHP driven sites. The added complexity of ensuring all your PHP code can be understood by HipHop would be enough to drive me mad, in particular. Adding to that is the number of issues I have seen people encountering whilst trying to compile HipHop on anything other than Facebook&#8217;s own platform of choice&#8230; Not pretty.</p>
<p>It isn&#8217;t just that though. I believe the only real increase in performance is in processing-limited scenarios which just aren&#8217;t that common in real life. Sure, Facebook need it, but they serve hundreds of millions of pageviews each day. For Joe Bloggs&#8217; e-commerce store the benefit of having slightly faster C++ code would quickly evaporate when it came to any code changes needing to be first done in PHP, passed through HipHop before being compiled and then debugged for a second time as C++ code.</p>
<p>Stability isn&#8217;t really an issue due to the above reason (it has apparently been powering Facebook for a while) and apparently HipHop supports &#8216;most&#8217; PHP code, but I really do not think you should consider it for your next project. Well, unless you&#8217;re re-coding MySpace&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.talkincode.com/is-hiphop-really-worth-it-1213.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Change of management!</title>
		<link>http://www.talkincode.com/change-of-management-1211.html</link>
		<comments>http://www.talkincode.com/change-of-management-1211.html#comments</comments>
		<pubDate>Thu, 04 Mar 2010 17:25:12 +0000</pubDate>
		<dc:creator>content</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://www.talkincode.com/?p=1211</guid>
		<description><![CDATA[Regular followers of this blog will remember that in the middle of 2009, the original author could no longer commit to posting new articles and announced their departure with a final blog. I would like to say that the response to that post was quite nice, so thanks for that! However, the time has now [...]]]></description>
			<content:encoded><![CDATA[<p>Regular followers of this blog will remember that in the middle of 2009, the original author could no longer commit to posting new articles and announced their departure with a final blog. I would like to say that the response to that post was quite nice, so thanks for that!</p>
<p>However, the time has now come for someone new to begin posting to this blog. I can&#8217;t guarantee that the posts will be quite as regular &#8211; what with work and other commitments &#8211; but what I will say is that I will be trying my hardest to provide nifty tips, tricks and news on the programming world to make your life easier.</p>
<p>So, enough about that &#8211; what do you guys want to see here? My focus is on web development (the same as the previous author), but I hope to take a little twist with more posts about the art of programming and updates on the latest tools and news. Anyway, this is me signing out for now &#8211; until the next time&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.talkincode.com/change-of-management-1211.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>My Final Post</title>
		<link>http://www.talkincode.com/my-final-post-1206.html</link>
		<comments>http://www.talkincode.com/my-final-post-1206.html#comments</comments>
		<pubDate>Tue, 02 Jun 2009 20:08:58 +0000</pubDate>
		<dc:creator>Tech</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://www.talkincode.com/?p=1206</guid>
		<description><![CDATA[The time has come for me to stop writing on Talk In Code. It has been a fun couple of years, and I have learnt a lot, but as of today I will not be able to write any more posts on this blog. I want to thank everyone who has posted comments and contributed [...]]]></description>
			<content:encoded><![CDATA[<p>The time has come for me to stop writing on Talk In Code. It has been a fun couple of years, and I have learnt a lot, but as of today I will not be able to write any more posts on this blog. I want to thank everyone who has posted comments and contributed to the site since I have been writing.</p>
<p>You might see the blog being updated non-regularly in the future as I have now passed the rains on to someone else.</p>
<p>This is Tech, signing off.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.talkincode.com/my-final-post-1206.html/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Extract Keywords From A Text String With PHP</title>
		<link>http://www.talkincode.com/extract-keywords-from-a-text-string-with-php-1204.html</link>
		<comments>http://www.talkincode.com/extract-keywords-from-a-text-string-with-php-1204.html#comments</comments>
		<pubDate>Thu, 21 May 2009 16:34:47 +0000</pubDate>
		<dc:creator>Tech</dc:creator>
				<category><![CDATA[PHP Strings]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[keywords]]></category>
		<category><![CDATA[string]]></category>
		<category><![CDATA[text]]></category>
		<category><![CDATA[vending machines]]></category>

		<guid isPermaLink="false">http://www.talkincode.com/?p=1204</guid>
		<description><![CDATA[A common issue I have come across in the past is that I have a CMS system, or an old copy of WordPress, and I need to create a set of keywords to be used in the meta keywords field. To solve this I put together a simple function that runs through a string and [...]]]></description>
			<content:encoded><![CDATA[<p>A common issue I have come across in the past is that I have a CMS system, or an old copy of WordPress, and I need to create a set of keywords to be used in the meta keywords field.  To solve this I put together a simple function that runs through a string and picks out the most commonly used words in that list as an array.  This is currently set to be 10, but you can change that quite easily.</p>
<p>The first thing the function defines is a list of &quot;stop&quot; words. This is a list of words that occur quite a bit in English text and would therefore interfere with the outcome of the function. The function also uses a variant of the slug function to remove any odd characters that might be in the text.</p>
<p><code class="php">function commonWords($string){<br />
&nbsp;&nbsp;&nbsp;&nbsp;$stopWords = array(&#39;i&#39;,&#39;a&#39;,&#39;about&#39;,&#39;an&#39;,&#39;and&#39;,&#39;are&#39;,&#39;as&#39;,&#39;at&#39;,&#39;be&#39;,&#39;by&#39;,&#39;com&#39;,&#39;de&#39;,&#39;en&#39;,&#39;for&#39;,&#39;from&#39;,&#39;how&#39;,&#39;in&#39;,&#39;is&#39;,&#39;it&#39;,&#39;la&#39;,&#39;of&#39;,&#39;on&#39;,&#39;or&#39;,&#39;that&#39;,&#39;the&#39;,&#39;this&#39;,&#39;to&#39;,&#39;was&#39;,&#39;what&#39;,&#39;when&#39;,&#39;where&#39;,&#39;who&#39;,&#39;will&#39;,&#39;with&#39;,&#39;und&#39;,&#39;the&#39;,&#39;www&#39;);<br />
&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;$string = preg_replace(&#39;/ss+/i&#39;, &#39;&#39;, $string);<br />
&nbsp;&nbsp;&nbsp;&nbsp;$string = trim($string); // trim the string<br />
&nbsp;&nbsp;&nbsp;&nbsp;$string = preg_replace(&#39;/[^a-zA-Z0-9 -]/&#39;, &#39;&#39;, $string); // only take alphanumerical characters, but keep the spaces and dashes too…<br />
&nbsp;&nbsp;&nbsp;&nbsp;$string = strtolower($string); // make it lowercase<br />
&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;preg_match_all(&#39;/([a-z]*?)(?=s)/i&#39;, $string, $matchWords);<br />
&nbsp;&nbsp;&nbsp;&nbsp;$matchWords = $matchWords[0];<br />
&nbsp;&nbsp;&nbsp;&nbsp;foreach ( $matchWords as $key=&gt;$item ) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if ( $item == &#39;&#39; || in_array(strtolower($item), $stopWords) || strlen($item) &lt;= 3 ) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;unset($matchWords[$key]);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;$wordCountArr = array();<br />
&nbsp;&nbsp;&nbsp;&nbsp;if ( is_array($matchWords) ) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;foreach ( $matchWords as $key =&gt; $val ) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$val = strtolower($val);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if ( isset($wordCountArr[$val]) ) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$wordCountArr[$val]++;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} else {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$wordCountArr[$val] = 1;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;arsort($wordCountArr);<br />
&nbsp;&nbsp;&nbsp;&nbsp;$wordCountArr = array_slice($wordCountArr, 0, 10);<br />
&nbsp;&nbsp;&nbsp;&nbsp;return $wordCountArr;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />
}</code></p>
<p>Here is an example of the function in action.</p>
<p><code class="php">$text = &quot;This is some text. This is some text. <a href="http://www.linkvending.co.uk/" title="Vending Machines">Vending Machines</a> are great.&quot;;<br />
$words = commonWords($text);<br />
echo implode(&#39;,&#39;, array_keys($words));</code></p>
<p>This produces the following output.</p>
<p><code class="php">some,text,machines,vending</code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.talkincode.com/extract-keywords-from-a-text-string-with-php-1204.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Excel Document Scanning With Zend_Search_Lucene</title>
		<link>http://www.talkincode.com/excel-document-scanning-with-zend_search_lucene-1195.html</link>
		<comments>http://www.talkincode.com/excel-document-scanning-with-zend_search_lucene-1195.html#comments</comments>
		<pubDate>Mon, 11 May 2009 09:25:21 +0000</pubDate>
		<dc:creator>Tech</dc:creator>
				<category><![CDATA[Zend Framework]]></category>
		<category><![CDATA[Excel]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Zend_Search_Lucene_Document_Xlsx]]></category>

		<guid isPermaLink="false">http://www.talkincode.com/?p=1195</guid>
		<description><![CDATA[Zend_Search_Lucene offers some powerful document scanning capabilities, and there are a few different formats that are useful for the search engine to index. To allow the indexing and searching of Excel documents using Zend_Search_Lucene you need to use the Zend_Search_Lucene_Document_Xlsx class. However, to use this class you must have the Zip module installed with PHP. [...]]]></description>
			<content:encoded><![CDATA[<p>Zend_Search_Lucene offers some powerful <a href="http://www.microstat.co.uk/" title="Document scanning">document scanning</a> capabilities, and there are a few different formats that are useful for the search engine to index.</p>
<p>To allow the indexing and searching of Excel documents using Zend_Search_Lucene you need to use the Zend_Search_Lucene_Document_Xlsx class. However, to use this class you must have the Zip module installed with PHP.  For Windows users this means editing your php.ini file and uncommenting the following line:</p>
<p><code>extension=php_zip.dll</code></p>
<p>For Linux users you will need to recompile PHP with the &#8211;enable-zip configure option.</p>
<p>Create and/or open the index in the normal way and you can index Excel documents using the following code.</p>
<p><code class="php">$filename = &#39;C:\Book1.xlsx&#39;;<br />
$doc = Zend_Search_Lucene_Document_Xlsx::loadXlsxFile($filename);<br />
$index-&gt;addDocument($doc);</code></p>
<p>You can now set up a query and search for the document in the following way, although you would normally expect the input string to be some kind of user input.</p>
<p><code class="php">$queryStr = &#39;wibble&#39;;<br />
$userQuery = Zend_Search_Lucene_Search_QueryParser::parse($queryStr);<br />
&nbsp;<br />
$query = new Zend_Search_Lucene_Search_Query_Boolean();<br />
$query-&gt;addSubquery($userQuery, true);<br />
&nbsp;<br />
&nbsp;<br />
$hits = $index-&gt;find($query);<br />
&nbsp;<br />
foreach ( $hits as $hit ) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;echo $hit-&gt;score.&#39;&lt;br /&gt;&#39;;<br />
&nbsp;&nbsp;&nbsp;&nbsp;echo $hit-&gt;filename.&#39;&lt;br /&gt;&#39;;<br />
}</code></p>
<p>The score is always returned with a hit object. Other parameters available to display are filename, title, subject, creator, keywords, description, lastModifiedBy, revision, modified, created. However, some of these depend on the contents of the document. It is possible to add keywords and subjects to an Excel document, so if they are not present then you will need to check for the existence of that parameter before displaying it.  The following code looks for the existence of the keyword parameter before trying to print it out.</p>
<p><code class="php">if ( isset($hit-&gt;keywords) ) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;echo $hit-&gt;keywords.&#39;&lt;br /&gt;&#39;;<br />
}</code></p>
<p>By default, this function indexes the document meta data and will tokenise and store the tokens as an index. The loadXlsxFile() function has a second optional parameter which is by default set to false. If this is set to true the contents of the Excel document will be included in the index.  You can then use the following code to print out the contents of the document.</p>
<p><code>echo .$hit-&gt;body.&#39;&lt;br /&gt;&#39;;</code></p>
<p>Bear in mind that this output will not contain any row or column information and will therefore look like a dump of the data.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.talkincode.com/excel-document-scanning-with-zend_search_lucene-1195.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Multi Page Forms In PHP</title>
		<link>http://www.talkincode.com/multi-page-forms-in-php-1171.html</link>
		<comments>http://www.talkincode.com/multi-page-forms-in-php-1171.html#comments</comments>
		<pubDate>Tue, 05 May 2009 11:14:03 +0000</pubDate>
		<dc:creator>Tech</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[form]]></category>
		<category><![CDATA[get]]></category>
		<category><![CDATA[multi]]></category>
		<category><![CDATA[multipage]]></category>
		<category><![CDATA[page]]></category>
		<category><![CDATA[post]]></category>
		<category><![CDATA[session]]></category>

		<guid isPermaLink="false">http://www.talkincode.com/?p=1171</guid>
		<description><![CDATA[Multi pages forms are just as they sound, a single form spread across multiple pages. These are useful in terms of usability as it can break up an otherwise dauntingly big form into smaller chunks. It can also be useful if you want to process some of the results in order to determine what forms [...]]]></description>
			<content:encoded><![CDATA[<p>Multi pages forms are just as they sound, a single form spread across multiple pages. These are useful in terms of usability as it can break up an otherwise dauntingly big form into smaller chunks. It can also be useful if you want to process some of the results in order to determine what forms the user sees on later steps.</p>
<p>There are two ways in which it is possible to do this using PHP.</p>
<p>The first (and simplest) is just to cycle through the items submitted on a previous form and print them out as hidden fields. Our first page source code will look like this:</p>
<p><code>&lt;form action=&quot;form2.php&quot; method=&quot;get&quot;&gt;<br />
Name: &lt;input type=&quot;text&quot; name=&quot;name&quot; /&gt;<br />
&lt;br /&gt;<br />
&lt;input type=&quot;submit&quot; value=&quot;Proceed&quot;&gt;<br />
&lt;/form&gt;</code></p>
<p>On submitting the form we are taken to form2.php, which asks the user a different question and prints out the hidden fields.  Because we used a get request for our first form we need to use the $_GET array.</p>
<p><code class="php">&lt;form action=&quot;end.php&quot; method=&quot;get&quot;&gt;<br />
Colour: &lt;input type=&quot;text&quot; name=&quot;colour&quot; /&gt;<br />
&lt;br /&gt;<br />
&lt;?php<br />
foreach ( $_GET as $key=&gt;$value ) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;if ( $key!=&quot;submit&quot; ) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$value = htmlentities(stripslashes(strip_tags($value)));<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo &quot;t&lt;input type=&quot;hidden&quot; name=&quot;$key&quot; value=&quot;$value&quot;&gt;\n&quot;;<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
}<br />
?&gt;<br />
&lt;input type=&quot;submit&quot; value=&quot;Proceed&quot;&gt;<br />
&lt;/form&gt;</code></p>
<p>This same code can be used on the different pages of the form.  This method is fine, and works quite well, but it doesn&#8217;t account for users going back through the form and resubmitting a previous item.  The $_GET array will only contain information about the previous forms.</p>
<p>To make this more user friendly, and robust, we need to employ a session to store our form values as the user goes through the form.  Using sessions means that the user can cycle back and forward through the forms with no ill effect on the form data.  The following code will take the input of the previous form and save it as a PHP session.</p>
<p><code class="php">session_start();<br />
foreach ( $_GET as $key=&gt;$value ) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;if ( $key!=&quot;submit&quot; ) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$value = htmlentities(stripslashes(strip_tags($value)));<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$_SESSION[$key] = $value;<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
}</code></p>
<p>This must be included on every page of our multi page form. If it is not then the data will simply not be saved for that step. Your users can now move back and forward through the forms, saving the information as they go.  You need to supply a back button for this to work as using the browser back and forward buttons will also not save the data.</p>
<p>Finally, when testing this code I found that using GET rather than POST was beneficial in terms of usability. This is mainly because if you use POST requests and the user clicks the back on their browser they will be asked if they want to resubmit the information for that form.</p>
<p>Does anyone else have any ideas about how to do this? If so then post a comment and suggest it. You can even put a post in the forum!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.talkincode.com/multi-page-forms-in-php-1171.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

