19 December 2007

Canon ImageRunner and Ubuntu

We have gone away from individual departments printers with a centralised printer/photocopier/scanner device. We chose Canon's ImageRunner 3300 as our solution. Installing the printer drivers for Windows was easy. Installing it on Ubuntu was even easier - no drivers necessary.

1) Select System / Administration / Printing.
2) Click on "New Printer". This would take about 10 seconds before this screen appears:

As it scans the network for available printers. The Printer I wanted was the Canon iR3300.
3) Clicking "Forward" would display the available drivers.

The Manufacturer was automatically selected, but the model was not. There was is an entry for imageRunner 330s which I selected.
4) Clicking "Forward" again was a screen for descriptive information for the printer.

Its not entirely necessary to fill it in...
5) and finally, when the "Apply" button is clicked, the new printer is displayed:

And the printer is immediately available! The test print worked, and a spreadsheet from OpenOffice.org Calc worked. Duplex (double sided) printing also works.

So that was relatively straightforward!

However, now Id have to figure out how to get the network scanning feature to work ...

yk.

How to make nice looking diffs

I was wondering how to make nice looking diff patch files yesterday, as using "diff " gave really cryptic outputs and not very user friendly. I IM'ed Aizat who happened to be online in Chile. He just said use "svn diff". I told him that I was working on files local on my machine, so svn was not appropriate.

Googling didn't help much. So I just submitted the standard diff output as my patch.

Then this morning, Ow had a blog post about his patch, and he included his command line. The answer is "diff -Nau"!

So here is the patch for the archivemail-dspam script:

yky@x1407:~/dspam$ diff -Nau archivemail archivemail-dspam
--- archivemail 2007-12-18 19:13:34.000000000 +0800
+++ archivemail-dspam 2007-12-18 19:02:47.000000000 +0800
@@ -187,6 +187,8 @@
min_size = None
verbose = 0
warn_duplicates = 0
+ """ 071218 yky DSPAM-Confidence setting """
+ spam_confidence = 0.00

def parse_args(self, args, usage):
"""Set our runtime options from the command-line arguments.
@@ -206,7 +208,7 @@
"filter-append=", "pwfile=", "dont-mangle",
"archive-name=",
"preserve-unread", "quiet", "size=", "suffix=",
- "verbose", "version", "warn-duplicate"])
+ "verbose", "version", "warn-duplicate", "spam=" ])
except getopt.error, msg:
user_error(msg)

@@ -256,6 +258,8 @@
self.verbose = 1
if o == '--archive-name':
self.archive_name = a;
+ if o == '--spam':
+ self.spam_confidence = float(a)
if o in ('-V', '--version'):
print __version__ + "\n\n" + __copyright__
sys.exit(0)
@@ -265,7 +269,7 @@
"""Complain bitterly about our options now rather than later"""
if self.output_dir:
check_sane_destdir(self.output_dir)
- if self.days_old_max <>= 10000:
user_error("--days argument must be less than 10000")
@@ -661,6 +665,7 @@
--include-flagged messages flagged important can also be archived
--no-compress do not compress archives with gzip
--warn-duplicate warn about duplicate Message-IDs in the same mailbox
+ --spam=FLOAT SPAM Confidence levels ( e.g. 0.80 )
-v, --verbose report lots of extra debugging information
-q, --quiet quiet mode - print no statistics (suitable for crontab)
-V, --version display version information
@@ -737,6 +742,22 @@
mbox_from = "From %s %s\n" % (address, date_string)
return mbox_from

+
+def get_spam_confidence(message):
+ """Returns the DSPAM_Confidence from the message headers. Zero by default"""
+ """ 071218 yky Created """
+
+ assert(message != None)
+
+ for header in ('X-DSPAM-Confidence', 'SPAM-Confidence'):
+ confidence = message.get(header)
+ if confidence:
+ confidence_val = float( confidence )
+ if confidence_val:
+ vprint("Spam Confidence: %f " % confidence_val)
+ return confidence_val
+
+ return 0.0

def guess_return_path(message):
"""Return a guess at the Return Path address of an rfc822 message"""
@@ -987,6 +1008,11 @@
return 0
if options.preserve_unread and is_unread(message):
return 0
+
+ # 071218 yky Filtering by SPAM Confidence
+ if (options.spam_confidence > 0) and (options.spam_confidence > get_spam_confidence(message)):
+ return 0
+
return 1


@@ -1019,7 +1045,7 @@
max_days -- maximum number of days before message is considered old

"""
- assert(max_days >= 1)
+ assert(max_days >= 0)

time_now = time.time()
if time_message > time_now:


Thanks Ow!

yk.

18 December 2007

Making Archivemail work with DSpam

Ive got an dspam "appliance" where the enterprise emails filter through. I've set it up so that only one dspam user is used to filter all the emails. This has worked well over the past few years, but managing it has been quite a chore. Every morning, I'd have to wade through the emails in the quarantine (about 15K), and free up any False Positives which were caught.

Beyond the 58% spam confidence as reported by DSpam is pretty much spam. Below that, between the 47% - 57% there may exist one or two False Positives.

After freeing them up, deleting the remaining emails is a huge chore, because the DSpam UI will not allow deleting the quarantine file when new spam pops in.

So I needed a little program which would scan the quarantine mbox file and delete off any messages which are 58% or higher spam confidence.

I tried the most obvious program called 'archivemail', which was readily available in all distros, but was disappointed that it only allowed filtering on the messages age. There was a mysterious "Filter" switch but it only applied to IMAP mailboxes.

The great thing about this is that archivemail, like the entire emailling stack on my servers, is its completely Free Software. I just had to invest some time to look at the code. archivemail lived in /usr/bin/. I had a look at the file, and its a very small 1500 line python script!

I haven't programmed in python before, but looking at the code, it didn't look too scary. It had classes, but no colons. Indentation seemed to be important here. I scanned the code, and I found the little function called "should_archive(message)". And sure enough, the crux of the logic which defines whether a message is to be archived away or not, was there.

So I added this line:
if (options.spam_confidence > 0)
and (options.spam_confidence > get_spam_confidence(message)):
return 0
And modified the options class to include the spam_confidence field. Did some modifications on the code to read in the command line options, and then had to create the section which extracts the spam confidence from the message headers. Doing this was relatively easy, because the rest of the code basically does the same things: reading things off the headers and using the information. So my new function looked like this:

def get_spam_confidence(message):
"""Returns the DSPAM_Confidence from the message headers. Zero by default"""
""" 071218 yky Created """

assert(message != None)

for header in ('X-DSPAM-Confidence', 'SPAM-Confidence'):
confidence = message.get(header)
if confidence:
confidence_val = float( confidence )
if confidence_val:
vprint("Spam Confidence: %f " % confidence_val)
return confidence_val

return 0.0
Thats it!

I also set some cronjobs to run against the quarantine file; to kill 88% and above spams every hour, kill 58% spams after 3 days, and kill the rest if they are more than 14 days old.

I then followed up with my corporate responsibility duties, and submitted the patch back to the archivemail project in sourceforge. This didn't take me long, and it is worth while whether they accept it or not. At least the source is available online.

I hope this helps other dspam admins out there too!

yk.

22 October 2007

Gutsy Gibbonized

Started the command line upgrade process on Friday, with all the packages downloaded from the pretty fast Taiwan mirror site (averaging at about 50kBs). I left it to download for about 5 hours. When I was done at work, it started unpacking the packages. Because my home is not far from the office, I just picked up the laptop and let it continue its installation all the way home.
About an hour later, the laptop was ready to be rebooted.
Restarted the machine, and waited in anticipation. The boot screen flicked to the text console (as normal, because fsck always has something to say about my two FAT32 partitions), and after that, blackness...

Uh oh... problems with X. The keyboard was non responsive (Caps Lock didnt toggle the LEDs), so the only alternative is to reboot into the recovery state.

Good chance to test out the bulletproof X, I thought, so I renamed /etc/X11/xorg.conf to something else, and rebooted. This time it worked, except that after logging in, the brownness of ubuntu changed to the harshness of raw X (cursor and all). Then the computer hung there for quite a while. I broke into another console (Ctrl-Alt-F2) and tried to dig around, but after about a minute, the familiar sounds of the ubuntu drums indicated that things were ok again. (Ctrl-Alt-F7) brought back the familiar gnome desktop.

But things were very different. Windows were very slow. Scrolling through webpages was actually painful! It was like running Windows XP without the appropriate video card drivers. I downloaded the new displayconfig-gtk tool to set the "Screen and Graphics Preferences", which created a new xorg.conf file. That didnt help much either. I tried using some settings from my fiesty xorg.conf, but certain Options would kill X (blank black screen).

Did a google, and found this: "ATI Radeon 9200 extremely slow in Gutsy" which described my situation to the dot. One recommendation is to disable Xgl, which is not a default install. To do so, do this:

touch ~/.config/xserver-xgl/disable

Make sure the "xserver-xgl" directory is created as well, because usually it isnt.

Rebooting made the performance of 2D X similar to the fiesty days.

Things are still not entirely back to normal: my Mighty Mouse is not scrolling sideways, and compiz isnt working. Need to allocate some time to dig into xorg.conf yet again. Also the timelag between logins and desktop appearing is very annoying.

yk.

[Update: I just found out that my xorg.conf was removed because in an hour of desperation, I tried to install the ATI proprietary drivers, fglrx. One of the steps involved was running aticonfig --initial, which clobbers the xorg.files. That core dumped and I gave up on that. So I have been running without an xorg.conf file all this while. So bulletproof X really works, and part of the delay in showing the gnome desktop was because of this.

My xorg.conf from fiesty still gives a dead black screen on bootup, so I have to work on a cut down version. I will have to slowly work on this to get my dual screen back up. Wonder how easy that would be ... ?]

16 October 2007

Driving License extended

Ow has an interesting factoid. When we met at aizat's birthday a few months back, he said that someone in a room of 10 is bound to have a driving license expired, or close to expiring. And true enough mine was going to expire (then) on the 2nd of October. Of course being the serial procrastinator that I am, I subsequently forgot about renewing it.

On the 4th of October, two days after the expiry, I checked the JPJ website and noticed that there is a 'CDL Renewal Online' feature hosted by a third party, MyEG.com.my. Throwing caution to the wind, I decided to test it out. I filled in my details, paying by Credit Card, and submitted the information.

I opted for a 5 year extension (RM150) and for the new license to be delivered to my office (RM5). MyEG seems to be charging RM2 for the service, which sounds fair. But considering the income generating nature of JPJ, citizens should expect service as this to be completely free. Additionally any form of automation would reduce overheads for JPJ.

At the end of it all, you get a official looking receipt with all the JPJ logos and all:

I double checked this by going to the main site, and clicking on 'License Expiry Date Inquiry' tab. The interface changed from English to Malay (because the URL seems to be hardcoded with the language settings). I punched in my IC number, and this is what I got:


Confirmation of a 5 year extension! I was still skeptical of the renewal because it seemed all too effortless. Additionally, my recently expired license is already 10 years old, and the picture of me was taken another 10 years prior.

So I waited for a few days... 7 days in all. I received a Registered Post letter from JPJ, which enclosed a laminated card stating that my old license indeed has been extended for another five years. This extra card (which they call a 'Slip') is 'To Be Produced With Driving License'. It makes my wallet marginally thicker, but I guess its a fair trade for an afternoon of bureaucracy.

Overall, I was impressed with this. Seems like a small thing to most IT enabled countries where doing things online is of the norm. But when Ive been disappointed with the online services in Malaysia so many times todate, I guess my standards are far lower.

Here are some points for JPJ to improve on:
  1. Do not hardcode the IP address of the servers on the website. Its currently now pointing to '202.190.64.96'. It makes linking directly to your services difficult especially in the future when you change your servers.
  2. Someone messed up with the sidebar links. Remove the '/lang,ms/' option in the URLs. This forces the language to flip from English to Malay on subsequent clicks.
  3. Its unnerving to be moved to another site, and another window when clicking on the CDL extension. Make it clear that MyEG is a trusted partner or embed the payment page within the main JPJ site. It would be alot better if this feature was seamless to the user.
  4. Don't making using the online service any less attractive to drivers. There should not be any additional costs (RM2). In fact online applications should be encouraged, and there should even be a small rebate.
Because only 5 people will read this blog post, I cannot guarantee that one of you will have an expiring or expired license. But if you do, you'd be glad to know you can now renew it online.

