<?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>[MeIsProgrammer]</title>
	<atom:link href="http://just-thor.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://just-thor.com</link>
	<description>all play and no work makes me a dull boy</description>
	<lastBuildDate>Fri, 05 Mar 2010 09:51:56 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>My blog just went down&#8230;</title>
		<link>http://just-thor.com/2010/03/05/my-blog-just-went-down/</link>
		<comments>http://just-thor.com/2010/03/05/my-blog-just-went-down/#comments</comments>
		<pubDate>Fri, 05 Mar 2010 09:47:17 +0000</pubDate>
		<dc:creator>Thor</dc:creator>
				<category><![CDATA[Life]]></category>
		<category><![CDATA[Misc]]></category>

		<guid isPermaLink="false">http://just-thor.com/?p=136</guid>
		<description><![CDATA[I just found out my website was down, and reported to the webhosting company. After I sent out the email, I received 3 emails, 2 claimed that they can browse [...]]]></description>
			<content:encoded><![CDATA[<p>I just found out my website was down, and reported to the webhosting company. After I sent out the email, I received 3 emails, 2 claimed that they can browse the website.<br />
Here&#8217;s the reply from the sales team<br />
&#8220;We can browse both websites without problems. See enclosed printscreen.&#8221;</p>
<p>And here&#8217;s the reply from the domain team (technical team,I suppose)<br />
&#8220;Both websites http://just-thor.com/ and http://bobokow.com/ are working fine at our side. Please check again.&#8221;</p>
<p>But I still can&#8217;t open the website on my site. I even asked a friend of mine which was at another location to test and still failed. Hence I replied an email.</p>
<p>&#8220;Sir/Madam,<br />
Attached with the error page. I am glad its working on your side, but I am not browsing at your side,so please fix it.&#8221;</p>
<p>ps. site was up one hour later I replied the email. Thank you for the hardwork. <img src='http://just-thor.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://just-thor.com/2010/03/05/my-blog-just-went-down/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Google Ajax Libraries Gotcha!</title>
		<link>http://just-thor.com/2010/02/23/google-ajax-libraries-gotch/</link>
		<comments>http://just-thor.com/2010/02/23/google-ajax-libraries-gotch/#comments</comments>
		<pubDate>Tue, 23 Feb 2010 09:37:58 +0000</pubDate>
		<dc:creator>Thor</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Work]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://just-thor.com/?p=129</guid>
		<description><![CDATA[I was working on Google Map for the past few days, and was using jQuery to retrieve markers information from another URL using ajax. I came across the Google Ajax [...]]]></description>
			<content:encoded><![CDATA[<p>I was working on Google Map for the past few days, and was using jQuery to retrieve markers information from another URL using ajax. I came across the Google Ajax Libraries (http://code.google.com/apis/ajaxlibs/) which helps to load Javascript from CDN.</p>
<p>Here&#8217;s part of the code<br />
<pre><pre class="brush: javascript">
//sample code taken from http://code.google.com/apis/ajaxlibs/
&lt;script src=&quot;http://www.google.com/jsapi&quot;&gt;&lt;/script&gt;
&lt;script&gt;
&nbsp;&nbsp;// Load jQuery
&nbsp;&nbsp;google.load(&quot;jquery&quot;, &quot;1&quot;);

&nbsp;&nbsp;// on page load complete, fire off a jQuery json-p query
&nbsp;&nbsp;// against Google web search
&nbsp;&nbsp;google.setOnLoadCallback(function() {
&nbsp;&nbsp;&nbsp;&nbsp;$.getJSON(&quot;http://ajax.googleapis.com/ajax/services/search/web?q=google&amp;v=1.0&amp;callback=?&quot;,

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// on search completion, process the results
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;function (data) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (data.responseData.results &amp;&amp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;data.responseData.results.length &gt; 0) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var results = data.responseData.results;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for (var i=0; i &lt; results.length; i++) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// Display each result however you wish
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;alert(results[i].titleNoFormatting);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;});
&nbsp;&nbsp;&nbsp;&nbsp;});
&lt;/script&gt;
</pre></pre><br />
By using this code, we actually load jQuery 1 from the CDN. However, there is a gotcha. If you follow the example I attached just now, it probably won&#8217;t work, well, at least not on my FF3.5 and IE8. In fact, you will have to do something like the following instead<br />
<pre><pre class="brush: javascript">
//sample code taken from http://code.google.com/apis/ajaxlibs/
&lt;script src=&quot;http://www.google.com/jsapi&quot;&gt;&lt;/script&gt;
&lt;script&gt;
&nbsp;&nbsp;// Load jQuery
&nbsp;&nbsp;google.load(&quot;jquery&quot;, &quot;1&quot;);
&lt;/script&gt;
&lt;script&gt;
&nbsp;&nbsp;// on page load complete, fire off a jQuery json-p query
&nbsp;&nbsp;// against Google web search
&nbsp;&nbsp;google.setOnLoadCallback(function() {
&nbsp;&nbsp;&nbsp;&nbsp;$.getJSON(&quot;http://ajax.googleapis.com/ajax/services/search/web?q=google&amp;v=1.0&amp;callback=?&quot;,

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// on search completion, process the results
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;function (data) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (data.responseData.results &amp;&amp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;data.responseData.results.length &gt; 0) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var results = data.responseData.results;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for (var i=0; i &lt; results.length; i++) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// Display each result however you wish
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;alert(results[i].titleNoFormatting);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;});
&nbsp;&nbsp;&nbsp;&nbsp;});
&lt;/script&gt;
</pre></pre><br />
You will have to close the script tag that load external script from CDN before you can use it. Else you will get javascript error, in IE8, it shows &#8216;Object expected&#8217;.I really hope you will be able to read my article before you pull all your hair off. <img src='http://just-thor.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Happy Coding</p>
]]></content:encoded>
			<wfw:commentRss>http://just-thor.com/2010/02/23/google-ajax-libraries-gotch/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Released of Scala 2.8 Beta</title>
		<link>http://just-thor.com/2010/01/28/released-of-scala-2-8-beta/</link>
		<comments>http://just-thor.com/2010/01/28/released-of-scala-2-8-beta/#comments</comments>
		<pubDate>Thu, 28 Jan 2010 01:59:09 +0000</pubDate>
		<dc:creator>Thor</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://just-thor.com/?p=125</guid>
		<description><![CDATA[Finally,Scala 2.8 beta is out&#8230;
Here&#8217;s the release note.
The new Scala 2.8 codebase includes the following new fixes and features:

Redesigned collection library
The collection library has undergone a complete overhaul for Scala [...]]]></description>
			<content:encoded><![CDATA[<p>Finally,Scala 2.8 beta is out&#8230;</p>
<p id="Whatisnew">Here&#8217;s the release note.</p>
<p>The new Scala 2.8 codebase includes the following new fixes and features:</p>
<ul>
<li><strong>Redesigned collection library</strong><br />
The collection library has undergone a complete overhaul for Scala 2.8, offering a more coherent and efficient design, while maintaining virtually complete compatibility with existing sources. Detailed information at: <a href="http://www.scala-lang.org/sid/3">http://www.scala-lang.org/sid/3</a></li>
<li><strong>New array implementation, manifests for polymorphic arrays</strong><strong><br />
</strong>Handling of arrays has been simplified and optimized in Scala 2.8. The previous compiler magic has been replaced by a more systematic and predictable implementation in terms of implicit conversions. Full details at: <a href="http://www.scala-lang.org/sid/7">http://www.scala-lang.org/sid/7</a></li>
<li><strong>Type specialization</strong><br />
Scala 2.8 adds specialized type parameters, which enable the compiler to generate transparently multiple versions of a given definition, and to use the most specific version whenever the static type information at a call site allows it. Details at: <a href="http://www.scala-lang.org/sid/9">http://www.scala-lang.org/sid/9</a></li>
</ul>
<ul>
<li><strong>Named and default arguments</strong><br />
Named arguments improve the readability of method calls with many arguments. Default arguments reduce code duplication, and enable &#8220;copy&#8221; methods for case classes, useful to generate quickly modified copies of case classes. A complete description at: <a href="http://www.scala-lang.org/sid/1">http://www.scala-lang.org/sid/1</a></li>
</ul>
<ul>
<li><strong>Package objects</strong><br />
Packages can now contain besides classes and objects also methods, fields or type aliases. These are added to a package by declaring a package object. Package objects are still work in progress; more capabilities might come for 2.8 final or a release soon afterwards.</li>
</ul>
<ul>
<li><strong>Beefed up Scala Swing libraries, better documentation</strong><br />
Components publish key events, input events can be consumed, refactored window subhierarchy, additional demos, Swing listeners are installed lazily, more complete component caching, minor refactorings, bugfixes, more Scaladocs. Design document at: <a href="http://www.scala-lang.org/sid/8">http://www.scala-lang.org/sid/8</a></li>
</ul>
<ul>
<li><strong>Revamped REPL</strong><br />
Many bugfixes. Tab-completion for all packages on the classpath, as well as object and instance methods and fields, including type aliases and package objects. Searchable history, integrated shell access, and a power mode which offers direct access to compiler internals.</li>
</ul>
<ul>
<li><strong>Implicits changes</strong><br />
We have refined the implicit resolution process so that resolution is now able to determine type variables.</li>
</ul>
<ul>
<li><strong>Improved equality</strong><br />
Equality across numeric types is to be consistent across all the primitives types, while also adhering to the equals/hashCode contract. Numeric comparisons will have the same results as they would between Java primitives. This is currently still being completed.</li>
</ul>
<ul>
<li><strong>Packrat parser combinators</strong><br />
With support for packrat parsing, parser combinators are now able to handle left-recursive grammars and will show improved performance for ambiguous productions.</li>
</ul>
<ul>
<li><strong>Improved XML library</strong><br />
Many bugfixes.</li>
</ul>
<ul>
<li><strong>Type constructor inference</strong><br />
Type inference has been extended to deal with type constructors, so that, in certain cases, you can omit type parameter lists that contain higher-kinded types (aka type constructors, e.g., <span style="font-family: monospace;">List</span>).</li>
</ul>
<ul>
<li><strong>Improved Annotations</strong><br />
Scala 2.8 adds support for nested java annotations. For annotations on fields, it is now possible to specify which synthetic members (getter / setter) will have the annotation. Documentation about Scala annotations can be found at: <a href="http://www.scala-lang.org/sid/5">http://www.scala-lang.org/sid/5</a></li>
</ul>
<ul>
<li><strong>Enhanced actors</strong><br />
New Reactors provide more lightweight, purely event-based actors with optional, implicit sender identification. Support for actors with daemon-style semantics was added. Actors can be configured to use the efficient JSR166y fork/join pool, resulting in significant performance improvements on 1.6 JVMs. Schedulers are now pluggable and easier to customize.</li>
</ul>
<ul>
<li><strong>Support for continuations</strong><br />
Continuations are supported by a compiler plugin. This plugin is not included in this first beta, but will be added in subsequent releases.</li>
</ul>
<p>Here&#8217;s the <a title="Scala 2.8 Beta released" href="http://www.scala-lang.org/node/4587" target="_blank">office page link</a> and here&#8217;s the <a title="Scala download link" href="http://www.scala-lang.org/downloads" target="_blank">download link</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://just-thor.com/2010/01/28/released-of-scala-2-8-beta/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Google is making me stupid</title>
		<link>http://just-thor.com/2009/12/23/google-is-making-me-stupid/</link>
		<comments>http://just-thor.com/2009/12/23/google-is-making-me-stupid/#comments</comments>
		<pubDate>Wed, 23 Dec 2009 05:49:27 +0000</pubDate>
		<dc:creator>Thor</dc:creator>
				<category><![CDATA[Work]]></category>
		<category><![CDATA[Misc]]></category>

		<guid isPermaLink="false">http://just-thor.com/?p=122</guid>
		<description><![CDATA[For the past few years, I am so used to google services, especially search engine and email. I can&#8217;t even remember when was the last time i use a Microsoft [...]]]></description>
			<content:encoded><![CDATA[<p>For the past few years, I am so used to google services, especially search engine and email. I can&#8217;t even remember when was the last time i use a Microsoft Outlook as my email client. Web based is great, I mean, the first thing I turned on my pc will be firing up a Mozilla Firefox or Google Chrome, why do I still need to launch another application just to receive emails or notifications? Maybe I am not good at using Outlook.</p>
<p>And now,my current company requested every one in the company to use Outlook as the mail client. The experience isn&#8217;t that great though. I took 5 minutes to send an email because I don&#8217;t know how to use the address book function. I used to get that by typing name or email,and gmail just suggest me possible match. Too many buttons, what&#8217;s the difference between &#8220;Attach Item&#8221; and &#8220;Attach File&#8221;? And when I try to search for person in my address book,I just can&#8217;t. For instance, I am trying to search for a name &#8220;John Doe&#8221;,I have to type &#8220;John&#8221; first in Outlook to locate the entry,but instead I type &#8220;Doe&#8221; in Gmail it will start suggesting me.And there are so many fields in address book.Oh man,its driving me crazy.</p>
<p>I think the simplicity and usability of Gmail had make me stupid.Thanks, Google.</p>
]]></content:encoded>
			<wfw:commentRss>http://just-thor.com/2009/12/23/google-is-making-me-stupid/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>A circular linked list in Java</title>
		<link>http://just-thor.com/2009/12/03/a-circular-linked-list-in-java/</link>
		<comments>http://just-thor.com/2009/12/03/a-circular-linked-list-in-java/#comments</comments>
		<pubDate>Thu, 03 Dec 2009 10:26:21 +0000</pubDate>
		<dc:creator>Thor</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://just-thor.com/?p=117</guid>
		<description><![CDATA[I was helping a friend of mine with her work today, and we came across with a requirement that there are few players in the room we need to know [...]]]></description>
			<content:encoded><![CDATA[<p>I was helping a friend of mine with her work today, and we came across with a requirement that there are few players in the room we need to know whose turn is it after this. Yes, we can definitely use a LinkedList or an ArrayList, but its not so convenient as we have to check whether this player is at the last position of the list. If so,we will need to start from the beginning of the list again. And its also quite cumbersome to retrieve the next player info after this. Therefore, I wrote a simple yet functional Circular Linked List. You can download the source code and the compiled class <a href="http://just-thor.com/sample-works/CircularLinkedList.jar">here</a> . I will port this over to Scala whenever I have the time to do so.</p>
<p>Happy coding <img src='http://just-thor.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://just-thor.com/2009/12/03/a-circular-linked-list-in-java/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Snowing in Beijing and here are some photos</title>
		<link>http://just-thor.com/2009/11/03/snowing-in-beijing-and-here-are-some-photos/</link>
		<comments>http://just-thor.com/2009/11/03/snowing-in-beijing-and-here-are-some-photos/#comments</comments>
		<pubDate>Tue, 03 Nov 2009 04:41:49 +0000</pubDate>
		<dc:creator>Thor</dc:creator>
				<category><![CDATA[Life]]></category>
		<category><![CDATA[Photography]]></category>
		<category><![CDATA[Photo]]></category>

		<guid isPermaLink="false">http://just-thor.com/?p=89</guid>
		<description><![CDATA[Its the early morning of 1st November,and it had been raining for the past few days.I was planning to go out to some parks this morning for a walk.When i [...]]]></description>
			<content:encoded><![CDATA[<p>Its the early morning of 1st November,and it had been raining for the past few days.I was planning to go out to some parks this morning for a walk.When i woke up,I heard that it was raining,therefore I stayed in my bed until 9 am.Finally I got out from my bed,and when I looked out from the window,and it&#8217;s snowing!!I quickly make some simple food and went to the park.I took some photos as well.</p>

<a href='http://just-thor.com/2009/11/03/snowing-in-beijing-and-here-are-some-photos/img_0089/' title='IMG_0089'><img width="150" height="150" src="http://just-thor.com/wp-content/uploads/2009/11/IMG_0089-150x150.jpg" class="attachment-thumbnail" alt="" title="IMG_0089" /></a>
<a href='http://just-thor.com/2009/11/03/snowing-in-beijing-and-here-are-some-photos/img_0062/' title='IMG_0062'><img width="150" height="150" src="http://just-thor.com/wp-content/uploads/2009/11/IMG_0062-150x150.jpg" class="attachment-thumbnail" alt="" title="IMG_0062" /></a>
<a href='http://just-thor.com/2009/11/03/snowing-in-beijing-and-here-are-some-photos/img_0113/' title='IMG_0113'><img width="150" height="150" src="http://just-thor.com/wp-content/uploads/2009/11/IMG_0113-150x150.jpg" class="attachment-thumbnail" alt="" title="IMG_0113" /></a>
<a href='http://just-thor.com/2009/11/03/snowing-in-beijing-and-here-are-some-photos/img_0128/' title='IMG_0128'><img width="150" height="150" src="http://just-thor.com/wp-content/uploads/2009/11/IMG_0128-150x150.jpg" class="attachment-thumbnail" alt="" title="IMG_0128" /></a>
<a href='http://just-thor.com/2009/11/03/snowing-in-beijing-and-here-are-some-photos/img_0068/' title='IMG_0068'><img width="150" height="150" src="http://just-thor.com/wp-content/uploads/2009/11/IMG_0068-150x150.jpg" class="attachment-thumbnail" alt="" title="IMG_0068" /></a>
<a href='http://just-thor.com/2009/11/03/snowing-in-beijing-and-here-are-some-photos/img_0076/' title='IMG_0076'><img width="150" height="150" src="http://just-thor.com/wp-content/uploads/2009/11/IMG_0076-150x150.jpg" class="attachment-thumbnail" alt="" title="IMG_0076" /></a>
<a href='http://just-thor.com/2009/11/03/snowing-in-beijing-and-here-are-some-photos/img_0099/' title='IMG_0099'><img width="150" height="150" src="http://just-thor.com/wp-content/uploads/2009/11/IMG_0099-150x150.jpg" class="attachment-thumbnail" alt="" title="IMG_0099" /></a>
<a href='http://just-thor.com/2009/11/03/snowing-in-beijing-and-here-are-some-photos/img_0124/' title='IMG_0124'><img width="150" height="150" src="http://just-thor.com/wp-content/uploads/2009/11/IMG_0124-150x150.jpg" class="attachment-thumbnail" alt="" title="IMG_0124" /></a>
<a href='http://just-thor.com/2009/11/03/snowing-in-beijing-and-here-are-some-photos/img_0057/' title='IMG_0057'><img width="150" height="150" src="http://just-thor.com/wp-content/uploads/2009/11/IMG_0057-150x150.jpg" class="attachment-thumbnail" alt="" title="IMG_0057" /></a>
<a href='http://just-thor.com/2009/11/03/snowing-in-beijing-and-here-are-some-photos/img_0095/' title='IMG_0095'><img width="150" height="150" src="http://just-thor.com/wp-content/uploads/2009/11/IMG_0095-150x150.jpg" class="attachment-thumbnail" alt="" title="IMG_0095" /></a>
<a href='http://just-thor.com/2009/11/03/snowing-in-beijing-and-here-are-some-photos/img_0037/' title='IMG_0037'><img width="150" height="150" src="http://just-thor.com/wp-content/uploads/2009/11/IMG_0037-150x150.jpg" class="attachment-thumbnail" alt="" title="IMG_0037" /></a>
<a href='http://just-thor.com/2009/11/03/snowing-in-beijing-and-here-are-some-photos/img_0108/' title='IMG_0108'><img width="150" height="150" src="http://just-thor.com/wp-content/uploads/2009/11/IMG_0108-150x150.jpg" class="attachment-thumbnail" alt="" title="IMG_0108" /></a>
<a href='http://just-thor.com/2009/11/03/snowing-in-beijing-and-here-are-some-photos/img_0066/' title='IMG_0066'><img width="150" height="150" src="http://just-thor.com/wp-content/uploads/2009/11/IMG_0066-150x150.jpg" class="attachment-thumbnail" alt="" title="IMG_0066" /></a>
<a href='http://just-thor.com/2009/11/03/snowing-in-beijing-and-here-are-some-photos/img_0056/' title='IMG_0056'><img width="150" height="150" src="http://just-thor.com/wp-content/uploads/2009/11/IMG_0056-150x150.jpg" class="attachment-thumbnail" alt="" title="IMG_0056" /></a>
<a href='http://just-thor.com/2009/11/03/snowing-in-beijing-and-here-are-some-photos/img_0042/' title='IMG_0042'><img width="150" height="150" src="http://just-thor.com/wp-content/uploads/2009/11/IMG_0042-150x150.jpg" class="attachment-thumbnail" alt="" title="IMG_0042" /></a>
<a href='http://just-thor.com/2009/11/03/snowing-in-beijing-and-here-are-some-photos/img_0096/' title='IMG_0096'><img width="150" height="150" src="http://just-thor.com/wp-content/uploads/2009/11/IMG_0096-150x150.jpg" class="attachment-thumbnail" alt="" title="IMG_0096" /></a>
<a href='http://just-thor.com/2009/11/03/snowing-in-beijing-and-here-are-some-photos/img_0051/' title='IMG_0051'><img width="150" height="150" src="http://just-thor.com/wp-content/uploads/2009/11/IMG_0051-150x150.jpg" class="attachment-thumbnail" alt="" title="IMG_0051" /></a>
<a href='http://just-thor.com/2009/11/03/snowing-in-beijing-and-here-are-some-photos/img_0105/' title='IMG_0105'><img width="150" height="150" src="http://just-thor.com/wp-content/uploads/2009/11/IMG_0105-150x150.jpg" class="attachment-thumbnail" alt="" title="IMG_0105" /></a>
<a href='http://just-thor.com/2009/11/03/snowing-in-beijing-and-here-are-some-photos/img_0045/' title='IMG_0045'><img width="150" height="150" src="http://just-thor.com/wp-content/uploads/2009/11/IMG_0045-150x150.jpg" class="attachment-thumbnail" alt="" title="IMG_0045" /></a>
<a href='http://just-thor.com/2009/11/03/snowing-in-beijing-and-here-are-some-photos/img_0087/' title='IMG_0087'><img width="150" height="150" src="http://just-thor.com/wp-content/uploads/2009/11/IMG_0087-150x150.jpg" class="attachment-thumbnail" alt="" title="IMG_0087" /></a>
<a href='http://just-thor.com/2009/11/03/snowing-in-beijing-and-here-are-some-photos/img_0145/' title='IMG_0145'><img width="150" height="150" src="http://just-thor.com/wp-content/uploads/2009/11/IMG_0145-150x150.jpg" class="attachment-thumbnail" alt="" title="IMG_0145" /></a>
<a href='http://just-thor.com/2009/11/03/snowing-in-beijing-and-here-are-some-photos/img_0055/' title='IMG_0055'><img width="150" height="150" src="http://just-thor.com/wp-content/uploads/2009/11/IMG_0055-150x150.jpg" class="attachment-thumbnail" alt="" title="IMG_0055" /></a>
<a href='http://just-thor.com/2009/11/03/snowing-in-beijing-and-here-are-some-photos/img_0047/' title='IMG_0047'><img width="150" height="150" src="http://just-thor.com/wp-content/uploads/2009/11/IMG_0047-150x150.jpg" class="attachment-thumbnail" alt="" title="IMG_0047" /></a>

<p>If you look carefully,there is a photo with a lamp post and some snows on it.I can&#8217;t help wondering how come the snow can shape like a snake or whatever it reminds you of.</p>
<p>Hope you like the photos <img src='http://just-thor.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://just-thor.com/2009/11/03/snowing-in-beijing-and-here-are-some-photos/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Scala reading content from the Web</title>
		<link>http://just-thor.com/2009/10/16/scala-reading-content-from-the-web/</link>
		<comments>http://just-thor.com/2009/10/16/scala-reading-content-from-the-web/#comments</comments>
		<pubDate>Fri, 16 Oct 2009 10:54:03 +0000</pubDate>
		<dc:creator>Thor</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Scala]]></category>

		<guid isPermaLink="false">http://just-thor.com/?p=84</guid>
		<description><![CDATA[I use scala.io.Source in my previous post, and now I am going to show another usage of this util. Let&#8217;s write a simple RSS feed parser that reads feed from [...]]]></description>
			<content:encoded><![CDATA[<p>I use scala.io.Source in my previous <a href="http://just-thor.com/2009/10/01/file-reading-in-java-and-scala/">post</a>, and now I am going to show another usage of this util. Let&#8217;s write a simple RSS feed parser that reads feed from my website and parse it.</p>
<p>Here&#8217;s the code of it.</p>
<p><pre><pre class="brush: scala">
package com.justthor.reader

import scala.io.Source
import scala.xml._

object SimpleFeedReader {
&nbsp;&nbsp;def main(args : Array[String]) : Unit = {
&nbsp;&nbsp;&nbsp;&nbsp;val url = &quot;http://just-thor.com/feed/&quot;
&nbsp;&nbsp;&nbsp;&nbsp;val data = XML.loadString( Source.fromURL(url).mkString )
&nbsp;&nbsp;&nbsp;&nbsp;data \ &quot;channel&quot; \ &quot;item&quot; foreach(
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;a =&gt; println((a \ &quot;title&quot; text) + &quot; == &quot;&nbsp;&nbsp;+ (a \ &quot;link&quot; text))
&nbsp;&nbsp;&nbsp;&nbsp;)
&nbsp;&nbsp;}
}
</pre></pre></p>
<p>Ok,let&#8217;s go thru the code line by line.</p>
<p>At line 09, again we use Source to load content from url,by calling the method <strong>fromURL</strong>(quite obvious,right?).The <strong>mkString </strong>will create a String out of the content. Then, we use <strong>XML.loadString</strong> to parse the String into an XML object. </p>
<p>At line 10, we traverse the XML object with something like XQuery.<br />
The RSS xml format is something like this<br />
<pre><pre class="brush: xml">
&lt;channel&gt;
&lt;link&gt;...&lt;/link&gt;
&lt;description&gt;...&lt;/description&gt;
&lt;!-- item 1--&gt;
&lt;item&gt;
&nbsp;&nbsp;&lt;title&gt;&lt;/title&gt;
&nbsp;&nbsp;&lt;link&gt;&lt;/link&gt;
&lt;/item&gt;
&lt;!-- item 2--&gt;
&lt;item&gt;
&nbsp;&nbsp;&lt;title&gt;&lt;/title&gt;
&nbsp;&nbsp;&lt;link&gt;&lt;/link&gt;
&lt;/item&gt;
&lt;!-- and the rest goes here --&gt;
&lt;/channel&gt;
</pre></pre></p>
<p>So when we write <pre class="brush: scala">data \ &quot;channel&quot; \ &quot;item&quot;</pre>, we mean traverse to channel node, then item node of it.It will return a collection of item nodes, and then we loop it. At line 11, we will print the text within the title node and the link node.</p>
<p>Here&#8217;s the output of the result<br />
<pre><pre class="brush: text">
File Reading in Java and Scala == http://just-thor.com/2009/10/01/file-reading-in-java-and-scala/
PHP communicate with Java using JSON – Unicode Version == http://just-thor.com/2009/09/28/php-communicate-with-java-using-json-unicode-version/
Scala And JDBC == http://just-thor.com/2009/09/27/scala-and-jdbc/
A mistake or fate? == http://just-thor.com/2009/09/17/a-mistake-or-fate/
Women are weird == http://just-thor.com/2009/09/13/women-are-weird/
20 must visit sites for Java developer == http://just-thor.com/2009/09/12/20-must-visit-sites-for-java-developer/
Why do I practice pair programming? == http://just-thor.com/2009/09/08/why-do-i-practice-pair-programming/
Installing Scala on Windows == http://just-thor.com/2009/09/02/installing-scala-on-window/
Logging for different requested URI in Apache HTTP Server == http://just-thor.com/2009/09/01/logging-for-different-requested-uri-in-apache-http-server/
Say hello to Java and Scala == http://just-thor.com/2009/08/30/say-hello-to-java-and-scala/
</pre></pre></p>
<p>And now we have a very simple yet functional RSS parser.</p>
<p>Happy coding, <img src='http://just-thor.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://just-thor.com/2009/10/16/scala-reading-content-from-the-web/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>File Reading in Java and Scala</title>
		<link>http://just-thor.com/2009/10/01/file-reading-in-java-and-scala/</link>
		<comments>http://just-thor.com/2009/10/01/file-reading-in-java-and-scala/#comments</comments>
		<pubDate>Wed, 30 Sep 2009 16:46:47 +0000</pubDate>
		<dc:creator>Thor</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Scala]]></category>

		<guid isPermaLink="false">http://just-thor.com/?p=75</guid>
		<description><![CDATA[Today we are going to look at reading files in Java and how to do the same thing in Scala.
This is normally how we read files in Java.First we open [...]]]></description>
			<content:encoded><![CDATA[<p>Today we are going to look at reading files in Java and how to do the same thing in Scala.</p>
<p>This is normally how we read files in Java.First we open a reading stream, then read the content and process it,and at last we close the stream.</p>
<p><pre><pre class="brush: java">
package com.justthor;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;

public class SampleFileReader {

&nbsp;&nbsp;/**
&nbsp;&nbsp; * @param args
&nbsp;&nbsp; */
&nbsp;&nbsp;public static void main(String[] args) {
&nbsp;&nbsp;&nbsp;&nbsp;BufferedReader in; 
&nbsp;&nbsp;&nbsp;&nbsp;try {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// Open file
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;in = new BufferedReader(new FileReader(&quot;test.txt&quot;));
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;String str;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// Start reading
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;while ((str = in.readLine()) != null) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// Print the content
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(str);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// Close the stream
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;in.close();
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} catch (IOException e) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;e.printStackTrace();
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;}
}
</pre></pre></p>
<p>With some third party libraries, such as <a href="http://commons.apache.org/io/index.html">Apache Common Io</a>, we can simplify the code to something like this.</p>
<p><pre><pre class="brush: java">
package com.justthor;

import java.io.File;
import java.io.IOException;
import java.util.List;

import org.apache.commons.io.FileUtils;

public class SampleFileReader {

&nbsp;&nbsp;/**
&nbsp;&nbsp; * @param args
&nbsp;&nbsp; */
&nbsp;&nbsp;@SuppressWarnings(&quot;unchecked&quot;)
&nbsp;&nbsp;public static void main(String[] args) {
&nbsp;&nbsp;&nbsp;&nbsp;try {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;List&lt;String&gt; contents = FileUtils.readLines(new File(&quot;test.txt&quot;));
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for ( String content : contents ) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(content);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;} catch (IOException e) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// TODO Auto-generated catch block
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;e.printStackTrace();
&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;}
}
</pre></pre></p>
<p>Well, it does look a bit simple now compare to the previous version. But we only manage to type 1 or 2 lines less than the previous version. This is due to we are force to handle the checked IOException. What if we try to achieve the same thing using Scala?</p>
<p><pre><pre class="brush: scala">
package com.justthor

import scala.io.Source

object SampleFileReader {
 def main(args : Array[String]) = {
&nbsp;&nbsp;Source fromFile(&quot;test.txt&quot;) getLines foreach { println }
 }
}
</pre></pre></p>
<p>Its much simple, right? Scala provides an util for IO named <strong>Source</strong>. This util read the file and get the contents by calling <strong>getLines</strong> method. This <strong>getLines</strong> method returns a <strong>Iterator[String]</strong>. And from there we can process the content by looping the returned iterator. We can use <strong>Source</strong> util to do more than reading files. I will provide more examples in the next few posts.</p>
<p>Happy coding. <img src='http://just-thor.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://just-thor.com/2009/10/01/file-reading-in-java-and-scala/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>PHP communicate with Java using JSON &#8211; Unicode Version</title>
		<link>http://just-thor.com/2009/09/28/php-communicate-with-java-using-json-unicode-version/</link>
		<comments>http://just-thor.com/2009/09/28/php-communicate-with-java-using-json-unicode-version/#comments</comments>
		<pubDate>Mon, 28 Sep 2009 12:30:13 +0000</pubDate>
		<dc:creator>Thor</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://just-thor.com/?p=71</guid>
		<description><![CDATA[JSON is one of the most popular message exchange format nowadays used in web application.Most of the time,we used JSON as a communication message format between Javascript and Server side [...]]]></description>
			<content:encoded><![CDATA[<p>JSON is one of the most popular message exchange format nowadays used in web application.Most of the time,we used JSON as a communication message format between Javascript and Server side language,such as PHP.We can also use it to exchange messages between different languages.</p>
<p>For instance,we want to store a PHP array in database and later to be processed by Java,we can do something like</p>
<p><pre><pre class="brush: php">
$aValue = array(&quot;key1&quot;=&amp;gt;&quot;value1&quot;,&quot;key2&quot;=&amp;gt;&quot;value2&quot;);
$sEncodedValue = json_encode($aValue)
//we will get something like {&quot;key1&quot;:&quot;value1&quot;,&quot;key2&quot;:&quot;value2&quot;}
//and then, we store the value to db
</pre></pre></p>
<p>On the other hand,we use Java  to read it and decode it.</p>
<p><pre><pre class="brush: java">
//read from db and got the resultset,assuming we are using JDBC
while (rs.next()){
String rawValue = rs.getString(&quot;encodedValue&quot;);
// since we encoded an associative array,it will be translated to a Java Map object instance.
// we are using JSON-lib for JSON parsing the following example
JSONObject json = JSONObject.fromObject(jsonString);
Map decodedValue = (Map) JSONObject.toBean(json, Map.class);
String value1 = decodedValue.get(&quot;key1&quot;);
}
</pre></pre></p>
<p>What if we are trying to store unicode value using JSON format in PHP?<br />
For example,</p>
<p><pre><pre class="brush: php">
$aValue = array(&quot;key1&quot;=&amp;gt;&quot;你好吗&quot;,&quot;key2&quot;=&amp;gt;&quot;value2&quot;);
$sEncodedValue = json_encode($aValue);
//This is what we get after encoded
//{&quot;key1&quot;:&quot;\u4f60\u597d\u5417&quot;,&quot;key2&quot;:&quot;value2&quot;}
</pre></pre></p>
<p>If you decoded it back to Java,key1 value will return &#8220;u4f60u597du5417&#8243; instead.This is so wrong.</p>
<p>How to solve it?<br />
We can use <b>mb_convert_encoding</b> function in PHP.<br />
Let&#8217;s make some changes to our code.</p>
<p><pre><pre class="brush: php">
$aValue = array(&quot;key1&quot;=&amp;gt;mb_convert_encoding(&quot;你好吗&quot;, &quot;UTF-8&quot;),&quot;key2&quot;=&amp;gt;&quot;value2&quot;);
$sEncodedValue = json_encode($aValue);
</pre></pre></p>
<p>By doing so,values are stored in database in unicode format,and you can decode it back in Java.</p>
<p>Happy coding. <img src='http://just-thor.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://just-thor.com/2009/09/28/php-communicate-with-java-using-json-unicode-version/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Scala And JDBC</title>
		<link>http://just-thor.com/2009/09/27/scala-and-jdbc/</link>
		<comments>http://just-thor.com/2009/09/27/scala-and-jdbc/#comments</comments>
		<pubDate>Sun, 27 Sep 2009 10:00:24 +0000</pubDate>
		<dc:creator>Thor</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Scala]]></category>

		<guid isPermaLink="false">http://just-thor.com/?p=68</guid>
		<description><![CDATA[I was writing some small programs yesterday trying to read data from one database and input to another database.Hence,I tried to use Scala to do that.I&#8217;ve never write scala to [...]]]></description>
			<content:encoded><![CDATA[<p>I was writing some small programs yesterday trying to read data from one database and input to another database.Hence,I tried to use Scala to do that.I&#8217;ve never write scala to connect to a database using JDBC before,but I am quite surprise with the simplicity of the code.It merely took me 10 minutes to finish writing the code.</p>
<p>Here&#8217;s the code<br />
<pre><pre class="brush: scala">
// Import JDBC package from standard Java SDK
import java.sql.{Connection, DriverManager, ResultSet};

class DataReader {
&nbsp;&nbsp;// Load the driver
&nbsp;&nbsp;Class.forName(&quot;com.mysql.jdbc.Driver&quot;).newInstance;

&nbsp;&nbsp;val connection = DriverManager getConnection &quot;jdbc:mysql://localhost:3306/mail?user=root&amp;amp;password=&amp;amp;characterEncoding=UTF8&quot;

&nbsp;&nbsp;def startReadingData(){
&nbsp;&nbsp;&nbsp;&nbsp;try{

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// Create statement for readonly
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;val statement = conn createStatement (ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY)

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;val rs = statement executeQuery &quot;select * from mail_queues order by id&quot;

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// Looping resultset
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;while (rs next) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;println (rs getLong &quot;id&quot;)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;statement close
&nbsp;&nbsp;&nbsp;&nbsp;}catch {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;case e =&amp;gt; e printStackTrace
&nbsp;&nbsp;&nbsp;&nbsp;}finally {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;connection close
&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;}

}
</pre></pre></p>
<p>Ok, you maybe wondering,why are so many dots(.) and parentheses missing?In Scala,when you are invoking one function with no or one parameter, you can omit the dot and parentheses. And Scala doesn&#8217;t have checked exception, which means you can write the above code without enclosed it with try&#8230;catch clause.I included it to make sure the DB connection is properly closed after use.</p>
<p>Happy coding.:)</p>
]]></content:encoded>
			<wfw:commentRss>http://just-thor.com/2009/09/27/scala-and-jdbc/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
