<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Nishant Arora's w3BL0G...</title>
	
	<link>http://nishantarora.in</link>
	<description>pH1N4lLY 50m3 pl4C3 1 k4n 8LUr7 0u7 73CH 5h!7... :)</description>
	<lastBuildDate>Mon, 20 May 2013 16:09:05 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/NishantArorasW3bl0g" /><feedburner:info uri="nishantarorasw3bl0g" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>Hangout Chat Notifications – My First Public Release on Chrome WebStore</title>
		<link>http://feedproxy.google.com/~r/NishantArorasW3bl0g/~3/XrSlTKkfoNM/hangout-chat-notifications-my-first-public-release-on-chrome-webstore.naml</link>
		<comments>http://nishantarora.in/hangout-chat-notifications-my-first-public-release-on-chrome-webstore.naml#comments</comments>
		<pubDate>Mon, 20 May 2013 16:09:05 +0000</pubDate>
		<dc:creator>Nishant Arora</dc:creator>
				<category><![CDATA[custom developed hacks]]></category>
		<category><![CDATA[labs]]></category>
		<category><![CDATA[babel]]></category>
		<category><![CDATA[chat]]></category>
		<category><![CDATA[Chrome Browser Extensions]]></category>
		<category><![CDATA[Gmail]]></category>
		<category><![CDATA[GmailGoogle]]></category>
		<category><![CDATA[hangout]]></category>
		<category><![CDATA[hangouts]]></category>
		<category><![CDATA[notifications]]></category>

		<guid isPermaLink="false">http://nishantarora.in/?p=935</guid>
		<description><![CDATA[Hi All Have been keeping very busy with multiple projects and did not get time to add all the new and exciting stuff on my blog. The great news for now is, I have made one of my many chrome browser extensions public and hope you guys like it. This extension aims for those who [...]]]></description>
				<content:encoded><![CDATA[<p>Hi All</p>
<p>Have been keeping very busy with multiple projects and did not get time to add all the new and exciting stuff on my blog. The great news for now is, I have made one of my many chrome browser extensions public and hope you guys like it.</p>
<p>This extension aims for those who have upgraded to Babel/Hangout chats within their Gmail/Google+ accounts. If you have noticed, now new chat does not generate browser notifications and hence you will never know who is pinging you if your Gmail/Google+ page is open in one of the many tabs. By the time the hangout team sorts this out and releases this functionality in later versions, this extension will actually add that functionality now.</p>
<blockquote><p><strong>Just go to <a rel="nofollow" target="_blank" rel="nofollow" title="Babel/Hangout Chat Notifications" href="https://chrome.google.com/webstore/detail/hangout-chat-notification/gbnhnghpfjmlncfmkdcamdnomjcobgmo" target="_blank">https://chrome.google.com/webstore/detail/hangout-chat-notification/gbnhnghpfjmlncfmkdcamdnomjcobgmo</a> and add this to chrome to enable chat notifications for new hangout chat.</strong></p></blockquote>
<p><strong>Make sure to leave a review</strong>, while I make a commit on github.</p>
<p>Cheers!</p><div class="betterrelated none"><p>No related content found.</p></div><img src="http://feeds.feedburner.com/~r/NishantArorasW3bl0g/~4/XrSlTKkfoNM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://nishantarora.in/hangout-chat-notifications-my-first-public-release-on-chrome-webstore.naml/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://nishantarora.in/hangout-chat-notifications-my-first-public-release-on-chrome-webstore.naml</feedburner:origLink></item>
		<item>
		<title>HTML form with more than one submit button and more than one action</title>
		<link>http://feedproxy.google.com/~r/NishantArorasW3bl0g/~3/eVHnAKpA09I/html-form-with-more-than-one-submit-button-and-more-than-one-action.naml</link>
		<comments>http://nishantarora.in/html-form-with-more-than-one-submit-button-and-more-than-one-action.naml#comments</comments>
		<pubDate>Mon, 15 Apr 2013 18:14:49 +0000</pubDate>
		<dc:creator>Nishant Arora</dc:creator>
				<category><![CDATA[custom developed hacks]]></category>
		<category><![CDATA[labs]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[more submit buttons]]></category>
		<category><![CDATA[multiple html form actions]]></category>
		<category><![CDATA[No Tags]]></category>
		<category><![CDATA[One form]]></category>
		<category><![CDATA[two actions]]></category>
		<category><![CDATA[two buttons]]></category>

		<guid isPermaLink="false">http://nishantarora.in/?p=930</guid>
		<description><![CDATA[I ruined almost all my evening just searching for the solution to having two submit buttons for an HTML form. The catch here was I wanted them to submit the form data to different scripts. After reading countless StackOverflow answers I came to the conclusion that there was no concrete solution to this, until of course I [...]]]></description>
				<content:encoded><![CDATA[<p>I ruined almost all my evening just searching for the solution to having two submit buttons for an HTML form. The catch here was I wanted them to submit the form data to different scripts. After reading countless StackOverflow answers I came to the conclusion that there was no concrete solution to this, until of course I made use of jQuery. This being a very light weight project I did not want to introduce such heavy JS framework just for this simple task.</p>
<p>Well I must say, that I am very impressed with the simplicity and workability of the solution I wrote for myself and it is pretty straight forward. Here it goes</p>
<p>Sample Form:</p><pre class="crayon-plain-tag">&lt;form action="" method="post" id="myform"&gt;
	&lt;input type="text" name="val1"&gt;
	&lt;input type="text" name="val2"&gt;
	&lt;input type="button" value="Submit One" /&gt;
	&lt;input type="button" value="Submit Two" /&gt;
&lt;/form&gt;</pre><p>The magical Javascript:</p><pre class="crayon-plain-tag">function submitTo(what,to){
	var frm=document.getElementById(what);
	frm.action = to;
	frm.submit();
}</pre><p>this is very easy to understand, it simply defines, what form needs to be submitted to what script. So lets say I need to submit a form with id &#8220;FormName1&#8243; to a script called &#8220;ProcessForm.php&#8221; then we just need to call <strong>&#8220;submitTo(&#8216;FormName1&#8242;,&#8217;ProcessForm.php&#8217;);&#8221;</strong>. Sounds easy, eh?</p>
<p>So the updated HTML becomes:</p><pre class="crayon-plain-tag">&lt;form action="" method="post" id="myform"&gt;
	&lt;input type="text" name="val1"&gt;
	&lt;input type="text" name="val2"&gt;
	&lt;input type="button" onClick="submitTo('myform','');" value="Submit One" /&gt;
	&lt;input type="button" onClick="submitTo('myform','some-script.php');" value="Submit Two" /&gt;
&lt;/form&gt;</pre><p>As simple as that, the easiest solution out there, no complex javascript functions, no processing using php. There is also a method to read the button values from $_POST variables but that becomes useless, seeing the simplicity of this. <a rel="nofollow" target="_blank" rel="nofollow" href="http://jsfiddle.net/whizzzkid/s3QZ7/" target="_blank">Here is a quick fiddle for this</a>, since the directory structure is not same at JSFiddle, this might not work entirely as expected, but will update soon!</p>
<p>Cheers!</p>
<p>Happy Hacking!</p><div class="betterrelated"><p><h3>Related content:</h3></p>
<ol><li> <a rel="nofollow" href="http://nishantarora.in/creating-a-fluid-site-ui-draggable-divs-and-handling-them-on-the-client-side.naml" title="Permanent link to Creating A Fluid Site UI: Draggable DIVs and Handling Them on The Client Side">Creating A Fluid Site UI: Draggable DIVs and Handling Them on The Client Side</a>  </li>
<li> <a rel="nofollow" href="http://nishantarora.in/oh-waoh-john-from-dynamic-drive-is-superb-programmer.naml" title="Permanent link to Oh Waoh&#8230; John From Dynamic Drive is SUPERB PROGRAMMER">Oh Waoh&#8230; John From Dynamic Drive is SUPERB PROGRAMMER</a>  </li>
<li> <a rel="nofollow" href="http://nishantarora.in/on-special-request-how-to-query-the-twitter-trends-api-to-get-latest-trends-in-real-time.naml" title="Permanent link to [On Special Request] How to Query the Twitter trends API to get latest trends in real time">[On Special Request] How to Query the Twitter trends API to get latest trends in real time</a>  </li>
<li> <a rel="nofollow" href="http://nishantarora.in/palm-pixi-plus-patching-and-hacking-made-simple.naml" title="Permanent link to Palm Pixi Plus &#8211; Patching and Hacking Made Simple">Palm Pixi Plus &#8211; Patching and Hacking Made Simple</a>  </li>
<li> <a rel="nofollow" href="http://nishantarora.in/arduino-breathing-leds-inspired-from-thecustomgeek-com.naml" title="Permanent link to Arduino Breathing LEDs &#8211; Inspired From thecustomgeek.com">Arduino Breathing LEDs &#8211; Inspired From thecustomgeek.com</a>  </li>
</ol></div><img src="http://feeds.feedburner.com/~r/NishantArorasW3bl0g/~4/eVHnAKpA09I" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://nishantarora.in/html-form-with-more-than-one-submit-button-and-more-than-one-action.naml/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://nishantarora.in/html-form-with-more-than-one-submit-button-and-more-than-one-action.naml</feedburner:origLink></item>
		<item>
		<title>How hard can it be to implement a pull tab drawer using CSS + jQuery?</title>
		<link>http://feedproxy.google.com/~r/NishantArorasW3bl0g/~3/QccdRntUnmg/how-hard-can-it-be-to-implement-a-pull-tab-drawer-using-css-jquery.naml</link>
		<comments>http://nishantarora.in/how-hard-can-it-be-to-implement-a-pull-tab-drawer-using-css-jquery.naml#comments</comments>
		<pubDate>Tue, 19 Mar 2013 18:29:46 +0000</pubDate>
		<dc:creator>Nishant Arora</dc:creator>
				<category><![CDATA[custom developed hacks]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[div]]></category>
		<category><![CDATA[drawer]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[No Tags]]></category>
		<category><![CDATA[out]]></category>
		<category><![CDATA[pull]]></category>
		<category><![CDATA[Pull Tab]]></category>
		<category><![CDATA[reveal]]></category>
		<category><![CDATA[slide]]></category>
		<category><![CDATA[Social Connections]]></category>
		<category><![CDATA[tab]]></category>

		<guid isPermaLink="false">http://nishantarora.in/?p=920</guid>
		<description><![CDATA[hi All Was just think about making a slide out drawer, which could be used for any purpose, like I am using it to show my social connections (Contact Me tab on the right bottom corner of the page). Well this is a pretty straight forward tutorial and will result in a tab displaying from [...]]]></description>
				<content:encoded><![CDATA[<p>hi All</p>
<p>Was just think about making a slide out drawer, which could be used for any purpose, like I am using it to show my social connections (Contact Me tab on the right bottom corner of the page). Well this is a pretty straight forward tutorial and will result in a tab displaying from the end of the page which can be clicked to open a div like a drawer and view stuff there.</p>
<p>Remember this code can be played around in the Fiddle mentioned at the end of this article and can be made to display from almost any edge of the page. While looking for a similar solution I could not locate a specific tutorial doing just this. You can also use an image in place of the pull tab and can also make it as small as an arrow to display the pull functionality.</p>
<p>The code here is the exact same used on my website. Without wasting any time let&#8217;s get started with the html structure for this first.</p>
<p><strong>STEP 1: HTML</strong></p>
<p>the code would look something like this:</p><pre class="crayon-plain-tag">&lt;div id="sidebox"&gt;
    &lt;div id="sidebox_tab"&gt;&lt;b&gt;Contact Me&lt;/b&gt;&lt;/div&gt;
    &lt;div id="sidebox_content"&gt;
        &lt;p&gt;Random text here.&lt;/p&gt;
    &lt;/div&gt;
&lt;/div&gt;</pre><p>&nbsp;</p>
<p><strong>STEP 2: CSS</strong></p>
<p>the style for this would look something like this and can be modded as per your requirement:</p><pre class="crayon-plain-tag">#sidebox {
    position:fixed;
    bottom:-200px;
    right:10px;
    width:150px;
    height:230px;
}

#sidebox .content {
    float:bottom;
    width:150px;
    height:200px;
    background:transparent;
}

#sidebox .tab {
    cursor:pointer;
    float:top;
    width:150px;
    height:30px;
    background:#356AA0;
    text-align: center;
    line-height: 30px;
    border-top-left-radius: 20px;
    border-top-right-radius:20px;
    font-family:&quot;lucida grande&quot;,tahoma,verdana,arial,sans-serif;
    color: white;
}</pre><p><strong>STEP 3: jQuery event</strong></p>
<p>well this is even simpler:</p><pre class="crayon-plain-tag">$('#sidebox .tab').toggle(function(){
    $('#sidebox').animate({'bottom':0});
}, function(){
    $('#sidebox').animate({'bottom':-$('#sidebox_content').height()});
});</pre><p>You would have something like the contact me box on the right side of the page or you can play around with <a rel="nofollow" target="_blank" rel="nofollow" href="http://jsfiddle.net/j9aDC/593/" target="_blank">this fiddle</a></p>
<p>Cheers!</p>
<p>Happy Hacking Stuff!</p><div class="betterrelated none"><p>No related content found.</p></div><h4>Incoming search terms:</h4><a href="http://nishantarora.in/how-hard-can-it-be-to-implement-a-pull-tab-drawer-using-css-jquery.naml" title="contact us left side drawer jquery">contact us left side drawer jquery</a> |<img src="http://feeds.feedburner.com/~r/NishantArorasW3bl0g/~4/QccdRntUnmg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://nishantarora.in/how-hard-can-it-be-to-implement-a-pull-tab-drawer-using-css-jquery.naml/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://nishantarora.in/how-hard-can-it-be-to-implement-a-pull-tab-drawer-using-css-jquery.naml</feedburner:origLink></item>
		<item>
		<title>Bytelandian gold coins</title>
		<link>http://feedproxy.google.com/~r/NishantArorasW3bl0g/~3/RRTy3Az0MrU/bytelandian-gold-coins.naml</link>
		<comments>http://nishantarora.in/bytelandian-gold-coins.naml#comments</comments>
		<pubDate>Sun, 17 Mar 2013 09:28:15 +0000</pubDate>
		<dc:creator>Nishant Arora</dc:creator>
				<category><![CDATA[Code Chef Solutions]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[bytelandian]]></category>
		<category><![CDATA[Codechef]]></category>
		<category><![CDATA[coins]]></category>
		<category><![CDATA[Dynamic Programming Problems]]></category>
		<category><![CDATA[gold]]></category>
		<category><![CDATA[Hack]]></category>
		<category><![CDATA[hackerearth]]></category>
		<category><![CDATA[Initial Approach]]></category>
		<category><![CDATA[solution]]></category>
		<category><![CDATA[spoj]]></category>
		<category><![CDATA[The Problem Statement]]></category>

		<guid isPermaLink="false">http://nishantarora.in/?p=917</guid>
		<description><![CDATA[This is one of the most amazing dynamic programming problems I solved till date. The problem sounds simple and seems to be easily doable. but here is the catch, it ain&#8217;t that easy. For those interested in the problem statement, here you go, it&#8217;s available on CodeChef, SPOJ and HackerEarth. In Byteland they have a [...]]]></description>
				<content:encoded><![CDATA[<p>This is one of the most amazing dynamic programming problems I solved till date. The problem sounds simple and seems to be easily doable. but here is the catch, it ain&#8217;t that easy. For those interested in the problem statement, here you go, it&#8217;s available on <a rel="nofollow" target="_blank" rel="nofollow" href="http://www.codechef.com/problems/COINS/" target="_blank">CodeChef</a>, <a rel="nofollow" target="_blank" rel="nofollow" href="http://www.spoj.com/problems/COINS/" target="_blank">SPOJ</a> and <a rel="nofollow" target="_blank" rel="nofollow" href="http://www.hackerearth.com/problem/bytelandian-gold-coins/" target="_blank">HackerEarth</a>.</p>
<blockquote><p>In Byteland they have a very strange monetary system. Each Bytelandian gold coin has an integer number written on it. A coin n can be exchanged in a bank into three coins: n/2, n/3 and n/4. But these numbers are all rounded down (the banks have to make a profit).</p>
<p>You can also sell Bytelandian coins for American dollars. The exchange rate is 1:1. But you can not buy Bytelandian coins. You have one gold coin. What is the maximum amount of American dollars you can get for it?</p>
<p><strong>Input</strong> The input will contain several test cases (not more than 10). Each testcase is a single line with a number n, 0 &lt;= n &lt;= 1 000 000 000. It is the number written on your coin.</p>
<p><strong>Output</strong> For each test case output a single line, containing the maximum amount of American dollars you can make.</p>
<p><strong>Explanation</strong> You can change 12 into 6, 4 and 3, and then change these into $6+$4+$3 = $13. If you try changing the coin 2 into 3 smaller coins, you will get 1, 0 and 0, and later you can get no more than $1 out of them. It is better just to change the 2 coin directly into $2.</p></blockquote>
<p>My initial approach was too subtle and narrow and I never thought that the coins could be exchanged multiple times. So the solution is simple as the following pseudo code:</p><pre class="crayon-plain-tag">1. exchange the coin from bank as n/2+n/3+n/4 and select the max out of the two. i.e max(n, (n/2+n/3+n/4))
2. maintain these conversion in a key=&gt;value array so that we need not calculate these again and again
3. for each n/2, n/3, n/4 repeat steps 1,2 and 3</pre><p>So here is the solution in Python:</p><pre class="crayon-plain-tag">#maintaining a dictionary
conv = {0:0}

def exch(num):
    if num in conv:
        return conv[num]
    else:
        conv[num] = max(num, exch(num/4)+exch(num/3)+exch(num/2))
        return conv[num]
while True:
    try:
        print exch(int(raw_input()))
    except:
        break</pre><p><a rel="nofollow" target="_blank" rel="nofollow" href="http://ideone.com/nUzyrv" target="_blank">here is the working code</a>. It won&#8217;t work in PHP as it will most probably run out of memory.</p>
<p>Cheers!&#8230; happy coding!&#8230;</p><div class="betterrelated"><p><h3>Related content:</h3></p>
<ol><li> <a rel="nofollow" href="http://nishantarora.in/facebook-hacker-cup-2013-online-round-1-left-out-but-feels-great.naml" title="Permanent link to Facebook Hacker Cup 2013 &#8211; Online Round 1 [Left Out, but feels great]">Facebook Hacker Cup 2013 &#8211; Online Round 1 [Left Out, but feels great]</a>  </li>
</ol></div><h4>Incoming search terms:</h4><a href="http://nishantarora.in/bytelandian-gold-coins.naml" title="bytelandian gold coins solution">bytelandian gold coins solution</a> | <a href="http://nishantarora.in/bytelandian-gold-coins.naml" title="code explanation of Bytelandian gold coins problem of hackerearth">code explanation of Bytelandian gold coins problem of hackerearth</a> | <a href="http://nishantarora.in/bytelandian-gold-coins.naml" title="www mduresult coin">www mduresult coin</a> |<img src="http://feeds.feedburner.com/~r/NishantArorasW3bl0g/~4/RRTy3Az0MrU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://nishantarora.in/bytelandian-gold-coins.naml/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://nishantarora.in/bytelandian-gold-coins.naml</feedburner:origLink></item>
		<item>
		<title>The Josephus Problem</title>
		<link>http://feedproxy.google.com/~r/NishantArorasW3bl0g/~3/GK6yQLFJEnI/the-josephus-problem.naml</link>
		<comments>http://nishantarora.in/the-josephus-problem.naml#comments</comments>
		<pubDate>Wed, 06 Mar 2013 14:40:09 +0000</pubDate>
		<dc:creator>Nishant Arora</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[extended]]></category>
		<category><![CDATA[josephus]]></category>
		<category><![CDATA[kill every second man in circle]]></category>
		<category><![CDATA[problem]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Wikipedia]]></category>

		<guid isPermaLink="false">http://nishantarora.in/?p=904</guid>
		<description><![CDATA[Across some programming challenge boards there lies many problems which are actually a variation of this beautiful problem. The text for this problem as stated by Wikipedia is as follows: There are people standing in a circle waiting to be executed. The counting out begins at some point in the circle and proceeds around the circle [...]]]></description>
				<content:encoded><![CDATA[<p>Across some programming challenge boards there lies many problems which are actually a variation of this beautiful problem. The text for this problem as stated by Wikipedia is as follows:</p>
<blockquote><p>There are people standing in a circle waiting to be executed. The counting out begins at some point in the circle and proceeds around the circle in a fixed direction. In each step, a certain number of people are skipped and the next person is executed. The elimination proceeds around the circle (which is becoming smaller and smaller as the executed people are removed), until only the last person remains, who is given freedom.</p>
<p>The task is to choose the place in the initial circle so that you are the last one remaining and so survive.</p></blockquote>
<p>Though I believe the interested guys would like to do more research on this, I spent a fair share of time with one of my colleagues and friend <strong>Ankit</strong> to figure this out. Wikipedia actually shows the theorems required to prove this mathematical equation, here is the implementation in Python.</p>
<p><strong>Approach 1: </strong>My initial approach was to run a loop which can actually yield out the required results:</p><pre class="crayon-plain-tag">def josephus( n, k):
   r = 0
   i = 2
   while i &lt;= n:
     r = (r + k) % i;
     i+= 1
   return r+1</pre><p>this is a O(n) solution, which will solve your problem, but will run for very long as compared to other approaches. <a rel="nofollow" target="_blank" rel="nofollow" href="http://ideone.com/7KTtRA" target="_blank">Run this on IdeOne</a>.</p>
<p><strong>Approach 2: </strong>Recursive solution was something everyone was talking about:</p><pre class="crayon-plain-tag">def josephus( n, k):
   if n ==1:
     return 1
   else:
     return ((josephus(n-1,k)+k-1) % n)+1</pre><p>but even that is O(n) solution and in cases where k is very small and n is very large, Python may even run out of memory. <a rel="nofollow" target="_blank" rel="nofollow" href="http://ideone.com/oCJdcn" target="_blank">Run this on IdeOne</a>.</p>
<p><strong>Approach 3:</strong> Also known as the Josephus Extended Problem, if k=2 and n is very large, the problem can be solved in O(k logn). Wikipedia has the theorem to prove this, the function is just so simple:</p><pre class="crayon-plain-tag">from math import log
  def josephus_2( n ):
    return 2*(n - 2**(int(log(n,2))))+1</pre><p>this is the best approach possible and the fastest one yet. <a rel="nofollow" target="_blank" rel="nofollow" href="http://ideone.com/O1v4LV" target="_blank">Run this on IdeOne</a>.</p>
<p>I also edited the wiki to have these solutions here <a rel="nofollow" target="_blank" rel="nofollow" href="http://en.wikipedia.org/wiki/Josephus_problem" target="_blank">Josephus Problem Wikipedia</a></p>
<p>Cheers, Lemme know of a better approach!</p><div class="betterrelated"><p><h3>Related content:</h3></p>
<ol><li> <a rel="nofollow" href="http://nishantarora.in/bytelandian-gold-coins.naml" title="Permanent link to Bytelandian gold coins">Bytelandian gold coins</a>  </li>
</ol></div><img src="http://feeds.feedburner.com/~r/NishantArorasW3bl0g/~4/GK6yQLFJEnI" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://nishantarora.in/the-josephus-problem.naml/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://nishantarora.in/the-josephus-problem.naml</feedburner:origLink></item>
		<item>
		<title>Facebook Hacker Cup 2013 – Online Round 1 [Left Out, but feels great]</title>
		<link>http://feedproxy.google.com/~r/NishantArorasW3bl0g/~3/dNCKxyU7pvA/facebook-hacker-cup-2013-online-round-1-left-out-but-feels-great.naml</link>
		<comments>http://nishantarora.in/facebook-hacker-cup-2013-online-round-1-left-out-but-feels-great.naml#comments</comments>
		<pubDate>Mon, 04 Feb 2013 09:08:19 +0000</pubDate>
		<dc:creator>Nishant Arora</dc:creator>
				<category><![CDATA[Facebook Hacker Cup 2013]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[2013]]></category>
		<category><![CDATA[cards game]]></category>
		<category><![CDATA[cup]]></category>
		<category><![CDATA[Facebook]]></category>
		<category><![CDATA[hacker]]></category>
		<category><![CDATA[Hand Strength]]></category>
		<category><![CDATA[Maximal Elements]]></category>
		<category><![CDATA[problem]]></category>
		<category><![CDATA[Problem Statement]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[The Problem]]></category>

		<guid isPermaLink="false">http://nishantarora.in/?p=885</guid>
		<description><![CDATA[hi All this weekend was on of the most fun filled problem solving weekend ever. All the three problems in the Online Round one were difficult in one way or the other. I only solved the first problem, that too in a language I was coding for the first time, glad to know the solution [...]]]></description>
				<content:encoded><![CDATA[<p>hi All</p>
<p>this weekend was on of the most fun filled problem solving weekend ever. All the three problems in the Online Round one were difficult in one way or the other. I only solved the first problem, that too in a language I was coding for the first time, glad to know the solution is correct!</p>
<p>Reading the first problem statement, the Card Game Problem I could almost immediately judge there was a pattern within the given problem sets. The only problem here was not the problem itself, but the language I love the most ( offcourse it is PHP!&#8230; ) the limitations given would generate numbers as large as &gt;10^13 and I very well knew, working on the WAMP stack (32-bit) would just not solve it, and at the same time, LAMP stack might do it, but it would be too long.</p>
<p>Since I was already working on Aptana, there was no better option to use ruby or python, because of the inbuilt support. Due to many other factors I inclined towards python and wrote my first ever problem solver code. It may not be optimized but it works to solve the problem set in less than 2 secs.</p>
<p>Without boring you further, the problem set was as follows:</p>
<blockquote><p>John is playing a game with his friends. The game&#8217;s rules are as follows: There is deck of N cards from which each person is dealt a hand of K cards. Each card has an integer value representing its strength. A hand&#8217;s strength is determined by the value of the highest card in the hand. The person with the strongest hand wins the round. Bets are placed before each player reveals the strength of their hand.</p>
<p>John needs your help to decide when to bet. He decides he wants to bet when the strength of his hand is higher than the average hand strength. Hence John wants to calculate the average strength of ALL possible sets of hands. John is very good at division, but he needs your help in calculating the sum of the strengths of all possible hands.</p>
<p><strong>Problem</strong><br />
You are given an array a with N ≤ 10 000 different integer numbers and a number, K, where 1 ≤ K ≤ N. For all possible subsets of a of size K find the sum of their maximal elements modulo 1 000 000 007.</p>
<p><strong>Input</strong><br />
The first line contains the number of test cases T, where 1 ≤ T ≤ 25</p>
<p>Each case begins with a line containing integers N and K. The next line contains N space-separated numbers 0 ≤ a [i] ≤ 2 000 000 000, which describe the array a.</p>
<p><strong>Output</strong><br />
For test case i, numbered from 1 to T, output &#8220;Case #i: &#8220;, followed by a single integer, the sum of maximal elements for all subsets of size K modulo 1 000 000 007.</p>
<p><strong>Example</strong><br />
For a = [3, 6, 2, 8] and N = 4 and K = 3, the maximal numbers among all triples are 6, 8, 8, 8 and the sum is 30.</p>
<p><strong>Sample Input</strong></p><pre class="crayon-plain-tag">5
4 3
3 6 2 8 
5 2
10 20 30 40 50 
6 4
0 1 2 3 5 8 
2 2
1069 1122 
10 5
10386 10257 10432 10087 10381 10035 10167 10206 10347 10088</pre><p><strong>Sample Output:</strong></p><pre class="crayon-plain-tag">Case #1: 30
Case #2: 400
Case #3: 103
Case #4: 1122
Case #5: 2621483</pre><p>
</p></blockquote>
<p><strong>Solution:</strong></p>
<p>well the problem statement takes time to understand, but definitely there is pattern, and you can see it sometime, later, it took me quite sometime to figure this out, I already could make out several relations with combinatorics, nCr and all.</p>
<p>later I realized the pseudo algorithm can be like:</p><pre class="crayon-plain-tag">sort array desc
total = 0
while (n-i) is not k{
    total = total + (a[n-i] * [n-i]C[k-1])
}</pre><p>so writing this code in PHP works, but fails on large data sets. Finally the code in python I wrote becomes:</p><pre class="crayon-plain-tag">import gmpy2

file        = open("card_game.txt")
o_file      = open("output.txt",'w')
testcases   = int(file.readline()) 
current     = 0

while current &lt; testcases:
    current = current + 1
    data_nk = file.readline().split()
    n       = int(data_nk[0])
    k       = int(data_nk[1])
    vals    = [int(i) for i in file.readline().split()]
    vals.sort()
    total   = 0
    i       = 0
    while (n-i) &gt;= k:
        i       = i + 1
        cval    = vals.pop()
        total   = total + (cval * gmpy2.comb((n-i), (k-1)))
        if total &gt; 1000000007:
            total   = total % 1000000007 
    o_file.write("Case #%s: "%current)
    o_file.write("%s"%total)
    if current &lt; testcases:
        o_file.write("\n")</pre><p>I use the gmp library available for almost all languages, in Python it is gmpy2 package. This code has scope for a lot of improvement. Please update me regarding this, would love to hear it from you.</p>
<p>Also, the rank that has been awarded to me is 2129 so I am pretty much happy with this.</p>
<p>Cheers!</p>
<p>&nbsp;</p><div class="betterrelated"><p><h3>Related content:</h3></p>
<ol><li> <a rel="nofollow" href="http://nishantarora.in/bytelandian-gold-coins.naml" title="Permanent link to Bytelandian gold coins">Bytelandian gold coins</a>  </li>
<li> <a rel="nofollow" href="http://nishantarora.in/facebook-hacker-cup-2013-solutions.naml" title="Permanent link to Facebook Hacker Cup 2013 &#8211; Solutions">Facebook Hacker Cup 2013 &#8211; Solutions</a>  </li>
<li> <a rel="nofollow" href="http://nishantarora.in/fbhc12-soup-problem-solution.naml" title="Permanent link to FbHc12 &#8211; Soup Problem Solution">FbHc12 &#8211; Soup Problem Solution</a>  </li>
<li> <a rel="nofollow" href="http://nishantarora.in/fbhc-2012-billboards-problem-solution.naml" title="Permanent link to FbHc 2012 &#8211; Billboards Problem Solution">FbHc 2012 &#8211; Billboards Problem Solution</a>  </li>
<li> <a rel="nofollow" href="http://nishantarora.in/the-josephus-problem.naml" title="Permanent link to The Josephus Problem">The Josephus Problem</a>  </li>
</ol></div><h4>Incoming search terms:</h4><a href="http://nishantarora.in/facebook-hacker-cup-2013-online-round-1-left-out-but-feels-great.naml" title="gmpy2">gmpy2</a> | <a href="http://nishantarora.in/facebook-hacker-cup-2013-online-round-1-left-out-but-feels-great.naml" title="John is playing a game with his friends The game\s rules are as follows: There is deck of N cards from which each person is dealt a hand of K cards Each card ha">John is playing a game with his friends The game\s rules are as follows: There is deck of N cards from which each person is dealt a hand of K cards Each card ha</a> | <a href="http://nishantarora.in/facebook-hacker-cup-2013-online-round-1-left-out-but-feels-great.naml" title="ncr % 1000000007 fast codechef lecards">ncr % 1000000007 fast codechef lecards</a> | <a href="http://nishantarora.in/facebook-hacker-cup-2013-online-round-1-left-out-but-feels-great.naml" title="ncr cup2013">ncr cup2013</a> |<img src="http://feeds.feedburner.com/~r/NishantArorasW3bl0g/~4/dNCKxyU7pvA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://nishantarora.in/facebook-hacker-cup-2013-online-round-1-left-out-but-feels-great.naml/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://nishantarora.in/facebook-hacker-cup-2013-online-round-1-left-out-but-feels-great.naml</feedburner:origLink></item>
		<item>
		<title>Facebook Hacker Cup 2013 – Solutions</title>
		<link>http://feedproxy.google.com/~r/NishantArorasW3bl0g/~3/Ev0MXpz9i5c/facebook-hacker-cup-2013-solutions.naml</link>
		<comments>http://nishantarora.in/facebook-hacker-cup-2013-solutions.naml#comments</comments>
		<pubDate>Tue, 29 Jan 2013 05:02:03 +0000</pubDate>
		<dc:creator>Nishant Arora</dc:creator>
				<category><![CDATA[Facebook Hacker Cup 2013]]></category>
		<category><![CDATA[labs]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[2013]]></category>
		<category><![CDATA[cup]]></category>
		<category><![CDATA[Facebook]]></category>
		<category><![CDATA[hacker]]></category>
		<category><![CDATA[Input File]]></category>
		<category><![CDATA[Little Johnny]]></category>
		<category><![CDATA[Parentheses]]></category>
		<category><![CDATA[Problem Beautiful StringsWhen John]]></category>
		<category><![CDATA[String]]></category>
		<category><![CDATA[Test Case]]></category>

		<guid isPermaLink="false">http://nishantarora.in/?p=874</guid>
		<description><![CDATA[hi All, This year&#8217;s hacker cup was on my most busiest weekend, had office to come, friend&#8217;s sister&#8217;s marriage to attend, broken ankle and bruised knee accompanied by the urge to solve challenges it hacker cup. I wanted to give my 100%, but could only spare 3 hours and was able to solve only two problems. That [...]]]></description>
				<content:encoded><![CDATA[<p>hi All,</p>
<p>This year&#8217;s hacker cup was on my most busiest weekend, had office to come, friend&#8217;s sister&#8217;s marriage to attend, broken ankle and bruised knee accompanied by the urge to solve challenges it hacker cup. I wanted to give my 100%, but could only spare 3 hours and was able to solve only two problems. That too, I am not sure, when the solution is judged tomorrow, will it be right or wrong.</p>
<p><strong>Problem 1: Beautiful Strings</strong></p>
<blockquote><p>When John was a little kid he didn&#8217;t have much to do. There was no internet, no Facebook, and no programs to hack on. So he did the only thing he could&#8230; he evaluated the beauty of strings in a quest to discover the most beautiful string in the world.</p>
<p>Given a string s, little Johnny defined the beauty of the string as the sum of the beauty of the letters in it.</p>
<p>The beauty of each letter is an integer between 1 and 26, inclusive, and no two letters have the same beauty. Johnny doesn&#8217;t care about whether letters are uppercase or lowercase, so that doesn&#8217;t affect the beauty of a letter. (Uppercase &#8216;F&#8217; is exactly as beautiful as lowercase &#8216;f&#8217;, for example.)</p>
<p>You&#8217;re a student writing a report on the youth of this famous hacker. You found the string that Johnny considered most beautiful. What is the maximum possible beauty of this string?</p>
<p>Input<br />
The input file consists of a single integer m followed by m lines.<br />
Output<br />
Your output should consist of, for each test case, a line containing the string &#8220;Case #x: y&#8221; where x is the case number (with 1 being the first case in the input file, 2 being the second, etc.) and y is the maximum beauty for that test case.<br />
Constraints<br />
5 ≤ m ≤ 50<br />
2 ≤ length of s ≤ 500</p>
<p>Example Input:<br />
5<br />
ABbCcc<br />
Good luck in the Facebook Hacker Cup this year!<br />
Ignore punctuation, please :)<br />
Sometimes test cases are hard to make up.<br />
So I just go consult Professor Dalves</p>
<p>Example Output:<br />
Case #1: 152<br />
Case #2: 754<br />
Case #3: 491<br />
Case #4: 729<br />
Case #5: 646</p></blockquote>
<p><strong>My Solution:</strong></p>
<p><strong>Algorithm:</strong></p>
<blockquote><p>1. Clean the string and only allow characters a-z</p>
<p>2. make a frequency array for each character</p>
<p>3. apply beauty from 26 to all chars in decreasing order</p>
<p>4. Sum and return</p></blockquote>
<p><strong>Code:</strong></p><pre class="crayon-plain-tag">&amp;lt;?php

if(!empty($_FILES[&quot;file&quot;])){
	$ip	= fopen($_FILES[&quot;file&quot;][&quot;tmp_name&quot;], &quot;r&quot;);
	$test_cases = trim(fgets($ip));
	$c 	=1;
	while($c!== $test_cases+1){
		$case=preg_replace('/[^a-z]+/', '', strtolower(trim(fgets($ip))));
		$vals=array_count_values(str_split($case));
		arsort($vals);
		$beauty	=26;
		$max_b	=0;
		foreach($vals as $v){
			$max_b	+=$v*$beauty;
			$beauty--;
		}
		print(&quot;Case #&quot;.$c.&quot;: &quot;.$max_b);
		if($c &amp;lt; $test_cases){
			print(&quot;\n&quot;);
		}
		$c++;
	}
}</pre><p><strong></strong><br />
<strong>Please feel free to test your input file here and lemme know if I am wrong:</strong><br />
<iframe src="http://clients.nishantarora.in/projects/fbhc13bs/" height="240" width="600" frameborder="0"></iframe></p>
<p><strong>Problem 2: Balanced Smileys</strong></p>
<blockquote><p>Your friend John uses a lot of emoticons when you talk to him on Messenger. In addition to being a person who likes to express himself through emoticons, he hates unbalanced parenthesis so much that it makes him go :(</p>
<p>Sometimes he puts emoticons within parentheses, and you find it hard to tell if a parenthesis really is a parenthesis or part of an emoticon.</p>
<p>A message has balanced parentheses if it consists of one of the following:</p>
<p>- An empty string &#8220;&#8221;<br />
- One or more of the following characters: &#8216;a&#8217; to &#8216;z&#8217;, &#8216; &#8216; (a space) or &#8216;:&#8217; (a colon)<br />
- An open parenthesis &#8216;(&#8216;, followed by a message with balanced parentheses, followed by a close parenthesis &#8216;)&#8217;.<br />
- A message with balanced parentheses followed by another message with balanced parentheses.<br />
- A smiley face &#8220;:)&#8221; or a frowny face &#8220;:(&#8221;<br />
Write a program that determines if there is a way to interpret his message while leaving the parentheses balanced.</p>
<p>Input<br />
The first line of the input contains a number T (1 ≤ T ≤ 50), the number of test cases.<br />
The following T lines each contain a message of length s that you got from John.</p>
<p>Output<br />
For each of the test cases numbered in order from 1 to T, output &#8220;Case #i: &#8221; followed by a string stating whether or not it is possible that the message had balanced parentheses. If it is, the string should be &#8220;YES&#8221;, else it should be &#8220;NO&#8221; (all quotes for clarity only)</p>
<p>Constraints<br />
1 ≤ length of s ≤ 100</p>
<p>Example Input:<br />
5<br />
:((<br />
i am sick today (:()<br />
(:)<br />
hacker cup: started :):)<br />
)(</p>
<p>Example Output:<br />
Case #1: NO<br />
Case #2: YES<br />
Case #3: YES<br />
Case #4: YES<br />
Case #5: NO</p></blockquote>
<p><strong>My Solution: IS WRONG!</strong></p>
<p><strong>The score board says my output is wrong, let&#8217;s see what I did here wrong:</strong></p>
<p><strong>Algorithm:</strong></p>
<blockquote><p>1. if string empty, it is a balanced string YES</p>
<p>2. if it contains characters other than a-z :)(\s it is not a balanced string NO.</p>
<p>3. clean the string and leave only the parenthesis.</p>
<p>4. Match a generic Regex which helps us match all the complete brackets, as in:</p>
<p><a rel="nofollow" target="_blank" rel="nofollow" href="http://content.nishantarora.in/wp-content/uploads/2013/01/regexbs.png"><br />
<img alt="regexbs 300x188 Facebook Hacker Cup 2013   Solutions" src="http://content.nishantarora.in/wp-content/uploads/2013/01/regexbs-300x188.png" width="300" height="188" title="Facebook Hacker Cup 2013   Solutions" /></a></p>
<p>&nbsp;</p>
<p>5. delete the matches recursively and check if the remaining string is balanced or not</p>
<p>6. Output results</p></blockquote>
<p><strong>Code:</strong></p><pre class="crayon-plain-tag">&amp;lt;?php

if(!empty($_FILES[&quot;file&quot;])){
	$ip	= fopen($_FILES[&quot;file&quot;][&quot;tmp_name&quot;], &quot;r&quot;);
	$test_cases = trim(fgets($ip));
	$c 	=1;
	while($c!== $test_cases+1){
		$case=trim(fgets($ip));
		if(empty($case)){
			$output	= &quot;YES&quot;;
		}elseif(preg_match('/[^:\(\)\sa-z]/s', $case)){
			$output	= &quot;NO&quot;;
		}else{
			$str=preg_replace('/[^:\(\)]/s', '', $case);
			while(preg_match('/\([^(\(|\))]*(\:\(|\:\))?[^(\(|\))]*\)/s', $str)){
				$str= preg_replace('/\([^(\(|\))]*(\:\(|\:\))?[^(\(|\))]*\)/s', '', $str);
			}
			$str= preg_replace('/\:[\(|\)]/s', '', $str);
			if(preg_match('/(\(|\))/s',$str)){
				$output	= &quot;NO&quot;;
			}else{
				$output	= &quot;YES&quot;;
			}
		}
		print(&quot;Case #&quot;.$c.&quot;: &quot;.$output);
		if($c &amp;lt; $test_cases){
			print(&quot;\n&quot;);
		}
		$c++;
	}
}</pre><p><strong>Please feel free to test your input file here and lemme know Where I went wrong:</strong><br />
<iframe src="http://clients.nishantarora.in/projects/fbhc13smileys/" height="240" width="600" frameborder="0"></iframe></p>
<p>I did not solve the 3rd problem, will do it in my free time, please update your thoughts on these solutions below.</p>
<p>Cheers!</p><div class="betterrelated"><p><h3>Related content:</h3></p>
<ol><li> <a rel="nofollow" href="http://nishantarora.in/fbhc12-soup-problem-solution.naml" title="Permanent link to FbHc12 &#8211; Soup Problem Solution">FbHc12 &#8211; Soup Problem Solution</a>  </li>
<li> <a rel="nofollow" href="http://nishantarora.in/fbhc-2012-billboards-problem-solution.naml" title="Permanent link to FbHc 2012 &#8211; Billboards Problem Solution">FbHc 2012 &#8211; Billboards Problem Solution</a>  </li>
<li> <a rel="nofollow" href="http://nishantarora.in/facebook-hacker-cup-2013-online-round-1-left-out-but-feels-great.naml" title="Permanent link to Facebook Hacker Cup 2013 &#8211; Online Round 1 [Left Out, but feels great]">Facebook Hacker Cup 2013 &#8211; Online Round 1 [Left Out, but feels great]</a>  </li>
<li> <a rel="nofollow" href="http://nishantarora.in/i-give-in-i-aint-no-maths-genius.naml" title="Permanent link to I give In&#8230; I ain&#8217;t no Maths Genius&#8230;">I give In&#8230; I ain&#8217;t no Maths Genius&#8230;</a>  </li>
<li> <a rel="nofollow" href="http://nishantarora.in/facebook-billboards-problem-detailed-solution-highly-optimized-on-special-request.naml" title="Permanent link to Facebook Billboards Problem Detailed Solution &#8211; Highly Optimized &#8211; On Special Request">Facebook Billboards Problem Detailed Solution &#8211; Highly Optimized &#8211; On Special Request</a>  </li>
</ol></div><h4>Incoming search terms:</h4><a href="http://nishantarora.in/facebook-hacker-cup-2013-solutions.naml" title="facebook hacker cup 2013 round 1 card game">facebook hacker cup 2013 round 1 card game</a> | <a href="http://nishantarora.in/facebook-hacker-cup-2013-solutions.naml" title="beautiful string hacker">beautiful string hacker</a> | <a href="http://nishantarora.in/facebook-hacker-cup-2013-solutions.naml" title="what is beautiful string problem">what is beautiful string problem</a> | <a href="http://nishantarora.in/facebook-hacker-cup-2013-solutions.naml" title="hacker cup solution">hacker cup solution</a> | <a href="http://nishantarora.in/facebook-hacker-cup-2013-solutions.naml" title="facebook solution for hacker cup">facebook solution for hacker cup</a> | <a href="http://nishantarora.in/facebook-hacker-cup-2013-solutions.naml" title="facebook hacker cup problems solution 2013">facebook hacker cup problems solution 2013</a> | <a href="http://nishantarora.in/facebook-hacker-cup-2013-solutions.naml" title="facebook hacker cup beautiful strings codechef">facebook hacker cup beautiful strings codechef</a> | <a href="http://nishantarora.in/facebook-hacker-cup-2013-solutions.naml" title="facebook hacker cup 2013 solutions">facebook hacker cup 2013 solutions</a> | <a href="http://nishantarora.in/facebook-hacker-cup-2013-solutions.naml" title="facebook friends number hack solution">facebook friends number hack solution</a> | <a href="http://nishantarora.in/facebook-hacker-cup-2013-solutions.naml" title="card game facebook hacker cup 2013 round 1 cpp">card game facebook hacker cup 2013 round 1 cpp</a> | <a href="http://nishantarora.in/facebook-hacker-cup-2013-solutions.naml" title="beautiful string problem">beautiful string problem</a> | <a href="http://nishantarora.in/facebook-hacker-cup-2013-solutions.naml" title="your friend john uses a lot of emoticons when you talk to him on messenger in addition to being a person who likes to express himself through emoticons he hates unbalanced parenthesis so much that it makes him go :(">your friend john uses a lot of emoticons when you talk to him on messenger in addition to being a person who likes to express himself through emoticons he hates unbalanced parenthesis so much that it makes him go :(</a> |<img src="http://feeds.feedburner.com/~r/NishantArorasW3bl0g/~4/Ev0MXpz9i5c" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://nishantarora.in/facebook-hacker-cup-2013-solutions.naml/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://nishantarora.in/facebook-hacker-cup-2013-solutions.naml</feedburner:origLink></item>
		<item>
		<title>Arduino Breathing LEDs – Inspired From thecustomgeek.com</title>
		<link>http://feedproxy.google.com/~r/NishantArorasW3bl0g/~3/heWprIxckxw/arduino-breathing-leds-inspired-from-thecustomgeek-com.naml</link>
		<comments>http://nishantarora.in/arduino-breathing-leds-inspired-from-thecustomgeek-com.naml#comments</comments>
		<pubDate>Sun, 13 Jan 2013 10:58:26 +0000</pubDate>
		<dc:creator>Nishant Arora</dc:creator>
				<category><![CDATA[custom developed hacks]]></category>
		<category><![CDATA[labs]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[arduino]]></category>
		<category><![CDATA[breathing LED]]></category>
		<category><![CDATA[Final Year Project]]></category>
		<category><![CDATA[Nishant Arora]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://nishantarora.in/?p=871</guid>
		<description><![CDATA[hi All, Almost a year ago, I was working on my final year project, when I cam across this awesome breathing LED tutorial on thecustomegeek.com. There I commented that this could be achieved more easily with the MOD function, but did not follow up with the article. The writer another nice dude, followed up with [...]]]></description>
				<content:encoded><![CDATA[<p>hi All,</p>
<p>Almost a year ago, I was working on <a rel="nofollow" target="_blank" rel="nofollow" href="https://www.facebook.com/media/set/?set=a.3969957497172.2168222.1527510667&amp;type=1&amp;l=d55cb271b7" target="_blank">my final year project</a>, when I cam across this awesome <a rel="nofollow" target="_blank" rel="nofollow" href="http://thecustomgeek.com/2011/06/17/breathing-sleep-led/" target="_blank">breathing LED tutorial on thecustomegeek.com</a>. There I commented that this could be achieved more easily with the MOD function, but did not follow up with the article. The writer another nice dude, followed up with me to give an update on the same. Thanks to bullsh*t facebook messaging system, it went to &#8220;other messages&#8221;, which were never in sight.</p>
<p>Long story short, I do not remember what was on my mind while writing that comment, still I can give in a solution, that just works, is more easy to manage and at the same time it saves us almost 200 bytes on the memory (for those who are wondering why 200bytes is so crucial, that&#8217;s almost 3% memory of a 8kb flash module on arduino uno and is almost 14% reduction than the previous code.)</p>
<p>So here is my updated version (I did not have a board in hand, I tested this on the <a rel="nofollow" target="_blank" rel="nofollow" href="http://www.arduino.com.au/Simulator-for-Arduino.php" target="_blank">simulator available here</a>)</p><pre class="crayon-plain-tag">/*
&quot;Breathing sleep LED, like on a Mac.
Jeremy Saglimbeni 2011
thecustomgeek.com

Updated by Nishant Arora 2013
nishantarora.in

LED is attached to pin 11 in series with a 5.6K resistor
*/

int i = 0;
int d = 0;
int breathe_speed	= 1;		// 1 being the fastest
void setup(){ // bring the LED up nicely from being off
  for(i = 0 ; i &amp;lt;= 15; i+=1){
    analogWrite(11, i);
    delay(5);
  }
}
void loop(){
  for(i = 15 ; i &amp;lt;= 255; i++){ 
    analogWrite(11, i);
    d  = (i/30)*breathe_speed;
    delay(d);
  }
  for(i = 255; i &amp;gt;=15; i--){
    analogWrite(11, i);
    d  = (i/30)*breathe_speed;
    delay(d);
  }
  delay(970);
}</pre><p>Lemme know in case of any further updates, or errors!&#8230; I loved coding it.</p>
<p>Cheers!</p><div class="betterrelated"><p><h3>Related content:</h3></p>
<ol><li> <a rel="nofollow" href="http://nishantarora.in/html-form-with-more-than-one-submit-button-and-more-than-one-action.naml" title="Permanent link to HTML form with more than one submit button and more than one action">HTML form with more than one submit button and more than one action</a>  </li>
<li> <a rel="nofollow" href="http://nishantarora.in/palm-pixi-plus-patching-and-hacking-made-simple.naml" title="Permanent link to Palm Pixi Plus &#8211; Patching and Hacking Made Simple">Palm Pixi Plus &#8211; Patching and Hacking Made Simple</a>  </li>
<li> <a rel="nofollow" href="http://nishantarora.in/how-to-enjoy-theater-quality-3d-movies-using-your-laptopdesktoplcdledcrt-even-on-your-mobiles.naml" title="Permanent link to How To Enjoy Theater Quality 3D Movies using your laptop/desktop/LCD/LED/CRT even on your mobiles">How To Enjoy Theater Quality 3D Movies using your laptop/desktop/LCD/LED/CRT even on your mobiles</a>  </li>
<li> <a rel="nofollow" href="http://nishantarora.in/creating-a-fluid-site-ui-draggable-divs-and-handling-them-on-the-client-side.naml" title="Permanent link to Creating A Fluid Site UI: Draggable DIVs and Handling Them on The Client Side">Creating A Fluid Site UI: Draggable DIVs and Handling Them on The Client Side</a>  </li>
<li> <a rel="nofollow" href="http://nishantarora.in/on-special-request-how-to-query-the-twitter-trends-api-to-get-latest-trends-in-real-time.naml" title="Permanent link to [On Special Request] How to Query the Twitter trends API to get latest trends in real time">[On Special Request] How to Query the Twitter trends API to get latest trends in real time</a>  </li>
</ol></div><h4>Incoming search terms:</h4><a href="http://nishantarora.in/arduino-breathing-leds-inspired-from-thecustomgeek-com.naml" title="breathing led arduino">breathing led arduino</a> | <a href="http://nishantarora.in/arduino-breathing-leds-inspired-from-thecustomgeek-com.naml" title="breathing led arduino code">breathing led arduino code</a> | <a href="http://nishantarora.in/arduino-breathing-leds-inspired-from-thecustomgeek-com.naml" title="breathing leds">breathing leds</a> |<img src="http://feeds.feedburner.com/~r/NishantArorasW3bl0g/~4/heWprIxckxw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://nishantarora.in/arduino-breathing-leds-inspired-from-thecustomgeek-com.naml/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://nishantarora.in/arduino-breathing-leds-inspired-from-thecustomgeek-com.naml</feedburner:origLink></item>
		<item>
		<title>Creating A Fluid Site UI: Draggable DIVs and Handling Them on The Client Side</title>
		<link>http://feedproxy.google.com/~r/NishantArorasW3bl0g/~3/Uhe3_A9N51g/creating-a-fluid-site-ui-draggable-divs-and-handling-them-on-the-client-side.naml</link>
		<comments>http://nishantarora.in/creating-a-fluid-site-ui-draggable-divs-and-handling-them-on-the-client-side.naml#comments</comments>
		<pubDate>Sun, 09 Dec 2012 11:41:42 +0000</pubDate>
		<dc:creator>Nishant Arora</dc:creator>
				<category><![CDATA[custom developed hacks]]></category>
		<category><![CDATA[labs]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Client Side]]></category>
		<category><![CDATA[Date ExdatesetDateexdategetDate]]></category>
		<category><![CDATA[Draggable]]></category>
		<category><![CDATA[persistence div drag]]></category>

		<guid isPermaLink="false">http://nishantarora.in/?p=864</guid>
		<description><![CDATA[hi All Long Time No See. I have been receiving and overwhelming number of queries related to my previous posts and have been keeping busy a lot at my new Job. I won&#8217;t be discussing anything about what I do or develop as it is Top Secret internal projects. For now, I was planning to create [...]]]></description>
				<content:encoded><![CDATA[<p>hi All</p>
<p>Long Time No See. I have been receiving and overwhelming number of queries related to my previous posts and have been keeping busy a lot at my new Job. I won&#8217;t be discussing anything about what I do or develop as it is Top Secret internal projects. For now, I was planning to create something which has been maybe around for long, but have never caught up with web masters.</p>
<p>Lately I just wanted to create menus and structures on a page movable. Well if you are using jQuery on your site, achieving this becomes a child play<a rel="nofollow" target="_blank" rel="nofollow" href="http://jqueryui.com/draggable/" target="_blank"> if you see what I mean</a>.</p>
<p>But the problem with this is, as soon as you refresh the page, the div move backs to it&#8217;s initial position. Which I think won&#8217;t work if we are planning to build a UI for a website. So more research reveals that this can be implemented if we can communicate the coordinates of the elements back to the server, again people have already <a rel="nofollow" target="_blank" rel="nofollow" href="http://net.tutsplus.com/tutorials/javascript-ajax/simple-draggable-element-persistence-with-jquery/" target="_blank">discussed about this too</a>.</p>
<p>But I do not understand the need of increasing web traffic just for persistence. The idea is to handle all the persistence on the client side. That means we can use client side features of browser to implement this in a simple manner. For this example I will be using simple functions for reading and writing cookies mentioned on <a rel="nofollow" target="_blank" rel="nofollow" href="http://www.w3schools.com/js/js_cookies.asp" target="_blank">w3schools</a>:</p><pre class="crayon-plain-tag">function setCookie(c_name,value,exdays){
	var exdate=new Date();
	exdate.setDate(exdate.getDate() + exdays);
	var c_value=escape(value) + ((exdays==null) ? &quot;&quot; : &quot;; expires=&quot;+exdate.toUTCString());
	document.cookie=c_name + &quot;=&quot; + c_value;
	console
}
function getCookie(c_name){
	var i,x,y,ARRcookies=document.cookie.split(&quot;;&quot;);
	for (i=0;i&amp;lt;ARRcookies.length;i++){
		x=ARRcookies[i].substr(0,ARRcookies[i].indexOf(&quot;=&quot;));
		y=ARRcookies[i].substr(ARRcookies[i].indexOf(&quot;=&quot;)+1);
		x=x.replace(/^\s+|\s+$/g,&quot;&quot;);
		if (x==c_name){
			return unescape(y);
		}
	}
}</pre><p>Now we can simply use the example mentioned for the <a rel="nofollow" target="_blank" rel="nofollow" href="http://jqueryui.com/draggable/" target="_blank">draggable feature on jQueryUI</a>:</p><pre class="crayon-plain-tag">&amp;lt;!doctype html&amp;gt;

&amp;lt;html lang=&quot;en&quot;&amp;gt;
&amp;lt;head&amp;gt;
    &amp;lt;meta charset=&quot;utf-8&quot; /&amp;gt;
    &amp;lt;title&amp;gt;jQuery UI Draggable - Default functionality&amp;lt;/title&amp;gt;
    &amp;lt;link rel=&quot;stylesheet&quot; href=&quot;http://code.jquery.com/ui/1.9.2/themes/base/jquery-ui.css&quot; /&amp;gt;
    &amp;lt;script src=&quot;http://code.jquery.com/jquery-1.8.3.js&quot;&amp;gt;&amp;lt;/script&amp;gt;
    &amp;lt;script src=&quot;http://code.jquery.com/ui/1.9.2/jquery-ui.js&quot;&amp;gt;&amp;lt;/script&amp;gt;
    &amp;lt;link rel=&quot;stylesheet&quot; href=&quot;/resources/demos/style.css&quot; /&amp;gt;
    &amp;lt;style&amp;gt;
    #draggable { width: 150px; height: 150px; padding: 0.5em; }
    &amp;lt;/style&amp;gt;
    &amp;lt;script&amp;gt;
    $(function() {
        $( &quot;#draggable&quot; ).draggable();
    });
    &amp;lt;/script&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;

&amp;lt;div id=&quot;draggable&quot; class=&quot;ui-widget-content&quot;&amp;gt;
    &amp;lt;p&amp;gt;Drag me around&amp;lt;/p&amp;gt;
&amp;lt;/div&amp;gt;

&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;</pre><p>and now we can change the draggable functions to store coordinate data into cookies, which would like this:</p><pre class="crayon-plain-tag">$( &quot;#draggable&quot; ).draggable().mouseup(function(){
	var coord		= $(this).offset();
	var offset_json	= '{&quot;top&quot;:'+coord.top+',&quot;left&quot;:'+coord.left+'}';
	setCookie(&quot;menu_offset&quot;,offset_json,365);
});</pre><p>and to read the data from the cookie at the page render we can simply write a read function:</p><pre class="crayon-plain-tag">var existing=getCookie(&quot;menu_offset&quot;);
if(existing!=null &amp;amp;&amp;amp; existing!=&quot;&quot;){
	offset_vals	= JSON.parse(existing);
	$(&quot;#draggable&quot;).css({
		top		: offset_vals.top,
		left	: offset_vals.left
	});
}</pre><p>Now combining it all gives us:</p><pre class="crayon-plain-tag">&amp;lt;html&amp;gt;
	&amp;lt;head&amp;gt;
		&amp;lt;script src=&quot;jquery.min.js&quot;&amp;gt;&amp;lt;/script&amp;gt;
		&amp;lt;script src=&quot;jquery-ui.min.js&quot;&amp;gt;&amp;lt;/script&amp;gt;
		&amp;lt;script&amp;gt;
			function setCookie(c_name,value,exdays){
				var exdate=new Date();
				exdate.setDate(exdate.getDate() + exdays);
				var c_value=escape(value) + ((exdays==null) ? &quot;&quot; : &quot;; expires=&quot;+exdate.toUTCString());
				document.cookie=c_name + &quot;=&quot; + c_value;
				console
			}
			function getCookie(c_name){
				var i,x,y,ARRcookies=document.cookie.split(&quot;;&quot;);
				for (i=0;i&amp;lt;ARRcookies.length;i++){
					x=ARRcookies[i].substr(0,ARRcookies[i].indexOf(&quot;=&quot;));
					y=ARRcookies[i].substr(ARRcookies[i].indexOf(&quot;=&quot;)+1);
					x=x.replace(/^\s+|\s+$/g,&quot;&quot;);
					if (x==c_name){
						return unescape(y);
					}
				}
			}
		&amp;lt;/script&amp;gt;
		&amp;lt;link rel=&quot;stylesheet&quot; href=&quot;http://code.jquery.com/ui/1.9.2/themes/base/jquery-ui.css&quot; /&amp;gt;
		&amp;lt;style&amp;gt;
			#draggable { width: 150px; height: 150px; padding: 0.5em; }
		&amp;lt;/style&amp;gt;
		&amp;lt;script&amp;gt;
			$(document).ready(function(){
				var existing=getCookie(&quot;menu_offset&quot;);
				if(existing!=null &amp;amp;&amp;amp; existing!=&quot;&quot;){
					offset_vals	= JSON.parse(existing);
					$(&quot;#draggable&quot;).css({
						top		: offset_vals.top,
						left	: offset_vals.left
					});
				}
				$( &quot;#draggable&quot; ).draggable().mouseup(function(){
					var coord		= $(this).offset();
					var offset_json	= '{&quot;top&quot;:'+coord.top+',&quot;left&quot;:'+coord.left+'}';
					setCookie(&quot;menu_offset&quot;,offset_json,365);
				});
			});
		&amp;lt;/script&amp;gt;
	&amp;lt;/head&amp;gt;
	&amp;lt;body&amp;gt;
		&amp;lt;div id=&quot;draggable&quot; class=&quot;ui-widget-content&quot;&amp;gt;
			&amp;lt;p&amp;gt;Drag me around and try refreshing. You should see me at the same position.&amp;lt;/p&amp;gt;
		&amp;lt;/div&amp;gt;
	&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;</pre><p>I would like you to check out a <a rel="nofollow" target="_blank" rel="nofollow" href="http://clients.nishantarora.in/projects/dragUI/" target="_blank">working example here</a>.<br />
Hope you liked it</p>
<p>Cheers!</p><div class="betterrelated"><p><h3>Related content:</h3></p>
<ol><li> <a rel="nofollow" href="http://nishantarora.in/on-special-request-how-to-query-the-twitter-trends-api-to-get-latest-trends-in-real-time.naml" title="Permanent link to [On Special Request] How to Query the Twitter trends API to get latest trends in real time">[On Special Request] How to Query the Twitter trends API to get latest trends in real time</a>  </li>
<li> <a rel="nofollow" href="http://nishantarora.in/html-form-with-more-than-one-submit-button-and-more-than-one-action.naml" title="Permanent link to HTML form with more than one submit button and more than one action">HTML form with more than one submit button and more than one action</a>  </li>
<li> <a rel="nofollow" href="http://nishantarora.in/how-to-enjoy-theater-quality-3d-movies-using-your-laptopdesktoplcdledcrt-even-on-your-mobiles.naml" title="Permanent link to How To Enjoy Theater Quality 3D Movies using your laptop/desktop/LCD/LED/CRT even on your mobiles">How To Enjoy Theater Quality 3D Movies using your laptop/desktop/LCD/LED/CRT even on your mobiles</a>  </li>
<li> <a rel="nofollow" href="http://nishantarora.in/oh-waoh-john-from-dynamic-drive-is-superb-programmer.naml" title="Permanent link to Oh Waoh&#8230; John From Dynamic Drive is SUPERB PROGRAMMER">Oh Waoh&#8230; John From Dynamic Drive is SUPERB PROGRAMMER</a>  </li>
<li> <a rel="nofollow" href="http://nishantarora.in/palm-pixi-plus-patching-and-hacking-made-simple.naml" title="Permanent link to Palm Pixi Plus &#8211; Patching and Hacking Made Simple">Palm Pixi Plus &#8211; Patching and Hacking Made Simple</a>  </li>
</ol></div><h4>Incoming search terms:</h4><a href="http://nishantarora.in/creating-a-fluid-site-ui-draggable-divs-and-handling-them-on-the-client-side.naml" title="cookies store position div draggable">cookies store position div draggable</a> | <a href="http://nishantarora.in/creating-a-fluid-site-ui-draggable-divs-and-handling-them-on-the-client-side.naml" title="How to store the position value of draggable widgets in cookies">How to store the position value of draggable widgets in cookies</a> |<img src="http://feeds.feedburner.com/~r/NishantArorasW3bl0g/~4/Uhe3_A9N51g" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://nishantarora.in/creating-a-fluid-site-ui-draggable-divs-and-handling-them-on-the-client-side.naml/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://nishantarora.in/creating-a-fluid-site-ui-draggable-divs-and-handling-them-on-the-client-side.naml</feedburner:origLink></item>
		<item>
		<title>[On Special Request] How to Query the Twitter trends API to get latest trends in real time</title>
		<link>http://feedproxy.google.com/~r/NishantArorasW3bl0g/~3/JdZTo4eJfQc/on-special-request-how-to-query-the-twitter-trends-api-to-get-latest-trends-in-real-time.naml</link>
		<comments>http://nishantarora.in/on-special-request-how-to-query-the-twitter-trends-api-to-get-latest-trends-in-real-time.naml#comments</comments>
		<pubDate>Mon, 15 Oct 2012 17:58:58 +0000</pubDate>
		<dc:creator>Nishant Arora</dc:creator>
				<category><![CDATA[custom developed hacks]]></category>
		<category><![CDATA[labs]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Client Project]]></category>
		<category><![CDATA[Country]]></category>
		<category><![CDATA[dynamic]]></category>
		<category><![CDATA[get twitter trends]]></category>
		<category><![CDATA[getting dynamic twitter trends]]></category>
		<category><![CDATA[Mikel Iturrioz]]></category>
		<category><![CDATA[twitter trends]]></category>
		<category><![CDATA[twitter trends api]]></category>
		<category><![CDATA[WOEID]]></category>

		<guid isPermaLink="false">http://nishantarora.in/?p=856</guid>
		<description><![CDATA[hi, I was just contacted by a reader of my blog Mikel Iturrioz, an internet passionate (as he claims himself to be) and had reached my blog through a client project available http://clients.nishantarora.in/projects/twitter_trends/. Now since it is a client project and I have been paid to do this, I doubt I can share this code freely, [...]]]></description>
				<content:encoded><![CDATA[<p>hi,</p>
<p>I was just contacted by a reader of my blog <strong>Mikel Iturrioz</strong>, an internet passionate (as he claims himself to be) and had reached my blog through a client project available <a rel="nofollow" target="_blank" rel="nofollow" href="http://clients.nishantarora.in/projects/twitter_trends/" target="_blank">http://clients.nishantarora.in/projects/twitter_trends/</a>. Now since it is a client project and I have been paid to do this, I doubt I can share this code freely, but the idea is something available for free and let me try to explain what I did here.</p>
<p><strong>Step 1: Understanding the twitter trends API:</strong></p>
<p>you can get the latest country trends by getting the URL <strong><em><a rel="nofollow" target="_blank" rel="nofollow" href="http://api.twitter.com/1/trends/&lt;WOEID&gt;.json" target="_blank">http://api.twitter.com/1/trends/&lt;WOEID&gt;.json</a></em> </strong>, the output will be a a json string containing latest trends of the respective WOEID. Now you need to understand what the WOEID is. WOEIDs are IDs issued to all the place entities around the world, Countries, cities, states, etc. To search more about the WOEIDs <a rel="nofollow" target="_blank" rel="nofollow" href="http://sigizmund.info/woeidinfo/" target="_blank">http://sigizmund.info/woeidinfo/</a> is a good place to start.</p>
<p>Here is a List of some common WOEIDs in PHP array format:</p><pre class="crayon-plain-tag">&amp;lt;?php

$woeid[&quot;Worldwide&quot;]		= &quot;1&quot;;
$woeid[&quot;US&quot;]			= &quot;23424977&quot;;
$woeid[&quot;Canada&quot;]		= &quot;23424775&quot;;
$woeid[&quot;France&quot;]		= &quot;23424819&quot;;
$woeid[&quot;UK&quot;]			= &quot;23424975&quot;;
$woeid[&quot;Mexico&quot;]		= &quot;23424900&quot;;
$woeid[&quot;Japan&quot;]			= &quot;23424856&quot;;
$woeid[&quot;Brazil&quot;]		= &quot;23424768&quot;;
$woeid[&quot;Netherlands&quot;]	= &quot;23424909&quot;;
$woeid[&quot;Indonesia&quot;]		= &quot;23424846&quot;;
$woeid[&quot;India&quot;]			= &quot;23424848&quot;;
$woeid[&quot;Venezuela&quot;]		= &quot;23424982&quot;;

?&amp;gt;</pre><p><strong>Step 2:  Creating a simple function to get trends from what we have learnt above</strong></p>
<p>Does the following function need any explanation?&#8230;</p><pre class="crayon-plain-tag">function get_trends($woeid){
	return json_decode(@file_get_contents(&quot;http://api.twitter.com/1/trends/&quot;.$woeid.&quot;.json&quot;, true), false); 
}</pre><p><strong>Step 3: Outputting the data.</strong></p>
<p>I think this is the most easiest part&#8230;</p><pre class="crayon-plain-tag">$data = get_trends($_GET['id']);
	if(!empty($data)){
		$country = $data[0]-&amp;gt;locations[0]-&amp;gt;name;
		$as_of = date(&quot;g:i a\\, F j\\&amp;lt;\\s\\u\\p\\&amp;gt;S\\&amp;lt;\\/\\s\\u\\p\\&amp;gt; Y&quot;, strtotime($data[0]-&amp;gt;as_of));
		$created = date(&quot;g:i a\\, F j\\&amp;lt;\\s\\u\\p\\&amp;gt;S\\&amp;lt;\\/\\s\\u\\p\\&amp;gt; Y&quot;, strtotime($data[0]-&amp;gt;created_at));
		$trends = $data[0]-&amp;gt;trends;
		echo &quot;Country: &quot;.$country.&quot;&amp;lt;br&amp;gt;As Of: &quot;.$as_of.&quot;&amp;lt;br&amp;gt;Created At: &quot;.$created.&quot;&amp;lt;ul&amp;gt;&quot;;
		foreach($trends as $trend){
			echo '&amp;lt;li&amp;gt;&amp;lt;a href=&quot;'.$trend-&amp;gt;url.'&quot; target=&quot;_blank&quot;&amp;gt;'.$trend-&amp;gt;name.'&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;';
		}
	}else{
		echo 'Twitter Seems To Be Not Responding!...';
	}</pre><p>Checkout this in action here <a rel="nofollow" target="_blank" rel="nofollow" href="http://clients.nishantarora.in/projects/twitter_trends/?id=23424977" target="_blank">http://clients.nishantarora.in/projects/twitter_trends/?id=23424977</a></p>
<p><strong>Step 4: Adding AJAX Magic (OPTIONAL)</strong></p>
<p>this is totally upto you how you wanna interface that with the data on your website. you can add some fancy AJAX or can just reload on a new request, Sky&#8217;s the Limit</p>
<p>Hope I explained every bit of it, clearly and as easy as possible. Thanks to my readers, this really encourages me!</p>
<p>Cheers!&#8230; Keep Hacking!&#8230;</p><div class="betterrelated"><p><h3>Related content:</h3></p>
<ol><li> <a rel="nofollow" href="http://nishantarora.in/creating-a-fluid-site-ui-draggable-divs-and-handling-them-on-the-client-side.naml" title="Permanent link to Creating A Fluid Site UI: Draggable DIVs and Handling Them on The Client Side">Creating A Fluid Site UI: Draggable DIVs and Handling Them on The Client Side</a>  </li>
<li> <a rel="nofollow" href="http://nishantarora.in/palm-pixi-plus-patching-and-hacking-made-simple.naml" title="Permanent link to Palm Pixi Plus &#8211; Patching and Hacking Made Simple">Palm Pixi Plus &#8211; Patching and Hacking Made Simple</a>  </li>
<li> <a rel="nofollow" href="http://nishantarora.in/html-form-with-more-than-one-submit-button-and-more-than-one-action.naml" title="Permanent link to HTML form with more than one submit button and more than one action">HTML form with more than one submit button and more than one action</a>  </li>
<li> <a rel="nofollow" href="http://nishantarora.in/how-to-enjoy-theater-quality-3d-movies-using-your-laptopdesktoplcdledcrt-even-on-your-mobiles.naml" title="Permanent link to How To Enjoy Theater Quality 3D Movies using your laptop/desktop/LCD/LED/CRT even on your mobiles">How To Enjoy Theater Quality 3D Movies using your laptop/desktop/LCD/LED/CRT even on your mobiles</a>  </li>
<li> <a rel="nofollow" href="http://nishantarora.in/arduino-breathing-leds-inspired-from-thecustomgeek-com.naml" title="Permanent link to Arduino Breathing LEDs &#8211; Inspired From thecustomgeek.com">Arduino Breathing LEDs &#8211; Inspired From thecustomgeek.com</a>  </li>
</ol></div><h4>Incoming search terms:</h4><a href="http://nishantarora.in/on-special-request-how-to-query-the-twitter-trends-api-to-get-latest-trends-in-real-time.naml" title="as_of php twitter">as_of php twitter</a> | <a href="http://nishantarora.in/on-special-request-how-to-query-the-twitter-trends-api-to-get-latest-trends-in-real-time.naml" title="twitter api trends by country">twitter api trends by country</a> |<img src="http://feeds.feedburner.com/~r/NishantArorasW3bl0g/~4/JdZTo4eJfQc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://nishantarora.in/on-special-request-how-to-query-the-twitter-trends-api-to-get-latest-trends-in-real-time.naml/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://nishantarora.in/on-special-request-how-to-query-the-twitter-trends-api-to-get-latest-trends-in-real-time.naml</feedburner:origLink></item>
	</channel>
</rss><!-- Dynamic page generated in 3.279 seconds. --><!-- Cached page generated by WP-Super-Cache on 2013-05-21 02:53:20 --><!-- Compression = gzip -->
