<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-5025713936013210120</id><updated>2011-11-27T16:35:42.680-08:00</updated><category term='Computer security'/><category term='facebook'/><category term='cool stuff'/><category term='whacky'/><category term='java'/><category term='personal'/><category term='ai'/><category term='web'/><category term='useful'/><category term='OOP'/><category term='genetic algos'/><category term='netbeans platform'/><category term='food for thought'/><category term='lol series'/><category term='framework'/><category term='adobe director'/><category term='lame observations'/><category term='c++'/><title type='text'>Just Me</title><subtitle type='html'>This is my personal blog...just-me!!</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://ragha-justme.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5025713936013210120/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://ragha-justme.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Ragha</name><uri>http://www.blogger.com/profile/09182969744128777413</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>50</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-5025713936013210120.post-1723459168288872828</id><published>2011-10-05T13:20:00.000-07:00</published><updated>2011-10-05T14:05:21.099-07:00</updated><title type='text'>A Gotcha with squaring on both sides..</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;One of the things we often do while solving equations is square on both sides of the equation. Until today, it never occured to me that one could introduce extraneous solutions by doing so. Here is a simple example. Consider the equation &lt;img src="http://latex.codecogs.com/svg.latex?\inline x=-1" /&gt;.&lt;br /&gt;&lt;br /&gt;Squaring on both sides, we have: &lt;img src="http://latex.codecogs.com/svg.latex?\inline x^{2}=1" /&gt;,which leads to solutions: &lt;img src="http://latex.codecogs.com/svg.latex?x=\pm 1" /&gt;.Here, &lt;img src="http://latex.codecogs.com/svg.latex?\inline x=1" /&gt; is an extraneous solution as a result of &lt;em&gt;squaring&lt;/em&gt; on ﻿both sides. Be mindful of this fact when you solve equations.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5025713936013210120-1723459168288872828?l=ragha-justme.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ragha-justme.blogspot.com/feeds/1723459168288872828/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ragha-justme.blogspot.com/2011/10/gotcha-with-squaring-on-both-sides.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5025713936013210120/posts/default/1723459168288872828'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5025713936013210120/posts/default/1723459168288872828'/><link rel='alternate' type='text/html' href='http://ragha-justme.blogspot.com/2011/10/gotcha-with-squaring-on-both-sides.html' title='A Gotcha with squaring on both sides..'/><author><name>Ragha</name><uri>http://www.blogger.com/profile/09182969744128777413</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5025713936013210120.post-1281853763664890503</id><published>2011-08-02T11:08:00.000-07:00</published><updated>2011-08-02T11:14:16.733-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='personal'/><title type='text'>Dream of death</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;Today i had a very scary dream. I owed somebody a debt, and he was going to kill me. I kind of get cornered on a huge staircase, and he was gonna push me from the top. Moments before throwing me, I ask him to give me some time (1 min or so), just so that i am prepared (I know its silly, but&amp;nbsp;that's&amp;nbsp;how the dream went).&lt;br /&gt;&lt;br /&gt;So, here I was, hanging from the top of a huge staircase, and i began to reflect..."Is that all there is to my life?, I wanted to do so much...None of what i am doing right now seemed significant - acads, job, publications - none of them mattered.&amp;nbsp;I reflected on how i spend most of my time keeping myself busy, never realizing that this moment would come"...it all seemed pointless. Luckily, I managed to wake up and shake off my fear...Strangely though, in the last moments of the fall, i lost all fear. I dont recall why.&lt;br /&gt;&lt;br /&gt;So, I've decided. From Aug, I am gonna devote 2 hrs to myself. Do whatever i wanted...even if it means to just sit, or stare blankly at the stars..&lt;br /&gt;&lt;br /&gt;On a totally unrelated note, I think this will make a fine novel. A novel that describes the thoughts of this fictional&amp;nbsp;character&amp;nbsp;who is going to die within a minute.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5025713936013210120-1281853763664890503?l=ragha-justme.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ragha-justme.blogspot.com/feeds/1281853763664890503/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ragha-justme.blogspot.com/2011/08/dream-of-death.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5025713936013210120/posts/default/1281853763664890503'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5025713936013210120/posts/default/1281853763664890503'/><link rel='alternate' type='text/html' href='http://ragha-justme.blogspot.com/2011/08/dream-of-death.html' title='Dream of death'/><author><name>Ragha</name><uri>http://www.blogger.com/profile/09182969744128777413</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5025713936013210120.post-2297458354376066936</id><published>2011-05-24T03:34:00.000-07:00</published><updated>2011-05-24T03:34:14.215-07:00</updated><title type='text'>Android  Fix</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;Press Volume up and power button to enter fastboot mode.&lt;br /&gt;Go to device manager.&lt;br /&gt;Select the android device with an ! mark, right click, update driver.&lt;br /&gt;Select "Browse my computer for driver software"&lt;br /&gt;Select :Let me pick from a list of devices on my computer"&lt;br /&gt;Select ADB bridge, install driver.&lt;br /&gt;&lt;br /&gt;PS: If you're using vista or windows 7, make sure your environmental variables are set up, and most importantly, launch your command prompt as admin.&lt;br /&gt;&lt;br /&gt;Run "fastboot oem unlock"&lt;br /&gt;That should do it..&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5025713936013210120-2297458354376066936?l=ragha-justme.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ragha-justme.blogspot.com/feeds/2297458354376066936/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ragha-justme.blogspot.com/2011/05/android-fix.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5025713936013210120/posts/default/2297458354376066936'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5025713936013210120/posts/default/2297458354376066936'/><link rel='alternate' type='text/html' href='http://ragha-justme.blogspot.com/2011/05/android-fix.html' title='Android &lt;waiting for device&gt; Fix'/><author><name>Ragha</name><uri>http://www.blogger.com/profile/09182969744128777413</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5025713936013210120.post-2471250192960241129</id><published>2011-01-15T13:26:00.000-08:00</published><updated>2011-05-16T12:44:49.268-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='facebook'/><title type='text'>Facebook hacker Cup Round 1A - Power Overwhelming</title><content type='html'>&lt;div style="text-align: justify;"&gt;The question goes something like: "You are to inflict mazimum damage to the zerg army. There are two types of units - Warrior and Sheild. Warriors do damage every second, while a sheild protects your entire army for one second. Your army is instantly overrun after the sheild generators expire. Given G cost to build a sheild, W cost to build a warrior and total money M, how many sheilds would you build?"&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;Let X and Y be the optimal number of generators and number of warriors to be built respectively. Lets take a simple example. Suppose sheilds and warriors both cost 1 unit and you have total money of 5 units. What is the optimum value of X and Y? It'd be optimum if you can inflict maximum damage. With 5 units of money, you can buy sheilds/warriors in the following combinations.&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;div align="center"&gt;&lt;table border="0" cellpadding="0" cellspacing="0" class="MsoNormalTable" style="border-collapse: collapse; mso-padding-alt: 0in 0in 0in 0in; mso-yfti-tbllook: 1184;"&gt;&lt;tbody&gt;&lt;tr style="mso-yfti-firstrow: yes; mso-yfti-irow: 0;"&gt;   &lt;td style="border: solid white 1.0pt; padding: 0in 5.4pt 0in 5.4pt; width: 54.9pt;" valign="top" width="73"&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; text-align: justify;"&gt;&lt;a href="http://www.blogger.com/post-edit.g?blogID=689000895995978913&amp;amp;postID=4602753985081169792" name="_GoBack"&gt;&lt;/a&gt;&lt;b&gt;&lt;span style="font-family: 'Times New Roman', serif; font-size: 12pt;"&gt;X&lt;/span&gt;&lt;/b&gt;&lt;span style="font-family: 'Times New Roman', serif; font-size: 12pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;   &lt;td style="border-left: none; border: solid white 1.0pt; mso-border-left-alt: solid white 1.0pt; padding: 0in 5.4pt 0in 5.4pt; width: .75in;" valign="top" width="72"&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; text-align: justify;"&gt;&lt;b&gt;&lt;span style="font-family: 'Times New Roman', serif; font-size: 12pt;"&gt;Y&lt;/span&gt;&lt;/b&gt;&lt;span style="font-family: 'Times New Roman', serif; font-size: 12pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;   &lt;td style="border-left: none; border: solid white 1.0pt; mso-border-left-alt: solid white 1.0pt; padding: 0in 5.4pt 0in 5.4pt; width: 67.5pt;" valign="top" width="90"&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; text-align: justify;"&gt;&lt;b&gt;&lt;span style="font-family: 'Times New Roman', serif; font-size: 12pt;"&gt;Damage&lt;/span&gt;&lt;/b&gt;&lt;span style="font-family: 'Times New Roman', serif; font-size: 12pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr style="mso-yfti-irow: 1;"&gt;   &lt;td style="border-top: none; border: solid white 1.0pt; mso-border-top-alt: solid white 1.0pt; padding: 0in 5.4pt 0in 5.4pt; width: 54.9pt;" valign="top" width="73"&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; text-align: justify;"&gt;&lt;span style="font-family: 'Times New Roman', serif; font-size: 12pt;"&gt;1&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;   &lt;td style="border-bottom: solid white 1.0pt; border-left: none; border-right: solid white 1.0pt; border-top: none; padding: 0in 5.4pt 0in 5.4pt; width: .75in;" valign="top" width="72"&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; text-align: justify;"&gt;&lt;span style="font-family: 'Times New Roman', serif; font-size: 12pt;"&gt;4&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;   &lt;td style="border-bottom: solid white 1.0pt; border-left: none; border-right: solid white 1.0pt; border-top: none; padding: 0in 5.4pt 0in 5.4pt; width: 67.5pt;" valign="top" width="90"&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; text-align: justify;"&gt;&lt;span style="font-family: 'Times New Roman', serif; font-size: 12pt;"&gt;4&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr style="mso-yfti-irow: 2;"&gt;   &lt;td style="border-top: none; border: solid white 1.0pt; mso-border-top-alt: solid white 1.0pt; padding: 0in 5.4pt 0in 5.4pt; width: 54.9pt;" valign="top" width="73"&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; text-align: justify;"&gt;&lt;span style="font-family: 'Times New Roman', serif; font-size: 12pt;"&gt;2&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;   &lt;td style="border-bottom: solid white 1.0pt; border-left: none; border-right: solid white 1.0pt; border-top: none; padding: 0in 5.4pt 0in 5.4pt; width: .75in;" valign="top" width="72"&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; text-align: justify;"&gt;&lt;span style="font-family: 'Times New Roman', serif; font-size: 12pt;"&gt;3&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;   &lt;td style="border-bottom: solid white 1.0pt; border-left: none; border-right: solid white 1.0pt; border-top: none; padding: 0in 5.4pt 0in 5.4pt; width: 67.5pt;" valign="top" width="90"&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; text-align: justify;"&gt;&lt;span style="font-family: 'Times New Roman', serif; font-size: 12pt;"&gt;6&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr style="mso-yfti-irow: 3;"&gt;   &lt;td style="border-top: none; border: solid white 1.0pt; mso-border-top-alt: solid white 1.0pt; padding: 0in 5.4pt 0in 5.4pt; width: 54.9pt;" valign="top" width="73"&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; text-align: justify;"&gt;&lt;span style="font-family: 'Times New Roman', serif; font-size: 12pt;"&gt;3&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;   &lt;td style="border-bottom: solid white 1.0pt; border-left: none; border-right: solid white 1.0pt; border-top: none; padding: 0in 5.4pt 0in 5.4pt; width: .75in;" valign="top" width="72"&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; text-align: justify;"&gt;&lt;span style="font-family: 'Times New Roman', serif; font-size: 12pt;"&gt;2&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;   &lt;td style="border-bottom: solid white 1.0pt; border-left: none; border-right: solid white 1.0pt; border-top: none; padding: 0in 5.4pt 0in 5.4pt; width: 67.5pt;" valign="top" width="90"&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; text-align: justify;"&gt;&lt;span style="font-family: 'Times New Roman', serif; font-size: 12pt;"&gt;6&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr style="mso-yfti-irow: 4; mso-yfti-lastrow: yes;"&gt;   &lt;td style="border-top: none; border: solid white 1.0pt; mso-border-top-alt: solid white 1.0pt; padding: 0in 5.4pt 0in 5.4pt; width: 54.9pt;" valign="top" width="73"&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; text-align: justify;"&gt;&lt;span style="font-family: 'Times New Roman', serif; font-size: 12pt;"&gt;4&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;   &lt;td style="border-bottom: solid white 1.0pt; border-left: none; border-right: solid white 1.0pt; border-top: none; padding: 0in 5.4pt 0in 5.4pt; width: .75in;" valign="top" width="72"&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; text-align: justify;"&gt;&lt;span style="font-family: 'Times New Roman', serif; font-size: 12pt;"&gt;1&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;   &lt;td style="border-bottom: solid white 1.0pt; border-left: none; border-right: solid white 1.0pt; border-top: none; padding: 0in 5.4pt 0in 5.4pt; width: 67.5pt;" valign="top" width="90"&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; text-align: justify;"&gt;&lt;span style="font-family: 'Times New Roman', serif; font-size: 12pt;"&gt;4&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;Assuming that a warrior does D damage per second, with 4 warriors and 1&amp;nbsp;shield, they do 4D damage. With 2&amp;nbsp;shields&amp;nbsp;and 3 warriors they do 3 + 3 = 6D damage. So in general, with X generators and Y warriors, the damage inflicted is X * Y * D. Therefore our goal is to maximize the product X * Y.&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;The cost to buy X generators is X * G. Similarly, the cost to buy Y warriors is Y * W. Since we are limited by M amount of money, X and Y must satisfy X * G + Y * W &amp;lt;= M. This can be represented as a line and the inequality encapsulates a region, both of which are shown in fig 1.&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;table cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/_7xvr19hYuG4/TTIPuLb33xI/AAAAAAAAARI/anuTkhwCmbo/s1600/fig1.PNG" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="308" src="http://3.bp.blogspot.com/_7xvr19hYuG4/TTIPuLb33xI/AAAAAAAAARI/anuTkhwCmbo/s400/fig1.PNG" width="400" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;Fig 1. Geometric representation&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;div style="text-align: justify;"&gt;For X + Y &amp;lt;= 5, the optimal points are (2,3) and (3,2). You can also try other examples, but you'll&amp;nbsp;eventually&amp;nbsp;notice that X*Y is maximum at the mid-point of the given line. G*X + W*Y &amp;lt;= M is just a general representation of the line. Putting Y=0, we get the intersection with X axis as M/G. Similarly, with X = 0 we get Y = M/W. The mid point is given by (M/2G, M/2W). Therefore optimal number of&amp;nbsp;shields&amp;nbsp;is given by M/2G.&amp;nbsp;However, M/2G must be an integer. Taking floor(M/2G) should suffice as it always ensures that the given region falls within the shaded region.&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;However, I&amp;nbsp;didn't&amp;nbsp;upload this solution as i was confused with the incorrect test cases :(&lt;/div&gt;&lt;div style="text-align: justify;"&gt;Wasted my 2.5 hours.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5025713936013210120-2471250192960241129?l=ragha-justme.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ragha-justme.blogspot.com/feeds/2471250192960241129/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ragha-justme.blogspot.com/2011/01/facebook-hacker-cup-round-1a-power.html#comment-form' title='8 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5025713936013210120/posts/default/2471250192960241129'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5025713936013210120/posts/default/2471250192960241129'/><link rel='alternate' type='text/html' href='http://ragha-justme.blogspot.com/2011/01/facebook-hacker-cup-round-1a-power.html' title='Facebook hacker Cup Round 1A - Power Overwhelming'/><author><name>Ragha</name><uri>http://www.blogger.com/profile/09182969744128777413</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_7xvr19hYuG4/TTIPuLb33xI/AAAAAAAAARI/anuTkhwCmbo/s72-c/fig1.PNG' height='72' width='72'/><thr:total>8</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5025713936013210120.post-1908502354478989192</id><published>2011-01-11T19:30:00.000-08:00</published><updated>2011-05-16T12:44:49.268-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='genetic algos'/><title type='text'>A Gotcha with function minimization using genetic algorithms</title><content type='html'>&lt;div style="text-align: justify;"&gt;Tyically, a genetic algorithm works by the notion of maximizing the fitness. Consider a function y = x, which is to be minimized in the interval [-5, +5]. One approach is use 1/x as the fitness function. Intuitively, by maximizing y = 1/x, we are minimizing y = x. However, a plot of y = 1/x reveals some serious flaws.&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;a href="http://1.bp.blogspot.com/_7xvr19hYuG4/TS0icWd8_qI/AAAAAAAAARA/U-Y2entOaOU/s1600/one%2Bby%2Bx.PNG"&gt;&lt;img src="http://1.bp.blogspot.com/_7xvr19hYuG4/TS0icWd8_qI/AAAAAAAAARA/U-Y2entOaOU/s320/one%2Bby%2Bx.PNG" border="0" alt="" id="BLOGGER_PHOTO_ID_5561138985335324322" style="display: block; margin-top: 0px; margin-right: auto; margin-bottom: 10px; margin-left: auto; text-align: center; cursor: pointer; width: 320px; height: 253px; " /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;span class="Apple-style-span" &gt;&lt;i&gt;Figure: Plot of y = 1/x&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;If we move from the right, the maximum occurs at x = 0 instead of x = -5. Why? Probably because 1/x is not differentiable at x = 0. Therefore, it is safe to use y = -x as the fitness function.&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;In general, if we are seeking to minimize Y = F(X), then it is safe to use Y = -F(x) as the fitness function.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5025713936013210120-1908502354478989192?l=ragha-justme.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ragha-justme.blogspot.com/feeds/1908502354478989192/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ragha-justme.blogspot.com/2011/01/gotcha-with-function-minimization-using.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5025713936013210120/posts/default/1908502354478989192'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5025713936013210120/posts/default/1908502354478989192'/><link rel='alternate' type='text/html' href='http://ragha-justme.blogspot.com/2011/01/gotcha-with-function-minimization-using.html' title='A Gotcha with function minimization using genetic algorithms'/><author><name>Ragha</name><uri>http://www.blogger.com/profile/09182969744128777413</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_7xvr19hYuG4/TS0icWd8_qI/AAAAAAAAARA/U-Y2entOaOU/s72-c/one%2Bby%2Bx.PNG' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5025713936013210120.post-1524684388203689012</id><published>2011-01-11T13:13:00.000-08:00</published><updated>2011-05-16T12:44:49.268-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='java'/><category scheme='http://www.blogger.com/atom/ns#' term='facebook'/><title type='text'>Facebook Hacker Cup: A Geometric Approach to Double Squares Problem</title><content type='html'>&lt;div style="text-align: justify;"&gt;Given an integer N, we need to find the number of integral pairs (x, y) such that &lt;a href="http://www.codecogs.com/eqnedit.php?latex=\inline%20{\color{white}%20x^2%20@plus;%20y^2%20=%20n}" target="_blank"&gt;&lt;img src="http://latex.codecogs.com/png.latex?\inline%20{\color{white}%20x^2%20+%20y^2%20=%20n}" title="\inline {\color{white} x^2 + y^2 = n}" /&gt;&lt;/a&gt;. &lt;/div&gt;&lt;div style="text-align: justify;"&gt;n can range from [0, 2147483647] and there can be a max of 100 such numbers in the input file.&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;From elementary geometry, we know that &lt;a href="http://www.codecogs.com/eqnedit.php?latex=\inline%20{\color{white}%20x^2%20@plus;%20y^2%20=%20r^2}" target="_blank"&gt;&lt;img src="http://latex.codecogs.com/png.latex?\inline%20{\color{white}%20x^2%20+%20y^2%20=%20r^2}" title="\inline {\color{white} x^2 + y^2 = r^2}" /&gt;&lt;/a&gt; represents a circle centered at (0,0) with a radius r. Therefore, &lt;a href="http://www.codecogs.com/eqnedit.php?latex=\inline%20{\color{white}%20x^2%20@plus;%20y^2%20=%20n}" target="_blank"&gt;&lt;img src="http://latex.codecogs.com/png.latex?\inline%20{\color{white}%20x^2%20+%20y^2%20=%20n}" title="\inline {\color{white} x^2 + y^2 = n}" /&gt;&lt;/a&gt; represents a circle with radius &lt;a href="http://www.codecogs.com/eqnedit.php?latex=\inline%20{\color{white}%20\sqrt{n}}" target="_blank"&gt;&lt;img src="http://latex.codecogs.com/png.latex?\inline%20{\color{white}%20\sqrt{n}}" title="\inline {\color{white} \sqrt{n}}" /&gt;&lt;/a&gt;. This is illustrated in figure 1. Now the problem is to find all possible solutions to this equation (in the first quadrant) where x, y are integers.&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;span class="Apple-style-span"&gt;&lt;u&gt;&lt;span class="Apple-style-span" style="-webkit-text-decorations-in-effect: none; color: black;"&gt;&lt;a href="http://2.bp.blogspot.com/_7xvr19hYuG4/TSz3Jjk1q5I/AAAAAAAAAQo/E9Y_PtUe0B0/s1600/Fig1.PNG"&gt;&lt;img alt="" border="0" id="BLOGGER_PHOTO_ID_5561091383436356498" src="http://2.bp.blogspot.com/_7xvr19hYuG4/TSz3Jjk1q5I/AAAAAAAAAQo/E9Y_PtUe0B0/s320/Fig1.PNG" style="cursor: pointer; display: block; height: 271px; margin-bottom: 10px; margin-left: auto; margin-right: auto; margin-top: 0px; text-align: justify; width: 320px;" /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/u&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;div style="text-align: center;"&gt;&lt;i&gt;&lt;span class="Apple-style-span"&gt;Figure 1&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;Bruteforcing all possible integral pairs of (x, y) upto n is equivalent to searching within the geometric space (grey rectangle) illustrated in fig 2.&lt;/div&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;a href="http://1.bp.blogspot.com/_7xvr19hYuG4/TSz78eJV_uI/AAAAAAAAAQ4/JvGpWsiq6Mk/s1600/Capture.PNG"&gt;&lt;img alt="" border="0" id="BLOGGER_PHOTO_ID_5561096656198696674" src="http://1.bp.blogspot.com/_7xvr19hYuG4/TSz78eJV_uI/AAAAAAAAAQ4/JvGpWsiq6Mk/s320/Capture.PNG" style="cursor: pointer; display: block; height: 279px; margin-bottom: 10px; margin-left: auto; margin-right: auto; margin-top: 0px; text-align: justify; width: 320px;" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;i&gt;&lt;span class="Apple-style-span"&gt;Figure 2&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;Algorithmically this approach takes O(&lt;a href="http://www.codecogs.com/eqnedit.php?latex=\inline%20{\color{white}%20n^2}" target="_blank"&gt;&lt;img src="http://latex.codecogs.com/png.latex?\inline%20{\color{white}%20n^2}" title="\inline {\color{white} n^2}" /&gt;&lt;/a&gt;) time.Consider the sample input as shown below (this was the file I received)&lt;/div&gt;&lt;div&gt;&lt;pre&gt;&lt;div style="text-align: justify;"&gt;20&lt;/div&gt;&lt;div style="text-align: justify;"&gt;1105&lt;/div&gt;&lt;div style="text-align: justify;"&gt;65&lt;/div&gt;&lt;div style="text-align: justify;"&gt;2147483646&lt;/div&gt;&lt;div style="text-align: justify;"&gt;1257431873&lt;/div&gt;&lt;div style="text-align: justify;"&gt;25&lt;/div&gt;&lt;div style="text-align: justify;"&gt;1000582589&lt;/div&gt;&lt;div style="text-align: justify;"&gt;1148284322&lt;/div&gt;&lt;div style="text-align: justify;"&gt;5525&lt;/div&gt;&lt;div style="text-align: justify;"&gt;0&lt;/div&gt;&lt;div style="text-align: justify;"&gt;1475149141&lt;/div&gt;&lt;div style="text-align: justify;"&gt;858320077&lt;/div&gt;&lt;div style="text-align: justify;"&gt;1022907856&lt;/div&gt;&lt;div style="text-align: justify;"&gt;1041493518&lt;/div&gt;&lt;div style="text-align: justify;"&gt;3&lt;/div&gt;&lt;div style="text-align: justify;"&gt;1215306625&lt;/div&gt;&lt;div style="text-align: justify;"&gt;372654318&lt;/div&gt;&lt;div style="text-align: justify;"&gt;160225&lt;/div&gt;&lt;div style="text-align: justify;"&gt;5928325&lt;/div&gt;&lt;div style="text-align: justify;"&gt;2147483643&lt;/div&gt;&lt;div style="text-align: justify;"&gt;1538292481&lt;/div&gt;&lt;/pre&gt;&lt;div style="text-align: justify;"&gt;On my machine, brute force approach takes approx 14 hours (!!!) to solve this input. Obviously Facebook wasnt kidding when it hinted: "Too hard to bruteforce, switching to dp". Clearly, we are exploring a lot of unwanted points. One obvious way to improve this is to explore points bounded by the circle as shown by blue shaded rectangle in fig 3.&lt;/div&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;a href="http://2.bp.blogspot.com/_7xvr19hYuG4/TSz2-_CAwYI/AAAAAAAAAQg/htxvPSa2w2k/s1600/Fig2.PNG"&gt;&lt;img alt="" border="0" id="BLOGGER_PHOTO_ID_5561091201827914114" src="http://2.bp.blogspot.com/_7xvr19hYuG4/TSz2-_CAwYI/AAAAAAAAAQg/htxvPSa2w2k/s320/Fig2.PNG" style="cursor: pointer; display: block; height: 291px; margin-bottom: 10px; margin-left: auto; margin-right: auto; margin-top: 0px; text-align: justify; width: 320px;" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;i&gt;&lt;span class="Apple-style-span"&gt;Figure 3&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;This is equivalent to looping x and y from 0 to &lt;a href="http://www.codecogs.com/eqnedit.php?latex=\inline%20{\color{white}%20\sqrt{n}}" target="_blank"&gt;&lt;img src="http://latex.codecogs.com/png.latex?\inline%20{\color{white}%20\sqrt{n}}" title="\inline {\color{white} \sqrt{n}}" /&gt;&lt;/a&gt;. This makes sense because x or y can never exceed &lt;a href="http://www.codecogs.com/eqnedit.php?latex=\inline%20{\color{white}%20\sqrt{n}}" target="_blank"&gt;&lt;img src="http://latex.codecogs.com/png.latex?\inline%20{\color{white}%20\sqrt{n}}" title="\inline {\color{white} \sqrt{n}}" /&gt;&lt;/a&gt;. For example, with n = 25, if x = 5, y = 0 and vice versa. This reduces the complexity from O(&lt;a href="http://www.codecogs.com/eqnedit.php?latex=\inline%20{\color{white}%20n^2}" target="_blank"&gt;&lt;img src="http://latex.codecogs.com/png.latex?\inline%20{\color{white}%20n^2}" title="\inline {\color{white} n^2}" /&gt;&lt;/a&gt;) to O(n) reducing execution time from 14 minutes to 80.5 sec!&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;Can we do any better? Why are we even exploring the blue rectangular region? Its sufficient if we examine all points on the arc of the circle in the first quadrant. i.e., we can increment x = 0 to &lt;a href="http://www.codecogs.com/eqnedit.php?latex=\inline%20{\color{white}%20\sqrt{n}}" target="_blank"&gt;&lt;img src="http://latex.codecogs.com/png.latex?\inline%20{\color{white}%20\sqrt{n}}" title="\inline {\color{white} \sqrt{n}}" /&gt;&lt;/a&gt; (if &lt;a href="http://www.codecogs.com/eqnedit.php?latex=\inline%20{\color{white}%20\sqrt{n}}" target="_blank"&gt;&lt;img src="http://latex.codecogs.com/png.latex?\inline%20{\color{white}%20\sqrt{n}}" title="\inline {\color{white} \sqrt{n}}" /&gt;&lt;/a&gt; is irrational number, its safe to use ceil(&lt;a href="http://www.codecogs.com/eqnedit.php?latex=\inline%20{\color{white}%20\sqrt{n}}" target="_blank"&gt;&lt;img src="http://latex.codecogs.com/png.latex?\inline%20{\color{white}%20\sqrt{n}}" title="\inline {\color{white} \sqrt{n}}" /&gt;&lt;/a&gt;)) and examine if the corresponding y points on the circle is an integer. y can be calculated using &lt;a href="http://www.codecogs.com/eqnedit.php?latex=\inline%20{\color{white}%20\sqrt{n}}" target="_blank"&gt;&lt;img src="http://latex.codecogs.com/png.latex?\inline%20{\color{white}%20\sqrt{n}}" title="\inline {\color{white} \sqrt{x^2 - n}}" /&gt;&lt;/a&gt;. Y is an integer if floor(y) == y. As illustrated in figure 4, all the points to the left of the line y=x is the mirror image of the points to the right. i.e, if we find a point, say (3, 4) to the left of y=x, then we will find a mirror image at (4, 3). Since the problem doesn't differentiate between these two. It is sufficient if we iterate x until the point x'. x' is given by &lt;a href="http://www.codecogs.com/eqnedit.php?latex=\inline%20{\color{white}%20\sqrt{n}%20\times%20\cos%20{45}%20=%20\sqrt{n/2}%20}" target="_blank"&gt;&lt;img src="http://latex.codecogs.com/png.latex?\inline%20{\color{white}%20\sqrt{n}%20\times%20\cos%20{45}%20=%20\sqrt{n/2}%20}" title="\inline {\color{white} \sqrt{n} \times \cos {45} = \sqrt{n/2} }" /&gt;&lt;/a&gt;.&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;a href="http://1.bp.blogspot.com/_7xvr19hYuG4/TSz44jZcUZI/AAAAAAAAAQw/orvD0e4jSWg/s1600/Fig3.PNG"&gt;&lt;img alt="" border="0" id="BLOGGER_PHOTO_ID_5561093290354037138" src="http://1.bp.blogspot.com/_7xvr19hYuG4/TSz44jZcUZI/AAAAAAAAAQw/orvD0e4jSWg/s320/Fig3.PNG" style="cursor: pointer; display: block; height: 278px; margin-bottom: 10px; margin-left: auto; margin-right: auto; margin-top: 0px; text-align: justify; width: 320px;" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;i&gt;&lt;span class="Apple-style-span"&gt;Figure 4&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;i&gt;&lt;span class="Apple-style-span"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span class="Apple-style-span"&gt;With this, the complete algorithm in JAVA is listed below: &lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;pre class="brush: java"&gt;private static int getNumSumSquares(int n) &lt;br /&gt;{&lt;br /&gt;if(n==0)&lt;br /&gt;return 1;&lt;br /&gt;&lt;br /&gt;int iterations = (int) Math.ceil(Math.sqrt((n * 1.0)/2));&lt;br /&gt;double y;&lt;br /&gt;int count = 0;&lt;br /&gt;for(int x=0; x &amp;lt;= iterations; x++)&lt;br /&gt;{&lt;br /&gt;y = Math.sqrt(n - (x*x));&lt;br /&gt;//check if y = int.&lt;br /&gt;if(Math.floor(y) == y)&lt;br /&gt;count++;&lt;br /&gt;}&lt;br /&gt;return count;&lt;br /&gt;}&lt;/pre&gt;&lt;div style="text-align: justify;"&gt;This algorithm works in &lt;a href="http://www.codecogs.com/eqnedit.php?latex=\inline%20{\color{white}%20O(\sqrt{n/2})%20\equiv%20O(\sqrt{n})}" target="_blank"&gt;&lt;img src="http://latex.codecogs.com/png.latex?\inline%20{\color{white}%20O(\sqrt{n/2})%20\equiv%20O(\sqrt{n})}" title="\inline {\color{white} O(\sqrt{n/2}) \equiv O(\sqrt{n})}" /&gt;&lt;/a&gt;. This is a huge improvement over the naive &lt;a href="http://www.codecogs.com/eqnedit.php?latex=\inline%20{\color{white}%20O(n^2)}" target="_blank"&gt;&lt;img src="http://latex.codecogs.com/png.latex?\inline%20{\color{white}%20O(n^2)}" title="\inline {\color{white} O(n^2)}" /&gt;&lt;/a&gt; approach. With these improvements, it just takes 0.047 secs to execute!&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5025713936013210120-1524684388203689012?l=ragha-justme.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ragha-justme.blogspot.com/feeds/1524684388203689012/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ragha-justme.blogspot.com/2011/01/facebook-hacker-cup-geometric-approach.html#comment-form' title='10 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5025713936013210120/posts/default/1524684388203689012'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5025713936013210120/posts/default/1524684388203689012'/><link rel='alternate' type='text/html' href='http://ragha-justme.blogspot.com/2011/01/facebook-hacker-cup-geometric-approach.html' title='Facebook Hacker Cup: A Geometric Approach to Double Squares Problem'/><author><name>Ragha</name><uri>http://www.blogger.com/profile/09182969744128777413</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_7xvr19hYuG4/TSz3Jjk1q5I/AAAAAAAAAQo/E9Y_PtUe0B0/s72-c/Fig1.PNG' height='72' width='72'/><thr:total>10</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5025713936013210120.post-8805363893705635311</id><published>2010-12-22T04:09:00.000-08:00</published><updated>2011-05-16T12:44:49.268-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='adobe director'/><title type='text'>Open AL, Adobe Director - No sound in projector [FIX]</title><content type='html'>One of the most annoying thing about Adobe Director is its lack of support. Open AL Xtra enables director to use OpenAL runtimes for 3D sound manipulation. Unfortunately, in a projector/exe, it doesn't play any sound. This issue was pointed out at multiple forums (&lt;a href="http://director-online.com/forums/read.php?2,34958,34958"&gt;here&lt;/a&gt; and &lt;a href="http://osdir.com/ml/lib.openal/2007-07/msg00026.html"&gt;here&lt;/a&gt;), without any fix so far. After struggling for nearly 4-5 hrs, I finally figured it out. The solution couldn't be any simpler. Just include these two xtras in the projector.&lt;div&gt;&lt;div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;- Mix Services&lt;/div&gt;&lt;div&gt;- Sound Import Export&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;I got he hint from &lt;a href="http://help.adobe.com/en_US/Director/11.5/UsingScripting/WSc3ff6d0ea77859461172e0811d64c1a1b3-7eb4.html"&gt;playFile()&lt;/a&gt; documentation for Director. It mentions the use of "Correct Mix Xtra" to play sound properly.&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5025713936013210120-8805363893705635311?l=ragha-justme.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ragha-justme.blogspot.com/feeds/8805363893705635311/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ragha-justme.blogspot.com/2010/12/open-al-adobe-director-no-sound-in.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5025713936013210120/posts/default/8805363893705635311'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5025713936013210120/posts/default/8805363893705635311'/><link rel='alternate' type='text/html' href='http://ragha-justme.blogspot.com/2010/12/open-al-adobe-director-no-sound-in.html' title='Open AL, Adobe Director - No sound in projector [FIX]'/><author><name>Ragha</name><uri>http://www.blogger.com/profile/09182969744128777413</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5025713936013210120.post-2615243406126241054</id><published>2010-12-07T20:32:00.000-08:00</published><updated>2010-12-07T21:50:30.000-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='food for thought'/><category scheme='http://www.blogger.com/atom/ns#' term='lame observations'/><title type='text'>Recenberg 1/5th success rule applied to life..</title><content type='html'>For those who are not familiar, Rechenberg's 1/5 rule refers to adaptive mutation in evolutionary strategies (ES). It says that the ratio of successful mutations to all mutation should be 1/5. Deriving from this idea, if you get too successful (i.e., more than 1 out of 5 tries) then you're converging too fast to a local optima (aka safe options) and will result in stagnation later on. So, don't run after too many successes. Ideally, at-least  according to Rechenberg, one should try 1 safe thing for every 4 risky things in life to optimally balance stagnation vs. growth.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5025713936013210120-2615243406126241054?l=ragha-justme.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ragha-justme.blogspot.com/feeds/2615243406126241054/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ragha-justme.blogspot.com/2010/12/recenberg-15th-success-rule-applied-to.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5025713936013210120/posts/default/2615243406126241054'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5025713936013210120/posts/default/2615243406126241054'/><link rel='alternate' type='text/html' href='http://ragha-justme.blogspot.com/2010/12/recenberg-15th-success-rule-applied-to.html' title='Recenberg 1/5th success rule applied to life..'/><author><name>Ragha</name><uri>http://www.blogger.com/profile/09182969744128777413</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5025713936013210120.post-5238234426433859790</id><published>2010-11-18T11:29:00.000-08:00</published><updated>2010-11-18T11:35:16.809-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='food for thought'/><title type='text'>Flaw with patent law?</title><content type='html'>&lt;div style="text-align: justify;"&gt;Math functions cannot be patented. Imagine sin, cos being patented, that'd be crazy right. Ironically computer programs can be patented. It has long been proved that computer programs are equivalent to mathematical functions. Does anyone realize its the same as patenting math functions?&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5025713936013210120-5238234426433859790?l=ragha-justme.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ragha-justme.blogspot.com/feeds/5238234426433859790/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ragha-justme.blogspot.com/2010/11/flaw-with-patent-law.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5025713936013210120/posts/default/5238234426433859790'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5025713936013210120/posts/default/5238234426433859790'/><link rel='alternate' type='text/html' href='http://ragha-justme.blogspot.com/2010/11/flaw-with-patent-law.html' title='Flaw with patent law?'/><author><name>Ragha</name><uri>http://www.blogger.com/profile/09182969744128777413</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5025713936013210120.post-8669736069311034582</id><published>2010-11-17T11:39:00.000-08:00</published><updated>2010-11-18T11:29:20.481-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='food for thought'/><title type='text'>Kleiber's Law</title><content type='html'>&lt;div&gt;Last week, I happened to read about &lt;a href="http://en.wikipedia.org/wiki/Kleiber's_law"&gt;Kleiber's law&lt;/a&gt; while browsing through literature on natural evolution. Its implications are really fascinating. It establishes a relationship between mass and metabolism as:&lt;/div&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_7xvr19hYuG4/TOQyB0HxwMI/AAAAAAAAAPw/q1DapGRGYAg/s1600/Kleibers%2Blaw.PNG"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 180px; height: 39px;" src="http://3.bp.blogspot.com/_7xvr19hYuG4/TOQyB0HxwMI/AAAAAAAAAPw/q1DapGRGYAg/s200/Kleibers%2Blaw.PNG" border="0" alt="" id="BLOGGER_PHOTO_ID_5540608448325075138" /&gt;&lt;/a&gt;Metabolism is ultimately linked to the number of heartbeats (heart pumps oxygenated blood, which is responsible for metabolism). Therefore, #heartbeats is proportional to the mass. Also, smaller creatures have high metabolism (heat generated per unit volume) and therefore have faster heart rate. &lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Curiously, the number of heartbeats per lifetime tends to be &lt;a href="http://www.dialogues-cvm.org/pdf/19/DCVM19_03.pdf"&gt;constant&lt;/a&gt;. Thus, bigger animals live longer as their heart beats slower. Flies on the other hand have shorter lifespan because of high metabolism (smaller mass).&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Come to think of it, if we have fixed number of heartbeats, wouldn't running/exercising make us die faster? We are spending more heartbeats per second and it makes perfect sense. Then why is it that people who exercise live longer? The answer is simple...I'll let you think about it.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5025713936013210120-8669736069311034582?l=ragha-justme.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ragha-justme.blogspot.com/feeds/8669736069311034582/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ragha-justme.blogspot.com/2010/11/kleibers-law.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5025713936013210120/posts/default/8669736069311034582'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5025713936013210120/posts/default/8669736069311034582'/><link rel='alternate' type='text/html' href='http://ragha-justme.blogspot.com/2010/11/kleibers-law.html' title='Kleiber&apos;s Law'/><author><name>Ragha</name><uri>http://www.blogger.com/profile/09182969744128777413</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_7xvr19hYuG4/TOQyB0HxwMI/AAAAAAAAAPw/q1DapGRGYAg/s72-c/Kleibers%2Blaw.PNG' height='72' width='72'/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5025713936013210120.post-3496423188682474840</id><published>2010-10-08T09:20:00.000-07:00</published><updated>2010-10-08T09:21:29.906-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='food for thought'/><title type='text'>The paradox...</title><content type='html'>Newton made calculus to simplify mathematics...a true paradox!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5025713936013210120-3496423188682474840?l=ragha-justme.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ragha-justme.blogspot.com/feeds/3496423188682474840/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ragha-justme.blogspot.com/2010/10/paradox.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5025713936013210120/posts/default/3496423188682474840'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5025713936013210120/posts/default/3496423188682474840'/><link rel='alternate' type='text/html' href='http://ragha-justme.blogspot.com/2010/10/paradox.html' title='The paradox...'/><author><name>Ragha</name><uri>http://www.blogger.com/profile/09182969744128777413</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5025713936013210120.post-8963394627583055472</id><published>2010-09-24T03:09:00.000-07:00</published><updated>2011-05-16T12:44:49.268-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='java'/><title type='text'>Adding class attributes at runtime :O</title><content type='html'>The use is kind of hard to describe. In some situations, it makes more sense to add attributes to an &lt;i&gt;instance &lt;/i&gt;at runtime. One example would be to perform optimizations at runtime (Maybe I'll describe a solid example at a latter time). &lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The trick is to use a HashMap to store property name and value pair. For ease of use, I defined a class 'Bufferable' with this capability. Any class extending 'Bufferable' should inherit dynamic attribute feature.&lt;/div&gt;&lt;pre class="brush: java"&gt;&lt;br /&gt;/**&lt;br /&gt;* A Utility class to support addition of new properties to a java bean&lt;br /&gt;* at the runtime. Extend your class with this to make it bufferable. It is&lt;br /&gt;* useful if you want to associate certain properties with an object and&lt;br /&gt;* maintain the OOP nature of your code.&lt;br /&gt;*&lt;br /&gt;* &lt;p&gt;This class extends &lt;code&gt;AbstractSerializableBean&lt;/code&gt;&lt;br /&gt;* for serialization and property change support.&lt;br /&gt;*&lt;br /&gt;* @author Ragha&lt;br /&gt;* @see AbstractSerializableBean&lt;br /&gt;* @version 1.0&lt;br /&gt;*/&lt;br /&gt;public class Bufferable extends AbstractSerializableBean&lt;br /&gt;{&lt;br /&gt;  private static final long serialVersionUID = 506835437375346326L;&lt;br /&gt;&lt;br /&gt;  /**&lt;br /&gt;   * This map is used to store property name and object as key-value pairs.&lt;br /&gt;   */&lt;br /&gt;  private HashMap&lt;string, object=""&gt; buffer = new HashMap&lt;string, object=""&gt;();&lt;br /&gt;&lt;br /&gt;  /**&lt;br /&gt;   * This method is used as a getter for the associated property in the&lt;br /&gt;   * buffer.&lt;br /&gt;   *&lt;br /&gt;   * &lt;/string,&gt;&lt;/string,&gt;&lt;/p&gt;&lt;p&gt;You must typically create the property using&lt;br /&gt;   * {@link #createPropertyInBuffer(java.lang.String) createPropertyInBuffer(...)} method&lt;br /&gt;   * before using this method.&lt;br /&gt;   *&lt;br /&gt;   * @param property The property to be used&lt;br /&gt;   * @return The value of the property.&lt;br /&gt;   * @throws java.lang.IllegalArgumentException If there is no such property.&lt;br /&gt;   */&lt;br /&gt;  public Object getValueFromBuffer(String property)&lt;br /&gt;          throws IllegalArgumentException&lt;br /&gt;  {&lt;br /&gt;      if(buffer.containsKey(property))&lt;br /&gt;          return buffer.get(property);&lt;br /&gt;      else&lt;br /&gt;      {&lt;br /&gt;          throw new IllegalArgumentException("Property: '"+property+"' " +&lt;br /&gt;                  "does not exist...");&lt;br /&gt;      }&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;  /**&lt;br /&gt;   * This method can be used as a setter for the associated property.&lt;br /&gt;   * in the buffer.&lt;br /&gt;   *&lt;br /&gt;   * &lt;/p&gt;&lt;p&gt;You must typically create the property using&lt;br /&gt;   * {@link #createPropertyInBuffer(java.lang.String) createPropertyInBuffer(...)} method&lt;br /&gt;   * before using this method.&lt;br /&gt;   *&lt;br /&gt;   * @param property The property value to be set&lt;br /&gt;   * @param Value The value to be set&lt;br /&gt;   * @throws java.lang.IllegalArgumentException If there is no such property&lt;br /&gt;   */&lt;br /&gt;  public void putValueInBuffer(String property, Object Value)&lt;br /&gt;          throws IllegalArgumentException&lt;br /&gt;  {&lt;br /&gt;      if(buffer.containsKey(property))&lt;br /&gt;          buffer.put(property, Value);&lt;br /&gt;      else&lt;br /&gt;      {&lt;br /&gt;          throw new IllegalArgumentException("Property: '"+property+"' " +&lt;br /&gt;                  "does not exist...");&lt;br /&gt;      }      &lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;  /**&lt;br /&gt;   * Creates a new property in the buffer. Once the property is created,&lt;br /&gt;   * it can be get or set using the&lt;br /&gt;   * {@link #putValueInBuffer(java.lang.String, java.lang.Object) putValueInBuffer(...)} and&lt;br /&gt;   * {@link #getValueFromBuffer(java.lang.String) getValueFromBuffer(...)} methods&lt;br /&gt;   *&lt;br /&gt;   * &lt;/p&gt;&lt;p&gt;It is recommended that you use Classname-property name as property&lt;br /&gt;   * string to avoid conflicts with other existing property names...&lt;br /&gt;   *&lt;br /&gt;   * @param property The property name to be associated with the buffer.&lt;br /&gt;   * @throws java.lang.IllegalArgumentException If the property name already exists.&lt;br /&gt;   */&lt;br /&gt;  public void createPropertyInBuffer(String property)&lt;br /&gt;          throws IllegalArgumentException&lt;br /&gt;  {&lt;br /&gt;      if(buffer.containsKey(property))&lt;br /&gt;      {&lt;br /&gt;          throw new IllegalArgumentException("Property: '"+property+"' " +&lt;br /&gt;                  "already exists...");&lt;br /&gt;      }&lt;br /&gt;      else&lt;br /&gt;      {&lt;br /&gt;          buffer.put(property, new Object());&lt;br /&gt;      }&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;  /**&lt;br /&gt;   * This method can be used to check if a given property already exists.&lt;br /&gt;   * @param property The property to be checked.&lt;br /&gt;   * @return true, if the property exists.&lt;br /&gt;   */&lt;br /&gt;  public boolean isPropertyInBuffer(String property)&lt;br /&gt;  {&lt;br /&gt;      return buffer.containsKey(property);&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;  @Override&lt;br /&gt;  public boolean equals(Object obj) {&lt;br /&gt;      if (obj == null) {&lt;br /&gt;          return false;&lt;br /&gt;      }&lt;br /&gt;      if (getClass() != obj.getClass()) {&lt;br /&gt;          return false;&lt;br /&gt;      }&lt;br /&gt;      final Bufferable other = (Bufferable) obj;&lt;br /&gt;      if (this.buffer != other.buffer &amp;amp;&amp;amp; (this.buffer == null || !this.buffer.equals(other.buffer))) {&lt;br /&gt;          return false;&lt;br /&gt;      }&lt;br /&gt;      return true;&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;  @Override&lt;br /&gt;  public int hashCode() {&lt;br /&gt;      int hash = 3;&lt;br /&gt;      hash = 79 * hash + (this.buffer != null ? this.buffer.hashCode() : 0);&lt;br /&gt;      return hash;&lt;br /&gt;  }  &lt;br /&gt;}&lt;br /&gt;&lt;/p&gt;&lt;/pre&gt;&lt;div style="text-align: justify;"&gt;Everything should look pretty obvious except for why i am extending my class with AbstractSerializableBean. Well, this is done in order to make the class Serializable. The code for AbstractSerializableBean should make things clearer.&lt;/div&gt;&lt;pre class="brush: java"&gt;&lt;br /&gt;/**&lt;br /&gt;* This subclass enhances {@code AbstractBean} by implementing the&lt;br /&gt;* {@code Serializable} interface. {@code AbstractSerializableBean} correctly&lt;br /&gt;* serializes all {@code Serializable} listeners that it contains. Implementors&lt;br /&gt;* that need to extends {@code AbstractBean} or one of its subclasses and&lt;br /&gt;* require serialization should use this class if possible. If it is not&lt;br /&gt;* possible to extend this class, the implementation can guide implementors on&lt;br /&gt;* how to properly serialize the listeners.&lt;br /&gt;*&lt;br /&gt;* @see AbstractBean&lt;br /&gt;* @author Ragha&lt;br /&gt;*/&lt;br /&gt;public class AbstractSerializableBean extends AbstractBean implements Serializable&lt;br /&gt;{&lt;br /&gt;  private static final long serialVersionUID = -3459406004204097480L;&lt;br /&gt;&lt;br /&gt;  protected AbstractSerializableBean()&lt;br /&gt;  {&lt;br /&gt;      super();&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;  private void writeObject(ObjectOutputStream s) throws IOException {&lt;br /&gt;      s.defaultWriteObject();&lt;br /&gt;&lt;br /&gt;      for (PropertyChangeListener l : getPropertyChangeListeners()) {&lt;br /&gt;          if (l instanceof Serializable) {&lt;br /&gt;              s.writeObject(l);&lt;br /&gt;          }&lt;br /&gt;      }&lt;br /&gt;      s.writeObject(null);&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;  private void readObject(ObjectInputStream s) throws ClassNotFoundException,&lt;br /&gt;          IOException {&lt;br /&gt;      s.defaultReadObject();&lt;br /&gt;&lt;br /&gt;      Object listenerOrNull;&lt;br /&gt;      while (null != (listenerOrNull = s.readObject())) {&lt;br /&gt;          if (listenerOrNull instanceof PropertyChangeListener) {&lt;br /&gt;              addPropertyChangeListener((PropertyChangeListener) listenerOrNull);&lt;br /&gt;          }&lt;br /&gt;      }&lt;br /&gt;  }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;That's it...pretty straight forward isn't it..&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5025713936013210120-8963394627583055472?l=ragha-justme.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ragha-justme.blogspot.com/feeds/8963394627583055472/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ragha-justme.blogspot.com/2010/09/adding-class-attributes-at-runtime-o.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5025713936013210120/posts/default/8963394627583055472'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5025713936013210120/posts/default/8963394627583055472'/><link rel='alternate' type='text/html' href='http://ragha-justme.blogspot.com/2010/09/adding-class-attributes-at-runtime-o.html' title='Adding class attributes at runtime :O'/><author><name>Ragha</name><uri>http://www.blogger.com/profile/09182969744128777413</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5025713936013210120.post-1671787744118761082</id><published>2010-09-24T02:46:00.001-07:00</published><updated>2011-05-16T12:57:50.400-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='lame observations'/><title type='text'>Predicting hand position on the keyboard by observing random text \m/</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;Today, I was just typing some nonsense keys on my keyboard and happened to observe something interesting. Below is a uniform random sample of what I typed:&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;gh&lt;/div&gt;&lt;div&gt;jgh&lt;/div&gt;&lt;div&gt;jg&lt;/div&gt;&lt;div&gt;hjg&lt;/div&gt;&lt;div&gt;hjg&lt;/div&gt;&lt;div&gt;hjg&lt;/div&gt;&lt;div&gt;hjg&lt;/div&gt;&lt;div&gt;hjg&lt;/div&gt;&lt;div&gt;hkg&lt;/div&gt;&lt;div&gt;hjg&lt;/div&gt;&lt;div&gt;hg&lt;/div&gt;&lt;div&gt;jg&lt;/div&gt;&lt;div&gt;hjg&lt;/div&gt;&lt;div&gt;hjg&lt;/div&gt;&lt;div&gt;hg&lt;/div&gt;&lt;div&gt;hjg&lt;/div&gt;&lt;div&gt;hg&lt;/div&gt;&lt;div&gt;hjg&lt;/div&gt;&lt;div&gt;h&lt;/div&gt;&lt;div&gt;gh&lt;/div&gt;&lt;div&gt;gh&lt;/div&gt;&lt;div&gt;ghj&lt;/div&gt;&lt;div&gt;ghj&lt;/div&gt;&lt;div&gt;ghj&lt;/div&gt;&lt;div&gt;g&lt;/div&gt;&lt;div&gt;hjg&lt;/div&gt;&lt;div&gt;khg&lt;/div&gt;&lt;div&gt;hg&lt;/div&gt;&lt;div&gt;hg&lt;/div&gt;&lt;div&gt;hg&lt;/div&gt;&lt;div&gt;hjg&lt;/div&gt;&lt;div&gt;hjg&lt;/div&gt;&lt;div&gt;hjg&lt;/div&gt;&lt;div&gt;hjg&lt;/div&gt;&lt;div&gt;h&lt;/div&gt;&lt;div&gt;ghj&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;Notice how 'h' repeats a lot of times. It so happens that my middle finger was on 'h'. So, is frequency somehow linked to the length of finger? Turns out I was right. See table below. I used the keys G, H, J, K. My index finger was on G, middle on H, ring finger on J and little finger on K.&lt;br /&gt;&lt;br /&gt;&lt;table border="1" cellpadding="0" cellspacing="0" class="MsoNormalTable" style="border-collapse: collapse; border: none; mso-border-alt: solid white 1.0pt; mso-border-insideh-themecolor: background1; mso-border-insideh: 1.0pt solid white; mso-border-insidev-themecolor: background1; mso-border-insidev: 1.0pt solid white; mso-border-themecolor: background1; mso-padding-alt: 0in 0in 0in 0in; mso-yfti-tbllook: 1184;"&gt;&lt;tbody&gt;&lt;tr style="mso-yfti-firstrow: yes; mso-yfti-irow: 0;"&gt;   &lt;td style="border: solid white 1.0pt; mso-border-themecolor: background1; padding: 0in 5.4pt 0in 5.4pt; width: 168.55pt;" valign="top" width="225"&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"&gt;&lt;b&gt;&lt;span style="font-family: Cambria, serif; font-size: 12pt;"&gt;Character   (Ordered by frequency)&lt;/span&gt;&lt;/b&gt;&lt;span style="font-family: 'Times New Roman', serif; font-size: 12pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;   &lt;td style="border-left: none; border: solid white 1.0pt; mso-border-left-alt: solid white 1.0pt; mso-border-left-themecolor: background1; mso-border-themecolor: background1; padding: 0in 5.4pt 0in 5.4pt; width: 160.65pt;" valign="top" width="214"&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"&gt;&lt;b&gt;&lt;span style="font-family: Cambria, serif; font-size: 12pt;"&gt;Actual   Finger on char&lt;/span&gt;&lt;/b&gt;&lt;span style="font-family: 'Times New Roman', serif; font-size: 12pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;   &lt;td style="border-left: none; border: solid white 1.0pt; mso-border-left-alt: solid white 1.0pt; mso-border-left-themecolor: background1; mso-border-themecolor: background1; padding: 0in 5.4pt 0in 5.4pt; width: 149.6pt;" valign="top" width="199"&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"&gt;&lt;b&gt;&lt;span style="font-family: Cambria, serif; font-size: 12pt;"&gt;Finger   (Ordered by length)&lt;/span&gt;&lt;/b&gt;&lt;span style="font-family: 'Times New Roman', serif; font-size: 12pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr style="mso-yfti-irow: 1;"&gt;   &lt;td style="border-top: none; border: solid white 1.0pt; mso-border-themecolor: background1; mso-border-top-alt: solid white 1.0pt; mso-border-top-themecolor: background1; padding: 0in 5.4pt 0in 5.4pt; width: 168.55pt;" valign="top" width="225"&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"&gt;&lt;span style="font-family: Cambria, serif; font-size: 12pt;"&gt;H&lt;/span&gt;&lt;span style="font-family: 'Times New Roman', serif; font-size: 12pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;   &lt;td style="border-bottom: solid white 1.0pt; border-left: none; border-right: solid white 1.0pt; border-top: none; mso-border-bottom-themecolor: background1; mso-border-left-alt: solid white 1.0pt; mso-border-left-themecolor: background1; mso-border-right-themecolor: background1; mso-border-top-alt: solid white 1.0pt; mso-border-top-themecolor: background1; padding: 0in 5.4pt 0in 5.4pt; width: 160.65pt;" valign="top" width="214"&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"&gt;&lt;span style="font-family: 'Times New Roman', serif; font-size: 12pt;"&gt;Middle&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;   &lt;td style="border-bottom: solid white 1.0pt; border-left: none; border-right: solid white 1.0pt; border-top: none; mso-border-bottom-themecolor: background1; mso-border-left-alt: solid white 1.0pt; mso-border-left-themecolor: background1; mso-border-right-themecolor: background1; mso-border-top-alt: solid white 1.0pt; mso-border-top-themecolor: background1; padding: 0in 5.4pt 0in 5.4pt; width: 149.6pt;" valign="top" width="199"&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"&gt;&lt;span style="font-family: 'Times New Roman', serif; font-size: 12pt;"&gt;Middle&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr style="mso-yfti-irow: 2;"&gt;   &lt;td style="border-top: none; border: solid white 1.0pt; mso-border-themecolor: background1; mso-border-top-alt: solid white 1.0pt; mso-border-top-themecolor: background1; padding: 0in 5.4pt 0in 5.4pt; width: 168.55pt;" valign="top" width="225"&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"&gt;&lt;span style="font-family: Cambria, serif; font-size: 12pt;"&gt;J&lt;/span&gt;&lt;span style="font-family: 'Times New Roman', serif; font-size: 12pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;   &lt;td style="border-bottom: solid white 1.0pt; border-left: none; border-right: solid white 1.0pt; border-top: none; mso-border-bottom-themecolor: background1; mso-border-left-alt: solid white 1.0pt; mso-border-left-themecolor: background1; mso-border-right-themecolor: background1; mso-border-top-alt: solid white 1.0pt; mso-border-top-themecolor: background1; padding: 0in 5.4pt 0in 5.4pt; width: 160.65pt;" valign="top" width="214"&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"&gt;&lt;span style="font-family: 'Times New Roman', serif; font-size: 12pt;"&gt;Ring&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;   &lt;td style="border-bottom: solid white 1.0pt; border-left: none; border-right: solid white 1.0pt; border-top: none; mso-border-bottom-themecolor: background1; mso-border-left-alt: solid white 1.0pt; mso-border-left-themecolor: background1; mso-border-right-themecolor: background1; mso-border-top-alt: solid white 1.0pt; mso-border-top-themecolor: background1; padding: 0in 5.4pt 0in 5.4pt; width: 149.6pt;" valign="top" width="199"&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"&gt;&lt;span style="font-family: 'Times New Roman', serif; font-size: 12pt;"&gt;Ring&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr style="mso-yfti-irow: 3;"&gt;   &lt;td style="border-top: none; border: solid white 1.0pt; mso-border-themecolor: background1; mso-border-top-alt: solid white 1.0pt; mso-border-top-themecolor: background1; padding: 0in 5.4pt 0in 5.4pt; width: 168.55pt;" valign="top" width="225"&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"&gt;&lt;span style="font-family: Cambria, serif; font-size: 12pt;"&gt;G&lt;/span&gt;&lt;span style="font-family: 'Times New Roman', serif; font-size: 12pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;   &lt;td style="border-bottom: solid white 1.0pt; border-left: none; border-right: solid white 1.0pt; border-top: none; mso-border-bottom-themecolor: background1; mso-border-left-alt: solid white 1.0pt; mso-border-left-themecolor: background1; mso-border-right-themecolor: background1; mso-border-top-alt: solid white 1.0pt; mso-border-top-themecolor: background1; padding: 0in 5.4pt 0in 5.4pt; width: 160.65pt;" valign="top" width="214"&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"&gt;&lt;span style="font-family: 'Times New Roman', serif; font-size: 12pt;"&gt;Index&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;   &lt;td style="border-bottom: solid white 1.0pt; border-left: none; border-right: solid white 1.0pt; border-top: none; mso-border-bottom-themecolor: background1; mso-border-left-alt: solid white 1.0pt; mso-border-left-themecolor: background1; mso-border-right-themecolor: background1; mso-border-top-alt: solid white 1.0pt; mso-border-top-themecolor: background1; padding: 0in 5.4pt 0in 5.4pt; width: 149.6pt;" valign="top" width="199"&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"&gt;&lt;span style="font-family: 'Times New Roman', serif; font-size: 12pt;"&gt;Index&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;tr style="mso-yfti-irow: 4; mso-yfti-lastrow: yes;"&gt;   &lt;td style="border-top: none; border: solid white 1.0pt; mso-border-themecolor: background1; mso-border-top-alt: solid white 1.0pt; mso-border-top-themecolor: background1; padding: 0in 5.4pt 0in 5.4pt; width: 168.55pt;" valign="top" width="225"&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"&gt;&lt;span style="font-family: Cambria, serif; font-size: 12pt;"&gt;K&lt;/span&gt;&lt;span style="font-family: 'Times New Roman', serif; font-size: 12pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;   &lt;td style="border-bottom: solid white 1.0pt; border-left: none; border-right: solid white 1.0pt; border-top: none; mso-border-bottom-themecolor: background1; mso-border-left-alt: solid white 1.0pt; mso-border-left-themecolor: background1; mso-border-right-themecolor: background1; mso-border-top-alt: solid white 1.0pt; mso-border-top-themecolor: background1; padding: 0in 5.4pt 0in 5.4pt; width: 160.65pt;" valign="top" width="214"&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"&gt;&lt;span style="font-family: 'Times New Roman', serif; font-size: 12pt;"&gt;Little&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;   &lt;td style="border-bottom: solid white 1.0pt; border-left: none; border-right: solid white 1.0pt; border-top: none; mso-border-bottom-themecolor: background1; mso-border-left-alt: solid white 1.0pt; mso-border-left-themecolor: background1; mso-border-right-themecolor: background1; mso-border-top-alt: solid white 1.0pt; mso-border-top-themecolor: background1; padding: 0in 5.4pt 0in 5.4pt; width: 149.6pt;" valign="top" width="199"&gt;&lt;div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"&gt;&lt;span style="font-family: 'Times New Roman', serif; font-size: 12pt;"&gt;Little&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;You can try this on your own. Place your fingers on the keyboard (horizontally, any other orientation complicates the situation as &lt;i&gt;relative length&lt;/i&gt; changes).&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;Probability theory says that the chance of occurrence of G, H, J or K is 1/4. But I think that in this case, probability is somehow weighted, in a sense that it is proportional to the length of the finger. &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;So, what's the use of all this? &lt;/div&gt;&lt;div&gt;&lt;ol&gt;&lt;li style="text-align: justify;"&gt;I wasted your time...haha!&lt;/li&gt;&lt;li style="text-align: justify;"&gt;You can predict the hand position based on random text...duh!&lt;/li&gt;&lt;li style="text-align: justify;"&gt;Its cool!&lt;/li&gt;&lt;li style="text-align: justify;"&gt;See 1&lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;Is it of any use?&lt;/div&gt;&lt;div style="text-align: justify;"&gt;I guess not, that explains the label 'lame observations'. But who cares?&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5025713936013210120-1671787744118761082?l=ragha-justme.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ragha-justme.blogspot.com/feeds/1671787744118761082/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ragha-justme.blogspot.com/2010/09/freq-of-occurance-of-random-text-to.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5025713936013210120/posts/default/1671787744118761082'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5025713936013210120/posts/default/1671787744118761082'/><link rel='alternate' type='text/html' href='http://ragha-justme.blogspot.com/2010/09/freq-of-occurance-of-random-text-to.html' title='Predicting hand position on the keyboard by observing random text \m/'/><author><name>Ragha</name><uri>http://www.blogger.com/profile/09182969744128777413</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5025713936013210120.post-4516872213017692710</id><published>2010-08-12T07:29:00.000-07:00</published><updated>2011-05-16T12:44:49.268-07:00</updated><title type='text'>P vs NP solved?</title><content type='html'>Vinay Deolalikar, an Indian scientist @ HP Labs claims to have proved P != NP. This is a significant breakthrough and is of great importance to Computer Scientists. A detailed problem description can be found at &lt;a href="http://www.claymath.org/millennium/P_vs_NP/pvsnp.pdf"&gt;http://www.claymath.org/millennium/P_vs_NP/pvsnp.pdf&lt;/a&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Deolalikar's proof can be found at &lt;a href="http://www.hpl.hp.com/personal/Vinay_Deolalikar/Papers/pnp_8_11.pdf"&gt;http://www.hpl.hp.com/personal/Vinay_Deolalikar/Papers/pnp_8_11.pdf&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Note: This is not the final version and is currently undergoing intense peer review.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;If his claim holds true, two clay math problems will have been solved! This is exciting!&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5025713936013210120-4516872213017692710?l=ragha-justme.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ragha-justme.blogspot.com/feeds/4516872213017692710/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ragha-justme.blogspot.com/2010/08/p-vs-np-solved.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5025713936013210120/posts/default/4516872213017692710'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5025713936013210120/posts/default/4516872213017692710'/><link rel='alternate' type='text/html' href='http://ragha-justme.blogspot.com/2010/08/p-vs-np-solved.html' title='P vs NP solved?'/><author><name>Ragha</name><uri>http://www.blogger.com/profile/09182969744128777413</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5025713936013210120.post-2960050128770397848</id><published>2010-07-24T07:08:00.000-07:00</published><updated>2010-09-25T00:36:18.702-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='food for thought'/><title type='text'>Are some people more intelligent than others? - A Mathematical Perspective</title><content type='html'>&lt;div style="text-align: justify;"&gt;People consider some to be more intelligent than others. For example, most of us would agree if I consider newton or Einstein to be more intelligent than you. But is this really true? First off, what is intelligence? At birth everyone is (more or less) at the same level. Then why is it that some people are good at studies, while some just aren't?&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;In my opinion, intelligence is all about making rational decisions given the information/knowledge you possess. People are different because the definition of being rational is different for each of us. For some of us, the act of crossing the road carefully might be rational. For others, most rational thing is to cross the road as quickly as possible. These beliefs are based on prior experiences. Someone who has witnessed a road cross accident might prefer to cross it carefully. Those who got fired because of being late might consider a hush hush approach towards crossing.&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;Bottom line: People are different because of different experiences they possess. This can actually be explained mathematically by a principle most of us are familiar with. Its called 'Bayes Rule'. Bayes rule seeks to find a hypothesis h with high probability given an observation D. Imagine this: You go to your kitchen, find a chair that was used to reach a cookie jar which is now empty. This is observed data D. Probability of this happening is P(D). Now, you can have a set of hypothesis h belonging to set H (representing all possible hypothesis). For instance h1 can be "My daughter must have stolen the cookie". h2 = "A thief stole a cookie as he was hungry". We don't know which of these are true, all may be equally likely. However if we did observe our house to be messed up (typical indicator of stealing), it increases chances of h2 to be true. This rule may be summarized mathematically as:&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_7xvr19hYuG4/TEr6CfzIKhI/AAAAAAAAADA/i_Jth_m1bMk/s1600/bayes.PNG"&gt;&lt;img style="display: block; margin: 0px auto 10px; text-align: center; cursor: pointer; width: 400px; height: 65px;" src="http://2.bp.blogspot.com/_7xvr19hYuG4/TEr6CfzIKhI/AAAAAAAAADA/i_Jth_m1bMk/s400/bayes.PNG" alt="" id="BLOGGER_PHOTO_ID_5497481215961737746" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;Our definition of rationality is based on how our knowledge is updated by this rule. By our experiences, we form various P(D)'s and P(H)'s that direct our thinking.&lt;br /&gt;&lt;br /&gt;Back to the original question: "Are some people smarter than others by birth?". According to bayes rule "NO". It is our experiences that lets us update probability distributions of likelihood of events/hypothesis. These probabilities guide our actions. If someone makes an intelligent choice despite this, then he/she just got lucky.&lt;br /&gt;&lt;br /&gt;Einstein and Newton are intelligent because of their experiences. Some take their experiences for granted. For instance, most of us would just pick up and eat the apple if it fell on our head. Instead, newton reasoned as to why it happened. Is this an indicator of superior intellect? He decided to do a different action (reasoning instead of eating) which is a manifestation of past experience. He must have observed/experienced that its rewarding when you reason every small aspect.&lt;br /&gt;&lt;br /&gt;Why do some people learn faster than others? Is it because of genetics? If so, it is again a propagation of ancestral experiences. It might be the case that they worked hard in their childhood (more experience), thereby improving their intellect. Hence, they don't have to work as hard as you to pick things up.&lt;br /&gt;&lt;br /&gt;So, in conclusion: "All people are born with the same intellect. It is their experiences that define them. To some extent you decide your experiences, so you control how intelligent you want to be."&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5025713936013210120-2960050128770397848?l=ragha-justme.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ragha-justme.blogspot.com/feeds/2960050128770397848/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ragha-justme.blogspot.com/2010/07/are-some-people-more-intelligent-than.html#comment-form' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5025713936013210120/posts/default/2960050128770397848'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5025713936013210120/posts/default/2960050128770397848'/><link rel='alternate' type='text/html' href='http://ragha-justme.blogspot.com/2010/07/are-some-people-more-intelligent-than.html' title='Are some people more intelligent than others? - A Mathematical Perspective'/><author><name>Ragha</name><uri>http://www.blogger.com/profile/09182969744128777413</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_7xvr19hYuG4/TEr6CfzIKhI/AAAAAAAAADA/i_Jth_m1bMk/s72-c/bayes.PNG' height='72' width='72'/><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5025713936013210120.post-6148732652493196811</id><published>2010-07-20T14:14:00.000-07:00</published><updated>2011-05-16T12:44:49.269-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='adobe director'/><title type='text'>Validation framework for adobe director</title><content type='html'>Validation can be a real pain in the ass. After all no developer likes doing labor tasks. With Java, there are many excellent validation frameworks. To know about my take on validation with java see this &lt;a href="http://ragha-infomaniac.blogspot.com/2009/05/my-ideal-desktop-recipe.html"&gt;article&lt;/a&gt;. Adobe director however doesn't have anything like it. So i decided to go ahead and make a simple framework in lingo.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Lets start with usage point of view. We need the name of text field, type of validator (regex, length etc..) and the error message when validation fails. Lets represent this as a list L = {"text field name", "Validator name", "error msg"}. To keep it simple, I only consider validation on text fields (I could have extended it, but it'd make the code look ugly, I wanted to keep it simple. Also, 99% of validation is on text fields)&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Its obvious that a field can have multiple validators. Also, it'd be nice to validate everything in one call. So we can have input as List {L1, L2, ...Ln), where Li aforementioned list format.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;But validators can have parameters. For example length validator can have 'length' parameter. So L should be List("text field name", List ("validator name", param1, param2, ...), "error message"). From the usage point of view we could have something like:&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;pre class="brush: js"&gt;oValidator = new(script "ValidationUtil")&lt;br /&gt;isValid = oValidator.validate([ \&lt;br /&gt;["txtField1", ["NonEmptyValidator"],"Please enter textField1"], \&lt;br /&gt;["txtSSN", ["LengthValidator", 4],"Please enter 4 digit ssn"], \&lt;br /&gt;["txtSSN", ["NumberValidator"],"Please enter a numeric value"]&lt;br /&gt;)&lt;br /&gt;&lt;/pre&gt;Predefined validators (functions) can be called by their string name using call(...) method.&lt;/div&gt;&lt;/div&gt;&lt;div&gt;Since we have all the necessary things are worked out, heres a complete listing of ValidationUtils class. You are free to use and modify this class as per your requirements. Just let me know if your are using it. At least i'll know it was useful to someone.&lt;/div&gt;&lt;div&gt;&lt;pre class="brush: js"&gt;-----------------------------------------------------&lt;br /&gt;--    This class manages all the validation stuff  --&lt;br /&gt;--    @author : Raghavendra Kotikalapudi           --&lt;br /&gt;--    @email  : ragha.unique2000@gmail.com         --&lt;br /&gt;-----------------------------------------------------&lt;br /&gt;&lt;br /&gt;--Currently works only for text fields..&lt;br /&gt;--Checks for validation on the given validator..&lt;br /&gt;on isValidOnValidator me, memberName, lstValidatorAndParams&lt;br /&gt;&lt;br /&gt;val = sprite(memberName).text&lt;br /&gt;--Extract validator name..&lt;br /&gt;validator = lstValidatorAndParams[1]&lt;br /&gt;otherParams = lstValidatorAndParams&lt;br /&gt;--Remove validator name...it now has params only.&lt;br /&gt;otherParams.deleteAt(1)&lt;br /&gt;--Achieves dynamic function calling..&lt;br /&gt;return call(symbol(validator), me, val, otherParams)&lt;br /&gt;&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;--This is the main function to be called.&lt;br /&gt;on validate me, lstMembersAndValidators&lt;br /&gt;&lt;br /&gt;ret = true&lt;br /&gt;repeat with lst in lstMembersAndValidators&lt;br /&gt;&lt;br /&gt;if isValidOnValidator(me, lst[1], lst[2]) = false then&lt;br /&gt; alert(lst[3])&lt;br /&gt; ret = false&lt;br /&gt; exit repeat&lt;br /&gt;end if&lt;br /&gt;&lt;br /&gt;end repeat&lt;br /&gt;&lt;br /&gt;return ret&lt;br /&gt;&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;--Validates non emptiness..&lt;br /&gt;on NonEmptyValidator me, str, lstOptionalParams&lt;br /&gt;&lt;br /&gt;if voidP(str) then&lt;br /&gt;return false&lt;br /&gt;else if length(str) = 0 then&lt;br /&gt;return false&lt;br /&gt;else&lt;br /&gt;return true&lt;br /&gt;end if&lt;br /&gt;&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;--Validates of length of str in in the range (low, hi) inclusive&lt;br /&gt;--lstOptParams has low, high pair&lt;br /&gt;on LengthRangeValidator me, str, lstOptionalParams&lt;br /&gt;&lt;br /&gt;len = length(str)&lt;br /&gt;if len &gt;= lstOptionalParams[1] and len &lt;= lstOptionalParams[2] then     return true   else     return false   end if    end  --Validates for non existence of special symbols.. --i.e, str can contain a-z, A-Z or 0-9 on NoSpecialSymbolsValidator me, str, lstOptionalParams      foundCount = PRegEx_Search([str], "~+|`+|!+|@+|#+|\$+|%+|\^+|&amp;amp;+|\*+|\(+|\)+|\{+|\}+|\[+|\]+|\++|\\+|\|+|:+|;+|/+|\&lt;+|\&gt;+|\?+|,+")&lt;br /&gt;&lt;br /&gt;--If special char is found, validate to false&lt;br /&gt;if foundCount &gt; 0 then&lt;br /&gt;return false&lt;br /&gt;else&lt;br /&gt;return true&lt;br /&gt;end if&lt;br /&gt;&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;--Validates if the given str is a valid name or not, i.e., it should not contain&lt;br /&gt;--special symbols or 0-9&lt;br /&gt;on NameValidator me, str, lstOptionalParams&lt;br /&gt;&lt;br /&gt;val = NoSpecialSymbolsValidator(me, str, lstOptionalParams)&lt;br /&gt;if val = false then&lt;br /&gt;return false&lt;br /&gt;else&lt;br /&gt;foundCount = PRegEx_Search([str], "[0-9]+")&lt;br /&gt;--If number if found..&lt;br /&gt;if foundCount &gt; 0 then&lt;br /&gt; return false&lt;br /&gt;else&lt;br /&gt; return true&lt;br /&gt;end if&lt;br /&gt;end if&lt;br /&gt;&lt;br /&gt;end&lt;br /&gt;&lt;/pre&gt;New Validators can be added as an when needed. PRegEX_search(...) comes from &lt;a href="http://openxtras.org/pregex/"&gt;PRegEx Xtra&lt;/a&gt;. Fortunately, it is free to download. This framework handles error notifications by showing alert messages whenever validation fails. Neat isn't it.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;If you have any suggestions or improvements, please let me know through comments. Hope you find this useful!&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5025713936013210120-6148732652493196811?l=ragha-justme.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ragha-justme.blogspot.com/feeds/6148732652493196811/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ragha-justme.blogspot.com/2010/07/validation-framework-for-adobe-director.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5025713936013210120/posts/default/6148732652493196811'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5025713936013210120/posts/default/6148732652493196811'/><link rel='alternate' type='text/html' href='http://ragha-justme.blogspot.com/2010/07/validation-framework-for-adobe-director.html' title='Validation framework for adobe director'/><author><name>Ragha</name><uri>http://www.blogger.com/profile/09182969744128777413</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5025713936013210120.post-6562984136455818996</id><published>2010-07-02T08:27:00.000-07:00</published><updated>2010-07-03T08:51:37.842-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='lol series'/><category scheme='http://www.blogger.com/atom/ns#' term='whacky'/><title type='text'>Women and Their Craze for Possessions</title><content type='html'>A woman parked her brand-new Lexus in front of her office ready to show it off to her colleagues. As she got out, a truck passed too close and completely tore off the door on the driver's side. The woman immediately grabbed her cell phone, dialed 911, and within minutes a policeman pulled up. Before the officer had a chance to ask any questions, the woman started screaming hysterically.&lt;br /&gt;&lt;br /&gt;Her Lexus, which she had just picked up the day before, was now completely ruined and would never be the same, no matter what the body shop did to it. When the woman finally wound down from her ranting and raving, the officer shook his head in disgust and disbelief. "I can't believe how materialistic you women are," he said. "You are so focused on your possessions that you don't notice anything else."&lt;br /&gt;&lt;br /&gt;"How can you say such a thing?" asked the woman.&lt;br /&gt;&lt;br /&gt;The cop replied, "Don't you know that your right arm is missing from the elbow down? It must have been torn off when the truck hit you."&lt;br /&gt;&lt;br /&gt;"OH MY GOD!" screamed the woman. "Where's my new bracelet !!!"&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5025713936013210120-6562984136455818996?l=ragha-justme.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ragha-justme.blogspot.com/feeds/6562984136455818996/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ragha-justme.blogspot.com/2010/07/women-and-their-craze-for-possessions.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5025713936013210120/posts/default/6562984136455818996'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5025713936013210120/posts/default/6562984136455818996'/><link rel='alternate' type='text/html' href='http://ragha-justme.blogspot.com/2010/07/women-and-their-craze-for-possessions.html' title='Women and Their Craze for Possessions'/><author><name>Ragha</name><uri>http://www.blogger.com/profile/09182969744128777413</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5025713936013210120.post-8565034254892995615</id><published>2010-06-07T13:23:00.000-07:00</published><updated>2011-05-16T12:44:49.269-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='adobe director'/><title type='text'>Report generation in adobe director..</title><content type='html'>&lt;div style="text-align: justify;"&gt;Report generation is perhaps the most plagued problem with director. There are a lot of xtras out there, but are commercial. Most of them are around $100-350, and all are limited in one way or another. After weeks of exploration, few of which included:&lt;br /&gt;&lt;/div&gt;&lt;ol&gt;&lt;li&gt;Using adobe reader&lt;/li&gt;&lt;li&gt;Interfacing it via. java program (this one almost worked)&lt;/li&gt;&lt;li&gt;Wasted time with lots of useless xtras&lt;/li&gt;&lt;/ol&gt;I decided to make my own scheme, one which works in most situations. The idea is as follows:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Create a HTML template of your report. For instance, if you wanted customer information report. You create a HTML template, fill in all the blanks with $1, $2, ... $n.&lt;/li&gt;&lt;li&gt;From director, while generating the report, you first read in the template (preferably from root folder\templates\).&lt;/li&gt;&lt;li&gt;Replace $1, $2, with appropriate values.&lt;/li&gt;&lt;li&gt;Generate HTML file and open it with default browser.&lt;/li&gt;&lt;/ol&gt;I created a utility class for the above tasks. You'll be needing FileIO xtra and FileXtra4 (both of which are available for free)&lt;br /&gt;&lt;hr /&gt;&lt;pre class="brush: js"&gt;-------------------------------------------------------------&lt;br /&gt;--------------Report generation Utility class----------------&lt;br /&gt;-------------------------------------------------------------&lt;br /&gt;&lt;br /&gt;--Finds and replaces the first occurrence of 'aLookForString' with 'aReplaceString'&lt;br /&gt;--in 'aString' and returns the new string&lt;br /&gt;on findAndReplace me, aString, aLookForString, aReplaceString&lt;br /&gt;&lt;br /&gt;n = aLookForString.length -1&lt;br /&gt;is_ok = false&lt;br /&gt;&lt;br /&gt;repeat while is_ok = false&lt;br /&gt;&lt;br /&gt;place = offset(aLookForString, aString)&lt;br /&gt;&lt;br /&gt;if (place = 0) then&lt;br /&gt;is_ok = true&lt;br /&gt;exit repeat&lt;br /&gt;else&lt;br /&gt;put aReplaceString into char place to (place+n) of aString&lt;br /&gt;exit repeat&lt;br /&gt;end if&lt;br /&gt;&lt;br /&gt;end repeat&lt;br /&gt;&lt;br /&gt;return aString&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;--Saves the text in given filename&lt;br /&gt;on saveText me, text, filename&lt;br /&gt;&lt;br /&gt;-- create the FileIO instance&lt;br /&gt;fileObj = new(xtra "FileIO")&lt;br /&gt;&lt;br /&gt;-- delete existing file, if any&lt;br /&gt;openFile (fileObj,filename,2)&lt;br /&gt;delete(fileObj)&lt;br /&gt;&lt;br /&gt;-- create and open the file&lt;br /&gt;createFile(fileObj,filename)&lt;br /&gt;openFile(fileObj,filename,2)&lt;br /&gt;&lt;br /&gt;-- check to see if file opened ok&lt;br /&gt;if status(fileObj) &lt;&gt; 0 then&lt;br /&gt;err = error(fileObj,status(fileObj))&lt;br /&gt;alert "Error:"&amp;amp;&amp;amp;err&lt;br /&gt;return FALSE&lt;br /&gt;end if&lt;br /&gt;&lt;br /&gt;-- write the file&lt;br /&gt;writeString(fileObj,text)&lt;br /&gt;&lt;br /&gt;-- close the file&lt;br /&gt;closeFile(fileObj)&lt;br /&gt;&lt;br /&gt;return TRUE&lt;br /&gt;&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;--Reads the text from a given filename&lt;br /&gt;on readFromFile me, filename&lt;br /&gt;&lt;br /&gt;-- create the FileIO instance&lt;br /&gt;fileObj = new(xtra "FileIO")&lt;br /&gt;&lt;br /&gt;-- open the file&lt;br /&gt;openFile(fileObj,filename,1)&lt;br /&gt;&lt;br /&gt;-- check to see if file opened ok&lt;br /&gt;if status(fileObj) &lt;&gt; 0 then&lt;br /&gt;err = error(fileObj,status(fileObj))&lt;br /&gt;alert "Error:"&amp;amp;&amp;amp;err&lt;br /&gt;return ""&lt;br /&gt;end if&lt;br /&gt;&lt;br /&gt;-- read the file&lt;br /&gt;text = readFile(fileObj)&lt;br /&gt;&lt;br /&gt;-- close the file&lt;br /&gt;closeFile(fileObj)&lt;br /&gt;&lt;br /&gt;--return the text&lt;br /&gt;return text&lt;br /&gt;&lt;br /&gt;end&lt;br /&gt;&lt;hr /&gt;&lt;br /&gt;&lt;/pre&gt;Sample usage is illustrated below:&lt;br /&gt;&lt;pre class="brush: js"&gt;&lt;br /&gt; oUtilClass = new(script "UtilClass")&lt;br /&gt;&lt;br /&gt;--Read html from the template&lt;br /&gt;html = oUtilClass.readFromFile(the moviepath &amp;amp; "\\Templates\\summary report.htm")&lt;br /&gt;&lt;br /&gt;--Fill in data..&lt;br /&gt;global strSelectedDate&lt;br /&gt;html = oUtilClass.findAndReplace(html, "$1", someVar)&lt;br /&gt;html = oUtilClass.findAndReplace(html, "$2", anotherVar)&lt;br /&gt;&lt;br /&gt;filename = the moviepath &amp;amp; "print.html"&lt;br /&gt;oUtilClass.saveText(html, filename)&lt;br /&gt;&lt;br /&gt;--Invoke through a browser..&lt;br /&gt;fileXtra4Obj = xtra("FileXtra4").new()&lt;br /&gt;fileXtra4Obj.fx_FileRunApp(the moviepath &amp;amp; "run.bat")&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;hr /&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;In run.bat, you just have to call print.html by writing "print.html", Duh!&lt;br /&gt;Therefore, run.bat opens print.html with the default browser, which can then be printed, previewed by the courtesy of browser. Whats more, you also get to fiddle with niche layout settings at runtime. In other operating systems like linux, you just have to replace run.bat with a shell script.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 102, 102);font-size:130%;" &gt;Some Minor Tidbits&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;What if you wanted to generate a table at runtime? Here's what I'd do:&lt;br /&gt;&lt;br /&gt;Generate HTML template from dreamweaver or MS word with one row of data in the table..&lt;br /&gt;For example...&lt;br /&gt;&lt;pre class="brush: html"&gt;&amp;lt;html&amp;gt;&lt;br /&gt;Some blah blah..&lt;br /&gt;&lt;br /&gt;Name: $1 &amp;lt;/br&amp;gt;&lt;br /&gt;Age : $2 &amp;lt;/br&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;table&amp;gt;&lt;br /&gt;&amp;lt;tr&amp;gt;&lt;br /&gt;&amp;lt;td&amp;gt; Subject &amp;lt;/td&amp;gt;&lt;br /&gt;&amp;lt;td&amp;gt; Marks &amp;lt;/td&amp;gt;&lt;br /&gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;tr&amp;gt;&lt;br /&gt;&amp;lt;td&amp;gt; Some subject &amp;lt;/td&amp;gt;&lt;br /&gt;&amp;lt;td&amp;gt; 85 &amp;lt;/td&amp;gt;&lt;br /&gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;&amp;lt;/table&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;/html&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Now, create a file template1_rows.txt containing the row data..&amp;lt;html&amp;gt;&lt;br /&gt;&lt;pre class="brush: html"&gt;&amp;lt;tr&amp;gt;&lt;br /&gt;&amp;lt;td&amp;gt; $1 &amp;lt;/td&amp;gt;&lt;br /&gt;&amp;lt;td&amp;gt; $2 &amp;lt;/td&amp;gt;&lt;br /&gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;&lt;/pre&gt;Here's the big idea. Whenever you build a table, read in the row data template, fill it and append it to the main html. Here's an example. Highlighted code achieves dynamic table generation behavior.&lt;br /&gt;&lt;pre class="brush: js; highlight: [9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23]"&gt; --Read html from the template&lt;br /&gt;html = oUtilClass.readFromFile(the moviepath &amp;amp; "\\Templates\\template1.htm")&lt;br /&gt;&lt;br /&gt;--Fill in data..&lt;br /&gt;global strSelectedDate&lt;br /&gt;html = oUtilClass.findAndReplace(html, "$1", name)&lt;br /&gt;html = oUtilClass.findAndReplace(html, "$2", age)&lt;br /&gt;&lt;br /&gt;tableRows = ""&lt;br /&gt;--Read in the row template..&lt;br /&gt;rowTemplate = oUtilClass.readFromFile(the moviepath &amp;amp "\\Templates\\template1_rows.htm")&lt;br /&gt;&lt;br /&gt;--Generate table rows..&lt;br /&gt;repeat with row=1 to numRows&lt;br /&gt;tableRow = rowTemplate&lt;br /&gt;tableRow = oUtilClass.findAndReplace(tableRow , "$1", subject)&lt;br /&gt;&lt;br /&gt;--Append data to tableRows..&lt;br /&gt;tableRows = tableRows &amp;amp; rowTemplate&lt;br /&gt;end repeat&lt;br /&gt;&lt;br /&gt;--Fill in table data..&lt;br /&gt;html = oUtilClass.findAndReplace(html, "$3", tableRows)&lt;br /&gt;&lt;br /&gt;filename = the moviepath &amp;amp; "print.html"&lt;br /&gt;oUtilClass.saveText(html, filename)&lt;br /&gt;&lt;br /&gt;fileXtra4Obj = xtra("FileXtra4").new()&lt;br /&gt;fileXtra4Obj.fx_FileRunApp(the moviepath &amp;amp; "run.bat")&lt;br /&gt;&lt;/pre&gt;I know, it looks complicated. But atleast this is transparent and you exactly know whats going on. Moreover, this approach gives you unlimited formatting options, &lt;span style="font-weight: bold;"&gt;works&lt;/span&gt; and is &lt;span style="font-weight: bold;"&gt;free&lt;/span&gt;. Once you get a hand of it, it'll seem pretty simple.&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 102, 102);font-size:130%;" &gt;Controlling print behavior&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;If you don't want your table to break across pages, you can use . Beware, this only works with opera browser. So be sure to ship your software with opera. Even better, use opera portable (requires no installation), make appropriate changes to run.bat to invoke html with the shipped browser.&lt;br /&gt;&lt;br /&gt;Comments and suggestions are welcome. If anyone has simpler and free approach, please let me know by posting comments.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5025713936013210120-8565034254892995615?l=ragha-justme.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ragha-justme.blogspot.com/feeds/8565034254892995615/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ragha-justme.blogspot.com/2010/06/report-generation-in-adobe-director.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5025713936013210120/posts/default/8565034254892995615'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5025713936013210120/posts/default/8565034254892995615'/><link rel='alternate' type='text/html' href='http://ragha-justme.blogspot.com/2010/06/report-generation-in-adobe-director.html' title='Report generation in adobe director..'/><author><name>Ragha</name><uri>http://www.blogger.com/profile/09182969744128777413</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5025713936013210120.post-5560964707374078869</id><published>2010-06-01T09:36:00.000-07:00</published><updated>2011-05-16T12:44:49.269-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='c++'/><title type='text'>Segmentation fault with c++ vector</title><content type='html'>&lt;div style="text-align: justify;"&gt;Ever been in a situation where you got a seg. fault when you tried to push_back a pointer into the vector? What's more,  you have a useless log file with no clues whatsoever. I had the same issue when i was working on an assignment with deadline in 2 hours. After whacking my head for 1-2 hours, I finally found a way to resolve the issue.&lt;br /&gt;&lt;br /&gt;I was working on "simple ecosystem" project. The code where new fishes are created and added to the ecosystem seg. faulted. Take a look, I cut down unnecessary things to keep this example simple.&lt;br /&gt;&lt;/div&gt;&lt;pre class="brush: c++"&gt;for (vector&lt;point2d&gt;::iterator it = vecPossiblePositions.begin(); it!=vecPossiblePositions.end(); ++it)&lt;br /&gt;{&lt;br /&gt;//create a new fish..&lt;br /&gt;Fish *f = new Fish();&lt;br /&gt;f-&gt;setPosition(it-&gt;getX(), it-&gt;getY());&lt;br /&gt;&lt;br /&gt;//This method does a push_back&lt;br /&gt;//operation on some vector&lt;br /&gt;ecosystem-&gt;addEcosystemObject(f);&lt;br /&gt;}&lt;br /&gt;&lt;/point2d&gt;&lt;/pre&gt;&lt;div style="text-align: justify;"&gt;If i comment out &lt;span style="color: rgb(255, 102, 0);"&gt;ecosystem-&gt;addEcosystemObject(f)&lt;/span&gt;&lt;span style="font-style: italic;"&gt; &lt;/span&gt;line, then it runs without seg. fault. Apparently, the line &lt;span style="color: rgb(255, 102, 0);"&gt;Fish *f = new Fish()&lt;/span&gt; was causing the problem. So here's what i did.&lt;br /&gt;&lt;/div&gt;&lt;pre class="brush: c++"&gt;Fish *f = NULL;&lt;br /&gt;for (vector&lt;point2d&gt;::iterator it = vecPossiblePositions.begin(); it!=vecPossiblePositions.end(); ++it)&lt;br /&gt;{&lt;br /&gt;//create a new fish..&lt;br /&gt;f = new Fish();&lt;br /&gt;f-&gt;setPosition(it-&gt;getX(), it-&gt;getY());&lt;br /&gt;&lt;br /&gt;//This method does a push_back&lt;br /&gt;//operation on some vector&lt;br /&gt;ecosystem-&gt;addEcosystemObject(f);&lt;br /&gt;}&lt;br /&gt;&lt;/point2d&gt;&lt;/pre&gt;&lt;div style="text-align: justify;"&gt;and that fixed the problem! I have no idea why it worked. So, today's lesson of  the day is "Keep the damn ptr declarations outside loops"&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5025713936013210120-5560964707374078869?l=ragha-justme.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ragha-justme.blogspot.com/feeds/5560964707374078869/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ragha-justme.blogspot.com/2010/06/segmentation-fault-with-c-vector.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5025713936013210120/posts/default/5560964707374078869'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5025713936013210120/posts/default/5560964707374078869'/><link rel='alternate' type='text/html' href='http://ragha-justme.blogspot.com/2010/06/segmentation-fault-with-c-vector.html' title='Segmentation fault with c++ vector'/><author><name>Ragha</name><uri>http://www.blogger.com/profile/09182969744128777413</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5025713936013210120.post-7847803496310068110</id><published>2010-06-01T09:14:00.000-07:00</published><updated>2010-06-01T09:30:08.494-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='personal'/><title type='text'>Enter teeki chawal</title><content type='html'>&lt;div style="text-align: justify;"&gt;Got bored of same old food? Try this recipe..I found out about it from a friend of mine and made a few modifications of my own.&lt;br /&gt;&lt;br /&gt;Here's what you need:&lt;br /&gt;&lt;/div&gt;&lt;ol style="text-align: justify;"&gt;&lt;li&gt;Cooked rice&lt;/li&gt;&lt;li&gt;Oil (obviously)&lt;/li&gt;&lt;li&gt;Mirchi powder, jeera, salt, chopped onions, semi boiled and cut potato (one will do)&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Crushed tomatoes, c, carrots, beans, green peas, corn&lt;/li&gt;&lt;/ol&gt;&lt;div style="text-align: justify;"&gt;Here's how you proceed:&lt;br /&gt;&lt;/div&gt;&lt;ol style="text-align: justify;"&gt;&lt;li&gt;Heat a pan with lots of oil..&lt;/li&gt;&lt;li&gt;Put jeera (one handful, needs to be more)&lt;/li&gt;&lt;li&gt;Put onions and fry em' all at med flame&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Once onions are semi fried, put capsicum, potatoes and cook for like 7 mins&lt;/li&gt;&lt;li&gt;Put remaining veggies and cook for another 7 mins.&lt;/li&gt;&lt;li&gt;Add mirchi powder, and any other spices you fancy (Dhaniya powder, Hing, Garam masala will also do)&lt;/li&gt;&lt;li&gt;Let it cook for another 5 mins..(At any point, if you notice that the veggies are burning, add a little bit of crushed tomato puree)&lt;/li&gt;&lt;li&gt;Add 40% of the crushed tomatoes from the can.&lt;/li&gt;&lt;li&gt;Cook for 10 mins.&lt;/li&gt;&lt;li&gt;Now, taste the mixture, it should be slightly spicier, if not, add more spices. Also, at this point you should notice oil separating from the mixture&lt;/li&gt;&lt;li&gt;Add cooked rice (cold one preferably), and stir for 3-5 mins..&lt;/li&gt;&lt;/ol&gt;&lt;div style="text-align: justify;"&gt;That's it..enjoy your meal :)&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5025713936013210120-7847803496310068110?l=ragha-justme.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ragha-justme.blogspot.com/feeds/7847803496310068110/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ragha-justme.blogspot.com/2010/06/enter-teeki-chawal.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5025713936013210120/posts/default/7847803496310068110'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5025713936013210120/posts/default/7847803496310068110'/><link rel='alternate' type='text/html' href='http://ragha-justme.blogspot.com/2010/06/enter-teeki-chawal.html' title='Enter teeki chawal'/><author><name>Ragha</name><uri>http://www.blogger.com/profile/09182969744128777413</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5025713936013210120.post-5206278508043746304</id><published>2010-05-27T21:48:00.000-07:00</published><updated>2010-05-28T09:42:04.087-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='food for thought'/><category scheme='http://www.blogger.com/atom/ns#' term='whacky'/><title type='text'>Measuring the Observer Expectancy Effect</title><content type='html'>&lt;div style="text-align: justify;"&gt;If you are performing an experiment in which you tell the participant what you are expecting, then this biases the result due to &lt;a href="http://en.wikipedia.org/wiki/Placebo"&gt;placebo effect&lt;/a&gt;. This is the observer expectancy effect. How can you measure this? Intuitively, the solution seems simple. Do the experiment twice, in the first, tell the participant about the expected outcomes and in the second don't tell him anything about the experiment. Then, you measure the difference in outcomes to calculate the variance introduced due to observer expectancy effect. But, is that accurate?&lt;br /&gt;&lt;br /&gt;Lets consider a simple example. Suppose you are to create stress relief program. How would you measure if stress is relived or not? If you tell your subjects that they were participating in stress relief program, placebo effect will come into account and you cannot truly determine if the reduction in stress is actually due to the program you created. If you don't tell anyone about anything, including researchers and participants, you can get rid of the observer expectancy effect. This is the &lt;a href="http://en.wikipedia.org/wiki/Double-blind_experiment#Double-blind_trials"&gt;Double Blind trial&lt;/a&gt; strategy.&lt;br /&gt;&lt;br /&gt;Coming back to the original question, if you do the experiment twice, one with the expectancy effect and another using double blind strategy and consider the difference in performance, do we then have the measure of observer expectancy?&lt;br /&gt;&lt;br /&gt;The answer is NO because in both the experiments the state of the participant is different. To be accurate, you'll have to conduct both the experiments in which the researchers, participants and in fact the entire universe is in the same state, i.e., do both the experiments simultaneously, which obviously doesn't work out.&lt;br /&gt;&lt;br /&gt;How else can we go about this problem? First we start by formalizing the problem, making it concise. For simplicity, let us consider a single participant. In a given experiment, let the state of the participant be Sp (could involve factors such as personality etc..) and the state of everything else be Se (state of the environment, ideally the entire universe, but a local region would suffice). Therefore, the state of an experiment can be defined by the Tuple (Sp, Se).&lt;br /&gt;&lt;br /&gt;Now, perform N experiments with blind trial strategy, each  represented by different tuples (S1p, S1e) ... (Snp, Sne) You can now build a regression model to determine the the outcome of the experiment as a function of Se and Sp, after collecting data from sufficiently large number of experiments.&lt;br /&gt;&lt;br /&gt;Now we can apply the strategy discussed before. We perform experiment with double blind trial with parameters (S1e, S1p). The second experiment (with expectancy effect) with parameters (S2e, S2p). We can now extrapolate the outcomes of first experiment if parameters S2e and S2p were used instead of S1e and S1p. Since, both the experiments are now virtually conducted simultaneously, we can now determine the observer expectancy effect by computing the difference in outcome.&lt;br /&gt;&lt;br /&gt;More accurate the regression model, better is the accuracy of the observer expectancy. With few obvious modifications, one can also build a model to estimate observer expectancy as a function of experiment, Se and Sp.&lt;br /&gt;&lt;br /&gt;On a second thought, who gives a damn? If the stress relief program works, be it due to expectancy, that's all we really care about.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5025713936013210120-5206278508043746304?l=ragha-justme.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ragha-justme.blogspot.com/feeds/5206278508043746304/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ragha-justme.blogspot.com/2010/05/measuring-observer-expectancy-effect.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5025713936013210120/posts/default/5206278508043746304'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5025713936013210120/posts/default/5206278508043746304'/><link rel='alternate' type='text/html' href='http://ragha-justme.blogspot.com/2010/05/measuring-observer-expectancy-effect.html' title='Measuring the Observer Expectancy Effect'/><author><name>Ragha</name><uri>http://www.blogger.com/profile/09182969744128777413</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5025713936013210120.post-2984167032863159535</id><published>2010-04-25T09:09:00.000-07:00</published><updated>2011-05-16T12:44:49.269-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ai'/><category scheme='http://www.blogger.com/atom/ns#' term='cool stuff'/><title type='text'>How to solve puzzles</title><content type='html'>Interested in solving single player puzzles such as "Sudoku", "Rubik's Cube", "Missionaries and Cannibals", "Traveling Salesman Problem"? Try out my newest project, &lt;a href="https://jsimpleai.dev.java.net/"&gt;JSimpleAI&lt;/a&gt;. For a detailed description, check my blog post on &lt;a href="http://ragha-justme.blogspot.com/2010/04/how-to-solve-puzzles.html"&gt;How to solve puzzles&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5025713936013210120-2984167032863159535?l=ragha-justme.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ragha-justme.blogspot.com/feeds/2984167032863159535/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ragha-justme.blogspot.com/2010/04/how-to-solve-puzzles_25.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5025713936013210120/posts/default/2984167032863159535'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5025713936013210120/posts/default/2984167032863159535'/><link rel='alternate' type='text/html' href='http://ragha-justme.blogspot.com/2010/04/how-to-solve-puzzles_25.html' title='How to solve puzzles'/><author><name>Ragha</name><uri>http://www.blogger.com/profile/09182969744128777413</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5025713936013210120.post-6177209780523666264</id><published>2010-04-25T08:39:00.000-07:00</published><updated>2010-04-27T18:35:17.359-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ai'/><category scheme='http://www.blogger.com/atom/ns#' term='whacky'/><title type='text'>How to solve puzzles</title><content type='html'>&lt;div style="text-align: justify;"&gt;I recently came across this puzzle called as &lt;a href="http://www.justriddlesandmore.com/frogleap.html"&gt;frog leap&lt;/a&gt;. Its an interesting puzzle, so, I sat down trying to solve it. I quickly lost my patience, and being a computer science student, decided to write an AI to solve it. It just took me 20 minutes to write an AI that solves this puzzle! boy am i glad not to have wasted my time thinking about the puzzle.&lt;br /&gt;&lt;br /&gt;I decided to go ahead an start a project that allows you to solve single player puzzles such as "Sudoku", "Rubik's cube", "Missionaries and Cannibals problem", the notorious euclidean traveling salesman problem etc.. Its called &lt;a href="https://jsimpleai.dev.java.net/"&gt;JSimpleAI&lt;/a&gt; and is open sourced @ java.net. I currently implemented TSP and Frog Leap solvers as demos. I'll be more than happy if any of you are interested in implementing suduko, rubiks cube etc..For the algorithmically oriented, you can implement SMA* algorithm. Think about the number of people that can benefit from this!&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;I am very proud of the project logo that i chose:&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_7xvr19hYuG4/S9RmySRXz4I/AAAAAAAAACw/39thXFfSMCU/s1600/landscape.png"&gt;&lt;img style="display: block; margin: 0px auto 10px; text-align: center; cursor: pointer; width: 300px; height: 250px;" src="http://3.bp.blogspot.com/_7xvr19hYuG4/S9RmySRXz4I/AAAAAAAAACw/39thXFfSMCU/s400/landscape.png" alt="" id="BLOGGER_PHOTO_ID_5464105261991448450" border="0" /&gt;&lt;/a&gt;It shows the search landscape and the local optima's. Cool isn't it!&lt;br /&gt;&lt;br /&gt;In case you're wondering about the solution for frog leap, there are two of them. Here is a screenshot from JSimpleAI. It took 0 secs to solve it! Why dont you go ahead and try writing a code to solve missionaries and cannibals problem? It'll be fun&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_7xvr19hYuG4/S9RnxbQMhiI/AAAAAAAAAC4/C-7-8um0d0U/s1600/solution.PNG"&gt;&lt;img style="display: block; margin: 0px auto 10px; text-align: center; cursor: pointer; width: 370px; height: 400px;" src="http://4.bp.blogspot.com/_7xvr19hYuG4/S9RnxbQMhiI/AAAAAAAAAC4/C-7-8um0d0U/s400/solution.PNG" alt="" id="BLOGGER_PHOTO_ID_5464106346734192162" border="0" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5025713936013210120-6177209780523666264?l=ragha-justme.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ragha-justme.blogspot.com/feeds/6177209780523666264/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ragha-justme.blogspot.com/2010/04/how-to-solve-puzzles.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5025713936013210120/posts/default/6177209780523666264'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5025713936013210120/posts/default/6177209780523666264'/><link rel='alternate' type='text/html' href='http://ragha-justme.blogspot.com/2010/04/how-to-solve-puzzles.html' title='How to solve puzzles'/><author><name>Ragha</name><uri>http://www.blogger.com/profile/09182969744128777413</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_7xvr19hYuG4/S9RmySRXz4I/AAAAAAAAACw/39thXFfSMCU/s72-c/landscape.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5025713936013210120.post-4233915411360797545</id><published>2010-04-12T19:43:00.000-07:00</published><updated>2010-04-12T19:48:56.479-07:00</updated><title type='text'>Life sure is busy...</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_7xvr19hYuG4/S8ParJjyQsI/AAAAAAAAACo/OGZadP8_vTc/s1600/things.PNG"&gt;&lt;img style="display: block; margin: 0px auto 10px; text-align: center; cursor: pointer; width: 447px; height: 300px;" src="http://4.bp.blogspot.com/_7xvr19hYuG4/S8ParJjyQsI/AAAAAAAAACo/OGZadP8_vTc/s400/things.PNG" alt="" id="BLOGGER_PHOTO_ID_5459447608138416834" border="0" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5025713936013210120-4233915411360797545?l=ragha-justme.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ragha-justme.blogspot.com/feeds/4233915411360797545/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ragha-justme.blogspot.com/2010/04/life-sure-is-busy.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5025713936013210120/posts/default/4233915411360797545'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5025713936013210120/posts/default/4233915411360797545'/><link rel='alternate' type='text/html' href='http://ragha-justme.blogspot.com/2010/04/life-sure-is-busy.html' title='Life sure is busy...'/><author><name>Ragha</name><uri>http://www.blogger.com/profile/09182969744128777413</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_7xvr19hYuG4/S8ParJjyQsI/AAAAAAAAACo/OGZadP8_vTc/s72-c/things.PNG' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5025713936013210120.post-5292464910232363952</id><published>2010-01-11T09:52:00.000-08:00</published><updated>2010-01-11T09:59:18.717-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='whacky'/><title type='text'>The irony..</title><content type='html'>A Japanese fisher man loves to fish. He sells just enough fish to pay for his bills; and enjoys a happy family life since his fishing does not take up all his time. A business man comes along, shakes his head and suggests that the fisher man buys a boat, hires men and fishes in deeper waters. That way, he advises, the fisherman can catch more fish... See More, make more money, and in turn buy more boats and hire even more men!&lt;br /&gt;&lt;br /&gt;The fisher man asks, "for what reason would I do such a thing?" The businessman smiles and says that once he has established a thriving business, he has then the option to sell it so that he can live a more leisurely life; perhaps spend more time with his family and hobbies. The fisherman smiles and says – "I already have that now…why would I waste time walking in circles only to come back to where I am now?"&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5025713936013210120-5292464910232363952?l=ragha-justme.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ragha-justme.blogspot.com/feeds/5292464910232363952/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ragha-justme.blogspot.com/2010/01/irony.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5025713936013210120/posts/default/5292464910232363952'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5025713936013210120/posts/default/5292464910232363952'/><link rel='alternate' type='text/html' href='http://ragha-justme.blogspot.com/2010/01/irony.html' title='The irony..'/><author><name>Ragha</name><uri>http://www.blogger.com/profile/09182969744128777413</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5025713936013210120.post-4885528499427103466</id><published>2009-10-24T04:43:00.000-07:00</published><updated>2009-10-24T06:36:14.598-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='useful'/><title type='text'>My research methodology, formalized :)</title><content type='html'>Ok, here's the scenario. You are in a conference hall lecturing some of the brilliant minds about your research, people are taking your notes!!! (aha), asking you fancy questions and you just bowl them over with your elegant answers (double aha). The conference is a great success, your teachers are impressed by you; who knows, your name just might appear in the news paper (now you can hear violins playing in the background). Suddenly you hear your mom shouting, struggling to wake you up from your slumber...grrr (Sad reality of life, good moments don't last long). Anyways, this dream has motivated you to write your very own research paper except for one teeny little problem. You dunno how to start. Oh, i hear your nerdish blood throbbing, good good, you can read on...&lt;br /&gt;&lt;br /&gt;Research is and always has been intuitive in nature. Most great things are just stumbled upon.., rarely do people plan and do something ingenious. If you are like me, then DO NOT rely on luck expecting a golden apple to fall right into your hands, work your way towards it. 99% of research is planned. Plan and work towards your goal, its that simple.&lt;br /&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 153, 153);"&gt;Research topic/problem selection&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;1) Select an interesting area of your choice. Its better if you have some former knowledge on it. I know big bang stuff sounds cool, but its way outta my league; so, select something that fits in your knowledge domain. Lets see, i am into software stuff...that should be a good place to start.&lt;br /&gt;&lt;br /&gt;2) Narrow down your domain. Ask yourself, "what in software stuff"? Hmm, for me it would be business modeling and analysis, just follow your interests.&lt;br /&gt;&lt;br /&gt;3) This is very important...what are my time constraints? How much research time (fool around time) can i afford? 1 month? 1 year?? Just keep an approx time frame in your mind before you proceed any further.&lt;br /&gt;&lt;br /&gt;4) Research type falls under three major categories (lol, i just made that up)&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Listing industrial/personal experience with something.&lt;/li&gt;&lt;li&gt;Survey of existing techniques/models/methods or whatever.&lt;/li&gt;&lt;li&gt;Augmenting/extending/improving existing stuff.&lt;/li&gt;&lt;li&gt;Coming up with something new in a particular area.&lt;/li&gt;&lt;li&gt;Coming up with something so dramatic, that it gives rise to a new field of study (like &lt;a href="http://en.wikipedia.org/wiki/Human-based_computation"&gt;human computation&lt;/a&gt; or &lt;a href="http://en.wikipedia.org/wiki/Institute_of_Noetic_Sciences"&gt;neotic sciences&lt;/a&gt;)&lt;/li&gt;&lt;/ul&gt;Did i say three categories? That's because you wouldn't be reading this post if you are researching 4th or 5th category. So for all purposes of the study (i know, it sounds L.A.M.E.), lets just focus on the first three categories. Also, the categories are arranged in the increasing order of difficulty (usually, not always the case).&lt;br /&gt;&lt;br /&gt;5) Its now the time to narrow down your domain further. Business analysis and modeling is a very large area. It will certainly consist of many sub-parts, explore each one of those sub-parts.&lt;br /&gt;&lt;ul&gt;&lt;li&gt;If you are attempting a research paper of category 1, then all you have to do is formalize your experience on a paper. It might seem lame to you, but it will make sense to many others.&lt;/li&gt;&lt;li&gt;If you wanna survey, be sure to choose a sub topic that's very extensive, i.e., has too many models/techniques each with their own advantages and disadvantages. &lt;/li&gt;&lt;li&gt;For the third category, your immediate goal should be to determine possible research areas/problems.&lt;/li&gt;&lt;/ul&gt;Based on these factors, choose a suitable sub-part. If its not in compliance with your time frame, repeat step 5 or jump back to step 2. ( I know, i know, its like a bloody pseudo code)&lt;br /&gt;&lt;br /&gt;6)For either of these categories, you gotta do some literature study. Try to get one of those survey papers that has a comprehensive analysis of all or most popularly available methods. You could google something like "sub-part survey ieee", "sub-part survey papers" or "sub-part research areas", "sub-part research problems". This should give you a head start. Also, do save the pdf copies as they will be used later on for references.&lt;br /&gt;&lt;br /&gt;From this point on i am just gonna discuss about 3rd category of research. Maybe i'll write about the first two categories later on...Here goes, make a list of all the positive and negative counterparts of each method. All you have to do is come up with one, that has all the strength's and none of the weakness (easier said than done). Ok, if not none of the weaknesses part, try to get all the positive attributes together in your method/model.&lt;br /&gt;&lt;br /&gt;By the end of these six steps, you should have come up with a problem worth investigating. Believe it or not, deciding upon a good problem is effectively 30% of the research (at least, according to me).&lt;br /&gt;&lt;br /&gt;Now the next step is to find a solution to your problem and then write your paper. Both these tasks are very daunting and i am feeling very sleepy right now. I will write about these in my next post. Hope you find this article useful.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="color: rgb(51, 153, 153);"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5025713936013210120-4885528499427103466?l=ragha-justme.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ragha-justme.blogspot.com/feeds/4885528499427103466/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ragha-justme.blogspot.com/2009/10/my-research-methodology-formalized.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5025713936013210120/posts/default/4885528499427103466'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5025713936013210120/posts/default/4885528499427103466'/><link rel='alternate' type='text/html' href='http://ragha-justme.blogspot.com/2009/10/my-research-methodology-formalized.html' title='My research methodology, formalized :)'/><author><name>Ragha</name><uri>http://www.blogger.com/profile/09182969744128777413</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5025713936013210120.post-4977387934596734870</id><published>2009-10-12T09:47:00.000-07:00</published><updated>2011-05-16T12:44:49.269-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Computer security'/><title type='text'>Can share algorithm</title><content type='html'>Show that there is an algorithm of complexity O(|V| + |E|) that tests the predicate can•share, where V is the set of vertices and E the set of edges, in G0. Prove this by showing one such algorithm. &lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;This question is from the book: &lt;a href="http://books.google.com/books?id=WvO00VprsmMC&amp;amp;dq=computer+security+art+and+science+matt+bishop&amp;amp;printsec=frontcover&amp;amp;source=bn&amp;amp;hl=en&amp;amp;ei=FCBGTMeMOJGonQe8pMHxAw&amp;amp;sa=X&amp;amp;oi=book_result&amp;amp;ct=result&amp;amp;resnum=4&amp;amp;ved=0CCYQ6AEwAw#v=onepage&amp;amp;q&amp;amp;f=false"&gt;Computer Security: Art and Science by Matt Bishop&lt;/a&gt;. I Found this question quite interesting (especially the algorithm part), hence the post.&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;hr /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;According to theorem 3-10, The predicate can•share(a, x, y, G0) is true if and only if there is an edge from x to y in G0 labeled a, or if the following hold simultaneously:&lt;/div&gt;&lt;br /&gt;a.       There is a vertex s in G0 with an s-to-y edge labeled a.&lt;br /&gt;b.      There exists a subject vertex x' such that x' = x or x' initially spans to x.&lt;br /&gt;c.       There exists a subject vertex s' such that s' = s or s' terminally spans to s&lt;br /&gt;d.      There exist islands I1, …, In such that x' belongs to I1, s' belongs to In, and there is a bridge from Ij to Ij+1&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: large;"&gt;&lt;span class="Apple-style-span"  style="color:#CCFFFF;"&gt;Algorithm:&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span"  style="color:#FFFF99;"&gt;(Abstraction level 1)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The idea for the algorithm is as follows:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;If node x or y does not exist, return false.&lt;/li&gt;&lt;li&gt;If there is an edge ‘a’ from x to y, return true.&lt;/li&gt;&lt;li&gt;Check conditions a, b, c, d of theorem 3-10, if they hold simultaneously, return true else return false.&lt;/li&gt;&lt;/ol&gt;&lt;br /&gt;&lt;span class="Apple-style-span"  style="color:#FFFF99;"&gt;(Abstraction level 2)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Step 3 from above can be elaborated as follows:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Start from node x.&lt;/li&gt;&lt;li&gt;Try to find x' satisfying condition B of theorem 3-10. If no, return false. If yes, for every such x', loop step 3.&lt;/li&gt;&lt;li&gt;Try to find s' satisfying condition D of theorem 3-10. (We don’t return false here as there might be some other x' for which step 3 might be true, so we check exhaustively; i.e., since we are in a loop right now). If yes, for every such s', loop step 4.&lt;/li&gt;&lt;li&gt;Try to find s satisfying condition C of theorem 3-10. If yes, for every such s, loop step 5.&lt;/li&gt;&lt;li&gt;If there is an edge ‘a’ from s to y, return true. (Checking condition A of theorem 3-10)&lt;/li&gt;&lt;li&gt;Return false (If it reached this step, it means that step 5 failed to return true)&lt;/li&gt;&lt;/ol&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The above sequence of actions can be represented as:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Start from node x.&lt;/li&gt;&lt;li&gt;Algorithm Step2(x)&lt;/li&gt;&lt;li&gt;Algorithm Step3(x')&lt;/li&gt;&lt;li&gt;Algorithm Step4(s')&lt;/li&gt;&lt;li&gt;If there is an edge ‘a’ from s to y, return true. (Checking condition A of theorem 3-10)&lt;/li&gt;&lt;li&gt;Return false (If it reached this step, it means that step 5 failed to return true)&lt;/li&gt;&lt;/ol&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;span class="Apple-style-span"  style="color:#FFFF99;"&gt;(Abstraction level 3)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span"  style="color:#CCFFFF;"&gt;Algorithm Step2(X)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The graph data structure is such that every node has an associated data ‘visited’, which is Boolean in nature. This data is used so that the node is not re-analyzed again. We need to find all x', such that, x' is a subject and x' has a T*G path to x. Two intermediate algorithms used within this algorithm, they are:&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span"  style="color:#CCFFFF;"&gt;Algo1(X) (Finds the neighborhood node of X such that it has a grant right over X)&lt;/span&gt;&lt;br /&gt;&lt;ol&gt;&lt;li&gt;For each neighboring vertex V of X such that V-&gt;visited = false (for loop), execute steps 2, 3&lt;/li&gt;&lt;li&gt;Make V-&gt;visited = true&lt;/li&gt;&lt;li&gt;If( V -&gt; X has a grant), call Algo2(V)&lt;/li&gt;&lt;/ol&gt;&lt;br /&gt;&lt;span class="Apple-style-span"  style="color:#CCFFFF;"&gt;Algo2(V) (Recursively checks for T* paths and calls step3 whenever appropriate)&lt;/span&gt;&lt;br /&gt;&lt;ol&gt;&lt;li&gt;For each neighboring vertex x' of V, if x' -&gt; V has a Take right and x' -&gt; visited = false. Execute steps 2, 3, 5&lt;/li&gt;&lt;li&gt;x' -&gt; visited = true&lt;/li&gt;&lt;li&gt;If x' is a subject vertex, execute step 4&lt;/li&gt;&lt;li&gt;Call algorithm Step3(x')&lt;/li&gt;&lt;li&gt;Call algorithm Algo2(x') (This call gives us the desired effect to check T* paths)&lt;/li&gt;&lt;/ol&gt;&lt;br /&gt;&lt;span class="Apple-style-span"  style="color:#CCFFFF;"&gt;The Step2(X) algorithm is defined as:&lt;/span&gt;&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Call algorithm Algo1(X)&lt;/li&gt;&lt;/ol&gt;&lt;br /&gt;&lt;span class="Apple-style-span"  style="color:#CCFFFF;"&gt;Algorithm Step3(X')&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;//Check for paths satisfying T* -&gt;, T* &lt;-, T* -&gt; G &lt;- T* &lt;-, T* -&gt; G -&gt; T* &lt;-   Algo3(X') (Checks for T* &lt;- paths) &lt;/div&gt;&lt;div&gt;&lt;ol&gt;&lt;li&gt;For each neighboring vertex n of x', if n &lt;- x' has a Take right and n -&gt; visited = false. Execute steps 2, 3, 5&lt;/li&gt;&lt;li&gt;n -&gt; visited = true&lt;/li&gt;&lt;li&gt;If n is a subject vertex, execute step 4&lt;/li&gt;&lt;li&gt;Call algorithm Step4(n)&lt;/li&gt;&lt;li&gt;Call algorithm Algo3(x') (This call gives us the desired effect to check T* paths)&lt;/li&gt;&lt;/ol&gt;&lt;br /&gt;&lt;span class="Apple-style-span"  style="color:#CCFFFF;"&gt;Algo4(X') (Handles remaining cases)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;For each neighboring vertex n of x', if n &lt;- x' has a Take right and n -&gt; visited = false. Execute steps 2, 3, 8&lt;br /&gt;&lt;ol&gt;&lt;li&gt;n -&gt; visited = true&lt;/li&gt;&lt;li&gt;If n is a subject vertex, execute block 4, 5, 6, 7&lt;/li&gt;&lt;li&gt;Call algorithm Step4(n)&lt;/li&gt;&lt;li&gt;For each neighboring vertex n' of n, if n' -&gt; n or n' &lt;- n has a Grant right and n' -&gt; visited = false. Execute step 6, 7&lt;/li&gt;&lt;li&gt;n' -&gt; visited = true&lt;/li&gt;&lt;li&gt;Call Algo3(n') (Tries to terminate with subject vertex having T* -&gt;)&lt;/li&gt;&lt;li&gt;Call algorithm Algo4(x') (Handles recursive paths with similar signature)&lt;/li&gt;&lt;/ol&gt;&lt;br /&gt;&lt;span class="Apple-style-span"  style="color:#CCFFFF;"&gt;The Step3(X') algorithm is defined as:&lt;/span&gt;&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Call algorithm Algo3(X')&lt;/li&gt;&lt;li&gt;Call algorithm Algo4(X')&lt;/li&gt;&lt;/ol&gt;&lt;br /&gt;&lt;span class="Apple-style-span"  style="color:#CCFFFF;"&gt;Algorithm Step4(S)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;//Try to find s' such that s' -&gt; s has T* path.&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Call algorithm Algo2(S) used in Step2, modify step 3 of Algo2 as ‘Call Step 5’&lt;/li&gt;&lt;/ol&gt;&lt;div&gt;&lt;br /&gt;&lt;hr /&gt;&lt;br /&gt;&lt;/div&gt;&lt;span class="Apple-style-span"  style="color:#FFFF99;"&gt;&lt;span class="Apple-style-span"  style="font-size:large;"&gt;Complexity Analysis:&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;From abstraction level 1, we conclude that the running time of the algorithm is the running time of step 3 as steps 1, 2 take O(1) time (Since only a lookup operation needs to be performed in the adjacency matrix)&lt;br /&gt;&lt;br /&gt;From abstraction level 2, we conclude that the complexity is determined by the sequence of actions in steps 2, 3, 4, 5.&lt;br /&gt;&lt;br /&gt;By observing steps 2, 3, 4, 5; in the worst case, all the edges and the vertices of the graph will be explored. (This will happen when all nodes connected to node n initially spans to it, making step 2 call step 3. Similarly, step 3, 4, 5 may explore all nodes before step 6 is reached).&lt;br /&gt;&lt;br /&gt;Therefore, worst case running time for the algorithm is O(|V| + |E|)&lt;br /&gt;The best case running time is O(1) (If the algorithm concludes with step 1 or 2 in abstraction level 1)&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5025713936013210120-4977387934596734870?l=ragha-justme.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ragha-justme.blogspot.com/feeds/4977387934596734870/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ragha-justme.blogspot.com/2009/10/can-share-algorithm.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5025713936013210120/posts/default/4977387934596734870'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5025713936013210120/posts/default/4977387934596734870'/><link rel='alternate' type='text/html' href='http://ragha-justme.blogspot.com/2009/10/can-share-algorithm.html' title='Can share algorithm'/><author><name>Ragha</name><uri>http://www.blogger.com/profile/09182969744128777413</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5025713936013210120.post-314896464097798247</id><published>2009-08-06T20:02:00.000-07:00</published><updated>2009-08-06T20:58:29.144-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='useful'/><title type='text'>When headache truly becomes a headache...</title><content type='html'>I had one of the worst possible night's yesterday. I had a bad headache, was tired but couldn't sleep :(&lt;br /&gt;&lt;br /&gt;After my excruciating experience i decided to blog on simple home therapies to relieve headaches. You can try one of the following:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Tie a cloth around your head, switch off the damn fan or AC. Take a sharp object, like a pen and poke it slightly on your upper left thumb.&lt;/li&gt;&lt;li&gt;Headache's can also occur because of high BP. It is typically characterized by neck pains, breathing spasms and heart throbbing sensations. Try garlic, watermelons or lemon + honey combo if that appears to be your case.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Put a hot water dripped cloth around your neck.&lt;/li&gt;&lt;li&gt;Avoid light and sound.&lt;/li&gt;&lt;li&gt;Start imagining and try making up some scenarios in your head to keep you distracted.&lt;br /&gt;&lt;/li&gt;&lt;/ol&gt;In case you are suffering from migraines, i suggest you read this &lt;a href="http://www.migraineassistant.com/"&gt;post&lt;/a&gt;. If none of the above works for you, go visit a doctor.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5025713936013210120-314896464097798247?l=ragha-justme.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ragha-justme.blogspot.com/feeds/314896464097798247/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ragha-justme.blogspot.com/2009/08/when-headache-truly-becomes-headache.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5025713936013210120/posts/default/314896464097798247'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5025713936013210120/posts/default/314896464097798247'/><link rel='alternate' type='text/html' href='http://ragha-justme.blogspot.com/2009/08/when-headache-truly-becomes-headache.html' title='When headache truly becomes a headache...'/><author><name>Ragha</name><uri>http://www.blogger.com/profile/09182969744128777413</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5025713936013210120.post-5434744031755957161</id><published>2009-06-28T00:27:00.000-07:00</published><updated>2009-06-28T00:28:38.304-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='lol series'/><title type='text'>Weather Prediction</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_7xvr19hYuG4/SkcbmtcJqxI/AAAAAAAAACU/ot0GGSW1dU0/s1600-h/untitled.JPG"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 254px; height: 332px;" src="http://1.bp.blogspot.com/_7xvr19hYuG4/SkcbmtcJqxI/AAAAAAAAACU/ot0GGSW1dU0/s400/untitled.JPG" alt="" id="BLOGGER_PHOTO_ID_5352277033999772434" border="0" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5025713936013210120-5434744031755957161?l=ragha-justme.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ragha-justme.blogspot.com/feeds/5434744031755957161/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ragha-justme.blogspot.com/2009/06/weather-prediction.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5025713936013210120/posts/default/5434744031755957161'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5025713936013210120/posts/default/5434744031755957161'/><link rel='alternate' type='text/html' href='http://ragha-justme.blogspot.com/2009/06/weather-prediction.html' title='Weather Prediction'/><author><name>Ragha</name><uri>http://www.blogger.com/profile/09182969744128777413</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_7xvr19hYuG4/SkcbmtcJqxI/AAAAAAAAACU/ot0GGSW1dU0/s72-c/untitled.JPG' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5025713936013210120.post-3913145366919247889</id><published>2009-06-14T23:33:00.000-07:00</published><updated>2009-06-14T23:39:35.069-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='lol series'/><title type='text'>Lol question series 1</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_7xvr19hYuG4/SjXsNY4CmUI/AAAAAAAAACM/C1JIxqLgwFM/s1600-h/q1.gif"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 146px; height: 400px;" src="http://3.bp.blogspot.com/_7xvr19hYuG4/SjXsNY4CmUI/AAAAAAAAACM/C1JIxqLgwFM/s400/q1.gif" alt="" id="BLOGGER_PHOTO_ID_5347439847332288834" border="0" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5025713936013210120-3913145366919247889?l=ragha-justme.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ragha-justme.blogspot.com/feeds/3913145366919247889/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ragha-justme.blogspot.com/2009/06/lol-question-series-1.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5025713936013210120/posts/default/3913145366919247889'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5025713936013210120/posts/default/3913145366919247889'/><link rel='alternate' type='text/html' href='http://ragha-justme.blogspot.com/2009/06/lol-question-series-1.html' title='Lol question series 1'/><author><name>Ragha</name><uri>http://www.blogger.com/profile/09182969744128777413</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_7xvr19hYuG4/SjXsNY4CmUI/AAAAAAAAACM/C1JIxqLgwFM/s72-c/q1.gif' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5025713936013210120.post-2289096676713250241</id><published>2009-06-13T21:24:00.000-07:00</published><updated>2011-05-16T12:44:49.269-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='java'/><category scheme='http://www.blogger.com/atom/ns#' term='netbeans platform'/><title type='text'>LookupListener problem?</title><content type='html'>There are many unanswered threads to this question. The common issue is that the resultChanged(...) method is never triggered!! Here is a proper use-case scenario (note the comments, they provide tips to avoid common loopholes)&lt;br /&gt;&lt;pre class="brush: java"&gt;public SomeClass extends LookupListener&lt;br /&gt;{&lt;br /&gt;  //It is important that you hold a reference to Lookup.Result&lt;br /&gt;  //so that it doesn't get garbage collected. This also applies to Lookup.Template&lt;br /&gt;  private Lookup.Result result = lookup.getDefault().lookupResult(MyInterface.class);&lt;br /&gt;&lt;br /&gt;  public SomeClass()&lt;br /&gt;  {&lt;br /&gt;      result.addLookupListener(this);&lt;br /&gt;   &lt;br /&gt;      //It is important to call this method once...otherwise           &lt;br /&gt;      //resultChanged(...) method is never triggered!!&lt;br /&gt;      resultchanged(new LookupEvent(result));&lt;br /&gt;  } &lt;br /&gt;&lt;br /&gt;  public void resultChanged(LookupEvent ev)&lt;br /&gt;  {&lt;br /&gt;      //do your stuff here...&lt;br /&gt;  }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;If you still have problems, then check the META-INF/services folder of your implementation, there is probably a typo in the flat file. Its better to use &lt;a href="http://wiki.netbeans.org/DeclarativeRegistrationUsingAnnotations"&gt;@Service&lt;/a&gt; annotation to avoid such mistakes.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5025713936013210120-2289096676713250241?l=ragha-justme.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ragha-justme.blogspot.com/feeds/2289096676713250241/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ragha-justme.blogspot.com/2009/06/lookuplistener-problem.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5025713936013210120/posts/default/2289096676713250241'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5025713936013210120/posts/default/2289096676713250241'/><link rel='alternate' type='text/html' href='http://ragha-justme.blogspot.com/2009/06/lookuplistener-problem.html' title='LookupListener problem?'/><author><name>Ragha</name><uri>http://www.blogger.com/profile/09182969744128777413</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5025713936013210120.post-5247279347288743067</id><published>2009-06-13T20:42:00.000-07:00</published><updated>2011-05-16T12:44:49.269-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='java'/><category scheme='http://www.blogger.com/atom/ns#' term='netbeans platform'/><title type='text'>Plugin manager for standalone swing apps</title><content type='html'>Lookup API provides more features than the typical &lt;a href="http://java.sun.com/javase/6/docs/api/java/util/ServiceLoader.html"&gt;ServiceLoader&lt;/a&gt; mechanism introduced in JDK 6. It allows you to listen to changes using &lt;a href="http://bits.netbeans.org/dev/javadoc/org-openide-util/org/openide/util/LookupListener.html"&gt;LookupListener&lt;/a&gt;. If your not aware of Lookup API, please read about it &lt;a href="http://wiki.netbeans.org/DevFaqLookup"&gt;here&lt;/a&gt; before continuing any further. For a more comprehensive tutorial on the subject, check out this &lt;a href="http://netbeans.dzone.com/news/top-10-netbeans-apis-part-2"&gt;screencast&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Lookup API provides amazing decoupling capabilities to your application, even in standalone and non visual applications. The problem comes when you have to install or remove modules from your applications (implementations of an interface). In Netbeans platform the plugin manager would automatically do this for you. To utilize the benefits of LookupListener, one has to add the module jar files to the classpath (at run time).&lt;br /&gt;&lt;br /&gt;This however cannot be achieved directly, here's a reflection hack to get it done:&lt;br /&gt;&lt;pre class="brush: java"&gt;/**&lt;br /&gt;* Rescans the given folder and adds all the Jar files (plugins)&lt;br /&gt;* to class path...simply ignores if a jar file is already added...&lt;br /&gt;*&lt;br /&gt;* @param path The folder containing plugins...&lt;br /&gt;* @throws java.io.IOException&lt;br /&gt;*/&lt;br /&gt;public void rescan(String path) throws IOException&lt;br /&gt;{&lt;br /&gt;File pluginFolder = new File(path);&lt;br /&gt;File plugins[] = pluginFolder.listFiles(new FileFilter()&lt;br /&gt;{&lt;br /&gt;   public boolean accept(File pathname)&lt;br /&gt;   {&lt;br /&gt;       if(pathname.getPath().endsWith(".jar"))&lt;br /&gt;           return true;&lt;br /&gt;       else&lt;br /&gt;           return false;&lt;br /&gt;   }&lt;br /&gt;});&lt;br /&gt;&lt;br /&gt;for(File f : plugins)&lt;br /&gt;{   &lt;br /&gt;   addPlugin(f.toURI().toURL());&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;/**&lt;br /&gt;* The url (preferably jar) to be added to the classpath.&lt;br /&gt;* This is like an install plugin thingy...&lt;br /&gt;* Must be used in place of {@link #rescan(java.lang.String) rescan} method&lt;br /&gt;* if a single new plugin is to be installed...gives good performance ups&lt;br /&gt;*&lt;br /&gt;* @param url The url to be added to classpath&lt;br /&gt;*/&lt;br /&gt;public void addPlugin(URL url) throws IOException&lt;br /&gt;{&lt;br /&gt;addURLToClassPath(url);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;/**&lt;br /&gt;* To avoid un-necessary object creation on method calls...&lt;br /&gt;*/&lt;br /&gt;private static final Class[] parameters = new Class[]{URL.class};&lt;br /&gt;/**&lt;br /&gt;* Adds a URL, preferably a JAR file to classpath. If URL already exists,&lt;br /&gt;* then this method simply returns...&lt;br /&gt;*&lt;br /&gt;* @param u The URL t be added to classpath&lt;br /&gt;* @throws java.io.IOException&lt;br /&gt;*/&lt;br /&gt;private void addURLToClassPath(URL u) throws IOException&lt;br /&gt;{&lt;br /&gt;URLClassLoader sysloader = URLClassLoader)ClassLoader.getSystemClassLoader();&lt;br /&gt;&lt;br /&gt;boolean isAdded = false;&lt;br /&gt;for(URL url : sysloader.getURLs())&lt;br /&gt;{&lt;br /&gt;  if(url.equals(u))&lt;br /&gt;      isAdded = true;&lt;br /&gt;}&lt;br /&gt;if(isAdded)&lt;br /&gt;  return;&lt;br /&gt;&lt;br /&gt;Class sysclass = URLClassLoader.class;&lt;br /&gt;try&lt;br /&gt;{&lt;br /&gt;  Method method = sysclass.getDeclaredMethod("addURL",parameters);&lt;br /&gt;  method.setAccessible(true);&lt;br /&gt;  method.invoke(sysloader, new Object[]{ u });&lt;br /&gt;}&lt;br /&gt;catch (Throwable t)&lt;br /&gt;{&lt;br /&gt;  t.printStackTrace();&lt;br /&gt;  throw new IOException("Error, could not add URL to system classloader");&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;In the above code we are adding a URL (typically pointing to a jar file) to the system classloader by invoking its private method via reflection.&lt;br /&gt;&lt;br /&gt;In your plugin manager...all you have to do is paste the jar file to a certain folder (say user.dir/plugins), then execute the following code to add jars to classpath:&lt;br /&gt;&lt;pre class="brush: java"&gt;&lt;br /&gt;/**&lt;br /&gt;* Rescans the given folder and adds all the Jar files (plugins)&lt;br /&gt;* to class path...simply ignores if a jar file is already added...&lt;br /&gt;*&lt;br /&gt;* @param path The folder containing plugins...&lt;br /&gt;* @throws java.io.IOException&lt;br /&gt;*/&lt;br /&gt;public void rescan(String path) throws IOException&lt;br /&gt;{&lt;br /&gt;File pluginFolder = new File(path);&lt;br /&gt;File plugins[] = pluginFolder.listFiles(new FileFilter()&lt;br /&gt;{&lt;br /&gt;   public boolean accept(File pathname)&lt;br /&gt;   {&lt;br /&gt;       if(pathname.getPath().endsWith(".jar"))&lt;br /&gt;           return true;&lt;br /&gt;       else&lt;br /&gt;           return false;&lt;br /&gt;   }&lt;br /&gt;});&lt;br /&gt;&lt;br /&gt;for(File f : plugins)&lt;br /&gt;{  &lt;br /&gt;   addPlugin(f.toURI().toURL());&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;/**&lt;br /&gt;* The url (preferably jar) to be added to the classpath.&lt;br /&gt;* This is like an install plugin thingy...&lt;br /&gt;* Must be used in place of {@link #rescan(java.lang.String) rescan} method&lt;br /&gt;* if a single new plugin is to be installed...gives good performance ups&lt;br /&gt;*&lt;br /&gt;* @param url The url to be added to classpath&lt;br /&gt;*/&lt;br /&gt;public void addPlugin(URL url) throws IOException&lt;br /&gt;{&lt;br /&gt;addURLToClassPath(url);&lt;br /&gt;}&lt;/pre&gt;That's it! the newly registered service providers can be caught in resultChanged(...) method of the LookupListener. Similarly you can remove items from the classpath to deactivate the plugins from your application, i'll leave that as your home work assignment :)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5025713936013210120-5247279347288743067?l=ragha-justme.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ragha-justme.blogspot.com/feeds/5247279347288743067/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ragha-justme.blogspot.com/2009/06/plugin-manager-for-standalone-swing.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5025713936013210120/posts/default/5247279347288743067'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5025713936013210120/posts/default/5247279347288743067'/><link rel='alternate' type='text/html' href='http://ragha-justme.blogspot.com/2009/06/plugin-manager-for-standalone-swing.html' title='Plugin manager for standalone swing apps'/><author><name>Ragha</name><uri>http://www.blogger.com/profile/09182969744128777413</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5025713936013210120.post-6754774642682122764</id><published>2009-06-10T08:10:00.000-07:00</published><updated>2011-05-16T12:44:49.270-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='java'/><category scheme='http://www.blogger.com/atom/ns#' term='netbeans platform'/><title type='text'>lookup third party service impl of an interface</title><content type='html'>If you have a jar file containing implementations of an interface that you want to be discovered by lookup...here's what you do:&lt;br /&gt;&lt;br /&gt;1) Use library wrapper wizard in Netbeans to create a jar module wrapper.&lt;br /&gt;2) Create a folder META-INF/services in the wrapper module.&lt;br /&gt;3) Create a file in META-INF/services named after the fully qualified name of the interface  containing the fully qualified names of the implementations (one per line)&lt;br /&gt;&lt;br /&gt;That's it!&lt;br /&gt;Third party service implementations to now be discovered by the global lookup on startup.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5025713936013210120-6754774642682122764?l=ragha-justme.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ragha-justme.blogspot.com/feeds/6754774642682122764/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ragha-justme.blogspot.com/2009/06/lookup-third-party-service-impl-of.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5025713936013210120/posts/default/6754774642682122764'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5025713936013210120/posts/default/6754774642682122764'/><link rel='alternate' type='text/html' href='http://ragha-justme.blogspot.com/2009/06/lookup-third-party-service-impl-of.html' title='lookup third party service impl of an interface'/><author><name>Ragha</name><uri>http://www.blogger.com/profile/09182969744128777413</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5025713936013210120.post-2264730986619405970</id><published>2009-06-06T23:13:00.000-07:00</published><updated>2011-05-16T12:44:49.270-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='java'/><title type='text'>Unnecessary object creation...</title><content type='html'>Most of you might already know about this. I just found this out while working on my open source project &lt;a href="https://jneuralnet.dev.java.net/"&gt;JNeuralNet&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;I had this situation:&lt;br /&gt; &lt;br /&gt;&lt;pre class="brush: java"&gt;&lt;br /&gt;loop&lt;br /&gt;{&lt;br /&gt; Double d = someclass.compute();&lt;br /&gt;}&lt;/pre&gt;When i ran the profiler. I noticed that the major portion of CPU was going into Double object creation. That's when i realized that its the classloader overload everytime the object is being created..so this is what i did:&lt;br /&gt;&lt;pre class="brush: java"&gt;&lt;br /&gt;//init variable...&lt;br /&gt;Double d = 0.0;&lt;br /&gt;loop&lt;br /&gt;{&lt;br /&gt;  d = someclass.compute();&lt;br /&gt;}&lt;/pre&gt;This simple optimization reduced a lot of CPU overload! Also if u have situations such as:&lt;br /&gt;&lt;pre class="brush: java"&gt;&lt;br /&gt;loop&lt;br /&gt;{&lt;br /&gt;  Obj o = new Obj();&lt;br /&gt;}&lt;/pre&gt;If feasible...try using:&lt;br /&gt;&lt;pre class="brush: java"&gt;&lt;br /&gt;Obj o = new Obj();&lt;br /&gt;loop&lt;br /&gt;{&lt;br /&gt;  //use o...&lt;br /&gt;  o.set(abc);&lt;br /&gt;}&lt;/pre&gt;This approach is not always feasible...especially if you intend to use the reference of the object elsewhere, my point is, to reduce object creation wherever feasible.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5025713936013210120-2264730986619405970?l=ragha-justme.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ragha-justme.blogspot.com/feeds/2264730986619405970/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ragha-justme.blogspot.com/2009/06/unnecessary-object-creation.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5025713936013210120/posts/default/2264730986619405970'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5025713936013210120/posts/default/2264730986619405970'/><link rel='alternate' type='text/html' href='http://ragha-justme.blogspot.com/2009/06/unnecessary-object-creation.html' title='Unnecessary object creation...'/><author><name>Ragha</name><uri>http://www.blogger.com/profile/09182969744128777413</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5025713936013210120.post-4751550428379218533</id><published>2009-06-05T07:34:00.000-07:00</published><updated>2009-06-14T23:41:18.721-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='whacky'/><title type='text'>My theory on time travel...</title><content type='html'>Already tortured people by giving this presentation back in my 8th semester...here goes:&lt;br /&gt;&lt;br /&gt;I have two solid conclusions:&lt;br /&gt;1) Its possible to view past.&lt;br /&gt;2) Not possible to travel back in past or is a very bad idea!&lt;br /&gt;&lt;br /&gt;1st assumption is an easy one to crack...you see this phenomenon every day (every night actually). Just look up at the sky...see the stars. What u actually see is the past. That star might have died by now...since it is 100's of light years away...what you're actually seeing is 100 light years backward.&lt;br /&gt;&lt;br /&gt;As for the 2nd assumption...lets start with the hypothesis that it is possible to travel to past. Now imagine that you do something to trigger the death of your past self...It means that you never took the path that led you to travel back to the past, a direct contradiction.&lt;br /&gt;&lt;br /&gt;so let us now suppose that its not possible to kill your past self. It might mean that your consciousness might merge with the past self and u forget everything about the future u came from...meaning that in future u again do the same time travel thingy., come back to past. Dude, you're now stuck in an indefinite loop.&lt;br /&gt;&lt;br /&gt;Third option, according to string theory, every universe represents a possibility. suppose u travel in past and do something different it means that you have shifted the future timeline to a new parallel universe...meaning that u effectively destroyed the current universe and connected the future events to another one...destruction of a universe...certainly sounds like a bad idea!&lt;br /&gt;&lt;br /&gt;Crazy comments are most welcome!!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5025713936013210120-4751550428379218533?l=ragha-justme.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ragha-justme.blogspot.com/feeds/4751550428379218533/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ragha-justme.blogspot.com/2009/06/my-theory-on-time-travel.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5025713936013210120/posts/default/4751550428379218533'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5025713936013210120/posts/default/4751550428379218533'/><link rel='alternate' type='text/html' href='http://ragha-justme.blogspot.com/2009/06/my-theory-on-time-travel.html' title='My theory on time travel...'/><author><name>Ragha</name><uri>http://www.blogger.com/profile/09182969744128777413</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5025713936013210120.post-1241836265017787605</id><published>2009-06-05T06:35:00.000-07:00</published><updated>2009-06-14T23:41:31.040-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='whacky'/><title type='text'>My theory of good and bad</title><content type='html'>Pardon me for the language folks, but i think good and bad is BULL CRAP! Here's what i believe...&lt;br /&gt;&lt;br /&gt;Some clever saint/person must have thought of this idea to keep things in control...so that the world doesn't go chaotic.&lt;br /&gt;&lt;br /&gt;Just think of this for a moment...U say that a good thing is good because if gives u the internal satisfaction or whatever. You know what i think...i feel its because of the society/environment you're brought up in. Imagine a society where they'd preach that hurting some one is a good thing. In that case, hurting someone may give u that internal satisfaction...just like the way animals kill each other...no moral code whatsoever.&lt;br /&gt;&lt;br /&gt;So in conclusion...there is no good and bad. Its human invented! Don't get the wrong idea, im not telling u to become bad or something. Its just my option...thought it was interesting and shared it!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5025713936013210120-1241836265017787605?l=ragha-justme.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ragha-justme.blogspot.com/feeds/1241836265017787605/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ragha-justme.blogspot.com/2009/06/my-theory-of-good-and-bad.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5025713936013210120/posts/default/1241836265017787605'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5025713936013210120/posts/default/1241836265017787605'/><link rel='alternate' type='text/html' href='http://ragha-justme.blogspot.com/2009/06/my-theory-of-good-and-bad.html' title='My theory of good and bad'/><author><name>Ragha</name><uri>http://www.blogger.com/profile/09182969744128777413</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5025713936013210120.post-7260032290337172335</id><published>2009-06-05T06:31:00.001-07:00</published><updated>2009-06-14T23:41:41.175-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='whacky'/><title type='text'>Give...dont expect things back!</title><content type='html'>Expectation is your worst enemy. Always help...if possible go out of the way to help others. I believe in karma and have a belief that whatever u do comes back to you. Please don't expect things in return...I have seem many people getting hurt because of this. Just take the happiness as a return gift for the moment. In the worst of times, the favor will return by itself!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5025713936013210120-7260032290337172335?l=ragha-justme.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ragha-justme.blogspot.com/feeds/7260032290337172335/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ragha-justme.blogspot.com/2009/06/givedont-expect-things-back.html#comment-form' title='5 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5025713936013210120/posts/default/7260032290337172335'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5025713936013210120/posts/default/7260032290337172335'/><link rel='alternate' type='text/html' href='http://ragha-justme.blogspot.com/2009/06/givedont-expect-things-back.html' title='Give...dont expect things back!'/><author><name>Ragha</name><uri>http://www.blogger.com/profile/09182969744128777413</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>5</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5025713936013210120.post-930984127383185080</id><published>2009-06-05T06:24:00.000-07:00</published><updated>2009-06-14T23:41:49.416-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='whacky'/><title type='text'>Afterall they're humans too!</title><content type='html'>Were there times when u get scared of your boss, faculty, giving presentations? Just remember this one thing, bottom line they're also humans...just like us. They have also made mistakes and must have been nervous at some point.&lt;br /&gt;&lt;br /&gt;Just imagine yourself in their position. Would have just laughed it off wouldn't you? So just tell them whatever it is that you're so hesitant about. Want a pay raise...wouldn't agree with their ideas, SPEAK OUT! At the most what will happen? You may get fired or ridiculed at...but will always be happy that you did the RIGHT THING!...In the end its the satisfaction that matters.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5025713936013210120-930984127383185080?l=ragha-justme.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ragha-justme.blogspot.com/feeds/930984127383185080/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ragha-justme.blogspot.com/2009/06/afterall-theyre-humans-too.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5025713936013210120/posts/default/930984127383185080'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5025713936013210120/posts/default/930984127383185080'/><link rel='alternate' type='text/html' href='http://ragha-justme.blogspot.com/2009/06/afterall-theyre-humans-too.html' title='Afterall they&apos;re humans too!'/><author><name>Ragha</name><uri>http://www.blogger.com/profile/09182969744128777413</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5025713936013210120.post-5759213908019443976</id><published>2009-05-27T04:52:00.000-07:00</published><updated>2011-05-16T12:44:49.270-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='java'/><title type='text'>My ideal desktop recipe</title><content type='html'>&lt;div&gt;Don't know about others, but i sure am confused by the vast ocean of frameworks and libraries available out there to help aid in java desktop applications.&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;br /&gt;&lt;div&gt;This blog is not about frameworks and libraries that offer the best functionality and power, but those that do with a faster learning curve.&lt;br /&gt;&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;br /&gt;&lt;div&gt;Typically, these are the pain points you'll encounter (sooner or later) in a large desktop application.&lt;br /&gt;&lt;/div&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;Validation&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Binding Pojo's with GUI&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Database Management&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Cool and sleek GUI&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Code complexity&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Packaging and deployment&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Creating Trialware's &lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;p&gt;&lt;span style="font-size:130%;"&gt;&lt;span class="Apple-style-span"  style="color:#CCFFFF;"&gt;1) Validation&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;I never paid much attention initially, but validation is one aspect that tends to get laborious. There are popular validation frameworks out there to help you with it. But as a beginner you'll want to learn it quick and easy. I'd prefer the &lt;a href="http://kenai.com/projects/simplevalidation/pages/Home"&gt;Simple Validation Api&lt;/a&gt; by Tim Boudreau. Powerful and simple at the same time. Hardly takes 10 minutes to learn.&lt;/p&gt;&lt;p&gt; &lt;/p&gt;&lt;p&gt;&lt;span style="font-size:130%;"&gt;&lt;span class="Apple-style-span"  style="color:#CCFFFF;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-size:130%;"&gt;&lt;span class="Apple-style-span"  style="color:#CCFFFF;"&gt;2) Binding POJO's with GUI&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;In my opinion there is no good tool for data binding, its currently unstable and there's no out of the box support for it. Its usually more pain than gain. But if u insist i suggest that you use the &lt;a href="http://www.netbeans.org/"&gt;Netbeans IDE&lt;/a&gt;, it features mattise GUI builder with binding support. It'd be nice if JComponent binds POJO via annotations. In either case be on a look out, some one is probably developing it right now.&lt;/p&gt;&lt;p&gt; &lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;span style="font-size:130%;"&gt;&lt;span class="Apple-style-span"  style="color:#CCFFFF;"&gt;3) Database Management&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span&gt;&lt;/span&gt;Wouldn't it be nice if you didnt have to write all the plumbing code required to execute a database transaction and just concentrate on the task itself? ORM's typically sheild you from all the database junk. Hibernate will probably be the first result if u ever tried to google. It however has a lot of XML mapping stuff to be done.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;In my opinion, &lt;a href="https://activeobjects.dev.java.net/"&gt;ActiveObjects&lt;/a&gt; orm by Daniel Spiewak is the easiest to use, i.e., in case u dont have distributed databases to deal with. It conpletely sheilds you from database complexity. The only disadvantage is that u need to create POJO interfaces first to generate the database schema . If you already have a database then you must create the interfaces yourself (no generator tool for now). A great feature worth noting is that it has Database Migrations (useful for maintenance).&lt;/p&gt;&lt;p&gt; &lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;span style="font-size:130%;"&gt;&lt;span class="Apple-style-span"  style="color:#CCFFFF;"&gt;4) Cool and sleek GUI&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Get &lt;a href="https://substance.dev.java.net/"&gt;substance look and feel&lt;/a&gt; by Kirill Grouchnikov is an excellent option to spice up you UI. All you have to do is add one line of code. If you're on MAC OS consider &lt;a href="http://www.randelshofer.ch/quaqua/"&gt;Quaqua&lt;/a&gt; lnf. Also check out &lt;a href="https://swingx.dev.java.net/"&gt;SwingX&lt;/a&gt;, &lt;a href="https://flamingo.dev.java.net/"&gt;Flamingo&lt;/a&gt;, &lt;a href="http://www.l2fprod.com/common/"&gt;L2fProd&lt;/a&gt;, &lt;a href="http://www.jgoodies.com/"&gt;JGoodies&lt;/a&gt; for cool swing components. &lt;/p&gt;If you have time to spare and want some extreme GUI with cool animation effects consider using &lt;a href="https://animatedtransitions.dev.java.net/"&gt;Animated Transitions Api&lt;/a&gt; and &lt;a href="https://timingframework.dev.java.net/"&gt;Timing Framework&lt;/a&gt; by Romain Guy and Chet Haase. I also suggest that you read &lt;a href="http://filthyrichclients.org/"&gt;Filthy Rich clients&lt;/a&gt; by the same authors.&lt;br /&gt;&lt;p&gt;For a quickie, with almost no learning curve u should use substance look and feel with SwingX components along with mattise in NetbeansIDE.&lt;br /&gt;&lt;/p&gt;&lt;p&gt; &lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;span style="font-size:130%;"&gt;&lt;span class="Apple-style-span"  style="color:#CCFFFF;"&gt;5) Code Complexity&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Be it a small or a large project, a GUI application soon gets out of the hand or you'll find yourself handling messy code or writing lots of plumbing code instead of putting effort into the business logic of the application. There's no point in reinventing the wheel, its always better to reuse a well tested framework instead of making one on your own. &lt;/p&gt;For a small scale application its better to use to use your own MVC pattern to separate model, view and control. Major concerns in such application would be to maintain configuration. You'll probably use bean property change listeners...in this case consider using AbstractSerializableBean from swingX project to reduce the amount of boilerplate code for firing property change. It your application still gets out of hand consider using &lt;a href="http://www.jidesoft.com/jdaf/index.htm"&gt;JIDE Application framework&lt;/a&gt;...havent really tried it, but looks good and has a moderate learning curve (2-3 days)&lt;br /&gt;&lt;p&gt;For a large application it is best of you use Netbeans Platform, its pretty complex and has a high learning curve, i would'nt recommend it unless you want to reuse netbeans features such as pallete, property sheets and editors etc...but on the bottom line its got great support and excellent documentation. Since its developed by sun, you can expect great support. Moreover NetbeansIDE has lots of code completion features for leveraging a netbeans platform based application.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;If you have at least made 5-6 desktop applications and have good knowledge of OOPS, especially the use of interfaces and abstract classes (read this &lt;a href="http://ragha-infomaniac.blogspot.com/2008/11/why-use-object-oriented-programming2.html"&gt;post&lt;/a&gt; for information on abstract classes) then you must consider using the Netbeans platform. Start by viewing these excellent &lt;a href="http://platform.netbeans.org/tutorials/nbm-10-top-apis.html"&gt;screencasts&lt;/a&gt;. &lt;/p&gt;&lt;p&gt; &lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;span style="font-size:130%;"&gt;&lt;span class="Apple-style-span"  style="color:#CCFFFF;"&gt;6) Packaging and deployment&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Consider an application based on java comm api. In such an app, you cant ask your client to copy and paste dll's at different locations, this should instead be done automatically at the deployment time, typically by distributing a setup file. To encash the benefits of cross platform nature of your java code, you'll need to use a cross platform deployer. Again, there are many of them, the easiest one to use and learn is by using &lt;a href="http://packjacket.sourceforge.net/"&gt;PackJacket&lt;/a&gt;, a GUI frontend to the IzPack project. It also lets you create runtime scripts to execute custom tasks. whats more, the project is open sourced and is free to use.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-size:130%;"&gt;&lt;span class="Apple-style-span"  style="color:#CCFFFF;"&gt;7) Creating Trialwares&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;Depending on your marketing strategy, you might want to create trialware applications that expire after a certain time period.I recommend using &lt;a href="https://truelicense.dev.java.net/"&gt;TrueLicense&lt;/a&gt; library. Will take 1 day to get a hang of it.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Hope the above collection of tools and libs help you be more productive... Please let me know if you find better and easier tools.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5025713936013210120-5759213908019443976?l=ragha-justme.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ragha-justme.blogspot.com/feeds/5759213908019443976/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ragha-justme.blogspot.com/2009/05/my-ideal-desktop-recipe.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5025713936013210120/posts/default/5759213908019443976'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5025713936013210120/posts/default/5759213908019443976'/><link rel='alternate' type='text/html' href='http://ragha-justme.blogspot.com/2009/05/my-ideal-desktop-recipe.html' title='My ideal desktop recipe'/><author><name>Ragha</name><uri>http://www.blogger.com/profile/09182969744128777413</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5025713936013210120.post-1788771900791534423</id><published>2009-01-12T22:17:00.000-08:00</published><updated>2011-05-16T12:44:49.270-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='cool stuff'/><title type='text'>Tyranny of autorun.inf</title><content type='html'>Irritated with the darn viruses...?&lt;br /&gt;A friend of mine came up with this cool idea.&lt;br /&gt;&lt;br /&gt;As u all might already know. Most of the viruses create an autorun.inf file (hidden obviously) in the drive. On double clicking the drive, the script is , triggering the virus (Trojans).&lt;br /&gt;&lt;br /&gt;Here's the big idea, create a autorun.inf file (blank one) with read only and hidden attributes set. Paste this file in all your drives...even your pen drives. That way, even if a virus is present, it wont be able to create its own autorun.inf, as one already exists, i.e., with the read only permission.&lt;br /&gt;&lt;br /&gt;Viola, the virus is as good as useless as it wont be triggered. This applies to most of them but not all.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5025713936013210120-1788771900791534423?l=ragha-justme.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ragha-justme.blogspot.com/feeds/1788771900791534423/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ragha-justme.blogspot.com/2009/01/tyranny-of-autoruninf.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5025713936013210120/posts/default/1788771900791534423'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5025713936013210120/posts/default/1788771900791534423'/><link rel='alternate' type='text/html' href='http://ragha-justme.blogspot.com/2009/01/tyranny-of-autoruninf.html' title='Tyranny of autorun.inf'/><author><name>Ragha</name><uri>http://www.blogger.com/profile/09182969744128777413</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5025713936013210120.post-1231241895547966045</id><published>2009-01-02T02:54:00.000-08:00</published><updated>2011-05-16T12:44:49.270-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='cool stuff'/><category scheme='http://www.blogger.com/atom/ns#' term='web'/><title type='text'>Cool web pages...</title><content type='html'>Designing cool looking web pages is not a rocket science. Awesome effects can be acheived without javascript, flash etc etc...&lt;br /&gt;&lt;br /&gt;Dont let these things deter you, best example is my friend vivek...with just 2-3 days of work he managed to make a gr8 web page (just needed to learn CSS). Take a look at his &lt;a href="http://www.viveksunder.co.nr/"&gt;page&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Also he showed me some of the coolest web pages ever...very simple in concept and could have been implemented by YOU.&lt;br /&gt;&lt;br /&gt;Check out &lt;a href="http://www.sursly.com/#home"&gt;Tyler's web page&lt;/a&gt;, this page takes time to load...let it load completely before clicking on any thing. This page was made using the '#' element...pretty cool nah!&lt;br /&gt;&lt;br /&gt;Also there is a site called &lt;a href="http://www.cssbeauty.com/"&gt;&lt;span&gt;CSS beauty&lt;/span&gt;&lt;/a&gt;, it has a listing of all the cool web pages...hope this gives you enough inspiration to work on that innovate page of urs :)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5025713936013210120-1231241895547966045?l=ragha-justme.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ragha-justme.blogspot.com/feeds/1231241895547966045/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ragha-justme.blogspot.com/2009/01/cool-web-pages.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5025713936013210120/posts/default/1231241895547966045'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5025713936013210120/posts/default/1231241895547966045'/><link rel='alternate' type='text/html' href='http://ragha-justme.blogspot.com/2009/01/cool-web-pages.html' title='Cool web pages...'/><author><name>Ragha</name><uri>http://www.blogger.com/profile/09182969744128777413</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5025713936013210120.post-2698266740576097659</id><published>2009-01-02T02:29:00.000-08:00</published><updated>2009-06-14T23:41:57.063-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='personal'/><title type='text'>Pic of the year...hehe</title><content type='html'>My stupid cousin naveen never misses opportunities to take ediotic pics of mine...not just mine but of every one else. This one was particularly funny...Believe it or not, that damn brown dog is just 5 months old (super big lol). Its gonna be like 90 kgs, but i still beat it in terms of weight :)&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_7xvr19hYuG4/SV3vy4FbrNI/AAAAAAAAAB8/uWS3Ky8g6lY/s1600-h/dog+incident.jpg"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 300px; height: 400px;" src="http://2.bp.blogspot.com/_7xvr19hYuG4/SV3vy4FbrNI/AAAAAAAAAB8/uWS3Ky8g6lY/s400/dog+incident.jpg" alt="" id="BLOGGER_PHOTO_ID_5286645194930498770" border="0" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5025713936013210120-2698266740576097659?l=ragha-justme.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ragha-justme.blogspot.com/feeds/2698266740576097659/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ragha-justme.blogspot.com/2009/01/pic-of-yearhehe.html#comment-form' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5025713936013210120/posts/default/2698266740576097659'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5025713936013210120/posts/default/2698266740576097659'/><link rel='alternate' type='text/html' href='http://ragha-justme.blogspot.com/2009/01/pic-of-yearhehe.html' title='Pic of the year...hehe'/><author><name>Ragha</name><uri>http://www.blogger.com/profile/09182969744128777413</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_7xvr19hYuG4/SV3vy4FbrNI/AAAAAAAAAB8/uWS3Ky8g6lY/s72-c/dog+incident.jpg' height='72' width='72'/><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5025713936013210120.post-7173845619851615095</id><published>2008-12-31T00:12:00.000-08:00</published><updated>2009-06-14T23:42:02.472-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='personal'/><title type='text'>Awesome Header</title><content type='html'>Searching a university for MS was one heck of a journey. Frankly, it was &lt;span style="font-style: italic;"&gt;deemag karab&lt;/span&gt;. Admist all that headache, i found this really good header from SUNY stony brook university. It's so good that i decided to put it up as my first blog entry...&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_7xvr19hYuG4/SVsy9tKgNRI/AAAAAAAAAB0/mkc043ArUTA/s1600-h/suny+stony+brook.JPG"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 415px; height: 139px;" src="http://4.bp.blogspot.com/_7xvr19hYuG4/SVsy9tKgNRI/AAAAAAAAAB0/mkc043ArUTA/s400/suny+stony+brook.JPG" alt="" id="BLOGGER_PHOTO_ID_5285874623326467346" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Pretty good eh? Was refreshing to me!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5025713936013210120-7173845619851615095?l=ragha-justme.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ragha-justme.blogspot.com/feeds/7173845619851615095/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ragha-justme.blogspot.com/2008/12/awesome-header.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5025713936013210120/posts/default/7173845619851615095'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5025713936013210120/posts/default/7173845619851615095'/><link rel='alternate' type='text/html' href='http://ragha-justme.blogspot.com/2008/12/awesome-header.html' title='Awesome Header'/><author><name>Ragha</name><uri>http://www.blogger.com/profile/09182969744128777413</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_7xvr19hYuG4/SVsy9tKgNRI/AAAAAAAAAB0/mkc043ArUTA/s72-c/suny+stony+brook.JPG' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5025713936013210120.post-9091044642212610190</id><published>2008-12-20T10:06:00.000-08:00</published><updated>2011-05-16T12:44:49.270-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='cool stuff'/><title type='text'>Pure Genius...</title><content type='html'>I accidentally came across a lecture on 'human computing' by Louis Von Ahn, a professor at Carnegie Mellon University. This is one of the best works i have seen. Pure genius and totally awesome...&lt;br /&gt;&lt;br /&gt;Dont forget to check this out:&lt;br /&gt;http://video.google.com/videoplay?docid=-8246463980976635143&amp;amp;hl=en&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5025713936013210120-9091044642212610190?l=ragha-justme.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ragha-justme.blogspot.com/feeds/9091044642212610190/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ragha-justme.blogspot.com/2008/12/pure-genius.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5025713936013210120/posts/default/9091044642212610190'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5025713936013210120/posts/default/9091044642212610190'/><link rel='alternate' type='text/html' href='http://ragha-justme.blogspot.com/2008/12/pure-genius.html' title='Pure Genius...'/><author><name>Ragha</name><uri>http://www.blogger.com/profile/09182969744128777413</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5025713936013210120.post-6786956392623727133</id><published>2008-11-17T21:03:00.000-08:00</published><updated>2011-05-16T12:44:49.270-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='OOP'/><title type='text'>Why use object oriented programming…2</title><content type='html'>In my previous post, I’ve written how OOP resolves basic issues such as&lt;br /&gt;&lt;br /&gt;• Functional Clutter&lt;br /&gt;• Problem with Global Variables&lt;br /&gt;• Unmanageable associations&lt;br /&gt;&lt;br /&gt;Apart from these OOP has other powerful features, namely Inheritance and abstract classes. In this blog I’m going to discuss what these terms mean and why are they so useful.&lt;br /&gt;&lt;br /&gt;We all know the common book definition of inheritance, but why is it so useful?&lt;br /&gt;Basically inheritance is used when you have to&lt;br /&gt;&lt;br /&gt;1) Modify the behavior of the object&lt;br /&gt;2) Add additional features to the existing class&lt;br /&gt;&lt;br /&gt;To modify the behavior all you gotta do is inherit the parent class into a new class called the base class and override the necessary methods. Take the example of JLabel in swing. The text in the label is rendered onto the screen by calling the paint method. Suppose you wanted to change the way border is shown, you have to override this method which is in turn called by swing framework to render the label.&lt;br /&gt;&lt;br /&gt;To add additional features to the label, you have to inherit it into the base class and write additional methods for enabling new features. The base class now contains all the previous functionality that lets keeps it compatible with the existing framework.&lt;br /&gt;&lt;br /&gt;Inheritance is essentially like copying and pasting all the code within the parent class into the base class. So why not copy and paste the code manually? I.e. copy code in class A to Class B instead of inheriting.&lt;br /&gt;&lt;br /&gt;Just imagine what would happen if class A is modified later on as a result of bug fix or enhancement. You’ll have to re-copy all the code from class A to class B, thereby hampering the code manageability. Moreover inheritance lets you reuse the well designed and tested classes you’ve already made.&lt;br /&gt;&lt;br /&gt;What’s more, inheritance also helps you debug the code. Suppose class A, B, C, D inherits class E. If there is a problem in classes A to D then it’s probable that the code in class A is buggy. If class A is buggy then it’s probable that the new code you’ve added is buggy. It may seem like a small thing but believe it or not, about 70% of development time is wasted in debugging and maintenance.&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-weight: bold;font-size:130%;" &gt;Abstract classes…Inherit benefits of Inheritance&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;Suppose there are a lot of things in common between the two classes (A and B), i.e. you notice some sort of code redundancy, but there are also many marked differences between them at the same time. Furthermore the redundant code cannot be grouped within a single class as it doesn’t make any sense. If you come across this kind of a situation, you could put all that redundant code in an abstract class (X) and make then create the other two by inheriting the abstract class. This kind of model is blessed with the benefits of inheritance. In short it Inherit benefits of Inheritance ?&lt;br /&gt;&lt;br /&gt;Abstract classes don’t have an instance, i.e. it’s not possible to create an object without implementing the abstract methods. Simply make the class specific methods, the ones used by classes A and B as abstract. Sounds like Greek and Latin? Let’s consider an example.&lt;br /&gt;&lt;br /&gt;Yesterday I was trying to make a class that can add the ‘trail period’ feature to any software. To do this I’ll have to –&lt;br /&gt;&lt;br /&gt;1) Record the date when the software is first used.&lt;br /&gt;2) Whenever the software is started, check the current date with the start date and evaluate the difference&lt;br /&gt;3) If the difference is greater than say 30 days then prompt the user to enter the serial key.&lt;br /&gt;&lt;br /&gt;To record the start date there can be two possibilities.&lt;br /&gt;&lt;br /&gt;1) Save the data in an encrypted form within a file.&lt;br /&gt;2) Save the data in an encrypted form within a database in case of a distributed application.&lt;br /&gt;&lt;br /&gt;So you make two classes, DBValidator and NonDBValidator. Both of then contain redundant code…i.e. the logic that checks the date difference, a fraud detection system to see if the user tampers with the system date etc etc…The only point of change is the way in which the start date is persisted onto a storage medium.&lt;br /&gt;&lt;br /&gt;In this scenario you could create an abstract class called validator with all the redundant code and make the persistDate method abstract.&lt;br /&gt;&lt;br /&gt;Classes DBValidator and NonDNValidator inherit the validate class by implementing the abstract method persistDate, each one defining their own persistence logic.&lt;br /&gt;&lt;br /&gt;Why go through this entire headache? Read the inheritance part again. This helps in centralizing the changes that may be required. You just have to make a change at a particular common place (the parent) and the necessary updates are forwarded to all the base classes.&lt;br /&gt;&lt;br /&gt;Today’s software development standard is not about writing logical code, anyone can do that today. Instead more emphasis is laid on writing code that is better managed, even if you’ll have to compromise on the logic part. This is probably one the reasons as to why they look for people with work experience. Anyone involved in big projects would’ve certainly faced this problem before. This is also the reason why frameworks such as hibernate, JSF, struts are so popular in spite of the high learning curve involved.&lt;br /&gt;&lt;br /&gt;Now that the basics of OOP is laid out, in my next post I’ll discuss about UML diagrams. I hope this article was useful.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5025713936013210120-6786956392623727133?l=ragha-justme.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ragha-justme.blogspot.com/feeds/6786956392623727133/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ragha-justme.blogspot.com/2008/11/why-use-object-oriented-programming2.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5025713936013210120/posts/default/6786956392623727133'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5025713936013210120/posts/default/6786956392623727133'/><link rel='alternate' type='text/html' href='http://ragha-justme.blogspot.com/2008/11/why-use-object-oriented-programming2.html' title='Why use object oriented programming…2'/><author><name>Ragha</name><uri>http://www.blogger.com/profile/09182969744128777413</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5025713936013210120.post-6468363555651650227</id><published>2008-11-10T09:01:00.000-08:00</published><updated>2011-05-16T12:44:49.271-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='OOP'/><title type='text'>Why use Object Oriented Programming…</title><content type='html'>Do you get this feeling, “why use classes and objects un-necessarily when functions can achieve the same in a simpler manner?” If yes, this article is for you. It took me about 3-4 months to fully realize the potential of OOP over structural paradigm. The only way you’ll realize the importance of OOP is when you write big code, I mean BIG, around 50K lines or so.&lt;br /&gt;&lt;br /&gt;Here’s the scenario, consider yourself as a topnotch programmer who has written about 50,000 lines of code :) , say you’ve written some utility functions (around 800 of em) and have packaged them in a library.&lt;br /&gt;&lt;br /&gt;Why does big code gets messy and un-manageable??&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-size:130%;" &gt;Problem 1…Functional clutter&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;From the usage point of view, the person using your library will probably be confused will all the functions you’ve provided (they’re about 800!!!) and moreover they have to remember all the parameters to the function, its behavior etc…&lt;br /&gt;&lt;br /&gt;Ex- funcA(param1, param2, param3)&lt;br /&gt;Param1, param2 are numbers…&lt;br /&gt;Param3 can take values 1,2,3&lt;br /&gt;&lt;br /&gt;1 would mean that the function will add param1 and param2…&lt;br /&gt;2, 3 means it’ll perform multiplication and division&lt;br /&gt;&lt;br /&gt;The whole point is that it’ll get real tough to remember the functions and its behavior, parameter’s when there are too many of them. Furthermore not all of the functions are of utility value. What I mean is that there will be some functions that are used by other utility value functions.&lt;br /&gt;&lt;br /&gt;Ex - funcA() uses funcB() and funcC()  to do its tasks. The end user is only concerned with funcA and not with funcB and funcC.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-size:130%;" &gt;Problem 2…The headache of global variables&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The usage of global variables is the most annoying thing for me. It’s very easy to confuse a global variable with a local one or vice-versa. Also tracking the usages of global variables is considerably difficult. It also increases dependencies between the functions.&lt;br /&gt;&lt;br /&gt;Ex-&lt;br /&gt;&lt;pre class="brush: c"&gt;&lt;br /&gt;int x; //(global variable)&lt;br /&gt;&lt;br /&gt;void func1()&lt;br /&gt;{&lt;br /&gt;   //Uses global var x (reads and modifies)&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;void func2()&lt;br /&gt;{&lt;br /&gt;   //Uses global var x (reads and modifies)&lt;br /&gt;}&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;In this case, there exists a dependency between func1 and func2 indirectly via global variables…&lt;br /&gt;&lt;br /&gt;How?&lt;br /&gt;If in the future, you’ve found some bugs in func1 and corrected…it might as well affect func2 as they share the same global variable (dependency).&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-size:130%;" &gt;Problem 3…Unmanageable Associations&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Consider a game consisting of 300 circles which are moved randomly (say). Every circle has three status variables associated with it.&lt;br /&gt;&lt;br /&gt;x, y coordinate and the radius.&lt;br /&gt;Here’s how your code would work.&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: c"&gt;&lt;br /&gt;loop&lt;br /&gt;{&lt;br /&gt;  //Clear screen&lt;br /&gt;  //Draw all circles by reading their respective status variables&lt;br /&gt;  //Update the positions of all the circles by updating the status variables,&lt;br /&gt;  //using some logic&lt;br /&gt;}&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;The thing is that there are three variables with each circle…So that makes it 300 * 3 variables&lt;br /&gt;&lt;br /&gt;You’ll probably end up naming variables as&lt;br /&gt;Int x1, y1, r1, y2, r2….x300, y300, r300&lt;br /&gt;&lt;br /&gt;What if there are more objects in the game, like clouds, trees etc (even more status variables). All of this makes the code look messy and also makes the associations harder. You’ll soon start confusing which function operates on what and which variable is associated with an object (circle in this case)&lt;br /&gt;&lt;br /&gt;So what are the solutions to these issues? If you think about it’ll almost seem obvious.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-size:130%;" &gt;Solution to problem 2 &amp;amp; 3&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;In the world of OOP objects form the building blocks of the code. Suppose you’re coding a game, just think of any sprite (something that’s rendered onto the screen) as an object.&lt;br /&gt;&lt;br /&gt;An object is just like any other real world entity.&lt;br /&gt;&lt;br /&gt;- It has certain attributes or properties associated with it. In case of the circle consider its status variables as its attributes.&lt;br /&gt;&lt;br /&gt;- Has certain operations associated with it. You could have associated an operation (function) ‘move()’ with the circle object that would randomly alter its attributes. Also a function called ‘draw()’ can be added to render the circle onto the screen.&lt;br /&gt;&lt;br /&gt;Now there’s no more confusion…All the variables and operations are ‘encapsulated’ within an object&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;span style="font-weight: bold;"&gt;Circle (class or prototype of an object)&lt;/span&gt;&lt;br /&gt;--------------------------------------&lt;br /&gt;&lt;span style="font-style: italic;"&gt;(Attributes)&lt;/span&gt;&lt;br /&gt;--------------------------------------&lt;br /&gt;Int x&lt;br /&gt;Int y&lt;br /&gt;Int radius&lt;br /&gt;--------------------------------------&lt;br /&gt;&lt;span style="font-style: italic;"&gt;(Operations)&lt;/span&gt;&lt;br /&gt;--------------------------------------&lt;br /&gt;Move()&lt;br /&gt;Draw()&lt;br /&gt;--------------------------------------&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Class is just a template; an object on the other hand is an instance of the class having its own attributes.&lt;br /&gt;&lt;br /&gt;Moreover there is no longer a menace of global variables as all the attributes (variables) are encapsulated within classes.&lt;br /&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Solution to problem 1&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;To avoid the confusion all the related functions and shared global variables could be encapsulated within a class.&lt;br /&gt;Ex- Suppose you have some functions that perform certificate auth, encryption, decryption etc…You could combine (associate, encapsulate) them all in a class named security. Make all the shared global variables its attributes.&lt;br /&gt;&lt;br /&gt;As far as the utility of the function is concerned, OOP introduces access modifiers such as public, private etc…&lt;br /&gt;&lt;br /&gt;Make the real utility valued functions as public. The supporting functions can be made private so that they cannot be accessed directly from the object.&lt;br /&gt;&lt;br /&gt;This is only the beginning (yea, I know it’s a movie dialog). You haven’t tasted the real power yet. Apart from the issues I discussed, the key strength of OOP is in inheritance and abstraction.&lt;br /&gt;I’ll discuss more about those in my next post. I hope this article was useful.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5025713936013210120-6468363555651650227?l=ragha-justme.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ragha-justme.blogspot.com/feeds/6468363555651650227/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ragha-justme.blogspot.com/2008/11/why-use-object-oriented-programming.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5025713936013210120/posts/default/6468363555651650227'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5025713936013210120/posts/default/6468363555651650227'/><link rel='alternate' type='text/html' href='http://ragha-justme.blogspot.com/2008/11/why-use-object-oriented-programming.html' title='Why use Object Oriented Programming…'/><author><name>Ragha</name><uri>http://www.blogger.com/profile/09182969744128777413</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5025713936013210120.post-4142625591434749940</id><published>2008-10-31T08:09:00.000-07:00</published><updated>2011-05-16T12:44:49.271-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='cool stuff'/><title type='text'>Better Explained?</title><content type='html'>Cant help but post this, Check out &lt;span style="text-decoration: underline;"&gt;&lt;a href="http://betterexplained.com/"&gt;http://betterexplained.com/&lt;/a&gt;&lt;/span&gt;. It has amazing new perspectives on simple issues...for starters, take a look at the &lt;a href="http://betterexplained.com/articles/surprising-uses-of-the-pythagorean-theorem/"&gt;pythagorean theorem&lt;/a&gt;. Im sure it'll amaze you as much as it did to me.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5025713936013210120-4142625591434749940?l=ragha-justme.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ragha-justme.blogspot.com/feeds/4142625591434749940/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ragha-justme.blogspot.com/2008/10/better-explained.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5025713936013210120/posts/default/4142625591434749940'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5025713936013210120/posts/default/4142625591434749940'/><link rel='alternate' type='text/html' href='http://ragha-justme.blogspot.com/2008/10/better-explained.html' title='Better Explained?'/><author><name>Ragha</name><uri>http://www.blogger.com/profile/09182969744128777413</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5025713936013210120.post-1299528129284444526</id><published>2008-10-29T16:50:00.000-07:00</published><updated>2011-05-16T12:44:49.271-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ai'/><category scheme='http://www.blogger.com/atom/ns#' term='cool stuff'/><title type='text'>Reverse Engineering the Brain</title><content type='html'>Oh yes, you heard it right. It’s no longer a stuff of science fiction. On July 25, 2008, Intelligence Realm Inc. has completed a simulation of 100 billion neurons, the estimated size of the human brain. The simulation used distributed computing and involved over 3000 volunteers, 10000 processors, 180 TB of data and it lasted for a couple of months. This was the first simulation that bypassed the 100 billion level and used database files to store the data. The simulation is one of the first steps in a long-term project that is aiming to build a large-scale artificial intelligence by reverse engineering the brain.&lt;br /&gt;&lt;br /&gt;So how are the neurons simulated? The concept of artificial neural networks (ANN) is used which can perform tasks like predicting stock market, hand writing recognition, face recognition and many more. A typical ANN hardly consists of 100 neurons. Imagine the potential of an ANN with 100 billion neurons. 'Google' on Artificial neural networks for more information...&lt;br /&gt;&lt;br /&gt;So what’s the catch? There are many challenges involved to simulate an ANN at this degree.&lt;br /&gt;1)    Interconnection of neurons and their weights associated.&lt;br /&gt;2)    The processing power and storage capabilities.&lt;br /&gt;&lt;br /&gt;The latter can be solved in an economical manner by using a distributed computing scheme similar to SETI (wherein, volunteers can share their processing power).  As for the storage, with TB’s of hard disks coming up, that shouldn’t be much of an issue.&lt;br /&gt;&lt;br /&gt;To solve the former, scientists have decided to mimic the connections and weights used in the brain. After all it is nothing less than marvelous. Take a look at &lt;a href="http://brainmaps.org/"&gt;www.brainmaps.org&lt;/a&gt;. They have created a brain map of many species. So far 92% of the human brain is mapped because of the complexity involved.&lt;br /&gt;&lt;br /&gt;To get the gravity of this research, imagine the following scenario. A person is permanently blinded because of damage to visual cortex of the brain. Since, human brain mapping is available. A Nano sized chip could be made containing all the ANN’s required to process visual data. The beauty of this is that we don’t even have to understand how the information is processed. All we have to do is device a way for it to interact with the remainder of the brain by interconnecting the neurons of the chip with the real ones with a Nano surgery just as described by the brain map. By this a permanently blind person’s vision can be restored. This is because; the visual cortex neurons, connections and weights are mimicked exactly as it was in the real brain.&lt;br /&gt;&lt;br /&gt;Seems far fetched? You’ll be in for a real surprise. Back in 1980’s, it was estimated that the number of computers to be used by the year 2000 would be about 100.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5025713936013210120-1299528129284444526?l=ragha-justme.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ragha-justme.blogspot.com/feeds/1299528129284444526/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ragha-justme.blogspot.com/2008/10/reverse-engineering-brain.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5025713936013210120/posts/default/1299528129284444526'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5025713936013210120/posts/default/1299528129284444526'/><link rel='alternate' type='text/html' href='http://ragha-justme.blogspot.com/2008/10/reverse-engineering-brain.html' title='Reverse Engineering the Brain'/><author><name>Ragha</name><uri>http://www.blogger.com/profile/09182969744128777413</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5025713936013210120.post-7773351491736270238</id><published>2008-10-29T12:11:00.000-07:00</published><updated>2011-05-16T12:44:49.271-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='java'/><category scheme='http://www.blogger.com/atom/ns#' term='framework'/><category scheme='http://www.blogger.com/atom/ns#' term='OOP'/><title type='text'>Understanding frameworks by example...2</title><content type='html'>&lt;span style="font-weight: bold;font-size:130%;" &gt;&lt;br /&gt;Step 3: Check your code so far, revise and optimize&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;All might seem rosy at the moment but when you try out this code…you’ll notice that&lt;br /&gt;&lt;br /&gt;1)    Frame rates vary widely, some systems show FPS of up to 150 and some about 30&lt;br /&gt;To ensure frame-rate consistency we’ll add &lt;span style="font-weight: bold;"&gt;ensureMinFPS()&lt;/span&gt; and &lt;span style="font-weight: bold;"&gt;ensureMaxFPS()&lt;/span&gt; functions. This can be done by skipping calls too &lt;span style="font-weight: bold;"&gt;render()&lt;/span&gt; function, also known as frame skipping.&lt;br /&gt;&lt;br /&gt;That means we update status like 3 times but only draw it once onto the screen. The result is that the sprite may seem to be moving with large steps and may damage smoothness. But that’s the PC's problem nothing to do with us. Also we could add a convenience method &lt;span style="font-weight: bold;"&gt;getCurrentFPS()&lt;/span&gt;, just to check the performance.&lt;br /&gt;&lt;br /&gt;2)    For animating a moving object like a man, we’ll have to cycle through a set of images…&lt;br /&gt;This requires some handling which is again redundant. So we’ll add &lt;span style="font-weight: bold;"&gt;AnimatedSprite &lt;/span&gt;class. This class may contain methods such as &lt;span style="font-weight: bold;"&gt;addFrame(Image img, long persistenceTime);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;We’ll extend this class with Renderable.class so that its update and render methods can be utilized by the Game.class when registered with it.&lt;br /&gt;&lt;pre class="brush: java"&gt;@Override&lt;br /&gt;public void update(long time)&lt;br /&gt;{&lt;br /&gt;Image curFrame = frames.get(curFrameIndex);&lt;br /&gt;animTime += elapsedTime;&lt;br /&gt;&lt;br /&gt;if(animTime &gt;= curFrameduration)&lt;br /&gt;{&lt;br /&gt; curFrameIndex++;&lt;br /&gt;&lt;br /&gt; //provides roll-over for animTime accurately...&lt;br /&gt; animTime = animTime % curFrame.duration;&lt;br /&gt;                    &lt;br /&gt; if(curFrameIndex == frames.size())&lt;br /&gt;     curFrameIndex = 0;      &lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;But sprites can move to...So we could use xSpeed, ySpeed and update them using:&lt;br /&gt;&lt;pre class="brush: java"&gt;xPos += xSpeed * (elapsedTime);&lt;br /&gt;yPos += ySpeed * (elapsedTime);&lt;br /&gt;&lt;/pre&gt;this xPos and yPos could be utilized in render()&lt;br /&gt;drawImage(getCurFrame() ,xPos,yPos);&lt;br /&gt;&lt;br /&gt;Now re-run your code again. This time when you add sufficient renderable objects to your game, you’ll notice Overlapping.&lt;br /&gt;&lt;br /&gt;i.e., the object added first is drawn first…&lt;br /&gt;how will it seem if the graphics of a tree is being drawn after drawing man??&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_7xvr19hYuG4/SQjiI2KO9oI/AAAAAAAAAA8/6gSIe9rlKUs/s1600-h/overlaps.JPG"&gt;&lt;img style="cursor: pointer; width: 320px; height: 199px;" src="http://4.bp.blogspot.com/_7xvr19hYuG4/SQjiI2KO9oI/AAAAAAAAAA8/6gSIe9rlKUs/s320/overlaps.JPG" alt="" id="BLOGGER_PHOTO_ID_5262704806187693698" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;Forgive me for my crappy drawing…that’s the best I can come up with!&lt;br /&gt;The problem occurs because in run() method of Game.class, we use:&lt;br /&gt;&lt;pre class="brush: java"&gt;for(int i=0 to numRenderable)&lt;br /&gt;{&lt;br /&gt;arrRenderable.get(i).update(curTime - prevTime);&lt;br /&gt;arrRenderable.get(i).render();&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;avoid this we could modify addRenderableObject as&lt;br /&gt;&lt;pre class="brush: java"&gt;//image with smallest index is drawn 1st…&lt;br /&gt;addRenderableObject (Renderable rend, int index)&lt;br /&gt;{&lt;br /&gt;arrRenderable.add(rend, index);&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;Now that the drawing order can be determined, overlapping won’t be a problem.&lt;br /&gt;&lt;br /&gt;So far we have managed:&lt;br /&gt;-    Screen management, ensure min frame rate, a generic Renderable class that can be used with Game class followed by easier Animation handling.&lt;br /&gt;&lt;br /&gt;Now imagine that you’re coding the game using THIS framework, suppose the game works on 500 images…you probably will have to load all the images @ startup and show a progress bar like loading or something…Now we’ll integrate this feature into this framework&lt;br /&gt;&lt;br /&gt;Lets design a class called ResourceBox, that holds all the images.&lt;br /&gt;&lt;pre class="brush: java"&gt;public abstract class ResourceBox&lt;br /&gt;{&lt;br /&gt;Private HashMap hm = new HashMap();&lt;br /&gt;&lt;br /&gt;//this is where you’ll load all the images…or ne other stuff&lt;br /&gt;Public abstract void init();&lt;br /&gt;&lt;br /&gt;Public void add(String id, Image img)&lt;br /&gt;{&lt;br /&gt;   hm.put(id, img);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;//methods such as remove, replace and so on…&lt;br /&gt;//Include a method getImage(String Id)&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;We first create a ResourceBox object as:&lt;br /&gt;&lt;pre class="brush: java"&gt;ResourceBox rb = new ResourceBox()&lt;br /&gt;{&lt;br /&gt;@Override&lt;br /&gt;Public void init()&lt;br /&gt;{&lt;br /&gt;    //Load whatever resources you want…&lt;br /&gt;    //Ex – add(“man”, imgMan);&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;Remember the Game class…?&lt;br /&gt;How do we register this object with the game class??&lt;br /&gt;&lt;pre class="brush: java"&gt;Game(ResourceBox rb)&lt;br /&gt;{&lt;br /&gt;//Copy this ref into a private variable within game class&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;This is how the game would run previously:&lt;br /&gt;&lt;pre class="brush: java"&gt;run()&lt;br /&gt;{&lt;br /&gt;Init();&lt;br /&gt;Game loop&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;Here we plug in a bit of code:&lt;br /&gt;&lt;pre class="brush: java"&gt;run()&lt;br /&gt;{&lt;br /&gt;Init();&lt;br /&gt;If(rb != null)&lt;br /&gt;    rb.init();&lt;br /&gt;Game loop&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;Also we’ll add a utility method to game class as:&lt;br /&gt;&lt;pre class="brush: java"&gt;public ResourceBox getResourceBox();&lt;br /&gt;&lt;/pre&gt;This method is needed as we could use:&lt;br /&gt;&lt;pre class="brush: java"&gt;Image man = gameObj.getResourceBox().get(“man”);&lt;br /&gt;&lt;/pre&gt;Cool eh?&lt;br /&gt;&lt;br /&gt;What about the progress bar??&lt;br /&gt;We can’t provide an implementation as it would restrict the user from customizing/ making his own style of progress bar. More-over the user defined Loading screen or whatever must be shown when &lt;span style="color: rgb(204, 102, 0);"&gt;rb.init()&lt;/span&gt; method is called.&lt;br /&gt;&lt;br /&gt;We’re gonna try some sort of an event listener kinda thingy. Here goes:&lt;br /&gt;&lt;br /&gt;Include a method in ResourceBox.class&lt;br /&gt;&lt;pre class="brush: java"&gt;public void registerListener(Listener l);&lt;br /&gt;&lt;br /&gt;//This is how Listener’s defined&lt;br /&gt;Public class Listener&lt;br /&gt;{&lt;br /&gt;Public abstract void onInit(Graphics g);&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;First of all user’s gotta create an obj of Listener class for which you HAVE TO override the &lt;span style="font-weight: bold;"&gt;onInit()&lt;/span&gt; method&lt;br /&gt;&lt;pre class="brush: java"&gt;Listener l = new Listener()&lt;br /&gt;{&lt;br /&gt;@Override&lt;br /&gt;Public void onInit(Graphics g)&lt;br /&gt;{&lt;br /&gt;    //Draw your stuff on this graphics context…&lt;br /&gt;    //Ex = ((Graphics2D)g).do any thing();&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;Now we’ll also include a method getRegisteredListener() in ResourceBox.class&lt;br /&gt;We now modify the game class run method as follows:&lt;br /&gt;&lt;pre class="brush: java"&gt;run()&lt;br /&gt;{&lt;br /&gt;Init();&lt;br /&gt;if(rb != null)&lt;br /&gt;{&lt;br /&gt;   Listener l = rb.getRegisteredListener();&lt;br /&gt;   If(l != null)&lt;br /&gt;   {&lt;br /&gt;       // Assuming we have some hypothetical screen management class&lt;br /&gt;       Graphics g = ScreenManager.getGraphics();&lt;br /&gt;       l.onInit(g);&lt;br /&gt;   }&lt;br /&gt;   rb.init();&lt;br /&gt;   g.dispose();// or clear…&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;Game loop&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;Now user can show a progress bar or…loading screen with his/her own graphics style…&lt;br /&gt;So here’s a short summary,&lt;br /&gt;&lt;br /&gt;-    Abstract methods and stuff is absolutely integral in designing a good framework&lt;br /&gt;(Primarily to give user the control of things, just as swing lets us control the shape of a button)&lt;br /&gt;&lt;br /&gt;-    You might need event listeners in case where your internal handling code needs to call something…like the &lt;span style="font-weight: bold;"&gt;onInit()&lt;/span&gt;&lt;span style="color: rgb(204, 102, 0);"&gt; &lt;/span&gt;we just discussed (swing provides action listeners etc…to a button which are automatically called on mouse click on that component, hope you can associate this with the &lt;span style="font-weight: bold;"&gt;onInit()&lt;/span&gt;)&lt;br /&gt;&lt;br /&gt;-    Let your imagination run wild…experiment, try, you’ll eventually be able to write the top notch code. Okay, enough philosophy I suppose lets move further.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-size:130%;" &gt;Go back to step 2:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The best way to add new feature(s) to your framework is like I said can be done by imagining the usage. So let’s start with some analysis...how do we integrate sounds? After all any game would suck without sounds…&lt;br /&gt;&lt;br /&gt;In my next blog I’ll put up a nice UML diagram of the concepts so far and also discuss sound integration. As always, do comment and help me improve my posts.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5025713936013210120-7773351491736270238?l=ragha-justme.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ragha-justme.blogspot.com/feeds/7773351491736270238/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ragha-justme.blogspot.com/2008/10/understanding-frameworks-by-example2.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5025713936013210120/posts/default/7773351491736270238'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5025713936013210120/posts/default/7773351491736270238'/><link rel='alternate' type='text/html' href='http://ragha-justme.blogspot.com/2008/10/understanding-frameworks-by-example2.html' title='Understanding frameworks by example...2'/><author><name>Ragha</name><uri>http://www.blogger.com/profile/09182969744128777413</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_7xvr19hYuG4/SQjiI2KO9oI/AAAAAAAAAA8/6gSIe9rlKUs/s72-c/overlaps.JPG' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5025713936013210120.post-6820027260962522411</id><published>2008-09-25T16:02:00.000-07:00</published><updated>2011-05-16T12:44:49.271-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='java'/><category scheme='http://www.blogger.com/atom/ns#' term='framework'/><category scheme='http://www.blogger.com/atom/ns#' term='OOP'/><title type='text'>Understanding Frameworks by example...1</title><content type='html'>You all must have heard about it, .Net, Swing etc.&lt;br /&gt;So what exactly is this ‘framework’?&lt;br /&gt;&lt;br /&gt;Simply put, it is a set of properly organized classes and packages with many features to offer.&lt;br /&gt;In case you want to make one, proper planning and design is a must.&lt;br /&gt;&lt;br /&gt;lets take the well known ‘swing ‘ in java&lt;br /&gt;To create a frame all we gotta do is:&lt;br /&gt;&lt;pre class="brush: java"&gt;&lt;br /&gt;new JFrame().setVisible();&lt;br /&gt;&lt;/pre&gt;If I remember correctly, using windows.h in c++ we need to write a 100+ lines of code just to do that. Creating a simple frame involves registering the handleInstance and some other init steps. Moreover its just a simple frame. It we wanted to add a label to it, it’d take another 20-40 lines to do that. In swing its as simple as:&lt;br /&gt;&lt;pre class="brush: java"&gt;frame.add(new JLabel());&lt;br /&gt;&lt;/pre&gt;In a sense most of the code is redundant (no one remembers all that init code, they just copy, paste it and modify it at a few places). That’s where a framework is needed. To avoid redundant stuff and provide several layers of abstraction over the inner mess that’s going on.&lt;br /&gt;&lt;br /&gt;Also swing manages repaints very cleverly, suppose we have a frame with blue background and a label with green background. Then the background is to be drawn first onto the screen followed by drawing the label. What’s more, it provides a lot of customization which could be achieved by over-ridding a few key methods.&lt;br /&gt;&lt;br /&gt;For example to make the button round all you gotta do is over-ride the necessary shaping method that swing calls internally to display a button.&lt;br /&gt;&lt;br /&gt;Now if you’re up to it lets try to design a 2D game framework.&lt;br /&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Step 1: Identify the requirements&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;So what could we do to simplify 2D game designing??&lt;br /&gt;Here’s a few that I figured&lt;br /&gt;&lt;br /&gt;1) Screen management (change resolution, manage double buffering etc…)&lt;br /&gt;2) Input management (Keyboard polling and mapping)&lt;br /&gt;3) Animations Management (sprite handling)&lt;br /&gt;4) Sound management (sound effect and stuff)&lt;br /&gt;&lt;br /&gt;There are many more to it but I’d like to keep it simple&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold;"&gt;Step 2: Imagine the usage&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;For a moment let us assume that the framework is designed.&lt;br /&gt;Then how would it help simplifying game programming??&lt;br /&gt;&lt;br /&gt;First we’ll discuss a few basics of game programming&lt;br /&gt;This is typically called ‘The game loop’&lt;br /&gt;&lt;pre class="brush: java"&gt;loop&lt;br /&gt;{&lt;br /&gt;//Update status of the game objects&lt;br /&gt;//Render graphics onto the screen(typically by using double buffering)&lt;br /&gt;&lt;br /&gt;//Provide a certain delay…so that the game doesn’t seem to be&lt;br /&gt;//Running like a cheetah&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;As most of you might have already faced, this poses a severe problem...the delay is the villain here. The game runs at different speeds on different processors because of variable instruction execution speed but a fixed delay. To prevent this, we synchronize the events to a global Timer&lt;br /&gt;&lt;pre class="brush: java"&gt;prevTime = getTimeInNanos();&lt;br /&gt;loop&lt;br /&gt;{&lt;br /&gt;curTime = getTimeInNanos();&lt;br /&gt;//Update status of the game objects using (curTime – prevTime)&lt;br /&gt;//Render graphics onto the screen&lt;br /&gt;prevTime = curTime;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;getTimeInNanos() returns an arbitrary timer, it can be the bios timer ticks or OS dependent timer. In JAVA one could use System.nanoTime()&lt;br /&gt;&lt;br /&gt;And what about pausing and resuming the game??&lt;br /&gt;The threads sleep and notify needs to be handled within the loop itself&lt;br /&gt;&lt;br /&gt;Also we should provide a way to handle screen resolution change…&lt;br /&gt;Also to avoid flickering double buffering must be done&lt;br /&gt;Most of this is almost a necessity to be handled and furthermore this stuff is redundant&lt;br /&gt;So we could add all these features into a class, lets call it Game&lt;br /&gt;&lt;pre class="brush: java"&gt;public abstract class Game extends Thread&lt;br /&gt;{&lt;br /&gt;Public abstract void init();&lt;br /&gt;public void startGame();&lt;br /&gt;public void stopGame();&lt;br /&gt;public void pauseGame();&lt;br /&gt;public void resumeGame();&lt;br /&gt;public void setScreenRes(int width, int height) throws NotSupportedResException&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;init method is supplied as abstract so that user may customize it to his needs. All the Renderable objects (sprites as a few call it) have the update() and render() associated with it. So why not make a class called &lt;span style="font-weight: bold;"&gt;Renderable&lt;/span&gt; as:&lt;br /&gt;&lt;pre class="brush: java"&gt;public abstract class Renderable&lt;br /&gt;{&lt;br /&gt;//update status calculations here…parameter time is the num of seconds elapsed since&lt;br /&gt;//last call&lt;br /&gt;Public void abstract update(long time);&lt;br /&gt;&lt;br /&gt;//all the graphics are to be drawn onto this graphics object…&lt;br /&gt;public void abstract render(Graphics g);&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;Using abstract methods one of the most commonly used techniques in JAVA.&lt;br /&gt;With this you tell the user to over-ride these methods in order to be used…&lt;br /&gt;(Instead of telling them to create a class which HAS TO contain update(long) and render() functions, which would in turn be used for internal purposes)&lt;br /&gt;&lt;br /&gt;Then we could do:&lt;br /&gt;&lt;pre class="brush: java"&gt;game.addRenderableObject(rendObj);&lt;br /&gt;&lt;/pre&gt;and in the Game class we could use:&lt;br /&gt;&lt;pre class="brush: java"&gt;private Arraylist arrRenderable;&lt;br /&gt;addRenderableObject(Renderable rend)&lt;br /&gt;{&lt;br /&gt;arrRenderable.add(rend);&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;the run() in Game can be coded to handle thread start,stop,resume,pause and automatically calls all the registered Renderable objects update and render methods…&lt;br /&gt;this is what how run() would look like:&lt;br /&gt;&lt;pre class="brush: java"&gt;public void run()&lt;br /&gt;{&lt;br /&gt; init();&lt;br /&gt; prevTime = getTimeMillis();&lt;br /&gt;&lt;br /&gt; while(!isStopped)&lt;br /&gt; {&lt;br /&gt;     curTime = getTimeMillis() - pausedTime;&lt;br /&gt;     pausedTime = 0;&lt;br /&gt;&lt;br /&gt;     for(int i=0 to numItemsRegistered) &lt;br /&gt;     {&lt;br /&gt;         arrRenderable.get(i).update(curTime - prevTime);&lt;br /&gt;         arrRenderable.get(i).render();&lt;br /&gt;     }&lt;br /&gt;&lt;br /&gt;     if(isPaused)&lt;br /&gt;     {&lt;br /&gt;         pausedTime = getTimeMillis();&lt;br /&gt;         while(isPaused)&lt;br /&gt;         {&lt;br /&gt;             Graphics g = screen.getGraphics();&lt;br /&gt;             screen.drawFrameContents(g);&lt;br /&gt;             g.dispose();&lt;br /&gt;             scr.updateGraphics();&lt;br /&gt;         }&lt;br /&gt;         pausedTime = getTimeMillis() - pausedTime;            &lt;br /&gt;     }    &lt;br /&gt;     prevTime = curTime;&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public void pauseGame()&lt;br /&gt;{&lt;br /&gt; isPaused = true;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public void stopGame()&lt;br /&gt;{&lt;br /&gt; isStopped = true;&lt;br /&gt;}    &lt;br /&gt;&lt;/pre&gt;Hope you got the whole picture here…&lt;br /&gt;I suppose that’s enough stuff for now, I’ll add more in my next post. Do comment…&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5025713936013210120-6820027260962522411?l=ragha-justme.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ragha-justme.blogspot.com/feeds/6820027260962522411/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ragha-justme.blogspot.com/2008/09/understanding-frameworks-by-example1.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5025713936013210120/posts/default/6820027260962522411'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5025713936013210120/posts/default/6820027260962522411'/><link rel='alternate' type='text/html' href='http://ragha-justme.blogspot.com/2008/09/understanding-frameworks-by-example1.html' title='Understanding Frameworks by example...1'/><author><name>Ragha</name><uri>http://www.blogger.com/profile/09182969744128777413</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>
