<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Snippet IT &#187; Programming and Scripting</title>
	<atom:link href="http://www.snippetit.com/category/programming-and-scripting/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.snippetit.com</link>
	<description>IT News, Programming, Internet and Blogging</description>
	<lastBuildDate>Mon, 16 Aug 2010 13:21:23 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Unix Shell Script: How to Receive Input Right After Echoing A Line</title>
		<link>http://www.snippetit.com/2010/08/unix-shell-script-how-to-receive-input-right-after-echoing-a-line/</link>
		<comments>http://www.snippetit.com/2010/08/unix-shell-script-how-to-receive-input-right-after-echoing-a-line/#comments</comments>
		<pubDate>Mon, 16 Aug 2010 13:21:23 +0000</pubDate>
		<dc:creator>szehau</dc:creator>
				<category><![CDATA[Programming and Scripting]]></category>

		<guid isPermaLink="false">http://www.snippetit.com/?p=389</guid>
		<description><![CDATA[For example, say I echo a line of text in shell script and I want to receive user input just right after the text (not in the next line). The are several ways to do it: Method 1 echo "Enter a value: \c" read value Method 2 echo -n "Enter a value: " read value [...]]]></description>
			<content:encoded><![CDATA[<p>For example, say I echo a line of text in shell script and I want to receive user input just right after the text (not in the next line). The are several ways to do it:</p>
<p>Method 1</p>
<p><code>echo "Enter a value: \c"<br />
read value</code></p>
<p>Method 2</p>
<p><code>echo -n "Enter a value: "<br />
read value</code></p>
<p>Method 3</p>
<p><code>read -p "Enter a value: " value</code></p>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-enjoy">
<ul class="socials">
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=Unix+Shell+Script%3A+How+to+Receive+Input+Right+After+Echoing+A+Line+-+http://b2l.me/ahqjs5&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="shr-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://www.snippetit.com/2010/08/unix-shell-script-how-to-receive-input-right-after-echoing-a-line/&amp;imageurl=" rel="nofollow" class="external" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="shr-yahoobuzz">
			<a href="http://buzz.yahoo.com/submit/?submitUrl=http://www.snippetit.com/2010/08/unix-shell-script-how-to-receive-input-right-after-echoing-a-line/&amp;submitHeadline=Unix+Shell+Script%3A+How+to+Receive+Input+Right+After+Echoing+A+Line&amp;submitSummary=For%20example%2C%20say%20I%20echo%20a%20line%20of%20text%20in%20shell%20script%20and%20I%20want%20to%20receive%20user%20input%20just%20right%20after%20the%20text%20%28not%20in%20the%20next%20line%29.%20The%20are%20several%20ways%20to%20do%20it%3A%0D%0A%0D%0AMethod%201%0D%0A%0D%0Aecho%20%22Enter%20a%20value%3A%20%5Cc%22%0D%0Aread%20value%0D%0A%0D%0AMethod%202%0D%0A%0D%0Aecho%20-n%20%22Enter%20a%20value%3A%20%22%0D%0Aread%20value%0D%0A%0D%0AMethod%203%0D%0A%0D%0Aread%20-p%20%22En&amp;submitCategory=science&amp;submitAssetType=text" rel="nofollow" class="external" title="Buzz up!">Buzz up!</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://www.snippetit.com/2010/08/unix-shell-script-how-to-receive-input-right-after-echoing-a-line/&amp;title=Unix+Shell+Script%3A+How+to+Receive+Input+Right+After+Echoing+A+Line" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://www.snippetit.com/2010/08/unix-shell-script-how-to-receive-input-right-after-echoing-a-line/&amp;title=Unix+Shell+Script%3A+How+to+Receive+Input+Right+After+Echoing+A+Line" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-blinklist">
			<a href="http://www.blinklist.com/index.php?Action=Blink/addblink.php&amp;Url=http://www.snippetit.com/2010/08/unix-shell-script-how-to-receive-input-right-after-echoing-a-line/&amp;Title=Unix+Shell+Script%3A+How+to+Receive+Input+Right+After+Echoing+A+Line" rel="nofollow" class="external" title="Share this on Blinklist">Share this on Blinklist</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://www.snippetit.com/2010/08/unix-shell-script-how-to-receive-input-right-after-echoing-a-line/&amp;title=Unix+Shell+Script%3A+How+to+Receive+Input+Right+After+Echoing+A+Line" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="shr-technorati">
			<a href="http://technorati.com/faves?add=http://www.snippetit.com/2010/08/unix-shell-script-how-to-receive-input-right-after-echoing-a-line/" rel="nofollow" class="external" title="Share this on Technorati">Share this on Technorati</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>

<h2  class="related_post_title">Most Commented Posts</h2><ul class="related_post"><li><a href="http://www.snippetit.com/2009/12/google-wave-invitation-giveaway/" title="Google Wave Invitation Giveaway">Google Wave Invitation Giveaway</a></li><li><a href="http://www.snippetit.com/2009/01/website-value-evaluation-tool/" title="Website value evaluation tool">Website value evaluation tool</a></li><li><a href="http://www.snippetit.com/2009/04/wordpress-plugin-blogtal-trackback/" title="Wordpress Plugin &#8211; Blogtal Trackback">Wordpress Plugin &#8211; Blogtal Trackback</a></li><li><a href="http://www.snippetit.com/2009/04/wordpress-plugin-default-trackbacks/" title="Wordpress Plugin &#8211; Default Trackbacks">Wordpress Plugin &#8211; Default Trackbacks</a></li><li><a href="http://www.snippetit.com/2009/02/c-loop-all-files-in-directory-and-its-sub-directories/" title="C# &#8211; Loop all files in directory and it&#8217;s sub-directories">C# &#8211; Loop all files in directory and it&#8217;s sub-directories</a></li><li><a href="http://www.snippetit.com/2009/05/wordpress-make-your-wordpress-a-little-bit-more-secure/" title="Wordpress: Make Your Wordpress A Little Bit More Secure">Wordpress: Make Your Wordpress A Little Bit More Secure</a></li><li><a href="http://www.snippetit.com/2008/10/implement-your-own-short-url/" title="Implement your own short URL">Implement your own short URL</a></li><li><a href="http://www.snippetit.com/2009/05/windows-live-messenger-beware-of-unsolicited-messages-sent-from-your-friends-live-account/" title="Windows Live Messenger: Beware of Unsolicited Messages Sent From Your Friends&#8217; Live Account">Windows Live Messenger: Beware of Unsolicited Messages Sent From Your Friends&#8217; Live Account</a></li><li><a href="http://www.snippetit.com/2009/07/java-mortgage-payment-calculator/" title="Java: Mortgage Payment Calculator">Java: Mortgage Payment Calculator</a></li><li><a href="http://www.snippetit.com/2009/02/gmails-labels-menu/" title="Gmail&#8217;s Labels menu">Gmail&#8217;s Labels menu</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.snippetit.com/2010/08/unix-shell-script-how-to-receive-input-right-after-echoing-a-line/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Database: CHAR and VARCHAR &#8211; What are the differences?</title>
		<link>http://www.snippetit.com/2010/05/database-char-and-varchar-what-are-the-differences/</link>
		<comments>http://www.snippetit.com/2010/05/database-char-and-varchar-what-are-the-differences/#comments</comments>
		<pubDate>Sun, 30 May 2010 15:28:01 +0000</pubDate>
		<dc:creator>szehau</dc:creator>
				<category><![CDATA[Programming and Scripting]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[DBMS]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[search engine optimization]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://www.snippetit.com/?p=383</guid>
		<description><![CDATA[Most programmers may already know the main different between CHAR and VARCHAR - The first one supports fixed-length data and the second one supports variable-lengths of data. Some people may think, since VARCHAR can do what CHAR does, then why we still need CHAR in our database design. I even have heard one of the [...]]]></description>
			<content:encoded><![CDATA[<p>Most programmers may already know the main different between CHAR and VARCHAR - The first one supports fixed-length data and the second one supports variable-lengths of data.</p>
<p>Some people may think, since VARCHAR can do what CHAR does, then why we still need CHAR in our database design. I even have heard one of the very experienced Oracle database administrator say "Nowadays nobody is using CHAR anymore, you can forget about putting CHAR column in your database design".</p>
<p><span id="more-383"></span></p>
<p>The statement is not totally right. Even though VARCHAR can do what CHAR does, CHAR does has certain level of advantages over VARCHAR in terms of performance, efficiency and space.</p>
<p>I think it is good for a database designer to know how a database is being design. In other words, to think how a database programmer will design the database management system (DBMS) for the best performance and efficiency.</p>
<p>1. When a table column size is quite small, for instance 1 to 4 bytes, using CHAR helps save more space then VARCHAR. This is because DBMS will need additional few bytes (depends on database limitation for VARCHAR) to keep track the length of the data (all the rows) for the VARCHAR column.</p>
<p>2. Since VARCHAR can keep variable size of data, therefore it needs to keep track the length of the data for all the records. Therefore it adds little overhead to the DBMS's performance if compared to CHAR.</p>
<p>3. DBMS (I would say most systems) keeps fixed-length data and index more efficiently. Retrieving and updating data from and to a fixed-length row table is faster then a variable-length row table.</p>
<p>Therefore, I think CHAR is still very useful. We should always use CHAR if the column size is small enough or the data input is always going to be the size of the column (e.g. most of the data is in 10-12 bytes size and the column size is 12 bytes), so that we can get better performance for our application.</p>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-enjoy">
<ul class="socials">
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=Database%3A+CHAR+and+VARCHAR+-+What+are+the+differences%3F+-+http://b2l.me/xx9ja&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="shr-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://www.snippetit.com/2010/05/database-char-and-varchar-what-are-the-differences/&amp;imageurl=" rel="nofollow" class="external" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="shr-yahoobuzz">
			<a href="http://buzz.yahoo.com/submit/?submitUrl=http://www.snippetit.com/2010/05/database-char-and-varchar-what-are-the-differences/&amp;submitHeadline=Database%3A+CHAR+and+VARCHAR+-+What+are+the+differences%3F&amp;submitSummary=Most%20programmers%20may%20already%20know%20the%20main%20different%20between%20CHAR%20and%20VARCHAR%20-%20The%20first%20one%20supports%20fixed-length%20data%20and%20the%20second%20one%20supports%20variable-lengths%20of%20data.%0D%0A%0D%0ASome%20people%20may%20think%2C%20since%20VARCHAR%20can%20do%20what%20CHAR%20does%2C%20then%20why%20we%20still%20need%20CHAR%20in%20our%20database%20design.%20I%20even%20hav&amp;submitCategory=science&amp;submitAssetType=text" rel="nofollow" class="external" title="Buzz up!">Buzz up!</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://www.snippetit.com/2010/05/database-char-and-varchar-what-are-the-differences/&amp;title=Database%3A+CHAR+and+VARCHAR+-+What+are+the+differences%3F" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://www.snippetit.com/2010/05/database-char-and-varchar-what-are-the-differences/&amp;title=Database%3A+CHAR+and+VARCHAR+-+What+are+the+differences%3F" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-blinklist">
			<a href="http://www.blinklist.com/index.php?Action=Blink/addblink.php&amp;Url=http://www.snippetit.com/2010/05/database-char-and-varchar-what-are-the-differences/&amp;Title=Database%3A+CHAR+and+VARCHAR+-+What+are+the+differences%3F" rel="nofollow" class="external" title="Share this on Blinklist">Share this on Blinklist</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://www.snippetit.com/2010/05/database-char-and-varchar-what-are-the-differences/&amp;title=Database%3A+CHAR+and+VARCHAR+-+What+are+the+differences%3F" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="shr-technorati">
			<a href="http://technorati.com/faves?add=http://www.snippetit.com/2010/05/database-char-and-varchar-what-are-the-differences/" rel="nofollow" class="external" title="Share this on Technorati">Share this on Technorati</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>

<h2  class="related_post_title">Related Articles</h2><ul class="related_post"><li><a href="http://www.snippetit.com/2010/01/java-format-integer-into-fixed-width-string/" title="Java: Format Integer Into Fixed Width String">Java: Format Integer Into Fixed Width String</a></li><li><a href="http://www.snippetit.com/2009/11/java-loading-large-data-into-jtable-or-jlist/" title="Java: Loading Large Data into JTable or JList">Java: Loading Large Data into JTable or JList</a></li><li><a href="http://www.snippetit.com/2009/05/seo-get-higher-ranking-in-search-engines/" title="SEO: Get Higher Ranking in Search Engines">SEO: Get Higher Ranking in Search Engines</a></li><li><a href="http://www.snippetit.com/2009/05/java-least-recently-used-lru-cache/" title="Java: Least Recently Used (LRU) Cache">Java: Least Recently Used (LRU) Cache</a></li><li><a href="http://www.snippetit.com/2009/05/php-how-to-protect-password-in-database-password-hashing/" title="PHP: How to Protect Password in Database &#8211; Password Hashing">PHP: How to Protect Password in Database &#8211; Password Hashing</a></li><li><a href="http://www.snippetit.com/2009/04/java-randomly-sort-values-in-a-array-the-generic-way-in-single-pasas/" title="Java: Randomly sort values in a array (the generic way) in single pass">Java: Randomly sort values in a array (the generic way) in single pass</a></li><li><a href="http://www.snippetit.com/2009/03/java-format-integer-into-number-of-decimal-places-and-performance/" title="Java: Format integer into number of decimal places and performance">Java: Format integer into number of decimal places and performance</a></li><li><a href="http://www.snippetit.com/2008/04/introduction/" title="Introduction">Introduction</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.snippetit.com/2010/05/database-char-and-varchar-what-are-the-differences/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Java: Use ByteBuffer As InputStream</title>
		<link>http://www.snippetit.com/2010/01/java-use-bytebuffer-as-inputstream/</link>
		<comments>http://www.snippetit.com/2010/01/java-use-bytebuffer-as-inputstream/#comments</comments>
		<pubDate>Mon, 11 Jan 2010 17:05:38 +0000</pubDate>
		<dc:creator>szehau</dc:creator>
				<category><![CDATA[Programming and Scripting]]></category>
		<category><![CDATA[Tips and Tricks]]></category>
		<category><![CDATA[ByteBuffer]]></category>
		<category><![CDATA[InputStream]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://www.snippetit.com/?p=381</guid>
		<description><![CDATA[Sometime, your program may need to read data from a ByteBuffer buffer into a InputStream object. There is no class in Java library that provide the facility to do the conversion. Anyway, to use a ByteBuffer object as an InputStream is pretty simple. What you need to do is to write a class wrapper that [...]]]></description>
			<content:encoded><![CDATA[<p>Sometime, your program may need to read data from a <code>ByteBuffer</code> buffer into a <code>InputStream</code> object. There is no class in Java library that provide the facility to do the conversion.</p>
<p>Anyway, to use a <code>ByteBuffer</code> object as an <code>InputStream</code> is pretty simple. What you need to do is to write a class wrapper that inherit <code>InputStream</code> and override the <code>read()</code> function in InputStream.</p>
<p><span id="more-381"></span></p>
<p>Here is the example:</p>
<p><code> </code></p>
<p><code></p>
<pre>public class ByteBufferInputStream extends InputStream {

  private int bbisInitPos;
  private int bbisLimit;
  private ByteBuffer bbisBuffer;

  public ByteBufferInputStream(ByteBuffer buffer) {
    this(buffer, buffer.limit() - buffer.position());
  }

  public ByteBufferInputStream(ByteBuffer buffer, int limit) {
    bbisBuffer = buffer;
    bbisLimit = limit;
    bbisInitPos = bbisBuffer.position();
  }

  @Override
  public int read() throws IOException {
    if (bbisBuffer.position() - bbisInitPos &gt; bbisLimit)
      return -1;
    return bbisBuffer.get();
  }
}</pre>
<p></code></p>
<p>In this class, <code>ByteBufferInputStream</code>, you can specify the limit to read from the <code>ByteBuffer</code> so that you can use the data in ByteBuffer later for other purposes. The read behavior is same as other <code>InputStream</code> class, where when there is no more data to read (or reached the preset limit), the <code>read()</code> function returns negative one.</p>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-enjoy">
<ul class="socials">
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=Java%3A+Use+ByteBuffer+As+InputStream+-+http://b2l.me/dgdbw&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="shr-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://www.snippetit.com/2010/01/java-use-bytebuffer-as-inputstream/&amp;imageurl=" rel="nofollow" class="external" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="shr-yahoobuzz">
			<a href="http://buzz.yahoo.com/submit/?submitUrl=http://www.snippetit.com/2010/01/java-use-bytebuffer-as-inputstream/&amp;submitHeadline=Java%3A+Use+ByteBuffer+As+InputStream&amp;submitSummary=Sometime%2C%20your%20program%20may%20need%20to%20read%20data%20from%20a%20ByteBuffer%20buffer%20into%20a%20InputStream%20object.%20There%20is%20no%20class%20in%20Java%20library%20that%20provide%20the%20facility%20to%20do%20the%20conversion.%0D%0A%0D%0AAnyway%2C%20to%20use%20a%20ByteBuffer%20object%20as%20an%20InputStream%20is%20pretty%20simple.%20What%20you%20need%20to%20do%20is%20to%20write%20a%20class%20wrapper&amp;submitCategory=science&amp;submitAssetType=text" rel="nofollow" class="external" title="Buzz up!">Buzz up!</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://www.snippetit.com/2010/01/java-use-bytebuffer-as-inputstream/&amp;title=Java%3A+Use+ByteBuffer+As+InputStream" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://www.snippetit.com/2010/01/java-use-bytebuffer-as-inputstream/&amp;title=Java%3A+Use+ByteBuffer+As+InputStream" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-blinklist">
			<a href="http://www.blinklist.com/index.php?Action=Blink/addblink.php&amp;Url=http://www.snippetit.com/2010/01/java-use-bytebuffer-as-inputstream/&amp;Title=Java%3A+Use+ByteBuffer+As+InputStream" rel="nofollow" class="external" title="Share this on Blinklist">Share this on Blinklist</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://www.snippetit.com/2010/01/java-use-bytebuffer-as-inputstream/&amp;title=Java%3A+Use+ByteBuffer+As+InputStream" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="shr-technorati">
			<a href="http://technorati.com/faves?add=http://www.snippetit.com/2010/01/java-use-bytebuffer-as-inputstream/" rel="nofollow" class="external" title="Share this on Technorati">Share this on Technorati</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>

<h2  class="related_post_title">Related Articles</h2><ul class="related_post"><li><a href="http://www.snippetit.com/2010/01/java-format-integer-into-fixed-width-string/" title="Java: Format Integer Into Fixed Width String">Java: Format Integer Into Fixed Width String</a></li><li><a href="http://www.snippetit.com/2009/12/java-continuously-read-data-from-filechannel-without-mappedbytebuffer/" title="Java: Continuously Read Data From FileChannel Without MappedByteBuffer">Java: Continuously Read Data From FileChannel Without MappedByteBuffer</a></li><li><a href="http://www.snippetit.com/2009/11/wordpress-rename-permalink-url-with-ease-in-administrator-page/" title="Wordpress: Rename Permalink URL with Ease in Administrator Page">Wordpress: Rename Permalink URL with Ease in Administrator Page</a></li><li><a href="http://www.snippetit.com/2009/11/wordpress-schedule-to-publish-a-post/" title="Wordpress: Schedule to Publish a Post">Wordpress: Schedule to Publish a Post</a></li><li><a href="http://www.snippetit.com/2009/11/java-loading-large-data-into-jtable-or-jlist/" title="Java: Loading Large Data into JTable or JList">Java: Loading Large Data into JTable or JList</a></li><li><a href="http://www.snippetit.com/2009/08/java-format-long-integer-into-hexadecimal-string/" title="Java: Format Long Integer Into Hexadecimal String">Java: Format Long Integer Into Hexadecimal String</a></li><li><a href="http://www.snippetit.com/2009/07/java-mortgage-payment-calculator/" title="Java: Mortgage Payment Calculator">Java: Mortgage Payment Calculator</a></li><li><a href="http://www.snippetit.com/2009/06/java-stop-a-thread-correctly/" title="Java: Stop A Thread Correctly">Java: Stop A Thread Correctly</a></li><li><a href="http://www.snippetit.com/2009/05/java-format-bytes-array-into-hexadecimal-string/" title="Java: Format Bytes Array into Hexadecimal String">Java: Format Bytes Array into Hexadecimal String</a></li><li><a href="http://www.snippetit.com/2009/05/java-least-recently-used-lru-cache/" title="Java: Least Recently Used (LRU) Cache">Java: Least Recently Used (LRU) Cache</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.snippetit.com/2010/01/java-use-bytebuffer-as-inputstream/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Java: Format Integer Into Fixed Width String</title>
		<link>http://www.snippetit.com/2010/01/java-format-integer-into-fixed-width-string/</link>
		<comments>http://www.snippetit.com/2010/01/java-format-integer-into-fixed-width-string/#comments</comments>
		<pubDate>Mon, 04 Jan 2010 17:36:47 +0000</pubDate>
		<dc:creator>szehau</dc:creator>
				<category><![CDATA[Programming and Scripting]]></category>
		<category><![CDATA[Tips and Tricks]]></category>
		<category><![CDATA[format]]></category>
		<category><![CDATA[format Integer]]></category>
		<category><![CDATA[how to]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[String]]></category>

		<guid isPermaLink="false">http://www.snippetit.com/?p=374</guid>
		<description><![CDATA[Sometime, you may want to format an integer or a long value into a fixed width String. You need to display the value in fixed width especially in reports where you want to keep the numbers in aligned (e.g. 3456 as 0003456 and 1234 as 0001234). Other than that, you may also want to format the integer value [...]]]></description>
			<content:encoded><![CDATA[<p>Sometime, you may want to format an <code>integer</code> or a <code>long</code> value into a fixed width <code>String</code>. You need to display the value in fixed width especially in reports where you want to keep the numbers in aligned (e.g. 3456 as <code>0003456</code> and 1234 as <code>0001234</code>).</p>
<p>Other than that, you may also want to format the <code>integer</code> value for a better visibility. For example, to display <code>integer</code> value as a document number (e.g. 12345678 as <code>00-01234-5678</code>), for example an account number.</p>
<p>The <code>Java.format()</code> is not flexible enough to solve my problem. At least it cannot be used to format a fixed length document number in the format I want: <code>XX-XXXX-XXXX</code>. Therefore I decide write my own format function.</p>
<p><span id="more-374"></span></p>
<p>The following function format a <code>integer</code> value into a fixed length <code>String</code>.<br />
<code> </code></p>
<p><code></p>
<pre>public class IntegerUtil {
    public static String formatFixedWidth(int value, int width) {
        char[] chars;
        int i;
        int c;

        chars = new char[width];
        for (i = 0; i &lt; width; i++) {
            c = value % 10;
            chars[width-i-1] = (char)('0' + c);
            value = value / 10;
        }
        return new String(chars);
    }
}</pre>
<p></code></p>
<p>To format the document number like the one I said above, you simply modify the source code above to add one or two lines code to append a "-" to the String when the loop iterate to the place where you want to put the "-". Remember to increase the characters buffer as well.</p>
<p>The following function shows a sample implementation of my document number format.</p>
<p><code> </code></p>
<p><code></p>
<pre>public class IntegerUtil {
  public static String formatDocumentNumber(int value) {
    char[] chars;
    int i;
    int c;
    int size;

    size = 10+2;
    chars = new char[size];
    for (i = 0; i &lt; size; i++) {
      if (i == 4 || i == 9) {
        chars[width-i-1] = '-';
        continue;
      }
      c = value % 10;
      chars[width-i-1] = (char)('0' + c);
      value = value / 10;
    }
    return new String(chars);
  }
}</pre>
<p></code></p>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-enjoy">
<ul class="socials">
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=Java%3A+Format+Integer+Into+Fixed+Width+String+-+http://b2l.me/cxtz8&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="shr-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://www.snippetit.com/2010/01/java-format-integer-into-fixed-width-string/&amp;imageurl=" rel="nofollow" class="external" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="shr-yahoobuzz">
			<a href="http://buzz.yahoo.com/submit/?submitUrl=http://www.snippetit.com/2010/01/java-format-integer-into-fixed-width-string/&amp;submitHeadline=Java%3A+Format+Integer+Into+Fixed+Width+String&amp;submitSummary=Sometime%2C%20you%20may%20want%20to%20format%20an%20integer%20or%20a%20long%20value%20into%20a%20fixed%20width%C2%A0String.%20You%20need%20to%20display%20the%20value%20in%20fixed%20width%20especially%20in%20reports%20where%20you%20want%20to%20keep%20the%20numbers%20in%20aligned%20%28e.g.%203456%20as%C2%A00003456%20and%201234%20as%C2%A00001234%29.%0D%0A%0D%0AOther%20than%20that%2C%20you%20may%20also%20want%20to%20format%20the%20i&amp;submitCategory=science&amp;submitAssetType=text" rel="nofollow" class="external" title="Buzz up!">Buzz up!</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://www.snippetit.com/2010/01/java-format-integer-into-fixed-width-string/&amp;title=Java%3A+Format+Integer+Into+Fixed+Width+String" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://www.snippetit.com/2010/01/java-format-integer-into-fixed-width-string/&amp;title=Java%3A+Format+Integer+Into+Fixed+Width+String" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-blinklist">
			<a href="http://www.blinklist.com/index.php?Action=Blink/addblink.php&amp;Url=http://www.snippetit.com/2010/01/java-format-integer-into-fixed-width-string/&amp;Title=Java%3A+Format+Integer+Into+Fixed+Width+String" rel="nofollow" class="external" title="Share this on Blinklist">Share this on Blinklist</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://www.snippetit.com/2010/01/java-format-integer-into-fixed-width-string/&amp;title=Java%3A+Format+Integer+Into+Fixed+Width+String" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="shr-technorati">
			<a href="http://technorati.com/faves?add=http://www.snippetit.com/2010/01/java-format-integer-into-fixed-width-string/" rel="nofollow" class="external" title="Share this on Technorati">Share this on Technorati</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>

<h2  class="related_post_title">Related Articles</h2><ul class="related_post"><li><a href="http://www.snippetit.com/2009/08/java-format-long-integer-into-hexadecimal-string/" title="Java: Format Long Integer Into Hexadecimal String">Java: Format Long Integer Into Hexadecimal String</a></li><li><a href="http://www.snippetit.com/2009/03/java-format-integer-into-number-of-decimal-places-and-performance/" title="Java: Format integer into number of decimal places and performance">Java: Format integer into number of decimal places and performance</a></li><li><a href="http://www.snippetit.com/2009/11/java-loading-large-data-into-jtable-or-jlist/" title="Java: Loading Large Data into JTable or JList">Java: Loading Large Data into JTable or JList</a></li><li><a href="http://www.snippetit.com/2009/04/java-randomly-sort-values-in-a-array-the-generic-way-in-single-pasas/" title="Java: Randomly sort values in a array (the generic way) in single pass">Java: Randomly sort values in a array (the generic way) in single pass</a></li><li><a href="http://www.snippetit.com/2009/12/java-continuously-read-data-from-filechannel-without-mappedbytebuffer/" title="Java: Continuously Read Data From FileChannel Without MappedByteBuffer">Java: Continuously Read Data From FileChannel Without MappedByteBuffer</a></li><li><a href="http://www.snippetit.com/2009/06/java-stop-a-thread-correctly/" title="Java: Stop A Thread Correctly">Java: Stop A Thread Correctly</a></li><li><a href="http://www.snippetit.com/2009/05/java-format-bytes-array-into-hexadecimal-string/" title="Java: Format Bytes Array into Hexadecimal String">Java: Format Bytes Array into Hexadecimal String</a></li><li><a href="http://www.snippetit.com/2009/05/java-least-recently-used-lru-cache/" title="Java: Least Recently Used (LRU) Cache">Java: Least Recently Used (LRU) Cache</a></li><li><a href="http://www.snippetit.com/2009/05/jsp-how-to-declare-methods-and-inner-class-in-jsp/" title="JSP: How to Declare Methods and Inner Class in JSP">JSP: How to Declare Methods and Inner Class in JSP</a></li><li><a href="http://www.snippetit.com/2009/04/php-format-integer-into-number-of-decimal-places/" title="PHP: Format integer into number of decimal places">PHP: Format integer into number of decimal places</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.snippetit.com/2010/01/java-format-integer-into-fixed-width-string/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Google Wave Invitation Giveaway</title>
		<link>http://www.snippetit.com/2009/12/google-wave-invitation-giveaway/</link>
		<comments>http://www.snippetit.com/2009/12/google-wave-invitation-giveaway/#comments</comments>
		<pubDate>Sun, 20 Dec 2009 12:20:12 +0000</pubDate>
		<dc:creator>szehau</dc:creator>
				<category><![CDATA[New and Happening]]></category>
		<category><![CDATA[Programming and Scripting]]></category>
		<category><![CDATA[Software and Hardware]]></category>
		<category><![CDATA[Google Wave]]></category>

		<guid isPermaLink="false">http://www.snippetit.com/?p=365</guid>
		<description><![CDATA[I got my free Google Wave invitation from LiewCf, thanks for the invitation! Ok, now is my turn to give you guys, my blog readers, the free invitations. First impression to Google Wave To me, Google Wave is like a chatting program (e.g. MSN) where a few people can have collaboration in a channel (the Wave). Everything [...]]]></description>
			<content:encoded><![CDATA[<p>I got my free Google Wave invitation from <a href="http://www.liewcf.com/archives/2009/11/free-google-wave-invites-giveaway/" target="_blank">LiewCf</a>, thanks for the invitation! Ok, now is my turn to give you guys, my blog readers, the free invitations.</p>
<p style="text-align: center;"><img class="aligncenter" src="http://farm5.static.flickr.com/4042/4199247557_f5ddebe157.jpg" alt="Google Wave Invitation" width="500" height="394" /></p>
<p><span id="more-365"></span><strong>First impression to Google Wave</strong></p>
<p>To me, Google Wave is like a chatting program (e.g. MSN) where a few people can have collaboration in a channel (the Wave). Everything can be happened in real time (e.g. the message you type) and everyone in the Wave can see the chances in real time (almost). And it is also like a social website (e.g. Facebook) too where you can put in applications (Gadgets) and use it within a group of people.</p>
<p><strong>How to Get a Free Google Wave Invitation?</strong></p>
<p>It's very simple. All you need to do is to leave a comment in this post (with your email address) and state that you want to have a free Google Wave Invitation.</p>
<p>You will not need to do anything else in order to get the invitation but it would be appreciated, if you could subscribe to my blog feed. Thanks.</p>
<p>Be hurry, I only have 8 invitations in total. First come first served.</p>
<p><strong>Invitations left: 1</strong></p>
<p>Note: It may take some time to get the invitation arrive to you inbox (as according to Google Wave).</p>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-enjoy">
<ul class="socials">
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=Google+Wave+Invitation+Giveaway+-+http://b2l.me/bvy3r&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="shr-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://www.snippetit.com/2009/12/google-wave-invitation-giveaway/&amp;imageurl=" rel="nofollow" class="external" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="shr-yahoobuzz">
			<a href="http://buzz.yahoo.com/submit/?submitUrl=http://www.snippetit.com/2009/12/google-wave-invitation-giveaway/&amp;submitHeadline=Google+Wave+Invitation+Giveaway&amp;submitSummary=I%20got%20my%20free%20Google%20Wave%20invitation%20from%20LiewCf%2C%20thanks%20for%20the%20invitation%21%20Ok%2C%20now%20is%20my%20turn%20to%20give%20you%20guys%2C%20my%20blog%20readers%2C%20the%20free%20invitations.%0D%0A%0D%0AFirst%20impression%20to%20Google%20Wave%0D%0A%0D%0ATo%20me%2C%20Google%20Wave%20is%20like%20a%20chatting%20program%20%28e.g.%20MSN%29%20where%20a%20few%20people%20can%20have%C2%A0collaboration%C2%A0in%20a%20cha&amp;submitCategory=science&amp;submitAssetType=text" rel="nofollow" class="external" title="Buzz up!">Buzz up!</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://www.snippetit.com/2009/12/google-wave-invitation-giveaway/&amp;title=Google+Wave+Invitation+Giveaway" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://www.snippetit.com/2009/12/google-wave-invitation-giveaway/&amp;title=Google+Wave+Invitation+Giveaway" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-blinklist">
			<a href="http://www.blinklist.com/index.php?Action=Blink/addblink.php&amp;Url=http://www.snippetit.com/2009/12/google-wave-invitation-giveaway/&amp;Title=Google+Wave+Invitation+Giveaway" rel="nofollow" class="external" title="Share this on Blinklist">Share this on Blinklist</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://www.snippetit.com/2009/12/google-wave-invitation-giveaway/&amp;title=Google+Wave+Invitation+Giveaway" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="shr-technorati">
			<a href="http://technorati.com/faves?add=http://www.snippetit.com/2009/12/google-wave-invitation-giveaway/" rel="nofollow" class="external" title="Share this on Technorati">Share this on Technorati</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>

<h2  class="related_post_title">Most Commented Posts</h2><ul class="related_post"><li><a href="http://www.snippetit.com/2009/12/google-wave-invitation-giveaway/" title="Google Wave Invitation Giveaway">Google Wave Invitation Giveaway</a></li><li><a href="http://www.snippetit.com/2009/01/website-value-evaluation-tool/" title="Website value evaluation tool">Website value evaluation tool</a></li><li><a href="http://www.snippetit.com/2009/04/wordpress-plugin-blogtal-trackback/" title="Wordpress Plugin &#8211; Blogtal Trackback">Wordpress Plugin &#8211; Blogtal Trackback</a></li><li><a href="http://www.snippetit.com/2009/04/wordpress-plugin-default-trackbacks/" title="Wordpress Plugin &#8211; Default Trackbacks">Wordpress Plugin &#8211; Default Trackbacks</a></li><li><a href="http://www.snippetit.com/2009/02/c-loop-all-files-in-directory-and-its-sub-directories/" title="C# &#8211; Loop all files in directory and it&#8217;s sub-directories">C# &#8211; Loop all files in directory and it&#8217;s sub-directories</a></li><li><a href="http://www.snippetit.com/2009/05/wordpress-make-your-wordpress-a-little-bit-more-secure/" title="Wordpress: Make Your Wordpress A Little Bit More Secure">Wordpress: Make Your Wordpress A Little Bit More Secure</a></li><li><a href="http://www.snippetit.com/2008/10/implement-your-own-short-url/" title="Implement your own short URL">Implement your own short URL</a></li><li><a href="http://www.snippetit.com/2009/05/windows-live-messenger-beware-of-unsolicited-messages-sent-from-your-friends-live-account/" title="Windows Live Messenger: Beware of Unsolicited Messages Sent From Your Friends&#8217; Live Account">Windows Live Messenger: Beware of Unsolicited Messages Sent From Your Friends&#8217; Live Account</a></li><li><a href="http://www.snippetit.com/2009/07/java-mortgage-payment-calculator/" title="Java: Mortgage Payment Calculator">Java: Mortgage Payment Calculator</a></li><li><a href="http://www.snippetit.com/2009/02/gmails-labels-menu/" title="Gmail&#8217;s Labels menu">Gmail&#8217;s Labels menu</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.snippetit.com/2009/12/google-wave-invitation-giveaway/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>Adobe Acrobat Reader: Possible Security Vulnerability When Acrobat JavaScript Is Enabled</title>
		<link>http://www.snippetit.com/2009/12/adobe-acrobat-reader-possible-security-vulnerability-when-acrobat-javascript-is-enabled/</link>
		<comments>http://www.snippetit.com/2009/12/adobe-acrobat-reader-possible-security-vulnerability-when-acrobat-javascript-is-enabled/#comments</comments>
		<pubDate>Thu, 17 Dec 2009 16:16:43 +0000</pubDate>
		<dc:creator>szehau</dc:creator>
				<category><![CDATA[Programming and Scripting]]></category>
		<category><![CDATA[Software and Hardware]]></category>
		<category><![CDATA[Acrobat Reader]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[security vulnerability]]></category>

		<guid isPermaLink="false">http://www.snippetit.com/?p=361</guid>
		<description><![CDATA[It is possible to have security vulnerability in Adobe's Acrobat Reader if the Acrobat Javascript option is enable. When the option is enabled and you open a crafted PDF file with Adobe Reader that allows JavaScript execution, your computer will be exposed to security risk - hacker may able to access your valuable data from your hard [...]]]></description>
			<content:encoded><![CDATA[<p>It is possible to have security vulnerability in Adobe's Acrobat Reader if the Acrobat Javascript option is enable.</p>
<p>When the option is enabled and you open a crafted PDF file with Adobe Reader that allows JavaScript execution, your computer will be exposed to security risk - hacker may able to access your valuable data from your hard disk.</p>
<p><span id="more-361"></span></p>
<p>JavaScript is a scripting language that is tend to be safe to be used in web browsers due to its limitation to access to client computer. Since it is safe, your antivirus software may not able to detect a pdf file with Javascript is actually contain an virus.</p>
<p>To prevent the security vulnerability, you should now check whether your Adobe Acrobat's Javascript option is enabled. If it is enabled, disable it as soon as possible. The default setting for Acrobat Javascript is set to enabled for most of the Acrobat Reader version.</p>
<p>To disable the option, open your Acrobat Reader application, click on Edit -&gt; Preferences and a window will pop up. Select the "JavaScript" option from your left and make sure the "Enable Acrobat JavaScript" option is un-ticked.</p>
<p style="text-align: center;"><img class="aligncenter" src="http://farm3.static.flickr.com/2504/4193101414_cdaf1df3e7.jpg" alt="Possible Security Vulnerability  in Adobe Acrobat Reader" width="500" height="413" /></p>
<p>Thanks for Walker for heading up the <a href="http://www.walkernews.net/2009/12/16/disable-adobe-reader-javascript-function-or-take-the-risk/" target="_blank">Acrobat JavaScript</a> issue.</p>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-enjoy">
<ul class="socials">
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=Adobe+Acrobat+Reader%3A+Possible+Security+Vulnerability+When+Acrobat+JavaScript+Is%5B..%5D+-+http://b2l.me/bqshw&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="shr-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://www.snippetit.com/2009/12/adobe-acrobat-reader-possible-security-vulnerability-when-acrobat-javascript-is-enabled/&amp;imageurl=" rel="nofollow" class="external" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="shr-yahoobuzz">
			<a href="http://buzz.yahoo.com/submit/?submitUrl=http://www.snippetit.com/2009/12/adobe-acrobat-reader-possible-security-vulnerability-when-acrobat-javascript-is-enabled/&amp;submitHeadline=Adobe+Acrobat+Reader%3A+Possible+Security+Vulnerability+When+Acrobat+JavaScript+Is+Enabled&amp;submitSummary=It%20is%20possible%20to%20have%20security%C2%A0vulnerability%C2%A0in%20Adobe%27s%20Acrobat%20Reader%20if%20the%20Acrobat%20Javascript%20option%20is%20enable.%0D%0A%0D%0AWhen%20the%20option%20is%20enabled%20and%20you%20open%20a%20crafted%20PDF%20file%20with%20Adobe%20Reader%20that%20allows%20JavaScript%20execution%2C%20your%20computer%20will%20be%20exposed%20to%20security%20risk%20-%20hacker%20may%20able%20to%20&amp;submitCategory=science&amp;submitAssetType=text" rel="nofollow" class="external" title="Buzz up!">Buzz up!</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://www.snippetit.com/2009/12/adobe-acrobat-reader-possible-security-vulnerability-when-acrobat-javascript-is-enabled/&amp;title=Adobe+Acrobat+Reader%3A+Possible+Security+Vulnerability+When+Acrobat+JavaScript+Is+Enabled" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://www.snippetit.com/2009/12/adobe-acrobat-reader-possible-security-vulnerability-when-acrobat-javascript-is-enabled/&amp;title=Adobe+Acrobat+Reader%3A+Possible+Security+Vulnerability+When+Acrobat+JavaScript+Is+Enabled" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-blinklist">
			<a href="http://www.blinklist.com/index.php?Action=Blink/addblink.php&amp;Url=http://www.snippetit.com/2009/12/adobe-acrobat-reader-possible-security-vulnerability-when-acrobat-javascript-is-enabled/&amp;Title=Adobe+Acrobat+Reader%3A+Possible+Security+Vulnerability+When+Acrobat+JavaScript+Is+Enabled" rel="nofollow" class="external" title="Share this on Blinklist">Share this on Blinklist</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://www.snippetit.com/2009/12/adobe-acrobat-reader-possible-security-vulnerability-when-acrobat-javascript-is-enabled/&amp;title=Adobe+Acrobat+Reader%3A+Possible+Security+Vulnerability+When+Acrobat+JavaScript+Is+Enabled" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="shr-technorati">
			<a href="http://technorati.com/faves?add=http://www.snippetit.com/2009/12/adobe-acrobat-reader-possible-security-vulnerability-when-acrobat-javascript-is-enabled/" rel="nofollow" class="external" title="Share this on Technorati">Share this on Technorati</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>

<h2  class="related_post_title">Related Articles</h2><ul class="related_post"><li><a href="http://www.snippetit.com/2009/11/javascript-overcome-slow-loading-javascript-on-a-web-page/" title="JavaScript: Overcome Slow Loading JavaScript On A Web Page">JavaScript: Overcome Slow Loading JavaScript On A Web Page</a></li><li><a href="http://www.snippetit.com/2009/11/wordpress-version-2-8-6-security-release/" title="Wordpress: Version 2.8.6 Security Release">Wordpress: Version 2.8.6 Security Release</a></li><li><a href="http://www.snippetit.com/2009/05/windows-live-messenger-beware-of-unsolicited-messages-sent-from-your-friends-live-account/" title="Windows Live Messenger: Beware of Unsolicited Messages Sent From Your Friends&#8217; Live Account">Windows Live Messenger: Beware of Unsolicited Messages Sent From Your Friends&#8217; Live Account</a></li><li><a href="http://www.snippetit.com/2009/05/get-paid-to-be-a-hacker/" title="Get Paid to Be a Hacker!">Get Paid to Be a Hacker!</a></li><li><a href="http://www.snippetit.com/2009/05/wordpress-make-your-wordpress-a-little-bit-more-secure/" title="Wordpress: Make Your Wordpress A Little Bit More Secure">Wordpress: Make Your Wordpress A Little Bit More Secure</a></li><li><a href="http://www.snippetit.com/2009/05/gmail-how-to-monitor-your-mail-account-activities/" title="Gmail: How to Monitor Your Mail Account Activities">Gmail: How to Monitor Your Mail Account Activities</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.snippetit.com/2009/12/adobe-acrobat-reader-possible-security-vulnerability-when-acrobat-javascript-is-enabled/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Java: Continuously Read Data From FileChannel Without MappedByteBuffer</title>
		<link>http://www.snippetit.com/2009/12/java-continuously-read-data-from-filechannel-without-mappedbytebuffer/</link>
		<comments>http://www.snippetit.com/2009/12/java-continuously-read-data-from-filechannel-without-mappedbytebuffer/#comments</comments>
		<pubDate>Thu, 17 Dec 2009 11:46:01 +0000</pubDate>
		<dc:creator>szehau</dc:creator>
				<category><![CDATA[Programming and Scripting]]></category>
		<category><![CDATA[Tips and Tricks]]></category>
		<category><![CDATA[FileChannel]]></category>
		<category><![CDATA[how to]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[MappedByteBuffer]]></category>

		<guid isPermaLink="false">http://www.snippetit.com/?p=359</guid>
		<description><![CDATA[When programmer writes a program to read data from a file continuously and sequentially with a fixed data type reading sequence (e.g. to read three integers then 2 doubles repeatedly), he or she may find the MappedByteBuffer from Java library is useful. MappedByteBuffer is pretty useful because its content is a memory-mapped region of a file. Program [...]]]></description>
			<content:encoded><![CDATA[<p>When programmer writes a program to read data from a file continuously and sequentially with a fixed data type reading sequence (e.g. to read three <code>integer</code>s then 2 <code>double</code>s repeatedly), he or she may find the <code>MappedByteBuffer</code> from Java library is useful.</p>
<p><span id="more-359"></span><code>MappedByteBuffer</code> is pretty useful because its content is a memory-mapped region of a file. Program can access to the position of the file it wants directly. It also does some optimization on loading data from file, where part of the content are loaded into memory before the <em>read</em> action is actually performed. But when the data will be load? It remains unknown and it is operating system dependent. This is the first problem when using <code>MappedByteBuffer</code> - are the data buffered?</p>
<p>The second problem arises when programmer uses <code>MappedByteBuffer</code> to read a big file. <code>MappedByteBuffer</code> only allows data reading up to the maximum value of an integer (2,147,483,648 bytes). If the program needs to read further from that, it will need to re-map the file by calling the <code>FileChannle.map</code> function by parsing in the correct file position. The programmer will need to be very careful in passing the correct file position because some time it can be very confusing.</p>
<p>To overcome these two problems, we can introduce, design and write a new class that ensures the data reading action is buffered for the best performance and also allows continuous of reading without the need of re-mapping the <code>FileChannle</code>. First, let's write out the pseudo code for the <em>read</em> file action:</p>
<p><code></p>
<pre>get data (e.g. get integer)
  ensure the memory buffer has enough data for the requested data type
    if not enough, read data from file
read the data from buffer and return them in the requested data type</pre>
<p></code></p>
<p>Below is the example of implementation:</p>
<p><code></p>
<pre>public class FileChannelReader {

  private final static int BUFFER_SIZE = 64 * 1024; // 64k

  private ByteBuffer readerBuffer;
  private FileChannel readerFileChannel;

  public FileChannelReader(FileChannel fileChannel) {
    readerBuffer = ByteBuffer.allocate(PAGE_SIZE);
    readerFileChannel = fileChannel;
    readerBuffer.clear();
    readerBuffer.flip();
  }

  // Ensure the buffer has enough data
  private void ensureData(int size) throws IOException  {
    if (readerBuffer.remaining() &lt; size) {
      readerBuffer.compact();
      if (readerFileChannel.read(readerBuffer) &lt;= 0)
        throw new IOException("Unexpected end-of-stream");
      readerBuffer.flip();
    }
  }

  // Get current position
  public long position() throws IOException {
    return readerFileChannel.position() - readerBuffer.remaining();
  }

  // Set current position
  public void position(long position) throws IOException {
    readerFileChannel.position(position);
    readerBuffer.clear();
    readerBuffer.flip();
  }

  // Get integer
  public int getInt() throws IOException {
    ensureData(Integer.SIZE/8);
    return readerBuffer.getInt();
  }

  // Get long
  public long getLong() throws IOException {
    ensureData(Long.SIZE/8);
    return readerBuffer.getLong();
  }

  // And so on ...
}</pre>
<p></code><br />
I'm using this technique in my programming projects and it performs pretty well. The data to be read is always ensured to be buffered and it also reduces complexity in writing a program to read data sequentially.</p>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-enjoy">
<ul class="socials">
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=Java%3A+Continuously+Read+Data+From+FileChannel+Without+MappedByteBuffer+-+http://b2l.me/bqdbj&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="shr-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://www.snippetit.com/2009/12/java-continuously-read-data-from-filechannel-without-mappedbytebuffer/&amp;imageurl=" rel="nofollow" class="external" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="shr-yahoobuzz">
			<a href="http://buzz.yahoo.com/submit/?submitUrl=http://www.snippetit.com/2009/12/java-continuously-read-data-from-filechannel-without-mappedbytebuffer/&amp;submitHeadline=Java%3A+Continuously+Read+Data+From+FileChannel+Without+MappedByteBuffer&amp;submitSummary=When%20programmer%20writes%20a%20program%20to%20read%20data%20from%20a%20file%20continuously%20and%C2%A0sequentially%C2%A0with%20a%20fixed%20data%20type%20reading%20sequence%20%28e.g.%20to%20read%20three%20integers%20then%202%20doubles%20repeatedly%29%2C%20he%20or%20she%20may%20find%20the%20MappedByteBuffer%20from%20Java%20library%20is%20useful.%0D%0A%0D%0AMappedByteBuffer%20is%20pretty%20useful%20because&amp;submitCategory=science&amp;submitAssetType=text" rel="nofollow" class="external" title="Buzz up!">Buzz up!</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://www.snippetit.com/2009/12/java-continuously-read-data-from-filechannel-without-mappedbytebuffer/&amp;title=Java%3A+Continuously+Read+Data+From+FileChannel+Without+MappedByteBuffer" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://www.snippetit.com/2009/12/java-continuously-read-data-from-filechannel-without-mappedbytebuffer/&amp;title=Java%3A+Continuously+Read+Data+From+FileChannel+Without+MappedByteBuffer" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-blinklist">
			<a href="http://www.blinklist.com/index.php?Action=Blink/addblink.php&amp;Url=http://www.snippetit.com/2009/12/java-continuously-read-data-from-filechannel-without-mappedbytebuffer/&amp;Title=Java%3A+Continuously+Read+Data+From+FileChannel+Without+MappedByteBuffer" rel="nofollow" class="external" title="Share this on Blinklist">Share this on Blinklist</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://www.snippetit.com/2009/12/java-continuously-read-data-from-filechannel-without-mappedbytebuffer/&amp;title=Java%3A+Continuously+Read+Data+From+FileChannel+Without+MappedByteBuffer" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="shr-technorati">
			<a href="http://technorati.com/faves?add=http://www.snippetit.com/2009/12/java-continuously-read-data-from-filechannel-without-mappedbytebuffer/" rel="nofollow" class="external" title="Share this on Technorati">Share this on Technorati</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>

<h2  class="related_post_title">Related Articles</h2><ul class="related_post"><li><a href="http://www.snippetit.com/2010/01/java-format-integer-into-fixed-width-string/" title="Java: Format Integer Into Fixed Width String">Java: Format Integer Into Fixed Width String</a></li><li><a href="http://www.snippetit.com/2009/11/java-loading-large-data-into-jtable-or-jlist/" title="Java: Loading Large Data into JTable or JList">Java: Loading Large Data into JTable or JList</a></li><li><a href="http://www.snippetit.com/2009/08/java-format-long-integer-into-hexadecimal-string/" title="Java: Format Long Integer Into Hexadecimal String">Java: Format Long Integer Into Hexadecimal String</a></li><li><a href="http://www.snippetit.com/2009/06/java-stop-a-thread-correctly/" title="Java: Stop A Thread Correctly">Java: Stop A Thread Correctly</a></li><li><a href="http://www.snippetit.com/2009/05/jsp-how-to-declare-methods-and-inner-class-in-jsp/" title="JSP: How to Declare Methods and Inner Class in JSP">JSP: How to Declare Methods and Inner Class in JSP</a></li><li><a href="http://www.snippetit.com/2009/04/java-randomly-sort-values-in-a-array-the-generic-way-in-single-pasas/" title="Java: Randomly sort values in a array (the generic way) in single pass">Java: Randomly sort values in a array (the generic way) in single pass</a></li><li><a href="http://www.snippetit.com/2009/03/java-format-integer-into-number-of-decimal-places-and-performance/" title="Java: Format integer into number of decimal places and performance">Java: Format integer into number of decimal places and performance</a></li><li><a href="http://www.snippetit.com/2009/03/java-static-constructor/" title="Java Static Constructor">Java Static Constructor</a></li><li><a href="http://www.snippetit.com/2010/01/java-use-bytebuffer-as-inputstream/" title="Java: Use ByteBuffer As InputStream">Java: Use ByteBuffer As InputStream</a></li><li><a href="http://www.snippetit.com/2009/11/wordpress-how-to-add-table-into-a-post/" title="Wordpress: How To Add Table Into A Post">Wordpress: How To Add Table Into A Post</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.snippetit.com/2009/12/java-continuously-read-data-from-filechannel-without-mappedbytebuffer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Short URL: Top 5 Websites That Provide Free Short URL Service</title>
		<link>http://www.snippetit.com/2009/12/short-url-top-5-websites-that-provide-free-short-url-service/</link>
		<comments>http://www.snippetit.com/2009/12/short-url-top-5-websites-that-provide-free-short-url-service/#comments</comments>
		<pubDate>Wed, 09 Dec 2009 17:56:55 +0000</pubDate>
		<dc:creator>szehau</dc:creator>
				<category><![CDATA[Earning with Website and Blogging]]></category>
		<category><![CDATA[Programming and Scripting]]></category>
		<category><![CDATA[Search Engine Optimization and Internet Marketing]]></category>
		<category><![CDATA[short URL]]></category>
		<category><![CDATA[tiny URL]]></category>

		<guid isPermaLink="false">http://www.snippetit.com/?p=347</guid>
		<description><![CDATA[What is a "short URL"? Short URL or tiny URL is an URL used to represent a long URL For example, http://tinyurl.com/45lk7x can be used to represent and will be used to redirect to http://www.snippetit.com/2008/10/implement-your-own-short-url. Why people use short URL? First, because it is easy to remember. Imagine when you read an article on a [...]]]></description>
			<content:encoded><![CDATA[<p>What is a "short URL"? Short URL or tiny URL is an URL used to represent a long URL For example, http://tinyurl.com/45lk7x can be used to represent and will be used to redirect to <a href="http://www.snippetit.com/2008/10/implement-your-own-short-url/">http://www.snippetit.com/2008/10/implement-your-own-short-url</a>.</p>
<p>Why people use short URL? First, because it is easy to remember. Imagine when you read an article on a magazine or newspaper that shows you a site with 100 characters and complicated URL. How can you remember the long URL, put down the magazine or newspaper, sit in front of your computer and type out the URL at web browser correctly? When the URL is short, for example <em>tinyurl.com/45lk7x</em>, you can do it easily.</p>
<p>Second, short URL is more portable. For instance, when you want to send your friend a SMS that contains some message and an URL, with short URL you can save a lot of space and give you more space to type your message.</p>
<p><span id="more-347"></span></p>
<p>Most short URL services are free and easy to use. You just need to provide the long URL and it will generate a new short URL for you. Here are the list of most popular short URL websites sorted by its traffic rank (by Alexa):</p>
<ol>
<li>bit.ly (Alexa traffic rank: 220)</li>
<li>tinyurl.com (Alexa traffic rank: 660)</li>
<li>is.gd (Alexa traffic rank: 10,833)</li>
<li>ff.im (Alexa traffic rank: 45,395)</li>
<li>twurl.nl (Alexa traffic rank: 120,846)</li>
</ol>
<p>If you are good in computer programming language, you interested in <a title="short URL" href="http://www.snippetit.com/2008/10/implement-your-own-short-url/">implementing your own short URL</a>.</p>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-enjoy">
<ul class="socials">
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=Short+URL%3A+Top+5+Websites+That+Provide+Free+Short+URL+Service+-+http://b2l.me/bbu7t&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="shr-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://www.snippetit.com/2009/12/short-url-top-5-websites-that-provide-free-short-url-service/&amp;imageurl=" rel="nofollow" class="external" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="shr-yahoobuzz">
			<a href="http://buzz.yahoo.com/submit/?submitUrl=http://www.snippetit.com/2009/12/short-url-top-5-websites-that-provide-free-short-url-service/&amp;submitHeadline=Short+URL%3A+Top+5+Websites+That+Provide+Free+Short+URL+Service&amp;submitSummary=What%20is%20a%20%22short%20URL%22%3F%20Short%20URL%20or%20tiny%20URL%20is%20an%20URL%20used%20to%20represent%20a%20long%20URL%20For%20example%2C%20http%3A%2F%2Ftinyurl.com%2F45lk7x%20can%20be%20used%20to%20represent%20and%20will%20be%20used%20to%20redirect%20to%20http%3A%2F%2Fwww.snippetit.com%2F2008%2F10%2Fimplement-your-own-short-url.%0D%0A%0D%0AWhy%20people%20use%20short%20URL%3F%20First%2C%20because%20it%20is%20easy%20to&amp;submitCategory=science&amp;submitAssetType=text" rel="nofollow" class="external" title="Buzz up!">Buzz up!</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://www.snippetit.com/2009/12/short-url-top-5-websites-that-provide-free-short-url-service/&amp;title=Short+URL%3A+Top+5+Websites+That+Provide+Free+Short+URL+Service" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://www.snippetit.com/2009/12/short-url-top-5-websites-that-provide-free-short-url-service/&amp;title=Short+URL%3A+Top+5+Websites+That+Provide+Free+Short+URL+Service" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-blinklist">
			<a href="http://www.blinklist.com/index.php?Action=Blink/addblink.php&amp;Url=http://www.snippetit.com/2009/12/short-url-top-5-websites-that-provide-free-short-url-service/&amp;Title=Short+URL%3A+Top+5+Websites+That+Provide+Free+Short+URL+Service" rel="nofollow" class="external" title="Share this on Blinklist">Share this on Blinklist</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://www.snippetit.com/2009/12/short-url-top-5-websites-that-provide-free-short-url-service/&amp;title=Short+URL%3A+Top+5+Websites+That+Provide+Free+Short+URL+Service" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="shr-technorati">
			<a href="http://technorati.com/faves?add=http://www.snippetit.com/2009/12/short-url-top-5-websites-that-provide-free-short-url-service/" rel="nofollow" class="external" title="Share this on Technorati">Share this on Technorati</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>

<h2  class="related_post_title">Related Articles</h2><ul class="related_post"><li><a href="http://www.snippetit.com/2009/04/php-short-url-algorithm-implementation/" title="PHP: Short URL Algorithm Implementation">PHP: Short URL Algorithm Implementation</a></li><li><a href="http://www.snippetit.com/2008/10/implement-your-own-short-url/" title="Implement your own short URL">Implement your own short URL</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.snippetit.com/2009/12/short-url-top-5-websites-that-provide-free-short-url-service/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WordPress: How To Add Table Into A Post</title>
		<link>http://www.snippetit.com/2009/11/wordpress-how-to-add-table-into-a-post/</link>
		<comments>http://www.snippetit.com/2009/11/wordpress-how-to-add-table-into-a-post/#comments</comments>
		<pubDate>Wed, 25 Nov 2009 16:23:41 +0000</pubDate>
		<dc:creator>szehau</dc:creator>
				<category><![CDATA[Programming and Scripting]]></category>
		<category><![CDATA[Tips and Tricks]]></category>
		<category><![CDATA[how to]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://www.snippetit.com/?p=337</guid>
		<description><![CDATA[WordPress' WYSIWYG post editor does not come with the functionality that allows user to create table when editing a post (like what you can do in Microsoft word). However, putting a table into a post in WordPress editor is not as hard as writing a software codes. What you need to know is to familiar [...]]]></description>
			<content:encoded><![CDATA[<p>WordPress' WYSIWYG post editor does not come with the functionality that allows user to create table when editing a post (like what you can do in Microsoft word).</p>
<p><span id="more-337"></span>However, putting a table into a post in WordPress editor is not as hard as writing a software codes. What you need to know is to familiar yourself with some HTML tags.</p>
<p>To create a table in post, you will need to switch your editor to HTML mode. Simply click on the <em>HTML</em> tab on the top-right of your WordPress editor and then insert the table codes into the position where you want the table appear.</p>
<p>Here is a simple table:<br />
<code></p>
<pre>&lt;table border="1" cellspacing="1" cellpadding="1" width="100"&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Column 1&lt;/td&gt;
&lt;td&gt;Column 2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Data 1&lt;/td&gt;
&lt;td&gt;Data 2&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;</pre>
<p></code></p>
<p>And it looks like this:</p>
<table border="1" cellspacing="1" cellpadding="1" width="100">
<tbody>
<tr>
<td>Column 1</td>
<td>Column 2</td>
</tr>
<tr>
<td>Data 1</td>
<td>Data 2</td>
</tr>
</tbody>
</table>
<p>You can change the table width by changing the <em>width</em> parameter to a certain value, either in pixels (without unit) or percentage (with %). You can also change the border size (<em>border</em>), cell's padding (<em>cellpadding</em>) and cell's spacing (<em>cellspacing</em>). Border size, cell's padding and cell's spacing are in unit pixels.</p>
<p>After you have put the code, change back to visual mode to preview your table. At that time, you can apply format (e.g. color, bold, link and etc) to your text in the table.</p>
<p>Another table with 2 columns in a row are merged:<br />
<code></p>
<pre>&lt;table border="1" cellspacing="1" cellpadding="1" width="100"&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td colspan="2"&gt;2 Columns merged&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Data 1&lt;/td&gt;
&lt;td&gt;Data 2&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;</pre>
<p></code></p>
<p>And it looks like this:</p>
<table border="1" cellspacing="1" cellpadding="1" width="100">
<tbody>
<tr>
<td colspan="2">2 Columns merged</td>
</tr>
<tr>
<td>Data 1</td>
<td>Data 2</td>
</tr>
</tbody>
</table>
<p>Another table with 2 rows in a column are merged:<br />
<code></p>
<pre>&lt;table border="1" cellspacing="1" cellpadding="1" width="100"&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td rowspan="2"&gt;Column 1&lt;/td&gt;
&lt;td&gt;Column 2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Data 2&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;</pre>
<p></code></p>
<p>And it looks like this:</p>
<table border="1" cellspacing="1" cellpadding="1" width="100">
<tbody>
<tr>
<td rowspan="2">Column 1</td>
<td>Column 2</td>
</tr>
<tr>
<td>Data 2</td>
</tr>
</tbody>
</table>
<p>It is easy and fun, right? You always have to trial and error to create the table you want. Once you have understood the basic, you can easily create tables with the design you want.</p>
<p>Have fun!;</p>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-enjoy">
<ul class="socials">
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=Wordpress%3A+How+To+Add+Table+Into+A+Post+-+http://b2l.me/atfk4&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="shr-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://www.snippetit.com/2009/11/wordpress-how-to-add-table-into-a-post/&amp;imageurl=" rel="nofollow" class="external" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="shr-yahoobuzz">
			<a href="http://buzz.yahoo.com/submit/?submitUrl=http://www.snippetit.com/2009/11/wordpress-how-to-add-table-into-a-post/&amp;submitHeadline=Wordpress%3A+How+To+Add+Table+Into+A+Post&amp;submitSummary=Wordpress%27%20WYSIWYG%20post%20editor%20does%20not%20come%20with%20the%20functionality%20that%20allows%20user%20to%20create%20table%20when%20editing%20a%20post%20%28like%20what%20you%20can%20do%20in%20Microsoft%20word%29.%0D%0A%0D%0AHowever%2C%20putting%20a%20table%20into%20a%20post%20in%20Wordpress%20editor%20is%20not%20as%20hard%20as%20writing%20a%20software%20codes.%20What%20you%20need%20to%20know%20is%20to%20famil&amp;submitCategory=science&amp;submitAssetType=text" rel="nofollow" class="external" title="Buzz up!">Buzz up!</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://www.snippetit.com/2009/11/wordpress-how-to-add-table-into-a-post/&amp;title=Wordpress%3A+How+To+Add+Table+Into+A+Post" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://www.snippetit.com/2009/11/wordpress-how-to-add-table-into-a-post/&amp;title=Wordpress%3A+How+To+Add+Table+Into+A+Post" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-blinklist">
			<a href="http://www.blinklist.com/index.php?Action=Blink/addblink.php&amp;Url=http://www.snippetit.com/2009/11/wordpress-how-to-add-table-into-a-post/&amp;Title=Wordpress%3A+How+To+Add+Table+Into+A+Post" rel="nofollow" class="external" title="Share this on Blinklist">Share this on Blinklist</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://www.snippetit.com/2009/11/wordpress-how-to-add-table-into-a-post/&amp;title=Wordpress%3A+How+To+Add+Table+Into+A+Post" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="shr-technorati">
			<a href="http://technorati.com/faves?add=http://www.snippetit.com/2009/11/wordpress-how-to-add-table-into-a-post/" rel="nofollow" class="external" title="Share this on Technorati">Share this on Technorati</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>

<h2  class="related_post_title">Related Articles</h2><ul class="related_post"><li><a href="http://www.snippetit.com/2009/04/how-to-add-advertisement-code-to-wordpress-themes-sidebar/" title="How to Add Advertisement Code to Wordpress Theme&#8217;s Sidebar">How to Add Advertisement Code to Wordpress Theme&#8217;s Sidebar</a></li><li><a href="http://www.snippetit.com/2010/01/java-format-integer-into-fixed-width-string/" title="Java: Format Integer Into Fixed Width String">Java: Format Integer Into Fixed Width String</a></li><li><a href="http://www.snippetit.com/2009/12/wordpress-version-2-9/" title="Wordpress: Version 2.9">Wordpress: Version 2.9</a></li><li><a href="http://www.snippetit.com/2009/12/java-continuously-read-data-from-filechannel-without-mappedbytebuffer/" title="Java: Continuously Read Data From FileChannel Without MappedByteBuffer">Java: Continuously Read Data From FileChannel Without MappedByteBuffer</a></li><li><a href="http://www.snippetit.com/2009/12/wordpress-catch-a-spamm-comment-with-statcounter/" title="Wordpress: Catch A Spam Comment With Statcounter">Wordpress: Catch A Spam Comment With Statcounter</a></li><li><a href="http://www.snippetit.com/2009/11/wordpress-rename-permalink-url-with-ease-in-administrator-page/" title="Wordpress: Rename Permalink URL with Ease in Administrator Page">Wordpress: Rename Permalink URL with Ease in Administrator Page</a></li><li><a href="http://www.snippetit.com/2009/11/wordpress-schedule-to-publish-a-post/" title="Wordpress: Schedule to Publish a Post">Wordpress: Schedule to Publish a Post</a></li><li><a href="http://www.snippetit.com/2009/11/wordpress-version-2-8-6-security-release/" title="Wordpress: Version 2.8.6 Security Release">Wordpress: Version 2.8.6 Security Release</a></li><li><a href="http://www.snippetit.com/2009/11/java-loading-large-data-into-jtable-or-jlist/" title="Java: Loading Large Data into JTable or JList">Java: Loading Large Data into JTable or JList</a></li><li><a href="http://www.snippetit.com/2009/08/java-format-long-integer-into-hexadecimal-string/" title="Java: Format Long Integer Into Hexadecimal String">Java: Format Long Integer Into Hexadecimal String</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.snippetit.com/2009/11/wordpress-how-to-add-table-into-a-post/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Google Chromium OS</title>
		<link>http://www.snippetit.com/2009/11/google-chromium-os/</link>
		<comments>http://www.snippetit.com/2009/11/google-chromium-os/#comments</comments>
		<pubDate>Mon, 23 Nov 2009 13:29:16 +0000</pubDate>
		<dc:creator>szehau</dc:creator>
				<category><![CDATA[New and Happening]]></category>
		<category><![CDATA[Programming and Scripting]]></category>
		<category><![CDATA[Search Engine Optimization and Internet Marketing]]></category>
		<category><![CDATA[Software and Hardware]]></category>
		<category><![CDATA[Chome OS]]></category>
		<category><![CDATA[Chrome]]></category>
		<category><![CDATA[Chromium]]></category>
		<category><![CDATA[Chromium OS]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[Google Chrome]]></category>

		<guid isPermaLink="false">http://www.snippetit.com/?p=332</guid>
		<description><![CDATA[Google Chromium OS or Chrome OS is an open source project created by Google that aims to build an operating system that provide fast, simple and more secure computing experience. The new OS is target for people who spend most of their time on the web. The following videos explain in detailed what Chrome OS [...]]]></description>
			<content:encoded><![CDATA[<p>Google <strong>Chromium OS</strong> or <strong>Chrome OS</strong> is an open source project created by Google that aims to build an operating system that provide fast, simple and more secure computing experience. The new OS is target for people who spend most of their time on the web.</p>
<p>The following videos explain in detailed what Chrome OS is:</p>
<p><strong>What is Google Chrome OS?</strong><br />
<object width="480" height="295"><param name="movie" value="http://www.youtube.com/v/0QRO3gKj3qw&#038;hl=en_US&#038;fs=1&#038;"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/0QRO3gKj3qw&#038;hl=en_US&#038;fs=1&#038;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="295"></embed></object><span id="more-332"></span></p>
<p><strong>Chrome OS Security</strong><br />
<object width="480" height="295"><param name="movie" value="http://www.youtube.com/v/A9WVmNfgjtQ&#038;hl=en_US&#038;fs=1&#038;"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/A9WVmNfgjtQ&#038;hl=en_US&#038;fs=1&#038;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="295"></embed></object></p>
<p><strong>Chromium OS &amp; Open Source</strong><br />
<object width="480" height="295"><param name="movie" value="http://www.youtube.com/v/KA5RQv9mBoY&#038;hl=en_US&#038;fs=1&#038;"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/KA5RQv9mBoY&#038;hl=en_US&#038;fs=1&#038;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="295"></embed></object></p>
<p><strong>Chromium OS Fast Boot</strong><br />
<object width="480" height="295"><param name="movie" value="http://www.youtube.com/v/mTFfl7AjNfI&#038;hl=en_US&#038;fs=1&#038;"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/mTFfl7AjNfI&#038;hl=en_US&#038;fs=1&#038;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="295"></embed></object></p>
<p>The basic architecture of Google Chromium OS is pretty simple. Instead of loading all the stuffs by ordinary operating systems (like drivers, detecting hardware, kernel and etc.), the computer that runs Chromium OS directly load the necessary softwares (in this case, the Chrome browser and other multimedia stuffs) and does not need to load other inessential stuffs.</p>
<p>It is pretty interesting to go through how why Google builds up the Chromium OS. Although the project is still in very early stage, you can get involve in the project or to download the source code to have a test run. You can join them at the <a href="http://www.chromium.org/chromium-os" target="_blank">Chromium Projects website for Chromium OS</a>.</p>
<p>Chrome OS will be available for consumers around end of next year. If you can't wait for the final release of Chrome OS, you can download <a href="http://discuss.gdgt.com/google/chrome-os/general/Download-Chrome-OS-VMWare-image/" target="_blank">Chrome OS VMWare/VirtualBox image</a> and run it as virtual machine on top of your current operating system (Windows, Mac, Linux).</p>
<p>Download it at your own risk because it is still in early development stage. However it should not have much risk since everything will be running in a virtual enviroment.</p>
<p>Stay updated with Google Chromium by visiting <a href="http://googleblog.blogspot.com" target="_blank">The Google Official Blog</a> and <a href="http://www.chromium.org/" target="_blank">The Chromium Projects</a> website.</p>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-enjoy">
<ul class="socials">
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=Google+Chromium+OS+-+http://b2l.me/aqnp4&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="shr-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://www.snippetit.com/2009/11/google-chromium-os/&amp;imageurl=" rel="nofollow" class="external" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="shr-yahoobuzz">
			<a href="http://buzz.yahoo.com/submit/?submitUrl=http://www.snippetit.com/2009/11/google-chromium-os/&amp;submitHeadline=Google+Chromium+OS&amp;submitSummary=Google%20Chromium%20OS%20or%20Chrome%20OS%20is%20an%20open%20source%20project%20created%20by%20Google%20that%20aims%20to%20build%20an%20operating%20system%20that%20provide%20fast%2C%20simple%20and%20more%20secure%20computing%20experience.%20The%20new%20OS%20is%20target%20for%20people%20who%20spend%20most%20of%20their%20time%20on%20the%20web.%0D%0A%0D%0AThe%20following%20videos%20explain%20in%20detailed%20what&amp;submitCategory=science&amp;submitAssetType=text" rel="nofollow" class="external" title="Buzz up!">Buzz up!</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://www.snippetit.com/2009/11/google-chromium-os/&amp;title=Google+Chromium+OS" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://www.snippetit.com/2009/11/google-chromium-os/&amp;title=Google+Chromium+OS" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-blinklist">
			<a href="http://www.blinklist.com/index.php?Action=Blink/addblink.php&amp;Url=http://www.snippetit.com/2009/11/google-chromium-os/&amp;Title=Google+Chromium+OS" rel="nofollow" class="external" title="Share this on Blinklist">Share this on Blinklist</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://www.snippetit.com/2009/11/google-chromium-os/&amp;title=Google+Chromium+OS" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="shr-technorati">
			<a href="http://technorati.com/faves?add=http://www.snippetit.com/2009/11/google-chromium-os/" rel="nofollow" class="external" title="Share this on Technorati">Share this on Technorati</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>

<h2  class="related_post_title">Related Articles</h2><ul class="related_post"><li><a href="http://www.snippetit.com/2009/06/sitestimator-com-new-badge-released/" title="Sitestimator.com: New Badge Released">Sitestimator.com: New Badge Released</a></li><li><a href="http://www.snippetit.com/2009/06/bing-a-new-search-engine-from-microsoft/" title="Bing: A New Search Engine from Microsoft">Bing: A New Search Engine from Microsoft</a></li><li><a href="http://www.snippetit.com/2009/05/google-desktop-google-reader-a-new-gadget-for-your-google-desktop/" title="Google Desktop: Google Reader, A New Gadget for Your Google Desktop">Google Desktop: Google Reader, A New Gadget for Your Google Desktop</a></li><li><a href="http://www.snippetit.com/2009/05/google-chrome-how-to-stop-youtube-loading-data-from-the-internet/" title="Google Chrome: How to Stop Youtube Loading Data from the Internet">Google Chrome: How to Stop Youtube Loading Data from the Internet</a></li><li><a href="http://www.snippetit.com/2009/05/seo-get-higher-ranking-in-search-engines/" title="SEO: Get Higher Ranking in Search Engines">SEO: Get Higher Ranking in Search Engines</a></li><li><a href="http://www.snippetit.com/2009/04/system-architecture-analysis-google-chrome-vs-internet-explore-8/" title="System Architecture Analysis &#8211; Google Chrome vs Internet Explore 8">System Architecture Analysis &#8211; Google Chrome vs Internet Explore 8</a></li><li><a href="http://www.snippetit.com/2009/02/get-the-url-of-a-photo-in-different-sizes-in-flickrcom/" title="Get the URL of a photo in different sizes in flickr.com">Get the URL of a photo in different sizes in flickr.com</a></li><li><a href="http://www.snippetit.com/2008/10/google-chrome-bug/" title="Google Chrome Bug?">Google Chrome Bug?</a></li><li><a href="http://www.snippetit.com/2008/04/google-adsense-search-result-in-worpress/" title="Google Adsense Search Result in Worpress">Google Adsense Search Result in Worpress</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.snippetit.com/2009/11/google-chromium-os/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JavaScript: Overcome Slow Loading JavaScript On A Web Page</title>
		<link>http://www.snippetit.com/2009/11/javascript-overcome-slow-loading-javascript-on-a-web-page/</link>
		<comments>http://www.snippetit.com/2009/11/javascript-overcome-slow-loading-javascript-on-a-web-page/#comments</comments>
		<pubDate>Thu, 19 Nov 2009 11:37:34 +0000</pubDate>
		<dc:creator>szehau</dc:creator>
				<category><![CDATA[Programming and Scripting]]></category>
		<category><![CDATA[Tips and Tricks]]></category>
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://www.snippetit.com/?p=330</guid>
		<description><![CDATA[Sometime a web page may load slowly due to loading a third party JavaScript source file from other domain. Most of the time, a web site comes with advertisement scripts or scripts for keep tracking visitors and these scripts are normally provided by third parties like Google Adsense, Statcounter, Amazon and etc. When these scripts' [...]]]></description>
			<content:encoded><![CDATA[<p>Sometime a web page may load slowly due to loading a third party JavaScript source file from other domain. Most of the time, a web site comes with advertisement scripts or scripts for keep tracking visitors and these scripts are normally provided by third parties like Google Adsense, Statcounter, Amazon and etc. When these scripts' loading speed is extremely slow, it blocks the whole page from loading.</p>
<p><span id="more-330"></span></p>
<p>One of the way to overcome the slow loading of JavaScript problems is to move the code that load the JavaScript file to the end of the website before the <code>body</code> tag. For example, <code>&lt;script type='text/javascript' src='http://www.example.com/some_script.js'&gt;&lt;/script&gt;</code>. This is so that the browser can load and render the whole page and then only load and run the script.</p>
<p>But this does not actually solve most of the problem. This is because in most time, in most JavaScript, the programmers will use the <code>document.write()</code> method to render the HTML code at the position where the JavaScript is loaded. For example, if you move the source line that load a advertisement to the bottom of the page and left the parameters on top, the advertisement will be loaded at the bottom of the page.</p>
<p>To solve this problem, we can implement a simple tricks with little JavaScript code. The idea is like this:</p>
<ul>
<li>Put a <strong>empty </strong><code>div</code> place holder at the place where you originally want to put and give it a unique name, let's say <code>ads1_ori</code>.</li>
<li>Put a <strong>hidden </strong><code>div</code> place holder at the bottom, put the scripts that load slowly inside the place hold and give it a unique name, let's say <code>ads1_new</code>.</li>
<li>At bottom of the page, right before the <code>body</code> tag, write a few line of JavaScript code to load the HTML content from <code>ads1_ori</code> to <code>ads1_new</code>.</li>
</ul>
<p>Example of implementation:</p>
<p><code></p>
<pre>&lt;html&gt;
  &lt;head&gt;&lt;title&gt;Some Web Site&lt;/title&gt;&lt;/head&gt;
  &lt;/body&gt;

  ....

  &lt;div id="ads1_ori "&gt;&lt;/div&gt;

  ...

  &lt;div id="ads1_new" style="display:none"&gt;
    &lt;!-- advertisement --&gt;
    &lt;script type="text/javascript"&gt;
      paramenter = "abcdefg";
    &lt;/script&gt;
    &lt;script type="text/javascript" src="http://www.example.com/some_script.js"&gt;&lt;/script&gt;
    &lt;!-- advertisement --&gt;
  &lt;/div&gt;

  &lt;script type="text/javascript"&gt;
    document.getElementById('ads1_ori').innerHTML = document.getElementById('ads1_new').innerHTML;
  &lt;/script&gt;
  &lt;/body&gt;
&lt;/html&gt;</pre>
<p></code></p>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-enjoy">
<ul class="socials">
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=JavaScript%3A+Overcome+Slow+Loading+JavaScript+On+A+Web+Page+-+http://b2l.me/akf7x&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="shr-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://www.snippetit.com/2009/11/javascript-overcome-slow-loading-javascript-on-a-web-page/&amp;imageurl=" rel="nofollow" class="external" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="shr-yahoobuzz">
			<a href="http://buzz.yahoo.com/submit/?submitUrl=http://www.snippetit.com/2009/11/javascript-overcome-slow-loading-javascript-on-a-web-page/&amp;submitHeadline=JavaScript%3A+Overcome+Slow+Loading+JavaScript+On+A+Web+Page&amp;submitSummary=Sometime%20a%20web%20page%20may%20load%20slowly%20due%20to%20loading%20a%20third%20party%20JavaScript%20source%20file%20from%20other%20domain.%20Most%20of%20the%20time%2C%20a%20web%20site%20comes%20with%20advertisement%20scripts%20or%20scripts%20for%20keep%20tracking%20visitors%20and%20these%20scripts%20are%20normally%20provided%20by%20third%20parties%20like%20Google%20Adsense%2C%20Statcounter%2C%20Am&amp;submitCategory=science&amp;submitAssetType=text" rel="nofollow" class="external" title="Buzz up!">Buzz up!</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://www.snippetit.com/2009/11/javascript-overcome-slow-loading-javascript-on-a-web-page/&amp;title=JavaScript%3A+Overcome+Slow+Loading+JavaScript+On+A+Web+Page" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://www.snippetit.com/2009/11/javascript-overcome-slow-loading-javascript-on-a-web-page/&amp;title=JavaScript%3A+Overcome+Slow+Loading+JavaScript+On+A+Web+Page" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-blinklist">
			<a href="http://www.blinklist.com/index.php?Action=Blink/addblink.php&amp;Url=http://www.snippetit.com/2009/11/javascript-overcome-slow-loading-javascript-on-a-web-page/&amp;Title=JavaScript%3A+Overcome+Slow+Loading+JavaScript+On+A+Web+Page" rel="nofollow" class="external" title="Share this on Blinklist">Share this on Blinklist</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://www.snippetit.com/2009/11/javascript-overcome-slow-loading-javascript-on-a-web-page/&amp;title=JavaScript%3A+Overcome+Slow+Loading+JavaScript+On+A+Web+Page" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="shr-technorati">
			<a href="http://technorati.com/faves?add=http://www.snippetit.com/2009/11/javascript-overcome-slow-loading-javascript-on-a-web-page/" rel="nofollow" class="external" title="Share this on Technorati">Share this on Technorati</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>

<h2  class="related_post_title">Related Articles</h2><ul class="related_post"><li><a href="http://www.snippetit.com/2009/12/adobe-acrobat-reader-possible-security-vulnerability-when-acrobat-javascript-is-enabled/" title="Adobe Acrobat Reader: Possible Security Vulnerability When Acrobat JavaScript Is Enabled">Adobe Acrobat Reader: Possible Security Vulnerability When Acrobat JavaScript Is Enabled</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.snippetit.com/2009/11/javascript-overcome-slow-loading-javascript-on-a-web-page/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>.NET: Microsoft to Open Source .NET Micro Framework</title>
		<link>http://www.snippetit.com/2009/11/net-microsoft-to-open-source-net-micro-framework/</link>
		<comments>http://www.snippetit.com/2009/11/net-microsoft-to-open-source-net-micro-framework/#comments</comments>
		<pubDate>Wed, 18 Nov 2009 17:34:07 +0000</pubDate>
		<dc:creator>szehau</dc:creator>
				<category><![CDATA[Programming and Scripting]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[open source]]></category>

		<guid isPermaLink="false">http://www.snippetit.com/?p=327</guid>
		<description><![CDATA[Microsoft has just announced the release of .NET Micro Framework version 4.0. The new .NET Micro Framework's source code will be made available under the Apache 2.0 license. All of the source of .NET Micro Framework will be made available, including Base Class Libraries which were implemented for .NET Micro Framework and the CLR code itself. [...]]]></description>
			<content:encoded><![CDATA[<p>Microsoft has just announced the release of .NET Micro Framework version 4.0. The new .NET Micro Framework's source code will be made available under the <a href="http://www.apache.org/licenses/LICENSE-2.0.html" target="_blank">Apache 2.0 license</a>.</p>
<p style="text-align: center;"><img class="aligncenter" src="http://farm3.static.flickr.com/2715/4115445348_48fe1eca0a.jpg" alt="Dot Net Framework" width="300" height="169" /></p>
<p><span id="more-327"></span>All of the source of .NET Micro Framework will be made available, including Base Class Libraries which were implemented for .NET Micro Framework and the CLR code itself.</p>
<p>The TCP/IP stack library in .NET Framework is a third party software (EBSNet) so Microsoft does not have the rights to distribute that source code. Developers who needs the source code for TCP/IP stack will need to get it from EBSNet.</p>
<p>The Cryptography library is not included in the source code because they are being used outside of the scope of the .NET Micro Framework.</p>
<p>Read more at <a href="http://arstechnica.com/open-source/news/2009/11/microsoft-to-open-source-net-micro-framework.ars" target="_blank">ars technica</a>.</p>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-enjoy">
<ul class="socials">
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=.NET%3A+Microsoft+to+Open+Source+.NET+Micro+Framework+-+http://b2l.me/ajq7s&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="shr-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://www.snippetit.com/2009/11/net-microsoft-to-open-source-net-micro-framework/&amp;imageurl=" rel="nofollow" class="external" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="shr-yahoobuzz">
			<a href="http://buzz.yahoo.com/submit/?submitUrl=http://www.snippetit.com/2009/11/net-microsoft-to-open-source-net-micro-framework/&amp;submitHeadline=.NET%3A+Microsoft+to+Open+Source+.NET+Micro+Framework&amp;submitSummary=Microsoft%20has%20just%C2%A0announced%20the%20release%20of%20.NET%20Micro%20Framework%20version%204.0.%20The%20new%20.NET%20Micro%20Framework%27s%20source%20code%20will%20be%20made%20available%20under%20the%20Apache%202.0%20license.%0D%0A%0D%0A%0D%0AAll%20of%20the%20source%20of%20.NET%20Micro%20Framework%20will%20be%20made%20available%2C%20including%20Base%20Class%20Libraries%20which%20were%20implemented%20&amp;submitCategory=science&amp;submitAssetType=text" rel="nofollow" class="external" title="Buzz up!">Buzz up!</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://www.snippetit.com/2009/11/net-microsoft-to-open-source-net-micro-framework/&amp;title=.NET%3A+Microsoft+to+Open+Source+.NET+Micro+Framework" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://www.snippetit.com/2009/11/net-microsoft-to-open-source-net-micro-framework/&amp;title=.NET%3A+Microsoft+to+Open+Source+.NET+Micro+Framework" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-blinklist">
			<a href="http://www.blinklist.com/index.php?Action=Blink/addblink.php&amp;Url=http://www.snippetit.com/2009/11/net-microsoft-to-open-source-net-micro-framework/&amp;Title=.NET%3A+Microsoft+to+Open+Source+.NET+Micro+Framework" rel="nofollow" class="external" title="Share this on Blinklist">Share this on Blinklist</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://www.snippetit.com/2009/11/net-microsoft-to-open-source-net-micro-framework/&amp;title=.NET%3A+Microsoft+to+Open+Source+.NET+Micro+Framework" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="shr-technorati">
			<a href="http://technorati.com/faves?add=http://www.snippetit.com/2009/11/net-microsoft-to-open-source-net-micro-framework/" rel="nofollow" class="external" title="Share this on Technorati">Share this on Technorati</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>

<h2  class="related_post_title">Related Articles</h2><ul class="related_post"><li><a href="http://www.snippetit.com/2009/06/bing-a-new-search-engine-from-microsoft/" title="Bing: A New Search Engine from Microsoft">Bing: A New Search Engine from Microsoft</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.snippetit.com/2009/11/net-microsoft-to-open-source-net-micro-framework/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Java: Loading Large Data into JTable or JList</title>
		<link>http://www.snippetit.com/2009/11/java-loading-large-data-into-jtable-or-jlist/</link>
		<comments>http://www.snippetit.com/2009/11/java-loading-large-data-into-jtable-or-jlist/#comments</comments>
		<pubDate>Tue, 10 Nov 2009 04:06:50 +0000</pubDate>
		<dc:creator>szehau</dc:creator>
				<category><![CDATA[Programming and Scripting]]></category>
		<category><![CDATA[algorithm]]></category>
		<category><![CDATA[how to]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[JList]]></category>
		<category><![CDATA[JTable]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://www.snippetit.com/?p=309</guid>
		<description><![CDATA[In software programming (especially Graphical User Interface or GUI programming), many times, we need to load data from file or database into a table or list to be displayed to user on computer screen. Most of the time, the size of the data can be determined only during runtime. The data could be very small [...]]]></description>
			<content:encoded><![CDATA[<p>In software programming (especially Graphical User Interface or GUI programming), many times, we need to load data from file or database into a table or list to be displayed to user on computer screen. Most of the time, the size of the data can be determined only during runtime. The data could be very small to a few rows of record and could be very large to a few millions rows of record.</p>
<p><span id="more-309"></span>The main problem facing by most of the programmers is that, the program cannot load all the data into memory because the computer has limited memory. Although the price of  RAM for a computer today is pretty cheap but adding more RAMs into a computer does not solve the problem in long term because you will get more and more data when the time past. Some more, it is not efficient to load all data once into memory because it will take a lot of time to load all the data (imagine to load a million of  records) and slow down the overall process and performance of the computer (other programs and operating system need to use memory too!).</p>
<p>One of the common way to solve this problem is to load the relevant data when the system needed. If you study how <code>JList</code> or <code>JTable</code> works, <code>JList</code> or <code>JTable</code> will only render the data that displayed on screen. The data requested by <code>JList</code> or <code>JTable</code> during runtime is retrieved from the list's or table's model. To utilize the model feature, you can write your own class that extends <code>AbstractListModel</code> or <code>AbstractTableModel</code> so that you can provide the needed data when necessary. The following example shows the usage of <code>AbstractTableModel</code>.</p>
<p><code></p>
<pre>private class SimpleModel extends AbstractTableModel {
  public int getRowCount() {
    /* return total rows of your data */
  }

  public int getColumnCount() {
    /* return total columns of your data, normally fixed value */
  }

  public Object getValueAt(int rowIndex, int columnIndex) {
    /* retrieve the relevant data from file or database */
  }
}

...

/* To use the model */
JTable table = new JTable();
table.setModel(new SimpleModel());
</pre>
<p></code></p>
<p>Although the "load when necessary" solution does solve the problem but it is still inefficient. Imagine if someone keep scrolling the big list of JTable or JList or keep moving mouse over or clicking on the records in the <code>JTable</code> or <code>JList</code>. Each of these actions will trigger the <code>JTable</code> or <code>JList</code> to re-render the screen and therefore make a data request through the data model. At the end, it will slow down the overall performance because of file or database (worse if over a network) reading activities.</p>
<p>So now we see another problem. We cannot load all the data into memory because computer has limited memory and we cannot keep reading data because it is inefficient to do so. What we can do now?</p>
<p>The best solution to the above problem is we load some of the data into memory and load the data from disk into memory again when it is not in the memory. We also need to decide when to dispose some of the data when we have loaded the maximum data into memory. The following parameters are to be decided by programmer in order to implement the solution:</p>
<ul>
<li>Maximum memory used to cached the data loaded from disk - normally I will allow the program to use about 10Mb of the memory</li>
<li>When and what data to be disposed when the memory cached reached the maximum - normally I will dispose the least recent used data</li>
</ul>
<p>Below is the sample solution for a handling a large <code>JTable</code> data:</p>
<p><code></p>
<pre>private class BetterModel extends AbstractTableModel {
  private final static int COLUMN_COUNT = 4;
  private final static int MEMORY_SIZE = 10 * 1024 * 1024;
  private final static int RECORD_SIZE = COLUMN_COUNT * 200;

  private int rowCount;
  private RecordCache cache;

  public BetterModel() {
    cache = new RecordCache(MEMORY_SIZE/RECORD_SIZE);
    rowCount = /* load row count from file or database */
  }

  public int getRowCount() {
    return rowCount;
  }

  public int getColumnCount() {
    return COLUMN_COUNT;
  }

  public Object getValueAt(int rowIndex, int columnIndex) {
    Integer row;
    Record record;

    row = new Integer(rowIndex);
    record = cache.get(row);

    if (record == null ) {
      // Load from file or database if record is not found in memory
      record = getRecord(rowIndex);
      // Save in to cache
      cache.put(row, record);
    }

    // Return the data at rowIndex and columnIndex
    return record.columnData[columnIndex];
  }

  public Record getRecord(int rowIndex) {
      /* return record loaded from disk or database */
  }

  private class Record {
    public String columnData[];
  }

  private class RecordCache extends LinkedHashMap&lt;Integer,Record&gt; {
    private int cacheSize;

    public RecordCache (int size) {
      cacheSize = size;
    }

    protected boolean removeEldestEntry(Entry&lt;Integer, Record&gt; eldest) {
      if (size() &gt; ldcSize) {
        // Release some memory
        eldest.getValue().columnData = null;
        return true;
      }
      return false;
    }
  }
}</pre>
<p></code></p>
<p>You can also further enhance the above solution by paginate the records. For example 50 records in one page. In the above example, it will take about 40k of memory size per page. This is because reading 40k at once from disk or network is much more efficient than reading 800 bytes from disk or network for 50 times. After you have paginate your records, make sure you map the row index to the relevant page index (e.g. row index at 55 is at page index 1).</p>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-enjoy">
<ul class="socials">
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=Java%3A+Loading+Large+Data+into+JTable+or+JList+-+http://b2l.me/adgfh&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="shr-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://www.snippetit.com/2009/11/java-loading-large-data-into-jtable-or-jlist/&amp;imageurl=" rel="nofollow" class="external" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="shr-yahoobuzz">
			<a href="http://buzz.yahoo.com/submit/?submitUrl=http://www.snippetit.com/2009/11/java-loading-large-data-into-jtable-or-jlist/&amp;submitHeadline=Java%3A+Loading+Large+Data+into+JTable+or+JList&amp;submitSummary=In%20software%20programming%20%28especially%20Graphical%20User%20Interface%20or%20GUI%20programming%29%2C%20many%20times%2C%20we%20need%20to%20load%20data%20from%20file%20or%20database%20into%20a%20table%20or%20list%20to%20be%20displayed%20to%20user%20on%20computer%20screen.%20Most%20of%20the%20time%2C%20the%20size%20of%20the%20data%20can%20be%20determined%20only%20during%20runtime.%20The%20data%20could%20be%20ve&amp;submitCategory=science&amp;submitAssetType=text" rel="nofollow" class="external" title="Buzz up!">Buzz up!</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://www.snippetit.com/2009/11/java-loading-large-data-into-jtable-or-jlist/&amp;title=Java%3A+Loading+Large+Data+into+JTable+or+JList" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://www.snippetit.com/2009/11/java-loading-large-data-into-jtable-or-jlist/&amp;title=Java%3A+Loading+Large+Data+into+JTable+or+JList" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-blinklist">
			<a href="http://www.blinklist.com/index.php?Action=Blink/addblink.php&amp;Url=http://www.snippetit.com/2009/11/java-loading-large-data-into-jtable-or-jlist/&amp;Title=Java%3A+Loading+Large+Data+into+JTable+or+JList" rel="nofollow" class="external" title="Share this on Blinklist">Share this on Blinklist</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://www.snippetit.com/2009/11/java-loading-large-data-into-jtable-or-jlist/&amp;title=Java%3A+Loading+Large+Data+into+JTable+or+JList" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="shr-technorati">
			<a href="http://technorati.com/faves?add=http://www.snippetit.com/2009/11/java-loading-large-data-into-jtable-or-jlist/" rel="nofollow" class="external" title="Share this on Technorati">Share this on Technorati</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>

<h2  class="related_post_title">Related Articles</h2><ul class="related_post"><li><a href="http://www.snippetit.com/2010/01/java-format-integer-into-fixed-width-string/" title="Java: Format Integer Into Fixed Width String">Java: Format Integer Into Fixed Width String</a></li><li><a href="http://www.snippetit.com/2009/05/java-least-recently-used-lru-cache/" title="Java: Least Recently Used (LRU) Cache">Java: Least Recently Used (LRU) Cache</a></li><li><a href="http://www.snippetit.com/2009/04/java-randomly-sort-values-in-a-array-the-generic-way-in-single-pasas/" title="Java: Randomly sort values in a array (the generic way) in single pass">Java: Randomly sort values in a array (the generic way) in single pass</a></li><li><a href="http://www.snippetit.com/2009/03/java-format-integer-into-number-of-decimal-places-and-performance/" title="Java: Format integer into number of decimal places and performance">Java: Format integer into number of decimal places and performance</a></li><li><a href="http://www.snippetit.com/2009/12/java-continuously-read-data-from-filechannel-without-mappedbytebuffer/" title="Java: Continuously Read Data From FileChannel Without MappedByteBuffer">Java: Continuously Read Data From FileChannel Without MappedByteBuffer</a></li><li><a href="http://www.snippetit.com/2009/08/java-format-long-integer-into-hexadecimal-string/" title="Java: Format Long Integer Into Hexadecimal String">Java: Format Long Integer Into Hexadecimal String</a></li><li><a href="http://www.snippetit.com/2009/06/java-stop-a-thread-correctly/" title="Java: Stop A Thread Correctly">Java: Stop A Thread Correctly</a></li><li><a href="http://www.snippetit.com/2009/05/jsp-how-to-declare-methods-and-inner-class-in-jsp/" title="JSP: How to Declare Methods and Inner Class in JSP">JSP: How to Declare Methods and Inner Class in JSP</a></li><li><a href="http://www.snippetit.com/2009/03/java-static-constructor/" title="Java Static Constructor">Java Static Constructor</a></li><li><a href="http://www.snippetit.com/2010/05/database-char-and-varchar-what-are-the-differences/" title="Database: CHAR and VARCHAR &#8211; What are the differences?">Database: CHAR and VARCHAR &#8211; What are the differences?</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.snippetit.com/2009/11/java-loading-large-data-into-jtable-or-jlist/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Java: Format Long Integer Into Hexadecimal String</title>
		<link>http://www.snippetit.com/2009/08/java-format-long-integer-into-hexadecimal-string/</link>
		<comments>http://www.snippetit.com/2009/08/java-format-long-integer-into-hexadecimal-string/#comments</comments>
		<pubDate>Mon, 17 Aug 2009 16:11:26 +0000</pubDate>
		<dc:creator>szehau</dc:creator>
				<category><![CDATA[Programming and Scripting]]></category>
		<category><![CDATA[DecimalFormat]]></category>
		<category><![CDATA[Float]]></category>
		<category><![CDATA[format]]></category>
		<category><![CDATA[format Integer]]></category>
		<category><![CDATA[how to]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Long]]></category>
		<category><![CDATA[String]]></category>

		<guid isPermaLink="false">http://www.snippetit.com/?p=302</guid>
		<description><![CDATA[In software programming, sometime you may want to convert a long integer or integer into hexadecimal string for viewing purpose or also as a text format to be stored in text file or database. The Java API itself does not have a class or function to convert a long into a fixed 16 characters hexadecimal [...]]]></description>
			<content:encoded><![CDATA[<p>In software programming, sometime you may want to convert a long integer or integer into hexadecimal string for viewing purpose or also as a text format to be stored in text file or database.</p>
<p>The Java API itself does not have a class or function to convert a long into a fixed 16 characters hexadecimal string or an integer into  fixed 8 characters hexadecimal string.</p>
<p>The Java's <code>Long.toHexString(long i)</code> or <code>Integer.toHexString(int i)</code> only able to convert the integer value to a string of ASCII digits in hexadecimal (base 16) with no extra leading 0s and it does not support the reverse way (from hexadecimal string to long integer value).</p>
<p><span id="more-302"></span></p>
<p>I wrote a simple class to convert a long integer value into fixed length hexadecimal string and vice versa.</p>
<p><code> </code></p>
<p><code></p>
<pre>public class Hex {

  private final static char[] HEX = {
    '0', '1', '2', '3', '4', '5', '6', '7',
    '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'
  };

  public static long toLong(String hexadecimal) throws NumberFormatException{
    char[] chars;
    char c;
    long value;
    int i;
    byte b;

    if (hexadecimal == null)
      throw new IllegalArgumentException();

    chars = hexadecimal.toUpperCase().toCharArray();
    if (chars.length != 16)
      throw new HexValueException("Incomplete hex value");

    value = 0;
    b = 0;
    for (i = 0; i &lt; 16; i++) {
      c = chars[i];
      if (c &gt;= '0' &amp;&amp; c &lt;= '9') {
        value = ((value &lt;&lt; 4) | (0xff &amp; (c - '0')));
      } else if (c &gt;= 'A' &amp;&amp; c &lt;= 'F') {
        value = ((value &lt;&lt; 4) | (0xff &amp; (c - 'A' + 10)));
      } else {
        throw new NumberFormatException("Invalid hex character: " + c);
      }
    }

    return value;
  }

  public static String fromLong(long value) {
    char[] hexs;
    int i;
    int c;

    hexs = new char[16];
    for (i = 0; i &lt; 16; i++) {
      c = (int)(value &amp; 0xf);
      hexs[16-i-1] = HEX[c];
      value = value &gt;&gt; 4;
    }
    return new String(hexs);
  }

  public static void main(String[] arg) {
    int i;
    long[] test = { -1234567890, 1234567890, 987654321, -987654321, 0xFFFFFFFFFFFFFFFFl, 0x1234567890FFFFFFl };
    long v;
    String s;

    for (i = 0; i &lt; test.length; i++) {
      s = Hex.fromLong(test[i]);
      v = 0;
      try {
        v = Hex.toLong(s);
      } catch(NumberFormatException ex) {
        System.err.println(ex.getMessage());
      }
      if (v != test[i]) {
        System.err.println("Not same " + test[i] + " " + v);
        System.exit(1);
      }
    }
    System.err.println("Test completed satisfactory");
  }
}</pre>
<p></code></p>
<p>To convert long integer into 16 characters hexadecimal string:</p>
<p><code>String result = Hex.fromLong(1234567890);</code></p>
<p>To convert  16 characters hexadecimal string into long integer:</p>
<p><code>long result = Hex.toLong("00000000499602D2");</code></p>
<p>The Hex class above can be easily modified to support integer and short value by changing the data type and its size (e.g. integer has 4 bytes or 8 characters of hexadecimal and short has 2 bytes or 4 characters of hexadecimal).</p>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-enjoy">
<ul class="socials">
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=Java%3A+Format+Long+Integer+Into+Hexadecimal+String+-+http://b2l.me/adhm9&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="shr-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://www.snippetit.com/2009/08/java-format-long-integer-into-hexadecimal-string/&amp;imageurl=" rel="nofollow" class="external" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="shr-yahoobuzz">
			<a href="http://buzz.yahoo.com/submit/?submitUrl=http://www.snippetit.com/2009/08/java-format-long-integer-into-hexadecimal-string/&amp;submitHeadline=Java%3A+Format+Long+Integer+Into+Hexadecimal+String&amp;submitSummary=In%20software%20programming%2C%20sometime%20you%20may%20want%20to%20convert%20a%20long%20integer%20or%20integer%20into%20hexadecimal%20string%20for%20viewing%20purpose%20or%20also%20as%20a%20text%20format%20to%20be%20stored%20in%20text%20file%20or%20database.%0D%0A%0D%0AThe%20Java%20API%20itself%20does%20not%20have%20a%20class%20or%20function%20to%20convert%20a%20long%20into%20a%20fixed%2016%20characters%20hexade&amp;submitCategory=science&amp;submitAssetType=text" rel="nofollow" class="external" title="Buzz up!">Buzz up!</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://www.snippetit.com/2009/08/java-format-long-integer-into-hexadecimal-string/&amp;title=Java%3A+Format+Long+Integer+Into+Hexadecimal+String" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://www.snippetit.com/2009/08/java-format-long-integer-into-hexadecimal-string/&amp;title=Java%3A+Format+Long+Integer+Into+Hexadecimal+String" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-blinklist">
			<a href="http://www.blinklist.com/index.php?Action=Blink/addblink.php&amp;Url=http://www.snippetit.com/2009/08/java-format-long-integer-into-hexadecimal-string/&amp;Title=Java%3A+Format+Long+Integer+Into+Hexadecimal+String" rel="nofollow" class="external" title="Share this on Blinklist">Share this on Blinklist</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://www.snippetit.com/2009/08/java-format-long-integer-into-hexadecimal-string/&amp;title=Java%3A+Format+Long+Integer+Into+Hexadecimal+String" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="shr-technorati">
			<a href="http://technorati.com/faves?add=http://www.snippetit.com/2009/08/java-format-long-integer-into-hexadecimal-string/" rel="nofollow" class="external" title="Share this on Technorati">Share this on Technorati</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>

<h2  class="related_post_title">Related Articles</h2><ul class="related_post"><li><a href="http://www.snippetit.com/2009/03/java-format-integer-into-number-of-decimal-places-and-performance/" title="Java: Format integer into number of decimal places and performance">Java: Format integer into number of decimal places and performance</a></li><li><a href="http://www.snippetit.com/2010/01/java-format-integer-into-fixed-width-string/" title="Java: Format Integer Into Fixed Width String">Java: Format Integer Into Fixed Width String</a></li><li><a href="http://www.snippetit.com/2009/12/java-continuously-read-data-from-filechannel-without-mappedbytebuffer/" title="Java: Continuously Read Data From FileChannel Without MappedByteBuffer">Java: Continuously Read Data From FileChannel Without MappedByteBuffer</a></li><li><a href="http://www.snippetit.com/2009/11/java-loading-large-data-into-jtable-or-jlist/" title="Java: Loading Large Data into JTable or JList">Java: Loading Large Data into JTable or JList</a></li><li><a href="http://www.snippetit.com/2009/06/java-stop-a-thread-correctly/" title="Java: Stop A Thread Correctly">Java: Stop A Thread Correctly</a></li><li><a href="http://www.snippetit.com/2009/05/java-format-bytes-array-into-hexadecimal-string/" title="Java: Format Bytes Array into Hexadecimal String">Java: Format Bytes Array into Hexadecimal String</a></li><li><a href="http://www.snippetit.com/2009/05/jsp-how-to-declare-methods-and-inner-class-in-jsp/" title="JSP: How to Declare Methods and Inner Class in JSP">JSP: How to Declare Methods and Inner Class in JSP</a></li><li><a href="http://www.snippetit.com/2009/04/php-format-integer-into-number-of-decimal-places/" title="PHP: Format integer into number of decimal places">PHP: Format integer into number of decimal places</a></li><li><a href="http://www.snippetit.com/2009/04/java-randomly-sort-values-in-a-array-the-generic-way-in-single-pasas/" title="Java: Randomly sort values in a array (the generic way) in single pass">Java: Randomly sort values in a array (the generic way) in single pass</a></li><li><a href="http://www.snippetit.com/2009/03/java-static-constructor/" title="Java Static Constructor">Java Static Constructor</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.snippetit.com/2009/08/java-format-long-integer-into-hexadecimal-string/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Develope a Mortgage Calculator and Win Up to $10000</title>
		<link>http://www.snippetit.com/2009/07/develope-a-mortgage-calculator-and-win-up-to-10000/</link>
		<comments>http://www.snippetit.com/2009/07/develope-a-mortgage-calculator-and-win-up-to-10000/#comments</comments>
		<pubDate>Tue, 21 Jul 2009 16:37:29 +0000</pubDate>
		<dc:creator>szehau</dc:creator>
				<category><![CDATA[New and Happening]]></category>
		<category><![CDATA[Programming and Scripting]]></category>
		<category><![CDATA[calculator]]></category>
		<category><![CDATA[contest]]></category>
		<category><![CDATA[loan calculator]]></category>
		<category><![CDATA[mortgage calculator]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://www.snippetit.com/?p=297</guid>
		<description><![CDATA[If you are a programmer, a creative programmer, I have a good news for you. Mortgage Loan Place is having a programming contest - The "Super Sexy" Mortgage Calculator Contest. You can have a chance to win $10,000 of extra pocket money by developing a mortgage calculator. The winner's calculator will become the centerpiece of the [...]]]></description>
			<content:encoded><![CDATA[<p>If you are a programmer, a creative programmer, I have a good news for you. <a href="http://www.mortgageloanplace.com/">Mortgage Loan Place</a> is having a programming contest - The "Super Sexy" Mortgage Calculator Contest. You can have a chance to win $10,000 of extra pocket money by developing a mortgage calculator. The winner's calculator will become the centerpiece of the tools section on Mortgage Loan Place.</p>
<p style="text-align: center;"><img class="aligncenter" src="http://farm3.static.flickr.com/2627/3743412086_c2a14740d4.jpg" alt="Mortgage Calculator Contest" width="500" height="165" /></p>
<p><span id="more-297"></span></p>
<p>What you need to do in this contest is to develop the best mortgage calculator on the Internet creatively. Your mortgage calculator should contain a minimum amount of functionality like taking the principal, interest, taxes and insurance as the main inputs and showing the monthly payment as the output. You can write your program in PHP, Java (I think they mean the Java language used in Javascript) and Ajax. The basic requirements are pretty simple to implement. To stand out in this contest, your program must be bug-free and you should also add in more features and functions especially on the presentation layer (on what kind of data you are going to present and how you present it).</p>
<p>I had developed a <a href="http://www.snippetit.com/2009/07/java-mortgage-payment-calculator/">mortgage calculator</a> but I think my program (a Java Applet) is too simple and it is not qualfied to enter the contest because it only helps in finding the mortgage monthly payment. Am I going to enter the contest? I think I don't have the time for now as I still have a lot of programming works on hand. Well I do have some ideas and I don't mind to share with you here.</p>
<p>If I'm the user of the calculator, what kind features will I look? Other than showing the mortgage payment, I think the calculator should be able:</p>
<ul>
<li>to generate a table that shows different mortgage payments at different rates for the terms (and export it to an Excel file).</li>
<li>to generate a table or graph that shows the total money I will need pay for the loan after the loan term (and export it to an Excel file).</li>
<li>to reverse some calculations. For example, to calculate the loan term if I'm able to pay $X of mortgage payment each month with Y% of interest rate and the principal of $Y (and also generate a table for the output, for example: loan term versus $X-20%, $X-10%, $X, $X+10% and $X+20).</li>
</ul>
<p>If you are not really sure how to calculate the mortgage payments or you want to add more features to your mortgage calculator, here are some useful materials from <a href="http://www.mortgageloanplace.com/">Mortgage Loan Place</a> for your reference:</p>
<ul>
<li><a href="http://mortgageloanplace.com/MortgageCalculatorChallenge.xls">A sample of simple mortgage calculator</a> (Excel)</li>
<li><a href="http://www.mortgageloanplace.com/MortgageCalculations.pdf">How amortization, taxes, and PMI are calculated</a> (PDF)</li>
<li><a href="http://www.mortgageloanplace.com/suggestedfeatures.pdf">Required and suggested features</a> (PDF)</li>
<li><a href="http://www.mortgagecalculator.org">http://www.mortgagecalculator.org</a></li>
<li><a href="http://www.drcalculator.com/mortgage/">http://www.drcalculator.com/mortgage/</a></li>
<li><a href="http://www.mlcalc.com">http://www.mlcalc.com</a></li>
</ul>
<p><strong>Video About The "Super Sexy" Mortgage Calculator Contest</strong><br />
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="425" height="344" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowScriptAccess" value="always" /><param name="src" value="http://www.youtube.com/v/2uNEe4Rob0E&amp;rel=0&amp;color1=0xb1b1b1&amp;color2=0xcfcfcf&amp;hl=en&amp;feature=player_embedded&amp;fs=1" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="425" height="344" src="http://www.youtube.com/v/2uNEe4Rob0E&amp;rel=0&amp;color1=0xb1b1b1&amp;color2=0xcfcfcf&amp;hl=en&amp;feature=player_embedded&amp;fs=1" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<p>The challenge runs from June 15th to July 31st, 2009. So hurry up and submit your very own, sexiest calculator!</p>
<p>Read more about <a href="http://www.mortgageloanplace.com/mortgage-calculator.php">Mortgage Calculator Contest</a>.</p>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-enjoy">
<ul class="socials">
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=Develope+a+Mortgage+Calculator+and+Win+Up+to+%2410000+-+http://b2l.me/adx7g&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="shr-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://www.snippetit.com/2009/07/develope-a-mortgage-calculator-and-win-up-to-10000/&amp;imageurl=" rel="nofollow" class="external" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="shr-yahoobuzz">
			<a href="http://buzz.yahoo.com/submit/?submitUrl=http://www.snippetit.com/2009/07/develope-a-mortgage-calculator-and-win-up-to-10000/&amp;submitHeadline=Develope+a+Mortgage+Calculator+and+Win+Up+to+%2410000&amp;submitSummary=If%20you%20are%20a%20programmer%2C%20a%20creative%20programmer%2C%20I%20have%20a%20good%20news%20for%20you.%20Mortgage%20Loan%20Place%20is%20having%20a%20programming%20contest%20-%20The%20%22Super%20Sexy%22%20Mortgage%20Calculator%20Contest.%C2%A0You%20can%20have%20a%20chance%20to%20win%20%2410%2C000%20of%20extra%20pocket%20money%20by%20developing%20a%20mortgage%20calculator.%20The%20winner%27s%20calculator%20wil&amp;submitCategory=science&amp;submitAssetType=text" rel="nofollow" class="external" title="Buzz up!">Buzz up!</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://www.snippetit.com/2009/07/develope-a-mortgage-calculator-and-win-up-to-10000/&amp;title=Develope+a+Mortgage+Calculator+and+Win+Up+to+%2410000" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://www.snippetit.com/2009/07/develope-a-mortgage-calculator-and-win-up-to-10000/&amp;title=Develope+a+Mortgage+Calculator+and+Win+Up+to+%2410000" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-blinklist">
			<a href="http://www.blinklist.com/index.php?Action=Blink/addblink.php&amp;Url=http://www.snippetit.com/2009/07/develope-a-mortgage-calculator-and-win-up-to-10000/&amp;Title=Develope+a+Mortgage+Calculator+and+Win+Up+to+%2410000" rel="nofollow" class="external" title="Share this on Blinklist">Share this on Blinklist</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://www.snippetit.com/2009/07/develope-a-mortgage-calculator-and-win-up-to-10000/&amp;title=Develope+a+Mortgage+Calculator+and+Win+Up+to+%2410000" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="shr-technorati">
			<a href="http://technorati.com/faves?add=http://www.snippetit.com/2009/07/develope-a-mortgage-calculator-and-win-up-to-10000/" rel="nofollow" class="external" title="Share this on Technorati">Share this on Technorati</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>

<h2  class="related_post_title">Related Articles</h2><ul class="related_post"><li><a href="http://www.snippetit.com/2009/11/java-loading-large-data-into-jtable-or-jlist/" title="Java: Loading Large Data into JTable or JList">Java: Loading Large Data into JTable or JList</a></li><li><a href="http://www.snippetit.com/2009/07/java-mortgage-payment-calculator/" title="Java: Mortgage Payment Calculator">Java: Mortgage Payment Calculator</a></li><li><a href="http://www.snippetit.com/2008/04/introduction/" title="Introduction">Introduction</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.snippetit.com/2009/07/develope-a-mortgage-calculator-and-win-up-to-10000/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
