<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/atom10full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><feed xmlns="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/" xmlns:georss="http://www.georss.org/georss" xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr="http://purl.org/syndication/thread/1.0" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" gd:etag="W/&quot;C0QFR3c4fyp7ImA9WhRaFE0.&quot;"><id>tag:blogger.com,1999:blog-3969325917870221979</id><updated>2012-02-16T19:38:36.937+05:30</updated><category term="java7" /><category term="Just Like That" /><category term="Maer" /><category term="MyJerry" /><category term="Creativity Concepts" /><category term="Spring Framework" /><category term="Apache Flex" /><category term="Code Challenge" /><category term="ActionScript" /><category term="Tools" /><category term="Link Listings" /><category term="Project Euler" /><category term="Adobe AIR" /><category term="My Projects" /><category term="Workarounds" /><category term="Interview Questions" /><category term="Java" /><category term="Blogger" /><category term="Coding Techniques" /><category term="Evenstar" /><category term="Web" /><category term="Scalability" /><title>Keep Walking!</title><subtitle type="html">Keep Walking!</subtitle><link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" href="http://blog.sangupta.com/feeds/posts/default" /><link rel="alternate" type="text/html" href="http://blog.sangupta.com/" /><link rel="next" type="application/atom+xml" href="http://www.blogger.com/feeds/3969325917870221979/posts/default?start-index=26&amp;max-results=25&amp;redirect=false&amp;v=2" /><author><name>Sandeep Gupta</name><uri>https://profiles.google.com/110645714607919970386</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-fgzHpYBSqzA/AAAAAAAAAAI/AAAAAAAAGLY/n0u9TBuTk4M/s512-c/photo.jpg" /></author><generator version="7.00" uri="http://www.blogger.com">Blogger</generator><openSearch:totalResults>156</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/atom+xml" href="http://feeds.feedburner.com/Azcarya" /><feedburner:info uri="azcarya" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><geo:lat>20.2</geo:lat><geo:long>70.3</geo:long><feedburner:emailServiceId>Azcarya</feedburner:emailServiceId><feedburner:feedburnerHostname>http://feedburner.google.com</feedburner:feedburnerHostname><entry gd:etag="W/&quot;CUIMSXg9fip7ImA9WhRbEEw.&quot;"><id>tag:blogger.com,1999:blog-3969325917870221979.post-1531666796150182852</id><published>2012-01-27T18:09:00.000+05:30</published><updated>2012-01-31T18:09:48.666+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-01-31T18:09:48.666+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Apache Flex" /><title>Proposed Apache Flex Logos | Round II - Results</title><content type="html">The Apache Flex logo contest came to end today with the results for Round 2 being announces by &lt;b&gt;Doug Arthur&lt;/b&gt;. And the winner is,&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://s.apache.org/af-logo-42"&gt;Logo #42&lt;/a&gt;:&lt;br /&gt;
Total: 77 Votes&lt;br /&gt;
Community: 61 *&lt;br /&gt;
PPMC: 16 *&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://s.apache.org/af-logo-49"&gt;Logo #49&lt;/a&gt;:&lt;br /&gt;
Total: 49 Votes&lt;br /&gt;
Community: 44&lt;br /&gt;
PPMC: 5&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Congrats to the team behind logo #42.&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Full results are available &lt;a href="http://people.apache.org/~dougarthur/apache_flex_logo_votes_round2.pdf"&gt;here (PDF)&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
Quoting Doug,&lt;br /&gt;
&lt;blockquote&gt;Finally, Tomasz Maciag's logo will appear as the new Apache Logo (As stated in the &lt;a href="http://incubator.apache.org/flex/logo-contest.html"&gt;contest rules&lt;/a&gt;, tweaks will be allowed now that the contest has been finalized. )&lt;/blockquote&gt;&lt;br /&gt;
For the over eagerly,&lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://www.fusecollective.com/apache-flex/apache-flex-fusecollective_v2.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="221" src="http://www.fusecollective.com/apache-flex/apache-flex-fusecollective_v2.jpg" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;b&gt;Disclaimer:&lt;/b&gt; I voted for #42.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3969325917870221979-1531666796150182852?l=blog.sangupta.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/Azcarya/~4/sdasW9IgEyc" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.sangupta.com/feeds/1531666796150182852/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=3969325917870221979&amp;postID=1531666796150182852&amp;isPopup=true" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/3969325917870221979/posts/default/1531666796150182852?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/3969325917870221979/posts/default/1531666796150182852?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/Azcarya/~3/sdasW9IgEyc/proposed-apache-flex-logos-round-ii.html" title="Proposed Apache Flex Logos | Round II - Results" /><author><name>Sandeep Gupta</name><uri>https://profiles.google.com/110645714607919970386</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-fgzHpYBSqzA/AAAAAAAAAAI/AAAAAAAAGLY/n0u9TBuTk4M/s512-c/photo.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://blog.sangupta.com/2012/01/proposed-apache-flex-logos-round-ii.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CUYHR38zeSp7ImA9WhRbEEw.&quot;"><id>tag:blogger.com,1999:blog-3969325917870221979.post-7931001492032499881</id><published>2012-01-24T18:00:00.000+05:30</published><updated>2012-01-31T18:02:16.181+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-01-31T18:02:16.181+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Apache Flex" /><title>Proposed Apache Flex Logos | Round I - Results</title><content type="html">From among all the contenders, after the first round of voting, the results are as under:&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://s.apache.org/af-logo-49"&gt;Logo #49&lt;/a&gt;:&lt;br /&gt;
  Total: 106.5 Pts&lt;br /&gt;
  Community: 83.5 *&lt;br /&gt;
  PPMC: 23&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://s.apache.org/af-logo-42"&gt;Logo #42&lt;/a&gt;:&lt;br /&gt;
  Total: 99.5&lt;br /&gt;
  Community: 68.5&lt;br /&gt;
  PPMC: 31 *&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://s.apache.org/af-logo-40"&gt;Logo #40&lt;/a&gt;:&lt;br /&gt;
  Total: 65&lt;br /&gt;
  Community: 63&lt;br /&gt;
  PPMC: 2&lt;br /&gt;