yk.

12 October 2007

Filename Dater v1.1

Since the release of my Filename Dater, I have implemented a few additional features for version 1.1:
  1. Added an option for timestamps to be incorporated into the filename
  2. Uses the Registry to remember the Path and options set
  3. Made the filetypes user definable
  4. Minor UI cleanups
Ive also made sure that the program works well under Wine, and here it is running in Ubuntu:

Thanks to the Malaysian FOSS guys, you can download the file from foss.org.my (565KB Windows Executable)

yk.

20 September 2007

Preserving time stamps on FAT32 copies

Strange thing about accessing FAT32 in Linux is that you get annoying warnings when manipulating the date and times of files. cp, tar and mv all raise wierd errors when doing the most basic things.

I especially needed to move some photos to my FAT32 mount, with the specific intention of retaining the file creation date and times. The correct command is "cp -p" where the "-p" flag means "preserve".

So we try:

$ cp -rp ../../cdrom/070915 .
cp: preserving times for `./070915/070915_P1250210.JPG': Operation not permitted
cp: preserving times for `./070915/070915_P1250211.JPG': Operation not permitted
$ ls -la 070915/
total 5344
drwxrwx--- 2 root plugdev 32768 2007-09-20 17:47 ./
drwxrwx--- 34 root plugdev 32768 2007-09-20 17:47 ../
-rwxrwx--- 1 root plugdev 593386 2007-09-20 17:47 070915_P1250210.JPG*
-rwxrwx--- 1 root plugdev 596410 2007-09-20 17:47 070915_P1250211.JPG*

The problem here is that the file creation date should be sometime on the 15th of September. NOT today. Did a google, and it brought me to this nugget of information:

This forum post:
if your own user id does not match the 'virtual' user-id, cp can not change the file date back to file date the source file.

The solution is clear - find out your user id (XXX), mount the partition with uid=XXX, and all the files on that partition belong to you - even the newly created ones. This way cp -a can set the original file date.

This works, of course, only for ONE user (and root).
So I changed the /etc/fstab file. Im quite disturbed by the new UUID usage instead of the ole fashioned /dev/hda access:

# Entry for /dev/sda5 :
UUID=41BD-AB60 /media/M vfat defaults,gid=users,utf8,umask=007 0 1

to

UUID=41BD-AB60 /media/M vfat defaults,uid=1000,gid=users,utf8,umask=002 0 0

Please note the changes in bold. A quick remount:

# umount /media/M
# mount -a

and copy:

# cp -rp ../../cdrom/070915 M/Photos/

Gives us:

# ls -la M/Photos/070915/070915_P1250210.JPG
-r-xr-xr-x 1 yky users 593386 2007-09-15 09:47 M/Photos/070915/070915_P1250210.JPG*

woohoo!

yk.

Domino PCs!

14 September 2007

Easily changing theme colours in Drupal

I like the "Garland" theme for Drupal. Its nice an elegant. However I needed to change the hues to represent a certain corporate colour. What I accidentally found while browsing through the CSS files was there there was some "preset" colours.
Intrigued, I did a google search and was pleasantly surprised to find that the Garland theme in Drupal allows easy changing of colours just by clicking on colour wheels! "How to change colours on the Garland theme". Theres even a nice screencast by the author.
However, when I went to "Administer >> Themes >> Garland-configure", I couldn't see the colour pickers as the screenshot above.

So I checked "Administer >> Modules" to double check that the Colors module was installed. And it was.

Checked "Administer >> Logs >> Status Report" and saw that the GD Graphics Library was also installed. All OK.

Then finally, "Administer >> Site Configuration >> File System" must have its "Download method" as "Public - files are available using HTTP directly."

