November Rain
Time flies. It’s November again. 2011 is waning and 2012 is just before the doorstep. Soon we will be greeting “Hello 2012.”
There is no particular topic for this blog post but I just want to share with you one of my favorite rock song, “November Rain” by Guns N’ Roses.
It’s November and at this time of the year, the beginning of North-Eastern monsoon, brings a lot of rains. No word in the Webster can describe the mixed feelings of listening and smelling the rain together with the music. If you are somewhere so happened to have rain outside your window in the month of November, turn up the volume and watch the rain outside.
Perhaps you want to share with me your feeling?
Regulus – My new (Lion) iMac
It has been my tradition to name my computers and mobile devices after the name of a moon, planet or star. This time is no exception.
The new OSX operating system 10.7, code-named Lion, was officially released by Apple, Inc. on July 20, 2011. In astrology, it was just two days before the Sun begins occupying Leo from July 22 to August 22. And I ordered my iMac and received it before the Sun leaves Leo.
In astronomy, Regulus or Alpha Leonis is the brightest star in Leo constellation. In Chinese, it is known as 轩辕十四, the Fourteenth Star of Xuanyuan. Regulus is also one of the brightest stars in the night sky. Together, with Eta Leonis (a fourth-magnitude star), they mark the lion’s heart.
My new 27″ iMac is a top range CTO model and will be the power horse for my works which include software development, some photography and design works. It is also the most powerful personal computer I have ever owned/purchased. Thus, Regulus is the best and most beautiful name for my new iMac.
Pluto will be passed down to my wife and kids after the data has been completely migrated to Regulus and a stable working environment is established.
Ada and Multiple Inheritance
When developing an information system which computes real-life data, one of the most common problems a software developer may encounter is multiple inheritance. Inheritance is one of the four aspects in Object-Oriented Programming (OOP).
What is Object-Oriented?
Object-oriented technique organizes software as collection of discrete objects incorporate with data structures and behaviors. Take a software that keeps records of professors and students in a university for instance. Both professor and student are person. These three entities – professor, student and person are objects. A person has data structure such as name, gender and date of birth to make things simple. Both professor and student share the same data structure of person. A professor has employee number, salary, and room number. And a student has student number, courses and grades. Both professor and student have different behavior: to lecture and to learn respectively. We can let professor and student to inherit the same data structure and behavior from person. Person is superclass. Both professor and student are subclass. Now both professor and student can derive data structure and behavior from superclass person but at the same time, both can preserve their own data structure and behavior as professor and student respectively.
Multiple inheritance is where a subclass inherits from more than one super class. One of the most common problems with multiple inheritance is symmetry. Let subclass D inherits from superclasses B and C which inherit from another superclass A. This is called symmetric multiple inheritance.
Multiple inheritance is rather problematic at linguistic level. Many object-oriented programming languages support multiple inheritance and solve the problems in such a way that usually they cause surprises to their users. In the above example, the operations in A can be derived to B and C and overridden in any other ways by any one of them in D.
Ada provides different approach to implement multiple inheritance by simply not allowing user to get into such problem in the first place and to force the user to break the symmetry.
While I slip deeper into my software design, symmetric multiple inheritance occurs. I have two classes A and B where both of them inherit from object List.Node. Another subclass C inherits both superclass A and B. Ada forces me to break the symmetry by letting C to have a direct inheritance from A plus indirect secondary inheritance of B.
package List is
type List is limited private;
type Access_List is access List;
type Node is tagged private;
type Access_Node is access all Node'Class;
private
type Node is tagged record
Previous : Access_Node;
Next : Access_Node;
end record;
type List is limited record
Head : Access_Node := null;
Tail : Access_Node := null;
Current : Access_Node := null;
Count : Unsigned := 0;
end record;
end List;
type A is new List.Node with private;
private
type A is new List.Node with
record
Id : Integer;
Str : String ( 1 .. 20 ) ;
end record;
type B is new List.Node with private;
private
type B is new List.Node with
record
Precision : Float;
end record;
type C is new A with private;
private
type C is new A with
record
Magic : B;
Plate : Integer;
end record;
Run Software Update from Terminal on Mac OS X
Every Mac comes with an application called Software Update, which automatically check for, download and install any available software updates. The application will prompt you to restart your Mac if necessary.
Although the automation of software update and restart is convenient most of the time, it can be quite an annoyance when you are in the midst of works, where the reminder window keeps popping up.
To avoid this annoying pop-up, you can run software update in Terminal (command line) and restart your Mac as you wish, using the following command:
sudo softwareupdate -i -a
This is also convenient for managing software update remotely over slow Internet connection. Logging in via ssh instead of remote desktop will reduce the high bandwidth requirement and yet still get the job done.
Embrace Life
It was a beautiful morning, starting with a cup of coffee and a few slices of toast, I began to read some articles on the Internet. The articles are related to my software project as well as some other stuffs regarding productivity and supplementary.
Among all I was reading, there was one that caught my attention, the one that I paused all my activities, and let it touch deeply into my heart. I can’t help to shed my tears.
This is the most beautiful and touching commercial I’ve ever watched. Besides the artistic and beautiful photography, the video portrays how beautiful life is and how fragile it can be. Take a moment off your work (yes, I know you are busy) to watch this video. I bet and I hope it will make you realize how beautiful our lives are.
Enjoy!
This is the new “wear your seatbelt” ad the UK is doing – started by a man not hired to do it, but because the cause is important to him, he came up with this idea, and now it’s being hailed across the world as a ‘beautiful’ commercial. And now the video has become so popular with the general public that people are forwarding it to friends/family on their own so quickly that it has spread all over the world in a very short time.
You can watch here too.
Today, Tomorrow and Todo
Last night, I was reading a blog post at Time Management Ninja (aka TMNinja). In “The Secret of Today Versus Todo“, what did you get done today is important. But sometimes it will not be the case. Someday, things just don’t work out as you wished.
For the past two weeks, I had been bugged by a silly tiny bug in one of my codes. Things weren’t moving at all. They were all still and my progress in a software project was stagnant. Before the bug was identified and removed, I could not move on to other tasks as they were highly dependent on the unit testing of that particular buggy code.
Yesterday, I finally managed to debug it and deducted 5 tasks. In actual fact, I only completed one task but deleted four. The four tasks which I deleted were no longer applicable because I completed one task which was dependent on the other four. I deleted them because they became obsolete.
So, yesterday, I completed one task that would allow me to complete more tasks today. In other words, imagine that we were traveling on a time machine to yesterday, it would be: today I completed one task and tomorrow I will be able to move on to other tasks. Confusing, isn’t it?
For a software developer, someday he/she will write many lines of code, perhaps a thousand. But someday, he/she will only write just one line of code or perhaps none. When the productivity is only one line of code for a day, is it too low? It is not. Sometimes, that single line of code will serve as a connector to many pieces of code together. That one single line that software developer has produced today, will allow many tasks to be completed tomorrow.
Praise yourself if you have got only one task done today because you will complete more tomorrow. The caveat, however, is that you do not make this an excuse for not having done so much today.
Catching HTML bugs with Safari 5
A bug in a seemingly harmless HTML code had been bugging me for almost 2 weeks. I was sort of yanking my hair while trying to trace the bug which messed up the HTML page. The debugging task was even harder because I work on a HTML template with an extension .THTML. The template does not only contain standard HTML but also tags which are only recognized by AWS (Ada Web Server) . This template file is parsed by the web application (I am developing), which has AWS library, before it is dispatched as raw HTML code to a browser.
In my design, I break down the HTML template into header, body and footer so that I can reuse the common codes in header and footer. That means, all the body templates are without <html> tag. This missing <html> tag disables the syntax-coloring feature of code editor, leading to a more laborious code reading.
Before this, I had gone through every line of html source code in the template file umpteen times. This “obscure” bug, if not removed, would throw a monkey wrench in my works. I browsed the Internet and read articles in hope that I would get some clues. So, I was reading a few articles about Extensions in Safari 5. Extensions are not really impressive to me as I do not need to add missing functionalities to my browser. Safari itself is more than enough for my daily browsing activities. Somehow, my curiosity had driven me to enable the Develop menu in Safari 5. After activating it, I noticed some debugging tools in the menu. I enabled the web inspector by selecting Show Web Inspector in the Develop menu (Figure 1) then navigated to the web page I wanted to debug. To use these debugging tools, the Develop menu must first be activated. Here is a simple guide to enabling the menu.