&lt;br /&gt;
A list of aggregated first round results is available &lt;a href="http://people.apache.org/~dougarthur/apache_flex_logo_votes.xlsx"&gt;here&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
The voting will now continue to choose the one from these three.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Disclaimer:&lt;/b&gt; The results are based on the vote of the community on Apache Flex Dev mailing-list.&lt;br /&gt;
&lt;br /&gt;
Happy Flexing!&lt;br /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3969325917870221979-7931001492032499881?l=blog.sangupta.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/Azcarya/~4/G6ziU1aVOxE" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.sangupta.com/feeds/7931001492032499881/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=3969325917870221979&amp;postID=7931001492032499881&amp;isPopup=true" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/3969325917870221979/posts/default/7931001492032499881?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/3969325917870221979/posts/default/7931001492032499881?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/Azcarya/~3/G6ziU1aVOxE/proposed-apache-flex-logos-round-i.html" title="Proposed Apache Flex Logos | Round I - Results" /><author><name>Sandeep Gupta</name><uri>https://profiles.google.com/110645714607919970386</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-fgzHpYBSqzA/AAAAAAAAAAI/AAAAAAAAGLY/n0u9TBuTk4M/s512-c/photo.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://blog.sangupta.com/2012/01/proposed-apache-flex-logos-round-i.html</feedburner:origLink></entry><entry gd:etag="W/&quot;Ck8CQHc_cCp7ImA9WhRVEEU.&quot;"><id>tag:blogger.com,1999:blog-3969325917870221979.post-1980895675591499719</id><published>2012-01-07T21:42:00.001+05:30</published><updated>2012-01-09T09:17:41.948+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-01-09T09:17:41.948+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Apache Flex" /><title>Proposed Apache Flex Logos | Part II</title><content type="html">In continuation of my previous post on &lt;a href="http://blog.sangupta.com/2012/01/proposed-apache-flex-logos.html"&gt;Proposed Apache Flex Logos&lt;/a&gt; here are some more logos that have been posted. Check them out.&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;By Mihai Ene&lt;/h3&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://cs.ibaneasa.ro/flex/flexlogoprop2-graybg.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="284" src="http://cs.ibaneasa.ro/flex/flexlogoprop2-graybg.png" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div style="clear: both;"&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://cs.ibaneasa.ro/flex/flexlogoprop3-blankbg.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="285" src="http://cs.ibaneasa.ro/flex/flexlogoprop3-blankbg.png" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div style="clear: both;"&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://cs.ibaneasa.ro/flex/flexlogoprop4-adobestyle.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="285" src="http://cs.ibaneasa.ro/flex/flexlogoprop4-adobestyle.png" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div style="clear: both;"&gt;&lt;/div&gt;&lt;br /&gt;
&lt;h3&gt;By Carlos Rovira - Updated&lt;/h3&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://www.carlosrovira.com/apache-flex-logo-proposal-2.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="300" src="http://www.carlosrovira.com/apache-flex-logo-proposal-2.png" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div style="clear: both;"&gt;&lt;/div&gt;&lt;br /&gt;
&lt;h3&gt;By Peter Elst&lt;/h3&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://peterelst.com/tmp/apacheflex-logo-proposal.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="252" src="http://peterelst.com/tmp/apacheflex-logo-proposal.png" width="550" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div style="clear: both;"&gt;&lt;/div&gt;&lt;br /&gt;
&lt;b&gt;Update: 9 Jan 2012&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;By Doug McCune&lt;/h3&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://dougmccune.com/apache_flex_logo.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="600" src="http://dougmccune.com/apache_flex_logo.jpg" width="800" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3969325917870221979-1980895675591499719?l=blog.sangupta.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/Azcarya/~4/ibaWviSBvCg" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.sangupta.com/feeds/1980895675591499719/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=3969325917870221979&amp;postID=1980895675591499719&amp;isPopup=true" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/3969325917870221979/posts/default/1980895675591499719?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/3969325917870221979/posts/default/1980895675591499719?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/Azcarya/~3/ibaWviSBvCg/proposed-apache-flex-logos-part-ii.html" title="Proposed Apache Flex Logos | Part II" /><author><name>Sandeep Gupta</name><uri>https://profiles.google.com/110645714607919970386</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-fgzHpYBSqzA/AAAAAAAAAAI/AAAAAAAAGLY/n0u9TBuTk4M/s512-c/photo.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://blog.sangupta.com/2012/01/proposed-apache-flex-logos-part-ii.html</feedburner:origLink></entry><entry gd:etag="W/&quot;A0QARnY7eip7ImA9WhRWGE8.&quot;"><id>tag:blogger.com,1999:blog-3969325917870221979.post-2199067782003892843</id><published>2012-01-06T09:26:00.001+05:30</published><updated>2012-01-06T11:25:47.802+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-01-06T11:25:47.802+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Apache Flex" /><title>Proposed Apache Flex Logos</title><content type="html">As we all have heard that &lt;a href="http://www.adobe.com"&gt;Adobe&lt;/a&gt; has started donating the &lt;a href="www.adobe.com/products/flex.html"&gt;Flex framework&lt;/a&gt; to the &lt;a href="http://www.apache.org"&gt;Apache&lt;/a&gt; foundation. The project was approved over the holidays and the combat has begun.&lt;br /&gt;
&lt;br /&gt;
The first blood was shed yesterday with some designers proposing new logos for the &lt;a href="http://incubator.apache.org/flex/"&gt;Apache Flex framework&lt;/a&gt;. Below are the logos submitted by the time of writing. Please vote for your favorite ones at the project's &lt;a href="http://incubator.apache.org/flex/mailing-lists.html"&gt;mailing list&lt;/a&gt;s.&lt;br /&gt;
&lt;br /&gt;
In case you are enthusiastic enough and are a designer, it would be helpful to propose your own thoughts for the same. Make sure you go over the &lt;a href="http://www.apache.org/licenses/icla.txt"&gt;Individual Contributor License Agreement&lt;/a&gt; for you would need to donate your work to &lt;a href="http://www.apache.org"&gt;Apache&lt;/a&gt; in its accordance.&lt;br /&gt;
&lt;br /&gt;
Without much ado, in no particular order:&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;By Erik Lundgren&lt;/h3&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://lndgrn.se/ApacheFlexLogo_01_01.png" imageanchor="1" style="clear:left; float:left;margin-right:1em; margin-bottom:1em"&gt;&lt;img border="0" height="600" width="800" src="http://lndgrn.se/ApacheFlexLogo_01_01.png" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div style="clear: both"&gt;&lt;/div&gt;&lt;br /&gt;
&lt;h3&gt;By Rick Winscot&lt;/h3&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://www.quilix.com/images/Apache_Flex_01.png" imageanchor="1" style="clear:left; float:left;margin-right:1em; margin-bottom:1em"&gt;&lt;img border="0" height="118" width="147" src="http://www.quilix.com/images/Apache_Flex_01.png" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div style="clear: both"&gt;&lt;/div&gt;&lt;br /&gt;
&lt;h3&gt;By Tink&lt;/h3&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://www.tink.ws/Flex-Logo.png" imageanchor="1" style="clear:left; float:left;margin-right:1em; margin-bottom:1em"&gt;&lt;img border="0" height="500" width="500" src="http://www.tink.ws/Flex-Logo.png" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div style="clear: both"&gt;&lt;/div&gt;&lt;br /&gt;
&lt;h3&gt;By Randy Troppmann&lt;/h3&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://randytroppmann.com/flex/apache-flex-logo.png" imageanchor="1" style="clear:left; float:left;margin-right:1em; margin-bottom:1em"&gt;&lt;img border="0" height="200" width="173" src="http://randytroppmann.com/flex/apache-flex-logo.png" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div style="clear: both"&gt;&lt;/div&gt;&lt;br /&gt;
&lt;h3&gt;By Carlos Rovira&lt;/h3&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://www.carlosrovira.com/apache-flex-logo-proposal.png" imageanchor="1" style="clear:left; float:left;margin-right:1em; margin-bottom:1em"&gt;&lt;img border="0" height="600" width="800" src="http://www.carlosrovira.com/apache-flex-logo-proposal.png" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div style="clear: both"&gt;&lt;/div&gt;&lt;br /&gt;
Happy Flexing! :)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3969325917870221979-2199067782003892843?l=blog.sangupta.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/Azcarya/~4/9E2jh5Ge4ns" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.sangupta.com/feeds/2199067782003892843/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=3969325917870221979&amp;postID=2199067782003892843&amp;isPopup=true" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/3969325917870221979/posts/default/2199067782003892843?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/3969325917870221979/posts/default/2199067782003892843?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/Azcarya/~3/9E2jh5Ge4ns/proposed-apache-flex-logos.html" title="Proposed Apache Flex Logos" /><author><name>Sandeep Gupta</name><uri>https://profiles.google.com/110645714607919970386</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-fgzHpYBSqzA/AAAAAAAAAAI/AAAAAAAAGLY/n0u9TBuTk4M/s512-c/photo.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://blog.sangupta.com/2012/01/proposed-apache-flex-logos.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CU4GQnY-fip7ImA9WhRQE0k.&quot;"><id>tag:blogger.com,1999:blog-3969325917870221979.post-2898284498595263583</id><published>2011-12-08T16:57:00.001+05:30</published><updated>2011-12-08T17:02:03.856+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-12-08T17:02:03.856+05:30</app:edited><title>Mission Accomplished - Greplin Programming Challenge!</title><content type="html">After a lull yesterday, I could finally find time to solve the third puzzle in the &lt;a href="http://challenge.greplin.com/"&gt;Greplin Programming Challenge&lt;/a&gt;. At first the puzzle seemed tricky, considering my bad with combinatory logic with numbers. However after many trials and errors I could solve the puzzle. And now I can sit and relax, and look at my stupid face as to why I was writing over 100 lines of code to solve, when the solution was simply a few lines.&lt;br /&gt;
&lt;br /&gt;
Anyways, am done with the challenge and I have my passcode now! Next steps involve dropping them a mail with my solutions.&lt;br /&gt;
&lt;br /&gt;
For those interested, the code is available on &lt;a href="https://github.com/sangupta/greplin"&gt;my GitHub repository&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
Happy Coding!&lt;br /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3969325917870221979-2898284498595263583?l=blog.sangupta.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/Azcarya/~4/48_wIRxGa5A" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.sangupta.com/feeds/2898284498595263583/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=3969325917870221979&amp;postID=2898284498595263583&amp;isPopup=true" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/3969325917870221979/posts/default/2898284498595263583?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/3969325917870221979/posts/default/2898284498595263583?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/Azcarya/~3/48_wIRxGa5A/mission-accomplished-greplin.html" title="Mission Accomplished - Greplin Programming Challenge!" /><author><name>Sandeep Gupta</name><uri>https://profiles.google.com/110645714607919970386</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-fgzHpYBSqzA/AAAAAAAAAAI/AAAAAAAAGLY/n0u9TBuTk4M/s512-c/photo.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://blog.sangupta.com/2011/12/mission-accomplished-greplin.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CUQCRnw6fyp7ImA9WhRQEk4.&quot;"><id>tag:blogger.com,1999:blog-3969325917870221979.post-4440455499375929165</id><published>2011-12-07T10:08:00.001+05:30</published><updated>2011-12-07T10:19:27.217+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-12-07T10:19:27.217+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Code Challenge" /><category scheme="http://www.blogger.com/atom/ns#" term="My Projects" /><category scheme="http://www.blogger.com/atom/ns#" term="Coding Techniques" /><title>Greplin Programming Challenge</title><content type="html">Yesterday evening I came across another programming challenge called &lt;a href="http://challenge.greplin.com/"&gt;Greplin Programming Challenge&lt;/a&gt;. The challenge presents three problems which requires one to write small pieces of code to solve, and provide the solution as the password to the next level. Something similar to &lt;a href="http://projecteuler.net/"&gt;Project Euler&lt;/a&gt; problems.&lt;br /&gt;
&lt;br /&gt;
The challenge claims it may take from anywhere between 20 minutes and 2 hours. The first and second level are quite easy and should be completed within 15 minutes (including the time to fire up the IDE and keying in code, lazying around in bed). The third level requires some combinatory logic and thus may require a little extra time. I am done with the first 2 levels and planning for the third today evening.&lt;br /&gt;
&lt;br /&gt;
For those interested, the code is available on &lt;a href="https://github.com/sangupta/greplin"&gt;my GitHub repository&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
Looks like am developing a liking for coding problems... Anyone recommending another?&lt;br /&gt;
&lt;br /&gt;
Have. Fun. Coding.&lt;br /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3969325917870221979-4440455499375929165?l=blog.sangupta.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/Azcarya/~4/FK6PjvfNFkk" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.sangupta.com/feeds/4440455499375929165/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=3969325917870221979&amp;postID=4440455499375929165&amp;isPopup=true" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/3969325917870221979/posts/default/4440455499375929165?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/3969325917870221979/posts/default/4440455499375929165?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/Azcarya/~3/FK6PjvfNFkk/greplin-programming-challenge.html" title="Greplin Programming Challenge" /><author><name>Sandeep Gupta</name><uri>https://profiles.google.com/110645714607919970386</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-fgzHpYBSqzA/AAAAAAAAAAI/AAAAAAAAGLY/n0u9TBuTk4M/s512-c/photo.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://blog.sangupta.com/2011/12/greplin-programming-challenge.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CEUMRH4zfyp7ImA9WhRQEk4.&quot;"><id>tag:blogger.com,1999:blog-3969325917870221979.post-6474523474298968444</id><published>2011-12-07T09:48:00.001+05:30</published><updated>2011-12-07T10:01:25.087+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-12-07T10:01:25.087+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Code Challenge" /><category scheme="http://www.blogger.com/atom/ns#" term="My Projects" /><category scheme="http://www.blogger.com/atom/ns#" term="Coding Techniques" /><title>Image Unshredder - Update</title><content type="html">In continuation of my &lt;a href="http://blog.sangupta.com/2011/12/instagrams-engineering-challenge.html"&gt;earlier post&lt;/a&gt; about &lt;b&gt;Instagram's Engineering Challenge on an Image Unshredder&lt;/b&gt;, I took some time out yesterday and completed the automatic strip width detection piece. The approach was easy, the euclidean distance on the strip edge will be too high than the normal values. For example the values may look like,&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;3, 4, 3, 5, 3, 2, 6, &lt;b&gt;22&lt;/b&gt;, 4, 3, 2, 3, 4, 3, 2, &lt;b&gt;27&lt;/b&gt;, 3, ...&lt;/pre&gt;&lt;br /&gt;
One just needs to take the average of above values, then find the average of values greater than this average. Once you have the maxAverage, one can run a loop and find the value where the ratio of (value / minimum) is close to the ratio of (maxAverage / minimum). The first index where this happens is the strip width. To be doubly sure that we have chosen the right value, make sure the strip width divides the image width in whole.&lt;br /&gt;
&lt;br /&gt;
I tested my code with many a free images from &lt;a href="http://www.flickr.com/"&gt;Flickr&lt;/a&gt; and it all worked. Though I did find a couple of issues with images that had a dark background and no front object - like a huge clear sky running in. &lt;br /&gt;
&lt;br /&gt;
As the challenge was to unshred the shredded &lt;b&gt;Tokyo&lt;/b&gt; image, it stands completed. The remaining improvements, I will leave for some other day.&lt;br /&gt;
&lt;br /&gt;
I have also added an &lt;b&gt;image shredder&lt;/b&gt; and a test suite that takes in images from a given folder, shreds and then unshreds them.&lt;br /&gt;
&lt;br /&gt;
For those interested the code is posted on my &lt;a href="https://github.com/sangupta/image-unshred"&gt;GitHub repository&lt;/a&gt; at &lt;a href="https://github.com/sangupta/image-unshred"&gt;https://github.com/sangupta/image-unshred&lt;/a&gt;&lt;br /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3969325917870221979-6474523474298968444?l=blog.sangupta.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/Azcarya/~4/6ameoxNmYks" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.sangupta.com/feeds/6474523474298968444/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=3969325917870221979&amp;postID=6474523474298968444&amp;isPopup=true" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/3969325917870221979/posts/default/6474523474298968444?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/3969325917870221979/posts/default/6474523474298968444?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/Azcarya/~3/6ameoxNmYks/image-unshredder-update.html" title="Image Unshredder - Update" /><author><name>Sandeep Gupta</name><uri>https://profiles.google.com/110645714607919970386</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-fgzHpYBSqzA/AAAAAAAAAAI/AAAAAAAAGLY/n0u9TBuTk4M/s512-c/photo.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://blog.sangupta.com/2011/12/image-unshredder-update.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DkcMRHs7cCp7ImA9WhRQEUk.&quot;"><id>tag:blogger.com,1999:blog-3969325917870221979.post-8202826302890036281</id><published>2011-12-06T09:00:00.000+05:30</published><updated>2011-12-06T09:31:25.508+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-12-06T09:31:25.508+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Code Challenge" /><category scheme="http://www.blogger.com/atom/ns#" term="My Projects" /><category scheme="http://www.blogger.com/atom/ns#" term="Coding Techniques" /><title>Instagram's Engineering Challenge: The Unshredder</title><content type="html">Three weeks ago, Instagram posted an engineering challenge: &lt;a href="http://instagram-engineering.tumblr.com/post/12651721845/instagram-engineering-challenge-the-unshredder"&gt;The Unshredder&lt;/a&gt;. The challenge presented an image that had been vertically shredded/spliced and then rejoined randomly, thus resulting in an image that looks like a puzzle. What one had to do was to write a script to take that image and unshred it - yes, reconstruct the original image. &lt;br /&gt;
&lt;br /&gt;
From their blog,&lt;br /&gt;
&lt;blockquote style="padding-left: 20px;"&gt;Your challenge, if you choose to accept it, is to write a simple script that takes a shredded image in as input:&lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://media.tumblr.com/tumblr_luigsoCv3s1qm4rc3.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="280" src="http://media.tumblr.com/tumblr_luigsoCv3s1qm4rc3.png" width="500" /&gt;&lt;/a&gt;&lt;/div&gt;and outputs an unshredded and reconstituted image. That is, imagine if you took an image, divided it into an even number of columns and shuffled those columns randomly to produce a shredded image. Then, take that image into the script and output the original image:&lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://media.tumblr.com/tumblr_luih7og6QM1qm4rc3.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="280" src="http://media.tumblr.com/tumblr_luih7og6QM1qm4rc3.png" width="500" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;br /&gt;
I happened to read and pick up this challenge yesterday, and it was surprising to find that the solution was a very simple best-match function that had to place a given slice alongside another based on how close the left-pixels of one were to the right-pixels of another. I used Java and the built in AWT package to load the image and read the pixel colors at various coordinates. Reconstructing the image was again super easy using AWT. To test that the solution was a generic one, I sliced some 50 random images and then reconstructed them using my code for varying slice-widths - ranging from 4 pixel wide to 64 pixel wide.&lt;br /&gt;
&lt;br /&gt;
My algorithm worked in the following way:&lt;br /&gt;
&lt;ol&gt;&lt;li&gt;Find out the number of stripes in the image (as the strip-width is known)&lt;/li&gt;
&lt;li&gt;Slice the image and store all sub-images in a given array&lt;/li&gt;
&lt;li&gt;Pick the first slice from the array&lt;/li&gt;
&lt;li&gt;Now for each other slice in the array (slices that have not yet been used) - compute the average Euclidean distance of the left edge of the given slice and the right edge of the test slice. Similarly, compute the average distance of the right edge of the given slice and the left edge of the test slice.&lt;/li&gt;
&lt;li&gt;Find the slices that have the least scores for left and right side&lt;/li&gt;
&lt;li&gt;Now, insert the one of the test slice to the left or to the right, depending on which test slice and edge had the lowest average distance&lt;/li&gt;
&lt;li&gt;Work this way to arrange each unused slice to the set of arranged slices&lt;/li&gt;
&lt;li&gt;At the end, you have all the slices in order resulting in the reconstructed image&lt;/li&gt;
&lt;/ol&gt;&lt;br /&gt;
For those interested the code is posted on my &lt;a href="https://github.com/sangupta/image-unshred"&gt;GitHub repository&lt;/a&gt; at &lt;a href="https://github.com/sangupta/image-unshred"&gt;https://github.com/sangupta/image-unshred&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
I haven't yet completed the bonus part of it due to lack of time, but hope to push it in a day or two.&lt;br /&gt;
&lt;br /&gt;
Happy Coding!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3969325917870221979-8202826302890036281?l=blog.sangupta.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/Azcarya/~4/JVkp1ibgBh8" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.sangupta.com/feeds/8202826302890036281/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=3969325917870221979&amp;postID=8202826302890036281&amp;isPopup=true" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/3969325917870221979/posts/default/8202826302890036281?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/3969325917870221979/posts/default/8202826302890036281?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/Azcarya/~3/JVkp1ibgBh8/instagrams-engineering-challenge.html" title="Instagram's Engineering Challenge: The Unshredder" /><author><name>Sandeep Gupta</name><uri>https://profiles.google.com/110645714607919970386</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-fgzHpYBSqzA/AAAAAAAAAAI/AAAAAAAAGLY/n0u9TBuTk4M/s512-c/photo.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://blog.sangupta.com/2011/12/instagrams-engineering-challenge.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CUQFQno7fSp7ImA9WhRQEUk.&quot;"><id>tag:blogger.com,1999:blog-3969325917870221979.post-6082245938844687990</id><published>2011-11-17T19:42:00.001+05:30</published><updated>2011-12-06T09:18:33.405+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-12-06T09:18:33.405+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Code Challenge" /><category scheme="http://www.blogger.com/atom/ns#" term="My Projects" /><category scheme="http://www.blogger.com/atom/ns#" term="Coding Techniques" /><title>The Luhny Bin</title><content type="html">Two days ago, &lt;a href="http://blog.crazybob.org/"&gt;Bob Lee&lt;/a&gt; posted a fun challenge on the &lt;a href="http://blog.crazybob.org/2011/11/coding-challenge-luhny-bin.html"&gt;Luhny Bin&lt;/a&gt;. It was not before a day has passed that I could get to know of the problem and try my hands at it. The delay being attributed to absence of &lt;b&gt;Cygwin&lt;/b&gt; on my Windows machine which was needed to run the test harness (refer original post on details).&lt;br /&gt;
&lt;br /&gt;
Yesterday, I spent most of my time first trying to get the harness running without using Cygwin. The solution was a bit tricky as I had to figure out how the test harness was actually running. Anyhow, my solution is available at &lt;a href="https://github.com/sangupta/luhnybin/blob/master/src/com/squareup/luhnybin/Main.java"&gt;here&lt;/a&gt; wherein I modified the original &lt;tt&gt;Main.java&lt;/tt&gt; file. The change was simple: first, change &lt;tt&gt;mask.sh&lt;/tt&gt; on line &lt;tt&gt;41&lt;/tt&gt; to say &lt;tt&gt;mask.bat&lt;/tt&gt; and second, modify line &lt;tt&gt;81&lt;/tt&gt; to correctly build the process.&lt;br /&gt;
&lt;br /&gt;
Once, I had it setup and after loosing all day, I was ready to start coding the actual solution. Before I dozed off to my bed, I had made sure that my code passed 18 of the 20 tests. The &lt;b&gt;19th test&lt;/b&gt; was tricky. It had many over-lapping &lt;tt&gt;luhn&lt;/tt&gt; numbers, and hence I had some leftover in the end which was not being cleaned up. This single test made me completely rewrite the piece introducing a third buffer (which came down to two, as I directly now wrote to &lt;tt&gt;System.out&lt;/tt&gt;).&lt;br /&gt;
&lt;br /&gt;
Anyways, the solution is now complete and posted on my fork of the &lt;a href="https://github.com/sangupta/luhnybin"&gt;LuhnyBin Github&lt;/a&gt; repository.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3969325917870221979-6082245938844687990?l=blog.sangupta.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/Azcarya/~4/f1qJRDqRJxc" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.sangupta.com/feeds/6082245938844687990/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=3969325917870221979&amp;postID=6082245938844687990&amp;isPopup=true" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/3969325917870221979/posts/default/6082245938844687990?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/3969325917870221979/posts/default/6082245938844687990?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/Azcarya/~3/f1qJRDqRJxc/luhny-bin.html" title="The Luhny Bin" /><author><name>Sandeep Gupta</name><uri>https://profiles.google.com/110645714607919970386</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-fgzHpYBSqzA/AAAAAAAAAAI/AAAAAAAAGLY/n0u9TBuTk4M/s512-c/photo.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://blog.sangupta.com/2011/11/luhny-bin.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CUABQnw_eip7ImA9WhRTGUk.&quot;"><id>tag:blogger.com,1999:blog-3969325917870221979.post-8844734209617607504</id><published>2011-11-10T21:48:00.001+05:30</published><updated>2011-11-10T22:19:13.242+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-11-10T22:19:13.242+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Java" /><category scheme="http://www.blogger.com/atom/ns#" term="Workarounds" /><title>EGit GitHub Commit API and Commit Stats</title><content type="html">While working today with &lt;a href="http://www.eclipse.org/egit"&gt;EGit&lt;/a&gt; for the &lt;a href="https://github.com"&gt;GitHub&lt;/a&gt; API, I found out that there is no way to get the Commit statistics and the various file details. If you ponder over the API details at &lt;a href="http://developer.github.com/v3/repos/commits/"&gt;http://developer.github.com/v3/repos/commits/&lt;/a&gt;,&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="brush: text"&gt;GET /repos/:user/:repo/commits/:sha
&lt;/pre&gt;&lt;br /&gt;
the response for the API contains details about the lines added/deleted in the commit. The response also contains details about the various files that are impacted. See the *stats* and the *files* section below:&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="brush: text"&gt;{
  "url": "https://api.github.com/repos/octocat/Hello-World/commits/6dcb09b5b57875f334f61aebed695e2e4193db5e",
  "sha": "6dcb09b5b57875f334f61aebed695e2e4193db5e",
  "commit": {
    "url": "https://api.github.com/repos/octocat/Hello-World/git/commits/6dcb09b5b57875f334f61aebed695e2e4193db5e",
    "sha": "6dcb09b5b57875f334f61aebed695e2e4193db5e",
    "author": {
      "name": "Monalisa Octocat",
      "email": "support@github.com",
      "date": "2011-04-14T16:00:49Z"
    },
    "committer": {
      "name": "Monalisa Octocat",
      "email": "support@github.com",
      "date": "2011-04-14T16:00:49Z"
    },
    "message": "Fix all the bugs",
    "tree": {
      "url": "https://api.github.com/repos/octocat/Hello-World/tree/6dcb09b5b57875f334f61aebed695e2e4193db5e",
      "sha": "6dcb09b5b57875f334f61aebed695e2e4193db5e"
    }
  },
  "author": {
    "login": "octocat",
    "id": 1,
    "avatar_url": "https://github.com/images/error/octocat_happy.gif",
    "url": "https://api.github.com/users/octocat"
  },
  "committer": {
    "login": "octocat",
    "id": 1,
    "avatar_url": "https://github.com/images/error/octocat_happy.gif",
    "url": "https://api.github.com/users/octocat"
  },
  "parents": [
    {
      "url": "https://api.github.com/repos/octocat/Hello-World/commits/6dcb09b5b57875f334f61aebed695e2e4193db5e",
      "sha": "6dcb09b5b57875f334f61aebed695e2e4193db5e"
    }
  ],
  "stats": {
    "additions": 104,
    "deletions": 4,
    "total": 108
  },
  "files": [
    {
      "filename": "file1.txt",
      "additions": 10,
      "deletions": 2,
      "total": 12
    }
  ]
}
&lt;/pre&gt;&lt;br /&gt;
As I needed these values, I happened to go over the source code for *EGit* and find a way around. Must say, the way the source code is structured makes it super-easy to modify the code for additional API values.&lt;br /&gt;
&lt;br /&gt;
Below are the two simple changes I made to make sure the API returns the details I needed,&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Add the following class &lt;tt&gt;org.eclipse.egit.github.core.Stats&lt;/tt&gt;&lt;/b&gt;&lt;br /&gt;
&lt;pre class="brush: java"&gt;package org.eclipse.egit.github.core;