Once that was selected (which it wasn't), the Colour pickers appeared!

[Drupal could improve by telling its admins what to enable to get the pickers to appear]

I changed the colours, and the onscreen colours changed immediately. However, when I clicked on "Save", my new colours refused to save, and it complained that PHP required 2.4MB more memory!

Strange, I checked the computer's memory, swap and harddisk and found no shortage. This link however says that its a PHP setting. /etc/php.ini, under the ; Resource Limits section. I changed it from 8MB to 18MB.

memory_limit = 18M ; Max amount of memory a script may consume

Once that was changed, the new colour scheme worked like a charm. This page "Integrating the Color Module" describes in detail how Drupal uses a PNG template, the GD library to create the nice gradients, and the PHP calls to slice up the images to create the templates for use. Quite fascinating.

yk.

11 September 2007

Move over Spock




You Are Incredibly Logical



Move over Spock - you're the new master of logic

You think rationally, clearly, and quickly.

A seasoned problem solver, your mind is like a computer!

Mighty Mouse Wired!

After trying out the bluetooth MightyMouse, I went to look for a good deal online. I decided against getting the bluetooth model because my laptop doesn't have a built in bluetooth adaptor. Plus I didn't want the hassles of batteries and such.

I did find a good e-bay seller, so I bought a few to bring down the shipping costs. All in all, it was about RM100 for each mouse. Quite a bargain compared to the Mac shops at KLCC which sell it for RM199.

Finally, after waiting 11 days of waiting, my Apple Mighty Mouse has arrived! Plugged it in, and it worked off the bat - as a normal mouse. Left click, Middle click, Right click all ok. Vertical scroll is smooth and accurate. Laser light shows a picture of a mouse too. All OK!

Im now configuring xorg.conf to allow for the horizontal scroll, and this is what you need to do:
Section "InputDevice"
Identifier "MightyMouse"
Option "CorePointer"
Driver "evdev"
Option "Name" "Primax Electronics Apple Optical USB Mouse"
Option "HWHEELRelativeAxisButtons" "7 6"
Option "Buttons" "8"
Option "Buttons" "9"
EndSection
The difference between this Input device and a regular mouse is that the Driver is "evdev". The "Name" should correspond to the name detected by your system. To review, you can check out /proc/bus/input/devices. You should find an entry which looks like:
I: Bus=0003 Vendor=05ac Product=0304 Version=0110
N: Name="Primax Electronics Apple Optical USB Mouse"
P: Phys=usb-0000:00:1d.0-2/input0
S: Sysfs=/class/input/input10
H: Handlers=mouse3 event8 ts3
B: EV=100007
B: KEY=f0000 0 0 0 0 0 0 0 0
B: REL=143
In the xorg.conf, make sure that in the "ServerLayout" Section, you have added a reference to this input device:
  InputDevice "MightyMouse" "AlwaysCore"

Make sure the "AlwaysCore" is there, otherwise the mouse won't be recognised by X.

Restart X (Ctrl-Alt-Backspace), and horizontal scroll should work. You can test with Inkscape.

For Firefox, a little bit more tweaking is required, as the horizontal scrolling of the ball actually maps to the "Back" and "Forwards" button of the browser. As you can imagine, this is "very irritating."
So to configure Firefox to behave properly, type in about:config in the URL bar, and edit mousewheel.horizscroll.withnokey.action from "2" to "0".

Immediately, (Firefox restart not required) you will find that the horizontal scroll will work. Unfortunately, the default direction is reversed! When you scroll the ball to the right, the page goes the the left and vice versa. Very disorientating and worthy of a prank in the future.

To fix this, change mousewheel.horizscroll.withnokey.numlines from "-1" to "1". This will reverse the direction to normalcy.

Compared to the bluetoothed Mighty Mouse, Wired Mighty Mouse is alot lighter, and easier on the wrist. Compared to my trusty old Logitech M-BJ58, the weight is about the same. However because of the construction of the device, it feels a lot more solid. Only time will tell how long the infamous Apple plastic will hold up.

Already Im addicted to the scrollball in moving around web-pages effortlessly. Looking for the scrollbars and aiming is now a thing of the past!

As mentioned above, I ordered a few Mighty Mouse from the seller. So I now have a couple of Apple Mighty Mouse to be resold. If you are interested, contact me. First come first serve, while stocks last, blah blah blah. RM100. A whopping 49.7487% discount! What-a-bargain. Works extremely well with your free desktop.

yk.

4 September 2007

Indexed

Im a big fan of Jessica Hagy's indexed cards of venn diagrams, graphs and connections. Todays edition is the best of all - "Plays well with others":


yk

3 September 2007

Headphones

Check out this picture:

Microsoft Netmeeting is so revolutionary! Skype eat this! Hehhehhhh!

Its so scary on so many levels. This is Steve Ballmer. He is the top guy at Microsoft. He seems to be thrilled at something to do with video conferencing. Look at his face in glee. Even when he's happy, he's scary. But look closely at the picture. The headphones dont seem to be big enough for his smooth big head. That is because the top dog at a high tech company doesnt know how to wear one of these. It should actually be worn like this:

I wonder if the staffer behind him had the guts to tell him how to put it on properly? Maybe it actually works by reverberations on his dome? Or when you are at his level, you dont really need to listen anymore. Just shout your commands. Tear some vocal chords.

yk.

28 August 2007

Apple Mighty Mouse

I managed to get my grubby little hands on a Apple Mighty Mouse. Its the bluetooth version. What enthralled me was the little scroll ball. I guess in my old age, Im finding using a scroll wheel inaccurate for small increments and tiresome for long pages. When I tried the Mighty Mouse at the new Mac shop in KLCC, I was won over.
So on my ubuntu machine, I plugged in the bluetooth dongle. On the command line I typed in:

# hidd --search

The Mighty Mouse blinked, and on screen, the taskbar displayed this popup:
Clicking on it will display this dialog:
And the default passkey for the Apple bluetooth Mighty Mouse is "0000".

Infortunately the command returned this error:
# hidd --search
Searching ...
Connecting to device 00:14:51:C4:55:71
HID create error 13 (Permission denied)

Which was strange. I could only use the root login to successfully pair with the mouse.

However once paired, the mouse worked like a charm. The scroll ball was smooth and extremely efficient. However I can't seem to get it to scroll horizontally. Perhaps its not supported yet?

The three button feature of the Mighty Mouse was ok, although disconcerting considering the entire upper body of the mouse is one big button. Im finding the weight of the device heavy. I hope it doesnt lead to RSI in the future.

Im looking for a good mouse to use at work. Considering Im on the PC 80% of the time, Id wont mind investing in a really good mouse. I don't really need the bluetooth feature, and I noticed that the Mac shop was selling the USB version for RM199. The American e-bay sell them at USD29 but shipping is about USD20 = USD49 = RM171. Hardly worth the savings.

Still undecided. I wonder if there are any other mice out there with the same scroll ball?


yk.

[Update: Info on getting horizontal scroll here ]

23 August 2007

Adjusting your swap files

I have a small Xen server which wouldn't start up with a swap partition. Whenever I add it in, it gives a strange error. Something which Ill have to figure out one of these days.

However its not a big deal, because its easy to set up a file based swap file in linux anyway.

First thing is to create the file to allocate disk space for it, for this case I just need a 500MB swapfile:

# dd if=/dev/zero of=swap.file bs=1M count=500
# chmod 600 swap.file
# mkswap swap.file
Setting up swapspace version 1, size = 524283 kB


Next is to make sure that it gets used at each bootup.
# cat >> /etc/fstab
/mnt/data/swap/swap.file none swap sw 0 0


but if you need it now, you just use 'swapon':

# free | grep swap
Swap: 0 0 0
# swapon /mnt/data/swap/swap.file
# free | grep swap
Swap: 511992 0 511992


and if you do a top,
top - 17:13:31 up 1 day, 6:57, 1 user, load average: 0.02, 0.03, 0.00
Tasks: 53 total, 2 running, 51 sleeping, 0 stopped, 0 zombie
Cpu(s): 0.0%us, 0.0%sy, 0.0%ni,100.0%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st
Mem: 257024k total, 251808k used, 5216k free, 1036k buffers
Swap: 511992k total, 0k used, 511992k free, 183108k cached


Nice swap!

You can dynamically change the size of your swap files using swapon / swapoff combos.

yk.

16 August 2007

Amir Hafizi: gone

Amir Hafizi's blog was certainly entertaining. Unfortunately because he simply "felt like it", he has deleted all the content and is leaving it blank. What a pity. With no hint to what he's working on now, it will definitely be harder to look for his material.

The wayback machine only has 8 pages archived in 2006.

Long Live Amir Hafizi.


yk.

14 August 2007

GeoGebra


This is such a nice Maths package. It almost makes me wish I was back in school. ALMOST. Instead of plotting my own graphs, drag and dropping mathematical objects on a virtual graph paper would be so cool. What is different from a CAD software where drawing primitives, tangents, perpendicular lines and measurements are available, GeoGebra actually provides the equations to create the objects.


For example, drawing a like between two points will give the equation y = 0.27x + 4.27. Additionally on right clicking and going to properties, you can set the equation type to ax + by = c. Otherwise, parametric form.

Drawing circles is very easy. What is interesting about this graph editor is that its like a modern parametric CAD app. Because each primitive is based on specific points, when you modify the points, the object will change in real time. This is especially interesting when you have different tangents, angles and related objects linked to one point.

The application is java based, so its platform independent. I used the webstart version which would automatically download the latest version, or otherwise load up from the Java cache.

Whats nice about this app is that it doesn't look cludgy like most Java apps do. The lines are anti-aliased which gives it a very professional look, and the interface is quite responsive. The primitives respond to mouse overs well. However there are issues with the "drop down" buttons. I tend to need just one more click and pause before more selections appear.

The project overall is well developed, and appears to be well funded by the Austrial Academy of Sciences (2004-2006), Austrian Federal Ministry for Education (2006-2007) and US National Science Foundation (2006-2008). Additionally it has support from University of Salzburg and University of Luxembourg.

Eventually when Id have to tutor my kids maths, I hope this project includes other features like parabolic curves and other amazing mathematical beauties.

Update: There are parabolas! At the bottom of the screen, type in Parabola[ , ] (e.g. Parabola[ G, f ] ) and GeoGebra draws it in. Nice! Not sure why its not available in the button menus.

yk.

11 August 2007

Making X fast(er)

I always wondered about my sluggish OpenGL performance. I just attributed it to the poor support of my ATI Radeon Mobility 9200 in Linux. Im still using the "radeon" Open source drivers and not the fglrx binaries from ATI.

One "random" thread suggested to add a ModeLine entry in /etc/X11/xorg.conf file. So I tried. I generated my ModeLine entry using this online calculator: "The XFree86 Modeline Generator: create the mode thats just right for you!"

In the Basic Configuration, I just entered in the resolution of my Laptop LCD, which is "1680x1050" and put in the refresh rate of 60Hz.
Click on "Calculate Modeline", and this will be generated:
So in /etc/X11/xorg.conf, update the "Monitor" section as such:

Section "Monitor"
Identifier "Laptop Monitor"
Option "DPMS"
# 070809 yky - added modeline:
# http://xtiming.sourceforge.net/cgi-bin/xtiming.pl
Modeline "1680x1050@60" 154.20 1680 1712 2296 2328 1050 1071 1081 1103
EndSection

You dont need to reboot your computer. You just need to restart X by pressing Ctrl-Alt-Backspace. When you've logged in, you may find X performing better. For example, the tilda application used to be quite jerky as it revealed itself. Now its smooth.

Additionally glxgears used to be a paltry 200-400FPS. Now its an OKay 2000-3000FPS. BZFlag also is now actually playable!

So if you think your X is underperforming, put a ModeLine in and see if theres any difference. Now to figure out why my laptop can't do dual-head/output video.

yk.

8 August 2007

Open Project

Here's a nice cross platform application to do project planning. Maintained by Projity, it claims to be able to open Microsoft Project files. Finding an immediate need to open an old MS Project file, I needed to try it out.

I downloaded the tarball from the sourceforge page, and did this:

# tar -xzvf openproj-beta2.tar.gz
# cd openproj-beta2/
# ./openproj.sh


but I got this error:
Exception in thread "main" java.awt.AWTError: Cannot load AWT toolkit: gnu.java.awt.peer.gtk.GtkToolkit
at java.awt.Toolkit.getDefaultToolkit(libgcj.so.70)
at java.awt.Font.tk(libgcj.so.70)
at java.awt.Font.getPeerFromToolkit(libgcj.so.70)
at java.awt.Font.
(libgcj.so.70)
at javax.swing.plaf.FontUIResource.
(libgcj.so.70)
:
No Java JRE installed. So used this command to install java in ubuntu:

# sudo apt-get install sun-java6-jre
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
java-common odbcinst1debian1 sun-java6-bin unixodbc
Suggested packages:
equivs sun-java6-plugin ia32-sun-java6-plugin sun-java6-fonts ttf-sazanami-gothic ttf-sazanami-mincho libmyodbc
odbc-postgresql libct1
Recommended packages:
gsfonts-x11
The following NEW packages will be installed:
java-common odbcinst1debian1 sun-java6-bin sun-java6-jre unixodbc
0 upgraded, 5 newly installed, 0 to remove and 0 not upgraded.
Need to get 32.5MB/33.0MB of archives.
After unpacking 94.4MB of additional disk space will be used.
Do you want to continue [Y/n]? y
Get:1 http://mirror.nttu.edu.tw feisty/multiverse sun-java6-bin 6-00-2ubuntu2 [26.2MB]
Get:2 http://mirror.nttu.edu.tw feisty/multiverse sun-java6-jre 6-00-2ubuntu2 [6324kB]
85% [2 sun-java6-jre 1544093/6324kB 24%] 106kB/s 44s
Fetched 32.5MB in 3m33s (153kB/s)


Had to agree with some java licenses, and after 5 minutes, all requirements were downloaded and installed. Then I ran the openproj script again, and I could open the old .MPP project which eluded me since my ubuntu migration.

Overall the interface is sluggish, but seems full featured. The fact that I now have access to MPP files certainly is a boon, without having to pay over RM1945 to access my old data.

I found this application via Bob Sutor's recent post, "Project Management via Open Source and Open Standards". What is interesting is that in a Computer World article "Saas rival to Microsoft Project goes open source":
Projity plans to invest “significant resources” into driving the creation of an open standards document format for project management that would be an alternative to the .mpp/.mpx formats used by Microsoft Project, and would eventually become a subset of the OpenDocument Format natively used by OpenOffice and StarOffice.
So what other productivity applications is Desktop Linux lacking? Ive been using Ubuntu for over 3 months now as my main OS, and Ive found that 90% of the things I need for daily usage are available for free.

Whats stopping you?


yk

3 August 2007

MySQL v3.23.52 on Red Hat 8.0

Had to set up an ancient MySQL database. Doncha just love legacy apps? So re-created the db server on Red Hat 8.0, installed the mysql-server rpms. Tested accessing it via localhost without any problems. Loaded in the data from the existing server (on its last legs) via this command:

@threelegs# mysqldump -h legless-server --add-drop-table --all-databases | mysql

Tested that the data was OK via localhost again. The ancient mysql-server v3.23.52 was running fine. Then I tried to access it via another client, and found this problem:

@client# mysql -h three-legs
ERROR 2013: Lost connection to MySQL server during query

Checked the log of three-legs (/usr/libexec/mysqld), and found that the server kept dying:

/usr/libexec/mysqld: ready for connections
Number of processes running now: 1
mysqld process hanging, pid 2762 - killed

Accessing from a more modern client (my ubuntu with mysql client v5.0), I got a more descriptive but just as useless error:

@clientv5.0# mysql -h three-legs
ERROR 2013 (HY000): Lost connection to MySQL server at 'reading initial communication packet', system error: 0

I googled high and low to find a solution for this problem, and was frustrated because google pageranks newer "solutions". So I had to go through many MySQL v5.0 and v4.0 issues before I found this gem. Im hoping that linking to the real solution would help increase its pagerank!

So it seems that glibc has some problems. The work-around is to put this in the /etc/my.cfg file under [mysqld]:

set-variable=thread_stack=1M

Restart the server, and it surprisingly worked! Well this problem haunted MySQL users until v4.0.9. This is why I hate messing about with ancient legacy systems.


yk.

Tilda - Quake on Linux

I just installed this little program called Tilda. Its quite good. If you ever needed a console pronto, and couldn't wait for gnome-terminal to come up, and have good memories of First Person Shooters and invoking the console with tilda (~), try this out.

To install in ubuntu, just type:

# sudo apt-get install tilda

Then launch it using

# tilda -C &

A nice gui interface will help you configure it and it looks something like this:
You can change the keybindings to whatever you so desire, "None+F2" is the default. "None+grave" would be the original (grave == tilda), but may be difficult if you want to go to someone's home directory ( ~user ). So I chose something easy to hit: "Control+grave".

Clicking on OK will load up the tilda interface and it looks something like this:

It appears on the top left hand corner of my screen. Initially it was rather small. So I had to modify the size (in pixels) of the console. You can also do this via the GUI, or if you are in a hurry, on the command line with this command:

# resize -s 60 150

where 60 is the number of rows and 150 is the number of columns. Tilda will automatically resize the input screen (for this session only).

Now if only IDDKFA, IDDQD and nowadays "impulse 101" works in real life!

yk.

2 August 2007

Monkeyboys iZune!

Fantastic Advertisement!




yk

31 July 2007

Little Tricks with Xen images from jailtime.org

Ive been busy setting up a CentOS server. After the successful installation of dspam on our FC5 Xen virtual machine, we have decided to move it from our development server (a frankenstein of a machine) to a proper host. Yes, Ive been testing it for over a year now!

Postfix with MySQL support in CentOS 5

So I downloaded a prebuilt CentOS image from jailtime and installed the necessary tools. A little trick I learnt was the inclusion of the extra repositories. dspam requires a postfix installation with MySQL support. To do this, you can either compile from source, but being the lazy git I am, I'd rather download the binaries.

To do this, you just need to enable the CentOSPlus repositories, which can be done via a command line switch:

# yum --enablerepo=centosplus upgrade postfix

Yum will then work out the requisites and download the stuff for you. Unfortunately it also brings down the postgresql binaries. So unless you are in dire need of hard disk space, don't do it this way.

We aren't in Kansas anymore, Toto

Another thing about the jailtime images is that the hwclock scripts are modified to return 0. This is because there is no hardware clock. It uses the host's (Dom0) time. So to get the correct time, make sure you change the zone information in /etc/localtime. For us users in Kuala Lumpur, I have to do this:

# ln -s /usr/share/zoneinfo/Asia/Kuala_Lumpur /etc/localtime

Keeping it 32bits

My Xen host is a AMD 64 server. My Xen clients are i386 virtual machines. This is for "portability" reasons. My previous post about using yum to install i386 binaries can be improved. Now use setarch. To install:

# yum install setarch.i386

subsequently make sure you run it before yumming some more.

# setarch i386

If you forget and accidentally call yum, mixing i386 and x86_64 info, the downloaded headers will be "confused". You'd have to do a clean:

# yum clean all


yk.

7 June 2007

VMWare and NAT

In my effort to make Ubuntu my single boot desktop, I have VMWare Server to run my Windows applications which I need to use for work. I initially set up the network for the VM to run as "Bridged" where the VM takes on the same network address as my host machine. This is good to start of with, but eventually it becomes a problem when I take my laptop back home, where there is no network to join.

So it would be better if the VM resided in one of the virtual networks within VMWare. When you install VMWare, there are two vmnets:

# ifconfig
...
vmnet1
Link encap:Ethernet HWaddr 00:50:56:C0:00:01
inet addr:172.16.46.1 Bcast:172.16.46.255 Mask:255.255.255.0
inet6 addr: fe80::250:56ff:fec0:1/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:168 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)


