28 December 2005

Java is portable?

Snippet for a java code:

public static MultipartRequest createMultipartRequest (HttpServletRequest req)
throws IOException

// Create a temp directory for the attachments
Runtime.getRuntime().exec ("mkdir -p " + Constants.UPLOAD_PATH);

File check = new File (Constants.UPLOAD_PATH);



What wrong with this code? The answer is, this code is not portable, i.e. doesn't work on Windows. Nothing wrong with the Java, the problem is the programmer itself. :D

I got this snippet from a discussion in The Daily WTF.

25 December 2005

Mailmerge in openoffice 2

In my head, to do mailmerge we need template and datasource. Place the mail merge field in the template and point the field to appropriate datasource field/column.

I spent this christmas evening with trying a script to mailmerge using pyuno, found in the openoffice forum. What I want to do is, produce a single openoffice file after mailmerge from a datasource(a csv file). I manage to do it after modify the code. Hooray!

I had refer to the api, and read a java code snippet.

What annoying me is when export the merged file to pdf, extra unwanted blank pages will be produced for odd-numbered page. Let say I have 1 page template then want to mailmerge with 3 set of data. The result is 5 pages of pdf. The second and fourth page is fill with unwanted blank page. I had tried using openoffice 2 in my Windowx XP box and FreeBSD 6.0 box, both produce same result. Is it a feature/a bug? What I know, this really annoy me :(

Some of openoffice users also complaints about memory usage for mailmerge.

Actually, I had implemented mailmerge using another approach. Modify the openoffice xml file (to be specific, modify content.xml) using ooopy. Although my script able to do the mailmerge, it really painful to get it work. Manipulate openoffice xml using dom really make me headache. No benchmark for these two approaches, what I want is just to mailmerge. Duhh.

13 December 2005

Merge arrays in php

The short answer is function array_merge from php manual.

Let say I have 2 arrays to merge:

$a1 = array('key1'=>'val1', '33'=>'dummy_value');
$a2 = array('choose_one'=>'');
$result = array_merge($a1, $a2);

What my expected result is:

array('key1'=>'val1', '33'=>'dummy_value', 'choose_one'=>'');

Right? Emm... my expectation is wrong, the actual result is, when print_r($result):

[key1] => val1
[0] => dummy_value
[choose_one] =>

What's wrong? After re-read the fine manual, the following line interest me:

Don't forget that numeric keys will be renumbered!

What? I put the key as '33' (with quotes), that should be string. Emmmm... no idea. I am suck or php suck?

04 December 2005

Vim in windows

For some reasons, I used Windows XP this whole week. I can't live without vim when doing programming. One of common feature I used is 'visual block' by press 'Ctrl+v', and default configuration for gVim assume 'Ctrl+V' as paste. No idea+lazy to google solution for this, I use vim in cygwin.

From the setup.exe of cygwin, need to check for option vim (unchecked in default setting) to install vim. After set my .vimrc, I can used vim as usual in my Linux/FreeBSD box plus the command-line (bash in cygwin). A bit annoying when copying snippet code from web browser, firefox to the cygwin window. You need to click top-left cygwin window>Edit>Paste :(

21 November 2005

Django down :(

Last time I can't access howtos ruby on rails, and tonight (10:30pm) I can't access django website. See below:

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, webmaster@djangoproject.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

That really frustrated, especially while I'm reading the documentation online. I'm searching something similar to widget idea by TurboGears.

18 November 2005

Attach file ala Gmail

Just publish my rudimentary version of attach file ala Gmail. I'm using behaviour and prototype to manipulate dom and make clean markup.

I had tried another implementation of behaviour, but I guess the function Behavior.apply() is buggy :(. Careful, since behaviour had call the window.onload in their script. hint (prototype: Event.observe(window, 'load', fn, false);). ShrinkSafe from dojo doesn't like the behaviour and the prototype script. ShrinkSafe == Not safe anymore :(

Did I say my script is clean markup? Below is the snippet:

<div id="attaches"></div>
<span class="attach">Add a file</span>
<br/><input type="submit" value="Send">

p/s: this is not related to AJAX.

13 November 2005

Architecture Astronauts

Joel make good point, Don't Let Architecture Astronauts Scare You. This make me thinking again when consider Ruby on Rails/Django as my next web application framework.

I found this Architecture Astrounauts from a thread in Turbogears group.

12 November 2005

Format hard drive, circa 1975

Next time, our future kid will laugh at us why we spend 'minutes' of time to format hard drive, or maybe why we need to format our hard drive :). We should appreciate history.

Format 500kb of hard drive on 1975

29 October 2005

Update favorite firefox extensions + form repetition

>>Previous post

1. SessionSaver
2. Aardvrak
3. ScrapBook
4. Tab X
5. Selenium Recorder

Nice script, Form Repetition by ian (like add attachment in Gmail). Don't have time to play with it :(

16 October 2005

mp3 to ogg conversion.

I'm using oggplay, v1.6.5 (since frequency analyzer works for .ogg in this version) as music player for my Nokia 3230. The problem is, how to batch conversion mp3 to ogg. I use Audio Conversion Wizard 1.8 in my Windows box. But it shareware :(, I'm gonna try oggdrogXPd.

I'm prefer command-line. After spend some time googling, I got this command from a website:

helmi > mpg321 un\ de\ vez\ en\ cuando.mp3 -w - | oggenc -o test.ogg -

08 October 2005

Main menu of my Nokia 3230

Originally uploaded by Gambar_Helmi.
I just uploaded few screenshots of my new series 60 handset interface. Feel free to visit my photos ;) Check out also my bookmark

07 October 2005

Creating nodes for Javascript DOM

First of all, new FreeBSD website launched. I just like it.

I had created a dynamic select box, [add/remove value from text box] for one of my javascript. It just works perfectly in firefox and the customer happy with it. But it doesn't work in IE (surely I will be blamed since most of the user using IE).

I need to add/remove node in select box. So I just refer to website one of javascript guru. It just using method appendChild and removeChild, duhh. But IE don't like it. I had tried debug using the Internet Explorer Developer Toolbar (doesn't help me, explore DOM in firefox much better). After spent some time googling, I got a nice article. Snippet below solved my problem.

try {
elSel.add(elOptNew, null); // standards compliant; doesn't work in IE
catch(ex) {
elSel.add(elOptNew); // IE only

28 September 2005

Transfer mp3 from Knoppix to series 60 phone

I'm using Knoppix-4.0.2 to transfer mp3 files to series 60 phone (Nokia 3230).

Connect the bluetooth adapter to pc. Double check by dmesg:

Bluetooth: Core ver 2.7
NET: Registered protocol family 31
Bluetooth: HCI device and connection manager initialized
Bluetooth: HCI socket layer initialized
Bluetooth: HCI USB driver ver 2.8
usbcore: registered new driver hci_usb

Open K Menu > KNOPPIX > Network/Internet > dev/modem connection setup.
Choose bluetooth, then click button OK.
From Konqueror, right click any files that want to transfer into the phone and choose Actions > Send with Bluetooth ...
A new window, Bluetooth OBEX will be show. Choose the correct device and click button Send.

I want try transfer data using my FreeBSD box, but quite scary when read bluetooth chapter in FreeBSD Handbook.

27 September 2005

Playing with Python for Series 60

Playing with Python for Series 60 on my new nokia 3230. Run simple script

import appuifw
appuifw.app.title = u"Hello K and R"
appuifw.note(u"Hello Kernighan and Ritchie!", 'info')

It come with Interactive console, COOL!

22 September 2005

Enable CD-RW in FreeBSD

Execute browser and open file:///usr/share/doc/handbook/creating-cds.html.

After customize my FreeBSD kernel, I can't write to my CD-RW, what happen? I need to recompile my kernel with these extra lines in config file:
device atapicam
device scbus
device cd
device pass
Argh... this second time I'm pulling my hair finding why my OS don't like CD-RW.

02 September 2005

01 September 2005

Favorite firefox extensions

A list of my favorite firefox extensions:
  1. miniT (drag+indicator)
  2. Web Developer
  3. Live HTTP Headers
  4. CustomizeGoogle
  5. Statusbar Clock
  6. fireFTP
  7. Zhluk.com DevBoi
At last, someone make documentation for prototype :). I updated my ajax application using prototype+php (last time using sajax). NOTE: prototype is NOT ONLY for ajax. Still looking free web hosting that support php (my helmi03.broadphase.com was eliminated ::SAD::)

I'm so HAPPY today because, at last able to run Nevow (from subversion) examples. Just make sure the example import module nevow from svn instead of in python default path. Currently just hack it, i.e. pkg_deinstall py24-nevow-0.4.1 and run #PYHONPATH=~/project/Nevow-svn twistd -noy examples.tac. The example source code much cleaner than 0.4.1. Only tight integration to twisted make me SICK. Asynchronous programming is hard to DEBUG (based on experience programming ajax)!

04 August 2005

Python IDE, ajax application using PHP, SQLObject

PIDA - Python Integrated Development Application. Cool features such as Vim as primary editor, Pydoc, code refactoring using Bicycle Repair Man, debugger.

Last weekend I implemented an ajax application using Sajax. The function of the application is like CountryRegionCityJax (based on AjaxAC). Sorry no release (related to my job) :(

What's Up With SQLObject Today...

29 July 2005

Can't access howtos Ruby on Rails

Today I got a message after try access Rails Howtos:

Bad Gateway

The proxy server received an invalid response from an upstream server.

Rails, ajax

looking for a simple straightforward explanation of Ruby, Rails and AJAX!.

Nice introduction for ajax on rails.

19 July 2005

firefox 1.0.5, opera 8, compile java jdk14

Upgraded firefox from 1.0.4 to 1.0.5. But not so smooth transition. I can't save my preferences. Every time I start firefox, I need to enable Security (so I can login to my gmail), enable javascript. Damn it. I hope freebsd maintainer notice this (I emailed them just now).

Wow, opera 8 is COOL (that was my first impression). But not programmer friendly. Some of my javascript doesn't work in opera :(. Javascript SUCK!

Last night, I tried to compile java in my FreeBSD-5.4 box. I need to get patches and enter Java download center several time before compile. And the result, I can't run the java since complain about 'elf linux compatibality' (sorry java was removed before write this). One more thing, my box hang when compile java.

16 July 2005

GeekBlock, Django

I need to handle a quite `big` software project this couple of week. Bugs, incomplete features, change of request keep forcing me and put me under pressure.

My mind always say to "go to ground - run and hide!", "quit this job, I will have brighter future in electrical engineering field instead of software engineering!", "other developers hate this project, what the heck you still doing this?". But this do not solve anything. Anyway, today I feel a bit better after read an article about "How to Overcome GeekBlock".

New Python web framework, Django is out, and make Rails developers speak out. Getting started with Django.

28 June 2005

adodb in freebsd

There is already a port for adodb in freebsd. As root
root > cd /usr/ports
root > make search key=adodb
root > cd /usr/ports/databases/adodb
root > make install clean
root > vim /usr/local/etc/php.ini

add a line in php.ini
include_path = "/usr/local/share/adodb

Now you can call adodb api without include/require in php code :)
Oops.. you still need:
require '/usr/local/share/adodb/adodb.inc.php'

20 June 2005

PHP References and foreach

References in PHP are not like C pointers. I had bad feeling on this :(. In php 4, they have foreach construct. "Easy way to iterate over arrays", i.e. not easy to iterate over objects/references. It possible in php 5, refer here and need a litte tweak for php 4, (a user comment in the same page). Here an excerpt from one of my php source:
//Set red background for all options in a select field
$_opt =& $cat->_content;
foreach ($_opt as $k => $v) {
$v =& $_opt[$k];



19 June 2005

tcpwatch selenium

Record a session (e.g. fill a form), tcpwatch and create a suite for functional test, selenium.

How I do functional test for my web application? (based on Starting with Selenium, by ian)

1. Open firefox, Edit>Preferences>Connection Settings
Choose Manual proxy configuration.
HTTP Proxy: localhost Port: 8888

2. Create a folder, record and run command:
tcpwatch.py -s -r record -p 8888

Note: assume tcpwatch.py in os environment path.
url: http://blog.ianbicking.org/starting-with-selenium.html?version=2

3. In firefox, open http://localhost/~helmi/test/main.php
Fill in one of the input box, then click button Carian.

4. Stop tcpwatch.py at command line, i.e. Ctrl+c.

5. Create TestScript.html for selenium by:
./tcpwatch_scriptgen.py -r record selenium > TestScript.html

6. Modify link, element locator appropriately.
e.g. adodb_search_field `rename to` document.name_srh.adodb_search_field

hint: FreeBSD
root > cd /usr/ports
root > make search name=tcpwatch
root > make search name=clientform

18 June 2005

onload javascript

1) Simple way to focus on input text when the page is first loaded.
<body onload='document.myform.foc.focus();'>
2) If javascript in an external file, we need to use other way.
window.onload = document.myform.foc.focus;
Note that, neglected () at the end and window.onload will execute once the page has finished loading. Drawback, if contain multiple script, the last window.onload will the only script to execute.

3) Dynamic one:
function addEvent(obj, evType, fn){
if (obj.addEventListener){
obj.addEventListener(evType, fn, true);
return true;
} else if (obj.attachEvent){
var r = obj.attachEvent('on'+evType, fn);
return r;
} else {
return false;

addEvent(window, 'load', function() {

Usable form, example
Enhance structural markup with javascript, example

08 June 2005


YAGNI - You Aren't Gonna Need It.
What? This practise is true when you involve in a project (especially to get in due date). There is an explanation from NetObjectives (I guess publisher for really great design pattern book, Design Patterns Explained).

29 May 2005

Software Engineering Management

"Reuse-in-the-large (components) remains a mostly unsolved problem, even though everyone agrees it is important and desirable."

Emm... make sense. This quote is from an article, "Facts of Software Engineering Management". I guess the author of this article is same as author for book "Software Creativity". Here is the summary.

22 May 2005

Roundup configuration (fix)

We start roundup server by:
roundup-server support=roundup

but I got an error page:
Error Response
Error code 404
Error code explanation: 404 = Nothing matches the given URI.
I can't remember how I start roundup-server nicely before this :), since I use this Roundup rarely. Now it fixed after modify ~/roundup/config.ini:
#! web = http://localhost:8080/roundup/
web = http://localhost:8080/support/
Refer configuring your first tracker.

11 May 2005

portupgrade -v postgresql-client

Upgrade postgres by:
portupgrade -v postgresql-client

then, got this error:
configure: error: do not put -ffast-math in CFLAGS
===> Script "configure" failed unexpectedly.
Please report the problem to girgen@FreeBSD.org [maintainer] and attach the
including the output of the failure of your make command. Also, it might be
a good idea to provide an overview of all packages installed on your system
(e.g. an `ls /var/db/pkg`).
*** Error code 1

Stop in /usr/ports/databases/postgresql74-client.
*** Error code 1

This happen after I build customized FreeBSD-5.4 kernel. I have this line in /etc/make.conf:
CFLAGS= -Os -pipe -funroll-loops -ffast-math
The postgresql74 don't like -ffast-math flag, so I add this line in /usr/ports/databases/postgresql74-client (to override default flag value in /etc/make.conf):
CFLAGS= -Os -pipe -funroll-loops #without -ffast-math

Then I can compile postgresql74-client happily :).

08 May 2005

Ruby on Rails. What?

Rails should support postgresql-7.4. But what the hell is this error?
No such file to load -- postgres

Ok, this is time for googling. Here is one of the solution. Interface to postgresql is
not included in standard rails distribution (I know, interface to mysql is in included).
Then, another error message appear:
ERROR C42P01 Mrelation "personals" does not exist Fnamespace.c L193 RRangeVarGetRelid: SELECT COUNT(*) FROM personals

Before this I had generate model and controller for table personal. This article has nice intro
to activerecord database tables and columns rules (heading: What's in a Table Name?). Also, refer to
this. i.e. the error is because, Rails guess table for model 'Personal' as 'personals' (smart..).
Then, if model 'Mouse', Rails will guess the table name is 'mouses'. What? My English language
teacher teach me that plural for mouse is mice. So,
class Mouse < ActiveRecord::Base
set_table_name "mice"

To have CRUD in Rails for model 'Personal', I only add one line in the controller, e.g:
class PersonalController < ApplicationController
scaffold :personal


05 May 2005

Recompile MPlayer 1.0pre7 and install xfce4

My mplayer is recompiled today. This time, I add some flag in Makefile

I'm gonna like this mplay - console based frontend for MPlayer. Previously I use cplay for my console based mp3 player. But I found, cplay give you very basic functionaly. Last time, I failed to use this app. Today, I solve it by run ./force_install_modules instead of just run ./install (script in mplay-0.80.tar.gz).

Yesterday, I pkg_add -vr xfce4. Works for me. Actually, this window manager is for my housemate. Maybe they found my evilwm quite hard to use :)

Joke for today. Credit to Sarah and Zubayer.

02 May 2005

Support crisis - What to do when client report bug?

My program crash. The client keep complaining why the program doesn't work as they expected. They even phone me during my holiday :(
The database is corrupt, GUI crashing, unexplainable problem coming out. The sky is FALLING! What to do?
I remember the first time they call me to report a bug. What I do was, my head gone blank, my hand is shaking, and I don't answer them properly. Very bad! That was obviously the wrong way to support crisis.

This article from extreme programming practise give me idea to handle crisis properly.

01 May 2005

pg_dump Postgresql.

[in office]Annoying pg_dump and restore database problem. I had a sequence issue_id_seq in a database. But after dump the database and restore to new database, the sequence become issue_issue_id_seq. Until now this problem don't solve. Grrrr...

[at home] How to copy schema of a database to new database?

createdb new_db
pg_dump -s old_db | psql new_db

24 April 2005

Visual Basic application.

This weekend, I implemented an application for my friend using Visual Basic 6.0. Check here. Why don't use my favorite programming language, Python? emm... It's in requirement :(. Still need to open manual how to declare variables:

Dim number as Single

How VB return value for function quite unique:
Private Function getCoordinateRight(X As Single, Y As Single)
X = (X - offsetRight) / (offsetEnd - offsetRight) * totalVpp
getCoordinateRight = X
End Function
I just updated my convocation photos on web. Check my photo album.

20 April 2005

Install openoffice-1.1.4 in FreeBSD and take screenshot, xv.

I always got problem to install openoffice from the stable branch. e.g.

%pkg_add -vr openoffice
looking up ftp3.jp.freebsd.org
connecting to ftp3.jp.freebsd.org:21
setting passive mode
opening data connection
initiating transfer
Error: FTP Unable to get ftp://ftp3.jp.freebsd.org/pub/FreeBSD/ports/i386/packages-5-stable/Latest/openoffice.tbz: File unavailable (e.g., file not found, no access)
pkg_add: unable to fetch 'ftp://ftp3.jp.freebsd.org/pub/FreeBSD/ports/i386/packages-5-stable/Latest/openoffice.tbz' by URL
pkg_add: 1 package addition(s) failed

To install from release branch you can use the:
# pkg_add -r openoffice
as suggested by the handbook, but the problem is it will fetch the openoffice-1.1.2 (I want the openoffice-1.1.4). Today, I solved my problem by:
%pkg_add -v http://oootranslation.services.openoffice.org/pub/OpenOffice.org/ooomisc/FreeBSD/OOo_1.1.4_FreeBSD53Intel_install.tbz
It clearly state in the OpenOffice.org website. Stupid me :(, I'm too much depend on default freebsd package repository.

How to grab the screenshot for the desktop? Use xv :) I know we can use gimp, but I rarely use that app (I don't remember when last time I use gimp, I guess last 2 months). Open xv menu>Grab. I use middle mouse to select fullscreen. Here is my desktop screenshot (in png format). (evilwm, FreeBSD-5.3, gkrellm). I had uploaded to my flickr, but it resize the image and I can't read the words :(. Yahoo photos also will resize the image (layout not good in firefox). The image size in fotopages quite OK, but 'Image Viewing is down for maintenance' message give me bad impression.

18 April 2005

Happy convocation!

Happy convocation to me, Bachelor of Engineering with Honours (Electrical) ! This is the 61st convocation for UiTM.

12 April 2005

Answer for Ruby on Rails

Ian answer's to a tutorial for Ruby on Rails.
A comparison for object relational mapper (ORM) in Java, Ruby, and Python.
Still, 'in between' Ruby and Python? Blog from mikewatkins try answer this question.

Steal this code for validation for email in nevow. Thanks to Tv (from #twisted.web at freenode).

To list files within package in freebsd (thanks to Low):
pkg_info -xL subversion
Can pipe to grep for filtering purpose (e.g. pkg_info -xL subversion | grep svn)

08 April 2005

Setting roundup

Today I set an issue-tracking system, Roundup. I install by package, (/usr/ports/www/roundup) in my FreeBSD-5.3 box. I chose to use postresql as storage backend. I follow this installation guide. Since I use postgresql, so I need to edit roundup/config.ini, [rdms] port= 5432.
To enable postgresql run on port 5432, edit the /usr/local/pgsql/data/postgresql.conf. Uncomment port=5432 and set tcpip_socket=true. Reload the postgresql by
> pg_ctl reload -D /usr/local/pgsql/data/
Check whether port is open or not by:
> nmap -v localhost
my console output:
25/tcp open smtp
80/tcp open http
111/tcp open rpcbind
5432/tcp open postgres
8080/tcp open http-proxy
I can open my Roundup now at http://localhost:8080/roundup/ . Now login as admin (hint: password set after roundup-admin initialise). I got an annoying problem about emel. For timebeing it solve by set [mail] in roundup/config.ini,

Implement form in nevow is unique. They use formless. To create a form, the class need to extend formless.annotate.TypeInterface. For the form elements, check formless.annotate.Choice(), formless.annotate.Integer(), etc. To set validation, I guess we need to extend formless.annotate.Type (hint: check parent class for formless.annotate.Integer ).

06 April 2005

nevow rocks!

This week, I playing with Nevow. I really impressed with the LivePage.

But I think a few things irritate me:
1) Plenty of documentation.
2) It's quite hard for beginner.

My internet connection at home not stable this couple of weeks. :(

29 March 2005

sql + python, large project with javascript, minibufexpl.vim

I'm not familiar with database design, but I find integration SQL with Python quite interesting. Check article Fast, Easy Database Access with Python and SQLObject.

Is it easy to build large project using javascript? How about implement 60,000 lines of javascript?

I found minibufexpl.vim useful for my daily usage of vim. Try it!

27 March 2005

How fast you can type?

How fast you can type? Type this line in the console:
> date ; wc -m ; date
Then type the words you want. Lastly, type 'Enter' and 'Ctrl+d' to get the result. An example of my session:
Sun Mar 27 07:33:14 MYT 2005
helmi bin ibrahim
Sun Mar 27 07:33:16 MYT 2005
Number 18 show how many characters typed include new line character.

23 March 2005

back to screen

I don't like much use screen before since can't run my favorite applications properly (vim, mplayer, centericq).
Add this line in the .tcshrc:
setenv TERM 'xterm'

Now, the key-binding for my favorite applications when run in screen work properly. Thanks to Kamal.

21 March 2005

Risk when update FreeBSD ports!

This morning before go to work, I did weekly task to update my FreeBSD ports manually (I don't use cron, since I don't want my cpu load when using other apps). Usually I use 'portupgrade -PP -varR', but this time without option PP.

In /usr/ports/UPDATING, 20050312 user can upgrade gnome, gtk/glib with the script gnome_upgrade.sh. I use this script and then I noticed that the firefox, open-office, py24-gtk were uninstalled ! I need to install these apps again :-(. And the worse thing happen then. I got this error message when run the py-gtk demo:
> python pygtk-demo.py

(process:30237): GLib-GObject-CRITICAL **: gtype.c:2254: initialization assertion failed, use IA__g_type_init() prior to this function

(process:30237): GLib-GObject-CRITICAL **: gtype.c:2254: initialization assertion failed, use IA__g_type_init() prior to this function

(process:30237): GLib-GObject-CRITICAL **: gtype.c:2294: initialization assertion failed, use IA__g_type_init() prior to this function

(process:30237): GLib-GObject-CRITICAL **: g_object_new: assertion `G_TYPE_IS_OBJECT (object_type)' failed
Failed to load Pango module for id: 'BasicScriptEngineFc'
(process:30237): GLib-GObject-CRITICAL **: gtype.c:2254: initialization assertion failed, use IA__g_type_init() prior to this function

(process:30237): GLib-GObject-CRITICAL **: gtype.c:2254: initialization assertion failed, use IA__g_type_init() prior to this function
I had try writing a gtk application using glade and pygtk by refer this article. I feel the pygtk demo better than last time I playing with this toolkit (it quite similar to wxpython demo approach). Yesterday I happily browse the pygtk demo, but this gtk problem give me headache.
Emm... I give up :-(.

Today I start my first project (start from scratch) at bytecraft for Kementerian Pembangunan Usahawan dan Koperasi.

15 March 2005


Debugging in firefox: open Tools>Javascript Console

Favorite references:
1) w3schools
2) Javascriptkit reference.
3) javascript-reference.

12 March 2005

Chatting in IRC.

People in channel #twisted.web, #vim, #python-gilliam at server irc.freenode.org are nice. They still answer my stupid question (since I am newbie).

Antidesktop. No mouse.
How to report bugs effectively. (get from Han)
How to ask questions the smart way.

I just found w3m. (/usr/ports/www/w3m-image). This is an alternative for links. Now 2005-03-13, there are two links version in FreeBSD-5.3, links-0.98 and links-2.1.p15.

Just add another program in my .xinitrc. (oneko-sakura)
oneko -bsd -bg red &

10 March 2005

How to run Plone?

Googling doesn't much help. How to run Plone in my FreeBSD box? This guide do not explain much about installation Plone in FreeBSD. I had once install Plone in my Windows box (it's easy, just click button 'next' then 'next', 'next', ...). But to run this service in my FreeBSD box give me headache. Usually when I try new software, I start with Read The Fine Manual. But there is 'No manual entry' for plone and zope, though.

Actually there is INSTALL.txt in /usr/local/www/Zope/doc. Create zope.conf (I put it at /usr/home/helmi/project/zope/etc) and add this 2 lines:
products /home/helmi/project/zope/Products
products /usr/local/www/Zope/Products

09 March 2005

Socket Programming in Python

I had tried a simple chat program this morning. The bad thing is you need to run 2 programs at same time (client and server).
An article from Python HOWTO explain basic about socket programming.

This couple of months, I involved in web application programming using PHP. This guide is very useful to remind me about web development mistakes. Plone, an open source Content Management System is quite interesting to be explored. After read this article and the definitive guide to plone, I'm become interested in this plone thing.

08 March 2005

Cannot startx

I cannot startx !
The message ask me to remove the /tmp/.X0-lock.
Then when try 'rm -vf /tmp/.X0-lock', a message say 'Bad file descriptor' appear and the file cannot be deleted.
When, I run 'fsck', a message like 'unlink ... /tmp/.X0-lock ... REMOVE? no' display.
I guess something wrong with the filesystem/harddisk since last night I saw a message in terminal 'ad0 write error..' message. My FreeBSD don't like my new Western Digital harddisk.
The solution: reboot in single user mode, then run 'fsck -y'. Now the /tmp/.X0-lock is removed. Exit single user mode, then I can startx now.

Harddisk problem?
You can use badblocks to search for device for bad blocks. (I not found yet badblocks in my FreeBSD, 'Command not found').
Use fsck to file system consistency check and interactive repair.
Still got problem, then better read this mail for solution :).

To monitor harddisk use smartctl. This article give good explanation to monitor hard disk with SMART. (Thanks to Han). In FreeBSD it is in /usr/ports/sysutils/smartmantools.
Got this error
Smartctl open device: /dev/ad0 failed: Inappropriate ioctl for device
when '> smartctl -a /dev/ad0' ? That's mean, you need to be superuser to run this application.
View here for my 'smartctl -a /dev/ad0'.

Cannot login to flyspray.
I cannot login to flyspray in IE (Internet Explorer 6). The address is something like http://helmi_ibrahim.com.my/flyspray. The solution is get ip address for this address (hint: ifconfig) for e.g. then now you can login. Why? The IE assume address with underscore '_' as security risk, so not allow flyspray to set cookies.
A quote for today "the antivirus program give more hassle than the virus".

Malaysian Bloggers, MYOSS.
Python development in Eclipse.

07 March 2005

python extension using pyrex for itl

I had create a python extension for itl/prayertime.

If interested:
1) extract solat.tar.bz2 to itl/libs/prayertime/src
2) run 'make pysolat'. If got error:
Cannot assign type 'double (*)' to 'int (*)
just 'make pysolat' again.
3) to test, run 'python test.py'

- pyrex (tested using pyrex-0.9)
- itl libs (tested using lib-0.6.3)
successfully run on my FreeBSD-5.3, python-2.4

The stupid geocities not allow me to upload solat.tar.bz2. So the trick is rename solat.tar.bz2 to solat_tar_bz2.zip then upload.

05 March 2005

Mount CD in FreeBSD.

By default user don't have permission to mount CD or other removable device.
There is no instruction in Handbook??? Actually the instruction was in FAQ, a little bit confusing though.

To mount cd:
> mount_cd9660 /dev/acd0 ~/mnt/cd
or for an odd type of cd,
> mount_cd9660 -v -o rw -s 0 /dev/acd0 ~/mnt/cd

I just found an easier way to play VCD using mplayer without mount the cd.
> mplayer vcd://1

This tool for acceptance/functional testing of Web sites (Selenium) is quite interesting.
While playing with nevow this morning, my boss ask me to take a look at ERP5. What is erp? Maybe this article will help you.

03 March 2005

PIL rocks!

Today I need to create a program for an image processing function. First I try the ImageMagick using the command-line. The problem is, it quite hard (at least for me) to get image width, height and use the parameters in shell script.
Another option is use PIL (Python Imaging Library). Then I manage to implement the script before due time.

Since I spent most of time programming using PHP, I always put semicolon ';' at the end of line in python script. Obviously it unnecessary in Python (not syntax error). I only notice that after my colleague correct me. This is one advantage of pair programming, though.

01 March 2005

Got problem with my hard disk again

Arghhhh... My seagate harddisk give me headache again. It contain my precious FreeBSD 5.3 with all the setting for the desktop. Then it crash again this weekend. It stuck at boot: prompt :(

And the happy thing is I bought new hard disk. 80Gb Western Digital 8Mb. But I still need to spent some times to configure my desktop and download my favorite packages again. Install openoffice always give me headache, something like:
> openoffice.org-1.1.4-setup
/usr/libexec/ld-elf.so.1: Shared object "libm.so.2" not found, required by "javaldx"
/usr/libexec/ld-elf.so.1: Shared object "libm.so.2" not found, required by "setup.bin"

My hard-disk uptime until this post
> uptime
8:16AM up 1 day, 2:12, 7 users, load averages: 0.01, 0.07, 0.14

25 February 2005

Keep FreeBSD package up-to-date

I believe that I learn the hard way to update my packages in FreeBSD. If I found this article earlier, I don't need spend much time googling and ask people why it so damn long to update my portsdb using 'portsdb -Uu' refer this, how to get packages in STABLE branch instead of RELEASE, is it any alternative to cvsup, ...

How to concatenate 'string' in C?
First, using python
>>> str1 = "helmi #"
>>> num = 1
>>> str2 = "%s%d" % (str1, num)
>>> print str2
helmi #1
>>> str3 = str1 + str(num)
helmi #1

Using C,
char string[] = "something";
char string2[50];
int number = 14;
sprintf(string2, "%s%d", string, number);

After spend some times googling then I found the solution in a post at comp.lang.c.

24 February 2005

Black-out again!

black-out again at my office around 4pm. This is second time for this week. black-out = delayed task since my job depends almost on computer.

Deal with xml, ElementTree is cool and pythonic :-) The htmlgen.py by a guy quite cool, just like phphtmllib paradigm to create the html tag.

Someone ask me to plot graph using Visual Basic. Then I suggest to her use the Microsoft Excel since the data is from experiment. If data from formula or involve calculation I would suggest matplotlib or scipy.

23 February 2005

Malaysian Vim group

My friend create a group for vim fan, from Malaysia. Malaysian are welcome to join myvim. The learning curve to learn use this editor is steep. But once, you able to edit the text using Vim, you can't live without it :).

Don't spend much time to find tips/shortcuts for vim (even worse learn all the editor commands). This article explain why, Seven habits of effective text editing.

C programming links:
C Programming Tutorial. Brief tutorial.

XOSD - X On-Screen Display:
Guide and reference.

22 February 2005

Some of my FreeBSD configuration files.

torsmo - Tyopoyta ORvelo System MOnitor
.torsmorc (see also /usr/X11R6/share/examples/torsmo/torsmorc.sample)