public class Stats {
 
 private int additions;
 
 private int deletions;
 
 private int total;

 public int getAdditions() {
  return additions;
 }

 public void setAdditions(int additions) {
  this.additions = additions;
 }

 public int getDeletions() {
  return deletions;
 }

 public void setDeletions(int deletions) {
  this.deletions = deletions;
 }

 public int getTotal() {
  return total;
 }

 public void setTotal(int total) {
  this.total = total;
 }

}&lt;/pre&gt;&lt;br /&gt;
&lt;b&gt;Modify the class &lt;tt&gt;org.eclipse.egit.github.core.RepositoryCommit&lt;/tt&gt;&lt;/b&gt; to add the following lines:&lt;br /&gt;
&lt;pre class="brush: java"&gt;private Stats stats;
 
 private List&amp;lt;CommitFile&amp;gt; files;

 public Stats getStats() {
  return stats;
 }

 public void setStats(Stats stats) {
  this.stats = stats;
 }

 public List&amp;lt;CommitFile&amp;gt; getFiles() {
  return files;
 }

 public void setFiles(List&amp;lt;CommitFile&amp;gt; files) {
  this.files = files;
 }
&lt;/pre&gt;&lt;br /&gt;
And we are done. Calling the following API,&lt;br /&gt;
&lt;pre class="brush: java"&gt;public void test() {

    CommitService commitService = new CommitService();

    RepositoryCommit commit = commitService.getCommit(repository, sha);

    System.out.println("Total lines impacted: " + commit.getTotal());

    System.out.println("Total files impacted: " + commit.getFiles().size());
}
&lt;/pre&gt;&lt;br /&gt;
should return back the various statistics as returned by *GitHub*.&lt;br /&gt;
&lt;br /&gt;
Hope this helps!&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Update:&lt;/b&gt; Added the files as a GitHub gist at &lt;a href="https://gist.github.com/1355351"&gt;https://gist.github.com/1355351&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3969325917870221979-8844734209617607504?l=blog.sangupta.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/Azcarya/~4/-zi-drrt0T4" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.sangupta.com/feeds/8844734209617607504/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=3969325917870221979&amp;postID=8844734209617607504&amp;isPopup=true" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/3969325917870221979/posts/default/8844734209617607504?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/3969325917870221979/posts/default/8844734209617607504?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/Azcarya/~3/-zi-drrt0T4/egit-github-commit-api-and-commit-stats.html" title="EGit GitHub Commit API and Commit Stats" /><author><name>Sandeep Gupta</name><uri>https://profiles.google.com/110645714607919970386</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-fgzHpYBSqzA/AAAAAAAAAAI/AAAAAAAAGLY/n0u9TBuTk4M/s512-c/photo.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://blog.sangupta.com/2011/11/egit-github-commit-api-and-commit-stats.html</feedburner:origLink></entry><entry gd:etag="W/&quot;Ak8BSH0zcSp7ImA9WhdbEk8.&quot;"><id>tag:blogger.com,1999:blog-3969325917870221979.post-3495951014372198703</id><published>2011-10-10T12:10:00.001+05:30</published><updated>2011-10-10T12:10:59.389+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-10-10T12:10:59.389+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Creativity Concepts" /><category scheme="http://www.blogger.com/atom/ns#" term="Adobe AIR" /><title>Preview: Connecting Content and Community in the Cloud</title><content type="html">&lt;b&gt;Jay Dutta&lt;/b&gt;, Experience Design Manager and &lt;b&gt;Luanne Seymour&lt;/b&gt;, Sr. Instructional Designer at &lt;a href="http://www.adobe.com"&gt;Adobe&lt;/a&gt; presented a Social Study on how to connect content and community in the cloud at &lt;a href="http://max.adobe.com/attend"&gt;Adobe MAX 2011&lt;/a&gt;.&lt;br /&gt;
As mentioned for the video,&lt;br /&gt;
&lt;blockquote&gt;See how a few simple UX design patterns can facilitate a shared, social learning experience that blurs the boundaries between inspiration and instruction, as well as between content and community. Three trends are currently sweeping digital media: Tablets are moving from content consumption to creation, social features are increasingly pervasive, and everything is shifting to the cloud. Join us to explore how this trifecta creates exciting opportunities for designers and developers, and to examine our own promising effort at taking advantage of these trends.&lt;/blockquote&gt;&lt;br /&gt;
Watch the video on &lt;a href="http://tv.adobe.com/watch/max-2011-envision/social-studies-connecting-content-and-community-in-the-cloud/"&gt;Adobe TV&lt;/a&gt; or,&lt;br /&gt;
&lt;div style="text-align: center;"&gt;&lt;iframe allowfullscreen="" frameborder="0" height="296" scrolling="no" src="http://tv.adobe.com/embed/802/11308/" title="AdobeTV Video Player" width="480"&gt;&lt;/iframe&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/3969325917870221979-3495951014372198703?l=blog.sangupta.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/Azcarya/~4/9YdPYNP8qDs" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.sangupta.com/feeds/3495951014372198703/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=3969325917870221979&amp;postID=3495951014372198703&amp;isPopup=true" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/3969325917870221979/posts/default/3495951014372198703?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/3969325917870221979/posts/default/3495951014372198703?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/Azcarya/~3/9YdPYNP8qDs/preview-connecting-content-and.html" title="Preview: Connecting Content and Community in the Cloud" /><author><name>Sandeep Gupta</name><uri>https://profiles.google.com/110645714607919970386</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-fgzHpYBSqzA/AAAAAAAAAAI/AAAAAAAAGLY/n0u9TBuTk4M/s512-c/photo.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://blog.sangupta.com/2011/10/preview-connecting-content-and.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DUICQX8_cSp7ImA9WhdUF0w.&quot;"><id>tag:blogger.com,1999:blog-3969325917870221979.post-6610685970250149080</id><published>2011-10-04T13:50:00.001+05:30</published><updated>2011-10-04T14:09:20.149+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-10-04T14:09:20.149+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="ActionScript" /><category scheme="http://www.blogger.com/atom/ns#" term="Adobe AIR" /><title>AIR 3.0 Native Extensions and Samples</title><content type="html">Today at &lt;a href="http://max.adobe.com"&gt;MAX 2011&lt;/a&gt;, Adobe &lt;a href="http://blogs.adobe.com/flashplayer/2011/10/adobe-flash-player-11-air-11-available-later-today.html"&gt;released&lt;/a&gt; the latest version of their Flash platform SDKs - Flash Player 11 and AIR 3.0. The most noticeable and exciting amongst &lt;a href="http://blogs.adobe.com/flashplatform/2011/09/announcing-flash-player-11-and-air-3.html"&gt;new features of AIR 3.0&lt;/a&gt; is the introduction of &lt;a href="http://www.adobe.com/devnet/air/articles/extending-air.html"&gt;Native Extensions&lt;/a&gt;. Native Extensions allow a developer to extend the capabilities of the AIR platform by running native code directly from their AIR applications. Quoting from Adobe's site,&lt;br /&gt;
&lt;blockquote&gt;This new capability allows developers to:&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;Achieve deeper integration with target devices&lt;/li&gt;
&lt;li&gt;Incorporate legacy native code in their application&lt;/li&gt;
&lt;li&gt;Achieve maximum performance for critical code&lt;/li&gt;
&lt;/ul&gt;&lt;/blockquote&gt;&lt;br /&gt;
I am not going to delve into what the feature introduces a developer to, for the same one may go ahead and read this &lt;a href="http://www.adobe.com/devnet/air/articles/extending-air.html"&gt;article by Oliver Goldman&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
Following are the links to the various Native Extensions that have been built and are available for ready use:&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;A &lt;a href="http://www.adobe.com/devnet/air/articles/developing-native-extensions-air.html"&gt;Hello World&lt;/a&gt; example to beign with&lt;br /&gt;
&lt;br /&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.adobe.com/devnet/air/native-extensions-for-air/extensions/notification.html"&gt;Push Notification native extension sample&lt;/a&gt; for Android and iOS&lt;br /&gt;
&lt;br /&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.adobe.com/devnet/air/articles/android-licensing-native-extensions.html"&gt;Licensing Adobe AIR applications&lt;/a&gt; on Android&lt;br /&gt;
&lt;br /&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.adobe.com/devnet/air/native-extensions-for-air/extensions/gyroscope.html"&gt;Gyroscope native extension&lt;/a&gt; sample&lt;br /&gt;
&lt;br /&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.adobe.com/devnet/air/native-extensions-for-air/extensions/networkinfo.html"&gt;NetworkInfo native extension&lt;/a&gt; sample&lt;br /&gt;
&lt;br /&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.adobe.com/devnet/air/native-extensions-for-air/extensions/vibration.html"&gt;Vibration native extension&lt;/a&gt; sample&lt;br /&gt;
&lt;br /&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a href="http://custardbelly.com/blog/2011/09/21/air-native-extension-example-ibattery-for-ios/"&gt;iBattery for iOS native extension&lt;/a&gt; sample&lt;br /&gt;
&lt;br /&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a href="http://blog.magicalhobo.com/2011/09/12/air-3-native-extension-imageprocessor/"&gt;Image Processor native extension&lt;/a&gt; sample for Windows&lt;br /&gt;
&lt;br /&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a href="http://blog.aboutme.be/2011/10/02/kinect-native-extension-for-adobe-air/"&gt;Kinect native extension&lt;/a&gt; library&lt;br /&gt;
&lt;br /&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.riaspace.com/2011/09/as3c2dm-air-native-extension-to-push-notifications-with-c2dm/"&gt;Android Cloud to Device Messaging Framework&lt;/a&gt; native extension library&lt;br /&gt;
&lt;br /&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a href="http://blog.magicalhobo.com/2011/10/01/air-3-native-extension-example-pentablet/"&gt;Read Pressure Sensitivity of a Pen Tablet&lt;/a&gt; on Windows&lt;br /&gt;
&lt;br /&gt;
&lt;/li&gt;
&lt;/ul&gt;&lt;br /&gt;
If you know of more example extensions that are publicly available, please drop a comment and I will include them in the list.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3969325917870221979-6610685970250149080?l=blog.sangupta.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/Azcarya/~4/6bxaUpw0ZCo" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.sangupta.com/feeds/6610685970250149080/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=3969325917870221979&amp;postID=6610685970250149080&amp;isPopup=true" title="13 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/3969325917870221979/posts/default/6610685970250149080?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/3969325917870221979/posts/default/6610685970250149080?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/Azcarya/~3/6bxaUpw0ZCo/air-30-native-extensions-and-samples.html" title="AIR 3.0 Native Extensions and Samples" /><author><name>Sandeep Gupta</name><uri>https://profiles.google.com/110645714607919970386</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-fgzHpYBSqzA/AAAAAAAAAAI/AAAAAAAAGLY/n0u9TBuTk4M/s512-c/photo.jpg" /></author><thr:total>13</thr:total><feedburner:origLink>http://blog.sangupta.com/2011/10/air-30-native-extensions-and-samples.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CUEHQnwzeyp7ImA9WhdUEEw.&quot;"><id>tag:blogger.com,1999:blog-3969325917870221979.post-5401651689116368863</id><published>2011-09-26T10:37:00.000+05:30</published><updated>2011-09-26T10:37:13.283+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-09-26T10:37:13.283+05:30</app:edited><title>Function Overloading in ActionScript</title><content type="html">We all know that function overloading, or for that matter Constructor overloading, is not supported in ActionScript. This is not a big deterrent till what you are writing your own code, but becomes a major blocker when you plan to port some code from a code piece written in another language. Recently, I have started migrating one of the de-facto open-source Java software to ActionScript. And the piece is huge. Giving different names to each overloaded method and then making sure that you call the right one tends to get complicated.&lt;br /&gt;
&lt;br /&gt;
Assigning a variable &lt;tt&gt;Object&lt;/tt&gt; to method arguments and then writing the overloaded method is so so messy and ugly. While porting this piece, this problem had been in my mind for almost a week now, and today morning it occurred that I could use &lt;tt&gt;abstraction&lt;/tt&gt; to solve my problem. To outline the methodology I adopted to solve this problem is as under. Suppose you have the following java code, &lt;br /&gt;
&lt;pre class="brush: java"&gt;public class Example {

    public void method(int x) { ... }

    public void method(int x, int y) { .... }

    public void method(String x) { .... }

    public void method(int x, String y) { .... }

}&lt;/pre&gt;&lt;br /&gt;
The most commonly used methodology when porting to ActionScript would be,&lt;br /&gt;
&lt;pre class="brush: as3"&gt;public class Example {

    public function method(x:*, y:* = undefined):void {
        if(x is int &amp;&amp; y is undefined) { ... }

        else if(x is String &amp;&amp; y is undefined) { ... }

        else if(x is int &amp;&amp; y is int) { .... }

        else if(x is int &amp;&amp; y is String) { ... }
    }

}&lt;/pre&gt;&lt;br /&gt;
This method has its own disadvantages as it looses type safety. We can thus utilize abstraction to make sure that we achieve the method overloading without loosing the type safety as below. First, define a marker interface that indicates that a given class encapsulates arguments for a given method, such as,&lt;br /&gt;
&lt;pre class="brush: as3"&gt;public interface IMethodArguments {

}
&lt;/pre&gt;Next define one class for each of the arguments type and the number of arguments as,&lt;br /&gt;
&lt;pre class="brush: as3"&gt;public class SingleIntegerArguments implements IMethodArguments {

    public var x:int;

}