Figure 1
Safari 5 immediately detected two error messages as shown in Figure 2. These two errors were easily corrected. After removing these unmatched </div> tags, my web page still did not show up properly with the intended layout.

Figure 2
Then I selected the Elements tab and it showed me the page source in debugging mode as shown in Figure 3. I instantly spotted the <div class=”data-base-layer”> tag which was supposed to be in the <div id=”container”> tag.

Figure 3
I clicked on the little grey triangles in the left pane to expand the <div id=”container”> tag and the <form> tag. There were two <div class=”data-base-layer”> tags (labelled as “1″ in Figure 4) and the one in label “2″ was supposed to be right after them.

Figure 4
I checked the source file again and they seemed to be in the correct place. Further investigation finally reviewed that there were two very tiny typos lurking somewhere within the second <div class=”data-base-layer”> tag as shown in Figure 5.

Figure 5
The web inspector in Safari 5 has helped me to identify errors effortlessly. If only I had such inquisitiveness two weeks ago, I would have saved so much time and efforts in debugging my HTML codes. An proverb says: “Curiosity killed the cat.” It is not always true, at least in this case. I will say: “Curiosity saved the donkey.”
iPhone is good for business
As I promised earlier in an article that I would write about my experience of using the iPhone. Well, here it goes…
I got an iPhone
If you have followed my blog, you must be aware of how I criticized about iPhone and Apple’s aggressive strategy with mobile carriers in my article, “iPhone is in Malaysia!” I have also been going around telling customers and friends that iPhone is not as useful as it seems and is more a toy to attract young generation.
Well, I admit that I was wrong. I am developing a cloud/web-based MIS (Medical Information System) which enables patient to be able to view certain information and interact with the clinic/doctor from anywhere. Likewise, it also provides doctors greater mobility and still are able to care for their patients while they are away.
After reading articles (on Apple’s website) how iPhones help hospitals in the U.S. to provide better healthcare at lower cost, I decided to build the MIS with iPhone support. I based my decision on these reasons:
- Ease of use. I have been toying/using around with an iPod Touch for a few months and I find that it is easy to navigate/use. iPod Touch is essentially an iPhone without the phone. You get what I mean.
- Beautiful UI. Apple is well known for its brilliant UI (User Interface) in Mac OS X and iPhone OS. Nothing else comes closer to it.
- Security. All applications must be approved by Apple and be signed with license keys issued by Apple. Apple’s iTunes Store is the only place to download applications. I can be rest assured to have less (or none) headache about spooky applications from unreliable sources. Of course, there are jail broken iPhones which do not play by the rules but I am not too worried about that.
So, I went ahead ordering one last week. Last night, I went to Maxis center to collect my 32GB Black iPhone. It is such a beauty.
Give me a couple of weeks mingling with it and I promise you I will write about my experience.
Nightlighting
Recently, I have been reading a little about women’s health while working on a software project. It is astonishing to know most of the facts about women and women-related illnesses. When reading about menstruation, I learned some terms such as menarche which means woman’s first menstruation, dysmenorrhea which is a medical condition characterized by severe uterine pain during menstruation.
Heredity, diet and health condition can affect a young woman’s menarche. This is something most parents with growing young daughters have overlook. Diet plays a very important part in young women especially teenage girls. Many teenage girls despite of having their menarche years earlier, neglects or intentionally limit their dietary intakes for body slimming purposes. This ignorance can seriously affect their reproductive system.
One most interesting fact I learned about menstruation is the term “Nightlighting”.
The word “menstruation” is etymologically related to “moon”. The terms “menstruation” and “menses” are derived from the Latin mensis (month), which in turn relates to the Greek mene (moon) and to the roots of the English words month and moon—reflecting the fact that the moon also takes close to 28 days to revolve around the Earth (actually 27.32 days). The synodical lunar month, the period between two new moons (or full moons), is 29.53 days long. — Wikipedia
In some traditional societies without nightlighting believe that women ovulate in full moon and menstruate in new moon. There are studies in both humans and animals where artificial lighting at night does alter the menstruation cycle. While none of the studies have suggested the lunar phase affects the ovulation cycle, bright light exposure in the morning stimulates more regular cycles.
Research also suggested that sensitivity of women’s cycles to nightlighting is related to nutritional deficiencies of certain minerals and vitamins. Again, balanced and healthy diet is utmost important to women’s health.
Backup your Mac with AppleScript
All programmers are lazy. They want to automate tasks as much as they can. Because of this uniquely great habit, they have developed countless of useful software.
Ok. I am lazy. I have been using rsync to sync folders I am working on between my Macs. I have been using command line scripts in Terminal for almost two years and finally I have gotten lazy over the task.
The thing is, I need to execute the scripts in Terminal every time I want to synch my folders. Of course, I could simply use cron to automate the tasks at specific time but I ran the risk to cause havoc between the folders on different Macs. It is best not to cron the task.
So, I learned up AppleScript and after a ten-minute hack, I wrote a nice AppleScripts to do the job. It is quick and dirty.
set debug to false
with timeout of (30 * 60) seconds
tell application "Terminal"
set Window_Title to "Sync Documents"
set Rsync_Cmd to "rsync -acrtv --delete
/Users/username/Documents/
username@xxx:Documents"
set output_doc to do shell script Rsync_Cmd
choose from list paragraphs of output_doc with prompt
"Result:" with title Window_Title with empty
selection allowed
end tell
end timeout
Copy the script to ~/Library/Scripts/Applications/Finder and save it as “sync documents.scpt”. Then launch Script Editor to edit username to your login name and xxx to your Mac IP address or computer name. This script will sync your Documents folder under your user home directory. To execute this AppleScript, at Finder, click on the script icon on the menu bar and select the script to launch.
rsync uses ssh. If you have not setup a password-less ssh login, you will need ssh-askpass in /usr/libexec. Unfortunately, it does not ship with Mac OS X. You can get it at Joe Mocker’s weblog.
Objectively Boolean
I was introduced to Objective-C in a workshop organized by Apple Malaysia about 3 years ago. Read my posts here and here. No real development using Objective-C after that.
One plain reason for me to pick up Objective-C again recently is to develop Cocoa and Cocoa Touch applications for the Macs and iPhone (and iPod Touch). Trying to having nonpartisan mind after so many years of using Ada (and away from C/C++ and variants) is a difficult task to comprehend. As an individual Ada developer (having my own opinion) I am finding C/C++ very compromising in many ways, for instance, readability of codes and safety. Although Objective-C has many improvement over C/C++, it is still lacking what Ada offers.
By syntax, Objective-C is still very much like C. A few obvious clues to tell if it is an Objective-C are the use of #import, instead of #include; the @ sign; the Smalltalk-like message passing syntax and several others.
The #include statement in C/C++ has many drawbacks. One which seriously affecting compilation efficiency is the repeating includes of same header files. With #import, header files are included once only throughout entire compilation.
One deadly pitfall I have encountered so far is the way Boolean type is implemented in Objective-C. C supports Boolean data type, bool, which takes on the value of either true or false. Objective-C has similar data type, BOOL, which is 8-bit number that takes on YES as 1 and NO as 0. If you unwittingly assign a 2-byte integer to a BOOL type, the result can be catastrophic. Only the lowest byte will be used for the value of BOOL. If the lowest byte is zero, for example, 4608 which its hexadecimal value is 0×1200, BOOL will be zero or NO.
Ada’s strong-typing disallows this to happen and thus saving, possibly countless hours of debugging. Personally, I like neither bool nor BOOL. I prefer Ada’s Boolean.
Unlike the dreaded C++, Objective-C does not support operator overloading and multiple inheritance. In Ada95, a restricted form of multiple inheritance is supported. In Ada2005, multiple inheritance is supported by new form of type called the interface type, similar to abstract tagged type with no components.
Apple TV playlist
I have installed an Apple TV at my client’s office waiting area. His purpose is to educate his patients while they are waiting for their consultation. That is a brilliant idea as we had long and boring waiting experience when LA was consulting him.
The idea is to design different programs with advertisements and messages interleaved among documentary and his own educational videos for playback on different days of the week. And the most important thing is to allow the doctor himself to easily update his educational videos and advertisements anytime as he wishes from his new 24″ iMac.
After I installed Apple TV a few days ago, I realized it did not have movie playlist. After Googling for a while, I wasn’t alone. Here is a blog entry with the same problem. And I found out the Apple TV Software Update 2.3 allows movie playlist in iTunes to be seen on Apple TV. I downloaded the 2.3 update this afternoon, and after I activated the movie playlist in Apple TV settings, it is now able to play the movies in the playlist as desired.
I pondered why Apple did not ship Apple TV with new software update 2.3. It was released in November 2008. About the Apple TV software update can be found here.
Another ultimate experience
When LA birthed Richie, I was there with her almost the whole day in the labor room. That was the first awesome experience in my life. About three years ago, when LA birthed Nik, I was there with her in the operating theatre (OT). That was another more wonderful day in my whole life. I could hear her doctor cut open her lower abdomen (Caesarean section).
Almost a month after Nik was born, I suffered from retina detachment and had to undergo a surgery to repair it. That was myself experiencing the first surgery of my life. The experience was really awesome and I had some mixed feeling.
This afternoon, I had to test out some equipment in the OT while the doctor was performing laparoscopic surgery. Like the second experience, I had to put on the surgical gown and mask before entering the OT. Only this time I was with the doctor.
That's me in surgical clothing
Although the laparoscopic surgery was not invasive, it was thrilling enough to witness the live performance before my own eyes. At least, it has proven I have a strong stomach up to this level.
A good head start
Happy New Year 2009 buddies!
It seems like a good head start for me. Everything I planned for today seems to be smooth sailing although I am having one problem which I do not know why it happens. I guess I will need to toy with it and/or hack it to learn why it isn’t behaving as it supposed to be. If everything is running perfect before end of this month, I will acquire an iPod Touch to proceed further. This will be my first wish on this very first day of 2009.


Listen to my podcast