vmnet8
Link encap:Ethernet HWaddr 00:50:56:C0:00:08
inet addr:192.168.221.1 Bcast:192.168.221.255 Mask:255.255.255.0
inet6 addr: fe80::250:56ff:fec0:8/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:7105 errors:0 dropped:0 overruns:0 frame:0
TX packets:20943 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)


I chose the VM to have the 192.168.221.x network, and manually fixed the IP in the Windows XP VM, with the gateway as 192.168.221.1 (the linux host). Also configure the "VMware Settings / Hardware / Ethernet 1 / Network Connection" to "NAT: Used to share the host's IP address"

The next part is to allow network traffic to flow freely from the VM through the linux host. To do so forwarding and iptables need to be configured. This page explains the commands quite well.

Ensure that Forwarding is enabled (if not already):
# echo 1 > /proc/sys/net/ipv4/ip_forward

Masquerade all traffic
# iptables --table nat --append POSTROUTING -j MASQUERADE

(I purposely left out --out-interface eth0 because I want it to pass through all devices; if connected to work, via eth0, connected at home via wifi at eth1 and remote via bluetooth dialup at ppp0)

And only forward from the vmnet8 device
# iptables --append FORWARD --in-interface vmnet8 -j ACCEPT

This should allow all traffic from the virtual machines and use the linux host as a gateway.