public class TwoIntegerArguments implements IMethodArguments {

    public var x:int;

    public var y:int;

}

public class SingleStringArguments implements IMethodArguments {

    public var x:String;

}

public class IntegerStringArguments implements IMethodArguments {

    public var x:int;

    public var y:String;

}
&lt;/pre&gt;Lastly, modify the original method to check against the implementing class of the object passed as argument. This makes sure that none of the variables declared anyplace is of type &lt;tt&gt;Object&lt;/tt&gt; or &lt;tt&gt;Variable '*'&lt;/tt&gt;.&lt;br /&gt;
&lt;pre class="brush: as3"&gt;public class Example {

    public function method(argument:IMethodArguments):void {
        if(argument is SingleIntegerArguments {
            ...
        } else if(argument is TwoIntegerArguments) {
            ...
        } else if(argument is SingleStringArguments) {
            ...
        } else if(argument is IntegerStringArguments) {
            ...
        }
    }
}&lt;/pre&gt;&lt;br /&gt;
The method outlined here is nothing novel but just a different approach to providing a functionality that is very common in the programming world in a type-safe way.&lt;br /&gt;
&lt;br /&gt;
Hope this helps.&lt;br /&gt;
&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3969325917870221979-5401651689116368863?l=blog.sangupta.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/Azcarya/~4/mOXXpT97Gnc" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.sangupta.com/feeds/5401651689116368863/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=3969325917870221979&amp;postID=5401651689116368863&amp;isPopup=true" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/3969325917870221979/posts/default/5401651689116368863?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/3969325917870221979/posts/default/5401651689116368863?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/Azcarya/~3/mOXXpT97Gnc/function-overloading-in-actionscript.html" title="Function Overloading in ActionScript" /><author><name>Sandeep Gupta</name><uri>https://profiles.google.com/110645714607919970386</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-fgzHpYBSqzA/AAAAAAAAAAI/AAAAAAAAGLY/n0u9TBuTk4M/s512-c/photo.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://blog.sangupta.com/2011/09/function-overloading-in-actionscript.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DkQBQHY4fSp7ImA9WhdVFko.&quot;"><id>tag:blogger.com,1999:blog-3969325917870221979.post-2183895486792508447</id><published>2011-09-22T12:21:00.003+05:30</published><updated>2011-09-22T12:22:31.835+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-09-22T12:22:31.835+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Coding Techniques" /><category scheme="http://www.blogger.com/atom/ns#" term="Interview Questions" /><title>parseDouble() in Java</title><content type="html">&lt;tt&gt;Problem:&lt;/tt&gt; Impement the &lt;b&gt;Double.parseDouble()&lt;/b&gt; method of Java.&lt;br /&gt;
&lt;br /&gt;
&lt;tt&gt;Solution:&lt;/tt&gt; A classic interview problem where one needs to check in for all boundary combinations and all representations of a number. The following number representations are perfectly fine and should be accounted for,&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;23&lt;/li&gt;
&lt;li&gt;+23&lt;/li&gt;
&lt;li&gt;-23&lt;/li&gt;
&lt;li&gt;+0.23&lt;/li&gt;
&lt;li&gt;-0.23&lt;/li&gt;
&lt;li&gt;.23&lt;/li&gt;
&lt;li&gt;-.23&lt;/li&gt;
&lt;li&gt;00000.23&lt;/li&gt;
&lt;li&gt;0.23000000&lt;/li&gt;
&lt;/ul&gt;&lt;br /&gt;
The code for the same is as under, and is also available on &lt;a href="https://github.com/sangupta/BlogExamples/blob/master/KeepWalking/src/com/sangupta/keepwalking/ParseDouble.java"&gt;GitHub&lt;/a&gt; for reference.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="brush: java"&gt;/**
 * Copyright (C) 2011, Sandeep Gupta
 * http://www.sangupta.com
 * 
 * The file is licensed under the the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * 
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * 
 */

package com.sangupta.keepwalking;


/**
 * A simple Java implementation of the Java's &lt;code&gt;Double.parseDouble()&lt;/code&gt; function.
 * 
 * @author Sandeep Gupta &lt;a href="http://www.sangupta.com"&gt;[email]&lt;/a&gt;
 * @version 1.0
 * @since 22 Sep 2011
 */
public class ParseDouble {
	
	/**
	 * Some tests to run.
	 * 
	 * @param args
	 */
	public static void main(String[] args) {
		System.out.println(parseDouble(".23"));
	}

	/**
	 * A simple implementation that takes a number as a string and converts it
	 * to a double method, similar to what &lt;code&gt;Double.parseDouble()&lt;/code&gt; does.
	 * 
	 * The following number values are supported,
	 * +23
	 * -23
	 * +0.23
	 * +.23
	 * 0.23
	 * .23
	 * 0000.23
	 * 0.23000
	 * 
	 * @param string the string representation of the number
	 * @return the double value
	 * @throws NumberFormatException if the string does not represent a number or is malformed
	 */
	private static double parseDouble(String num) {
		if(num == null || "".equals(num.trim())) {
			throw new NumberFormatException("Number cannot be null/empty.");
		}
		
		// remove any leading or trailing spaces
		num = num.trim();
		final int size = num.length();
		
		// holds the starting position of the digits
		int index = 0;
		boolean isNegative = false;
		boolean hasDecimal = false;
		
		// check for unary operators
		char first = num.charAt(0);
		switch(first) {
			case '+':
				index++;
				break;
				
			case '-':
				index++;
				isNegative = true;
				break;
				
			case '.':
				index++;
				hasDecimal = true;
				break;
				
			default:
				throw new NumberFormatException("Number is malformed: " + num); 
		}
		
		// start the parsing logic
		
		double ip = 0.0, dp = 0.0;
		double fd = 1.0;
		
		for(int i = index; i &lt; size; i++) {
			char c = num.charAt(i);
			int digit = c - '0';
			
			if(isNumeric(c) &amp;&amp; digit != '0') {
				if(!hasDecimal) {
					ip *= 10;
					ip += digit;
				} else {
					dp *= 10;
					dp += digit;
					fd *= 10;
				}
			} else if(c == '.') {
				if(hasDecimal) {
					throw new NumberFormatException("Number is malformed: " + num);
				}
				
				hasDecimal = true;
			} else {
				throw new NumberFormatException("Number is malformed: " + num);
			}
		}
		
		// add the decimal fraction
		dp = dp / fd;
		double number = ip + dp;
		
		// test for negative
		if(isNegative) {
			number = 0 - number;
		}
		
		return number;
	}

	/**
	 * Tests whether the given character is a digit or not.
	 * 
	 * @param digit the character to be tested
	 * @return &lt;code&gt;true&lt;/code&gt; if character is a digit, else &lt;code&gt;false&lt;/code&gt;
	 */
	private static boolean isNumeric(char digit) {
		if('0' &lt;= digit &amp;&amp; digit &lt;= '9') {
			return true;
		}
		
		return false;
	}
	
}
&lt;/pre&gt;
&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3969325917870221979-2183895486792508447?l=blog.sangupta.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/Azcarya/~4/ffANnh9S_v0" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.sangupta.com/feeds/2183895486792508447/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=3969325917870221979&amp;postID=2183895486792508447&amp;isPopup=true" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/3969325917870221979/posts/default/2183895486792508447?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/3969325917870221979/posts/default/2183895486792508447?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/Azcarya/~3/ffANnh9S_v0/problem-impement-double.html" title="parseDouble() in Java" /><author><name>Sandeep Gupta</name><uri>https://profiles.google.com/110645714607919970386</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-fgzHpYBSqzA/AAAAAAAAAAI/AAAAAAAAGLY/n0u9TBuTk4M/s512-c/photo.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://blog.sangupta.com/2011/09/problem-impement-double.html</feedburner:origLink></entry><entry gd:etag="W/&quot;C04DRH49fSp7ImA9WhdVFE8.&quot;"><id>tag:blogger.com,1999:blog-3969325917870221979.post-3658094829345683594</id><published>2011-09-19T14:06:00.001+05:30</published><updated>2011-09-19T14:16:15.065+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-09-19T14:16:15.065+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="My Projects" /><category scheme="http://www.blogger.com/atom/ns#" term="Adobe AIR" /><title>FRAG for Free Rice</title><content type="html">&lt;a href="http://www.freerice.com"&gt;Free Rice&lt;/a&gt; is a site that helps one improve their English vocabulary (the first feature/section they rolled). Quite Simple, huh? No - for every word one gets right they donate 10 grains of rice to the World Food Programme to help end hunger. The cause itself along with the methodology they employ makes it a huge attraction. I am addicted to the game myself, but the professional commitments do not let me make the most of it.&lt;br /&gt;
&lt;br /&gt;
Thus, I decided to use some of my skills to better use... and developed &lt;b&gt;FRAG - Free Rice Avant Garde&lt;/b&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://en.wikipedia.org/wiki/Frag_(video_gaming)"&gt;Frag&lt;/a&gt; as per &lt;a href="http://en.wikipedia.org"&gt;Wikipedia&lt;/a&gt; is,&lt;br /&gt;
&lt;blockquote&gt;Frag is a computer and video game term originating from the word fragging, a term indicating to kill an unpopular superior officer with a fragmentation grenade. A frag is roughly equivalent to "kill", with the typical main difference that the player being "fragged" can instantly respawn (play again) in most games, i.e. the "kill" is only temporary&lt;/blockquote&gt;&lt;br /&gt;
&lt;a href="http://en.wikipedia.org/wiki/Avant-garde"&gt;Avant Garde&lt;/a&gt; as per &lt;a href="http://en.wikipedia.org"&gt;Wikipedia&lt;/a&gt; is,&lt;br /&gt;
&lt;blockquote&gt;Avant-garde means "advance guard" or "vanguard". The adjective form is used in English to refer to people or works that are experimental or innovative, particularly with respect to art, culture, and politics.&lt;/blockquote&gt;&lt;br /&gt;
Thus, FRAGs is an automated bot that &lt;b&gt;kills&lt;/b&gt; the hunger monster, by experimenting with technology where the arena relates to art and culture.&lt;br /&gt;
&lt;br /&gt;
Simply, FRAGs for FreeRice is an automated bot that can play the game on your behalf. It comes with its own memory of answers, but is geared to keep building its memory as and when more questions are added to the game. It can play at a rate of 1 question every 3 seconds, thus accumulating 200 grains of rice every minute, or more than 0.25 million grains per day. Currently, the bot can play the following subjects,&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;Algebra&lt;/li&gt;
&lt;li&gt;Capitals&lt;/li&gt;
&lt;li&gt;English Vocabulary&lt;/li&gt;
&lt;li&gt;Multiplication&lt;/li&gt;
&lt;li&gt;Paintings&lt;/li&gt;
&lt;li&gt;Periodic Table&lt;/li&gt;
&lt;/ul&gt;&lt;br /&gt;
The bot is written in &lt;a href="http://get.adobe.com/air"&gt;Adobe AIR&lt;/a&gt; technology and demonstrates how one can interact between the HTML of a loaded page with &lt;tt&gt;ActionScript&lt;/tt&gt;.&lt;br /&gt;
&lt;br /&gt;
The source code for the bot is available on &lt;a href="http://github.com/sangupta/frag"&gt;GitHub&lt;/a&gt;. A downloadable binary will be available soon.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3969325917870221979-3658094829345683594?l=blog.sangupta.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/Azcarya/~4/AwUfN-QATMg" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.sangupta.com/feeds/3658094829345683594/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=3969325917870221979&amp;postID=3658094829345683594&amp;isPopup=true" title="3 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/3969325917870221979/posts/default/3658094829345683594?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/3969325917870221979/posts/default/3658094829345683594?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/Azcarya/~3/AwUfN-QATMg/frag-for-free-rice.html" title="FRAG for Free Rice" /><author><name>Sandeep Gupta</name><uri>https://profiles.google.com/110645714607919970386</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-fgzHpYBSqzA/AAAAAAAAAAI/AAAAAAAAGLY/n0u9TBuTk4M/s512-c/photo.jpg" /></author><thr:total>3</thr:total><feedburner:origLink>http://blog.sangupta.com/2011/09/frag-for-free-rice.html</feedburner:origLink></entry><entry gd:etag="W/&quot;C08CSXo7eCp7ImA9WhdWE0U.&quot;"><id>tag:blogger.com,1999:blog-3969325917870221979.post-8067648911607556014</id><published>2011-09-07T13:21:00.000+05:30</published><updated>2011-09-07T13:21:08.400+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-09-07T13:21:08.400+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Project Euler" /><title>Project Euler Problem 348 Solution</title><content type="html">&lt;b&gt;&lt;u&gt;Problem&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;
Many numbers can be expressed as the sum of a square and a cube. Some of them in more than one way.&lt;br /&gt;
&lt;br /&gt;
Consider the palindromic numbers that can be expressed as the sum of a square and a cube, both greater than 1, in &lt;b&gt;exactly&lt;/b&gt; 4 different ways.&lt;br /&gt;
For example, 5229225 is a palindromic number and it can be expressed in exactly 4 different ways:&lt;br /&gt;
&lt;br /&gt;
2285&lt;sup&gt;2&lt;/sup&gt; + 20&lt;sup&gt;3&lt;/sup&gt;&lt;br /&gt;
2223&lt;sup&gt;2&lt;/sup&gt; + 66&lt;sup&gt;3&lt;/sup&gt;&lt;br /&gt;
1810&lt;sup&gt;2&lt;/sup&gt; + 125&lt;sup&gt;3&lt;/sup&gt;&lt;br /&gt;
1197&lt;sup&gt;2&lt;/sup&gt; + 156&lt;sup&gt;3&lt;/sup&gt;&lt;br /&gt;
&lt;br /&gt;
Find the sum of the five smallest such palindromic numbers.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;u&gt;Analysis&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;
The given palindrome number is 7 digit. Hence, we start iterating with all palindromes that are atleast 7 digits in length and go up to the point where we find the first 5 palindromes satisfying the given condition. Finding palindromes iterating over a sequence is time consuming, hence, create a small function that generates only palindromes.&lt;br /&gt;
&lt;br /&gt;
For a palindrome of digit length n, when n is even, a simple loop of n/2 digits can be run. Thus for palindromes of length 4, a loop from 10 to 99 can be run, where the number and its reverse are appended. Similarly for a palindrome of digit length n, when n is odd, a first loop for (n - 1)/2 digits and a second loop from 0 to 9 can be run. Thus for palindromes with a length 5, run an outerloop from 10 to 99 and an inner loop from 0 to 9. Concatenate the number, the middle element and the reverse of the number to generate the palindromes.&lt;br /&gt;
&lt;br /&gt;
To check for the given condition that the number be expressed as a sum of square and cube, where both numbers are greater than 2. Simply run a loop from 2 to cube root of number minus 4 (for the square will be of atleast 2). Then see if the square root is perfect or not. Keep counting valid combinations. If a number has 4 such combinations consider it for the solution.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;u&gt;Solution&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;
Code part of &lt;a href="https://github.com/sangupta/maer"&gt;Project Maer on Github&lt;/a&gt;. Runs under 2 seconds in Java 6.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="brush: java"&gt;package com.sangupta.maer.page7;

import com.sangupta.maer.util.MathUtil;

/**
 * Problem 348 on Project Euler, http://projecteuler.net/index.php?section=problems&amp;id=348
 *
 * @author &lt;a href="http://www.sangupta.com"&gt;Sandeep Gupta&lt;/a&gt;
 * @since 06-Sep-2011
 */
public class Problem348 {
	
	private static int found = 0;
	
	private static long sum = 0;

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		iterateOnPalindromes(7, 12);
		System.out.println("Sum: " + sum);
	}
	
	private static void iterateOnPalindromes(final int startDigits, final int maxDigits) {
		for(int numDigits = startDigits; numDigits &lt;= maxDigits; numDigits++) {
			if(MathUtil.isEven(numDigits)) {
				long end = (long) Math.pow(10, (numDigits / 2));
				long start = end / 10;
				
				// loop
				for(long i = start; i &lt; end; i++) {
					String palindrome = String.valueOf(i);
					palindrome = palindrome + new StringBuilder(palindrome).reverse().toString();
					boolean stopLoop = checkPalindrome(palindrome);
					if(stopLoop) {
						return;
					}
				}
			} else {
				// this is odd digit based
				int digitGroupLength = numDigits - 1;
				long end = (long) Math.pow(10, (digitGroupLength / 2));
				long start = end / 10;
				
				// loop
				for(long i = start; i &lt; end; i++) {
					// the middle digit comes from the second loop
					for(int middle = 0; middle &lt; 10; middle++) {
						String palindrome = String.valueOf(i);
						palindrome = palindrome + String.valueOf(middle) + new StringBuilder(palindrome).reverse().toString();
						boolean stopLoop = checkPalindrome(palindrome);
						if(stopLoop) {
							return;
						}
					}
				}				
			}
		}
	}

	/**
	 * @param palindrome
	 * @return
	 */
	private static boolean checkPalindrome(String palindrome) {
		Long number = Long.parseLong(palindrome);
		if(isPalindromeRepresentable(number)) {
			System.out.println("Found " + number);
			found++;
			sum += number;
		}
		
		if(found == 5) {
			return true;
		}
		return false;
	}

	private static boolean isPalindromeRepresentable(final long number) {
		int cubeLimit = (int) Math.cbrt(number - 4);
		
		int countForms = 0;
		
		for(int testNumber = 2; testNumber &lt;= cubeLimit; testNumber++) {
			int cube = testNumber * testNumber * testNumber;
			long diff = number - cube;
			double squareRoot = Math.sqrt(diff);
			int intSquareRoot = (int) squareRoot;
			if(squareRoot == intSquareRoot) {
				countForms++;
			}
		}
		
		if(countForms == 4) {
			return true;
		}
		
		return false;
	}
}&lt;/pre&gt;
&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3969325917870221979-8067648911607556014?l=blog.sangupta.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/Azcarya/~4/f0vhhzitdyo" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.sangupta.com/feeds/8067648911607556014/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=3969325917870221979&amp;postID=8067648911607556014&amp;isPopup=true" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/3969325917870221979/posts/default/8067648911607556014?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/3969325917870221979/posts/default/8067648911607556014?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/Azcarya/~3/f0vhhzitdyo/project-euler-problem-348-solution.html" title="Project Euler Problem 348 Solution" /><author><name>Sandeep Gupta</name><uri>https://profiles.google.com/110645714607919970386</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-fgzHpYBSqzA/AAAAAAAAAAI/AAAAAAAAGLY/n0u9TBuTk4M/s512-c/photo.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://blog.sangupta.com/2011/09/project-euler-problem-348-solution.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CUcCQns8fip7ImA9WhdRE0s.&quot;"><id>tag:blogger.com,1999:blog-3969325917870221979.post-902271578107834045</id><published>2011-08-03T14:47:00.001+05:30</published><updated>2011-08-03T14:47:43.576+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-08-03T14:47:43.576+05:30</app:edited><title>Magic of flash.trace.Trace</title><content type="html">One of the hidden treasures in the Flash Player is the &lt;tt&gt;flash.trace.Trace&lt;/tt&gt; class. It was meant to be hidden, but in open-source nothing can be treasured without the world knowing it. The actual class implementation is available in the &lt;a href="http://hg.mozilla.org/tamarin-central/file/e774dfe22b39/extensions/Trace.as"&gt;tamarin-central&lt;/a&gt; codebase. An excerpt of the class implementation is as under (copyright notices etc removed),&lt;br /&gt;
&lt;pre class="brush:as3"&gt;package flash.trace
	public class Trace
	{
		/* levels of desired logging */
		public static const OFF:int = 0;
		public static const METHODS:int = 1;						// method entry only 
		public static const METHODS_WITH_ARGS:int = 2;				// method entry and arguments
		public static const METHODS_AND_LINES:int = 3;				// method entry and line numbers
		public static const METHODS_AND_LINES_WITH_ARGS:int = 4;	// method entry, arguments and line numbers

		/* used to select either file or listener callback logging. */
		public static const FILE = 1;
		public static const	LISTENER = 2;

		public static native function setLevel(l:int, target:int=LISTENER);
		public static native function getLevel(target:int=LISTENER):int;

		/**
		 * Register a listener to receive trace callbacks upon method and/or 
		 * line number changes.  Passing null to this function effectively
		 * 'unregisters' the listener and only a single listener can 
		 *  be specified.
		 * 
		 *  The callback funcition must have the following signature:
		 *
		 *     function foo(file_name:String, linenum:int, method_name:String, method_args:String):void
		 *
		 *  Depending upon the setting of the trace level, 2 or more arguments may be non-empty.  
		 *  In all cases file_name and method_name are obtained and passed to the callback.  If 
		 *  the trace level include line numbers information then this value is also obtained 
		 *  and passed into the callback.  Setting the trace level to include method arguments implies
		 *  that the 'method_args' parameter will be filled with string representation of the arguments
		 *  passed into the call.
		 */
		public static native function setListener(f:Function);
		public static native function getListener():Function;
	};
};&lt;/pre&gt;&lt;br /&gt;
Harnessing the power of the same in ActionScript is easy. &lt;b&gt;The magic lies in the fact that for every executed line, the listener as provided in the class above would be called, giving out the class name, the method name, the file name, and yes, the method arguments as well.&lt;/b&gt; Don't believe it. Try it.&lt;br /&gt;
&lt;br /&gt;
The following class is a wrapper over the &lt;tt&gt;flash.trace.Trace&lt;/tt&gt; class to see the code execution between two points.&lt;br /&gt;
&lt;pre class="brush:as3"&gt;package com.sangupta.utils
{
	import flash.trace.Trace;

	public class TraceUtility {
		
		private static var init:Boolean = false;
		
		private static var linesExecuted:uint = 0;
		
		public function TraceUtility() {
			super();
		}
		
		public static function startTracing():void {
			if(!init) {
				Trace.setListener(traceListener);
				init = true;
			}
			
			Trace.setLevel(Trace.METHODS_AND_LINES_WITH_ARGS, Trace.LISTENER);
		}
		
		public static function stopTracing():void {
			Trace.setLevel(Trace.OFF, Trace.LISTENER);
			trace('Total lines executed: ' + linesExecuted);
			linesExecuted = 0;
		}
		
		private static function traceListener(fileInfo:String, lineNumber:String, classAndMethod:String, methodArguments:String):void {
			linesExecuted++;
			trace(classAndMethod + '(' + methodArguments + ')'); 
		}
	}
}&lt;/pre&gt;&lt;br /&gt;
Usage is simple in a class, say, &lt;i&gt;MyWorker&lt;/i&gt;:&lt;br /&gt;
&lt;pre class="brush:as3"&gt;package com.sangupta.utils
{
	import TraceUtility;

	public class TraceUtilityTest {
		
		public function myWorkingMethod():void {
			TraceUtility.startTracing();

			// do something expensive here

			TraceUtility.stopTracing();
		}
		
	}
}&lt;/pre&gt;&lt;br /&gt;
&lt;b&gt;Notes:&lt;/b&gt; First, as for every executed line the listener is called, this will slow down the execution of the code. Second, this is not meant to replace the &lt;b&gt;Application Profiling&lt;/b&gt; workflows. Lastly, in a nutshell, this technique should not be used in releasable code.&lt;br /&gt;
&lt;br /&gt;
Hope this helps.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3969325917870221979-902271578107834045?l=blog.sangupta.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/Azcarya/~4/ttsG0d4K2C0" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.sangupta.com/feeds/902271578107834045/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=3969325917870221979&amp;postID=902271578107834045&amp;isPopup=true" title="1 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/3969325917870221979/posts/default/902271578107834045?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/3969325917870221979/posts/default/902271578107834045?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/Azcarya/~3/ttsG0d4K2C0/magic-of-flashtracetrace.html" title="Magic of flash.trace.Trace" /><author><name>Sandeep Gupta</name><uri>https://profiles.google.com/110645714607919970386</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-fgzHpYBSqzA/AAAAAAAAAAI/AAAAAAAAGLY/n0u9TBuTk4M/s512-c/photo.jpg" /></author><thr:total>1</thr:total><feedburner:origLink>http://blog.sangupta.com/2011/08/magic-of-flashtracetrace.html</feedburner:origLink></entry><entry gd:etag="W/&quot;Ak8HR3s5fCp7ImA9WhdREkU.&quot;"><id>tag:blogger.com,1999:blog-3969325917870221979.post-8876724432493768922</id><published>2011-08-02T18:10:00.001+05:30</published><updated>2011-08-02T18:10:36.524+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-08-02T18:10:36.524+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Just Like That" /><title>Agam | Adobe Flash Platform Summit</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;I recently had the chance of attending my first &lt;a href="http://www.adobesummit.com/"&gt;Adobe Flash Platform Summit&lt;/a&gt;. The whole experience was just awesome, and this I say not because I am currently with &lt;a href="http://www.adobe.com/"&gt;Adobe&lt;/a&gt;, but for the wealth of information, tips and tricks, demos and tutorials, the evangelist team shared. The sessions had packed a lot of information, which to grasp in the given time frame was difficult. Add to it the magical Bangalore weather and the tasty south indian dishes for lunch, my experience enhances many a folds.&lt;br /&gt;
&lt;br /&gt;
Anyways, this post is not about the shared information (there will be more later), but about the best time and/or session, we had in the summit. To disappoint all the geeks, what am I talking of is &lt;br /&gt;
the live performance of the contemporary carnatic rock band, &lt;a href="http://www.agamtheband.in/"&gt;Agam&lt;/a&gt;. What made it more enjoyable was the fact that all group members are engineers of the IT industry (gosh, where do they find time from) from companies like &lt;a href="http://www.adobe.com/"&gt;Adobe&lt;/a&gt;, &lt;a href="http://www.yahoo.com/"&gt;Yahoo!&lt;/a&gt; and more.&lt;br /&gt;
&lt;br /&gt;
More on Agam in their own words,&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote&gt;GENRES&lt;br /&gt;
Rock / Carnatic / Experimental&lt;br /&gt;
&lt;br /&gt;
LOCATION&lt;br /&gt;
Bangalore, IN&lt;br /&gt;
&lt;br /&gt;
MEMBERS&lt;br /&gt;
Harish - Vox&lt;br /&gt;
Ganesh - Drums&lt;br /&gt;
Praveen &amp;amp; Suraj - Guitars&lt;br /&gt;
Vignesh - Bass&lt;br /&gt;
Shiva - Percussions&lt;br /&gt;
Swamy - Keys&lt;/blockquote&gt;&lt;br /&gt;
The groups &lt;a href="http://www.agamtheband.in/"&gt;site&lt;/a&gt; features all their songs ready to be enjoyed. I will recommend &lt;b&gt;Brahma's Dance&lt;/b&gt; to one and all.&lt;br /&gt;
&lt;br /&gt;
Next is the snapshot of the memoirs I will always cherish.&lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/-sS4KHhKia3g/TjfvklZLNYI/AAAAAAAAGKk/KMVsPeZllgM/s1600/IMAG0665.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="380" src="http://3.bp.blogspot.com/-sS4KHhKia3g/TjfvklZLNYI/AAAAAAAAGKk/KMVsPeZllgM/s640/IMAG0665.jpg" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
Go and enjoy some good music. Thanks &lt;a href="http://www.agamtheband.in/"&gt;Agam&lt;/a&gt;!&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3969325917870221979-8876724432493768922?l=blog.sangupta.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/Azcarya/~4/ese-vQoXqMM" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.sangupta.com/feeds/8876724432493768922/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=3969325917870221979&amp;postID=8876724432493768922&amp;isPopup=true" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/3969325917870221979/posts/default/8876724432493768922?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/3969325917870221979/posts/default/8876724432493768922?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/Azcarya/~3/ese-vQoXqMM/agam-adobe-flash-platform-summit.html" title="Agam | Adobe Flash Platform Summit" /><author><name>Sandeep Gupta</name><uri>https://profiles.google.com/110645714607919970386</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-fgzHpYBSqzA/AAAAAAAAAAI/AAAAAAAAGLY/n0u9TBuTk4M/s512-c/photo.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://3.bp.blogspot.com/-sS4KHhKia3g/TjfvklZLNYI/AAAAAAAAGKk/KMVsPeZllgM/s72-c/IMAG0665.jpg" height="72" width="72" /><thr:total>0</thr:total><georss:featurename>Bengaluru, Karnataka, India</georss:featurename><georss:point>12.9715987 77.5945627</georss:point><georss:box>12.9715987 77.5945627 12.9715987 77.5945627</georss:box><feedburner:origLink>http://blog.sangupta.com/2011/08/agam-adobe-flash-platform-summit.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CkEEQHw_eip7ImA9WhdTFkw.&quot;"><id>tag:blogger.com,1999:blog-3969325917870221979.post-5658304608585684597</id><published>2011-07-14T08:00:00.000+05:30</published><updated>2011-07-14T08:00:01.242+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-07-14T08:00:01.242+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Java" /><category scheme="http://www.blogger.com/atom/ns#" term="Interview Questions" /><title>In-Place Character Array Compression</title><content type="html">&lt;tt&gt;Problem: &lt;/tt&gt;Given a character stream as an array, compress the characters in place appending the number of continuous characters by the numerical value and then the character. The array is terminated by a &lt;tt&gt;0x00&lt;/tt&gt; character.&lt;br /&gt;
&lt;br /&gt;
&lt;tt&gt;Solution: &lt;/tt&gt;Another classic interview problem which tests multiple skills in a single problem, namely,&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;Conversion from integer to ascii - the number returned is a integral value which needs to be converted to ascii and then put in place in stream&lt;/li&gt;
&lt;li&gt;Skills with pointers (not the &lt;tt&gt;real&lt;/tt&gt; pointers) when operating on an array&lt;/li&gt;
&lt;/ul&gt;&lt;br /&gt;
The following JAVA code illustrates how to work up the given problem. It makes use of an &lt;tt&gt;&lt;b&gt;itoa()&lt;/b&gt;&lt;/tt&gt; method that was explained before &lt;a href=""&gt;here&lt;/a&gt;.&lt;br /&gt;
&lt;pre class="brush:java"&gt;package com.sangupta.keepwalking;

