 



<?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>lamehacks</title>
	<atom:link href="http://lamehacks.net/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://lamehacks.net/blog</link>
	<description>Stuff is fun</description>
	<lastBuildDate>Mon, 06 Feb 2012 16:09:13 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>View on flickriver userscript</title>
		<link>http://lamehacks.net/blog/view-on-flickriver-userscript/</link>
		<comments>http://lamehacks.net/blog/view-on-flickriver-userscript/#comments</comments>
		<pubDate>Mon, 06 Feb 2012 14:37:54 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[computer stuff]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[flickr]]></category>
		<category><![CDATA[flickriver]]></category>
		<category><![CDATA[greasemonkey]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[scriptish]]></category>
		<category><![CDATA[userscript]]></category>

		<guid isPermaLink="false">http://lamehacks.net/blog/?p=313</guid>
		<description><![CDATA[Flickr&#8217;s navigation and layout have been a source of increasing frustration for me. I find myself copy-pasting search phrases, usernames and tags on flickriver all the time. To put an end to this endless copy-pasting, I put together a small userscript that adds links to flickriver on flickr pages. It&#8217;s just a few lines of [...]]]></description>
			<content:encoded><![CDATA[<p>Flickr&#8217;s navigation and layout have been a source of increasing frustration for me. I find myself copy-pasting search phrases, usernames and tags on <a href="http://flickriver.com">flickriver</a> all the time.<br />
To put an end to this endless copy-pasting, I put together a small userscript that adds links to flickriver on flickr pages.</p>
<p><a href="http://lamehacks.net/blog/wp-content/uploads/2012/02/flickr.png"><img src="http://lamehacks.net/blog/wp-content/uploads/2012/02/flickr-300x174.png" alt="" title="flickr" width="300" height="174" class="alignnone size-medium wp-image-314" /></a></p>
<p>It&#8217;s just a few lines of ghetto flavored javascript, but it does what it is supposed to. It works on Chrome/Chromium, Firefox and Opera. I don&#8217;t know (don&#8217;t care) if it will work on other browsers.<br />
Download it <a href="https://gist.github.com/raw/1748810/86848686adbdd80acdb884481901dc53826aecdd/viewonflickriver.user.js">here</a>.</p>
<p>In case you want to further improve it, feel free to fork it on github:<br />
<a href="https://gist.github.com/1748810">https://gist.github.com/1748810</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://lamehacks.net/blog/view-on-flickriver-userscript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>More processing.js fun</title>
		<link>http://lamehacks.net/blog/more-processing-js-fun/</link>
		<comments>http://lamehacks.net/blog/more-processing-js-fun/#comments</comments>
		<pubDate>Thu, 02 Feb 2012 12:40:20 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://lamehacks.net/blog/?p=297</guid>
		<description><![CDATA[This time I wanted to try processing.js as a javascript library (object, to be strict) instead of writing a processing sketch. To be honest, this felt easier than referring to a new language. Also, there&#8217;s the advantage of all the available javascript debugging tools such as firebug. This lame colorscheme generator was the result. See [...]]]></description>
			<content:encoded><![CDATA[<p>This time I wanted to try processing.js as a javascript library (object, to be strict) instead of writing a processing sketch. To be honest, this felt easier than referring to a new language. Also, there&#8217;s the advantage of all the available javascript debugging tools such as firebug.</p>
<p>This lame colorscheme generator was the result.<br />
<a href="http://plainas.github.com/cubecolors"><img src="http://lamehacks.net/blog/wp-content/uploads/2012/02/cubecolorsscreen-300x222.png" alt="" title="cubecolorsscreen" width="300" height="222" class="alignnone size-medium wp-image-304" /></a></a></p>
<p>See it in action here <br />
<a href="http://plainas.github.com/cubecolors" title="Colorscheme generator">http://plainas.github.com/cubecolors</a></p</p>
]]></content:encoded>
			<wfw:commentRss>http://lamehacks.net/blog/more-processing-js-fun/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Building my own computer from scratch&#8230; kind of</title>
		<link>http://lamehacks.net/blog/building-my-own-computer-from-scratch-kind-of/</link>
		<comments>http://lamehacks.net/blog/building-my-own-computer-from-scratch-kind-of/#comments</comments>
		<pubDate>Wed, 04 Jan 2012 04:00:42 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Books]]></category>
		<category><![CDATA[computer stuff]]></category>
		<category><![CDATA[books]]></category>

		<guid isPermaLink="false">http://lamehacks.net/blog/?p=274</guid>
		<description><![CDATA[I am reading The Elements of Computing Systems. I&#8217;ve been wanting to read a few computer science classics but I thought I would start by reading this instead (it&#8217;s not a classic&#8230; yet) as I feel like there are holes in my knowledge. Just as an example, I have never implemented a virtual machine nor [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://lamehacks.net/blog/wp-content/uploads/2012/01/cover.jpg"><img src="http://lamehacks.net/blog/wp-content/uploads/2012/01/cover-266x300.jpg" alt="The elements of computing systems" title="The elements of computing systems" width="200" height="235" class="alignright size-medium wp-image-275" /></a>I am reading The Elements of Computing Systems. I&#8217;ve been wanting to read a few computer science classics but I thought I would start by reading this instead (it&#8217;s not a classic&#8230; yet) as I feel like there are holes in my knowledge. Just as an example, I have never implemented a virtual machine nor have written an emulator. Those are the kind of basic challenges that every computer hacker should beat at least once.</p>
<p>This is a rather uncommon kind of textbook. First of all, it openly presents itself as a light accessible book that can easily be picked up by anybody with little knowledge of computing systems, but at the same time it sets a very ambitious goal to the reader: to build a computing system completely &#8216;from NAND to Tetris&#8217;. Secondly, there are no exercises for the reader to practice, there are project specifications that should be implemented by the reader. The projects are self contained, I could implement them in whichever order I wanted. That said, they communicative with each other through well defined interfaces so that in the end, the group of all the projects form a complete computing system.</p>
<p>I&#8217;ve red the first three chapters and it has been a joy to read and to implement the projects.</p>
<p>For more information about the book check out <a href="http://www1.idc.ac.il/tecs/">its official website</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://lamehacks.net/blog/building-my-own-computer-from-scratch-kind-of/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Implementing a state machine in javascript</title>
		<link>http://lamehacks.net/blog/implementing-a-state-machine-in-javascript/</link>
		<comments>http://lamehacks.net/blog/implementing-a-state-machine-in-javascript/#comments</comments>
		<pubDate>Sun, 11 Dec 2011 13:10:56 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[computer stuff]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[finite state automaton]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[state machine]]></category>

		<guid isPermaLink="false">http://lamehacks.net/blog/?p=244</guid>
		<description><![CDATA[For reasons beyond my understanding, and despite their relative ubuiquity, state machines are still largely disregarded by a huge slice of programmers. Many problems can be modeled using a state machine, the most common one is the maintenance of a database table column which holds some kind of state. Many programmers don&#8217;t realize that they [...]]]></description>
			<content:encoded><![CDATA[<p>For reasons beyond my understanding, and despite their relative ubuiquity, state machines are still largely disregarded by a huge slice of programmers.<br />
Many problems can be modeled using a state machine, the most common one is the maintenance of a database table column which holds some kind of state. Many programmers don&#8217;t realize that they are in presence of a state machine and end up throwing bits of code accross the codebase to flip state whenever necessary. They are basically resourcing to a messy ad-hoc implementation of a state machine without realizing it. Personally I&#8217;ve been tearing my hair off because of this countless times.<br />
Simply put, if you&#8217;re going to use ad-hoc code to flip states among three or more possible values, you are going to make mistakes and ultimately render you codebase unmanageable.<br />
<span id="more-244"></span></p>
<p>But what&#8217;s a sate machine anyway?</p>
<p><strong>From wikipedia:</strong><br />
<em>A finite-state machine (FSM) or finite-state automaton (plural: automata), or simply a state machine, is a mathematical model used to design computer programs and digital logic circuits. It is conceived as an abstract machine that can be in one of a finite number of states. The machine is in only one state at a time; the state it is in at any given time is called the current state. It can change from one state to another when initiated by a triggering event or condition, this is called a transition. A particular FSM is defined by a list of the possible states it can transition to from each state, and the triggering condition for each transition.</em></p>
<p>To show how harmless state machines are, I&#8217;m going to model myself with a state machine. More specifically I&#8217;ll use a state machine to model a day at work.</p>
<p>So, my average work day consists of writting software in front of a computer screen. When I get bored I make a pause for coffee, after a few minutes I go back to work. If somebody calls for a meeting I imediatly follow, regardless if I&#8217;m working or having a coffee. Once the meeting is over I go back to work.</p>
<p>Let&#8217;s put this into a diagram for clarity.<br />
<a href="http://lamehacks.net/blog/wp-content/uploads/2011/12/Sem-título.gif"><img src="http://lamehacks.net/blog/wp-content/uploads/2011/12/Sem-título.gif" alt="" title="A day at work" width="500" height="317" class="alignnone size-full wp-image-248" /></a></p>
<p>If you&#8217;re an electrical enginner like myself, you&#8217;ll notice the similarity between this diagram and a state diagram of a circuit with flip-flops. That is not a coincidence, sequential logic circuits are state machines.</p>
<p>On to the implementation, I&#8217;ll use javascript, but obviously this can be done in your favorite language. But first, let&#8217;s start by specifying the sate machine by writting down all the states and transitions among them.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">states <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #3366CC;">'name'</span><span style="color: #339933;">:</span><span style="color: #3366CC;">'working'</span><span style="color: #339933;">,</span>
		<span style="color: #3366CC;">'initial'</span><span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span>
		<span style="color: #3366CC;">'events'</span><span style="color: #339933;">:</span><span style="color: #009900;">&#123;</span>
			<span style="color: #3366CC;">'bored'</span><span style="color: #339933;">:</span><span style="color: #3366CC;">'coffee'</span><span style="color: #339933;">,</span>
			<span style="color: #3366CC;">'call_for_meeting'</span><span style="color: #339933;">:</span><span style="color: #3366CC;">'meeting'</span><span style="color: #339933;">,</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #3366CC;">'name'</span><span style="color: #339933;">:</span><span style="color: #3366CC;">'coffee'</span><span style="color: #339933;">,</span>
		<span style="color: #3366CC;">'events'</span><span style="color: #339933;">:</span><span style="color: #009900;">&#123;</span>
			<span style="color: #3366CC;">'break_over'</span><span style="color: #339933;">:</span><span style="color: #3366CC;">'working'</span><span style="color: #339933;">,</span>
			<span style="color: #3366CC;">'call_for_meeting'</span><span style="color: #339933;">:</span><span style="color: #3366CC;">'meeting'</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #3366CC;">'name'</span><span style="color: #339933;">:</span><span style="color: #3366CC;">'meeting'</span><span style="color: #339933;">,</span>
		<span style="color: #3366CC;">'events'</span><span style="color: #339933;">:</span><span style="color: #009900;">&#123;</span>
			<span style="color: #3366CC;">'meetings_over'</span><span style="color: #339933;">:</span><span style="color: #3366CC;">'working'</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span></pre></div></div>

<p>This is pretty self-explanatory.<br />
The implementation is straightforward too: a constructor sets up the state machine when provided with a state machine definition such as the example above.  Aditionally we define two extra methods, one to handle events and other to report the current state. What could be simpler?</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> StateMachine<span style="color: #009900;">&#40;</span>states<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">states</span> <span style="color: #339933;">=</span> states<span style="color: #339933;">;</span>
	<span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">indexes</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">//just for convinience</span>
	<span style="color: #000066; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span> <span style="color: #003366; font-weight: bold;">var</span> i <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> i<span style="color: #339933;">&lt;</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">states</span>.<span style="color: #660066;">length</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">indexes</span><span style="color: #009900;">&#91;</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">states</span><span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #000066;">name</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> i<span style="color: #339933;">;</span>
		<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">states</span><span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">initial</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
			<span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">currentState</span> <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">states</span><span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">consumeEvent</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>e<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">currentState</span>.<span style="color: #660066;">events</span><span style="color: #009900;">&#91;</span>e<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
			<span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">currentState</span> <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">states</span><span style="color: #009900;">&#91;</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">indexes</span><span style="color: #009900;">&#91;</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">currentState</span>.<span style="color: #660066;">events</span><span style="color: #009900;">&#91;</span>e<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">getStatus</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #000066; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">currentState</span>.<span style="color: #000066;">name</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>And that&#8217;s it! Let&#8217;s see it in action.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">sm <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> StateMachine<span style="color: #009900;">&#40;</span>states<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
sm.<span style="color: #660066;">getStatus</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// will return 'working'</span>
&nbsp;
sm.<span style="color: #660066;">consumeEvent</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'bored'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
sm.<span style="color: #660066;">getStatus</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// I went for coffee</span>
&nbsp;
sm.<span style="color: #660066;">consumeEvent</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'call_for_meeting'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
sm.<span style="color: #660066;">getStatus</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">//will return 'meeting'</span>
&nbsp;
sm.<span style="color: #660066;">consumeEvent</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'bored'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">//doesn't matter how boring a meeting can be...</span>
sm.<span style="color: #660066;">getStatus</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">//will still return 'meeting'</span>
&nbsp;
sm.<span style="color: #660066;">consumeEvent</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'meetings_over'</span><span style="color: #009900;">&#41;</span>
sm.<span style="color: #660066;">getStatus</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// 'working'</span></pre></div></div>

<p>In many scenarios you might want to add some extra features such as signaling, external persistence or hooks, but this is basically it.</p>
]]></content:encoded>
			<wfw:commentRss>http://lamehacks.net/blog/implementing-a-state-machine-in-javascript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to fix Canon  Powershot A590 IS  battery issue</title>
		<link>http://lamehacks.net/blog/how-to-fix-canon-powershot-a590-is-battery-issue/</link>
		<comments>http://lamehacks.net/blog/how-to-fix-canon-powershot-a590-is-battery-issue/#comments</comments>
		<pubDate>Sat, 10 Dec 2011 03:35:04 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[hardware hacks]]></category>
		<category><![CDATA[photography]]></category>
		<category><![CDATA[battery]]></category>
		<category><![CDATA[canon]]></category>
		<category><![CDATA[canon a690is]]></category>
		<category><![CDATA[fix]]></category>
		<category><![CDATA[how to]]></category>

		<guid isPermaLink="false">http://lamehacks.net/blog/?p=259</guid>
		<description><![CDATA[I have mixed feelings about this camera, while it packed a great set of features for its price, the image quality was notoriously inferior to older A-series cameras such as the A60, A80,A80, etc. But the big deal breaker was the battery issue. Most cameras would run out of battery (well, not quite, read bellow) [...]]]></description>
			<content:encoded><![CDATA[<p>I have mixed feelings about this camera, while it packed a great set of features for its price, the image quality was notoriously inferior to older A-series cameras such as the A60, A80,A80, etc.<br />
But the big deal breaker was the battery issue. Most cameras would run out of battery (well, not quite, read bellow) after very few shots. This defect affected nearly every unit of this and similar models. So badly that canon pulled these cameras out of the market as quickly as possible.<span id="more-259"></span></p>
<p>Most of the people that owned this camera most likely already replaced it. But for those who still have the camera laying on the back of some drawer, the fix is surprisingly quick and simple. And it will bring back this perfectly usable camera to life.</p>
<p>All you have to do is force the metal contact on the strip slightly out of its place. This way the metal contact between the metal and piece and the battery will be more effective.</p>
<p>With a pointy object such as a knife or a screw driver, press the tip of the metal lid so it bends until it gets out of it place. The picture bellow should give you a clearer idea:<br />
<a href="http://lamehacks.net/blog/wp-content/uploads/2011/12/1.jpg"><img src="http://lamehacks.net/blog/wp-content/uploads/2011/12/1.jpg" alt="" title="Canon A590is" width="562" height="500" class="alignnone size-full wp-image-260" /></a></p>
<p>Notice that you need to press from the tip of the strip first.</p>
<p>And here&#8217;s how it should look after the procedure<br />
<a href="http://lamehacks.net/blog/wp-content/uploads/2011/12/2.jpg"><img src="http://lamehacks.net/blog/wp-content/uploads/2011/12/2.jpg" alt="" title="Canon 590is fixed" width="500" height="442" class="alignnone size-full wp-image-261" /></a></p>
<p>The lid will be slightly more difficult to close, but that&#8217;s barely noticeable.</p>
<p>I&#8217;ve seen dozens of fix suggestions that mention buying fancy batteries or install a custom firmware called CHDK which allows you to set the the threshold voltage that triggers the battery warning. All these sound like non-fixes to me, ultimately this is not a small software  or electronics issue. It&#8217;s simply a malfunction electric contact. No camera setting or expensive batteries will fix that.</p>
]]></content:encoded>
			<wfw:commentRss>http://lamehacks.net/blog/how-to-fix-canon-powershot-a590-is-battery-issue/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fun with processing &#8211; basic isometric selector</title>
		<link>http://lamehacks.net/blog/fun-with-processing-basic-isometric-selector/</link>
		<comments>http://lamehacks.net/blog/fun-with-processing-basic-isometric-selector/#comments</comments>
		<pubDate>Sat, 29 Oct 2011 05:48:01 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[isometric]]></category>
		<category><![CDATA[processing]]></category>

		<guid isPermaLink="false">http://lamehacks.net/blog/?p=231</guid>
		<description><![CDATA[Below is a simple (x,y,z) isometric selection I made with the sole purpose of trying out processing. Download source.]]></description>
			<content:encoded><![CDATA[<p>Below is a simple (x,y,z) isometric selection I made with the sole purpose of trying out processing.<br />
<span id="more-231"></span><br />
<script src="http://lamehacks.net/blog/wp-content/uploads/2011/10/processing-1.3.6.min_.js"></script><br />
<canvas data-processing-sources="http://lamehacks.net/blog/wp-content/uploads/2011/10/cubepde.js"></canvas></p>
<p><a href="https://gist.github.com/1324117" title="isometric slesctor">Download source</a>. </p>
]]></content:encoded>
			<wfw:commentRss>http://lamehacks.net/blog/fun-with-processing-basic-isometric-selector/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Linear algebra in javascript</title>
		<link>http://lamehacks.net/blog/linear-algebra-in-javascript/</link>
		<comments>http://lamehacks.net/blog/linear-algebra-in-javascript/#comments</comments>
		<pubDate>Mon, 12 Sep 2011 22:09:40 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[computer stuff]]></category>
		<category><![CDATA[Mathematics]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[algebra]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[mathematics]]></category>
		<category><![CDATA[ualgebra.js]]></category>

		<guid isPermaLink="false">http://lamehacks.net/blog/?p=224</guid>
		<description><![CDATA[Every other week I find myself solving some kind of problem that involves matrix operations or other linear algebra concepts. I still have my old TI-89 from when I was a student. It&#8217;s a handy calculator, no doubt about that, older people will even call it a luxury. But quite frankly, I don&#8217;t know why [...]]]></description>
			<content:encoded><![CDATA[<p>Every other week I find myself solving some kind of problem that involves matrix operations or other linear algebra concepts. I still have my old <a href="http://en.wikipedia.org/wiki/TI-89_series" title="TI-89" target="_blank">TI-89</a> from when I was a student. It&#8217;s a handy calculator, no doubt about that, older people will even call it a luxury. But quite frankly, I don&#8217;t know why we should use calculators considering the speed of an average personal computer. Or even a cellphone in case you&#8217;re thinking about throwing the portability argument.<br />
Anyway, rants aside, I was bored so I put together a tiny javascript library with basic linear algebra functions.<br />
<span id="more-224"></span></p>
<p>Here&#8217;s the infamous system of linear equations solve example:</p>
<p>Let&#8217;s consider the following system of linear equations:</p>
<pre>
x + y + z = 1
x + 2y + 3z = 4
x + 4y + 8z = 8</pre>
<p>from your first algebra class..</p>
<pre>A.x = b
x = Inv(A).b</pre>
<p>So let&#8217;s just to that</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">A <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#91;</span><span style="color: #CC0000;">1</span><span style="color: #339933;">,</span><span style="color: #CC0000;">1</span><span style="color: #339933;">,</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><span style="color: #009900;">&#91;</span><span style="color: #CC0000;">1</span><span style="color: #339933;">,</span><span style="color: #CC0000;">2</span><span style="color: #339933;">,</span><span style="color: #CC0000;">3</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><span style="color: #009900;">&#91;</span><span style="color: #CC0000;">1</span><span style="color: #339933;">,</span><span style="color: #CC0000;">4</span><span style="color: #339933;">,</span><span style="color: #CC0000;">8</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
b <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#91;</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><span style="color: #009900;">&#91;</span><span style="color: #CC0000;">4</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><span style="color: #009900;">&#91;</span><span style="color: #CC0000;">8</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
Ai <span style="color: #339933;">=</span> inverseMatrix<span style="color: #009900;">&#40;</span>a<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
x <span style="color: #339933;">=</span> matrixMultiply<span style="color: #009900;">&#40;</span>Ai<span style="color: #339933;">,</span>b<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">//will return the solution [[28],[49],[22]] yay!!!</span></pre></div></div>

<p>More examples and download at <a href="https://github.com/plainas/ualgebra.js" title="ualgebra.js" target="_blank">github</a>.</p>
<p>Mmm&#8230;. turns out my rant is <a href="http://xkcd.com/768/" title="TI WTF" target="_blank">all but original</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://lamehacks.net/blog/linear-algebra-in-javascript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>galleria for wordpress</title>
		<link>http://lamehacks.net/blog/galleria-for-wordpress/</link>
		<comments>http://lamehacks.net/blog/galleria-for-wordpress/#comments</comments>
		<pubDate>Wed, 07 Sep 2011 02:02:53 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[computer stuff]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[galleria]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[slidesho]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://lamehacks.net/blog/?p=210</guid>
		<description><![CDATA[Galleria is an awesome slideshow gallery built on top of jquery. After trying out about 10 different picture slideshow plugins for wordpress I couldn&#8217;t find one that would do what exactly what I want. For some reason, none of the plugins I tried was able to display more than one gallery in the same page. [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://galleria.aino.se/" target="_blank">Galleria</a> is an awesome slideshow gallery built on top of jquery.<br />
After trying out about 10 different picture slideshow plugins for wordpress I couldn&#8217;t find one that would do what exactly what I want. For some reason, none of the plugins I tried was able to display more than one gallery in the same page. I wonder what use scenarios fall into that stupid restriction. Personally I don&#8217;t see any point on installing a picture slideshow plugin and use it once, but that&#8217;s just me.</p>
<p>So I ended up rolling my own. I googled around and picked galleria out of many javascript slideshow scripts, and wrapped it in a wordpress plugin.<br />
<a href="https://github.com/plainas/post-slideshow-gallery" title="post slideshow gallery" target="_blank"><br />
Grab it from github</a>.</p>
<p>Demo slideshow:<br />




<div id="galleria-p210">
</div> 

<style> 
<!--
#galleria-p210{
	height:300px;
	width:400px;

}
-->
</style>

<script> 


data = [{"image":"http:\/\/lamehacks.net\/blog\/wp-content\/uploads\/2011\/09\/6EE4A2DECDF144CC860F22B04EB78C39.jpg","thumb":"http:\/\/lamehacks.net\/blog\/wp-content\/uploads\/2011\/09\/6EE4A2DECDF144CC860F22B04EB78C39-150x150.jpg","layer":"\t\t\t<div class=\"psgwrapper\">\r\n\t\t\t<h4 class=\"psgtitle\">6EE4A2DECDF144CC860F22B04EB78C39<\/h4>\r\n\t\t\t<p class=\"psgdescription\"><\/p>\r\n\t\t\t<\/div>"},{"image":"http:\/\/lamehacks.net\/blog\/wp-content\/uploads\/2011\/09\/8E0321E5A7FC49D0A5E05784AFA56C80.jpg","thumb":"http:\/\/lamehacks.net\/blog\/wp-content\/uploads\/2011\/09\/8E0321E5A7FC49D0A5E05784AFA56C80-150x150.jpg","layer":"\t\t\t<div class=\"psgwrapper\">\r\n\t\t\t<h4 class=\"psgtitle\">8E0321E5A7FC49D0A5E05784AFA56C80<\/h4>\r\n\t\t\t<p class=\"psgdescription\"><\/p>\r\n\t\t\t<\/div>"},{"image":"http:\/\/lamehacks.net\/blog\/wp-content\/uploads\/2011\/09\/6112DFB5A2204E5D9FFBC94A8F4810D6.jpg","thumb":"http:\/\/lamehacks.net\/blog\/wp-content\/uploads\/2011\/09\/6112DFB5A2204E5D9FFBC94A8F4810D6-150x150.jpg","layer":"\t\t\t<div class=\"psgwrapper\">\r\n\t\t\t<h4 class=\"psgtitle\">6112DFB5A2204E5D9FFBC94A8F4810D6<\/h4>\r\n\t\t\t<p class=\"psgdescription\"><\/p>\r\n\t\t\t<\/div>"},{"image":"http:\/\/lamehacks.net\/blog\/wp-content\/uploads\/2011\/09\/27651C0C837B4780823F38BC870E5A71.jpg","thumb":"http:\/\/lamehacks.net\/blog\/wp-content\/uploads\/2011\/09\/27651C0C837B4780823F38BC870E5A71-150x150.jpg","layer":"\t\t\t<div class=\"psgwrapper\">\r\n\t\t\t<h4 class=\"psgtitle\">27651C0C837B4780823F38BC870E5A71<\/h4>\r\n\t\t\t<p class=\"psgdescription\"><\/p>\r\n\t\t\t<\/div>"},{"image":"http:\/\/lamehacks.net\/blog\/wp-content\/uploads\/2011\/09\/A497AD6040194C25B125325480FBC8D3.jpg","thumb":"http:\/\/lamehacks.net\/blog\/wp-content\/uploads\/2011\/09\/A497AD6040194C25B125325480FBC8D3-150x150.jpg","layer":"\t\t\t<div class=\"psgwrapper\">\r\n\t\t\t<h4 class=\"psgtitle\">A497AD6040194C25B125325480FBC8D3<\/h4>\r\n\t\t\t<p class=\"psgdescription\"><\/p>\r\n\t\t\t<\/div>"},{"image":"http:\/\/lamehacks.net\/blog\/wp-content\/uploads\/2011\/09\/C8D7A94116DD4034BED6310BCE7C47DE.jpg","thumb":"http:\/\/lamehacks.net\/blog\/wp-content\/uploads\/2011\/09\/C8D7A94116DD4034BED6310BCE7C47DE-150x150.jpg","layer":"\t\t\t<div class=\"psgwrapper\">\r\n\t\t\t<h4 class=\"psgtitle\">C8D7A94116DD4034BED6310BCE7C47DE<\/h4>\r\n\t\t\t<p class=\"psgdescription\"><\/p>\r\n\t\t\t<\/div>"}];

Galleria.loadTheme('wp-content/plugins/post-slideshow-gallery/galleria/themes/classic/galleria.classic.js');

// Initialize Galleria
jQuery('#galleria-p210').galleria({
	imageCrop: false,
	dataSource: data,
	transition: 'fadeslide',
	debug:false,
});

</script> </p>
]]></content:encoded>
			<wfw:commentRss>http://lamehacks.net/blog/galleria-for-wordpress/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Azulejo update &#8211; new keybinds and .deb package</title>
		<link>http://lamehacks.net/blog/azulejo-update-new-keybinds-and-deb-package/</link>
		<comments>http://lamehacks.net/blog/azulejo-update-new-keybinds-and-deb-package/#comments</comments>
		<pubDate>Wed, 16 Mar 2011 20:01:50 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[computer stuff]]></category>
		<category><![CDATA[Gnome]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[azulejo]]></category>
		<category><![CDATA[gnome]]></category>
		<category><![CDATA[openbox]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[tilling]]></category>
		<category><![CDATA[wnck]]></category>
		<category><![CDATA[xfce]]></category>

		<guid isPermaLink="false">http://lamehacks.net/blog/?p=198</guid>
		<description><![CDATA[So&#8230; After a  great deal of procrastination, I&#8217;m releasing a deb package of azulejo with some new window tilling actions. This is still very unstable/experimental. To take advantage of the new features, you must delete your ~/.azulejorc.js in case you&#8217;re already using azulejo. Here goes the current list of keyboard shortcuts: Super+2 Place two windows [...]]]></description>
			<content:encoded><![CDATA[<p>So&#8230; After a  great deal of procrastination, I&#8217;m releasing a deb package of <a href="http://lamehacks.net/blog/introducing-azulejo-user-friendly-window-tilling/">azulejo</a> with some new window tilling actions.<br />
This is still very unstable/experimental. To take advantage of the new features, you must delete your ~/.azulejorc.js in case you&#8217;re already using azulejo.</p>
<p>Here goes the current list of keyboard shortcuts:</p>
<pre>Super+2		Place two windows side by side
Super+3		Place a window on the left half of the screen and two on the right half
Super+4		Arrange four windows two by two
Super+R		Rotate windows' positions i.e. cycle windows
Super+H		Resize and move current window to the left
Super+K		Resize and move current window to the right
Super+Y		Resize and move current window to left upper corner
Super+U		Resize and move current window to right upper corner
Super+B		Resize and move current window to left lower corner
Super+N		Resize and move current window to right lower corner</pre>
<p><a href="https://bitbucket.org/plainas/azulejo/downloads/azulejo_0.1-1_all.deb">Download deb package</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://lamehacks.net/blog/azulejo-update-new-keybinds-and-deb-package/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Simple PHP url dispatcher</title>
		<link>http://lamehacks.net/blog/simple-php-url-dispatcher/</link>
		<comments>http://lamehacks.net/blog/simple-php-url-dispatcher/#comments</comments>
		<pubDate>Fri, 18 Feb 2011 04:12:05 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[computer stuff]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[dispatcher]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[url]]></category>

		<guid isPermaLink="false">http://lamehacks.net/blog/?p=174</guid>
		<description><![CDATA[PHP maps filenames into urls, this is a very handy feature and many applications simply use that for all their request handling needs. Practical as it can be, it&#8217;s quite limited. Mapping url patterns into functions or Object methods is simple and easy. I&#8217;ll comment as I go&#8230; //defining what url patterns get mapped into [...]]]></description>
			<content:encoded><![CDATA[<p>PHP maps filenames into urls, this is a very handy feature and many applications simply use that for all their request handling needs. Practical as it can be, it&#8217;s quite limited.</p>
<p>Mapping url patterns into functions or Object methods is simple and easy. I&#8217;ll comment as I go&#8230;<br />
<span id="more-174"></span></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">//defining what url patterns get mapped into what funcitons.</span>
<span style="color: #666666; font-style: italic;">//if no route is provided 'default' route is used</span>
<span style="color: #000088;">$routes</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
	<span style="color: #0000ff;">&quot;default&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">&quot;sayhello&quot;</span><span style="color: #339933;">,</span>
	<span style="color: #0000ff;">&quot;hello&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">&quot;sayhello&quot;</span><span style="color: #339933;">,</span>
	<span style="color: #0000ff;">&quot;sum&quot;</span>  <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">&quot;computesum&quot;</span>
<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009933; font-style: italic;">/**
*Dispatch function - delegates action to other function and passes parameters to it
*/</span>
<span style="color: #000000; font-weight: bold;">function</span> dispatch<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$routes</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">//stear clear, allow only leters, numbers and slashes</span>
	<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$raw_route</span><span style="color: #009900;">&#41;</span> and <span style="color: #990000;">preg_match</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/^[\p{L}\/\d]++$/uD'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;PATH_INFO&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #990000;">die</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Invalid URL&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">//extract parameters</span>
	<span style="color: #000088;">$url_pieces</span> <span style="color: #339933;">=</span> <span style="color: #990000;">explode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/&quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;PATH_INFO&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$action</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$url_pieces</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$params</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">count</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$url_pieces</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">&gt;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$params</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array_slice</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$url_pieces</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>	
&nbsp;
	<span style="color: #666666; font-style: italic;">//when no action is passed default action is performed</span>
	<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$action</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$action</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;default&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">//make sure the route is defined</span>
	<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">in_array</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$action</span><span style="color: #339933;">,</span> <span style="color: #990000;">array_keys</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$routes</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #990000;">die</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Nothing to see here&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">//all checked, execute requested funcion with provided parameters</span>
	<span style="color: #000088;">$action_function</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$routes</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$action</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$action_function</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$params</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//just an example</span>
<span style="color: #000000; font-weight: bold;">function</span> sayhello<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Hello to you too!&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//another example</span>
<span style="color: #000000; font-weight: bold;">function</span> computesum<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$params</span> <span style="color: #339933;">=</span> <span style="color: #990000;">func_get_arg</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000088;">$sum</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$i</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$params</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$par</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$par</span> <span style="color: #339933;">=</span> <span style="color: #990000;">intval</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$par</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$sum</span> <span style="color: #339933;">+=</span> <span style="color: #000088;">$par</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span> <span style="color: #339933;">!=</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot; + &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$par</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span>
		<span style="color: #b1b100;">else</span><span style="color: #009900;">&#123;</span><span style="color: #b1b100;">echo</span> <span style="color: #000088;">$par</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span>
		<span style="color: #000088;">$i</span><span style="color: #339933;">++;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot; = &quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$sum</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//run the whole thing</span>
dispatch<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>paste this into a file, for example<code> dispatcher.php, </code> put it on your server then try out urls like:</p>
<p>http://example.com/dispatcher.php/sum/1/2/3/4/10</p>
<p>http://example.com/dispatcher.php/hello</p>
<p>http://example.com/dispatcher.php</p>
<p>The file name can be removed if your server has support for url rewriting.</p>
]]></content:encoded>
			<wfw:commentRss>http://lamehacks.net/blog/simple-php-url-dispatcher/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

