tag:blogger.com,1999:blog-88370114054630351592024-03-06T01:12:40.239+08:00Jabu ni Gandhi ManaluLearn. Contribute.Anonymoushttp://www.blogger.com/profile/15935744013650476808noreply@blogger.comBlogger164125tag:blogger.com,1999:blog-8837011405463035159.post-61049475233975737392012-02-13T15:36:00.002+08:002012-02-13T15:36:25.114+08:00How to configure Tomcat 6.0 Virtual DirectorySuppose a virtual directory http://localhost:8080/<span style="color: blue;">gandhi</span> will be created on Tomcat 6.0, the virtual directory base directory is in<span style="color: purple;"> /home/gandhi/tomcat-home</span>. The steps to create the virtual directory are as follows:<br />
<br />
<ol>
<li>Create a file named <span style="color: blue;">gandhi</span><b>.xml</b> in $CATALINA_HOME/conf/Catalina/localhost/</li>
<li>Type the following configuration:<br /><context #0000ff"="" path="/<font color=">gandhi" docBase="<span style="color: purple;">/home/gandhi/tomcat-home</span>" debug="0" privileged="true"></context></li>
</ol>
Now restart the tomcat, and the virtual directory will be up and running.<br />
<br />
-gandhiAnonymoushttp://www.blogger.com/profile/15935744013650476808noreply@blogger.com0tag:blogger.com,1999:blog-8837011405463035159.post-22739980951549822812012-02-03T17:39:00.000+08:002012-02-03T17:39:39.708+08:00Runtime.getRuntime().exec with Output Redirection<div style="text-align: justify;">
Runtime.getRuntime().exec is a method used in Java to execute internal command of the operating system. The use of the method is quite straightforward, for example the code to display a content of a current directory (the "ls" command) is shown as follow:</div>
<br />
<pre style="background-image: URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjiacWZZrqO2JyHI-FZWQK4Lz5mZqcmhogsu9WiGaQ5z2nczui41ue2uPWQrYRSMePiHDIkO0METSUhnpyia-1mu4AfZd16Hea59oTLfMh4cuT-nkDcr6xHUFAKIt7ymKhAPQJ19a_G4Qal/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;">1: import java.io.*;
2: public class TestExec {
3: public static void main(String[] args) {
4: try {
5: Process p = Runtime.getRuntime().exec("ls");
6: BufferedReader in = new BufferedReader(
7: new InputStreamReader(p.getInputStream()));
8: String line = null;
9: while ((line = in.readLine()) != null) {
10: System.out.println(line);
11: }
12: } catch (IOException e) {
13: e.printStackTrace();
14: }
15: }
16: }
</code></pre>
<br />
However, the above code will not works to execute more "complex" command, for example when piping or output redirection is involved. For example, the command "cat * > total" will not be executed. Therefore, for the piping or output redirection command to be involved, the above code will be changed as follow:<br />
<br />
<pre style="background-image: URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjiacWZZrqO2JyHI-FZWQK4Lz5mZqcmhogsu9WiGaQ5z2nczui41ue2uPWQrYRSMePiHDIkO0METSUhnpyia-1mu4AfZd16Hea59oTLfMh4cuT-nkDcr6xHUFAKIt7ymKhAPQJ19a_G4Qal/s320/codebg.gif); background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;"><code style="color: black; word-wrap: normal;">1: import java.io.*;
2: public class TestExec {
3: public static void main(String[] args) {
4: try {
5: String[] complexCommand = {"/bin/bash", "-c", "cat * > total"};
6: Process p = Runtime.getRuntime().exec(complexCommand);
7: BufferedReader in = new BufferedReader(
8: new InputStreamReader(p.getInputStream()));
9: String line = null;
10: while ((line = in.readLine()) != null) {
11: System.out.println(line);
12: }
13: } catch (IOException e) {
14: e.printStackTrace();
15: }
16: }
17: }
</code></pre>
<br />
I hope this piece of code could be useful for you :)<br />
<br />
-gandhiAnonymoushttp://www.blogger.com/profile/15935744013650476808noreply@blogger.com0tag:blogger.com,1999:blog-8837011405463035159.post-72223760326567172852012-02-02T11:01:00.002+08:002012-02-02T11:03:03.621+08:00How to Sort HashMap by Values in Java<div style="text-align: justify;">
Recently I had a task that requires me to work with HashMap. One of the task is to sort the content of a HashMap by its values. I use a HashMap to store a user-defined Object. Therefore, I need to make the user-defined Object "sortable" by implementing Comparable interface first. In this example, the user-defined object is Summary.</div>
<br />
This is how I sort a HashMap:<br />
<br />
<string, summary=""><string, summary=""><string, summary=""></string,></string,></string,><br />
public HashMap<string, summary=""> sortSummary(HashMap<string, summary=""> listOfSummary</string,></string,>) {<br />
HashMap<string, summary=""> sortedListOfSummary = new LinkedHashMap<string, summary="">();</string,></string,><br />
<br />
ArrayList keys = new ArrayList();<br />
keys.addAll(listOfSummary.values());<br />
Collections.sort(keys, Collections.reverseOrder());<br />
int size = keys.size();<br />
for (int i = 0; i < size; i++) {<br />
Summary summary = (Summary) keys.get(i);<br />
sortedListOfSummary.put(summary.getUrl(), summary);<br />
}<br />
<br />
return sortedListOfSummary;<br />
}<br />
<br />
<div style="text-align: justify;">
I've seen several codes in the Internet that use TreeMap to sort a HashMap, so this code could be another alternative in dealing with such kind of task.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
PS: I don't know how to format my code in Blogger. If anyone now how to do it, please let me know.</div>Anonymoushttp://www.blogger.com/profile/15935744013650476808noreply@blogger.com0tag:blogger.com,1999:blog-8837011405463035159.post-28079938469664304192012-01-18T12:54:00.000+08:002012-01-18T12:54:19.180+08:00How to Extract .DZ Files<div style="text-align: justify;">
DZ extension is not a very popular file extension, it's usually used to compress a dictionary file (hence the name, Dictionary Zip).</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Today I got one file of this type and wondered how to extract the dictionary inside. Default file extractor on my Ubuntu machine could recognize the content of the file, but apparently it failed to extract the dictionary. After a moment of googling, I found a way on how to extract a file from a DZ file:</div>
<div style="text-align: justify;">
<br /></div>
<blockquote class="tr_bq" style="text-align: justify;">
<b>dictzip –decompress dictionary.dict.dz</b></blockquote>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
And the dictionary inside the DZ will be extracted without leaving the original DZ file.</div>Anonymoushttp://www.blogger.com/profile/15935744013650476808noreply@blogger.com0tag:blogger.com,1999:blog-8837011405463035159.post-88353171888391353432010-04-25T20:40:00.001+08:002010-04-25T20:40:06.503+08:00Taiwan Top Universities 2009<p align="justify">There’re are lots of ranking methodology and results on the Internet. But the list of Taiwan Top Universities I wrote here will be based on <a href="http://www.topuniversities.com/" target="_blank">QS Top Universities</a>. You can read their university ranking on their website. I’ll list 3-6 top Taiwan Universities grouped by various categories. The Taiwan universities will be ordered based on their ranking on each categories. <font color="#ffffff">This post is written by Gandhi Manalu [http://gandhim.wordpress.com].</font></p> <ol> <li> <p><strong>World University Rankings:</strong></p> </li> <ol> <li> <p><a href="http://www.ntu.edu.tw/engv4/" target="_blank">National Taiwan University – NTU</a> (95)</p> </li> <li> <p><a href="http://www.nthu.edu.tw/english/index.php" target="_blank">National TSING HUA University</a> (223)</p> </li> <li> <p><a href="http://english.web.ncku.edu.tw/bin/home.php" target="_blank">National CHENG KUNG University</a> (281)</p> </li> <li> <p><a href="http://nymu-e.web.ym.edu.tw/front/bin/home.phtml" target="_blank">National YANG MING University</a> (306)</p> </li> <li> <p><a href="http://www-e.ntust.edu.tw/front/bin/home.phtml" target="_blank">National Taiwan University of Science And Technology – NTUST</a> (351)</p> </li> </ol> <li> <p><strong>World University Rankings – Natural Sciences:</strong></p> </li> <ol> <li> <p><a href="http://www.ntu.edu.tw/engv4/" target="_blank">National Taiwan University – NTU</a> (51)</p> </li> <li> <p><a href="http://www.nthu.edu.tw/english/index.php" target="_blank">National TSING HUA University</a> (150)</p> </li> <li> <p><a href="http://www-e.ntust.edu.tw/front/bin/home.phtml" target="_blank">National Taiwan University of Science And Technology – NTUST</a> (254)</p> </li> </ol> <li> <p><strong>World University</strong> <strong>Rankings – Engineering/Technology:</strong></p> </li> <ol> <li> <p><a href="http://www.ntu.edu.tw/engv4/" target="_blank">National Taiwan University – NTU</a> (47)</p> </li> <li> <p><a href="http://www.nthu.edu.tw/english/index.php" target="_blank">National TSING HUA University</a> (84)</p> </li> <li> <p><a href="http://www-e.ntust.edu.tw/front/bin/home.phtml" target="_blank">National Taiwan University of Science And Technology – NTUST</a> (143)</p> </li> <li> <p><a href="http://english.web.ncku.edu.tw/bin/home.php" target="_blank">National CHENG KUNG University</a> (160)</p> </li> <li> <p><a href="http://www.nctu.edu.tw/english/index.php" target="_blank">National CHIAO TUNG University</a> (166)</p> </li> </ol> <li> <p><strong>Asian University Rankings:</strong></p> </li> <ol> <li> <p><a href="http://www.ntu.edu.tw/engv4/" target="_blank">National Taiwan University – NTU</a> (22)</p> </li> <li> <p><a href="http://www.nthu.edu.tw/english/index.php" target="_blank">National TSING HUA University</a> (40)</p> </li> <li> <p><a href="http://english.web.ncku.edu.tw/bin/home.php" target="_blank">National CHENG KUNG University</a> (43)</p> </li> <li> <p><a href="http://nymu-e.web.ym.edu.tw/front/bin/home.phtml" target="_blank">National YANG MING University</a> (47)</p> </li> <li> <p><a href="http://www.oia.nsysu.edu.tw/english/index.php" target="_blank">National SUN YAT-SEN University</a> (71)</p> </li> <li> <p><a href="http://www-e.ntust.edu.tw/front/bin/home.phtml" target="_blank">National Taiwan University of Science And Technology – NTUST</a> (72)</p> </li> </ol> <li> <p><strong>Asian University Rankings – Life Sciences & Biomedicine Subject:</strong></p> </li> <ol> <li> <p><a href="http://www.ntu.edu.tw/engv4/" target="_blank">National Taiwan University – NTU</a> (10)</p> </li> <li> <p><a href="http://www-e.ntust.edu.tw/front/bin/home.phtml" target="_blank">National Taiwan University of Science And Technology – NTUST</a> (42)</p> </li> <li> <p><a href="http://www.oia.nsysu.edu.tw/english/index.php" target="_blank">National SUN YAT-SEN University</a> (66)</p> </li> <li> <p><a href="http://www.nthu.edu.tw/english/index.php" target="_blank">National TSING HUA University</a> (67)</p> </li> <li> <p><a href="http://www.ncu.edu.tw/?hl=en" target="_blank">National Central University</a> (69)</p> </li> </ol> <li> <p><strong>Asian University Rankings – Natural Sciences:</strong></p> </li> <ol> <li> <p><a href="http://www.ntu.edu.tw/engv4/" target="_blank">National Taiwan University – NTU</a> (10)</p> </li> <li> <p><a href="http://www.nthu.edu.tw/english/index.php" target="_blank">National TSING HUA University</a> (33)</p> </li> <li> <p><a href="http://www-e.ntust.edu.tw/front/bin/home.phtml" target="_blank">National Taiwan University of Science And Technology – NTUST</a> (57)</p> </li> <li> <p><a href="National Central University" target="_blank">National Central University</a> (60)</p> </li> <li> <p><a href="http://english.web.ncku.edu.tw/bin/home.php" target="_blank">National CHENG KUNG University</a> (63)</p> </li> </ol> <li> <p><strong>Asian University Rankings – IT and Engineering:</strong></p> </li> <ol> <li> <p><a href="http://www.ntu.edu.tw/engv4/" target="_blank">National Taiwan University – NTU</a> (16)</p> </li> <li> <p><a href="http://www.nthu.edu.tw/english/index.php" target="_blank">National TSING HUA University</a> (32)</p> </li> <li> <p><a href="http://www-e.ntust.edu.tw/front/bin/home.phtml" target="_blank">National Taiwan University of Science And Technology – NTUST</a> (41)</p> </li> <li> <p><a href="http://english.web.ncku.edu.tw/bin/home.php" target="_blank">National CHENG KUNG University</a> (49)</p> </li> <li> <p><a href="http://www.nctu.edu.tw/english/index.php" target="_blank">National CHIAO TUNG University</a> (52)</p> </li> </ol> </ol> <p>The number in the left is the university ranking in Taiwan on particular category whereas the number in brackets denotes the university ranking in each category.<font color="#ffffff">This post is written by Gandhi Manalu [http://gandhim.wordpress.com].</font></p> Anonymoushttp://www.blogger.com/profile/15935744013650476808noreply@blogger.com0tag:blogger.com,1999:blog-8837011405463035159.post-79329501063711988382010-04-14T21:15:00.001+08:002010-04-14T21:15:32.886+08:00Yahoo Messenger 10 Profile Directory in Vista<p align="justify">My Yahoo Messenger 10 suddenly crashed, I didn’t know the cause, but it might be the side effect of uninstalling several programs from my computer.</p> <p align="justify">I wanted to reinstall Yahoo Messenger 10, but first I need to backup my profile that includes my chat history, so that all my recorded chats could be restored later. Usually, I could find my Yahoo profile directory at Program Files installation directory, but I couldn’t find it.</p> <p align="justify">After searching through directories in my computer, I found out that Yahoo Messenger 10 stores its user profile in:</p> <p align="left"><strong>X:\Users\<<font color="#0000ff">windows_username</font>>\AppData\Local\VirtualStore\Program Files\Yahoo!\Messenger\Profiles\<<font color="#0000ff">yahoo_id</font>></strong> <br />(where windows_username is user’s windows id and yahoo_id is user’s yahoo id).</p> <p align="justify">I hope this post will be helpful for those who have the same problems as me.</p> Anonymoushttp://www.blogger.com/profile/15935744013650476808noreply@blogger.com0tag:blogger.com,1999:blog-8837011405463035159.post-73971162375338164382010-04-12T09:35:00.001+08:002012-01-18T14:56:32.378+08:00WD 1T External Hard disk drive<div style="text-align: justify;">
Yesterday, I went to Guang Hua, Taipei, to buy a new hard disk drive. At first, I didn’t plan to go there, but to Nova Computer Store at Taipei Main Station. After visited several stores, I found out that the price is about 3,100 NTD, more expensive than the price my friend told me before.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Then I decided to go to Guang Hua instead. Yup, the price in Guang Hua is much cheaper, almost all stores sell with price about 2,850 NTD, and then I found this one store which sells with price of 2,800 NTD. Without thinking much longer, I decided to buy the hard disk drive at this store.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
</div>
<div style="text-align: justify;">
It is WD 1 Terabyte external hard disk drive. It provides a software for smart backup and storage (it installed a virtual CD drive that stores the software). What’s more assured is that it offers a three-year warranty (well actually I wouldn’t stay at this town that longer, but it’s worth noted).</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
</div>
<div style="text-align: justify;">
</div>
<div style="text-align: justify;">
The actual size of the hard disk drive is 930 GB, and I think it’s quite enough to store all my multimedia files :)</div>Anonymoushttp://www.blogger.com/profile/15935744013650476808noreply@blogger.com1tag:blogger.com,1999:blog-8837011405463035159.post-35951449253764592272010-04-10T23:14:00.002+08:002010-04-11T01:06:18.484+08:00Beef Hotpot at Shida<div style="text-align: justify;">This afternoon, my friends and I went to hotpot restaurant at Shida area, Taipei. It’s not far from our place so we went there using bicycle, and it took only 15 minutes to get there. From the main road of Shida night market, turn left at the 7-11 intersection, just walk a little more and there the restaurant is. I don’t really know the name of the restaurant, but it’s with an ‘8′ written in its name.
</div><div style="text-align: justify;"><div style="text-align: justify;">
There are lots of hotpot choices, but I ordered beef hotpot because I just like beef :) What’s nice about this restaurant is the price is not too expensive, all food is in the range of 100 – 130 NTD. Better yet, you can take as much rice as you want, and also take as much ice cream and cold tea as you like :)
</div>
<a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://gandhim.files.wordpress.com/2010/04/dsc00020.jpg?w=518&h=389"><img style="cursor: pointer; width: 518px; height: 389px;" src="http://gandhim.files.wordpress.com/2010/04/dsc00020.jpg?w=518&h=389" alt="" border="0" /></a>
For the range from 1-10 (where 10 is the most delicious), I give this restaurant a score of 7.0.
</div>Anonymoushttp://www.blogger.com/profile/15935744013650476808noreply@blogger.com0tag:blogger.com,1999:blog-8837011405463035159.post-22530094591250097232010-04-08T18:01:00.001+08:002010-04-11T00:26:23.333+08:00Music for My Soul<p style="text-align: justify;">I usually play particular songs for different states of my mood. Whenever I felt angry, distressful, or disappointed then I’ll play songs from Kenny G. But not all of his songs fits my weary condition. I usually listen for these songs of Kenny G:</p><div style="text-align: justify;"> </div><ul style="text-align: justify;"> <li> The moment </li> <li> Morning </li> <li> Theme from dying young </li> <li> Loving you </li> <li> Forever in love </li> <li> Sentimental </li> <li> Silhouette </li> </ul><div style="text-align: justify;"> </div><p style="text-align: justify;">Whenever I heard those songs my soul becomes calm again. I feel relax. It feels like there’s a calm strength fill my mind. And usually, I gain new power to do cope with my problems and do my activity again. </p><div style="text-align: justify;"> </div><p style="text-align: justify;">But it doesn’t mean that whenever I play those songs it means I’m in a weary condition :)</p>Anonymoushttp://www.blogger.com/profile/15935744013650476808noreply@blogger.com0tag:blogger.com,1999:blog-8837011405463035159.post-38580342212155232852010-04-08T06:40:00.003+08:002010-04-11T00:26:33.756+08:00Steps in dealing with procrastination<div style="text-align: justify;">Procrastination is an evil thing. It comes like a disease, but in a convenient form, yet very disastrous. All of us may have suffered this disease once. Me myself has been dealing with this disease ever since my undergraduate study, and yet it still come tempting me.
I've read several book in dealing with this disease, unfortunately it can only help for several weeks. I think I need to always be reminded about this. Lucky me, I've just found an article about the cure, I'll summarize it here (with my own words):
</div><ol style="text-align: justify;"><li>Try to identify the cause of the procrastination.</li><li>Plan to do your activity on a certain period of time.</li><li>Prepare to do your activity, by preparing things you'll be more motivated on doing the activity.</li><li><span style="color: rgb(255, 0, 0);"><strong>Just do it.</strong></span></li><li>Reward yourself for things well done on time.</li></ol>This article has helped me in motivating myself again against procrastination, and I hope it will help you also.Anonymoushttp://www.blogger.com/profile/15935744013650476808noreply@blogger.com0tag:blogger.com,1999:blog-8837011405463035159.post-50180606327085908782010-04-07T01:15:00.001+08:002010-04-11T00:24:29.645+08:00Pay attention to the detail<p style="text-align: justify;">I've been struggling with an anomaly in my code for several days now. I've tried to rewrite the code, change some more variables, add the number iterations but it doesn't work out. But then after re-read the paper again I realize that the problem lies on the number of intervals length, I used a very small number of intervals where actually it need a little more number of intervals length.</p>How I can miss such information? It's because I thought I've understood the global flow of the algorithm and didn't read small information written at the end of the paragraph. D'oh!
<p style="text-align: justify;">Lesson learned: don't assume you've already understood the program, until you read the whole paper thoroughly and in detail.</p>Anonymoushttp://www.blogger.com/profile/15935744013650476808noreply@blogger.com0tag:blogger.com,1999:blog-8837011405463035159.post-85761875226187947942010-04-05T23:39:00.002+08:002010-04-11T00:26:46.674+08:00Qingming Festival<p style="text-align: justify;">Today is holiday, let me scream first, Horraaaayyy :)</p><div style="text-align: justify;">It is called Qing Ming festival, or usually known as Cheng Beng festival. It's not really a festival in a way like there are parades on the street. No, there are no such thing. In contrary, usually people go back to their hometown and together with their family they go to their ancestors tomb and sweep them, that's why it is also called Tomb Sweeping day.
</div><p style="text-align: justify;">This tradition is quite similar with what my tribe (Batak tribe) has back in Bonapasogit, North Sumatra, Indonesia. Usually, few days before Easter, a family gather in their ancestors' tomb and clean it. I don't know what's the reason behind this tradition, but I think it's a good one to pay respect to our ancestor.</p><div style="text-align: justify;">Could it be that this tradition rooted from the same source? Who knows..</div>Anonymoushttp://www.blogger.com/profile/15935744013650476808noreply@blogger.com0tag:blogger.com,1999:blog-8837011405463035159.post-32234224063912888162010-04-05T23:21:00.002+08:002010-04-11T00:27:02.961+08:00TOP Huayu<p style="text-align: justify;">Last week I decided to take a Test of Proficiency (TOP) Huayu. It's a certification test for Mandarin language organized by <a href="http://www.sc-top.org.tw/" target="_blank">Steering Committee of the Test of Proficiency Huayu</a> (SC-TOP). You can image it as a "TOEFL" test for Mandarin language. I enrolled on the test not only because it's free (at the time, a promotion I guess) but also because I want to measure how my Mandarin language goes. I took a beginner level, and the test was conducted at Technology and Science Institute of Northern Taiwan.</p><div style="text-align: justify;"><a href="http://gandhim.files.wordpress.com/2010/04/dsc00002.jpg"><img class="alignnone size-full wp-image-387" title="TOP Huayu" src="http://gandhim.files.wordpress.com/2010/04/dsc00002.jpg" alt="TOP Huayu" height="389" width="518" /></a>
</div><p style="text-align: justify;">I've downloaded the sample mock test provided at SC-TOP website, and also review book 1 Practical Audio-Visual Chinese. I thought it was all enough. But the test was just not as expected. There are lots of new characters that I've never known before, and the audio voice was just so fast.</p><div style="text-align: justify;">One Japan-born American I met at the test said that the real test is indeed a lot more difficult than the mock test, and he said that there are a special book for the test preparation. Darn! I just knew it at the D-day. I hope I'd knew that several weeks before the test.
</div><p style="text-align: justify;">Well, this is not an excuse, but a lesson. Next time, prepare well, in a way that read books that are specially designed for the test. What I was doing is just like "taking an English conversation class" for facing "TOEFL" test. That was just not right.</p><div style="text-align: justify;">I hope I'll perform better for the next test. Jia you!</div>Anonymoushttp://www.blogger.com/profile/15935744013650476808noreply@blogger.com0tag:blogger.com,1999:blog-8837011405463035159.post-72391984404304993902010-04-04T22:28:00.001+08:002010-04-11T00:27:39.439+08:00Happy Easter 2010<p style="text-align: justify;">It's Easter now, so I'd like to say Happy Easter to all of us. May God bless us. Compare to my <a href="http://gandhim.wordpress.com/2009/04/13/easter-2009-message/" target="_blank">Easter experience last year</a>, today I didn't come late :)
</p><p style="text-align: justify;">Since I didn't got any real Easter egg today, I'll give you another type of "Easter egg" :)</p>To do this, you'll need an Open Office application suite. I'm using version 3.2.0.
<ol style="text-align: justify;"><li>Open a new spreadsheet</li><li>Type "<strong>=game()</strong>" at the cell and press Enter, the cell will display "<strong>say what?</strong>"</li><li>Now type "<strong>=Game("StarWars")</strong>" and press Enter again</li><li>A new window for the game will be opened</li><li>Have fun :)</li></ol>After playing you might feel like playing it again. Well, repeating the same procedure will give you a funny response, the application will say "<strong>oh no, not again!</strong>" :) So you need to close the Open Office application (along with the quick starter at your task bar) and start over again.Anonymoushttp://www.blogger.com/profile/15935744013650476808noreply@blogger.com0tag:blogger.com,1999:blog-8837011405463035159.post-35639470997802255272010-04-04T10:42:00.000+08:002010-04-10T23:56:06.631+08:00Spring is ComingYey, Spring is coming..<br/><br/><a href="http://gandhim.files.wordpress.com/2010/04/dsc00004.jpg"><img class="alignnone size-full wp-image-382" title="Spring" src="http://gandhim.files.wordpress.com/2010/04/dsc00004.jpg" alt="Spring" width="389" height="518" /></a><br/><br/>or not :( (while writing this post the weather is still very cold, not the kind of Spring I imagined).Anonymoushttp://www.blogger.com/profile/15935744013650476808noreply@blogger.com0tag:blogger.com,1999:blog-8837011405463035159.post-73962814384067695612010-04-04T10:36:00.001+08:002010-04-11T00:59:59.888+08:00Particle Swarm Optimization (PSO) Sample Code using Java<p style="text-align: justify;">Yes, I'm still coding and I'm proud of it :)</p>
<p style="text-align: justify;">This post assume that the reader has already known about Particle Swarm Optimization (PSO) method, and hence I wouldn't spare a space to explain about it. But if you'd like to ask the method's component on the code I provide below then I'll be gladly explain it in greater length. <span style="color: rgb(255, 255, 255);">[This post is written by Gandhi Manalu - gandhim.wordpress.com]</span></p>
<p style="text-align: justify;">In this post, I'll describe and provide a sample code of PSO method for solving a very simple function optimization. Let say that the function to be minimized is as follow:</p>
<p style="text-align: justify;"><code>$latex f(x,y) = (2.8125-x+xy^4)^2+(2.25-x+xy^2)^2+(1.5-x+xy)^2$</code></p>
<p style="text-align: justify;">With the following constraints:<code> $latex 1<=x<=4; -1<=y<=1$
</code></p>
<p style="text-align: justify;">In order to solve this problem using PSO, we'll need these classes:</p>
<ul>
<li>Position: to represent Position part of the particle</li>
<li>Velocity: to represent Velocity part of the particle</li>
<li>Particle: the particle itself <span style="color: rgb(255, 255, 255);">[This post is written by Gandhi Manalu - gandhim.wordpress.com]</span></li>
<li>SimplePSO: the main control of the program</li>
<li>PSOConstants: an interface to define parameters used in the PSO</li>
</ul>
Since we're going to solve two-variable function optimization, we'll need to provide two-dimensional position and velocity.
For the Position we have:
<pre class="brush: java">
package org.gandhim.pso;
/**
*
* @author gandhim
*/
public class Position {
private double x;
private double y;
public Position(double x, double y) {
this.x = x;
this.y = y;
}
public double getX() {
return x;
}
public void setX(double x) {
this.x = x;
}
public double getY() {
return y;
}
public void setY(double y) {
this.y = y;
}
}
</pre>
For the Velocity we have:
<pre class="brush: java">
package org.gandhim.pso;
/**
*
* @author gandhim
*/
public class Velocity {
private double x;
private double y;
public Velocity(double x, double y) {
this.x = x;
this.y = y;
}
public double getX() {
return x;
}
public void setX(double x) {
this.x = x;
}
public double getY() {
return y;
}
public void setY(double y) {
this.y = y;
}
}
</pre>
And the Particle is as follow:<span style="color: rgb(255, 255, 255);">[This post is written by Gandhi Manalu - gandhim.wordpress.com]</span>
<pre class="brush: java">
package org.gandhim.pso;
/**
*
* @author gandhim
*/
public class Particle {
private Position location;
private Velocity velocity;
private double fitness;
public double getFitness() {
calculateFitness();
return fitness;
}
public void calculateFitness() {
double x = this.location.getX();
double y = this.location.getY();
fitness = Math.pow((2.8125 - x + x * Math.pow(y, 4)), 2) +
Math.pow((2.25 - x + x * Math.pow(y, 2)), 2) +
Math.pow((1.5 - x + x * y), 2);
}
public Position getLocation() {
return location;
}
public void setLocation(Position location) {
this.location = location;
}
public Velocity getVelocity() {
return velocity;
}
public void setVelocity(Velocity velocity) {
this.velocity = velocity;
}
}
</pre>
Pay attention to the <strong>calculateFitness()</strong> method, it is where we put the function evaluation.
Now, we're ready for the main process of the PSO. In this class, we'll need several methods:
<ul>
<li>initializeSwarm() - to initialize the swarm used in the method</li>
<li>execute() - the main part of the process<span style="color: rgb(255, 255, 255);">[This post is written by Gandhi Manalu - gandhim.wordpress.com]</span></li>
</ul>
Here's the code (partial code):
<pre class="brush: java">
private void initializeSwarm() {
Particle p;
Random generator = new Random();
for (int i = 0; i < SWARM_SIZE; i++) {
p = new Particle();
double posX = generator.nextDouble() * 3.0 + 1.0;
double posY = generator.nextDouble() * 2.0 - 1.0;
p.setLocation(new Position(posX, posY));
double velX = generator.nextDouble() * 2.0 - 1.0;
double velY = generator.nextDouble() * 2.0 - 1.0;
p.setVelocity(new Velocity(velX, velY));
swarm.add(p);
}
}
public void execute() {
Random generator = new Random();
initializeSwarm();
evolutionaryStateEstimation();
int t = 0;
double w;
while (t < MAX_ITERATION) {
// calculate corresponding f(i,t) corresponding to location x(i,t)
calculateAllFitness();
// update pBest
if (t == 0) {
for (int i = 0; i < SWARM_SIZE; i++) {
pBest[i] = fitnessList[i];
pBestLoc.add(swarm.get(i).getLocation());
}
} else {
for (int i = 0; i < SWARM_SIZE; i++) {
if (fitnessList[i] < pBest[i]) {
pBest[i] = fitnessList[i];
pBestLoc.set(i, swarm.get(i).getLocation());
}
}
}
int bestIndex = getBestParticle();
// update gBest
if (t == 0 || fitnessList[bestIndex] < gBest) {
gBest = fitnessList[bestIndex];
gBestLoc = swarm.get(bestIndex).getLocation();
}
w = W_UP - (((double) t) / MAX_ITERATION) * (W_UP - W_LO);
for (int i = 0; i < SWARM_SIZE; i++) {
// update particle Velocity
double r1 = generator.nextDouble();
double r2 = generator.nextDouble();
double lx = swarm.get(i).getLocation().getX();
double ly = swarm.get(i).getLocation().getY();
double vx = swarm.get(i).getVelocity().getX();
double vy = swarm.get(i).getVelocity().getY();
double pBestX = pBestLoc.get(i).getX();
double pBestY = pBestLoc.get(i).getY();
double gBestX = gBestLoc.getX();
double gBestY = gBestLoc.getY();
double newVelX = (w * vx) + (r1 * C1) * (pBestX - lx) + (r2 * C2) * (gBestX - lx);
double newVelY = (w * vy) + (r1 * C1) * (pBestY - ly) + (r2 * C2) * (gBestY - ly);
swarm.get(i).setVelocity(new Velocity(newVelX, newVelY));
// update particle Location
double newPosX = lx + newVelX;
double newPosY = ly + newVelY;
swarm.get(i).setLocation(new Position(newPosX, newPosY));
}
t++;
}
}
</pre>
And the last is the interface for storing the constants:
<pre class="brush: java">
package org.gandhim.pso;
/**
*
* @author gandhim
*/
public interface PSOConstants {
int SWARM_SIZE = 30;
int DIMENSION = 2;
int MAX_ITERATION = 300;
double C1 = 2.0;
double C2 = 2.0;
double W_UP = 1.0;
double W_LO = 0.0;
}
</pre>
I made the interface just for the sake of flexibility.
A sample of running the program is as follow:
<a href="http://gandhim.files.wordpress.com/2010/04/result.jpg"><img class="alignnone size-full wp-image-378" title="PSO Result" src="http://gandhim.files.wordpress.com/2010/04/result.jpg" alt="PSO Result" height="223" width="496" /></a>
<p style="text-align: justify;">As we can see from the result, the program found the solution of the problem for (x=3.0 and y=0.5). You might have noticed that the program is not optimized yet, for example it could have been stopped when it already found the solution.<span style="color: rgb(255, 255, 255);">[This post is written by Gandhi Manalu - gandhim.wordpress.com]</span></p>
<p style="text-align: justify;">Actually, there are other PSO's components that have not been implemented in this program, for example constraints handling. But since the problem we solved here is a very simple one it doesn't really need the constraint handling.</p>
<p style="text-align: justify;">I hope that this post is useful for you.</p>Anonymoushttp://www.blogger.com/profile/15935744013650476808noreply@blogger.com1tag:blogger.com,1999:blog-8837011405463035159.post-90625878383531305602010-04-04T01:12:00.001+08:002010-04-11T00:32:37.940+08:00New Year's Resolution: Current State<p style="text-align: justify;">I don't know why, but it just came into my mind about nine (yes, it's nine!) new year's resolutions that I made on the very first day of this 2010 year.</p>I'm trying to count how many of them have been realized or at least being attempted. Well, though the progress is not aggressive I'm happy to say that all of them are being proceed. Some is 50% done, the other is still 30% done, but at least they're all started to improve day by day (well at least week by week). I don't want to make a speculation, or even planning an "alternative" resolution in case of some of my resolution are not able to be achieved (on time). All of them are important, so they're all have to be achieved. Though I still have 8 more months to go, I realize I couldn't waste my time again.
<p style="text-align: justify;">So I have to focus to speed up the progress. Stop at doing unproductive activities. Eliminate procrastination spirit. And just do it!</p>Anonymoushttp://www.blogger.com/profile/15935744013650476808noreply@blogger.com0tag:blogger.com,1999:blog-8837011405463035159.post-75579910552634861062010-04-04T00:58:00.000+08:002010-04-10T23:56:06.604+08:00Prof. Kaoru Hirota's Visit<a href="http://gandhim.files.wordpress.com/2010/04/dsc000871.jpg"><img class="alignnone size-full wp-image-365" title="Prof. Kaoru Hirota" src="http://gandhim.files.wordpress.com/2010/04/dsc000871.jpg" alt="Prof. Kaoru Hirota" width="720" height="539" /></a><br/><p style="text-align:justify;">Several weeks ago, <a href="http://www.hrt.dis.titech.ac.jp/hirota/hirota_en.htm" target="_blank">Prof. Kaoru Hirota</a> from the <a href="http://www.hrt.dis.titech.ac.jp/en/index.html" target="_blank">HIROTA LAB, Titech</a>, visit our lab. His lab's research topics are interesting. I hope to go there sometimes in the future. Hopefully :)</p>Anonymoushttp://www.blogger.com/profile/15935744013650476808noreply@blogger.com0tag:blogger.com,1999:blog-8837011405463035159.post-54867965464542158132010-04-04T00:32:00.001+08:002010-04-11T00:34:27.445+08:00Free Pop Yahoo Mail<p style="text-align: justify;">Actually this trick is a very old one, but it still works until now, and I've been using it for quite some time now. It just came to my mind to share it with those who haven't known about this yet.</p>Yes, it's true. You can easily pop your yahoo mails into your desktop based email client like Thunderbird or Windows Live Mail. You just need to change your time zone setting. Don't worry, your email address will be stay the same (endings with @yahoo.com, it won't change into @yahoo.co.id whatsoever). I didn't have much time to provide the visual steps, but I guarantee that the textual steps is comprehensive enough for you to follow.
<p style="text-align: justify;">Here are the steps: <span style="color: rgb(255, 255, 255);">[These steps provided by Gandhi Manalu - gandhim.wordpress.com]</span></p><ol style="text-align: justify;"><li>Open your web based Yahoo Mail (I use the All-New version).</li><li>At the right hand side of the window there is an Options menu, click on it and choose "More options...".</li><li>At the left hand pane you can see several menus, chose Accounts.</li><li>At the right hand pane click "Add or edit an account". A new window will be opened to add or edit an account.</li><li>Just choose the default one (the one titled Yahoo! Mail) and click Edit button.<span style="color: rgb(255, 255, 255);">[These steps provided by Gandhi Manalu - gandhim.wordpress.com]</span></li><li>Now you have several options at the left side, choose "Account Information".</li><li>You'll be asked to enter your account information (password) again. Just enter it and press "Sign In".</li><li>Scroll down to "Account Settings" box, you'll find "Set language, site, and time zone" menu, just click it.</li><li>In the new setting, just choose Yahoo! Asia.</li><li>Press finished. Now, your time zone will be Yahoo! Asia. Don't worry, it won't change your time zone, you can adjust it under the time zone drop box. <span style="color: rgb(255, 255, 255);">[These steps provided by Gandhi Manalu]</span></li><li>Now go back to window opened at step 3. You'll find "POP & Forwarding" menu there. Click it.</li><li>At the right side pane choose "Set up or edit POP & Forwarding". A new window will be opened.</li><li>Choose "Web & POP Access" to enable POP Access and don't forget to press the "Save" button at the left bottom side of the window.</li><li>Now, you can pop your Yahoo email freely into your desktop based email client application.</li></ol><p style="text-align: justify;">Depends on your email client application, you can setup a new Yahoo email account. Use this setting while configuring your email client: <span style="color: rgb(255, 255, 255);">[These steps provided by Gandhi Manalu - gandhim.wordpress.com]</span></p><ul style="text-align: justify;"><li>Incoming mail (POP 3): pop.mail.yahoo.com. Port number: 995.</li><li>Outgoing mail (SMTP): smtp.mail.yahoo.com. Port number: 465.</li></ul><p style="text-align: justify;">And you're ready popping your Yahoo email, freely! Have fun.</p><p style="text-align: justify;"></p>Anonymoushttp://www.blogger.com/profile/15935744013650476808noreply@blogger.com1tag:blogger.com,1999:blog-8837011405463035159.post-59488951292118012252009-12-28T06:47:00.001+08:002010-04-11T00:35:39.397+08:00Choice<p style="text-align: justify;">This post is about Sunday morning service I attended at the Grace Baptist Church at Taipei on December 27, 2009. The sermon was taken from Galatians 6:7-10 and preached by pastor Jim West.</p><p style="text-align: justify;"><em>7Do not be deceived: God cannot be mocked. A man reaps what he sows. 8The one who sows to please his sinful nature, from that nature will reap destruction; the one who sows to please the Spirit, from the Spirit will reap eternal life. 9Let us not become weary in doing good, for at the proper time we will reap a harvest if we do not give up. 10Therefore, as we have opportunity, let us do good to all people, especially to those who belong to the family of believers.</em></p><p style="text-align: justify;">Here's what I got:</p><ol style="text-align: justify;"><li>You can kid yourself about your choice of seed.
<ol><li>Gal 6:7a, Do not deceive yourselves.</li> <li>Matt 18:12-13, The process of wandering from truth is one move at a time, so you'll never aware of it. Be careful!</li> <li>Matt 22:29, You are in error because you do not know the scriptures or the power of God.</li></ol></li> <li>You can't kid God about your choice of seed.
<ol><li>No one makes fool of God.</li> <li>God can't be mocked.</li> <li>We must not even try to ridicule God.</li></ol></li> <li>You be careful about your choice of seed.
<ol><li>The harvest we gather is a direct result of the seeds we sow.</li></ol></li> <li>You never have a choice about what you harvest.</li></ol><p style="text-align: justify;"><strong>The law of harvest</strong>: If we sow good seed, we will reap good harvest.</p><p style="text-align: justify;"><strong>The law of the ratio of harvest</strong>: if we sow a little we harvest a little, if we sow many we harvest many.</p><p style="text-align: justify;"><strong>Summed up in a sentence</strong>: Every person harvests a crop, in due time, that corresponds to the seed he or she planted.</p><p style="text-align: justify;"><strong>Probing question</strong>: What will be the crop that I will harvest?</p><p style="text-align: justify;">Download full audio recording <a href="http://cid-38002db6f9815e62.skydrive.live.com/self.aspx/Sunday%20Service/20091227-GBC-SundayService.amr">here</a>.</p>Anonymoushttp://www.blogger.com/profile/15935744013650476808noreply@blogger.com0tag:blogger.com,1999:blog-8837011405463035159.post-20485457709116223472009-12-02T07:52:00.001+08:002010-04-11T00:35:48.379+08:00Blogging again...<p style="text-align: justify;">Finally, I decided to start blogging again.. No special reason for this decision, actually I've been thinking about this for several months, but I just wanted to wait for the right moment. And this is it, the beginning of the end. This is the beginning of December, the last month, the end of 2009.</p><p style="text-align: justify;">I can't guarantee (as always) that I'll write regularly, since there are lots of things to do in my daily activities. But I'll try for at least one post per week.</p><p style="text-align: justify;">So, welcome back, and enjoy this blog again :)</p><p style="text-align: justify;">Cold Town, 1st December 2009</p>Anonymoushttp://www.blogger.com/profile/15935744013650476808noreply@blogger.com0tag:blogger.com,1999:blog-8837011405463035159.post-81772644081812572482009-07-14T22:51:00.000+08:002010-04-10T23:56:06.370+08:00MicroworkersSalah satu alternatif mengumpulkan receh di Internet. Silahkan <a href="http://microworkers.com/?Id=a2ee0f4a">daftar</a>.Anonymoushttp://www.blogger.com/profile/15935744013650476808noreply@blogger.com0tag:blogger.com,1999:blog-8837011405463035159.post-18685814012453326322009-07-10T00:32:00.000+08:002010-04-10T23:56:06.357+08:00Lehon Ma Dalan Mi Tu AhuIntro: F Bb Eb Bb F Bb<br/><br/>Bb F Gm<br/>Tu dia luluanhu ho<br/>Eb Dm Cm<br/>Dame na sumurung i<br/>F Bb Eb Bb<br/><br/>Tung mansai loja Loja situtu<br/>Eb F Eb F<br/>sai sungkun sungkun di bagas rohangkon<br/><br/>Bb F Gm<br/>Tu dia sungkunon hu ho<br/>Eb Dm Cm<br/>Paboa hatorangan i<br/>F Bb Eb Bb<br/>Songon torang ni mataniari i<br/>Eb F Eb F Bb F<br/>Na manondangi i Marsada-sada hami be<br/><br/>Reff:<br/>Bb Eb Bb<br/>Sai ganup ari sai martangiang ahu<br/>C F<br/>Anggiat boi dibege ho tangianghon<br/>Bb Eb Bb Eb<br/>Sai ganup ari sungkun-sungkun do ahu<br/>Bb F Bb<br/>Anggiat songgop ho nian di tondinghon<br/><br/>Bb F Gm<br/>Sipata marnipi ahu<br/>Eb Dm Cm<br/>Ro suru-suruan i<br/>F Bb Eb Bb<br/>Mangahusiphon i Dame portibion<br/>Eb F Eb F Bb F<br/>Ihuthun ahu Ima soara ni ho Tuhan<br/><br/>Back to: ReffAnonymoushttp://www.blogger.com/profile/15935744013650476808noreply@blogger.com0tag:blogger.com,1999:blog-8837011405463035159.post-42214718051230114902009-04-24T00:43:00.000+08:002010-04-10T23:56:06.174+08:00Test Post from LiveWriter<p>Just a test… :)</p>Anonymoushttp://www.blogger.com/profile/15935744013650476808noreply@blogger.com1tag:blogger.com,1999:blog-8837011405463035159.post-17429493786214748632009-04-14T01:03:00.001+08:002010-04-11T00:36:44.502+08:00Easter 2009 Message<p style="text-align: justify;">Yesterday, I went to Grace Baptist Church for Sunday sermon. It was a special sermon, because it was an Easter Celebration. Unfortunately, I came late because I thought the sermon will be started as usual, but apparently the sermon was started one hour earlier.</p><p style="text-align: justify;">Fortunately (yeah, I always try to find good thing from a less fortunate thing ;p), I arrived in time the priest was giving the message. One lessons that I remembered from that sermon was "It has eternal significance, all that we do for Christ". This reminded me to always do everything in HIS name, even it's a very small thing, because it'll bring eternal significance.</p><p style="text-align: justify;">Hope that this lesson could be a blessings for all of you.</p>Anonymoushttp://www.blogger.com/profile/15935744013650476808noreply@blogger.com1