yk.

6 June 2007

Ops Tulen 2007 - The "promo" continues

This year's Ops Tulen was not as big as last years. Almost no flyers sent via regular mail. Very little threats and scams via emails. I hoped that it was because of the market's backlash against the blatant threats just to push sales.

However today I received the latest, and probably the most brutally honest ad campaign run in this series. No subtle marketing messages here. Just the basics. Scary imagery. Offer of way out. Sell stuff. What a bargain!

Save n' be Safe. Is not a good enough tagline...
... it really should read: Threaten 'n Profit!


Thats right. They used an image of a handcuff. Is it a double-entendre? Are they suggesting that I am engaged in criminal acts ( ... is S&M outlawed)? Or is it a hidden warning against the advertised Microsoft products, which will inevitably handcuff or lock you into the vendor's treadmill of constant upgrades and limited CALs?

Can't they see how insulting it is to receive an "offer" like this? Do you think the advertisers customers would react positively towards this mailer? Is the offer so poor (purchase 6 licenses, get 1 free = a mere 14% discount) that you have to resort to criminal threats? Is Malaysia's reputation in piracy so bad that sending out threats like these are justifiable? Is this how the ICT industry in Malaysia should grow?

Perhaps it was just a rogue Microsoft reseller? Well, judge for yourself. Here is the official June "Shout out" from Microsoft sent yesterday:
Snitches are paid well ...

