<?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:blogger="http://schemas.google.com/blogger/2008" xmlns:georss="http://www.georss.org/georss" xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr="http://purl.org/syndication/thread/1.0" gd:etag="W/&quot;DEUNRnw4cCp7ImA9WhNUFk8.&quot;"><id>tag:blogger.com,1999:blog-4385671836555623731</id><updated>2013-01-07T22:24:57.238-08:00</updated><category term="future" /><category term="technology" /><category term="System" /><category term="JBoss" /><category term="GWT" /><category term="Yum" /><category term="finance" /><category term="JSP" /><category term="detroit" /><category term="C" /><category term="AJAX" /><category term="environment" /><category term="GM" /><category term="india" /><category term="Java" /><category term="general" /><category term="Web" /><category term="speculation" /><category term="economics" /><category term="energy" /><category term="Exception" /><category term="Firefox" /><category term="software" /><category term="Language" /><category term="Linux" /><category term="Warning" /><category term="Eclipse" /><category term="hedge" /><category term="Tools" /><category term="fun" /><category term="mini" /><category term="US" /><category term="JSON" /><category term="crisis" /><category term="science" /><title>TechForb</title><subtitle type="html">As technology goes...</subtitle><link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" href="http://techforb.blogspot.com/feeds/posts/default" /><link rel="alternate" type="text/html" href="http://techforb.blogspot.com/" /><author><name>Vishal Jain</name><uri>http://www.blogger.com/profile/01516639234852190662</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><generator version="7.00" uri="http://www.blogger.com">Blogger</generator><openSearch:totalResults>15</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/Techforb" /><feedburner:info xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" uri="techforb" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><feedburner:emailServiceId xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0">Techforb</feedburner:emailServiceId><feedburner:feedburnerHostname xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0">http://feedburner.google.com</feedburner:feedburnerHostname><entry gd:etag="W/&quot;D0YFRX4zcSp7ImA9WhdWEkg.&quot;"><id>tag:blogger.com,1999:blog-4385671836555623731.post-263840917619458580</id><published>2011-09-05T13:38:00.000-07:00</published><updated>2011-09-05T13:38:34.089-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-09-05T13:38:34.089-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="speculation" /><category scheme="http://www.blogger.com/atom/ns#" term="technology" /><category scheme="http://www.blogger.com/atom/ns#" term="india" /><category scheme="http://www.blogger.com/atom/ns#" term="US" /><category scheme="http://www.blogger.com/atom/ns#" term="software" /><category scheme="http://www.blogger.com/atom/ns#" term="general" /><category scheme="http://www.blogger.com/atom/ns#" term="future" /><category scheme="http://www.blogger.com/atom/ns#" term="science" /><title>Are Indian Speculators About to Find Religion?</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;Wow! Its been a long break from blogging. My last post was in April 2009. And I have enjoyed all this time doing my computer science studies, researching and learning new technologies.&lt;br /&gt;
&lt;br /&gt;
But, there is something else about this period. There was a bull market in stocks, commodities since March 2009 of historical proportions. Credit has flown big time in emerging markets during this time and India has been a big receiver.&lt;br /&gt;
&lt;br /&gt;
Speculators made hell lot of money during this time. Stocks, commodities, real estate, bla bla. And what were Indian businesses doing all this time. Any guess? Speculation. Very easy :) My logic behind saying so is that people who were playing government policies, money flow etc made good money. Everyone seem stressed to recover from 2008 blow.&lt;br /&gt;
&lt;br /&gt;
Availability of easy credit encourages speculation and kills innovation. India was already on very low side of innovation since economic boom starting in 1990, but bull market since 2009 caused even more damage.&lt;br /&gt;
&lt;br /&gt;
For me, its easy to see that actual long term growth comes from real innovation. America has grown in 20th century not because of fast food drive thru chains, but because of industrial, rail road, aviation, computer, internet, &amp;amp; telecommunication boom. Market for American banks contracted after 1970 due to rise of corporate bonds and they starting looking for growth outside. They are good at engineering boom bust cycle, making truck loads of profit in between. All they need is "favorable government policies". And what goes into favorable government policies.&lt;br /&gt;
&lt;ul style="text-align: left;"&gt;&lt;li&gt;&lt;i&gt;Willingness to force people in speculative assets by lowering bank saving interest rate.&lt;/i&gt;&lt;/li&gt;
&lt;li&gt;&lt;i&gt;Stealing money out of common men pocket by creating inflation and making sure that debtor gets paid for foolish speculation.&lt;/i&gt;&lt;/li&gt;
&lt;/ul&gt;And India has favorable policy response by running 10% inflation for more than a year. RBI was "behind the curve" for major portion of this time in interest rate tightening.&lt;br /&gt;
&lt;br /&gt;
Who gains for this "favorable government policies"? If one thinks technology companies like Infosys etc. then he/she is wrong. Infact, technology companies come under pressure to raise salaries because employees can't keep up with rising prices of all the stuff we need and want (home/property).&lt;br /&gt;
&lt;br /&gt;
I have seen a lot of guys (especially since start of 2003 commodity and stock bull) who were poor in studies, lazy, dilatory make good money. And lately they have been feeling very confident. They feel as if guys who burnt mid night oil in their teens, studied in 115 F temperature without A/C were fools. And they have gone neck deep in speculation.&lt;br /&gt;
&lt;br /&gt;
Stocks and other speculations are stairs up and elevators down. Losses come fast and wash out profits of last few years. Stock markets are like NBA. Only difference being its easy to jump in and start playing. But, organizers of this game are not lame and they are not here to distribute paper money among incompetent people. James has presented this fact really well in his article &lt;a href="http://kostohryz.hypermart.net/jamesblog/?p=2922"&gt;CAN THE AVERAGE JOE MAKE IT IN THE MARKET?&lt;/a&gt; that one is more likely going to get his butt handed to him in market. &lt;br /&gt;
&lt;br /&gt;
Unfortunately, for speculators, bull market in India came when world was beginning to enter prolonged bear phase. Fed's low interest rate policy enabled hot money flow to emerging markets and Fed's low interest policy is in place because US and world economy is on shaky grounds.&lt;br /&gt;
&lt;br /&gt;
Recently, I have seen 2 casualties in my circle due to speculation. And I am sure this count will continue to increase till 2015-2016 by which time I think assets around the world will correct severely to the downside. This will be good for free markets in long run. And I am sure that Indian businessmen and speculators will find religion by that time.&lt;br /&gt;
&lt;br /&gt;
I only wish that things remain good and favorable for innovative, hard working people. Though some pain will be inevitable.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
And those who think technology or software is dead.. Software is not dead, it's just the beginning. If software become less profitable, that doesn't mean software is dead. It can be very profitable at some time in future. And software is not just able microsoft, apple, google, or facebook. I would like to quote Prof. &lt;a href="http://en.wikipedia.org/wiki/Hal_Abelson"&gt;Hal Abelson&lt;/a&gt; from &lt;a href="http://groups.csail.mit.edu/mac/classes/6.001/abelson-sussman-lectures/"&gt;Lecture 1a "Introduction to Lisp"&amp;nbsp;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;"thousands of years ago Egyptians thought Geometry was about surveying instruments (measuring earth).. when some field is really starting, its easy to confuse the essence of what you are doing with the tools that you use.. right now we know less about essence of computer science like ancient Egyptians knew about geometry.. Now when we look back at Egyptians, we know that they were actually trying to formalize the notion about space and time, to start a way of talking about mathematical truth formally, that led to all the modern mathematics.. Similarly, in future people will look back and say those primitives in 20th century were fiddling around with gadgets called computers but really what they were doing is starting to learn how to formalize intuition about process.. how to do thing.. "&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
With all due respect to Prof. Hal Abelson, I agree with him. And my thoughts on software are very similar to those expressed in the article &lt;a href="http://online.wsj.com/article/SB10001424053111903480904576512250915629460.html"&gt;Why Software is Eating the World&lt;/a&gt;.&lt;br /&gt;
&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://techforb.blogspot.com/feeds/263840917619458580/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=4385671836555623731&amp;postID=263840917619458580" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/4385671836555623731/posts/default/263840917619458580?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/4385671836555623731/posts/default/263840917619458580?v=2" /><link rel="alternate" type="text/html" href="http://techforb.blogspot.com/2011/09/are-indian-speculators-about-to-find.html" title="Are Indian Speculators About to Find Religion?" /><author><name>Vishal Jain</name><uri>http://www.blogger.com/profile/01516639234852190662</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;C0IGRH49cCp7ImA9WxVaGUU.&quot;"><id>tag:blogger.com,1999:blog-4385671836555623731.post-79108449709569929</id><published>2009-04-17T07:41:00.000-07:00</published><updated>2009-04-17T08:18:45.068-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-04-17T08:18:45.068-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="fun" /><category scheme="http://www.blogger.com/atom/ns#" term="mini" /><category scheme="http://www.blogger.com/atom/ns#" term="environment" /><category scheme="http://www.blogger.com/atom/ns#" term="energy" /><title>Lower your CO2 emissions</title><content type="html">If you are reading this, then you may be a frequent computer user. Desktop or laptop computer run on electricity and hence appear very environment friendly against a car or any other fossil fuel burning machine. &lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;But, most of the electricity generated at present (2009 AD) across the world comes from thermal power stations which generate electricity by burning coal or petrol. These power stations release millions of tons of CO2 (Carbon Dioxide) every year. CO2 is a green house gas and is making our planet earth warmer. &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;We all computer users can help prevent our earth by following a few easy tips:&lt;/div&gt;&lt;div&gt;&lt;ul&gt;&lt;li&gt;Turn off computer/laptop completely when away for more than a day or so.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Change settings to turn off monitor if idle for more than 2 minutes.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Use stand-by mode if stepping away for more than 1/2 hr. You may automate settings for stand-by mode if system is idle for more than 1/2 hr (I personal don't like automatic setting for stand-by)&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Some Operating system has very fast hibernate and stand-by mode. Fast mode saves frustration by avoiding 1-2 minute wait while the system wakes up. I have heard Apple computer go to sleep and stand-by in a flash and wake up is also equally fast. Apple users shutdown system rarely. They simply press the sleep button.&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Personally, I have been following these tips for last few months. Shutting down office computer during weekend and hibernating personal laptop while stepping away saves many pounds of CO2 emissions every week. Turning car engine off at night might sound intuitive but turning off computer isn't that hard either. Isn't it.&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://techforb.blogspot.com/feeds/79108449709569929/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=4385671836555623731&amp;postID=79108449709569929" title="4 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/4385671836555623731/posts/default/79108449709569929?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/4385671836555623731/posts/default/79108449709569929?v=2" /><link rel="alternate" type="text/html" href="http://techforb.blogspot.com/2009/04/lower-your-co2-emissions.html" title="Lower your CO2 emissions" /><author><name>Vishal Jain</name><uri>http://www.blogger.com/profile/01516639234852190662</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>4</thr:total></entry><entry gd:etag="W/&quot;D0UFQ34_fyp7ImA9WxVaGEo.&quot;"><id>tag:blogger.com,1999:blog-4385671836555623731.post-5200004049629719676</id><published>2009-04-16T02:41:00.000-07:00</published><updated>2009-04-16T02:46:52.047-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-04-16T02:46:52.047-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="fun" /><category scheme="http://www.blogger.com/atom/ns#" term="mini" /><category scheme="http://www.blogger.com/atom/ns#" term="finance" /><title>When do companies issue common stock?</title><content type="html">Companies issue common stock under 2 circumstances:&lt;br /&gt;&lt;ol style="text-align: left;"&gt;&lt;li&gt;when they absolutely have to&lt;/li&gt;&lt;li&gt;when they're stupid not to&lt;/li&gt;&lt;/ol&gt;Case 1: In bad times, companies may issue common stock to raise money and pay off their debt or fulfill other obligations.&lt;br /&gt;&lt;br /&gt;Case 2: In good times, companies can raise huge amount of money taking advantage of high stock prices. The money may be used for fueling further growth and projects or for nothing :). Just because other companies are taking advantage of high stock prices some rouge companies do follow the trend.</content><link rel="replies" type="application/atom+xml" href="http://techforb.blogspot.com/feeds/5200004049629719676/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=4385671836555623731&amp;postID=5200004049629719676" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/4385671836555623731/posts/default/5200004049629719676?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/4385671836555623731/posts/default/5200004049629719676?v=2" /><link rel="alternate" type="text/html" href="http://techforb.blogspot.com/2009/04/when-do-companies-issue-common-stock.html" title="When do companies issue common stock?" /><author><name>Vishal Jain</name><uri>http://www.blogger.com/profile/01516639234852190662</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;C0MHRXY4cCp7ImA9WxVVGEk.&quot;"><id>tag:blogger.com,1999:blog-4385671836555623731.post-3160636489967572293</id><published>2009-03-11T22:47:00.000-07:00</published><updated>2009-03-12T00:03:54.838-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-03-12T00:03:54.838-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Linux" /><category scheme="http://www.blogger.com/atom/ns#" term="System" /><title>How to mount/format a USB mass storage device (pen drive) in Linux</title><content type="html">Using a USB mass storage device with Linux is not difficult at all. Linux is well equipped with command line utilities which can help accomplish this task in few easy steps.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Step1: Determine device file&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;When a USB device is connected to a machine running Linux, Linux kernel (brain of Operating System) will detect that a device has been connected to it and will log a message like this:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;usb.c: registered new driver usb-storage&lt;br /&gt;scsi3 : SCSI emulation for USB Mass Storage devices&lt;br /&gt;Vendor: Generic   Model: USB Disk          Rev: 1.10&lt;br /&gt;Type:   Direct-Access                      ANSI SCSI revision: 02&lt;br /&gt;Attached scsi removable disk sdb at scsi3, channel 0, id 0, lun 0&lt;br /&gt;SCSI device sdb: 7897088 512-byte hdwr sectors (4043 MB)&lt;br /&gt;sdb: Write Protect is off&lt;br /&gt;sdb: sdb1 sdb2 sdb3 sdb4&lt;br /&gt;WARNING: USB Mass Storage data integrity not assured&lt;br /&gt;USB Mass Storage device found at 2&lt;br /&gt;USB Mass Storage support registered.&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;The message above is obtained by running command&lt;br /&gt;&lt;code&gt;dmesg&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;dmesg command display message logged by Linux kernel. The message displayed above can be found at the end of log for a device connected a while ago. You can also run &lt;code&gt;dmesg|tail&lt;/code&gt; to see last few lines.&lt;br /&gt;&lt;br /&gt;The message above says that a USB device has been detected and the device file (don't bother what a device file is) is &lt;code&gt;sdb&lt;/code&gt; for the whole device and 4 partitions are available at &lt;code&gt;sdb1 sdb2 sdb3 sdb4&lt;/code&gt;. The device file are usually located under &lt;code&gt;/dev&lt;/code&gt; directory. So&lt;br /&gt;&lt;code&gt;/dev/sdb&lt;/code&gt; is the device file for whole USB device and partitions are&lt;br /&gt;&lt;code&gt;/dev/sdb1&lt;/code&gt;&lt;br /&gt;&lt;code&gt;/dev/sdb2&lt;/code&gt;&lt;br /&gt;&lt;code&gt;/dev/sdb3&lt;/code&gt;&lt;br /&gt;&lt;code&gt;/dev/sdb4&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Skip Step2 and Step3 if you don't want to change partitions and reformat partitions.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Step2: Alter partition table&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;code&gt;fdisk&lt;/code&gt; utility helps in add/delete partitions. In our example, we have 4 partitions, lets delete them and create 1 partition of type FAT32.&lt;br /&gt;&lt;br /&gt;Run fdisk as root user or &lt;code&gt;sudo&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;1. &lt;/span&gt;Type &lt;code&gt;sudo fdisk /dev/sdb&lt;/code&gt; to run fdisk program. It will display a command line interface.&lt;br /&gt;&lt;code&gt;&lt;br /&gt;#sudo fdisk /dev/sdb&lt;br /&gt;&lt;br /&gt;Command (m for help): m&lt;br /&gt;Command action&lt;br /&gt;a   toggle a bootable flag&lt;br /&gt;b   edit bsd disklabel&lt;br /&gt;c   toggle the dos compatibility flag&lt;br /&gt;d   delete a partition&lt;br /&gt;l   list known partition types&lt;br /&gt;m   print this menu&lt;br /&gt;n   add a new partition&lt;br /&gt;o   create a new empty DOS partition table&lt;br /&gt;p   print the partition table&lt;br /&gt;q   quit without saving changes&lt;br /&gt;s   create a new empty Sun disklabel&lt;br /&gt;t   change a partition's system id&lt;br /&gt;u   change display/entry units&lt;br /&gt;v   verify the partition table&lt;br /&gt;w   write table to disk and exit&lt;br /&gt;x   extra functionality (experts only)&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;2. &lt;/span&gt;Type &lt;code&gt;p&lt;/code&gt; to print partition table&lt;br /&gt;&lt;code&gt;&lt;br /&gt;Command (m for help): p&lt;br /&gt;&lt;br /&gt;Disk /dev/sdb: 4043 MB, 4043309056 bytes&lt;br /&gt;125 heads, 62 sectors/track, 1018 cylinders&lt;br /&gt;Units = cylinders of 7750 * 512 = 3968000 bytes&lt;br /&gt;&lt;br /&gt;Device Boot    Start       End    Blocks   Id  System&lt;br /&gt;/dev/sdb1   ?    100405    247697 570754815+  72  Unknown&lt;br /&gt;Partition 1 has different physical/logical beginnings (non-Linux?):&lt;br /&gt;phys=(357, 116, 40) logical=(100404, 79, 11)&lt;br /&gt;Partition 1 has different physical/logical endings:&lt;br /&gt;phys=(357, 32, 45) logical=(247696, 24, 51)&lt;br /&gt;Partition 1 does not end on cylinder boundary.&lt;br /&gt;/dev/sdb2   ?     21767    271577 968014120   65  Novell Netware 386&lt;br /&gt;Partition 2 has different physical/logical beginnings (non-Linux?):&lt;br /&gt;phys=(288, 115, 43) logical=(21766, 48, 47)&lt;br /&gt;Partition 2 has different physical/logical endings:&lt;br /&gt;phys=(367, 114, 50) logical=(271576, 60, 42)&lt;br /&gt;Partition 2 does not end on cylinder boundary.&lt;br /&gt;/dev/sdb3   ?    241276    491086 968014096   79  Unknown&lt;br /&gt;Partition 3 has different physical/logical beginnings (non-Linux?):&lt;br /&gt;phys=(366, 32, 33) logical=(241275, 3, 30)&lt;br /&gt;Partition 3 has different physical/logical endings:&lt;br /&gt;phys=(357, 32, 43) logical=(491085, 14, 39)&lt;br /&gt;Partition 3 does not end on cylinder boundary.&lt;br /&gt;/dev/sdb4   ?    372346    372354     27749+   d  Unknown&lt;br /&gt;Partition 4 has different physical/logical beginnings (non-Linux?):&lt;br /&gt;phys=(372, 97, 50) logical=(372345, 119, 25)&lt;br /&gt;Partition 4 has different physical/logical endings:&lt;br /&gt;phys=(0, 10, 0) logical=(372353, 14, 33)&lt;br /&gt;Partition 4 does not end on cylinder boundary.&lt;br /&gt;&lt;br /&gt;Partition table entries are not in disk order&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;3. &lt;/span&gt;Type &lt;code&gt;d&lt;/code&gt; then &lt;code&gt;1&lt;/code&gt; to delete first partition.&lt;br /&gt;&lt;code&gt;&lt;br /&gt;Command (m for help): d&lt;br /&gt;Partition number (1-4): 1&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;4. &lt;/span&gt;Repeat command &lt;code&gt;d&lt;/code&gt; to delete other partitions.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;5. &lt;/span&gt;See current partition table with command &lt;code&gt;p&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;Command (m for help): p&lt;br /&gt;&lt;br /&gt;Disk /dev/sdb: 4043 MB, 4043309056 bytes&lt;br /&gt;125 heads, 62 sectors/track, 1018 cylinders&lt;br /&gt;Units = cylinders of 7750 * 512 = 3968000 bytes&lt;br /&gt;&lt;br /&gt;Device Boot    Start       End    Blocks   Id  System&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Note: These changes are still not saved to the device. So if you want to quit, exit &lt;code&gt;fdisk&lt;/code&gt; using command &lt;code&gt;q&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;6. &lt;/span&gt;Create new partition with command &lt;code&gt;n&lt;/code&gt; and then enter &lt;code&gt;p&lt;/code&gt; for primary &lt;code&gt;e&lt;/code&gt; for extended partition. If you want to have less than 5 partitions in your device, then enter &lt;code&gt;p&lt;/code&gt; and create a primary partition.&lt;br /&gt;&lt;code&gt;&lt;br /&gt;Command (m for help): n&lt;br /&gt;Command action&lt;br /&gt;e   extended&lt;br /&gt;p   primary partition (1-4)&lt;br /&gt;p&lt;br /&gt;Partition number (1-4): 1&lt;br /&gt;First cylinder (1-1018, default 1):&lt;br /&gt;Using default value 1&lt;br /&gt;Last cylinder or +size or +sizeM or +sizeK (1-1018, default 1018):&lt;br /&gt;Using default value 1018&lt;br /&gt;&lt;br /&gt;Command (m for help): p&lt;br /&gt;&lt;br /&gt;Disk /dev/sdb: 4043 MB, 4043309056 bytes&lt;br /&gt;125 heads, 62 sectors/track, 1018 cylinders&lt;br /&gt;Units = cylinders of 7750 * 512 = 3968000 bytes&lt;br /&gt;&lt;br /&gt;Device Boot    Start       End    Blocks   Id  System&lt;br /&gt;/dev/sdb1             1      1018   3944719   83  Linux&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;7. &lt;/span&gt;The new partition is type Linux. If you want to create partition of type say "FAT32" then use &lt;code&gt;t&lt;/code&gt; command to toggle partition's ID.&lt;br /&gt;&lt;code&gt;&lt;br /&gt;Command (m for help): t&lt;br /&gt;Selected partition 1&lt;br /&gt;Hex code (type L to list codes): b&lt;br /&gt;Changed system type of partition 1 to b (Win95 FAT32)&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;8. &lt;/span&gt;See you changes and if fine with it, then save changes and exit fdisk.&lt;br /&gt;&lt;code&gt;&lt;br /&gt;Command (m for help): p&lt;br /&gt;&lt;br /&gt;Disk /dev/sdb: 4043 MB, 4043309056 bytes&lt;br /&gt;125 heads, 62 sectors/track, 1018 cylinders&lt;br /&gt;Units = cylinders of 7750 * 512 = 3968000 bytes&lt;br /&gt;&lt;br /&gt;Device Boot    Start       End    Blocks   Id  System&lt;br /&gt;/dev/sdb1             1      1018   3944719    b  Win95 FAT32&lt;br /&gt;&lt;br /&gt;Command (m for help): w&lt;br /&gt;The partition table has been altered!&lt;br /&gt;&lt;br /&gt;Calling ioctl() to re-read partition table.&lt;br /&gt;&lt;br /&gt;WARNING: If you have created or modified any DOS 6.x&lt;br /&gt;partitions, please see the fdisk manual page for additional&lt;br /&gt;information.&lt;br /&gt;Syncing disks.                                                                                                                                           &lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Step3: Format partition&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;If you have create new partition(s), then fdisk command just create/alters partition table. The partition still need to be formatted to make it usable.&lt;br /&gt;&lt;br /&gt;Command &lt;code&gt;mkfs&lt;/code&gt; helps in formatting a partition. For example:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;#sudo mkfs -t vfat /dev/sdb1&lt;br /&gt;mkfs.vfat 2.8 (28 Feb 2001)                                                                                                                                        &lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Step4: Mount a partition&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;When we connect a device to Windows, it mounts it automatically as some drive such as F:. In linux, we need to do it manually. Lets say we want to mount &lt;code&gt;/dev/sdb1&lt;/code&gt; (First partition) at &lt;code&gt;/mnt/d&lt;/code&gt;. So create this directory&lt;br /&gt;&lt;code&gt;#sudo mkdir /mnt/d&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;and run command&lt;br /&gt;&lt;code&gt;#sudo mount -t vfat /dev/sdb1 /mnt/d&lt;/code&gt; to mount the partition.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Finally&lt;/span&gt;, We have mounted the USB device and its available for use under directory &lt;code&gt;/mnt/d&lt;/code&gt;.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Step5: Unmount partition&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;To disconnect device, we have to unmount all the partitions previously mounted. This can be done as follows:&lt;br /&gt;&lt;code&gt;#sudo umount /dev/sdb1&lt;/code&gt;&lt;br /&gt;or&lt;br /&gt;&lt;code&gt;#sudo eject /dev/sdb&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;With these easy steps, we can easily use USB mass storage devices with Linux.</content><link rel="replies" type="application/atom+xml" href="http://techforb.blogspot.com/feeds/3160636489967572293/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=4385671836555623731&amp;postID=3160636489967572293" title="4 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/4385671836555623731/posts/default/3160636489967572293?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/4385671836555623731/posts/default/3160636489967572293?v=2" /><link rel="alternate" type="text/html" href="http://techforb.blogspot.com/2009/03/how-to-mountformat-usb-mass-storage.html" title="How to mount/format a USB mass storage device (pen drive) in Linux" /><author><name>Vishal Jain</name><uri>http://www.blogger.com/profile/01516639234852190662</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>4</thr:total></entry><entry gd:etag="W/&quot;DE4GR3cyfyp7ImA9WxRUEUw.&quot;"><id>tag:blogger.com,1999:blog-4385671836555623731.post-7828496744370287901</id><published>2008-11-19T07:19:00.000-08:00</published><updated>2008-11-19T09:48:46.997-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-11-19T09:48:46.997-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="economics" /><category scheme="http://www.blogger.com/atom/ns#" term="finance" /><category scheme="http://www.blogger.com/atom/ns#" term="hedge" /><title>About Hedge Funds...</title><content type="html">Hedge Funds get paid to manage risk. They assume the risk of others. &lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;They are different from conventional money management funds in the sense that money managers buy stocks and wait for stocks to go up. Hedge funds have been around for almost 60 years now. The first was opened in 1949, by Australian-born Alfred Jones.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Jones on the other hand supplemented his "buy and hold" stock positions with bets that some other stocks will go down, a sort of hedge. He smoked the competition and the modern day Hedge fund was born. &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Hedge fund focus on investing in a broad range of asset classes, from the increasingly wild world of stocks to credit markets, commodities, currencies and derivatives.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;They are different from mutual funds in the way that not everybody can invest in them. Most funds have strict requirements regarding investors, usually of the net-worth variety, used to separate so-called sophisticates from average Joes.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Because they assume risk, therefore a return of 10-20% is not justified or too small. They need to make money, no matter the market goes up or down. &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Now, the question is why average Joes who might just buys stocks is talking about Hedge Funds...&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;During stock market declines, as we are witnessing now a days, the lenders in Hedge Funds get worried about their money and begin withdrawing money from Hedge Funds. Due to redumption pressure, Hedge Fund manager start selling stocks. Selling on large scale triggers stock price decline which sets panic in market. The panic encourages more selling and - well, you got the idea.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Example, Long Term Capital Management, or LTCM, almost took down the entire financial system when it collapsed in 1998. &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The sheer impact of Hedge Fund on stock market is the main reason behind many bailouts of late, back then the government convened Wall Street’s heaviest hitters -- JPMorgan (JPM), Goldman Sachs (GS), Morgan Stanley (MS) and others -- and forced them to clean up the LTCM mess themselves.&lt;br /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://techforb.blogspot.com/feeds/7828496744370287901/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=4385671836555623731&amp;postID=7828496744370287901" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/4385671836555623731/posts/default/7828496744370287901?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/4385671836555623731/posts/default/7828496744370287901?v=2" /><link rel="alternate" type="text/html" href="http://techforb.blogspot.com/2008/11/about-hedge-funds.html" title="About Hedge Funds..." /><author><name>Vishal Jain</name><uri>http://www.blogger.com/profile/01516639234852190662</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;CUYGRnc7fSp7ImA9WxRUEEQ.&quot;"><id>tag:blogger.com,1999:blog-4385671836555623731.post-3935987948139083389</id><published>2008-11-17T21:59:00.000-08:00</published><updated>2008-11-19T03:12:07.905-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-11-19T03:12:07.905-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="economics" /><category scheme="http://www.blogger.com/atom/ns#" term="detroit" /><category scheme="http://www.blogger.com/atom/ns#" term="GM" /><category scheme="http://www.blogger.com/atom/ns#" term="crisis" /><category scheme="http://www.blogger.com/atom/ns#" term="US" /><category scheme="http://www.blogger.com/atom/ns#" term="finance" /><title>GM's bankruptcy can be Creative Destruction</title><content type="html">GM's probable bankruptcy is in news everywhere. As GM and other automakers in Detroit line for government bailout, stocks are already down a whopping 95% this year.&lt;br /&gt;&lt;br /&gt;Government has already spent billions of US dollars in bailout of financial institutions this year and fiscal deficit is expected to be around $2.5 trillion this year. These bailout are a liability for our children and coming generations. Fiscal deficit is piling up year by year.&lt;br /&gt;&lt;br /&gt;So, the big question around is that &lt;span style="font-weight: bold;"&gt;"Should the government bailout auto industry too?"&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Supports of bailout suggest that the bailout will save around a million jobs directly employed by automakers and indirectly by their suppliers and dealers, and 3-4 million might loose health care benefits, pension etc.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;object height="344" width="425"&gt;&lt;param name="movie" value="http://www.youtube.com/v/72cHfOKoA1c&amp;amp;hl=en&amp;amp;fs=1"&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;param name="allowscriptaccess" value="always"&gt;&lt;embed src="http://www.youtube.com/v/72cHfOKoA1c&amp;amp;hl=en&amp;amp;fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" height="344" width="425"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;But is it correct to reward GM's bad conduct, poor performance for the last many years with this bailout?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;GM has lost almost $74b since 2003. This loss hasn't happened in a single day. GM has continued with poor management and business plans. It's hasn't concentrated on its core business and made risky investments in other businesses. GM is one of the biggest holders of mortgage backed securities in US.&lt;br /&gt;GM has already laid of thousands of workers.&lt;br /&gt;&lt;br /&gt;Moreover, GM business is not going to be healthy soon. More of 50% of US households with 4 or more members have more than 3 cars. So, people are not going to cars at the same pace as they have been doing before. GM should now give reason for people to buy new cars. And that won't come easy. Toyota and Honda have spend big money on R&amp;amp;D of next generation hybrid cars during their heyday. And they are sound even in these tough days. &lt;span style="font-style: italic;"&gt;When the going gets tough, the tough gets going.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;US is a capitalist economy. In the free market, it's not government headache to save falling business. If White House wants to play a role, it should have drafted strict regulations for companies, forced them to invest in new fuels and technologies.&lt;br /&gt;&lt;br /&gt;A bailout at this time will only reward bad conduct. If I lose money, I might borrow money to kick start my business again. If I lose money again, then I won't and shouldn't borrow more money. It's not about confidence but plain financial fundamentals. One more failure and I may end up destroying life of my family members and debt for coming generations. A slow recovery is better than risky one.&lt;br /&gt;&lt;br /&gt;GM has been losing money for last many years. With future business outlook, recovery is not in sight.&lt;br /&gt;And bailout will be a liability for coming generations in US.&lt;br /&gt;&lt;br /&gt;And bankruptcy is not a bad idea. Under Chapter 11, GM will have chance to reorganize. In a bankruptcy, the debt holders line up to come up with a restructuring plan so that they can maximize the return of their loans or obligations. The shareholders get wiped out, but with GM down over 95%, that has largely been accomplished already. It has happened before with thousands of other companies. This healthy process is called &lt;span style="font-weight: bold;"&gt;Creative Destruction&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;Auto Industry has a lot to learn from Tech business and startup. Think Apple. Steve Jobs turned Apple into a success story with next generation products. The products which people like, which build company's reputation. What's good in having a company around that is not able to manage its business, innovate and prepare for the future? Employment? Come on. There is no lack of creative people in US and this world. People will get unemployed once. Some creative people will kick off new businesses and employment will be generated. Even today when many wall street companies are laying off, there are companies having open vacancies. Problem is that new vacancies are less compared to lay offs. Thousands of companies have ceased to exist since start of 20th century but we are still employed with unemployment rate around 5-6%.&lt;br /&gt;&lt;br /&gt;Toyota may be selling hybrid cars in US at very low margin (because they are costlier to build) but these hybrids help them build reputation. Toyota owns near 70% hybrid market in US. Toyota and Honda lead in compact car segment. Usually people buy compact car as their first car. This way Japanese car makers win customers which Detroit has to fight for later on.&lt;br /&gt;&lt;br /&gt;Another example is from Honda, India. Honda has build such a strong reputation in India that it doesn't even advertise its cars on TV. It sells only from &lt;span style="font-weight: bold;"&gt;Word of Mouth Marketing&lt;/span&gt;. Cars they sell come at a premium to cars from other manufacturers in the same segment. Honda has been able to do that because of good performance of its cars.&lt;br /&gt;&lt;br /&gt;Detroit needs to reinvent itself. Cars will be build in Detroit even in future. But companies there need to change their mindset. And a bailout is not going to help in this change.</content><link rel="replies" type="application/atom+xml" href="http://techforb.blogspot.com/feeds/3935987948139083389/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=4385671836555623731&amp;postID=3935987948139083389" title="1 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/4385671836555623731/posts/default/3935987948139083389?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/4385671836555623731/posts/default/3935987948139083389?v=2" /><link rel="alternate" type="text/html" href="http://techforb.blogspot.com/2008/11/gms-bankruptcy-can-be-creative.html" title="GM's bankruptcy can be Creative Destruction" /><author><name>Vishal Jain</name><uri>http://www.blogger.com/profile/01516639234852190662</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>1</thr:total></entry><entry gd:etag="W/&quot;CU8FRn8-fSp7ImA9WxRUEEQ.&quot;"><id>tag:blogger.com,1999:blog-4385671836555623731.post-1253544683336601047</id><published>2008-11-14T03:48:00.000-08:00</published><updated>2008-11-19T03:23:37.155-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-11-19T03:23:37.155-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Tools" /><category scheme="http://www.blogger.com/atom/ns#" term="Linux" /><category scheme="http://www.blogger.com/atom/ns#" term="Yum" /><category scheme="http://www.blogger.com/atom/ns#" term="System" /><title>Useful packages for Linux</title><content type="html">I like to install some useful stuff on my linux machine.&lt;br /&gt;To make my workstation more productive. :)&lt;br /&gt;&lt;br /&gt;Here is the list of packages I usually install:&lt;br /&gt;&lt;br /&gt;- screen&lt;br /&gt;- freenx.i386&lt;br /&gt;&lt;br /&gt;I use yum package manager on Fedora.</content><link rel="replies" type="application/atom+xml" href="http://techforb.blogspot.com/feeds/1253544683336601047/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=4385671836555623731&amp;postID=1253544683336601047" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/4385671836555623731/posts/default/1253544683336601047?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/4385671836555623731/posts/default/1253544683336601047?v=2" /><link rel="alternate" type="text/html" href="http://techforb.blogspot.com/2008/11/i-like-to-install-some-useful-stuff-on.html" title="Useful packages for Linux" /><author><name>Vishal Jain</name><uri>http://www.blogger.com/profile/01516639234852190662</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;C0UEQn09cCp7ImA9WB9RF0w.&quot;"><id>tag:blogger.com,1999:blog-4385671836555623731.post-5583778865964579281</id><published>2007-10-17T02:22:00.000-07:00</published><updated>2007-10-18T05:40:03.368-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2007-10-18T05:40:03.368-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="C" /><category scheme="http://www.blogger.com/atom/ns#" term="Language" /><category scheme="http://www.blogger.com/atom/ns#" term="System" /><title>How to convert an integer to little endian or big endian</title><content type="html">As discussed in my previous post "&lt;a href="http://techforb.blogspot.com/2007/10/little-endian-vs-big-endian.html"&gt;Little endian vs Big endian&lt;/a&gt;", there are some scenario where we need to take care of endianness of system. Consider an example where you want to send data over network to some remote systems. The systems can be of &lt;span style="font-style: italic;"&gt;any&lt;/span&gt; endianness. All interested parties decide that the data transmitted over internet will be in big endian format. The system receiving data will then convert it to local endian format.&lt;br /&gt;&lt;br /&gt;Let's write function to write and read bytes from a 64 bit integer. I am considering 64 bit integer because an endian related C program written with int may work fine on 32 bit platform but will fail on 64 bit platform. So, we will be using strict data types. More on C data types related issues &lt;a href="http://techforb.blogspot.com/2007/10/c-interger-constant-out-of-range.html"&gt;here&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;1. Extract bytes in big endian sequence from &lt;/span&gt;&lt;code style="font-weight: bold;"&gt;uint64_t&lt;/code&gt;&lt;span style="font-weight: bold;"&gt; irrespective of the execution platform.&lt;/span&gt;&lt;br /&gt;&lt;pre name="code" class="c"&gt;&lt;br /&gt;void&lt;br /&gt;uint64ToByteArray (uint64_t num, size_t bytes, unsigned char *arr)&lt;br /&gt;{&lt;br /&gt;size_t i;&lt;br /&gt;unsigned char ch;&lt;br /&gt;for (i = 0; i &amp;lt; bytes; i  )&lt;br /&gt; {&lt;br /&gt;   ch = (num &amp;gt;&amp;gt; ((i &amp;amp; 7) &amp;lt;&amp;lt; 3)) &amp;amp; 0xFF;&lt;br /&gt;   arr[bytes - i - 1] = ch;&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;For &lt;code&gt;UINT64_C (0xabcdef1234567890)&lt;/code&gt;, we will get the following sequence of bytes irrespective of platform.&lt;br /&gt;&lt;code&gt;ab cd ef 12 34 56 78 90&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Infact, we can make this function more generic by adding a type parameter which will specify the sequence in which we need the bytes. Lets support little and big endian.&lt;br /&gt;&lt;pre name="code" class="c"&gt;&lt;br /&gt;#define LITTLE 0&lt;br /&gt;#define BIG 1&lt;br /&gt;&lt;br /&gt;void&lt;br /&gt;uint64ToByteArray (uint64_t num, size_t bytes, unsigned char *arr, int type)&lt;br /&gt;{&lt;br /&gt;size_t i;&lt;br /&gt;unsigned char ch;&lt;br /&gt;for (i = 0; i &amp;lt; bytes; i  )&lt;br /&gt; {&lt;br /&gt;   ch = (num &amp;gt;&amp;gt; ((i &amp;amp; 7) &amp;lt;&amp;lt; 3)) &amp;amp; 0xFF;&lt;br /&gt;   if (type == LITTLE)&lt;br /&gt; arr[i] = ch;&lt;br /&gt;   else if (type == BIG)&lt;br /&gt; arr[bytes - i - 1] = ch;&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;So, if &lt;code&gt;type == 0&lt;/code&gt;, byte sequence will be &lt;code&gt;90 78 56 34 12 ef cd ab&lt;/code&gt;&lt;br /&gt;and if &lt;code&gt;type == 1&lt;/code&gt;, byte sequence will be &lt;code&gt;ab cd ef 12 34 56 78 90&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;2. Reconstruct &lt;/span&gt;&lt;code style="font-weight: bold;"&gt;uint64_t&lt;/code&gt;&lt;span style="font-weight: bold;"&gt; from bytes in little/Big endian sequence irrespective of the execution platform.&lt;/span&gt;&lt;br /&gt;&lt;pre name="code" class="c"&gt;&lt;br /&gt;uint64_t&lt;br /&gt;byteArrayToUInt64 (unsigned char *arr, size_t bytes, int type)&lt;br /&gt;{&lt;br /&gt;uint64_t num = UINT64_C (0);&lt;br /&gt;uint64_t tmp;&lt;br /&gt;&lt;br /&gt;size_t i;&lt;br /&gt;for (i = 0; i &amp;lt; bytes; i  )&lt;br /&gt; {&lt;br /&gt;   tmp = UINT64_C (0);&lt;br /&gt;   if (type == LITTLE)&lt;br /&gt;     tmp = arr[i];&lt;br /&gt;   else if (type == BIG)&lt;br /&gt;     tmp = arr[bytes - i - 1];&lt;br /&gt;&lt;br /&gt; num |= (tmp &amp;lt;&amp;lt; ((i &amp;amp; 7) &amp;lt;&amp;lt; 3));&lt;br /&gt; }&lt;br /&gt;return num;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;So, if byte sequence is &lt;code&gt;90 78 56 34 12 ef cd ab&lt;/code&gt; and &lt;code&gt;type == 0&lt;/code&gt;, then &lt;code&gt;uint64_t&lt;/code&gt; will be &lt;code&gt;0xabcdef1234567890&lt;/code&gt;</content><link rel="replies" type="application/atom+xml" href="http://techforb.blogspot.com/feeds/5583778865964579281/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=4385671836555623731&amp;postID=5583778865964579281" title="10 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/4385671836555623731/posts/default/5583778865964579281?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/4385671836555623731/posts/default/5583778865964579281?v=2" /><link rel="alternate" type="text/html" href="http://techforb.blogspot.com/2007/10/how-to-convert-integer-to-little-endian.html" title="How to convert an integer to little endian or big endian" /><author><name>Vishal Jain</name><uri>http://www.blogger.com/profile/01516639234852190662</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>10</thr:total></entry><entry gd:etag="W/&quot;CkcDRX44eCp7ImA9WB9RFkw.&quot;"><id>tag:blogger.com,1999:blog-4385671836555623731.post-7356754559222150931</id><published>2007-10-12T11:18:00.000-07:00</published><updated>2007-10-17T01:34:34.030-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2007-10-17T01:34:34.030-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="C" /><category scheme="http://www.blogger.com/atom/ns#" term="Language" /><category scheme="http://www.blogger.com/atom/ns#" term="System" /><title>Little endian vs Big endian</title><content type="html">&lt;span style="font-weight: bold;"&gt;Endianness &lt;/span&gt;in simple words is ordering of &lt;span style="font-weight: bold;"&gt;bytes &lt;/span&gt;in memory to represent some data. Computer memory in general is visualized as a &lt;span style="font-style: italic;"&gt;sequence of bytes&lt;/span&gt;. But, in medium or high level languages like C we work with data types with size more than a byte.&lt;br /&gt;&lt;br /&gt;Consider a 32 bit integer (in hex): &lt;code&gt;0xabcdef12&lt;/code&gt;&lt;br /&gt;It consists of 4 bytes: ab, cd, ef, and 12. Hence this integer will occupy 4 bytes in memory. Say we store it at memory address starting 1000. There are &lt;span style="font-weight: bold;"&gt;24&lt;/span&gt; different orderings possible to store these 4 bytes in 4 locations (1000 - 1003). &lt;span style="font-weight: bold;"&gt;2&lt;/span&gt; among these 24 possibilities are very popular. These are called as &lt;span style="font-weight: bold;"&gt;little endian and big endian&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;span style="font-weight: bold;"&gt;Little endian&lt;/span&gt; - Stores the &lt;span style="font-weight: bold;"&gt;L&lt;/span&gt;east significant byte at the &lt;span style="font-weight: bold;"&gt;lowest address&lt;/span&gt;. Example: Intel Pentium Processors.&lt;/li&gt;&lt;li&gt;&lt;span style="font-weight: bold;"&gt;Big endian&lt;/span&gt;     - Stores the Most (&lt;span style="font-weight: bold;"&gt;B&lt;/span&gt;ig) significant byte at the &lt;span style="font-weight: bold;"&gt;lowest address&lt;/span&gt;. Example: Sun/SPARC, IBM/RISC 6000.&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;On little endian system, memory will be like:&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style="font-weight: bold;"&gt;Address&lt;/td&gt;&lt;td style="font-weight: bold;"&gt;Value&lt;/td&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;td&gt;1000&lt;/td&gt;&lt;td&gt;12&lt;/td&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;td&gt;1001&lt;/td&gt;&lt;td&gt;ef&lt;/td&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;td&gt;1002&lt;/td&gt;&lt;td&gt;cd&lt;/td&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;td&gt;1003&lt;/td&gt;&lt;td&gt;ab&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;br /&gt;On Big endian system, memory will be like:&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style="font-weight: bold;"&gt;Address&lt;/td&gt;&lt;td style="font-weight: bold;"&gt;Value&lt;/td&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;td&gt;1000&lt;/td&gt;&lt;td&gt;ab&lt;/td&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;td&gt;1001&lt;/td&gt;&lt;td&gt;cd&lt;/td&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;td&gt;1002&lt;/td&gt;&lt;td&gt;ef&lt;/td&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;td&gt;1003&lt;/td&gt;&lt;td&gt;12&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;Now, the good news is that &lt;span style="font-style: italic;"&gt;usually&lt;/span&gt; we don't need to care about endianness. It's taken care by Hardware Platforms, and Compilers. But, in &lt;span style="font-style: italic;"&gt;some&lt;/span&gt; scenarios &lt;span style="font-style: italic;"&gt;we need to&lt;/span&gt; care about endianness. A common scenario is when the data need to be &lt;span style="font-weight: bold;"&gt;exchanged&lt;/span&gt; between different systems. In such a situation, a standard layout is specified. Example: network protocols like TCP use &lt;span style="font-style: italic;"&gt;Network Byte Order&lt;/span&gt; which is big endian. Thus the writers have to ensure that the data they write is in standardized order.&lt;br /&gt;&lt;br /&gt;Before learning how to write/read in different orders lets play around and take a simple problem to determine endian of a given system.&lt;br /&gt;&lt;br /&gt;There are 2 easy ways.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;1. Write a known integer value in a binary file and view the file contents using a hex utility.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;This method is more &lt;span style="font-weight: bold;"&gt;visual &lt;/span&gt;but is easy to implement and easy to detect layouts other than little/big endian. (Yes, there are other endians too like mixed endian).&lt;br /&gt;&lt;br /&gt;Lets dump a 64 bit integer to a file:&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="c"&gt;&lt;br /&gt;#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;#include &amp;lt;inttypes.h&amp;gt;&lt;br /&gt;&lt;br /&gt;int&lt;br /&gt;main ()&lt;br /&gt;{&lt;br /&gt;uint64_t integerForTesting = UINT64_C (0xabcdef1234567890);&lt;br /&gt;FILE *fp = NULL;&lt;br /&gt;fp = fopen ("dump.bin", "wb");&lt;br /&gt;if (fp)&lt;br /&gt;{&lt;br /&gt;   printf ("Writing 64 bit number = 0x%" PRIx64 "  to dump.bin as it is\n", integerForTesting);&lt;br /&gt; fwrite (integerForTesting, sizeof (uint64_t), 1, fp);&lt;br /&gt; fclose (fp);&lt;br /&gt; printf ("Done writing\n");&lt;br /&gt; return 0;&lt;br /&gt;}&lt;br /&gt;printf ("Not written\n");&lt;br /&gt;return 0;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Now, dump the contents of binary file (dump.bin) using command line hex utility like &lt;code&gt;od.&lt;br /&gt;#od -t x1 --width=8 dump.bin&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;If it dumps something like&lt;code&gt;&lt;br /&gt;0000000 90 78 56 34 12 ef cd ab&lt;br /&gt;0000010&lt;/code&gt;&lt;br /&gt;then the system is little endian.&lt;br /&gt;&lt;br /&gt;If it dumps something like&lt;code&gt;&lt;br /&gt;0000000 ab cd ef 12 34 56 78 90&lt;br /&gt;0000010&lt;/code&gt;&lt;br /&gt;then the system is big endian.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;2. Programmatically by looking at the value of byte stored at the starting address of a known number.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;This method is limited in scope as it looks at only the first byte and only on the basis of that distinguishes between big and little endian. It won't detect other endian systems.&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="c"&gt;&lt;br /&gt;#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;#include &amp;lt;inttypes.h&amp;gt;&lt;br /&gt;&lt;br /&gt;int&lt;br /&gt;main ()&lt;br /&gt;{&lt;br /&gt;uint64_t integerForTesting = UINT64_C (0xabcdef1234567890);&lt;br /&gt;unsigned char *ch = (unsigned char *) &amp;amp;integerForTesting;&lt;br /&gt;FILE *fp = NULL;&lt;br /&gt;if (*ch == 0x90)&lt;br /&gt;{&lt;br /&gt; printf ("this is little endian system\n");&lt;br /&gt;}&lt;br /&gt;else&lt;br /&gt;{&lt;br /&gt; printf ("this is big endian system\n");&lt;br /&gt;}&lt;br /&gt;return 0;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;</content><link rel="replies" type="application/atom+xml" href="http://techforb.blogspot.com/feeds/7356754559222150931/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=4385671836555623731&amp;postID=7356754559222150931" title="2 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/4385671836555623731/posts/default/7356754559222150931?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/4385671836555623731/posts/default/7356754559222150931?v=2" /><link rel="alternate" type="text/html" href="http://techforb.blogspot.com/2007/10/little-endian-vs-big-endian.html" title="Little endian vs Big endian" /><author><name>Vishal Jain</name><uri>http://www.blogger.com/profile/01516639234852190662</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>2</thr:total></entry><entry gd:etag="W/&quot;CkANRHg4eip7ImA9WB9REk8.&quot;"><id>tag:blogger.com,1999:blog-4385671836555623731.post-6979163369360554956</id><published>2007-10-11T00:10:00.000-07:00</published><updated>2007-10-12T13:26:35.632-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2007-10-12T13:26:35.632-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="C" /><category scheme="http://www.blogger.com/atom/ns#" term="Language" /><category scheme="http://www.blogger.com/atom/ns#" term="Warning" /><title>C - Integer constant out of range warning</title><content type="html">C doesn't define sizes exactly. C types such as &lt;span style="font-weight: bold;"&gt;int&lt;/span&gt; and &lt;span style="font-weight: bold;"&gt;long&lt;/span&gt; are defined as being &lt;span style="font-style: italic;"&gt;"at least 16 bits''&lt;/span&gt; and &lt;span style="font-style: italic;"&gt;"at least 32 bits''&lt;/span&gt; respectively.&lt;br /&gt;&lt;br /&gt;If we want to define variables which have a specific size independent of platform, then we can use types such as &lt;span style="font-weight: bold;"&gt;int32_t, int64_t&lt;/span&gt; defined in &lt;span style="font-weight: bold;"&gt;sys/types.h&lt;/span&gt; header file.&lt;br /&gt;&lt;br /&gt;So we would assume that the following code should work:&lt;br /&gt;&lt;pre name="code" class="c"&gt;&lt;br /&gt;#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;#include &amp;lt;sys/types.h&amp;gt;&lt;br /&gt;&lt;br /&gt;int64_t num;&lt;br /&gt;num = 0xabcdef1234567890;&lt;br /&gt;printf("num = %llx\n", num);&lt;br /&gt;&lt;/pre&gt;&lt;code&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Intended O/P: abcdef1234567890&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/code&gt;BUT on some platform/compiler combination the output can come out to be 34567890.&lt;br /&gt;&lt;br /&gt;Such as on &lt;span style="font-weight: bold;"&gt;IBM/AIX&lt;/span&gt;, compiler will give a warning &lt;code&gt;&lt;span style="font-weight: bold; font-style: italic;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;&lt;span style="font-size:130%;"&gt;1506-207 (W) Integer constant &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;value&gt;&lt;span style="font-weight: bold;"&gt;&amp;lt;value&amp;gt; out of range.&lt;/span&gt;&lt;/value&gt;&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Whereas GCC/LINUX will print the intended output.&lt;br /&gt;&lt;br /&gt;The reason is that the integer literal 0xabcdef1234567890 wasn't explicitly specified to be of type int64_t.&lt;br /&gt;&lt;br /&gt;A solution to this is to specify literal as 0xabcdef1234567890&lt;span style="font-weight: bold;"&gt;LL&lt;/span&gt; but a better way of doing this is to use macros in &lt;span style="font-weight: bold;"&gt;stdint.h&lt;/span&gt; (included in inttypes.h)&lt;br /&gt;&lt;pre name="code" class="c"&gt;#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;#include &amp;lt;inttypes.h&amp;gt;&lt;br /&gt;&lt;br /&gt;int64_t num;&lt;br /&gt;num = INT64_C(0xabcdef1234567890);&lt;br /&gt;printf("num = %" PRIx64 "\n", num);&lt;/pre&gt;INT64_C will itself append &lt;span style="font-weight: bold;"&gt;"LL"&lt;/span&gt; or appropriate size specifier to literal depending on platform.</content><link rel="replies" type="application/atom+xml" href="http://techforb.blogspot.com/feeds/6979163369360554956/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=4385671836555623731&amp;postID=6979163369360554956" title="1 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/4385671836555623731/posts/default/6979163369360554956?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/4385671836555623731/posts/default/6979163369360554956?v=2" /><link rel="alternate" type="text/html" href="http://techforb.blogspot.com/2007/10/c-interger-constant-out-of-range.html" title="C - Integer constant out of range warning" /><author><name>Vishal Jain</name><uri>http://www.blogger.com/profile/01516639234852190662</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>1</thr:total></entry><entry gd:etag="W/&quot;DUEMSXk8eyp7ImA9WB5aEUs.&quot;"><id>tag:blogger.com,1999:blog-4385671836555623731.post-7053786842415189549</id><published>2007-09-07T02:48:00.000-07:00</published><updated>2007-09-07T05:21:28.773-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2007-09-07T05:21:28.773-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Web" /><category scheme="http://www.blogger.com/atom/ns#" term="GWT" /><category scheme="http://www.blogger.com/atom/ns#" term="JSON" /><category scheme="http://www.blogger.com/atom/ns#" term="Java" /><category scheme="http://www.blogger.com/atom/ns#" term="AJAX" /><title>Accelerating AJAX based Web Client Development with JSON and GWT</title><content type="html">With the rise of Web 2.0, web client are doing more than parsing and displaying HTML. Web Client are powerful than ever before. There is a shift in programming paradigm with servers providing services and serving data and Clients parsing data, managing state information over and above powerful AJAX UIs. Servers are now proposed to be built the &lt;a href="http://www.xfront.com/REST-Web-Services.html"&gt;REST&lt;/a&gt; way. Server may return data in different format. AJAX has been associated with XML response but response can be in any format. One such format which makes Web 2.0 client development really easy is &lt;a href="http://www.json.org/"&gt;JSON&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;JSON is very similar to XML. It is also text based. Server side objects can be easily serialized into JSON text format using frameworks like &lt;a href="http://turbogears.org/"&gt;TurboGears&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;For example, a library application might provide a Web service that yields books in this XML format:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&amp;lt;book&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;lt;author&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;fullname&amp;gt;Vishal&amp;nbsp;Jain&amp;lt;/fullname&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;org&amp;gt;Consulting&amp;lt;/org&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;lt;/author&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;lt;chapters&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;chapter&amp;nbsp;page="'10'"&amp;gt;Chapter&amp;nbsp;1&amp;lt;/chapter&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;chapter&amp;nbsp;page="'20'"&amp;gt;Chapter&amp;nbsp;2&amp;lt;/chapter&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;lt;/chapters&amp;gt;&lt;br /&gt;&amp;lt;/book&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;With JSON, it looks like this:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;"author"&amp;nbsp;:&amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;"fullname":&amp;nbsp;{&amp;nbsp;"value"&amp;nbsp;:&amp;nbsp;"Vishal&amp;nbsp;Jain"&amp;nbsp;}&amp;nbsp;,&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;"org":&amp;nbsp;{&amp;nbsp;"value"&amp;nbsp;:&amp;nbsp;"Consulting"&amp;nbsp;}&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;"chapters":&amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;"chapter"&amp;nbsp;:&amp;nbsp;[&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&amp;nbsp;"page"&amp;nbsp;:&amp;nbsp;"10",&amp;nbsp;"value"&amp;nbsp;:&amp;nbsp;"Chapter&amp;nbsp;1"&amp;nbsp;}&amp;nbsp;,&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&amp;nbsp;"page"&amp;nbsp;:&amp;nbsp;"20"&amp;nbsp;,&amp;nbsp;"value"&amp;nbsp;:&amp;nbsp;"Chapter&amp;nbsp;2"&amp;nbsp;}&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;]&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;Working with JSON is Javascipt is very easier. In Javascript, we can access information about chapter 2 as&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;var book = eval('(' + req.responseText + ')');&lt;br /&gt;inputBox.value = book.chapters.chapter[1].value;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;An example of JSON response from a real world service can be seen here.&lt;br /&gt;&lt;a href="http://api.search.yahoo.com/ImageSearchService/V1/imageSearch?appid=YahooDemo&amp;query=potato&amp;amp;amp;results=2&amp;output=json"&gt;http://api.search.yahoo.com/ImageSearchService/V1/imageSearch?appid=YahooDemo&amp;amp;query=potato&amp;results=2&amp;amp;output=json&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Working with JSON using GWT&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://techforb.blogspot.com/2007/08/gwt-overview.html"&gt;GWT&lt;/a&gt; provides an elegant way of client side programming where developer codes in Java and Java code is converted into Javascript by GWT.&lt;br /&gt;&lt;br /&gt;GWT comes with &lt;a href="http://code.google.com/webtoolkit/documentation/com.google.gwt.json.client.html"&gt;API&lt;/a&gt; which make working with JSON easier.&lt;br /&gt;&lt;br /&gt;A typical cycle will include:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Sending HTTP GET/POST request for JSON response.&lt;/li&gt;&lt;li&gt;Parsing JSON response in Response Handler&lt;/li&gt;&lt;li&gt;Extracting Data and displaying it as appropriate.&lt;/li&gt;&lt;/ul&gt;Lets take them one by one.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Sending HTTP GET/POST request for JSON response&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;HTTPRequest.asyncGet(&lt;url&gt;, new JSONResponseTextHandler())&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Parsing JSON response in Response Handler&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;Implement a response handler extending ResponseTextHandler&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;private&amp;nbsp;class&amp;nbsp;JSONResponseTextHandler&amp;nbsp;implements&amp;nbsp;ResponseTextHandler&amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;public&amp;nbsp;void&amp;nbsp;onCompletion(String&amp;nbsp;responseText)&amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;try&amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;JSONValue&amp;nbsp;jsonValue&amp;nbsp;=&amp;nbsp;JSONParser.parse(responseText);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;displayJSONObject(jsonValue);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&amp;nbsp;catch&amp;nbsp;(JSONException&amp;nbsp;e)&amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;...&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Extracting Data and displaying it as appropriate&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;private&amp;nbsp;void&amp;nbsp;displayJSONObject(JSONValue&amp;nbsp;jsonValue)&amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;JSONObject&amp;nbsp;book;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if&amp;nbsp;((book&amp;nbsp;=&amp;nbsp;jsonValue.isObject())&amp;nbsp;!=&amp;nbsp;null)&amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;JSONValue&amp;nbsp;chapters&amp;nbsp;=&amp;nbsp;book.get("chapters");&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if(chapters&amp;nbsp;!=&amp;nbsp;null)&amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;JSONArray&amp;nbsp;chapterArray;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if&amp;nbsp;((chapterArray&amp;nbsp;=&amp;nbsp;chapters.isArray())&amp;nbsp;!=&amp;nbsp;null)&amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;JSONObject&amp;nbsp;chapter&amp;nbsp;=&amp;nbsp;chapterArray.get(1).isObject();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;inputBox.setText(chapter.get("value"));&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;That's it!!!&lt;br /&gt;&lt;br /&gt;A demo of JSON/GWT is available &lt;a href="http://gwt.google.com/samples/JSON/JSON.html"&gt;here&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;The source of this demo comes bundled with &lt;a href="http://code.google.com/webtoolkit/"&gt;Google Web Toolkit&lt;/a&gt;.&lt;br /&gt;&lt;/url&gt;</content><link rel="replies" type="application/atom+xml" href="http://techforb.blogspot.com/feeds/7053786842415189549/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=4385671836555623731&amp;postID=7053786842415189549" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/4385671836555623731/posts/default/7053786842415189549?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/4385671836555623731/posts/default/7053786842415189549?v=2" /><link rel="alternate" type="text/html" href="http://techforb.blogspot.com/2007/09/accelerating-ajax-based-web-client.html" title="Accelerating AJAX based Web Client Development with JSON and GWT" /><author><name>Vishal Jain</name><uri>http://www.blogger.com/profile/01516639234852190662</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;CUAASXcyfyp7ImA9WB5aEUg.&quot;"><id>tag:blogger.com,1999:blog-4385671836555623731.post-2890303825616550727</id><published>2007-09-05T13:25:00.000-07:00</published><updated>2007-09-07T01:29:08.997-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2007-09-07T01:29:08.997-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Web" /><category scheme="http://www.blogger.com/atom/ns#" term="Tools" /><category scheme="http://www.blogger.com/atom/ns#" term="Firefox" /><title>Web Developer - Awesome Extension for firefox</title><content type="html">I was looking for web developer tool for firefox which aids in designing web pages especially with monitors of different resolutions. I knew about a developer toolbar provided by Microsoft for &lt;a href="http://www.google.co.in/search?q=ie+developer+toolbar"&gt;IE&lt;/a&gt; but I was looking for a similar extension for firefox when I stumbled upon &lt;a href="http://chrispederick.com/work/web-developer/"&gt;Web Developer extension for firefox.&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;I just downloaded the latest version for Mozilla firefox.   &lt;br /&gt;It's awesome!!!&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_l9mcJGSZ42g/Rt8RpEUQYKI/AAAAAAAAAG0/1lNtuNvvulQ/s1600-h/4.JPG"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://2.bp.blogspot.com/_l9mcJGSZ42g/Rt8RpEUQYKI/AAAAAAAAAG0/1lNtuNvvulQ/s400/4.JPG" alt="" id="BLOGGER_PHOTO_ID_5106819899692441762" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;A decent summary of features: &lt;br /&gt;&lt;ul&gt;&lt;li&gt;Dynamic updating of css of a given page&lt;/li&gt;&lt;li&gt;Images: show their paths, sizes, point out images with no 'alt' attributes, etc.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;All types of page info (cookies, headers, more...)&lt;/li&gt;&lt;li&gt;Utils to clear cache, session cookies, javascript debugger&lt;/li&gt;&lt;li&gt;Helpful outlining: like outlining all block elements&lt;/li&gt;&lt;li &gt;Resize the browser window to various resolutions&lt;/li&gt;&lt;li&gt;Validation : HTML/XHTML, css, validating of link...&lt;/li&gt;&lt;li&gt;Disabling of images, javascript, ...&lt;/li&gt;&lt;li&gt;Links to specifications: css1, css2, HTML, XHTML, DOM...&lt;/li&gt;&lt;li&gt;Manipulating Forms ... various utilities&lt;/li&gt;&lt;/ul&gt;</content><link rel="replies" type="application/atom+xml" href="http://techforb.blogspot.com/feeds/2890303825616550727/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=4385671836555623731&amp;postID=2890303825616550727" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/4385671836555623731/posts/default/2890303825616550727?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/4385671836555623731/posts/default/2890303825616550727?v=2" /><link rel="alternate" type="text/html" href="http://techforb.blogspot.com/2007/09/i-was-looking-for-web-developer-tool.html" title="Web Developer - Awesome Extension for firefox" /><author><name>Vishal Jain</name><uri>http://www.blogger.com/profile/01516639234852190662</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://2.bp.blogspot.com/_l9mcJGSZ42g/Rt8RpEUQYKI/AAAAAAAAAG0/1lNtuNvvulQ/s72-c/4.JPG" height="72" width="72" /><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;C0cNR3o5fSp7ImA9WB9RFk4.&quot;"><id>tag:blogger.com,1999:blog-4385671836555623731.post-8880029240883003679</id><published>2007-09-04T00:30:00.000-07:00</published><updated>2007-10-17T07:24:56.425-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2007-10-17T07:24:56.425-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Web" /><category scheme="http://www.blogger.com/atom/ns#" term="GWT" /><category scheme="http://www.blogger.com/atom/ns#" term="Java" /><category scheme="http://www.blogger.com/atom/ns#" term="Eclipse" /><category scheme="http://www.blogger.com/atom/ns#" term="JBoss" /><title>Deploy GWT using external application server like JBoss</title><content type="html">I wanted to use GWT with external application server. It is really easy to use GWT with embedded tomcat server. But, I needed advanced services provided by managed application servers like &lt;span style="font-weight: bold;"&gt;JBoss&lt;/span&gt;. After figuring out how to use GWT with external web servers, I am posting the details with an example web application.&lt;br /&gt;&lt;br /&gt;Environment:&lt;br /&gt;I am using &lt;span style="font-style: italic;"&gt;GWT version 1.4.1&lt;/span&gt;. Instructions have changed from previous releases of GWT.&lt;br /&gt;&lt;br /&gt;I expect the following system variables are set:&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;GWT_HOME &lt;directory where="" gwt="" was="" extracted=""&gt;&lt;br /&gt;JAVA_HOME&lt;br /&gt;JBOSS_HOME&lt;br /&gt;&lt;/directory&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Step 1: Create sample application using GWT scripts.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;This will use embedded tomcat in step 1. Later on we will change it to use external web app server.&lt;br /&gt;&lt;br /&gt;1) &lt;span style="font-family:courier new;"&gt;cd %GWT_HOME%&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;2) &lt;span style="font-family:courier new;"&gt;projectCreator.cmd -eclipse gwtjboss -out ..\gwtjboss&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;3) &lt;span style="font-family:courier new;"&gt;applicationCreator.cmd -eclipse gwtjboss -out ..\gwtjboss com.gwtjboss.client.GwtJbossTry&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;4) Now verify that the generated application is working with embedded tomcat using &lt;span style="font-family:courier new;"&gt;GwtJbossTry-shell.cmd&lt;/span&gt;&lt;br /&gt;Note the URL in hosted browser  &lt;a href="http://localhost:8888/com.gwtjboss.GwtJbossTry/GwtJbossTry.html"&gt;http://localhost:8888/com.gwtjboss.GwtJbossTry/GwtJbossTry.html&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;5) Also try to bring up the hosted browser using GWT Eclipse launch configuration. It can be accessed from &lt;span style="font-style: italic;"&gt;Run -&gt; Debug... -&gt; click GwtJbossTry under Java Application tree node&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;&lt;snapshot&gt;&lt;/snapshot&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_l9mcJGSZ42g/Rt0WSkUQYHI/AAAAAAAAAGc/8v_QZsxBr4g/s1600-h/1.JPG"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://2.bp.blogspot.com/_l9mcJGSZ42g/Rt0WSkUQYHI/AAAAAAAAAGc/8v_QZsxBr4g/s320/1.JPG" alt="" id="BLOGGER_PHOTO_ID_5106262060750102642" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;directory where="" gwt="" was="" extracted=""&gt;&lt;snapshot&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Step 2: Change to use external application server&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;1) Run &lt;span style="font-family:courier new;"&gt;GwtJbossTry-compile.cmd&lt;/span&gt; script and copy the following files from 'www' output directory to &lt;span style="font-family:courier new;"&gt;%JBOSS_HOME%/server/default/deploy/gwtjboss.war&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;com.gwtjboss.GwtJbossTry\GwtJbossTry.html&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;com.gwtjboss.GwtJbossTry\history.html&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;com.gwtjboss.GwtJbossTry\com.gwtjboss.GwtJbossTry.nocache.js&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;com.gwtjboss.GwtJbossTry\hosted.html&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;2) Update &lt;span style="font-family:courier new;"&gt;GwtJbossTry-shell.cmd.&lt;br /&gt;@java -cp "%~dp0\src;%~dp0\bin;%GWT_HOME%/gwt-user.jar;%GWT_HOME%/gwt-dev-windows.jar" com.google.gwt.dev.GWTShell -noserver -port 8080 -out  %JBOSS_HOME%/server/default/deploy/gwtjboss.war %* gwtjboss/com.gwtjboss.GwtJbossTry/GwtJbossTry.html&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;We have made the following changes to *-shell.cmd:&lt;br /&gt;&lt;/snapshot&gt;&lt;/directory&gt;&lt;ul&gt;&lt;li&gt;&lt;directory where="" gwt="" was="" extracted=""&gt;&lt;snapshot&gt;Added &lt;span style="font-weight: bold;"&gt;-noserver&lt;/span&gt; to tell GWTShell not to start embedded tomcat.&lt;/snapshot&gt;&lt;/directory&gt;&lt;/li&gt;&lt;li&gt;&lt;directory where="" gwt="" was="" extracted=""&gt;&lt;snapshot&gt;Added &lt;span style="font-weight: bold;"&gt;-port 8080&lt;/span&gt; because external server (JBoss here) is running on port 8080.&lt;/snapshot&gt;&lt;/directory&gt;&lt;/li&gt;&lt;li&gt;&lt;directory where="" gwt="" was="" extracted=""&gt;&lt;snapshot&gt;Changed &lt;span style="font-weight: bold;"&gt;output directory&lt;/span&gt; to D:\jboss\server\default\deploy\gwtjboss.war so that clicking compile button in hosted browser will automatically update the deployed application. Note that in complex application, we may need complex packaging mechanism to deploy application. So this compile feature may not be very helpful in complex application. &lt;span style="font-weight: bold;"&gt;[Not necessary]&lt;/span&gt;&lt;br /&gt;&lt;/snapshot&gt;&lt;/directory&gt;&lt;/li&gt;&lt;li&gt;&lt;directory where="" gwt="" was="" extracted=""&gt;&lt;snapshot&gt;Updated the path to HTML page.&lt;/snapshot&gt;&lt;/directory&gt;&lt;/li&gt;&lt;/ul&gt;&lt;directory where="" gwt="" was="" extracted=""&gt;&lt;snapshot&gt;To &lt;span style="font-weight: bold;"&gt;debug &lt;/span&gt;the client side code, we need to update the eclipse launch configuration too.&lt;br /&gt;&lt;/snapshot&gt;&lt;/directory&gt;&lt;ul&gt;&lt;li&gt;&lt;directory where="" gwt="" was="" extracted=""&gt;&lt;snapshot&gt;Go to &lt;span style="font-style: italic;"&gt;Run -&gt; Debug... -&gt; click GwtJbossTry under Java Application tree node&lt;/span&gt;.&lt;/snapshot&gt;&lt;/directory&gt;&lt;/li&gt;&lt;li&gt;&lt;directory where="" gwt="" was="" extracted=""&gt;&lt;snapshot&gt;Update arguments.&lt;/snapshot&gt;&lt;/directory&gt;&lt;/li&gt;&lt;/ul&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_l9mcJGSZ42g/Rt0Xe0UQYII/AAAAAAAAAGk/RI5IhZloNec/s1600-h/2.JPG"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://3.bp.blogspot.com/_l9mcJGSZ42g/Rt0Xe0UQYII/AAAAAAAAAGk/RI5IhZloNec/s320/2.JPG" alt="" id="BLOGGER_PHOTO_ID_5106263370715127938" border="0" /&gt;&lt;/a&gt;&lt;directory where="" gwt="" was="" extracted=""&gt;&lt;snapshot&gt;&lt;snapshot&gt;&lt;br /&gt;3) Now set a &lt;span style="font-weight: bold;"&gt;breakpoint &lt;/span&gt;inside GwtJbossTry class and play around the page. If you hit the breakpoint, you are done.&lt;br /&gt;&lt;br /&gt;This is &lt;span style="font-style: italic;"&gt;all we need&lt;/span&gt; to do to use external server.&lt;br /&gt;We we will hit the URL &lt;a href="http://localhost:8080/gwtjboss/com.gwtjboss.GwtJbossTry/GwtJbossTry.html"&gt;http://localhost:8080/gwtjboss/com.gwtjboss.GwtJbossTry/GwtJbossTry.html&lt;/a&gt; (assuming JBoss running on port 8080)from hosted browser, GWT's hosted browser will intercept Javascript calls and runs the corresponding Java code in its classpath.&lt;br /&gt;&lt;br /&gt;Note the change in URL. We have &lt;span style="font-weight: bold;"&gt;added &lt;/span&gt;gwtjboss to URL. This is because of the fact that we have deployed the application gwtjboss.war&lt;br /&gt;&lt;br /&gt;The directory listing of deployed application is:&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;D:\JBOSS\SERVER\DEFAULT\DEPLOY\GWTJBOSS.WAR&lt;br /&gt;+---com.gwtjboss.GwtJbossTry&lt;/span&gt;&lt;/snapshot&gt;&lt;/snapshot&gt;&lt;/directory&gt;&lt;br /&gt;&lt;directory where="" gwt="" was="" extracted=""&gt;&lt;snapshot&gt;&lt;snapshot&gt;&lt;span style="font-family:courier new;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;com.gwtjboss.GwtJbossTry.nocache.js&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;GwtJbossTry.html&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;history.html&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;hosted.html&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;The modified application is available at googlecode.&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;svn checkout https://gwt-external-server-jboss.googlecode.com/svn/tags/simple-gwt-jboss &lt;/span&gt;&lt;/snapshot&gt;&lt;/snapshot&gt;&lt;/directory&gt;&lt;span style="font-family:courier new;"&gt;simple-gwt-jboss&lt;/span&gt;&lt;br /&gt;or simply &lt;span style="font-weight: bold;"&gt;download &lt;/span&gt;&lt;a href="http://gwt-external-server-jboss.googlecode.com/files/gwtjboss_v01.zip"&gt;gwtjboss_v01.zip&lt;/a&gt;&lt;br /&gt;&lt;directory where="" gwt="" was="" extracted=""&gt;&lt;snapshot&gt;&lt;snapshot&gt;&lt;br /&gt;In this simple example we haven't deployed any servlet and made call to that servlet from GWT client code. Doing that is also easy. We just need to copy compiled client + server code to WEB-INF\classes, gwt-servlet.jar to WEB-INF\lib and update web.xml. More on GWT with servlet deployed in JBoss (external server) later.&lt;/snapshot&gt;&lt;/snapshot&gt;&lt;/directory&gt;</content><link rel="replies" type="application/atom+xml" href="http://techforb.blogspot.com/feeds/8880029240883003679/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=4385671836555623731&amp;postID=8880029240883003679" title="8 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/4385671836555623731/posts/default/8880029240883003679?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/4385671836555623731/posts/default/8880029240883003679?v=2" /><link rel="alternate" type="text/html" href="http://techforb.blogspot.com/2007/09/gwt-with-extenal-application-server.html" title="Deploy GWT using external application server like JBoss" /><author><name>Vishal Jain</name><uri>http://www.blogger.com/profile/01516639234852190662</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://2.bp.blogspot.com/_l9mcJGSZ42g/Rt0WSkUQYHI/AAAAAAAAAGc/8v_QZsxBr4g/s72-c/1.JPG" height="72" width="72" /><thr:total>8</thr:total></entry><entry gd:etag="W/&quot;C0cMQXk5fip7ImA9WB9RFk4.&quot;"><id>tag:blogger.com,1999:blog-4385671836555623731.post-1601213731030978307</id><published>2007-09-03T21:16:00.000-07:00</published><updated>2007-10-17T07:24:40.726-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2007-10-17T07:24:40.726-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Web" /><category scheme="http://www.blogger.com/atom/ns#" term="JSP" /><category scheme="http://www.blogger.com/atom/ns#" term="Java" /><category scheme="http://www.blogger.com/atom/ns#" term="JBoss" /><category scheme="http://www.blogger.com/atom/ns#" term="Exception" /><title>JBoss - JasperException in JSP using generics and 'for each'</title><content type="html">JBoss 4.2.0 throws the following exception while using generics in JSP even if java version is 1.5 or greater&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;Syntax error, parameterized types are only available if source level is 5.0&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;Syntax error, 'for each' statements are only available if source level is 5.0&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The &lt;span style="font-weight: bold;"&gt;workaround &lt;/span&gt;for this issue is to add the following XML configuration to&lt;br /&gt;&lt;span style="font-style: italic;"&gt;${jboss.home}/server/default/deploy/jboss-web.deployer/conf/web.xml&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Add&lt;br /&gt;&lt;br /&gt;&amp;lt;init-param&amp;gt;&lt;br /&gt;&amp;lt;param-name&amp;gt;compilerSourceVM&amp;lt;/param-name&amp;gt;&lt;br /&gt;&amp;lt;param-value&amp;gt;1.5&amp;lt;/param-value&amp;gt;&lt;br /&gt;&amp;lt;/init-param&amp;gt;&lt;br /&gt;&amp;lt;init-param&amp;gt;&lt;br /&gt;&amp;lt;param-name&amp;gt;compilerTargetVM&amp;lt;/param-name&amp;gt;&lt;br /&gt;&amp;lt;param-value&amp;gt;1.5&amp;lt;/param-value&amp;gt;&lt;br /&gt;&amp;lt;/init-param&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;inside &amp;lt;servlet&amp;gt;&lt;/span&gt; tag with &amp;lt;servlet-name&amp;gt;jsp&amp;lt;/servlet-name&amp;gt; inside it.&lt;br /&gt;(Note that there are many servlet tags in this web.xml, so be careful)</content><link rel="replies" type="application/atom+xml" href="http://techforb.blogspot.com/feeds/1601213731030978307/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=4385671836555623731&amp;postID=1601213731030978307" title="9 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/4385671836555623731/posts/default/1601213731030978307?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/4385671836555623731/posts/default/1601213731030978307?v=2" /><link rel="alternate" type="text/html" href="http://techforb.blogspot.com/2007/09/jboss-jasperexception-in-jsp-using.html" title="JBoss - JasperException in JSP using generics and 'for each'" /><author><name>Vishal Jain</name><uri>http://www.blogger.com/profile/01516639234852190662</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>9</thr:total></entry><entry gd:etag="W/&quot;C0cCQnY7eip7ImA9WB9RFk4.&quot;"><id>tag:blogger.com,1999:blog-4385671836555623731.post-5564250042333811859</id><published>2007-08-07T23:46:00.000-07:00</published><updated>2007-10-17T07:24:23.802-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2007-10-17T07:24:23.802-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Web" /><category scheme="http://www.blogger.com/atom/ns#" term="GWT" /><category scheme="http://www.blogger.com/atom/ns#" term="Java" /><category scheme="http://www.blogger.com/atom/ns#" term="AJAX" /><title>Why should I use Google Web Toolkit (GWT) ?</title><content type="html">&lt;a href="http://code.google.com/webtoolkit/"&gt;Google Web Toolkit (GWT)&lt;/a&gt; was launched by Google in May 2006 and the toolkit is being evaluated by web developers around the world. GWT enables &lt;a href="http://en.wikipedia.org/wiki/Ajax_%28programming%29"&gt;AJAX&lt;/a&gt; based web applications to be coded in Java language. GWT will then convert Java code written for client side (browser) to JavaScript which can run on any &lt;a href="http://en.wikipedia.org/wiki/Web_browser"&gt;Javascript enabled browser&lt;/a&gt; (most modern browsers are).&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Pros:&lt;/span&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Java Developers can &lt;span style="font-style: italic;"&gt;easily develop AJAX based web apps&lt;/span&gt; without learning JavaScript.&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;JavaScript generated by GWT is &lt;span style="font-style: italic;"&gt;browser independent.&lt;/span&gt; So it saves the headache of supporting multiple browsers.&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;Coding in Java &lt;span style="font-style: italic;"&gt;increases the testability&lt;/span&gt; of source code since Java is type-based language. GWT also provides &lt;a href="http://code.google.com/webtoolkit/documentation/com.google.gwt.doc.DeveloperGuide.JUnitIntegration.html"&gt;JUnit integration&lt;/a&gt; for writing test cases for client side code.&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;GWT helps manage browser &lt;span style="font-style: italic;"&gt;back button&lt;/span&gt; easily which is usually ignored in AJAX web apps.&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;GWT doesn't invade the server side code. It draws a boundary b/w &lt;a href="http://code.google.com/webtoolkit/documentation/com.google.gwt.doc.DeveloperGuide.Fundamentals.ProjectStructure.html"&gt;server and client side code&lt;/a&gt;. Bottom line - GWT &lt;span style="font-weight: bold; font-style: italic;"&gt;is not a framework&lt;/span&gt; which is good. Not much shakeup is required to start using GWT. &lt;a href="http://code.google.com/webtoolkit/documentation/com.google.gwt.doc.DeveloperGuide.Fundamentals.ClientSide.html"&gt;Client side  code&lt;/a&gt;  &lt;a href="http://code.google.com/webtoolkit/documentation/com.google.gwt.doc.DeveloperGuide.Fundamentals.ServerSide.html"&gt;Server side code&lt;/a&gt;&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;And above all.. &lt;a href="http://code.google.com/webtoolkit/documentation/com.google.gwt.doc.DeveloperGuide.Fundamentals.HostedMode.html"&gt;DEBUGGING&lt;/a&gt;. Client side Java code can be debugged using any Java debugger such as &lt;a href="http://www.eclipse.org/"&gt;Eclipse&lt;/a&gt;, Netbeans etc. Once the developer is sure that client Java code is working fine, then it can be converted to JavaScript.&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;To support debugging, GWT supports 2 browsing modes. &lt;a href="http://code.google.com/webtoolkit/documentation/com.google.gwt.doc.DeveloperGuide.Fundamentals.JavaToJavaScriptCompiler.html"&gt;Hosted mode and web mode&lt;/a&gt;. In hosted mode, a special browser shipped with GWT is used to running client code as Java (i.e. without conversion to JavaScript). In web mode, any browser can be used and compiled JavaScript is run. It also provides scripts to run hosted mode.&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;GWT also provides &lt;a href="http://code.google.com/webtoolkit/documentation/com.google.gwt.doc.DeveloperGuide.Fundamentals.CommandLineTools.html"&gt;scripts&lt;/a&gt; to easily generated project stubs (&lt;a href="http://www.eclipse.org/"&gt;Eclipse IDE based Java projects&lt;/a&gt;), sample code, test cases, compilation to JavaScript.&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;How to exchange &lt;span style="font-weight: bold; font-style: italic;"&gt;data &lt;/span&gt;with client side? GWT helps here by serializing data b/w client and server side using &lt;a href="http://code.google.com/webtoolkit/documentation/com.google.gwt.doc.DeveloperGuide.RemoteProcedureCalls.html"&gt;GWT-RPC&lt;/a&gt;. In simple words, the server side code creates a Java object of client side Java class (which has been translated and equivalent JavaScript code also exists on client side). GWT serializes the object and populates the equivalent JavaScript code on client side. &lt;a href="http://code.google.com/webtoolkit/documentation/com.google.gwt.doc.DeveloperGuide.RemoteProcedureCalls.PlumbingDiagram.html"&gt;Diagram...&lt;/a&gt; The serializable classes can be any primitive Java type, their wrappers, String, Date, class implementing IsSerializable interface and Arrays of objects of serializable classes (including Arrays of Arrays). &lt;span style="font-style: italic;"&gt;Note:&lt;/span&gt; GWT-RPC is tailored RPC protocol for communication b/w Java and JavaScript. It should not be confused with standard RPC.&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;Supports &lt;a href="http://code.google.com/webtoolkit/documentation/com.google.gwt.doc.DeveloperGuide.Internationalization.html"&gt;Internationalization.&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;span style="font-weight: bold;"&gt;Cons:&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://code.google.com/webtoolkit/documentation/com.google.gwt.doc.DeveloperGuide.Fundamentals.JavaToJavaScriptCompiler.JavaRuntimeSupport.html"&gt;Few Java classes&lt;/a&gt; can be used in client side code.&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;Java 1.5 or above are not supports on client side code. Hence user can't use features like annotations, generics in client side code. This doesn't mean that you can't use Java 5.0 or 6.0 JDK. Only the source code need to comply with JDK 1.4.2.&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://en.wikipedia.org/wiki/CSS"&gt;CSS&lt;/a&gt; is used to styling so user still got to play around CSS. This is also good from Java code point of view as style information is not getting deeply hard coded in Java. Only style names are coded in Java. These styles are defined in CSS. GWT provides default styles for most of the &lt;a href="http://code.google.com/webtoolkit/documentation/com.google.gwt.doc.DeveloperGuide.UserInterface.html"&gt;widgets&lt;/a&gt;.&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;No support for other languages. But people are working on it. Find out more...&lt;/li&gt;&lt;/ul&gt;&lt;a href="http://www.gwtsite.com/?m=200605&amp;paged=2"&gt; http://www.gwtsite.com/?m=200605&amp;amp;paged=2&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.gwtpowered.org/#Resources"&gt; http://www.gwtpowered.org/#Resources&lt;/a&gt;&lt;br /&gt;&lt;a href="http://code.google.com/hosting/search?q=label%3AGWT&amp;btn=Search+Projects"&gt; Google Project Search with label GWT&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Overall GWT materializes a great idea. For Java developers, its a great gift from Google. For guys from non-Java background, it will be hard to use and play around initially. Just a bunch of scripts and mainly 3 jars to play around with.&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;span style="font-style: italic;"&gt;   gwt-user.jar&lt;/span&gt; - While coding in Java and hosted mode.&lt;/li&gt;&lt;li&gt;&lt;span style="font-style: italic;"&gt;   gwt-dev-{OS_NAME}.jar&lt;/span&gt; - Debugging in hosted mode.&lt;/li&gt;&lt;li&gt;&lt;span style="font-style: italic;"&gt;   gwt-servlet.jar&lt;/span&gt; - To be used in web app container as some client side Java code is also used on server side.&lt;/li&gt;&lt;/ul&gt;&lt;span style="font-weight: bold;"&gt;Useful Links:&lt;/span&gt;&lt;br /&gt;&lt;a href="http://code.google.com/webtoolkit/documentation/"&gt;Documentation&lt;/a&gt;&lt;br /&gt;&lt;a href="http://code.google.com/webtoolkit/faq.html"&gt;FAQs&lt;/a&gt;</content><link rel="replies" type="application/atom+xml" href="http://techforb.blogspot.com/feeds/5564250042333811859/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=4385671836555623731&amp;postID=5564250042333811859" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/4385671836555623731/posts/default/5564250042333811859?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/4385671836555623731/posts/default/5564250042333811859?v=2" /><link rel="alternate" type="text/html" href="http://techforb.blogspot.com/2007/08/gwt-overview.html" title="Why should I use Google Web Toolkit (GWT) ?" /><author><name>Vishal Jain</name><uri>http://www.blogger.com/profile/01516639234852190662</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total></entry></feed>
