tag:blogger.com,1999:blog-10321735072862370522024-03-18T11:03:40.344+08:00glomelurus.com: A Geek's StoryAnything that's happening here.Anonymoushttp://www.blogger.com/profile/16184419777911994138noreply@blogger.comBlogger72125tag:blogger.com,1999:blog-1032173507286237052.post-63537079171883162352016-04-10T19:06:00.001+08:002016-04-10T19:06:44.579+08:00Replacing the Hard Drive of Macbook Pro Mid 2010One of the bad purchase decisions that I ever made was to buy an Apple product without following its release schedule. Just two months after buying the Macbook Pro late 2010, Apple released the Macbook Pro 2011. The reason why it was a big deal is because the 2011's is so much different with its predecessor. One of the huge difference is that the 2011's supports SATA 3.0 while the 2010's only supports SATA 2.0. This means that if you would enjoy the full speed of SSD 6Gb/s when installing an SSD SATA III 6Gb/s, while installing in the 2010's would result in the negotiated speed of 3Gb/s, given that you install the compatible SSD product.<br />
<br />
After searching around in the Google, I finally came to a summarized fact that Macbook Pros before 2011 came with a buggy graphic card - NVidia MCP89 AHCI. Many people reported that they only got the negotiated speed of 1.5 Gb/s (same speed as a SATA drive with 7200 rpm, which makes the SSD upgrade looks like a joke) when they installed an SSD with SandForce controller. Apparently buggy graphic card plus buggy SSD controller means speed cut in half. Many SSDs in fact, use SandForce as the controller, so you would want to be careful in choosing the correct SSD. For example, Crucial BX200 240GB SATA 2.5" 7mm (with 9.5mm adapter) Internal SSD and other variants, are guaranteed to be compatible with MacBook Pro Mid 2010. A lot of people fancy the Samsung SSD 850 EVO, but I just wouldn't risk an incompatible part.<br />
<br />
Replacing the hard drive is very simple, just unscrew the back body of the Macbook Pro, and then locate the hard drive, and unscrew 4 screws that hold the hard drive together (as shown in the picture), pull out the old drive and detach the cable. You might need to use the extension from 7mm to 9.5 mm that came with the SSD if it's a 9mm drive since the slot here is for 9.5mm drive.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://1.bp.blogspot.com/-qmMRXQ_uIQ4/VwouD0-GVhI/AAAAAAAASpQ/9e2Ty1dGow0r_whRS23RxOqU0DqhW3uGQ/s1600/IMG_7272.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://1.bp.blogspot.com/-qmMRXQ_uIQ4/VwouD0-GVhI/AAAAAAAASpQ/9e2Ty1dGow0r_whRS23RxOqU0DqhW3uGQ/s400/IMG_7272.png" /></a></div>
<br />
Regarding the content of the drive (OS and data), I saw 3 options here:<br />
<br />
<ol>
<li>Copy the image of the entire old hard drive to the new hard drive using `dd` and a SATA to SSD cable. If the size of the old hard drive is smaller with new drive, you might need to create drive partitions on the new drive, for example: 128GB for the content of the old drive, and 128GB empty partition. </li>
<li>Use the migration software that usually comes with the SSD, here you would also need a SATA to SSD cable. </li>
<li>Create a Mac OS bootable drive, then install new OS from scratch on the new hard drive. Migrate just the data through an external hard drive. </li>
</ol>
Since I don't own a SATA to SSD cable, so I just did the last option, which is not too bad because a fresh install might speed up the system too.<br />
<br />
<a href="https://support.apple.com/en-us/HT201372">To create a Mac OS bootable drive</a>, prepare an empty pen drive with capacity of more than 8GB that is formatted with (Journaled) HFS+. Then open the App Store and install "OS X El Capitan", which will take a long time because it will download around 6GB of data. Once it's done, open the terminal and run this command:<br />
<pre style="background-color: #fafbfc; border: 1px solid rgb(222, 222, 222); color: #666666; font-size: 16px; margin-top: 1em; overflow: auto; padding: 8px;">/Applications/Install\ OS\ X\ El\ Capitan.app/Contents/Resources/createinstallmedia
</pre>
<div>
<br /></div>
<div>
It is also possible to do an <a href="https://support.apple.com/en-us/HT201314">Internet recovery</a> and directly install Mac OS online without having to create a bootable pen drive.</div>
Momotarohttp://www.blogger.com/profile/01628232941901237433noreply@blogger.com38tag:blogger.com,1999:blog-1032173507286237052.post-39985041051443625132015-07-04T23:49:00.002+08:002016-04-10T19:06:54.604+08:00Replacing the Battery of Macbook Pro Mid 2010My old Macbook Pro that I have been using since Jan 2011 has never had a good battery life since a few years ago. It might be because I have been abusing it with dual boot or I never care to unplug it from the power.<br />
<br />
I wish there is a free app for OS X that could automatically stop the power in some scheduled time so that the battery is always exercised to charge and discharge. I know there is an application that does exactly this sort of thing on Lenovo Thinkpad called ThinkPad Power Management.<br />
<br />
Changing a Macbook Pro's battery is very simple, what you need are only a replacement battery, a plus screwdriver, and a tri-wing screwdriver. First, shut down the MacBook and then unscrew all the screws off the back lid using a plus screwdriver. Lift the lid and don't be surprised with the amount of dust that has accumulated there.<br />
<br />
Next, just unscrew the 2 screws on the battery with a three-wing screwdriver. Then, unplug the socket to disconnect the battery from the laptop, which should be easy if it's picked from the correct angle. Lift the battery and then install a new replacement battery there.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/-t1FdDo48XPg/VZf-2KOjJBI/AAAAAAAAAio/fq6pcAeIhi8/s1600/IMG_7272.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="160" src="https://3.bp.blogspot.com/-t1FdDo48XPg/VZf-2KOjJBI/AAAAAAAAAio/fq6pcAeIhi8/s320/IMG_7272.JPG" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
It takes less than 10 minutes and would save you 2 trips to Apple Care, not to mention the days where the laptop has to stay with them.</div>
<br />Momotarohttp://www.blogger.com/profile/01628232941901237433noreply@blogger.com2tag:blogger.com,1999:blog-1032173507286237052.post-5425209385792322992015-05-31T03:01:00.001+08:002015-09-28T03:20:29.477+08:00ThesisThis<a href="https://github.com/mimitantono/p-swarm" target="_blank"> thesis program</a> is the result of my work from Dec 2014 until around Mar 2015. It is a parallelisation of <a href="https://github.com/torognes/swarm" target="_blank">swarm</a> - an existing single-linkage clustering algorithm for metagenomics data. This program arranges the complete hierarchical clustering workflow into of a set of finely-grained computations (referred as row calculations) that can be run in parallel. The concept of "subseed" was re-used from swarm to skip most of the redundant comparisons (referred as economic search).<br />
<br />
The code for global pairwise alignment and k-mer filtering scheme were also re-used from Swarm since they were proven to be very efficient with the SIMD utilisation.<br />
<br />
Based on the tests that were run on medium sequence length dataset (averagely 381 nucleotides), the speedup that can be achieved through the parallelisation is averagely 11 times when using 16 threads. This result indicates a successful parallelisation technic which according to Amdahl's law it means 97% of the code were able to be parallelised.<br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-OQwvR1Tq0Oo/VWoIm9jKB8I/AAAAAAAAAfw/wMG5VOpKrJI/s1600/economic_search.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="301" src="http://4.bp.blogspot.com/-OQwvR1Tq0Oo/VWoIm9jKB8I/AAAAAAAAAfw/wMG5VOpKrJI/s320/economic_search.png" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
4 level economic search</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/-SuJOi4VUl20/VWoIqml1ZpI/AAAAAAAAAf4/iV5qJgPdHBo/s1600/redundant2cp.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="210" src="http://3.bp.blogspot.com/-SuJOi4VUl20/VWoIqml1ZpI/AAAAAAAAAf4/iV5qJgPdHBo/s320/redundant2cp.png" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
sequence distance triangle inequality</div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<br />
And the full document:<br />
<iframe class="scribd_iframe_embed" data-aspect-ratio="0.7080062794348508" data-auto-height="false" frameborder="0" height="600" id="doc_97940" scrolling="no" src="https://www.scribd.com/embeds/282911056/content?start_page=7&view_mode=scroll&access_key=key-6ckh9ypsQIJPbWDOpbvA&show_recommendations=true" width="100%"></iframe>
<br />
<br />
<br />
<iframe class="scribd_iframe_embed" src="https://www.scribd.com/embeds/282911680/content?start_page=1&view_mode=slideshow&access_key=key-XQj7txGn3VQhs99MnO4d&show_recommendations=true" data-auto-height="true" data-aspect-ratio="1.6021314387211367" scrolling="no" id="doc_12025" width="100%" frameborder="0"></iframe><script type="text/javascript">(function() { var scribd = document.createElement("script"); scribd.type = "text/javascript"; scribd.async = true; scribd.src = "https://www.scribd.com/javascripts/embed_code/inject.js"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(scribd, s); })();</script>Momotarohttp://www.blogger.com/profile/01628232941901237433noreply@blogger.com2tag:blogger.com,1999:blog-1032173507286237052.post-30191115669680716202015-03-27T03:00:00.002+08:002015-07-04T23:50:49.527+08:00Is write to disk faster than write to memory? Don't think soNot long after being featured in <a href="http://www.itworld.com/article/2901453/no-its-not-always-quicker-to-do-things-in-memory.html">IT World</a>, <a href="http://arxiv.org/pdf/1503.02678v1.pdf">this paper</a> went viral in <a href="http://developers.slashdot.org/story/15/03/25/1430251/no-its-not-always-quicker-to-do-things-in-memory">Slashdot</a>.<br />
<br />
Code was written in different language: Java and Python and this paper claimed to prove that "in-memory DOES NOT always work faster than disk operation". I couldn't help but to read the code because it cannot be true.<br />
<br />
First of all, the code is not proving that memory operation is slower than disk operation.<br />
<br />
First part of the code repeatedly concatenate the String object "1" as a single byte using `concatString += addString` which is a proven inefficient way to do it (mentioned in every Java programming book). This is irrelevant with memory operation being slow.<br />
<br />
Second of all, what "Single Write to Disk Time" does is actually not an in-memory operation. This is just the time used to write an object of a very big String (length of 1,000,000) into a file. What will happen is that CPU will fetch buffers of data from RAM and then pass it to the file.<br />
<br />
The part "Write to Disk Time" that is claimed to be faster is the part where "1" is repeatedly written to BufferedWriter for 1,000,000 times. Of course it will be faster because "1" will be stored in CPU cache since it's used for 1 million times and fetching from CPU cache is very fast because the data is already there in the CPU.<br />
<br />
It is not a surprise that reading "1" from CPU cache for 1,000,000 times is faster than reading a String containing 1,000,000 of "1"s from the RAM.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://2.bp.blogspot.com/-1tyDXixUDEA/VRRSRuT-x6I/AAAAAAAAAeo/ERQ4rTQL5bE/s1600/Screen%2BShot%2B2015-03-26%2Bat%2B19.38.28.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="100" src="http://2.bp.blogspot.com/-1tyDXixUDEA/VRRSRuT-x6I/AAAAAAAAAeo/ERQ4rTQL5bE/s1600/Screen%2BShot%2B2015-03-26%2Bat%2B19.38.28.png" width="400" /></a></div>
<br />
So, no, disk operation cannot be faster than memory operation.<br />
<br />
OTOH this could also remind us how important it is to validate any research paper before citing or referring from it.<br />
<br />
<br />Momotarohttp://www.blogger.com/profile/01628232941901237433noreply@blogger.com0tag:blogger.com,1999:blog-1032173507286237052.post-69144783081153921492014-11-28T14:48:00.000+08:002015-06-14T02:10:57.475+08:00Setting up Valgrind on Mac OS YosemiteValgrind is a popular tool for debugging memory leak in C++. By using this tool you will be able to see objects that were forgotten to be freed/deleted, and potential bug from code that Valgrind doesn't like.<br />
<br />
Installing Valgrind on older Mac OS is very simple and can be done from brew. However the most recent Mac OS 10.10 (Yosemite), has not been officially supported by Valgrind. Hence to be able to use this, installation must be done manually from their latest svn trunk which is also very simple.<br />
<br />
<div class="p1">
<span style="font-family: Courier New, Courier, monospace;"><span class="s1">svn</span><span class="s2"> checkout </span><span class="s1">svn</span><span class="s2">://</span><span class="s1">svn</span><span class="s2">.valgrind.org/valgrind/trunk</span></span></div>
<div class="p1">
<span class="s2"><br /></span></div>
<div class="p1">
Followed by going into the directory trunk and:</div>
<div class="p1">
<br /></div>
<div class="p1">
<span style="font-family: Courier New, Courier, monospace;">./autogen.sh</span></div>
<div class="p1">
<span style="font-family: Courier New, Courier, monospace;">make</span></div>
<div class="p1">
<span style="font-family: Courier New, Courier, monospace;">make install</span></div>
<div class="p1">
<br />
While running <span style="font-family: Courier New, Courier, monospace;">autogen.sh</span> one might get an error saying that <span style="font-family: Courier New, Courier, monospace;">aclocal</span> was not found.<br />
<div class="p1">
<span class="s1"><span style="font-family: Courier New, Courier, monospace;">./autogen.sh: line 6: aclocal: command not found</span></span></div>
<span style="font-family: 'Courier New', Courier, monospace;">error: while running 'aclocal'</span><br />
<br />
In this case the <span style="font-family: Courier New, Courier, monospace;">automake</span> needs to be installed prior to running this script. The easiest way to do it is to install from brew, such as:<br />
<br />
<span style="font-family: Courier New, Courier, monospace;">brew install automake</span><br />
<br /></div>
<div class="p1">
To start using valgrind:</div>
<div class="p1">
<br /></div>
<div class="p1">
<span style="font-family: Courier New, Courier, monospace;">valgrind --leak-check=full --show-reachable=yes --log-info=leak.log "[your program and args]"</span></div>
<div class="p1">
<br /></div>
<div class="p1">
For less detailed information and log to stdout:</div>
<div class="p1">
<br /></div>
<div class="p1">
<span style="font-family: Courier New, Courier, monospace;">valgrind --leak-check=yes "[your program and args]"</span></div>
<br />
<br />
<br />Anonymoushttp://www.blogger.com/profile/16184419777911994138noreply@blogger.com2tag:blogger.com,1999:blog-1032173507286237052.post-76730774101726889062014-11-08T06:28:00.003+08:002014-11-28T14:48:35.235+08:00How to Setup GDB in Mac OSThe last time I wrote something in C++ was 10 years ago during the lab session in the university, and recently I just decided to write my thesis project in C++ because of many reasons. First time writing after 10 years wasn't so easy and I got this error message on the screen when running the code:<br />
<blockquote class="tr_bq">
<span style="font-family: Courier New, Courier, monospace;">Segmentation fault: 11</span></blockquote>
<br />
Not so helpful, is it? Meaning some errors relating to pointer happened somewhere in the program.<br />
<br />
In Java (and probably many other modern programming languages too) usually a complete stack trace will be printed at least on the stdout, even if it's the programmer's fault for not catching the exception. Apparently in C to debug something like this there is a tool called GDB that can be easily installed in linux. On Mac it can be installed from brew, followed by a simple step of adding keychain access for gdb.<br />
<br />
So to install:<br />
<br />
<ol>
<li><span style="font-family: Courier New, Courier, monospace;">brew tap homebrow/dupes</span></li>
<li><span style="font-family: Courier New, Courier, monospace;">brew install gdb</span></li>
<li>Open /Applications/Utilities/Keychain Access and <b>create a certificate</b> in <b>"System"</b>. Things to highlight here are (chronologically):</li>
<ul>
<li>Identity type: Self signed root</li>
<li>Certificate type: code signing</li>
<li>Let me override defaults</li>
<li>Store in "System"</li>
</ul>
<li>Get info of the just created certificate and set everything to <b>"Always trust"</b></li>
<li><span style="font-family: Courier New, Courier, monospace;">codesign -s [name of certificate] <name certificate="" of="">$(which gdb)</name></span></li>
</ol>
<div>
Start using GDB:</div>
<div>
<ol>
<li><span style="font-family: Courier New, Courier, monospace;">gdb [name of executable]<name executable="" of=""></name></span></li>
<li><span style="font-family: Courier New, Courier, monospace;">run <type arguments="" here=""></type></span></li>
<ul>
<li><span style="font-family: inherit;">up to this point the program will run and print out line number where the error happened and if need more information use backtrace.</span></li>
</ul>
<li><span style="font-family: Courier New, Courier, monospace;">backtrace </span></li>
<li><span style="font-family: Courier New, Courier, monospace;">help catch exception </span><span style="font-family: inherit;">followed by </span><span style="font-family: Courier New, Courier, monospace;">catch throw</span><span style="font-family: inherit;"> and re-run debug to help catch exceptions that were not caught in code.</span></li>
<li><span style="font-family: Courier New, Courier, monospace;">quit</span></li>
</ol>
<div>
<br /></div>
</div>
Anonymoushttp://www.blogger.com/profile/16184419777911994138noreply@blogger.com0tag:blogger.com,1999:blog-1032173507286237052.post-72796829661158119062013-12-08T09:25:00.001+08:002013-12-08T09:25:40.421+08:00C2 Cubic Piecewise Interpolation with Different Parameterization Methods<div class="separator" style="clear: both; text-align: left;">
On the previous geometric modelling class assignment, we were given some points in dimension 2, and then asked to implement a C2 cubic interpolation with 3 different parameterization methods.</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgh93RBGtJaUJxSQ9jm_PWV620v-freD92MUfwXeYiZC7gYcQeJKN9de8HqAr6dympJG3RXaTDT86gmaIfiXx9F-58DyAf-zpjPP1Gq3wDvoSXWJgj2bmxJHjEGexdiYaKPKt_FuFXxyMxd/s1600/x1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="241" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgh93RBGtJaUJxSQ9jm_PWV620v-freD92MUfwXeYiZC7gYcQeJKN9de8HqAr6dympJG3RXaTDT86gmaIfiXx9F-58DyAf-zpjPP1Gq3wDvoSXWJgj2bmxJHjEGexdiYaKPKt_FuFXxyMxd/s400/x1.png" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
Here I will try to explain briefly everything related to the image above as much as I can in layman terms. </div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<h4>
Interpolation</h4>
<div>
Remember in junior high when mathematics was very basic, where we were given 2 points $(x_1, y_1); (x_2,y_2)$ and then we were asked to find a line passing these points? This is what interpolation means. Only that we would want a spline instead of a line, which means that it will involve polynomial equations. A line $f(x)=ax+b$ itself is a degree one polynomial.</div>
<div>
<br /></div>
<h4>
Piecewise</h4>
<div>
Piecewise means that we want the interpolation to be done separately by considering only 2 points at one time. And then we connect those pieces into one complete spline.</div>
<div>
<br /></div>
<h4>
C2 Continuity</h4>
<div>
Above we also see the terms C2 cubic interpolation. What C2 means is that we want the spline segments to be connected in the way such that their second derivative are the same. Here I call a spline between 2 points as a spline segment. </div>
<div>
<br /></div>
<h4>
Cubic</h4>
<div>
For this term we may refer to Bézier curve where it indicates that the curve will have 4 control points. Here is the equation for Bézier representation:</div>
<div>
$p(u)=\sum_{i=0}^n c_i B^n_i(u)$ where $B^n_i(x)=\binom{n}{i}t^n (1-x)^{n-i}$</div>
<div>
<br /></div>
<h4>
Parameterization</h4>
<div>
The image above was drawn using 3 different parameterization methods:</div>
<div>
<ul>
<li>uniform for $\mu=0$</li>
<li>chordal for $\mu=1$</li>
<li>centripetal for $\mu=0.5$</li>
</ul>
</div>
The $\mu$ was used to calculate the length of each parameter in their sequence $t_0,t_1, ..., t_n$ by using $t_{i+1}-t_i=\|x_{i+1}-x_i\|^\mu$<br />
<br />
To make it easier to imagine how these $\mu$ values will affect the shape of the spline, I made up a little story by looking the points as the racing game where the driver were required to pass these points in order to complete the race. Here we have 3 different drivers with different driving style.<br />
<br />
<b><span style="color: red;">Racer #1</span></b> drives with the same speed all the way, this is why he made sharp turn when he has to pass points that are closed to each other. This causes the ^ section which is called as <a href="http://en.wikipedia.org/wiki/Cusp_(singularity)">cusp</a>.<br />
<br />
And then moving on to <b><span style="color: blue;">racer #2</span></b> who adjusts his speed extremely based from time to time by observing how far away the next point is. If the next point is near then he will slow down, otherwise if it is still far away then he will increase speed. This causes the last turn to be a late <a href="http://kentongrayracing.com/racing101.php#Apex">apex</a>.<br />
<blockquote class="tr_bq">
In racing, a driver will often use a "late apex," turning into the corner a little later than normal in order to straighten out the last part of the corner. This allows the driver to accelerate earlier and harder, gaining maximum speed down the next straight.</blockquote>
Lastly <b><span style="color: lime;">racer #3</span></b> is also the type who adjusts speed based on how far away the next point is. But he does not make too much extreme changes of speed along the way. So here we can see that the driving path he made is the one passing those points elegantly.<br />
<br />
The question now is which racers complete the trip the earliest?<br />
They completed it in the same amount of time!Anonymoushttp://www.blogger.com/profile/16184419777911994138noreply@blogger.com0tag:blogger.com,1999:blog-1032173507286237052.post-33316957612665620232013-12-05T02:00:00.001+08:002013-12-05T21:43:31.062+08:00Cubic Spline Interpolation in MatlabThis was a homework in my geometric modeling class. Later I modified it to receive input with mouse click and a button to clear and redraw, and also a drop down to choose parametrization method.<br />
<br />
Take a look at the spiral I made!!<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-cNK-W1LuMWo/Up94ZMeFzbI/AAAAAAAAAT4/BRV9FQxRXi8/s1600/Screen+Shot+2013-12-04+at+7.45.12+pm.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="240" src="http://4.bp.blogspot.com/-cNK-W1LuMWo/Up94ZMeFzbI/AAAAAAAAAT4/BRV9FQxRXi8/s320/Screen+Shot+2013-12-04+at+7.45.12+pm.png" width="320" /></a></div>
<br />
<br />
Bezier representation:<br />
$$<br />
p(t)=\sum_{i=0}^{n} c_i B^n_i(t)<br />
$$<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<br />
<pre class="brush:cpp;">function [ ] = draw( )
figure
hold on; box on;
grid;
uicontrol('Style', 'pushbutton', 'String', 'Try me again!',...
'Position', [20 20 50 20],...
'Callback', @draw_new);
uicontrol('Style', 'popup',...
'String', 'uniform|centripetal|chordal',...
'Position', [20 340 100 50],...
'Callback', @setmethod);
draw_new ('','');
end
function [] = setmethod (hObj,event)
axis([0 10 0 10]);
global PARAMETER;
PARAMETER=get(hObj,'Value');
draw_spline();
end
function[]=draw_spline()
cla;
global XY;
global PARAMETER;
if PARAMETER ==1
interpolate(XY, 0, 'r');
elseif PARAMETER == 2
interpolate(XY, 0.5, 'g');
elseif PARAMETER == 3
interpolate(XY, 1, 'b');
else
interpolate(XY, 0, 'r');
end
end
function [] = draw_new (hObj,event) %#ok<inusd>
global XY;
cla;
axis([0 10 0 10]);
% Initially, the list of points is empty.
XY = [];
n = 0;
% Loop, picking up the points.
disp('Left mouse button picks points.')
disp('Right mouse button picks last point.')
but = 1;
while but == 1
[xi,yi,but] = ginput(1);
plot(xi,yi,'ro')
n = n+1;
XY(:,n) = [xi;yi];
if (length(XY(1,:)) > 1)
draw_spline;
end
end
draw_spline();
end
function [] = interpolate(x, mu, color)
n=length(x);
t=parameterize(x,mu);
h(1:n-1) = t(2:n)-t(1:n-1);
mi=get_cubic_slope(x,t);
for i=1:n-1
a=x(1,i);
b=x(1,i+1);
p(1,:)=x(:,i);
p(2,:)=x(:,i)+(h(i)).*mi(:,i)/3;
p(3,:)=x(:,i+1)-(h(i)).*mi(:,i+1)/3;
p(4,:)=x(:,i+1);
[q_bez] = deCasteljau(0,1,p,linspace(0,1,100));
plot(q_bez(:,1),q_bez(:,2),[color,'-'],'LineWidth',3);
plot(p(:,1),p(:,2),[color,'--o'], 'MarkerSize',3);
end
plot(x(1,:),x(2,:),'ro', 'MarkerSize',5,'MarkerFaceColor','r');
xlabel('x'), ylabel('y'),title(['Cubic Spline Interpolation']);
end
function[m] = get_cubic_slope(x,t)
%cublic spline interpolation
n=length(x);
h(2:n) = t(2:n)-t(1:n-1);
A=zeros(n-1,n-1);
b=zeros(2,n-1);
b(:,1)= 3*((h(1)/h(2)*(x(:,2)-x(:,1))));
for i=1:n-1
A(i,i)=2*(h(i)+h(i+1));
end
for i=2:n-1
b(:,i)=3*((h(i+1)/h(i)*(x(:,i)-x(:,i-1)))+(h(i)/h(i+1)*(x(:,i+1)-x(:,i))));
A(i,i-1)=h(i+1);
A(i-1,i)=h(i);
end
m=A\b';
m=m';
m(:,n)=0;
end
function[m] = get_hermite_slope(x,t)
n=length(x);
%piecewise hermite interpolation
m(:,1)=(x(:,2)-x(:,1))./(t(2)-t(1));
m(:,n)=(x(:,n)-x(:,n-1))./(t(n)-t(n-1));
m(1,2:n-1)=(x(1,3:n)-x(1,1:n-2))./(t(3:n)-t(1:n-2));
m(2,2:n-1)=(x(2,3:n)-x(2,1:n-2))./(t(3:n)-t(1:n-2));
end
function [t] = parameterize(x, mu)
t=zeros(1,length(x));
for i=2:length(x)
t(i)=sqrt((x(1,i) - x(1,i-1))^2 + (x(2,i) - x(2,i-1))^2)^mu + t(i-1);
end
end
function [p_t] = deCasteljau(a,b,p,t)
n = size(p,1);
m = length(t);
p_t = zeros(m,2);
X(:,1) = p(:,1);
Y(:,1) = p(:,2);
for j = 1:m
for i = 2:n
X(i:n,i) = (t(j)-a)/(b-a)*X(i-1:n-1,i-1) + (b-t(j)-a)/(b-a)*X(i:n,i-1);
Y(i:n,i) = (t(j)-a)/(b-a)*Y(i-1:n-1,i-1) + (b-t(j)-a)/(b-a)*Y(i:n,i-1);
end
p_t(j,1) = X(n,n);
p_t(j,2) = Y(n,n);
end
end
</inusd></pre>
Anonymoushttp://www.blogger.com/profile/16184419777911994138noreply@blogger.com0tag:blogger.com,1999:blog-1032173507286237052.post-35172596405344832702013-11-27T07:48:00.004+08:002013-12-05T21:16:04.100+08:00Browsers Add-ons<h2>
WOT</h2>
<div>
<a href="https://www.mywot.com/">WOT</a> gives warning whenever we are about to enter websites with bad reputations, rated by the community. WOT categorises those bad websites as either: scam, phishing, adult content, illegal, Malwares/viruses. </div>
<div>
<br /></div>
<div>
<br /></div>
<h2>
Adblock</h2>
<div>
I totally understand that ads is a way to gain traffic and customers. But I sincerely prefer to not have flashy adult site ads, or promotions that actually requires you to do sacrifice for them before they will give you a piece of cake. So go ahead and install this <a href="https://adblockplus.org/en/chrome">Adblock</a> add-on.</div>
<div>
<br /></div>
<div>
<br /></div>
<h2>
Google Translate</h2>
<div>
This is especially useful for someone who is living in a foreign country. You might be thinking that English is an international language and most websites must have the option for English. This is partially true because some websites are not multi-lingual and even if they do, some of the times it sucks. Here it is: <a href="https://addons.mozilla.org/en-US/firefox/addon/google-translator-for-firefox/">for Firefox</a>, and <a href="https://chrome.google.com/webstore/detail/google-translate/aapbdbdomjkkjkaonfhkkikfgjllcleb?hl=en">for Chrome</a>.</div>
<div>
<br /></div>
<h2>
XPath Helper</h2>
<div>
It might be out of topic, but I found this useful for web application development. <a href="https://chrome.google.com/webstore/detail/xpath-helper/hgimnogjllphhhkhlmebbmlgjoejdpjl?hl=en">XPath Helper</a> also gives a console where we can test Xpath command, and it also displays HTML element inspect and another couple of useful things.</div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<br /></div>
Momotarohttp://www.blogger.com/profile/01628232941901237433noreply@blogger.com0tag:blogger.com,1999:blog-1032173507286237052.post-76387720109598844712013-01-28T20:46:00.001+08:002013-12-05T21:16:18.584+08:00VOIP with Skype from a Local phoneIf you are someone living far from family and being lazy to buy telephone cards, perhaps you are like me too, to end up using Skype for calling home. And then if you think 3G connection is not good enough to make phone call, then perhaps you have already known that Skype offered a VOIP feature.<br />
<br />
So I've just recently tried the 'Call To Go' feature from Skype. Long story short, this feature makes it available to set up our own private VOIP number specified for our favorite contacts. And then to call that person we just need to dial the private VOIP number from a telephone. The VOIP number will appear as a local toll-free number. Other than that as a bonus, you do not have to get online in Skype in order to make a phone call.<br />
<br />
The pro of this method, I don't have to say no more, is that you are going to have a phone call with better and stable quality. And then about the pricing, it has no different with how much if will cost if the call was made through Internet connection via Skype client. Of course to be able to make use of the toll-free, you might need a fixed line telephone. Maybe it is free as well if made from a mobile phone.<br />
<br />
So below are the steps to setup the to-go number.<br />
<br />
<br />
1. Login to Skype, and then under your profile, click Skype To Go.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/-ZhnYtqt5dtA/UQZwyzrZNyI/AAAAAAAAAH4/A37twXh-36U/s1600/My+account+-+Google+Chrome_2013-01-24_14-32-15.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="249" src="http://3.bp.blogspot.com/-ZhnYtqt5dtA/UQZwyzrZNyI/AAAAAAAAAH4/A37twXh-36U/s320/My+account+-+Google+Chrome_2013-01-24_14-32-15.png" width="320" /></a></div>
<br />
2. To set up a new Skype To Go number, click on "Add a contact". If you have not set up any registered phone, at this point Skype will have you register one, which could be either a local phone or a mobile phone.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-G_sb1a1OqDs/UQZwzIdbLyI/AAAAAAAAAH8/pRicr_lq8rc/s1600/Your+Skype+account+overview+-+Google+Chrome_2013-01-24_14-32-50.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="352" src="http://4.bp.blogspot.com/-G_sb1a1OqDs/UQZwzIdbLyI/AAAAAAAAAH8/pRicr_lq8rc/s640/Your+Skype+account+overview+-+Google+Chrome_2013-01-24_14-32-50.png" width="640" /></a></div>
<br />
3. And then, fill in contact's name, country, type, and phone number or Skype ID. On the right side you are going to see a local phone number started with (315). In Singapore, this is a phone number format reserved for VOIP purpose.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://2.bp.blogspot.com/-H5AnH5Epmqk/UQZxwHsrRwI/AAAAAAAAAIc/UZ1offAjyd0/s1600/Your+Skype+account+overview+-+Google+Chrome_2013-01-24_14-32-50.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="352" src="http://2.bp.blogspot.com/-H5AnH5Epmqk/UQZxwHsrRwI/AAAAAAAAAIc/UZ1offAjyd0/s640/Your+Skype+account+overview+-+Google+Chrome_2013-01-24_14-32-50.png" width="640" /></a></div>
<br />
4. You could also set up a PIN number if you wish to protect your Skype balance, especially when you have auto reload being set up.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://2.bp.blogspot.com/-rhP_v6eXubs/UQZwy63uDxI/AAAAAAAAAIA/tpJVKO1C8mc/s1600/Skype+To+Go+-+Google+Chrome_2013-01-24_14-33-46.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://2.bp.blogspot.com/-rhP_v6eXubs/UQZwy63uDxI/AAAAAAAAAIA/tpJVKO1C8mc/s1600/Skype+To+Go+-+Google+Chrome_2013-01-24_14-33-46.png" /></a></div>
<br />
5. To make the phone call by using your Skype credit, directly dial the number specified for the contact, and you phone number where you made the call from, will appear as the Caller ID.<br />
<br />
<br />
*Unfortunately, Skype has not yet support all countries for this feature. Fortunately, Singapore is one of the country that has this feature ready.<br />
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<br />Momotarohttp://www.blogger.com/profile/01628232941901237433noreply@blogger.com0tag:blogger.com,1999:blog-1032173507286237052.post-74536802357360961172012-01-30T22:48:00.002+08:002012-01-30T22:48:32.431+08:00How to Set to Always Open a Similar File with a Preferred Application in Mac OS X<span style="font-size: large;">The Wrong Way to Do This</span><br />
<ol>
<li><span style="font-size: small;">Right click on the file</span></li>
<blockquote class="tr_bq">
<div class="separator" style="clear: both; text-align: center;">
<a href="http://2.bp.blogspot.com/-UHdj6byfyUY/TwxSPR1Um-I/AAAAAAAAAC4/OULzwXVNxEE/s1600/Screen+shot+2012-01-10+at+PM+10.55.24.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="232" src="http://2.bp.blogspot.com/-UHdj6byfyUY/TwxSPR1Um-I/AAAAAAAAAC4/OULzwXVNxEE/s320/Screen+shot+2012-01-10+at+PM+10.55.24.png" width="320" /></a></div>
</blockquote>
<li><span style="font-size: large;"><span style="font-size: small;">Select "Open With", and then select "Other...", choose the application</span></span></li>
<blockquote class="tr_bq">
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-cOrmjZKRDHs/TwxSQP3feSI/AAAAAAAAADA/2Vzm9VrkYbg/s1600/Screen+shot+2012-01-10+at+PM+10.55.48.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="235" src="http://4.bp.blogspot.com/-cOrmjZKRDHs/TwxSQP3feSI/AAAAAAAAADA/2Vzm9VrkYbg/s320/Screen+shot+2012-01-10+at+PM+10.55.48.png" width="320" /></a></div>
</blockquote>
</ol>
<span style="font-size: small;">Doing #1 and #2 will lead to always open <i>rand-anthem.epub</i> with Adobe Digital Editions, instead of setting to always open epub file with Adobe Digital Editions.</span><br />
<br />
<br />
<br />
<span style="font-size: large;">The RightWay to Do This</span><br />
<ol>
<li><span style="font-size: small;">Right click on the file, choose "Get Info"</span></li>
<blockquote class="tr_bq">
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-WTGLCiA3qAU/TwxSQ4r1WLI/AAAAAAAAADI/_04-QJBUDsI/s1600/Screen+shot+2012-01-10+at+PM+10.56.04.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="308" src="http://4.bp.blogspot.com/-WTGLCiA3qAU/TwxSQ4r1WLI/AAAAAAAAADI/_04-QJBUDsI/s320/Screen+shot+2012-01-10+at+PM+10.56.04.png" width="320" /></a></div>
</blockquote>
<li><span style="font-size: small;">A left panel will show up. Select "Open with:" and then check the specified application.</span></li>
<blockquote class="tr_bq">
<div class="separator" style="clear: both; text-align: center;">
<a href="http://2.bp.blogspot.com/-dDzvSdgDvVg/TwxSR-JrtrI/AAAAAAAAADM/OnULwSLbD7Q/s1600/Screen+shot+2012-01-10+at+PM+10.56.28.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="http://2.bp.blogspot.com/-dDzvSdgDvVg/TwxSR-JrtrI/AAAAAAAAADM/OnULwSLbD7Q/s320/Screen+shot+2012-01-10+at+PM+10.56.28.png" width="141" /></a></div>
</blockquote>
<li><span style="font-size: small;">Click on "Change All.."</span></li>
<blockquote class="tr_bq">
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/-9c4aRIsTdo8/TwxSSazBv3I/AAAAAAAAADU/J4YPDGHiquQ/s1600/Screen+shot+2012-01-10+at+PM+10.56.42.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://3.bp.blogspot.com/-9c4aRIsTdo8/TwxSSazBv3I/AAAAAAAAADU/J4YPDGHiquQ/s1600/Screen+shot+2012-01-10+at+PM+10.56.42.png" /></a></div>
</blockquote>
<li><span style="font-size: small;">Click "Continue", and now you have a MAC OS which always open epub file with Adobe Digital Editions.</span></li>
<blockquote class="tr_bq">
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-VlVu4uWYtRY/TwxSTVHQrXI/AAAAAAAAADc/jFAI16QY82Y/s1600/Screen+shot+2012-01-10+at+PM+10.56.50.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="134" src="http://4.bp.blogspot.com/-VlVu4uWYtRY/TwxSTVHQrXI/AAAAAAAAADc/jFAI16QY82Y/s320/Screen+shot+2012-01-10+at+PM+10.56.50.png" width="320" /></a></div>
</blockquote>
</ol>
<span style="font-size: large;">Why a blog post was made to explain this</span><br />
<blockquote class="tr_bq">
Because the way to do this in MAC OS is ridiculously against the common sense. </blockquote>Momotarohttp://www.blogger.com/profile/01628232941901237433noreply@blogger.com0tag:blogger.com,1999:blog-1032173507286237052.post-39453776918349722042011-12-11T11:44:00.201+08:002012-01-09T10:19:12.820+08:00You Are Just One Click Away to Spend Those DollarsIt's been years since the last time working on some shopping related web applications that I forgot the main angle behind the design of those applications is to make it as easy as possible for the customers to spend their money. The idea behind online shopping business is that it's so easy that as long as we have a credit card (or credit card numbers), we can order whatever we want.<br />
<br />
So last time I went to Groupon to purchase a voucher for gift because of the convenience. Prior completing the payment, I was surprised that everything is already filled up. What I have to do to complete the payment is basically just to click the "Submit Order" button. And there is no explanation provided that "after clicking this button, your credit card will be charged". It just happened, my card was charged.<br />
<br />
<div class="separator" style="clear: both; text-align: left;"><a href="http://3.bp.blogspot.com/-hI_KaJCITug/TwcKeIqDT_I/AAAAAAAAACY/KdDsobpu808/s1600/untitled.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://3.bp.blogspot.com/-hI_KaJCITug/TwcKeIqDT_I/AAAAAAAAACY/KdDsobpu808/s1600/untitled.PNG" /></a></div><br />
So convenient, right? Imagine if some day Groupon's database get hacked, what will happen? If really one day all those credit cards numbers were downloaded by someone else and he's using them to shop around, I wonder if Groupon is going to stand up and take the full responsibility to handle customers' claim to VISA to fully refund all the money drained by the hacker. If not, then at this time the customers are going to experience big time inconvenience, provided that they're using a credit card. If they're using debit VISA, then I wonder if Groupon is going to refund those money, because debit card has zero fraud protection and does not provide dispute resolution options.<br />
<br />
The fact is that this kind of thing happens, and when it does, everything is already too late. For example <a href="http://en.kunming.cn/index/content/2011-12/25/content_2789463.htm">this is what it will look like when 6 millions of CSDN's users credentials getting hacked and shared publicly on XunLei (a torrent clone of China)</a>. This event occurred just last month, and I was one of the members of CSDN. What happened is that since then my mail account (that I used to register on the website) has been always full of spams and I have to update every account that is using the same password (because it's a common knowledge that people tend to use the same password for everything).<br />
<br />
Going back to my story about Groupon, I was upset for a few minutes and then daydreaming big time to sue the company. Of course it's not going to happen. They are big, I am just like a fly to them, chances are so small. But I still did some researches and <a href="http://security.stackexchange.com/questions/9570/groupon-sg-is-storing-customers-credit-card-information">asked around about it</a>.<br />
<br />
With the references given by some of StackExchange's member, I figured out that it's indeed illegal to store customer's CVV2 number.<br />
<br />
<a href="http://www.visa-asia.com/ap/sea/merchants/riskmgmt/ais_merchants.shtml#TIP">http://www.visa-asia.com/ap/sea/merchants/riskmgmt/ais_merchants.shtml#TIP</a><br />
<br />
<blockquote class="tr_bq">The merchant must have confirmed that sensitive authentication data (i.e., the full contents of magnetic stripe, CVV2 and PIN data) is not stored, as defined in the PCI DSS.</blockquote><br />
So I wrote an email to VISA's AIS team to complain about that. What they replied is that they're unable to confirm if Groupon is storing customers' sensitive credit card information. The asterisk may not represent the actual CVV2 provided that the credit card information is also masked. If I have any concern about card security, I was supposed to contact the bank who was issuing the card (I assumed that they were trying to say that I may request the bank to just deactivate the card if I was really concerned about it).<br />
<br />
But Amazon, Apple Store and PayPal also provide the same convenience, right? What makes it different between them and Groupon is that they explicitly explained it to us when we're going to enter the number, that it will be for future purchases as well. Groupon does not do that, I might have remembered it wrong, but I'm quite sure that there wasn't any explanation when I made the first purchase a few months before that.<br />
<br />
To support my unreliable memory, additionally here's what we can see on Groupon's FAQ page. It is so beautiful and safe!<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="http://2.bp.blogspot.com/-avHq9OH3RKI/TwcPIE7w2nI/AAAAAAAAACk/yIbvfNIwOAo/s1600/Screen+shot+2012-01-06+at+PM+11.10.48.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="55" src="http://2.bp.blogspot.com/-avHq9OH3RKI/TwcPIE7w2nI/AAAAAAAAACk/yIbvfNIwOAo/s640/Screen+shot+2012-01-06+at+PM+11.10.48.png" width="520" /></a></div><br />
What make it worse is that Groupon is allowing you to connect your Groupon account with your Facebook account. People will commonly be being careless about Facebook account because it's just a social media. So what usually happen is that they will check the "remember me" button to keep their browser logged in to Facebook until there's one of the day when the browser's cookies are being cleaned up. Of course this is related to personal responsibility, but what I see here is that Groupon doesn't really care about their customers' security.<br />
<br />
Maybe I'm just making this small thing such a big deal. But as a customer I never expect and wouldn't be thankful to have this kind of convenience, especially when it's related to the safety of a debit VISA card.Anonymoushttp://www.blogger.com/profile/16184419777911994138noreply@blogger.com0tag:blogger.com,1999:blog-1032173507286237052.post-47541096705806572222011-12-10T07:00:00.000+08:002011-12-10T07:00:01.074+08:00Toyota Commercial - Jean Reno as DoraemonA bit OOT but Doraemon is my childhood favorite cartoon, so here we go, 3 parts, with English translation.<br />
<br />
<iframe allowfullscreen="" frameborder="0" height="315" src="http://www.youtube.com/embed/k3YmwZ0bWeE" width="420"></iframe>
<br />
<br />
<br />
Shizuka: What are we going to be when we're adults?<br />
Suneo: A rich man!<br />
Takeshi: I want to be a singer.<br />
Shizuka: How about Nobita?<br />
Nobita: It seems like I don't have any dream.<br />
Doraemon: What? You don't have any dream at all?<br />
Nobita: I want to go out with Sizhuka with a car!!!!<br />
Takeshi: Nobita want to drive a car.....<br />
Nobita: What are you guys laughing at!! There's nothing wrong with that!!<br />
Takeshi: You're just a Nobita what are you arrogant about!!<br />
[20 years later]<br />
Takeshi: I'm really an idiot ~~~ a big idiot ~~~<br />
[Nobita 30 years old]<br />
Nobita: yeah really an idiot<br />
Takeshi: What did you say?<br />
Nobita: Nnnothing... Thank you for the ride, Takeshi...<br />
Takeshi: Apparently just a Nobita<br />
(Nobi Nobita, 30 years old, still single)<br />
<br />
<br />
<iframe allowfullscreen="" frameborder="0" height="315" src="http://www.youtube.com/embed/ddWaK6Kw_iM" width="420"></iframe>
<br />
<br />
Sizhuka: It's been so long since the last time playing with Nobita
<br />
Nobita: But bad things happen when we go out and play.
<br />
Nobita: We're late ~~~~~~~
<br />
Nobita: We're lost ~~~~~~~
<br />
Nobita: Hot hot ~~~~~ so hot ~~~~~
<br />
Shizuka: Nobita... I still have to attend the violin class ...
<br />
Suneo (coming out of nowhere): Let me give you a ride!
<br />
Shizuka: Suneo, it's Suneo!
<br />
Suneo: Oh? So you don't drive??? Bye bye
<br />
Nobita: Damn it.... I can't let it go... Does it mean that you can do everything when you have a car?
<br />
Nobita: Doraemon!
<br />
Doraemon: Long time no see Nobita.
<br />
Nobita: Give me a car!!
<br />
Doraemon: I won't
<br />
Nobita: Why?
<br />
Doraemon: You don't have a driver license.
<br />
Nobita: Driver license ....
<br />
<br />
<iframe allowfullscreen="" frameborder="0" height="315" src="http://www.youtube.com/embed/AbfQd_WMKW4" width="420"></iframe>
<br />
<br />
Nobita: Oh no!! Suneo is going out with Shizuka again!!
<br />
Nobita: Oh no!! I don't want a future like this!!
<br />
Doraemon: Nobita, I can't give you a car, but...
<br />
Doraemon: Anywhere door!!!!!
<br />
Doraemon: Can go to the beach in a moment.
<br />
Nobita: I've known this a few hundreds years ago.
<br />
Takeshi: What!! An empty can!!
<br />
Nobita: Giant!
<br />
Takeshi: What are you doing!! You think I'm an idiot?
<br />
Doraemon: If you want to hang out with Sizhuka ~ use this ~
<br />
Doraemon: Bamboo flyer!!!
<br />
Nobita: I don't want to rely on tools anymore!! I want to learn driving with my own effort!!
<br />
Nobita: Let's go to the showroom first! Bring out the anywhere door!
<br />
Doraemon: But you said you don't want to rely on tools ...
<br />
Nobita: Don't be mean..
<br />
Nobita: uuuuuuuuuuuuuu....Anonymoushttp://www.blogger.com/profile/16184419777911994138noreply@blogger.com1tag:blogger.com,1999:blog-1032173507286237052.post-88732298662257497762011-10-01T19:24:00.002+08:002011-10-01T19:31:31.744+08:00Book Review: Your Money - The Missing ManualsRight after reading the first chapter of <a href="http://www.amazon.com/gp/product/0596809409/ref=as_li_tf_tl?ie=UTF8&tag=glomelurus-20&linkCode=as2&camp=217145&creative=399377&creativeASIN=0596809409">Your Money: The Missing Manual</a>, you might think that it mainly and only talks about frugality. You are right, it's all about frugality. But there's actually much more inside of it. I like how the author explains about the relationship between money and us. And also the way he tells things by using himself as an example.<br />
<br />
I actually skipped a few chapters of it because they are not (yet) applicable for me. The chapter I found most useful is the one about budgeting. I have been keeping track of money since a few years ago, but I have never been really using it to conclude anything.<br />
<br />
This book actually reminds me about an old funny Hongkong movie I used to like a lot: <a href="http://www.imdb.com/title/tt0368770/">Frugal Game (2002)</a>. Someone actually <a href="http://www.youtube.com/watch?v=AcsKZTS6txA">uploaded this movie in several parts to Youtube</a>, but unfortunately there is no subs and it talks Cantonese.<br />
<br />
Back to the main topic, I would say that you won't find anything "heavy" inside this book since he's not inventing any new theory. But this is a nice book to start with if you think that financial security lead an important rule in our life.Momotarohttp://www.blogger.com/profile/01628232941901237433noreply@blogger.com0tag:blogger.com,1999:blog-1032173507286237052.post-41671982530759141932011-09-25T12:51:00.000+08:002011-09-25T12:51:14.943+08:00Debian Squeeze on Macbook Pro (Part III)This might be the last part of Debian Squeeze installation story. In this part I'm going to describe about what I did for backup.<br />
<br />
At first, to backup the entire debian system, we can use "<a href="http://en.wikipedia.org/wiki/Dd_%28Unix%29">dd</a>". <br />
<br />
The command is like this:<br />
<code><br />
dd if=/dev/sda4 of=/path/to/backup-`date +%s`.img<br />
</code><br />
<br />
To restore, boot from some place else (live CD or the other OS) and then run:<br />
<code><br />
dd if=/path/to/backup.img of=/dev/sda4<br />
</code><br />
<br />
Here, /dev/sda4 is the '/' partition where debian is installed.<br />
<br />
Example:<br />
<code><br />
momotaro@debbie:~/Downloads$ df -h<br />
Filesystem Size Used Avail Use% Mounted on<br />
/dev/sda4 9.2G 5.3G 3.5G 61% /<br />
tmpfs 1.9G 0 1.9G 0% /lib/init/rw<br />
udev 1.9G 264K 1.9G 1% /dev<br />
tmpfs 1.9G 0 1.9G 0% /dev/shm<br />
/dev/sda6 187G 40G 138G 23% /home<br />
/dev/sdb1 466G 423G 43G 91% /media/hd<br />
momotaro@debbie:~/Downloads$ <br />
</code><br />
<br />
To backup personal file, I use <a href="http://en.wikipedia.org/wiki/Rsync">rsync</a>.<br />
<code><br />
rsync -av /home/momotaro/Pictures/ /media/hd/Pictures<br />
rsync -av /home/momotaro/Music/ /media/hd/Music/iTunes/Music<br />
rsync -av /home/momotaro/Documents/ /media/hd/Documents<br />
</code><br />
<br />
The next step would be to run this backup script within a useful scheduled time, like weekly or maybe less.Anonymoushttp://www.blogger.com/profile/16184419777911994138noreply@blogger.com5tag:blogger.com,1999:blog-1032173507286237052.post-12403623419036945682011-09-11T01:12:00.003+08:002011-09-25T12:38:20.008+08:00Debian Squeeze on Macbook Pro (Part II)So, this is what I did to make wifi works on Macbook. First, I had to connect to the Internet by using cable. Thanks God our house has the cable (confirmed with my housemate that the cable is dedicated to the people who needs to do weird things LoL).<br />
<br />
Below are the steps to enable connection via cable:<br />
<ol><li>Edit /etc/hosts, add newname so it become something like this: <code>127.0.1.1 debbie newname</code></li>
<li>Set hostname to newname by using this command: <code>hostname newname</code></li>
<li>Remove oldname from /etc/hosts so it become: <code>127.0.1.1 newname</code></li>
<li>Find out the name of the network card interface (usually it's eth0) by using: <code>ls /sys/class/net </code></li>
<li>If there is a NetworkManager installed, you need to stop it by using the script from the usual location /etc/init.d, then you'll also need to remove it by using apt-get. But if there is a NetworkManager installed, why would you need to use command line to connect to the LAN?</li>
<li>Next, bring up the connection by using: <br />
<pre>sudo ip link set dev eth0 down
<span class="anchor" id="line-2-3"></span>sudo dhclient eth0</pre><pre></pre></li>
</ol>And next, just follow the steps explained <a href="http://wiki.debian.org/wl">on this page (wl)</a> thoroughly and you should be getting a working wifi on Macbook Pro (late 2010 version).<br />
<br />
If there is not a network manager available, then need to install it by using:<br />
<code>apt-get install network-manager-gnome</code><br />
or<br />
<code>apt-get install network-manager-kde </code><br />
<br />
By default, linux has ipv6 installed. To disable it:<br />
run: <code>echo net.ipv6.conf.all.disable_ipv6=1 > /etc/sysctl.d/disableipv6.conf</code><br />
<br />
and then modify /etc/modprobe.d/aliases.conf, add these lines:<br />
<code>alias net-10 ipv6 off</code><br />
<code>alias ipv6 off</code><br />
<br />
<span style="font-size: x-small;"><i>And yes, time goes by so quickly when you are working on the computer (have you noticed that?). </i></span><br />
<span style="font-size: x-small;"><i>I lose track of time while working on these things I looked at the clock and then realized that it's already 1AM, OMG!!</i></span><br />
<br />
Next step would be trying to:<br />
<ol><li>Installing GNOME (will be very easy) * </li>
<li><strike>Make brightness auto-adjustment works</strike>. Though by following the steps from <a href="http://wiki.debian.org/MacBook">Debian's wiki</a>, the brightness up and down keys are working properly.</li>
<li>Assigning MAC keys to their original purpose.</li>
<li>Finding out how to backup the entire debian, for future</li>
<li><strike>Auto backup for essential folders when an external HDD is attached and last backup was older than 1 week</strike> -> it might be disturbing that every time you connect an external HDD, it backs up. ** </li>
<li>Create a script to backup everything</li>
</ol><br />
* <span style="font-size: x-small;">To KDE fans: no offense, this is just a matter of taste. I might or might not be ending up liking KDE, but before that I still would like to see GNOME</span>. <br />
** <span style="font-size: x-small;">Well, lets admit that when your HDD is working fine, this kind of thing seems too exaggerating. But when it's dead, you'll be sorry like I was when you didn't have it.</span>Anonymoushttp://www.blogger.com/profile/16184419777911994138noreply@blogger.com0tag:blogger.com,1999:blog-1032173507286237052.post-15653188044114047442011-09-09T13:33:00.000+08:002011-09-09T13:33:52.433+08:00Installing Debian Squeeze on Macbook Pro 13" (late 2010)<span style="font-size: large;"><b>Shrinking MAC OS partition</b></span><br />
Is almost impossible. Some people reported that DiskUtility hanged up in the middle of the process. For me, I ended up reformat the entire disk, and then re-install MAC OS on a small newly created partition (29GB), and left the rest as "FREE SPACE".<br />
<span style="font-size: large;"><b><br />
</b></span><br />
<span style="font-size: large;"><b>Installing rEFIt</b></span><br />
Is perhaps the simplest task among all. rEFIt can be downloaded from:<br />
<a href="http://refit.sourceforge.net/">http://refit.sourceforge.net/</a><br />
<br />
Run the installer, and then reboot twice to be able to see the changes.<br />
<span style="font-size: large;"><b><br />
</b></span><br />
<span style="font-size: large;"><b>Creating bootable USB disk</b></span><br />
<br />
<ol><li>Download Debian installation disk image from: <a href="http://www.debian.org/devel/debian-installer/">http://www.debian.org/devel/debian-installer/</a> </li>
<li>Convert iso to img by using: hdiutil convert -format UDRW -o ~/path/to/target.img ~/path/to/ubuntu.iso</li>
<li>Insert an empty USB drive (will be formatted) </li>
<li>Run diskutil list to find out device node: e.g. /dev/disk2</li>
<li>Unmount USB: diskutil unmountDisk /dev/disk2</li>
<li>Write the bootable drive: sudo dd if=/path/to/downloaded.img of=/dev/rdiskN bs=1m </li>
</ol>thanks to: <a href="https://help.ubuntu.com/community/Installation/FromUSBStick">https://help.ubuntu.com/community/Installation/FromUSBStick</a><br />
<br />
Note:<br />
<ul><li>also work on SD card</li>
<li>need to use the full CD installation, because to get macbook's wireless card to work with linux it will need extra effort which can be done later. If you use the network installer CD image, you will end up getting a merely CLI debian. </li>
</ul><br />
<span style="font-size: large;"><b>Installing Debian</b></span><br />
<ol><li>Insert USB or SD card, reboot and choose to boot from USB.</li>
<li>Install as usual.</li>
<li>Reboot.</li>
<li>Run rEFIt's partition manager on the boot screen.</li>
<li>Choose to boot from Linux.</li>
<li>And voila you'll got a Debian with no Internet connection because wifi is not working.</li>
</ol><br />
Hopefully I can later successfully install wifi driver for Broadcam BCM4322.<br />
<br />
<br />
Some useful readings:<br />
<a href="http://wiki.debian.org/wl#Squeeze">http://wiki.debian.org/wl#Squeeze</a><br />
<a href="http://wiki.debian.org/MacBook">http://wiki.debian.org/MacBook</a>Anonymoushttp://www.blogger.com/profile/16184419777911994138noreply@blogger.com1tag:blogger.com,1999:blog-1032173507286237052.post-50054906988071833752011-08-03T23:11:00.000+08:002011-08-03T23:11:32.317+08:00XPath<a href="http://www.w3schools.com/xpath/default.asp">XPath</a> is used to navigate through elements and attributes in an XML document.<br />
<br />
Since HTML is basically an XML document, XPath can be useful in developing an automation test, web crawler, and perhaps an advanced XML parsing application.<br />
<br />
Example of XPath syntax:<br />
<br />
<code>//input[@type="hidden"]</code><br />
this syntax will return all inputs of which type are "hidden"<br />
<br />
<code>//input[@type="hidden"][@name="input_name"]</code><br />
this syntax will return all inputs of which type are "hidden" and have the name "input_name" <br />
<br />
<code>//tr[contains(.,"some texts")]/td[1][contains(.,"more detailed text")]</code><br />
this syntax will return the first which contains "more detailed text" and this is the child of which contains "some texts" in any of its elements or attributes.<br />
<br />
To learn more about XPath, w3school provides <a href="http://www.w3schools.com/xpath/xpath_intro.asp">a very brief and to-the-point tutorial</a>. <br />
<br />
To play around with XPath, install Firebug and then enable "Console" and type $x(' -- xpath syntax -- '), it will return the XML parts which match the XPath query.<br />
It's very handy and fun!Anonymoushttp://www.blogger.com/profile/16184419777911994138noreply@blogger.com0tag:blogger.com,1999:blog-1032173507286237052.post-67864471018622938232011-07-23T22:32:00.001+08:002011-07-26T17:13:08.172+08:00Python Learning Journal (Part II - Preparing for Mechanize)<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgQeESttkjBpaZaqw8IpYBgWPxDUC1mQCW-A_MFFPryGvzs6WrjpMLuWGysCKL3Shyyu8qOxY4X5v1VLxjEdHI8eEX4JaIvJGSNzVzJQqhZdofUyltJ8fbcJZatRX7jQWRldCenvGhZ5q8p/s1600/python-icon-small.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgQeESttkjBpaZaqw8IpYBgWPxDUC1mQCW-A_MFFPryGvzs6WrjpMLuWGysCKL3Shyyu8qOxY4X5v1VLxjEdHI8eEX4JaIvJGSNzVzJQqhZdofUyltJ8fbcJZatRX7jQWRldCenvGhZ5q8p/s200/python-icon-small.png" height="50" width="50" border="0" /></a></div>To get familiar with Python syntax, I'll start with a play-around with web crawler scripts. I'll be using <a href="http://pypi.python.org/pypi/mechanize">Mechanize</a>, a supposedly stateful programmatic web browsing module. For introduction, I'll try to write a script to list out recent torrents from <a href="http://www.blogger.com/goog_1301008367">thepiratebay.org/recent</a>. And later I'll proceed with a script to retrieve and then summarize flight tickets price from <a href="http://www.airasia.com/">www.airasia.com</a>. Input parameters would be date range, origin city, and destination city. Then the script shall print out a table consists of date, time, and price. And then it will list out additional fees and taxes that will be applied upon payment.<br /><br /><br /><span style="font-size:large;">Mechanize Installation</span><br /><br />There is one thing I like about python, it's that everything comes with a general installation script:<code><br />python setup.py install</code><br /><br />Unlike Java, you need to mess around with path, classpath, and jar files.<br />So, to install Mechanize, it's as simple as downloading the archive, and then unpack followed by running the command with sudo.<br /><span style="font-size:large;"><br /></span><br /><span style="font-size:large;">Editor</span><br /><br />For editor, I'm using Eclipse with PyDev plugin.<br />To install this Plugin, simply go to Help | Install New Software, and then setup new site: <a href="http://pydev.org/updates">http://pydev.org/updates</a>.<br />Later, just go to Preference and setup this section: "Interpreter - Python".<br /><span style="font-size:large;"><br /></span><br /><span style="font-size:large;">Reference</span><br /><br />For me, code convention is very important. And thus, here is the general <a href="http://www.python.org/dev/peps/pep-0008/">convention of Python - PEP 8</a>.<br />Let me summarize here things that are new to me:<br /><ul><li>For indentation use 4 spaces, not tab</li><li>No space before and after = to indicate a keyword argument or default parameter</li><li>For package and module name use lowercase no underscore</li><li>For class name use CamelCase</li><li>For internal class name use CamelCase and one leading underscore</li><li>Exception name should have the suffix "Error"</li><li>Function/method/instance variables names use underscored lowercase</li><li>Non-public method/instance variables names use underscored lowercase and one leading underscore</li></ul> Below are some basic readings to do:<br /><ul><li><a href="http://learnpythonthehardway.org">Learn Python The Hard Way</a><br /></li><li><a href="http://docs.python.org/library/stdtypes.html">Python Build-in Types</a></li><li><a href="http://docs.python.org/reference/">Python Language Reference</a></li></ul>Anonymoushttp://www.blogger.com/profile/16184419777911994138noreply@blogger.com0tag:blogger.com,1999:blog-1032173507286237052.post-26840928690334250212011-07-23T14:27:00.001+08:002011-10-25T10:19:10.692+08:00Glomelurus.com: Short Story about Custom Domain NameI have finally subscribed a domain for this blog, triggered by an ads-tweet from my ex-colleague about hosting and domain name.<br />
<br />
First name came to mind is <a href="http://momotaro.com/">momotaro.com</a>. I have been naming almost all of my computers I've ever used with this name. And then the domain has been taken (of course), since it's <a href="http://en.wikipedia.org/wiki/Momotar%C5%8D">a hero name</a> of a very famous Japanese classic story. But actually they are giving it up (not sure why because I can't read Japanese). So this name is actually available for auction. But I don't think I need a domain name that special for just these simple writings.<br />
<br />
<table cellpadding="0" cellspacing="0" class="tr-caption-container" style="float: left; margin-right: 1em; text-align: left;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbQRZwqjHsvDh6qJxIoMbapijc-yd2a67cRPCUfoAyEe_wevUnNeoxVGKfIWpjd6qUY1MwyHYHAlyF3Oa7AxdB3gfeEwFW6pW6RW3BFSaNpZblhyphenhyphenBUJfIph1ZWk9Oqwz1SUnozhYGjSvH6/s1600/glomerulus.jpg" imageanchor="1" style="clear: left; margin-bottom: 1em; margin-left: auto; margin-right: auto;"><img border="0" height="255" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbQRZwqjHsvDh6qJxIoMbapijc-yd2a67cRPCUfoAyEe_wevUnNeoxVGKfIWpjd6qUY1MwyHYHAlyF3Oa7AxdB3gfeEwFW6pW6RW3BFSaNpZblhyphenhyphenBUJfIph1ZWk9Oqwz1SUnozhYGjSvH6/s320/glomerulus.jpg" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">img source: http://www.jimstanis.com</td></tr>
</tbody></table>
And then second name came to mind is <a href="http://momokun.com/">momokun.com</a>, and still this name is taken, for some kind of kindergarten website, I guess? And they messed up the encoding style, all those Japanese characters are displayed with ISO-8859-1.<br />
<br />
And voila, <a href="http://glomelurus.com/">glomelurus.com</a> is available. This name is special for me, because I was having a lot of troubles in remembering body parts name in Biology lesson more than a decade back. And until yesterday, I never realized that all this time I've been misspelling this kidney's component. <br />
<i><span style="font-size: x-small;"><br />
</span></i><br />
<i><span style="font-size: x-small;">Glomelur.us has also came to mind but due to pricing, I've also given up this one. Since ".com" is the most common suffix for domains, it shouldn't be that bad I supposed.</span></i>Anonymoushttp://www.blogger.com/profile/16184419777911994138noreply@blogger.com9tag:blogger.com,1999:blog-1032173507286237052.post-7914098416809103962011-07-15T13:08:00.004+08:002011-07-15T13:39:28.421+08:00Python Learning Journal (Part I - Foreword)Learning from past experiences and evidences, there is always a death point for everything when it comes to technology, especially IT. So it is always a good thing to try out something different, prepare yourself for that one day when you need to make that changes.<br /><br />I have been sticking myself to Java for at least 4 years (I started as a Delphi fans - the legendarily popular desktop programming language). At that time, Java was just starting to get popular with its runtime version 1.5.0.<br /><br />The problem with Java is that you need to type a lot, java codes, XML, XSD, properties file and everything. However this problem can be overcame by varieties of sophisticated tools and IDE. And then the hosting cost for a Java web application, is not cheap. You'll at least need a dedicated server. There is no way you can host it shared with another applications.<br /><br />Not to mention when you code for a desktop application, there is hardly any good and productive desktop UI library you can rely on. The only thing that is robust enough IMHO is <a href="http://www.eclipse.org/swt/">SWT (The Standard Widget Toolkit)</a> from Eclipse foundation, which consumes a lot of memory and is very very slow <span style="font-size:85%;">(needs references)</span>.<br /><br />I am not saying that Java is bad, or going to be outdated soon. Actually Java is really good for an enterprise solution. But I think it is a requirement to explore something contrastingly different (a dynamic language) than the thing you do everyday, once in a while. <span style="font-style: italic;">And ironically <a href="http://www.python.org/ftp/python/src/">Python is not even something new</a>, should I pick another language instead?</span>Anonymoushttp://www.blogger.com/profile/16184419777911994138noreply@blogger.com1tag:blogger.com,1999:blog-1032173507286237052.post-24927607003524412552011-07-09T14:03:00.007+08:002011-08-03T23:21:21.039+08:00Sexism in IT CareerIt has never come to my mind to write this blog entry until I saw a Python workshop advertisement which is "specially designed" for ladies. I don't know if it represents sexism, but the first thing that passed in my mind is: why would women need a specially design workshop in the first place?<br />
<br />
Is it based on the assumption that women don't excel men in logic, that is why they need a separate workshop, so that they can learn programming with a slower pace to prevent slowing down the other members (which will happen in a unisex workshop) ?<br />
<br />
You can say, "no, this is not it". Then why is it categorized based on gender and not based on the skill level of the candidates?<br />
<br />
Catholic educates boys and girls separately, which I don't know why because I'm not a Catholic. But I believe that the reason behind it is not because of smartness differentiation between boys and girls.<br />
<br />
In my humble opinion, women and men have the same opportunities to understand complex algorithm and how to work with programming language. There is no correlation between gender and ability when it comes to logic. This kind of gender specialized workshop has just proved that there has been some unprofessional gender prejudices happening in the community (which is sad), perhaps as a result of society belief.<br />
<br />
What do you think? Do you see or experience any similar discrimination incident ongoing in your workplace?<br />
<br />
<hr />Update per 03 August 2011 <br />
<hr />After asking for a number of trusted friends' opinions, it turns out that I had been acting too subjective upon posting this entry. Whatever the reason is, claiming something to be sexist is so judgmental and it's inappropriate. I apologize for that I've written this entry, I admit that it was subjective and personal.Anonymoushttp://www.blogger.com/profile/16184419777911994138noreply@blogger.com0tag:blogger.com,1999:blog-1032173507286237052.post-19552014560431140172011-04-10T02:14:00.000+08:002011-04-11T23:00:55.689+08:00Installing Massive Coupon on Mac OS 10What will you need:<br /><ol><li>Python 2.5+ - by default MAC OS 10 already have python installed, so actually for this one you don't have to do anything.<br /></li><li><a href="http://www.djangoproject.com/">Django 1.3</a> - a Python web framework </li><li><a href="http://dev.mysql.com/downloads/mysql/">MySQL</a> - you are recommended to download the dmg</li><li><a href="http://sourceforge.net/projects/mysql-python/">MySQLDb</a> - a Python-mysql connector</li><li><a href="http://code.google.com/p/django-photologue/">Photologue</a> - a photo management plugin for Django</li><li><a href="http://www.pythonware.com/products/pil/">PIL</a> - Python Imaging Library</li><li><a href="http://pypi.python.org/pypi/oauth/1.0.1">oauth</a> - Python oauth library</li><li><a href="http://pypi.python.org/pypi/python-openid/">openid.consumer</a><br /></li><li><a href="http://www.massivecoupon.com/deals/groupon-clone/">Massive coupon</a>'s source code</li></ol>Installation steps:<br /><ol><li>install mysql by running the dmg package</li><li>login to mysql by: <span style="font-family:courier new;">mysql -uroot</span></li><li>mysql> <span style="font-family:courier new;">create database massivecoupon;</span></li><li>mysql> <span style="font-family:courier new;">create user 'massive'@'localhost' identified by 'coupon';</span></li><li>mysql> <span style="font-family:courier new;">grant all privileges on massivecoupon.* to 'massive'@'localhost';</span><br /></li><li>install every required modules by: <span style="font-family:courier new;">sudo python setup.py install</span><br /></li><li>untar massive coupon's source code and then update the settings.py file <span style="font-style: italic;">accordingly</span><br /></li><li>run: <span style="font-family:courier new;">python manage.py syncdb</span></li><li>run: <span style="font-family:courier new;">python manage.py runserver</span></li><li>remove this line from massivecoupon/engine/forms.py:<br /><pre style="color: rgb(51, 102, 255); font-weight: bold;" class="default prettyprint"><code><span class="kwd">from</span><span class="pln"> massivecoupon</span><span class="pun">.</span><span class="pln">libs </span><span class="kwd">import</span><span class="pln"> formutils</span></code></pre></li><li>go to browser and <a href="http://localhost:8000/admin">http://localhost:8000/admin</a></li><li>login with the superuser credentials created before, and then setup everything<br /></li></ol><br />Tips for editing settings.py:<br /><br /><span style="font-family:courier new;">DEBUG = True</span><br /><br /><span style="font-family:courier new;">DATABASE_ENGINE = 'mysql' </span><br /><span style="font-family:courier new;">DATABASE_NAME = 'massivecoupon' </span><br /><span style="font-family:courier new;">DATABASE_USER = 'massive' </span><br /><span style="font-family:courier new;">DATABASE_PASSWORD = 'coupon' </span><br /><span style="font-family:courier new;">DATABASE_HOST = 'localhost' </span><br /><span style="font-family:courier new;">DATABASE_PORT = '3306' </span><br /><br /><span style="font-family:courier new;">SESSION_COOKIE_DOMAIN = 'localhost'</span><br /><br /><br />Upon these installation steps, below are the errors that you are more likely going to encounter:<br /><br /><span style="font-family:courier new;">momotaro:MySQL-python-1.2.3 momotaro$ sudo python setup.py install</span><br /><span style="font-family:courier new;">Password:</span><br /><span style="font-family:courier new;">sh: mysql_config: command not found</span><br /><span style="font-family:courier new;">Traceback (most recent call last):</span><br /><span style="font-family:courier new;"> File "setup.py", line 15, in <module></module></span><br /><span style="font-family:courier new;"> metadata, options = get_config()</span><br /><span style="font-family:courier new;"> File "/Users/momotaro/Downloads/MySQL-python-1.2.3/setup_posix.py", line 43, in get_config</span><br /><span style="font-family:courier new;"> libs = mysql_config("libs_r")</span><br /><span style="font-family:courier new;"> File "/Users/momotaro/Downloads/MySQL-python-1.2.3/setup_posix.py", line 24, in mysql_config</span><br /><span style="font-family:courier new;"> raise EnvironmentError("%s not found" % (mysql_config.path,))</span><br /><span style="font-family:courier new;">EnvironmentError: mysql_config not found</span><br /><br /><span style="font-weight: bold;">solution:</span><br /><span style="font-weight: bold;">> ln -s /usr/local/mysql/bin/* /usr/bin</span><br /><br /><span style="font-family:courier new;"> File "/Library/Python/2.6/site-packages/django/db/backends/mysql/base.py", line 14, in <module></module></span><br /><span style="font-family:courier new;"> raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e)</span><br /><span style="font-family:courier new;">django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: dlopen(/Users/momotaro/.python-eggs/MySQL_python-1.2.3-py2.6-macosx-10.6-universal.egg-tmp/_mysql.so, 2): Library not loaded: libmysqlclient.18.dylib</span><br /><span style="font-family:courier new;"> Referenced from: /Users/momotaro/.python-eggs/MySQL_python-1.2.3-py2.6-macosx-10.6-universal.egg-tmp/_mysql.so</span><br /><span style="font-family:courier new;"> Reason: image not found</span><br /><br /><span style="font-weight: bold;">Solution:</span><br /><span style="font-weight: bold;">> sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib</span><br /><span style="font-weight: bold;">> sudo ln -s /usr/local/mysql/lib /usr/local/mysql/lib/mysql<br /><br /><span style="font-weight: bold;"><br />Notes:<br /></span></span><ul><li><span>It is very important to install every required python modules completely, otherwise the applications won't run at all.</span></li><li>Need to stop and re-run the manage.py runserver after every installation of modules</li><li><span>It's also required to create a soft link from /var/www/massivecoupon to the real path of the massivecoupon folder itself, and then modify the permission of that folder to the proper user for rwx.</span></li><li><span>For any absence of modules you can try searching on this website: <a href="http://pypi.python.org/pypi/">http://pypi.python.org/pypi/</a></span></li></ul><br /><div style="text-align: center;"><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg5lVCxKzZggYjzO6Je-sZWs-mtOxM81DIOkmJOruzlvfizBkcDo8LXIoZeSLHiBvHeCkB2oZAPNc2ikZf16CVR-grWLIljV1Ey2fCGobLo3bFrW2S9SBfJL_UuQPiI2gH7LvgYdRTjANkN/s1600/Screen+shot+2011-04-11+at+PM+10.59.18.png"><img style="cursor:pointer; cursor:hand;width: 400px; height: 250px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg5lVCxKzZggYjzO6Je-sZWs-mtOxM81DIOkmJOruzlvfizBkcDo8LXIoZeSLHiBvHeCkB2oZAPNc2ikZf16CVR-grWLIljV1Ey2fCGobLo3bFrW2S9SBfJL_UuQPiI2gH7LvgYdRTjANkN/s400/Screen+shot+2011-04-11+at+PM+10.59.18.png" alt="" id="BLOGGER_PHOTO_ID_5594340966864105282" border="0" /></a><br /></div><br />Last updated: 11/04/2011<br /><span style="font-style: italic;">Finally can get it works, yay!!</span>Anonymoushttp://www.blogger.com/profile/16184419777911994138noreply@blogger.com4tag:blogger.com,1999:blog-1032173507286237052.post-15005615161292902152011-01-22T13:38:00.000+08:002011-01-26T23:59:49.506+08:00Building an Automated Test Script with RFT without RecordingSome times ago, I wrote an entry about <a href="http://ageekstory.blogspot.com/2009/04/automated-testing.html">Automated Test</a>. Until now, I still agree that a good automated test project, should be written without recording anything at all. I don't know why those automated test tools provide "recording" function. I don't think recorded automated scripts will be useful enough to support software development, since UI will always change, and some day you'll always get to migrate "things" around.<br /><br />By using recording, clicking a button will become "pressing mouse at the screen coordinate x and y". Some day when you run this script again, any of the condition below will fail the script:<br /><ul><li>the application windows are maximized (it wasn't maximized when you recorded it)</li><li>the UI was updated, now there are some texts above the OK button</li><li>the OS was on resolution 1024 x 800 when you recorded the script (your boss gave you a new high resolution monitor)</li><li>some other reasons that will always be there</li></ul>So I have been doing some research and testing with Rational Functional Test version 7.0 and web browser Internet Explorer 6.<br /><br />There are some tools you should be familiar with when using RFT. For starter, here are the 2 most important tools you have to know:<br />The last icon on the image below, is for opening the "Test Object Inspector".<br />The second icon, is for showing the "Enable Environments" preference.<br /><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhvxKFsIG0cL393Crf2zoaKigHaEKISDf5O1XUEw7xhjTjSoRfZ-Fr82lNfjmA5nhTEyfg2C_7Z6WsuGT8Yt5G-MoEVsZNfyF8uegb0cusVHMsLBAR5sKWuQf9aM20j35OSuSNjHCDX3HD5/s1600/ScreenShot235.png"><img style="float: none; margin: 0pt 10px 10px 0pt; cursor: pointer; width: 99px; height: 30px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhvxKFsIG0cL393Crf2zoaKigHaEKISDf5O1XUEw7xhjTjSoRfZ-Fr82lNfjmA5nhTEyfg2C_7Z6WsuGT8Yt5G-MoEVsZNfyF8uegb0cusVHMsLBAR5sKWuQf9aM20j35OSuSNjHCDX3HD5/s400/ScreenShot235.png" alt="" id="BLOGGER_PHOTO_ID_5564883544787402754" border="0" /></a><br /><br />The Test Object Inspector, is something you can use to figure out the properties' keys and values of you application's component. Once you hover it, the window will show all properties related to it.<br /><br /><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhDtHDnTDYzsmdmzzPYwFUVgG6-iISCSsI7f0HS_kk7PE45G1WCwGbCijh-QuwejygeSkzGvZHoo_lmfjACtwtElqu34NEqNNdiFWCjlwRXk2CjnpTTfy27xrP-vycokdso-76rEDbo1CPr/s1600/ScreenShot234.png"><img style="float: none; margin: 0pt 10px 10px 0pt; cursor: pointer; width: 400px; height: 370px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhDtHDnTDYzsmdmzzPYwFUVgG6-iISCSsI7f0HS_kk7PE45G1WCwGbCijh-QuwejygeSkzGvZHoo_lmfjACtwtElqu34NEqNNdiFWCjlwRXk2CjnpTTfy27xrP-vycokdso-76rEDbo1CPr/s400/ScreenShot234.png" alt="" id="BLOGGER_PHOTO_ID_5564884079819906786" border="0" /></a><br /><br />"Enable Environments", is the preference for setting the application you want to test. In this entry, I will be talking only about web application. With this preference, you can add the browser that you want to use for testing.<br /><br />There is one thing you should know, that RFT 7.0 can only work with IE6. If you want to perform testing in IE7 or IE8, then you will have to use RFT 8.0.<br /><br /><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj3qVkhCZpeDv84MjGzGs1CTZU0owctaJ6CAwuzoltIzUOLRU3ve99lD6vesaneEqeHL6xPk-mPT8Jq_rLqTENgd6sW5pf3SDMMXy0vgiUdw6W69kFjgHmdGooBfs0riEEVV4_192766ppY/s1600/ScreenShot236.png"><img style="cursor: pointer; width: 400px; height: 250px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj3qVkhCZpeDv84MjGzGs1CTZU0owctaJ6CAwuzoltIzUOLRU3ve99lD6vesaneEqeHL6xPk-mPT8Jq_rLqTENgd6sW5pf3SDMMXy0vgiUdw6W69kFjgHmdGooBfs0riEEVV4_192766ppY/s400/ScreenShot236.png" alt="" id="BLOGGER_PHOTO_ID_5564884821387782386" border="0" /></a><br /><br />Below are some codes that you can use as a base to build an integrated automated test script. It has been already tested and running well, as long as you are using the correct version of RFT and web browser.<br /><br />To start running a browser with a particular web address:<br /><pre>ProcessTestObject proc = startBrowser("http://www.google.com/");</pre><br />To kill the browser:<br /><pre>proc.kill();</pre><br />To wait for a specific time (allowing the page to load):<br /><pre>sleep(10); //meaning wait for 10 seconds.. </pre><br />And the most important thing, to get the DomainTestObject for the loaded HTML domain. With this DomainTestObject you can later perform a "find" to look for the objects you wish to test:<br /><pre><br />private void clickLink(String title) {<br /> TestObject[] links = dto.find(atDescendant(".class", "Html.A", ".text", title));<br /> while (links != null && links.length <= 0) {<br /> links = dto.find(atDescendant(".class", "Html.A", ".text", title));<br /> }<br /> clickSomething((GuiTestObject) links[0]);<br />} <br /></pre><br />To find a link, and to click on it:<br /><pre><br />private void clickLink(String title) {<br /> TestObject[] links = dto.find(atDescendant(".class", "Html.A", ".text", title));<br /> while (links != null && links.length <= 0) {<br /> links = dto.find(atDescendant(".class", "Html.A", ".text", title));<br /> }<br /> clickSomething((GuiTestObject) links[0]);<br />} <br /></pre><br />To click on the object found:<br /><pre><br />private void clickSomething(GuiTestObject object) {<br /> boolean tryAgain = true;<br /> while (tryAgain) {<br /> try {<br /> object.click();<br /> tryAgain = false;<br /> } catch (UnsupportedActionException e) {<br /> sleep(1);<br /> }<br /> }<br />}<br /></pre><br />The reason behind try and catching the UnsupportedActionException is that because sometimes the page hasn't been finished loaded, and then clicking the object will throw an exception and it will stop the entire script, which we don't want to happen.<br /><br />To input some text into an input box:<br /><pre><br />private void typeInput(String name, String inputText, boolean hitEnter) {<br /> TestObject[] links = dto.find(atDescendant(".name", name));<br /> while (links != null && links.length <= 0) { <br /> links = dto.find(atDescendant(".name", name)); <br /> } <br /> while (!((GuiTestObject) links[0]).exists()) { <br /> sleep(1); <br /> } <br /> clickSomething((GuiTestObject) links[0]); <br /> TopLevelTestObject textBox = new TopLevelTestObject(links[0].getTopParent()); <br /> textBox.inputChars(inputText); <br /> if (hitEnter) { <br /> textBox.inputKeys("~"); <br /> } <br />} <br /></pre><br />To press Yes/No at browser's confirmation dialog:<br /><pre><br />private void clickConfirmationButton(String button) {<br /> TestObject[] links = null;<br /> do {<br /> sleep(1);<br /> links = dto.find(atDescendant(".class", "Html.DialogButton", ".text", button));<br /> } while (links != null && links.length == 0);<br /> clickSomething((GuiTestObject) links[0]);<br />}<br /></pre><br /><br />Those are just examples, you are always free to modify and improve it with your own creativity.Anonymoushttp://www.blogger.com/profile/16184419777911994138noreply@blogger.com4tag:blogger.com,1999:blog-1032173507286237052.post-80215656590380120322010-07-02T13:21:00.001+08:002012-01-06T22:15:08.762+08:00Eclipse Plugins - KBS File Colored Editor plus CSV Colored EditorSo I'm in this new company working with a framework called Selectica which is mainly dealing with KBS files. I wonder why everybody's eyes are so great looking at those plain Textpad screens without any color at all.<br />
<br />
So I managed to get one, by searching around on the Internet and turns out that this framework is such unpopular that nobody cares to create a colored editor. Finally I came to this Eclipse plugin: <a href="http://www.gstaff.org/colorEditor/">Color Editor</a><br />
<br />
Later I modified something inside, added functionality for KBS and CSV file support, and it works! Well, not so perfectly works, but at least it's colored.<br />
<br />
Since the editor is an open source project, meaning it's free for modification and distribution, if you're also looking for the same thing, you can download it from:<br />
<a href="http://dl.dropbox.com/u/8521165/cbg.editor_1.2.6.jar">http://dl.dropbox.com/u/8521165/cbg.editor_1.2.6.jar</a><br />
<br />
Version 2.6.2:<br />
9th July 2010<br />
- CSV file supports<br />
- Added more keywords for kbs<br />
<br />
<a href="http://dl.dropbox.com/u/8521165/cbg.editor_1.2.6.2.jar">http://dl.dropbox.com/u/8521165/cbg.editor_1.2.6.2.jar</a><br />
<br />
Installation step is easy. For Eclipse 3.2:<br />
1. Copy jar file to eclipse plugins folder<br />
2. Restart Eclipse<br />
3. Try open a KBS file, if file is still displayed as plain text editor, proceed to step 4<br />
4. Open Windows | Preference | File Association<br />
5. Add *.kbs extension, and Syntax Color Editor as default editor.<br />
<br />
For Eclipse 3.3 or above, copy jar file to eclipse dropins folder, I'm not sure it will work, but you can just try.<br />
<br />
I'll continue working on the patterns to make it more perfect and post it here again whenever there is a significant enhancement. Because this KBS file is so unique, it's something like a semi-XML file. What make it difficult to be mapped is that it's not very strict in terms of using < > as a tag. Normally in XML, <> is not permitted inside a tag. But here it happens which make it looks like some mathematics equations.Anonymoushttp://www.blogger.com/profile/16184419777911994138noreply@blogger.com0