public class CharacterArrayCompression {

	public static void main(String[] args) {
		String stream = "aaaaaaaaaaaaaaaaaaaaabbbbbbssssskkkkjkkdkksdkkkdeeeekkllsssiii";
		char[] characters = stream.toCharArray();
		compress(characters);
		System.out.println(characters);
	}

	private static void compress(char[] characters) {
		if(characters == null || characters.length &lt;= 1) {
			// do nothing if we are not provided with any data
			// or if we have a single character
			return;
		}
		
		char current = characters[0];
		int count = 1;
		int destination = 0;
		for(int index = 1; index &lt; characters.length; index++) {
			char found = characters[index];
			if(current == found) {
				count++;
			} else {
				// compress and store the value
				if(count &gt; 1) {
					char[] value = IntegerToAscii.itoa(count);
					for(int j = 0; j &lt; value.length; j++) {
						char temp = value[j];
						if(temp != '\0') {
							characters[destination++] = temp;
						}
					}
				}
				characters[destination++] = current;
				
				// reset to the new occurence of character
				current = found;
				count = 1;
			}
		}
		
		for(int index = destination; index &lt; characters.length; index++) {
			characters[index] = '\0';
		}
	}

}&lt;/pre&gt;
&lt;br /&gt;
Happy Coding!&lt;br /&gt;
&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3969325917870221979-5658304608585684597?l=blog.sangupta.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/Azcarya/~4/SpDrXIKdgNE" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.sangupta.com/feeds/5658304608585684597/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=3969325917870221979&amp;postID=5658304608585684597&amp;isPopup=true" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/3969325917870221979/posts/default/5658304608585684597?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/3969325917870221979/posts/default/5658304608585684597?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/Azcarya/~3/SpDrXIKdgNE/in-place-character-array-compression.html" title="In-Place Character Array Compression" /><author><name>Sandeep Gupta</name><uri>https://profiles.google.com/110645714607919970386</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-fgzHpYBSqzA/AAAAAAAAAAI/AAAAAAAAGLY/n0u9TBuTk4M/s512-c/photo.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://blog.sangupta.com/2011/07/in-place-character-array-compression.html</feedburner:origLink></entry><entry gd:etag="W/&quot;C0MBSHs_eip7ImA9WhdTFUg.&quot;"><id>tag:blogger.com,1999:blog-3969325917870221979.post-6778854910325194765</id><published>2011-07-13T15:34:00.000+05:30</published><updated>2011-07-13T15:34:19.542+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-07-13T15:34:19.542+05:30</app:edited><title>Make Sharing Easy</title><content type="html">Yesterday a very dear friend of mine, &lt;a href="http://rajat.ahuja.name/blog/about-rajat"&gt;Rajat Ahuja&lt;/a&gt; suggested me to add a &lt;b&gt;Facebook Like&lt;/b&gt; or a &lt;b&gt;Google +1&lt;/b&gt; button to the blog so that sharing becomes easy. As this was something I had turned off a while back, bringing it in was not so tough. Hence, from just now all over my blog the following 3 buttons will appear along with the usual &lt;b&gt;ReTweet&lt;/b&gt; button,&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;Facebook Like button&lt;/li&gt;
&lt;li&gt;Google Buzz button&lt;/li&gt;
&lt;li&gt;Google +1 button&lt;/li&gt;
&lt;/ul&gt;&lt;br /&gt;
I might turn off the &lt;tt&gt;Google Buzz&lt;/tt&gt; button, again, due to my personal aversion to its color combination :)&lt;br /&gt;
&lt;br /&gt;
Thanks a lot, &lt;b&gt;Rajat&lt;/b&gt; for suggestion.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3969325917870221979-6778854910325194765?l=blog.sangupta.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/Azcarya/~4/NHqB-J93NFA" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.sangupta.com/feeds/6778854910325194765/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=3969325917870221979&amp;postID=6778854910325194765&amp;isPopup=true" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/3969325917870221979/posts/default/6778854910325194765?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/3969325917870221979/posts/default/6778854910325194765?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/Azcarya/~3/NHqB-J93NFA/make-sharing-easy.html" title="Make Sharing Easy" /><author><name>Sandeep Gupta</name><uri>https://profiles.google.com/110645714607919970386</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-fgzHpYBSqzA/AAAAAAAAAAI/AAAAAAAAGLY/n0u9TBuTk4M/s512-c/photo.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://blog.sangupta.com/2011/07/make-sharing-easy.html</feedburner:origLink></entry><entry gd:etag="W/&quot;D0QCRX0-fSp7ImA9WhdTFU8.&quot;"><id>tag:blogger.com,1999:blog-3969325917870221979.post-3349252045593349105</id><published>2011-07-13T08:19:00.000+05:30</published><updated>2011-07-13T08:19:24.355+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-07-13T08:19:24.355+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Java" /><category scheme="http://www.blogger.com/atom/ns#" term="Interview Questions" /><title>In-Place Character Array Encoding</title><content type="html">&lt;tt&gt;Problem: &lt;/tt&gt;Given a character stream as an array, encode the characters in place replacing given set of characters by their 3-character equivalent. The array is terminated by a &lt;tt&gt;0x00&lt;/tt&gt; character. If the array cannot be fully encoded, the array should not be modified.&lt;br /&gt;
&lt;br /&gt;&lt;tt&gt;Solution: &lt;/tt&gt;This is a classic interview problem. There are two aspects to this problem,&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;Calculating whether the array would be able to contain the entirely encoded string. This can be easily achieved by calculating the length of the string, the number of encod&lt;i&gt;able&lt;/i&gt; characters and the size of the array. If the free space in the array is equal to the additional capacity that would be needed by the encod&lt;i&gt;able&lt;/i&gt; characters &lt;/li&gt;
&lt;li&gt;Encode the string from tail than from head. This is a must so that one does not override the characters ahead, when an encod&lt;i&gt;able&lt;/i&gt; character is written encoded in the string.&lt;br /&gt;
&lt;br /&gt;
A simple JAVA implementation is shown below.&lt;br /&gt;
&lt;pre class="brush:java"&gt;/**
 * Copyright (C) 2010-2011, Sandeep Gupta
 * http://www.sangupta.com
 * 
 * The file is licensed under the the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * 
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * 
 */

