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.”
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.
The new WordPress
Just finished upgrading WordPress to 2.7.1 with a totally new user interface. I still prefer the one in 2.6.x so I guess I need a little time to get use to the new UI.
The upgrade is inevitable because some of my sites were affected by Yahoo! Counter malicious malware. It is a nasty injection of script. I could not locate where it was injected and my web host wasn’t very helpful. I decided to upgrade, hopefully, to wipe out the code injection.
Now, I have to file a request to Google to clear the malware listing of my sites.
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.
Finder hang in Leopard
When I returned home this evening, LA told me her applications had hung. I checked and found not only that, the Finder was not responsive too. I had no choice but to power off and to restart the Mac Mini again. This had also affected my user account. The Finder had failed to launch after login and the Dock did not appear as well. But fortunately root user account was not badly affected.
I Googled and found some articles and solutions here, here and here. I exhausted all the methods and I did not have DivXNetworks and ApplicationEnhancer.bundle in the directories mentioned in these links. I decided to go my own way.
What I did was to delete everything that was related to DivX. Since I did not have DivXNetworks, so I removed DivX folders in “/Library/Application Support” and “~/Library/Application Support” and also the DivX programs in Applications.
After the deletion, Finder still could not launch properly. I launched Console.app to examine system logs and found some errors in cache files com.apple.LaunchedServices*. I removed everything with com.apple.LaunchedServices in /Library/Caches.
Viola! Everything is back to normal again. DivX is a third party enhancement software and is not very stable. It seems like DivX has messed up with the system caches and somehow prevented Finder to launch.
I have spent two and half hours mingling with this problem. I hope my experience will save some of your time if you have the same problem as mine. I am going to take my supper.
Good luck!
Subversion client hangs after post-commit
I had been hit by this problem since I setup Subversion on Ubuntu in January. The svnserve was properly invoked on Ubuntu server but whenever any svn client was trying to commit something back to the server, the client would hang for hours before it prompted an error: “Connection reset by peers.”
I searched all the Subversion and Ubuntu forums but could not find any solution to my problem. In the past months, I tried to identify the source of the problem and even tried many solutions suggested by people on these forums but the problem persisted. I had been committing to svn server with post commit email notification turned off and lost quite a number of post commit message. I used to keep track of changes by these email notification.
Yesterdat, I was trying my luck again and I accidentally noticed sendmail and sendmail-mta were called after commit. A look into syslog confirmed that sendmail process was put into sleep by some unknown reason. Failing to identify the cause, I removed sendmail and related packages from my Ubuntu server and installed Exim4. It is claimed to be easier to installed and configured than sendmail. The problem diminished after I got exim4 up and running. Now I am able to receive post commit email notification after every svn commit. Every commit takes a few seconds to complete after this. Problem resolved.
Hacker and Cracker
I received an email from my sister, M. In her email, she pointed out I should not label myself as “hacker”. Well, I could not agree to her opinion so I decided to write this post entry to clear the name for all hackers.
Many people have watched too much Hollywood movies and have developed a perception that hackers are bad guys. They do not understand, nor can distinguish the difference between Hacker and Cracker.
Very well, Hacker and Cracker are like Good Sorcerer and Bad Sorcerer. Hackers are generally referring to a group of programmers or software engineers who dwell into codes of a computer system to find faults or loop holes so that the functionality, usually, security of the computer system can be improved. Hackers are also contributing to many open source device drivers to be used in open source software such as Linux. They study how a device communicates with a computer system without any documentation from the manufacturer (sometimes, some device manufacturers are reluctant to release technical information fearing their competitors may steal their secrets) and write codes to allow the device to communicate with the operating system.
Some hackers visit websites to look for security loop holes and put a file there to indicate their successful hack. Usually, they cause no disruption or damage but to alert system administrator of such security vulnerabilities. One of my website was hacked by hacker from Turkey last week. No damage or disruption caused but simply alerted me of security vulnerability. I quickly corrected the security flaw.
Hackers also study computer codes (binary or source) to learn about a computer software system so to rebuild another similar computer software system for the interest of know-how or to improve the software system. Instead of hacking, reverse engineering best described this type of activity.
Crackers, on the other hand, have the intention to harm or steal. They look for security vulnerabilities to get access into your computer system to cause disruption or steal your information for illicit purposes. Their ultimate goal is to cause damage or to gain something from you to be used for illicit activities, such as stealing your financial accounts or credit cards data for their financial gain.
There are many hacker organizations, for instance, BlackHat. It holds many international technical conferences and training around the world to improve information security.
Laypersons who do not understand the meaning of hacker generally think hacker is a bad guy. Being a hacker myself (sometimes), I just want to clear the name for hackers. And to show the good nature of a hacker, please read here and here.
IP Flooding
I am experiencing IP flooding on my router. It notifies me by email about this attack. Right now, I have identified the source and hopefully I can nail this attacker soon. This is not the first time I experience IP flooding. I have received quite many email notifications in the past 3 weeks but I was out. It is coincident that I am still at my computers solving some server problems.
SVN setup
I’ve finally found time to setup svn at my home net after so many months. My svn server was down when my previous Linux box was down with a dead hard disk last year. The setup was quite a brisk. I had everything installed and configured last night. The test for remote access using a url was successful. I could import, checkout and check in. Because it was already late, about 1AM, I felt rather tire and went to bed.
This morning, I hacked some codes to provide a rather informative post commit email notification. All are done except the check in will stall. It takes a long time (and possibly hang!). I have yet to fully test before I begin my development project again.
Lost your password?
There goes year-end and you need to prepare your new year budget. You retrieve an Excel budgeting file to work on. You have not been touching this file for a year and you encounter problem. You can’t remember the password to unlock the Excel file. You can’t recall where you have written down the password either. You need to do the budgeting for first review in the board meeting tomorrow. What should you do?
You need a Excel password recovery software. It is an easy to use software to unlock the password for Microsoft Word, Excel and Access. Password-Studio Pro cracks the password from instantly to within minutes. It uses Smart Dictionary and Bruteforce hacking methods. With Smart Dictionary, it checks through 5.8 million common password combinations in a matter of minutes.
Password-Studio Pro cracks your password as easy as 1-2-3. First, start the wizard. Second, select an attacking method. Third, reap your rewards.
Steganography and Information Security
One of the major threats in this information age is the exposure of sensitive information in the Internet. The most common method of securing information is through encryption technology. Today, 128-bit technology is the commonly used encryption method in emails and documents. Recent upheaval as my ISP closing down port 25 for SMTP (Simple Mail Transfer Protocol) has rung an alarm to my computing needs on the Internet. My ISP’s decision is to curb spammers who have abused direct SMTP access to email servers. The act is a foolish one as this will not stop spams but at the same time, it affects those genuine users.
A 128-bit encryption can be broken into with cluster computer. A cluster computer consists of computers, called nodes, with one or more CPU. These computers are connected to a network. A special program capable of distributing calculation tasks to all the nodes is needed. This architecture is called Beowulf. Breaking a 128-bit encryption is just a matter of time depending on the number of nodes and the number of CPUs on each node.
My ISP forces all direct SMTP connection to be routed to an unsecured proxy server. As an emergency contingency to my Internet use, I quickly setup encryption for my email client. So far, the closing of port 25 has not affected me.
As I have the need to send sensitive work information across the Net, I feel the encryption is not enough on a unsecured proxy server. I would elevate the level of information security by using steganography together with encryption.
Steganography is a technique to embed information to a digital photo or picture without altering the photo or picture at eye level. The technique uses advanced algorithm to manipulate bits of data in the digital image with the bits from the information I am going to send. To extract the information from the encrypted digital image, an original image is the key. Only my intended recipient has an original copy of the digital image.
Information Forensics
What is information forensics? Information forensics is a science of investigation into systemic processes that produce information. Systemic processes utilize technology, primarily computing technology, in creating, delivering, storing, evaluating and processing of information. This process is usually complement by manual process. Information forensics investigation dwells into the aspect of creation, operation and evolution of the enterprise information.
My first exposure to information forensics was during my project seeding at UTAR. Dr. Robert Tee was a good friend of mine and he exposed me to information forensics. Although we did not dwell too much deeper into it, I did some research myself and practice it. I provide Information Security Assessment Service to my clients on demand basis.
Information forensics is also very useful for SEO (Search Engine Optimization). My current SEO effort has fully utilized my skill in information forensics investigation to optimize my blog search results on search engines. I also utilize this skill to investigate the visiting patterns of my visitors by cross-referencing their IP addresses from various sources, visiting destination, search criteria, and other interests. From this information, I can have a deeper understanding of the visiting habits of my visitors and identify their search interest. To date, I have identified some spammers and reported them.
I am amazed how information forensics investigation helps me in SEO. If you would like more information about SEO or ISAS services, please visit here.
HOWTO – SCIM and Ubuntu Gutsy Gibbon
Ubuntu 7.10, code named “Gutsy Gibbon”, has been released. I just finished upgrading from Feisty Fawn (7.04) to Gutsy Gibbon. The upgrade (downloading, unpacking, removing, installing, configuring and cleaning) took about 6 hours to complete.
The upgrade was smooth and without any problems except it broke my scim. I have exhausted the search on Internet for a fix but was disappointed. So, I tried to experiment with a few methods based on the information I had on the Internet and came up a work around for this problem.
Referring to my Chinese Input HOWTO here, I assume you have installed scim in Feisty Fawn (7.04) and later upgraded to Gutsy Gibbon (7.10).
- Goto System -> Preference -> Sessions. Delete the “Input Method” as created in my previous HOWTO.
- Uninstall and install again scim and all suggested packages.
- Click on menu: System -> Preferences ->Sessions
- Click Startup Program Tab then [New] button.
- Name: Input Methods
- Command: scim -d
- Click [OK] button
- Logout and login again.
- Go to System -> Administration -> Language Support
- Select your language(s) support. In my case, Chinese and Japanese.
- Check the box at the bottom, Input Method, to activate complex characters input. Apply, uncheck it, apply and check again and apply then quit.
- Restart Language Support to make sure the box is checked.
- Logout and restart your system.
- Login and launch any application, e.g. gedit or Terminal. Right click and select “Input Method” and check “SCIM Input Method”.
- Now click on the “Input Method” tray icon on the top left of your screen to choose your desired language support and input method.
Now, you should be able to switch input method in some applications such as Terminal or gedit. It still does not work on every applications such as Open Office. To activate scim for every applications, use the command line (or Terminal):
- Check your locale:
$ locale | grep LANG=The answer would be something like below, which is in my case:
LANG=en_US.UTF-8 - Now, with the following command, insall scim-qtimm and tell your system you want to use scim for your input method in your locale:
$ sudo apt-get install scim-qtimm $ im-switch -z en_US -s scim - Logout and login again and start Open Office. You should now able to select your input method in every applications.
This should also work (with instructions from my previous post here) if you have a fresh installation of Gutsy Gibbon. Please let me know if this works for you.
HOWTO – Building GtkAda project with xcode
My current project (here) requires to develop a GUI application for displaying some JPEG images. I intended to develop a native Mac OS X GUI application using Carbon or Cocoa. Since there is no Cocoa binding in Ada, I narrowed down my option to Carbon. I hit on the wall of frustration where Carbon binding on MacAda.org is very old and supports only gnat-3.3 and PPC (I hope I am not wrong on this).
I have to turn to Gtk+ which will require GtkAda and X11 on Mac OS X. I compiled my test code written for GtkAda very well on console. But when I imported the codes into xcode project, it did not compile. I got the following errors:
error: "gtk.ads" must be recompiled ("a-except.ads" has been modified)
error: "gdk.ads" must be recompiled ("a-except.ads" has been modified)
error: "glib.adb" must be recompiled ("a-except.ads" has been modified)
error: "glib-object.adb" must be recompiled ("a-except.ads" has been modified)
error: "glib-type_conversion_hooks.adb" must be recompiled ("a-except.ads" has been modified)
error: "gtkada.ads" must be recompiled ("system.ads" has been modified)
error: "gtkada-bindings.adb" must be recompiled ("a-except.ads" has been modified)
error: "gtkada-c.adb" must be recompiled ("system.ads" has been modified)
...
I sought help from GNAT-OSX mailing list (September 2007 archive), but to no avail. I spent many days investigating the cause but to find out that gtkada source codes would be compiled and produced .ali and .o files in the build directory when I used gnatmake to build my GtkAda application.
$ gnatmake testproject.adb `gtkada-config`
To build a GtkAda project in xcode, follow the instructions below:
- In the project browser, under the Group & Files column, locate Targets and the your project name. Right click your project name and select Add Link Binary With Libraries. Select GtkAda libraries from /opt/local/lib/gtkada and necessary libraries from /opt/local/lib.
- Select your project name and click on the Info button. In Build tab, select Search Paths under Collection. Include /opt/local/include/gtkada in Header Search Paths. Also include /opt/local/lib and /opt/local/lib/gtkada in Library Search Paths.
- Select Source in your project. Select Add to Project … in Project menu. Include all the GtkAda source files in /opt/local/include/gtkada.
HOWTO – Installing gnat-4.3 on Mac OS X
Perhaps someone has written this before but it seems no where to be found. So I just write a simple HOWTO about installing gnat-4.3 on Mac OS X.
My installation is on MacBook 2.16GHz Intel Core 2 Duo running Mac OS 10.4.10 with Xcode 2.4.1. Pre-requisition is to have Xcode installed before installing gnat-4.3.
- Go to MacAda.org to download gnat-4.3 and other necessary tools. Launch the installation in the disk image.
- Make the following softlinks:
$ ln -s /usr/local/ada-4.3/bin/gcc /usr/bin/gcc-4.3 $ ln -s /usr/local/ada-4.3/bin/g++ /usr/bin/g++-4.3 - Launch gcc_select:
$ sudo gcc_select 4.3


Listen to my podcast