Microsoft and their resellers should run more constructive campaigns. Educational campaigns on Copyright which educates users on the "ownership" software, benefits of software with support, the importance of a vendor/distributor/reseller channel. Or just proper promotional activities with better bargains adjusted to the Malaysian buying power. Perhaps the piracy rate in Malaysia is higher than in the US because we pay the same amount (if not more) and are less likely to afford the software?

Shame on them for taking advantage of the BSA and Ministry of Domestic Trade, as another excuse to push more licenses. These strongarm tactics are taking its toll on the Microsoft brand, and when the Malaysian public finally realise that there are valid alternatives to these products, there will be very little goodwill or brand loyalty left in to keep us from switching.

Tell your marketeers to grow up!

yk.

24 May 2007

Ubuntu dialup via bluetooth

After using Feisty Fawn, Ubuntu v7.04 for close to a month now, Im happy to report that things are going extremly well. Latest task was to get my e61 to work with my computer so that I can dial up to the internet whenever I dont have access to a wifi spot or wired connectivity.

I have been using a CNet CBD-021 device for over a year now, and it has some nifty tools for Windows XP, with a nice UI "BlueSoleil" which displays connected and available bluetooth devices around the computer. It also provides point and clicky access to file transfers and dial up networking.

However in the Linux world, no such niceities are provided. We have to do things ourselves, unfortunately. So heres what I had to do to get Laptop -> Bluetooth dongle -> Nokia E61 -> Maxis internet connectivity going.

First step is to get bluetooth working. Plug the Bluetooth dongle into your machine. The dmesg should read something like this:
# dmesg
[ 9383.380000] usb 3-1: new full speed USB device using uhci_hcd and address 2
[ 9383.548000] usb 3-1: configuration #1 chosen from 1 choice
[ 9384.356000] Bluetooth: HCI USB driver ver 2.9


This wiki entry for Ubuntu is extremely useful: "Bluetooth Setup" Basically make sure that bluetooth tools are installed:
# apt-get install bluez-utils ppp
# hcitool scan
[Update: 080211 yky: bluez-pin is not required anymore ]

The output I get from this is: 00:12:D1:6C:8F:10 Yk's phone

I set the computer bluetooth key using the bluez-pin utility

I then paired up my phone with my laptop via the e61 interface. Menu / Connectivity / Bluetooth / Paired Devices, exchanging a numeric key to complete the step.

To make your phone a modem, you will need to define it as a rfcomm device. To do so;

# sdptool browse 00:12:D1:6C:8F:11

of which a whole list of services will be displayed. The one of importance is

Service Name: Dial-Up Networking
Service RecHandle: 0x10013
Service Class ID List:
"Dialup Networking" (0x1103)
Protocol Descriptor List:
"L2CAP" (0x0100)
"RFCOMM" (0x0003)
Channel: 2
Language Base Attr List:
code_ISO639: 0x454e
encoding: 0x6a
base_offset: 0x100
Profile Descriptor List:
"Dialup Networking" (0x1103)
Version: 0x0100

Highlighted is the Channel number, and for my case, its #2. So edit the /etc/bluetooth/rfcomm.conf file

rfcomm0 {
bind yes;
device 00:12:D1:6C:8F:10;
channel 2;
comment "Yk's phone";
}

This means that everytime bluetooth is enabled and your phone is detected, a modem device will be created and accessible as /dev/rfcomm0

[Update: 080211 yky: You will now need to restart the bluetooth service with a /etc/init.d/bluetooth restart for the rfcomm0 device file to appear]

The next step is to configure wvdial. This blogpost has some information "pairing bluetooth modem di feisty fawn" Fortunately I can read Indonesian. To configure wvdial to dialup to maxis, the configuration for /etc/wvdial.conf is:


[Dialer Defaults]
Phone = *99#

Username = maxis

Password = wap

New PPPD = yes
Dial Command = ATDT
[Dialer E61]
Modem = /dev/rfcomm0
Baud = 460800

Dial Command = ATDT

Init2 = ATZ

Init3 = ATM0

Init4 = AT+CGDCONT=1,"IP","unet"

FlowControl = crtscts
Modem Type = Analog Modem


Note the Init4, username, password and phone number have been modified, as described in "Using a phone as a modem" from maxis themselves.

You should now be able to dial into maxis by typing:

# wvdial E61
--> WvDial: Internet dialer version 1.56
--> Cannot get information for serial port.

--> Initializing modem.

--> Sending: ATZ ATZ OK
--> Sending: ATM0
ATM0 OK
--> Sending: AT+CGDCONT=1,"IP","unet"
AT+CGDCONT=1,"IP","unet" OK
--> Modem initialized.