package com.sangupta.keepwalking;

import java.util.Arrays;

/**
 * Class to encode a given character stream (defined as char[] array). The character array is the only
 * memory space one has. In case encoding is not possible, the array should be left untouched. The array
 * will be terminated by a &lt;code&gt;null&lt;/code&gt; to indicate string termination.
 * 
 * Each encodable character is 3 characters in length. Thus, additional space required would be 2 characters
 * per each encodable character.
 * 
 * @author sangupta
 * @since 12 July 2011
 */
public class CharacterStreamEncoder {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		char[] stream = new char[12];
		Arrays.fill(stream, '\0');
		stream[0] = 's';
		stream[1] = 'a';
		stream[2] = 'n';
		stream[3] = 'd';
		stream[4] = ' ';
		stream[5] = ' ';
		stream[6] = 'p';
		
		boolean result = encode(stream);
		if(result) {
			System.out.println(stream);
		} else {
			System.out.println("String was not modified.");
		}
	}
	
	public static boolean encode(char[] stream) {
		final int streamLength = stream.length;
		System.out.println("Total length: " + streamLength);
		
		// first we need to check if we can encode the string or not
		// in the given only space
		// so we read each character and count the total number of encodable
		// characters and also the length of the string.
		int encodable = 0;
		int length = 0;
		for(int index = 0; index &lt; stream.length; index++) {
			char temp = stream[index];
			if(temp == '\0') {
				break;
			} else {
				length++;
				if(isEncodable(temp)) {
					encodable++;
				}
			}
		}
		
		System.out.println("Length of string: " + length);
		System.out.println("Encodable: " + encodable);
		
		if(encodable == 0) {
			return true;
		}
			
		// now check for the balance length
		int balance = streamLength - length;
		if(encodable *2 &gt;= balance) {
			// not sufficient space in stream to encode
			return false;
		}
		
		// now we start from the end of the stream to encode
		// so that we do not override the characters before
		// as we already know the number of encodable characters
		// we know where the last character would be written
		int destination = length + encodable * 2 - 1;
		int source = length;
		
		for(int index = source; index &gt; 0; index--) {
			char character = stream[index - 1];
			char[] encoded = encode(character);
			if(encoded.length == 1) {
				stream[destination--] = encoded[0];
			} else {
				// we need to set the 3 character bytes properly
				stream[destination--] = encoded[2];
				stream[destination--] = encoded[1];
				stream[destination--] = encoded[0];
			}
		}
		
		return true;
	}

	private static boolean isEncodable(char character) {
		switch(character) {
			case ' ':
				return true;
				
		}
		
		return false;
	}
	
	private static char[] encode(char character) {
		switch(character) {
			case ' ':
				return new char[] { '%', '2', '0' };
		}
		
		return new char[] { character };
	}

}
&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3969325917870221979-3349252045593349105?l=blog.sangupta.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/Azcarya/~4/hU4DoN5bV6A" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.sangupta.com/feeds/3349252045593349105/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=3969325917870221979&amp;postID=3349252045593349105&amp;isPopup=true" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/3969325917870221979/posts/default/3349252045593349105?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/3969325917870221979/posts/default/3349252045593349105?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/Azcarya/~3/hU4DoN5bV6A/in-place-character-array-encoding.html" title="In-Place Character Array Encoding" /><author><name>Sandeep Gupta</name><uri>https://profiles.google.com/110645714607919970386</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-fgzHpYBSqzA/AAAAAAAAAAI/AAAAAAAAGLY/n0u9TBuTk4M/s512-c/photo.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://blog.sangupta.com/2011/07/in-place-character-array-encoding.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DE4MSHsyfip7ImA9WhdTFEs.&quot;"><id>tag:blogger.com,1999:blog-3969325917870221979.post-3522051598983917635</id><published>2011-07-12T16:06:00.000+05:30</published><updated>2011-07-12T16:06:29.596+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-07-12T16:06:29.596+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="java7" /><title>Java 7: Enhanced Syntax for Numeric Literals</title><content type="html">As far as I know, Java never updated the syntax for defining integral constants since JDK 1.2, which seems like ages before. To end that drought, Java 7 defines enhanced syntax for the following,&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;Numeric constants expressed as binary&lt;/li&gt;
&lt;li&gt;Suffix to denote type as short or byte&lt;/li&gt;
&lt;li&gt;Improved readability by use of underscores in integer constants&lt;/li&gt;
&lt;/ul&gt;&lt;br /&gt;
The above enhancements do not impact a seasoned developer much, nor they provide something out-of-this-world. The only benefit you get is improved readability and vanishing of minor hiccups when coding. &lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;Binary Values&lt;/h3&gt;Before Java 7, in order to parse binary values one would write,&lt;br /&gt;
&lt;blockquote&gt;int value = Integer.parseInt("10101010", 2);&lt;/blockquote&gt;This in addition to some extra code, also has performance impact besides making the value as a runtime constant than compile time constant. Thankfully, Java 7 introduces the concept of &lt;b&gt;0b&lt;/b&gt; on the same lines as &lt;b&gt;0x&lt;/b&gt; for hexa-decimal values. Thus, the above code fragment in Java 7 would become,&lt;br /&gt;
&lt;blockquote&gt;int value = 0b10101010;&lt;/blockquote&gt;The value is now a compile time constant and also, has no performance hit.&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;Short and Byte values&lt;/h3&gt;Java had several integral types such as &lt;tt&gt;short&lt;/tt&gt; and &lt;tt&gt;byte&lt;/tt&gt;, but no syntactical way to code the values directly in, as all numerical constant were treated as integers. Type-casting led to annoyance and discomfort during code and might also have led to limit-over-runs. With Java 7, assigning values for these integral types becomes easy as,&lt;br /&gt;
&lt;blockquote&gt;byte b = 245y;&lt;/blockquote&gt;and,&lt;br /&gt;
&lt;blockquote&gt;short s = 65535s;&lt;/blockquote&gt;The above values just provide some syntactical sugar when coding and improves readability.&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;Underscores in values&lt;/h3&gt;A long binary, hexa-decimal or integral value becomes hard to read by human mind. If the number of digits increase figuring out the exact extant of the value at times gets difficult. Java 7 adds some real beauty for such use-cases by adding support to add underscores to integral values for improved readability. Thus a value of &lt;tt&gt;2 GB, 2147483648&lt;/tt&gt; now may be expressed as,&lt;br /&gt;
&lt;blockquote&gt;long twoGigabytes = 2_147_483_648L;&lt;/blockquote&gt;In my honest opinion, this is definitely a boon for mathematical and statistical developers who really had tough time understanding someone's else code... err.. defined constants.&lt;br /&gt;
&lt;br /&gt;
Hope this helps me, more than anyone else in remembering the new sugars! Happy Coding!&lt;br /&gt;
&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3969325917870221979-3522051598983917635?l=blog.sangupta.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/Azcarya/~4/1tSOVd2Yc7M" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.sangupta.com/feeds/3522051598983917635/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=3969325917870221979&amp;postID=3522051598983917635&amp;isPopup=true" title="1 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/3969325917870221979/posts/default/3522051598983917635?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/3969325917870221979/posts/default/3522051598983917635?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/Azcarya/~3/1tSOVd2Yc7M/java-7-enhanced-syntax-for-numeric.html" title="Java 7: Enhanced Syntax for Numeric Literals" /><author><name>Sandeep Gupta</name><uri>https://profiles.google.com/110645714607919970386</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-fgzHpYBSqzA/AAAAAAAAAAI/AAAAAAAAGLY/n0u9TBuTk4M/s512-c/photo.jpg" /></author><thr:total>1</thr:total><feedburner:origLink>http://blog.sangupta.com/2011/07/java-7-enhanced-syntax-for-numeric.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DEENQng-fip7ImA9WhdTE0s.&quot;"><id>tag:blogger.com,1999:blog-3969325917870221979.post-3596405913908480346</id><published>2011-07-11T12:14:00.000+05:30</published><updated>2011-07-11T12:14:53.656+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-07-11T12:14:53.656+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Java" /><category scheme="http://www.blogger.com/atom/ns#" term="Spring Framework" /><category scheme="http://www.blogger.com/atom/ns#" term="Workarounds" /><title>Intermittent error establishing connection with Spring, Hibernate and C3P0</title><content type="html">Most of the Java web projects (and desktop projects as well) use the well known &lt;a href="http://www.springsource.org/about"&gt;Spring&lt;/a&gt; and &lt;a href="http://hibernate.org/"&gt;Hibernate&lt;/a&gt; frameworks. I myself have been using them for over 6 years now, and must say, the benefits they have provided have been immense, both in terms of rapid application development, testing and of course, maintenance. With good amount of experience in using the both I rarely find it difficult debugging a bug, but sometimes, I have come across issues that have been both time-consuming and have thrown open unleashed areas of the frameworks. Recently, I happened to land debugging one such issue.&lt;br /&gt;
&lt;br /&gt;
When running are project, which uses &lt;a href="http://static.springsource.org/spring/docs/2.5.x/api/org/springframework/orm/hibernate3/HibernateTemplate.html"&gt;HibernateTemplate&lt;/a&gt; to simplify access to the data layer, we saw intermittent timeout issues. The intermittent failures in them self were very strange. Running from a machine with query latency of around 10 seconds, only once reproduced the issue. Running from a machine with 2.5 second latency, the issue was 25% reproducible, and from a machine with just 1 second latency (quite close to DB datacenter) never reproduced the issue.&lt;br /&gt;
&lt;br /&gt;
Our application configuration was pretty simple, Spring 2.5.6 working in tandem with Hibernate 2.4, using C3P0 as the connection pool. Good stack, right?&lt;br /&gt;
&lt;br /&gt;
There were two Java exceptions which were coming up randomly, as,&lt;br /&gt;
&lt;blockquote&gt;&lt;pre&gt;org.hibernate.util.JDBCExceptionReporter

No suitable driver found for jdbc:oracle:thin:@myDomain:myPort/mySchemaName&lt;/pre&gt;&lt;/blockquote&gt;&lt;b&gt;and,&lt;/b&gt;&lt;br /&gt;
&lt;pre&gt;org.springframework.dao.DataAccessResourceFailureException: Hibernate operation: Cannot open connection; SQL [???]; 
Io exception: The Network Adapter could not establish the connection; nested exception is,
 java.sql.SQLException: Io exception: The Network Adapter could not establish the connection
	at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.doTranslate(SQLErrorCodeSQLExceptionTranslator.java:236)
	at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:72)
	at org.springframework.orm.hibernate3.HibernateAccessor.convertJdbcAccessException(HibernateAccessor.java:424)
	at org.springframework.orm.hibernate3.HibernateAccessor.convertHibernateAccessException(HibernateAccessor.java:410)
	at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:424)
	at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:339)
	at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
	at java.util.concurrent.FutureTask.run(FutureTask.java:138)
	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
	at java.lang.Thread.run(Thread.java:662)
Caused by: java.sql.SQLException: Io exception: The Network Adapter could not establish the connection
	at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:145)
	at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:190)
	at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:363)
	at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:401)
	at oracle.jdbc.driver.PhysicalConnection.&lt;init&gt;(PhysicalConnection.java:441)
	at oracle.jdbc.driver.T4CConnection.&lt;init&gt;(T4CConnection.java:165)
	at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:35)
	at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:839)
	at java.sql.DriverManager.getConnection(DriverManager.java:582)
	at java.sql.DriverManager.getConnection(DriverManager.java:154)
	at org.springframework.jdbc.datasource.DriverManagerDataSource.getConnectionFromDriverManager(DriverManagerDataSource.java:174)
	at org.springframework.jdbc.datasource.DriverManagerDataSource.getConnectionFromDriver(DriverManagerDataSource.java:165)
	at org.springframework.jdbc.datasource.AbstractDriverBasedDataSource.getConnectionFromDriver(AbstractDriverBasedDataSource.java:149)
	at org.springframework.jdbc.datasource.AbstractDriverBasedDataSource.getConnection(AbstractDriverBasedDataSource.java:119)
	at org.springframework.orm.hibernate3.LocalDataSourceConnectionProvider.getConnection(LocalDataSourceConnectionProvider.java:82)
	at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:417)
	at org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.java:144)
	at org.hibernate.jdbc.AbstractBatcher.prepareQueryStatement(AbstractBatcher.java:139)
	at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1560)
	at org.hibernate.loader.Loader.doQuery(Loader.java:661)
	at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
	at org.hibernate.loader.Loader.doList(Loader.java:2144)
	at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2028)
	at org.hibernate.loader.Loader.list(Loader.java:2023)
	at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:289)
	at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1695)
	at org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:142)
	at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:150)
	at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:419)
	... 15 more