--> Sending: ATDT*99#

--> Waiting for carrier.
ATDT*99# CONNECT
~[7f]}#@!}!} } }2}#}$@#}!}$}%\}"}&} }*} } g}%~
--> Carrier detected. Waiting for prompt.

~[7f]}#@!}!} } }2}#}$@#}!}$}%\}"}&} }*} } g}%~
--> PPP negotiation detected.
--> Starting pppd at Thu May 24 16:37:43 2007

--> Pid of pppd: 30491
--> Using interface ppp0
--> local IP address 58.71.246.115

--> remote IP address 10.6.6.6
--> primary DNS address 10.213.17.1

--> secondary DNS address 10.213.17.2


Unplug your cables, shutdown your Wifi, check your route tables. Confirm to yourself that your internet access is being provided by your phone. Rejoice.


yk.

25 April 2007

Ubuntu: Feisty Fawn

I managed to download ubuntu Feisty Fawn from the Taiwanese servers and got it relatively quickly. I installed it last Friday, and have been using it for a few days now and Im glad to say its pretty good!

First off, the installation process was OK, although it b0rked slightly while doing a Windows document migration. I just clicked cancel and it went away. Just slightly disconcerting.

After installation, I went into System/Preference/Desktop Effects, and immediately enabled compiz. Magically, it started up immediately, and it worked out of the box without me having to install any other drivers for my laptop's ATI Mobility Radeon 9200. Wobbly windows galore!

note: nice drop shadows, transparency on background windows and frames

Not wanting to miss out on the new eye candy, I installed beryl following these instructions: 3D Desktop (Beryl and Xgl) on Ubuntu Edgy Eft with ATI card
Installation, as I have now taken to expect, was a breeze. Synaptic is very nice. I just wish it would download files in parallel, and/or change to faster mirrors on the fly (ala Download Manager).

Beryl Settings and its Emerald Theme manager are extensive. There are a whole load of gizmos to test out and modify. Changing the drop shadow blur, the K factor in the wobbly windows, how windows minimize and appear, and whether to have over-the-top effects is addictive, and can waste a good hour or two of your life. Beware.

The other things I have done in making myself at home is to leverage on Google's tools to self integrate in the many different platforms. The Google Browser Sync for Firefox makes sure that my bookmarks and cookies are stored outside my Windows and Linux partitions. Ive also had to download my must have Add-ons, Mouse Gestures, PermaTabs, Google Notebook and Chatzilla.

I have Lotus Notes installed, running on CrossOver Office. Unfortunately the Lotus Notes window crashes or rather disapears when I do a beryl rotation of the cube. Its strange.

Ive setup some network printers. Pointing to a HP printer via JetDirect was easy, but setting up a printer which was shared by Windows was strange. I set SMB as the protocol, and everytime my computer located a Windows machine, a pop up appeared asking for a password. So if your network contains many machines (like mine) "Good Luck." Other than that, I managed to type in the Windows share name, and CUPS managed to find the appropriate share on that machine and I was up and running after selecting the correct printer driver.

Only now I wish there was an option to print 2 pages in one as most Windows HP drivers have the option to.

peeking behind Firefox... Lotus Notes, GIMP and OOo Calc running 'transparently' in the back ground

Other than that, the fonts look really good on my LCD display, and its certainly an impressive distro. Try it out today.

I passed a copy to Aizat and he too is finding it worthy of an upgrade.


yk

7 March 2007

An Inconvenient Truth

I had the opportunity to watch Al Gore's Academy Award winning documentry "An Inconvenient Truth" last night, and it was both scary and inspiring. The message was clear. The delivery was excellent. The facts were sound. I'd encourage anyone who has any moral fibre to watch that movie.

It is not just some handwaving nor vague presentation of global warming as we have glossed over over the years. This documentary actually shows honestly the scientific facts without dumbing down the content. There are no patronising quips and where there are basic points which needed to by explained, the show does it in a humourous manner, so that the people who are new would get educated and the people who already know, would be entertained. Its an excellent way of delivering a message an appealing to the entire audience.

Al Gore's treatment of FUD is also excellent. He gives a history on the misuse and spreading of Doubt. The tactics used against the message of Global Warming is very similar to what the FOSS community is facing. There are many lessons which can be learnt!

On the issue on Doubt about Global Warming, he states that in the scientific community, all 928 peer reviewed papers on this issue does not contradict the proposal that:
"Human activities ... are modifying the concentration of atmospheric constituents ... that absorb or scatter radiant energy. ... [M]ost of the observed warming over the last 50 years is likely to have been due to the increase in greenhouse gas concentrations"
None. No scientist says otherwise. And yet, yesterday in The New Straits Times, there was an article stating that there were some 'scientists' who stated that "Global Warming is a Sham." Which highlights Al Gore's findings that 48% (I think that was the figure in the movie) of POPULAR news are 'undecided' or 'cannot confirm' or 'raises questions' that mankind is causing climate change. It shows that the lobbying of oilcos are successfull where it matters: the public's perception on the threat of global heating.

Apple and the 'Keynote' the software used to present "the slide show" was featured prominently, and well deservedly so. The data was well presented in the movie. The graph which was shown which blew my socks off was this:

This is the Wikipedia version. In the Al Gore version, he projected it on a very large screen, and used a cherry picker to demonstrate how high that CO2 concentration is going. This graph shows that our CO2 creation is not cyclical nor is it normal throughout the history of our planet. It is not caused by nature but directly caused by us humans.
He then correlates this with the CO2 levels and temperature. I could not find a suitable graph in Wikipedia as the closest one is not easy to read. They shouldnt have normalised so much.

[note the x-axis is flipped]
What was hard hitting was the collapse of the Larsen B glacier in Antartica. We thought that it would not fall for the next 100 years but in 2002 it did. The immediate impact was that low lying islands had to be evacuated as the islands were literally submerged.

If Greenland (near the Artic) were to thaw out, the sealevels would rise by 6m. If parts of Antartica were to thaw out, where there are current signs of doing so, that would be another 6m. The rise in the water levels will displace over 100 million people worldwide.

There was no need to hype the facts. Al Gore's delivery was even handed and clear. The facts by themselves are so scary.

I urge all of you to see this film, and lets try to save ourselves.



visit Climate Crisis


yk.