&lt;/pre&gt;&lt;br /&gt;
Obviously the &lt;b&gt;ERROR 1&lt;/b&gt; listed above was nothing related, as the code had obtained DB connections (for sure). The &lt;b&gt;ERROR 2&lt;/b&gt; indicated that we were opening more connections than what the database could handle. We tried setting up a local database and tested the whole code, but the error won't reproduce. We thus concluded (only to be proven wrong later) that the database was unable to handle the load of our connections (a connection pool of 100 connections). We lowered our throttle of hitting to 50, 20, 10, and lastly 5 connections but the error still occurred on the staging and production servers. We contacted the &lt;tt&gt;database team&lt;/tt&gt; and they informed that there were more than enough free handles on the database side and no alert was raised for DB going overboard the total number of allowed connections.&lt;br /&gt;
&lt;br /&gt;
This made us change our mind to think that there was some connectivity issues with the stating/production machines, both being in the same datacenter. We tested heavily both the machines but found nothing that suggested a connectivity issue. Again we stood at a blank wall.&lt;br /&gt;
&lt;br /&gt;
We again went back to the DB team to help us debug. As one another test, we ran our code in the DBA presence monitoring the database. The DBA informed that we were creating connections at a rapid pace, creating them, firing a query, and then disconnecting. Voila! What was that - we were using a connection pool. Was it not working?&lt;br /&gt;
&lt;br /&gt;
We went back to the code and ran the profiler along with &lt;tt&gt;netstat&lt;/tt&gt;s. This confirmed that we were creating DB connections and then dropping for every single query. But why should that happen, when we were for sure, using &lt;a href="http://sourceforge.net/projects/c3p0/"&gt;C3P0&lt;/a&gt; (shipped with Hibernate) for our connection pooling. After deep penetration into the code, we figured out that firing plain &lt;b&gt;SQL queries&lt;/b&gt; using Hibernate template does not makes use of the inherent connection pool of Hibernate. This broke all our code - we were using the &lt;tt&gt;HibernateTemplate&lt;/tt&gt; extensively in our application and firing native queries (why so - leaving as it calls for another detailed post) over the &lt;a href="http://mysql.com/"&gt;MySQL&lt;/a&gt; database.&lt;br /&gt;
&lt;br /&gt;
As a quick fix, we added &lt;a href="http://commons.apache.org/dbcp/"&gt;Apache Commons DBCP&lt;/a&gt; connection pooling layer over our data-source. This made our stack look something like,&lt;br /&gt;
&lt;blockquote&gt;DB -&gt; Apache DBCP DataSource -&gt; Hibernate -&gt; C3P0 -&gt; Spring -&gt; Our application&lt;/blockquote&gt;.&lt;br /&gt;
This seemed to do the trick. Not only did the connection fetch failure vanished, we also saw improved performance gains with connection pooling (as if we didn't knew).&lt;br /&gt;
&lt;br /&gt;
As they say, better late than never - we could fix the problem well before the release, burning some mid-night...err... mid-day oil. But this taught me a lesson,&lt;br /&gt;
&lt;blockquote&gt;&lt;b&gt;Always profile your application for connections before releasing.&lt;/b&gt;&lt;/blockquote&gt;.&lt;br /&gt;
Hope this helps someone out there having a similar problem. You do, try this and if it gets resolved, drop in a comment.&lt;br /&gt;
&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3969325917870221979-3596405913908480346?l=blog.sangupta.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/Azcarya/~4/cZapHq43kBI" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.sangupta.com/feeds/3596405913908480346/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=3969325917870221979&amp;postID=3596405913908480346&amp;isPopup=true" title="2 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/3969325917870221979/posts/default/3596405913908480346?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/3969325917870221979/posts/default/3596405913908480346?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/Azcarya/~3/cZapHq43kBI/intermittent-error-establishing.html" title="Intermittent error establishing connection with Spring, Hibernate and C3P0" /><author><name>Sandeep Gupta</name><uri>https://profiles.google.com/110645714607919970386</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-fgzHpYBSqzA/AAAAAAAAAAI/AAAAAAAAGLY/n0u9TBuTk4M/s512-c/photo.jpg" /></author><thr:total>2</thr:total><feedburner:origLink>http://blog.sangupta.com/2011/07/intermittent-error-establishing.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CUMMRnkzeyp7ImA9WhZaGUs.&quot;"><id>tag:blogger.com,1999:blog-3969325917870221979.post-8033277587988407124</id><published>2011-07-06T20:14:00.000+05:30</published><updated>2011-07-06T20:14:47.783+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-07-06T20:14:47.783+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="MyJerry" /><category scheme="http://www.blogger.com/atom/ns#" term="My Projects" /><title>Time For Change</title><content type="html">They say,&lt;br /&gt;
&lt;blockquote&gt;Change is the only constant.&lt;/blockquote&gt;How true this is, we realize as we keep walking down the lane of our life.&lt;br /&gt;
&lt;br /&gt;
Today, happens to be one such change. Today, I have started migrating all code from various repositories that held my code, such as &lt;a href="http://sourceforge.net/projects/jerry/"&gt;Source Forge&lt;/a&gt;, &lt;a href="http://code.google.com/p/sangupta"&gt;Google Code&lt;/a&gt; and other locally hosted ones, to their new home - &lt;a href="https://github.com/organizations/myjerry"&gt;Github&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
This is one single consolidation effort where in I want all my code to be available publicly, be of good quality and above all - clean up my systems. Keeping their backups have already become nightmare for me. I anticipate this to take around 2 weeks, so keep watching for more posts under the label, &lt;b&gt;myjerry&lt;/b&gt;.&lt;br /&gt;
&lt;br /&gt;
Stay tuned, for more blog posts on how to reuse all this shit of code ;)&lt;br /&gt;
&lt;br /&gt;
Keep Walking!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3969325917870221979-8033277587988407124?l=blog.sangupta.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/Azcarya/~4/byUAAO-fOi8" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.sangupta.com/feeds/8033277587988407124/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=3969325917870221979&amp;postID=8033277587988407124&amp;isPopup=true" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/3969325917870221979/posts/default/8033277587988407124?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/3969325917870221979/posts/default/8033277587988407124?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/Azcarya/~3/byUAAO-fOi8/time-for-change.html" title="Time For Change" /><author><name>Sandeep Gupta</name><uri>https://profiles.google.com/110645714607919970386</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-fgzHpYBSqzA/AAAAAAAAAAI/AAAAAAAAGLY/n0u9TBuTk4M/s512-c/photo.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://blog.sangupta.com/2011/07/time-for-change.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CUMGRng5fyp7ImA9WhZaE0s.&quot;"><id>tag:blogger.com,1999:blog-3969325917870221979.post-7175898701984497583</id><published>2011-06-29T21:33:00.000+05:30</published><updated>2011-06-29T21:33:47.627+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-06-29T21:33:47.627+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Java" /><category scheme="http://www.blogger.com/atom/ns#" term="java7" /><title>Java 7: String switching</title><content type="html">Today, I started my journey into the world of Java 7. Quite late I know, but as they &lt;i&gt;better late than never&lt;/i&gt;. So I now have a build of Java 7 SDK on my desktop, and spent some time fiddling with the new features in. One of the most striking features of Java 7, specially after working in ActionScript 3, is the ability to &lt;b&gt;switch on strings&lt;/b&gt;.&lt;br /&gt;
&lt;br /&gt;
ActionScript developers would know the value and power of this small feature, as it gets rid of those ugly multiple &lt;tt&gt;if-else if-else if-else&lt;/tt&gt; blocks. One way to fool around was to use &lt;b&gt;Enum&lt;/b&gt;s but that to me seemed overkill specifically if the input data was coming from a file, database or human interface.&lt;br /&gt;
&lt;br /&gt;
Thus, what looked like in the Java world till Java 6&lt;br /&gt;
&lt;pre class="brush: java"&gt;public void someMethod(String command) {
    if("dir".equals(command)) {
        // list the files in folder
    } else if("cls".equals(command)) {
        // clear the screen
    } else if("rename".equals(command)) {
        // rename the given file
    } else if("delete".equals(command)) {
        // delete the given file
    } else if("ver".equals(command)) {
        // display OS version
    } else {
        throw new IllegalArgumentException("Command not found.");
    }
}
&lt;/pre&gt;&lt;br /&gt;
has now been reduced to something like,&lt;br /&gt;
&lt;pre class="brush: java"&gt;public void someMethod(String command) {
    switch(command) {
        case "dir":
            // list file in folder
            break;

        case "cls":
            // clear the screen
            break;

        case "rename":
            // rename the given file
            break;

        case "delete":
            // delete the given file
            break;

        case "ver":
            // display OS version
            break;

        default:
            throw new IllegalArgumentException("Command not found.");
    }
}
&lt;/pre&gt;&lt;br /&gt;
Foshizle, it is not a super-developer-feature that may make you say a &lt;tt&gt;WOW&lt;/tt&gt;, but it surely would make some pieces of code readable, and easily debug-&lt;i&gt;able&lt;/i&gt;.&lt;br /&gt;
&lt;br /&gt;
Happy Coding!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3969325917870221979-7175898701984497583?l=blog.sangupta.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/Azcarya/~4/W4rVUtNTCIk" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.sangupta.com/feeds/7175898701984497583/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=3969325917870221979&amp;postID=7175898701984497583&amp;isPopup=true" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/3969325917870221979/posts/default/7175898701984497583?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/3969325917870221979/posts/default/7175898701984497583?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/Azcarya/~3/W4rVUtNTCIk/java-7-string-switching.html" title="Java 7: String switching" /><author><name>Sandeep Gupta</name><uri>https://profiles.google.com/110645714607919970386</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-fgzHpYBSqzA/AAAAAAAAAAI/AAAAAAAAGLY/n0u9TBuTk4M/s512-c/photo.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://blog.sangupta.com/2011/06/java-7-string-switching.html</feedburner:origLink></entry></feed>

