02 October 2009

OpenStreetMap data for Malaysia = impressive progress!


Version 17 Apr 09

Version 24 Sept 09


OpenStreetMap data for Malaysia = impressive progress!
Quite a lot of new road added at Kuala Lumpur for 5 months work.
Map above viewed using udig.
Google Map Maker is available for Malaysia, but don't think it easy for offline usage/internal use (hint:shapefile).

28 August 2009

Which location column more trusted?

You have database from your client with fields state, district (description of locations), and the_geom (latitude/longitude) column. Example of the db

| state | district | the_geom |
| Selangor | Petaling | POINT(101.497838106615 3.27468487066054) |


Anyone doing GIS should know that, the state, district fields is duplicate with the_geom since once we know the latitude/longitude we will know the state, district.
The problem is the_geom is not within Selangor, Petaling. Then when do group by st_intersects, the value is wrong since the_geom is refer to other place!

So, need to decide, which location column more trusted?
The latitude/longitude or description of locations.

26 June 2009

Mapnik need to know postgis column type

Mapnik need to know postgis column type to render properly. This mapnik xml for style not working for me.


<Style name="jalan_casing2">
<Rule>
<Filter>[jenis] = 'lebuhraya'</Filter>
<MaxScaleDenominator>&maxscale_zoom7;</MaxScaleDenominator>
<MinScaleDenominator>&minscale_zoom7;</MinScaleDenominator>
<LineSymbolizer>
<CssParameter name="stroke">#808080</CssParameter>
<CssParameter name="stroke-width">6</CssParameter>
<CssParameter name="stroke-linejoin">round</CssParameter>
<CssParameter name="stroke-linecap">round</CssParameter>
</LineSymbolizer>
</Rule>
</Style>
<Layer name="jalan_lebuhraya" srs="+proj=latlong +datum=WGS84" status="on">
<StyleName>jalan_casing2</StyleName>
<StyleName>jalan_fill</StyleName>
<StyleName>jalan_text</StyleName>
<Datasource>
<Parameter name="type">postgis</Parameter>
<Parameter name="password"></Parameter>
<Parameter name="host">localhost</Parameter>
<Parameter name="port">5432</Parameter>
<Parameter name="user">helmi</Parameter>
<Parameter name="dbname">road</Parameter>
<Parameter name="table">(select * no_jalan, 'lebuhraya' as jenis, the_geom from jalanraya.lebuhraya) as jalan</Parameter>
<Parameter name="estimate_extent">false</Parameter>
<Parameter name="extent">-180,-90,180,89.99</Parameter>
</Datasource>
</Layer>


My workaround (only tested on Ubuntu Jaunty) is cast the new column as varchar.

(select * no_jalan, 'lebuhraya'::varchar as jenis, the_geom from jalanraya.lebuhraya) as jalan


Mapnik is better than MapGuide when rendering road labels

OptimizeRenderingWithPostGIS

27 May 2009

MapGuide 2.1beta

Eager to try beta version, here I log the problem I face and how I solve.

Error msg:

httpd.exe: Syntax error on line 127 of C:/Program Files/OSGeo/MapGuide/Web/Apache2/conf/httpd.conf: Cannot load ../Php/MgHttpHandler.dll into server: The specified procedure could not be found.

Fix by move directive 'MgHttpHandler.dll' up

LoadFile ../Php/php5ts.dll
LoadFile ../Php/ACE.dll
LoadFile ../Php/MgHttpHandler.dll # put this directive here, the first one and restart apache service
LoadFile ../Php/MgFoundation.dll
LoadFile ../Php/MgGeometry.dll
LoadFile ../Php/MgMapGuideCommon.dll
LoadFile ../Php/MgMdfModel.dll
LoadFile ../Php/MgMdfParser.dll
LoadFile ../Php/MgPlatformBase.dll
LoadFile ../Php/MgWebApp.dll

http://n2.nabble.com/MGOS-2.0.0-Beta-2-loadfile-error-td1816710.html

26 May 2009

13 May 2009

schema.table to "schema"."table"

PHP

<?php
$st = 'schema.table';
print join('.', array_map(create_function('$a', 'return \'"\'.$a.\'"\';'), explode('.', $st)));

Selected 3 of 3 Lines; 11 of 11 Words; 124 of 124 Bytes

Python

st = 'schema.table'
print '.'.join('"'+i+'"' for i in st.split('.'))

Selected 2 of 2 Lines; 9 of 9 Words; 69 of 69 Bytes

Python=PHP/2

05 May 2009

Trac error - database disk image is malformed

One of my trac page got the error message "database disk image is malformed"

"underlying Trac DB is in serious trouble, may corrupted" - Ticket #6347

How I fix:
sqlite3 trac.db .dump | sqlite3 trac2.db
cp trac.db trac.broken.db
cp trac2.db trac.db

04 May 2009

Find files, php5 way

Find files, implemented using iterator.

class RegexFilter extends FilterIterator {
protected $regex;

public function __construct(Iterator $it, $regex) {
parent::__construct($it);
$this->regex = $regex;
}

public function accept() {
return preg_match($this->regex, $this->current());
}
}

function find_files($path, $pattern, $include_dir=FALSE) {
$objects = new RecursiveDirectoryIterator($path);
$objects = new RecursiveIteratorIterator($objects, RecursiveIteratorIterator::SELF_FIRST);
$objects = new RegexFilter($objects, $pattern);
return $objects;
}


Example usage:

$files = find_files('/tmp', '/.py$/');
foreach ($files as $file) {
echo $file;
}


Previously using php 4:

function find_files4($path, $pattern, $callback=null) {
$path = rtrim(str_replace("\\", "/", $path), '/') . '/';
$matches = Array();
$entries = Array();
$dir = dir($path);
while (false !== ($entry = $dir->read())) {
$entries[] = $entry;
}
$dir->close();
$files = array();
foreach ($entries as $entry) {
$fullname = $path . $entry;
if ($entry != '.' && $entry != '..' && is_dir($fullname)) {
$this->find_files($fullname, $pattern, $callback);
} else if (is_file($fullname) && preg_match($pattern, $entry)) {
if (!$callback) {
$files[] = $fullname;
} else {
call_user_func($callback, $fullname);
}
}
}
if (!$callback) {
return $files;
}
}

import data from csv into postgresql

We can use sql command, COPY. But programmer still need to create the table before copy the data. Simple python script to help


#!/usr/bin/python
fn = '/home/helmi/world.csv'
columns = file(fn).readline()
print 'create table world (%s text);' % " text,".join(columns.split(','))
print "copy world from '%s' with csv header;" % fn


then

python csv2psql.py | psql mydb

06 March 2009

Validate KML

I implement dynamic KML data using PHP + Postgis for a pet project. The problem is, Google Earth don't tell you the error when our kml file have problem, such as invalid KML. It just not appear in 'My Places' or 'Temporary Places'. So, I keep wondering whether I open correct link, or php not working, etc.

Previously how I debug is by check apache log or postgresql log. But just found the 'macho' way - by command line:


sudo apt-get install xmlstarlet
helmi@gandalf:/tmp> xmlstarlet val -e --xsd http://code.google.com/apis/kml/schema/kml21.xsd tree.kml
tree.kml - valid
# for offline xsd
helmi@gandalf:/tmp> wget -c http://code.google.com/apis/kml/schema/kml21.xsd
helmi@gandalf:/tmp> xmlstarlet val -e --xsd kml21.xsd tree.kml
tree.kml - valid
# without option -e, don't know status when xsd file not found
helmi@gandalf:/tmp> xmlstarlet val --xsd invalid_kml21.xsd tree.kml
# better version
helmi@gandalf:/tmp> xmlstarlet val -e --xsd invalid_kml21.xsd tree.kml
I/O warning : failed to load external entity "invalid_kml21.xsd"
Schemas parser error : Failed to locate the main schema resource at 'invalid_kml21.xsd'.
# of course you can validate kml generated by php
helmi@gandalf:/tmp> xmlstarlet val -e --xsd kml21.xsd http://localhost/~helmi/tree_kml/trees.php
http://localhost/~helmi/tree_kml/trees.php - valid


Google Earth gotchas:
* when click url http://localhost/~helmi/tree_kml/trees.php (this php return header with KML mimetype properly), and open with Google Earth, it not appear at 'Temporary Places'. One workaround, use apache url rewrite to redirect trees.kml to trees.php
not really gotcha, hint: header('Content-Disposition: attachment; filename="test_file.kml"');

RewriteEngine on
RewriteBase /~helmi/tree_kml/
RewriteRule trees\.kml$ trees.php [NC] # note that without option R

Now, use http://localhost/~helmi/tree_kml/trees.kml to display in GE properly

29 November 2008

Vim smart syntax highlighting



Smart because it syntax highlighting sql in php heredoc. gedit and nano don't support this. I don't know about other editor.
I used font size 16 all the time, big font eh ;-)

24 November 2008

Disable scrollkeeper on Ubuntu

"proses ini hampir memakan 90% cpu dan memory, dan seringkali menyebabkan sistem menjadi hang" -- happen to me today and not at right time.

To disable:

sudo mv /usr/bin/scrollkeeper-update /usr/bin/scrollkeeper-update.real
sudo ln -s /bin/true /usr/bin/scrollkeeper-update
sudo find /var/lib/scrollkeeper/ -name \*.xml -type f -exec rm -f '{}' \;
sudo dpkg-divert --local --divert /usr/bin/scrollkeeper-update.real --add /usr/bin/scrollkeeper-update


Refs:
* http://blog.its.ac.id/kholis/2008/11/01/scrollkeeper-di-ubuntu/
* http://mapopa.blogspot.com/2008/09/disable-scrollkeeper-on-ubuntu-is-good.html

31 October 2008

Google Maps driving direction to Machang, Malaysia

Google Maps driving direction back again as today, 31 Oct 2008. It not official, I guessed (since not mentioned in Google LatLong). So, I give it a try from Kuala Lumpur to Machang

From Misc


The routing is accurate and fast (compared to Garmin Que+malsingmaps which lead me to Ipoh instead of Gua Musang before reach Machang). But the direction is not detail enough, see the instruction no 24 in screenshot below. "Continue on 8 -- 307 km" but from the map, the blue road show that you have turn right at Pekan Gua Musang.

From Misc


You should try 'Print' function, look useful. Hey, this driving direction also works on Google Maps on my Windows Mobile, Dopod M700. On mobile version, you have feature 'My Location' and integration with GPS works for me.

Cannot wait to see Malaysian Street View :-)

16 October 2008

1.0 is greater than 0.9.x [ies4linux]

helmi@gandalf:~/Packages/ubuntu/ies4linux-2.99.0.1$ ./ies4linux
IEs4Linux 2 is developed to be used with recent Wine versions (0.9.x). It seems that you are using an old version. It's recommended that you update your wine to the latest version (Go to: winehq.com).


and when

helmi@gandalf:~/Packages/ubuntu/ies4linux-2.99.0.1$ wine --version
wine-1.0


what?? I't wrong warning dude. 1.0 > 0.9.x

19 September 2008

IE innerHTML - "Unknown runtime error"

"Unknown runtime error" -- only in IE. Occur when click 'innerHTML WITH form tag'

<html>
<body>
<form>
<div id="replaceme"></div>
</form>
<div onclick="replace();return false;">innerHTML WITHOUT form tag</div><br/>
<div onclick="replace2();return false;">innerHTML WITH form tag</div>
<script>
function replace() {
document.getElementById('replaceme').innerHTML = 'REPLACED';
}
function replace2() {
document.getElementById('replaceme').innerHTML = '<form>REPLACED form</form>';
}
</script>
</body>
</html>


innerHTML supposed to supported on all major browser, http://www.quirksmode.org/dom/innerhtml.html

Current solution, don't wrap the #replaceme div in form tag

30 August 2008

"unable to resolve host" that matter

The "unable to resolve host" is matter when I have problem installing mysql.

Whenever sudo in my hardy , I got "unable to resolve host" . No harm and my terminal works as usual, so just ignore it.
helmi@hix2:~> sudo -s
sudo: unable to resolve host hix2
Then, today wanna use mysql for my pet project.
helmi@hix2:~> sudo dpkg --configure mysql-server-5.0
sudo: unable to resolve host hix2
Setting up mysql-server-5.0 (5.0.51a-3ubuntu5.2) ...
* Stopping MySQL database server mysqld
...done.
Reloading AppArmor profiles Warning: found /etc/apparmor.d/force-complain/usr.sbin.named, forcing complain mode
: done.
* Starting MySQL database server mysqld
...fail!
invoke-rc.d: initscript mysql, action "start" failed.
dpkg: error processing mysql-server-5.0 (--configure):
subprocess post-installation script returned error exit status 1
Errors were encountered while processing:
mysql-server-5.0
Nothing in /var/log/mysql.err or /var/log/mysql.log , but something in /var/log/syslog
Aug 30 05:07:00 hix2 mysqld[2817]: 080830 5:07:00 [ERROR] Fatal error: Can't open and lock privilege tables: Incorrect file format 'host'
Then "unable to resolve host" become matter now. Solution: add following line to /etc/hosts, then reconfigure mysql
127.0.1.1 hix2
Refs:

15 May 2008

Connect winxp lappy to kubuntu using samba

I want transfer files from my lappy to my kubuntu desktop FAST. I managed make my lappy talk to kubuntu via ssh (winscp), but not fast enough. Yeah, I know it caused by encrypt, bla bla ... I'm the only one who use LAN in my home, so who cares about security???

Anyway, since new to setup samba, I thought it just matter click Next, Next, ... and so on. Not that easy maa. After setup it in kubuntu, whenever I submit uname/passwd from windows xp, it keep popup the uname/passwd, without error msg. Spend hours RTFM, google , read article, ... then, manage to fix it. When troubleshoot, I reach to the:

C:\> net view \\bigboy
System error 5 has occurred.

Access is denied.


Then, it easier to fix when know cause of the problem. Just enable the 'encrypt password = yes'. I also added the samba user by smbpasswd

11 May 2008

Why I hate innerHTML

Why I hate innerHTML? Because IE suck! It doesn't work for select tag in IE. I have something like

<div>
<select id="foo"><option value="1">baz</option></select>
</div>


Javascript that doesn't work in IE:
document.getElementById("foo").innerHTML = '<option value="2">baz</option>';


Solution -- have to use DOM lah! Note that use innerHTML will destroy the tag events. My prefered solution:


document.getElementById("foo").options[0] = new Option("baz", 2);


Astute reader may ask, why not use dom method add() ? Again, because IE suck!


var x=document.getElementById("foo");
try
{
x.add(y,null); // standards compliant
}
catch(ex)
{
x.add(y); // IE only
}

http://www.w3schools.com/htmldom/met_select_add.asp

More love/hate on innerHTMl, http://www.wait-till-i.com/2006/04/18/innerhtml-vs-dom-pot-noodles-vs-real-cooking/

11 February 2008

php popen whitespace bug in windows

This popen path with whitespace bug, http://bugs.php.net/bug.php?id=40988&edit=1 make my day worse. Tired from long 9 hours journey from 'balik kampung', arrive at 3.30am and 8.30am go to office, huh. Then have to debug why the stupid php don't want execute the command.

I want use php to backup a postgis table. So

system('"C:\\Program Files\\PostgreSQL\\8.2\\bin\\pg_dump.exe" -t project_geom projectgis > '.$backup);


that, should straight forward, but the output is empty page. Then use popen to redirect the stdout and stderr, 2>&1 for debugging, I get this message

'C:\Program' is not recognized as an internal or external command, operable program or batch file.


Tried many technique to solve: escapeshellarg(), backslash to slash, all lowercase, etc, then afters spent hours debugging, it was the php problem, not my code. grrr.

BTW:
A 8.3 name (PROGRA~1) will still work on Windows, if it's not disabled
in the NTFS settings.

05 February 2008

Traffic images on google map

Simple map to show live traffic images.

Wake up early plus lazy to go to office :-( Rather than read reddit and google reader, this morning I decide to create simple map instead. Map for my town and click the marker for live traffic image, hah, deadly simple idea! Since lazy morning, I don't know any legal issue regarding the image, so "It's Easier to Ask Forgiveness Than Permission"

01 December 2007

Turn VIM omni completion ON

Turn omni completion feature by put this in vimrc.
autocmd FileType python set omnifunc=pythoncomplete#Complete
autocmd FileType javascript set omnifunc=javascriptcomplete#CompleteJS
autocmd FileType html set omnifunc=htmlcomplete#CompleteTags
autocmd FileType css set omnifunc=csscomplete#CompleteCSS
autocmd FileType xml set omnifunc=xmlcomplete#CompleteTags
autocmd FileType php set omnifunc=phpcomplete#CompletePHP
autocmd FileType c set omnifunc=ccomplete#Complete


Default vim turn off this feature. And here to set ctags

ctags -R -f ~/.vim/qttags /usr/include/qt3

:set tags +=~/.vim/qttags

03 November 2007

Muslim prayer times by web scraping

Here I'll show how to get Muslim pray times by web scraping. Web scraping is one of the methods to implement mashup.


<?php

$curl_handle=curl_init();
curl_setopt($curl_handle,CURLOPT_URL,'http://www.e-solat.gov.my/solat.php?kod=sgr03&lang=ENG');
curl_setopt($curl_handle,CURLOPT_CONNECTTIMEOUT,2);
curl_setopt($curl_handle,CURLOPT_RETURNTRANSFER,1);
$buffer = curl_exec($curl_handle);
curl_close($curl_handle);

if (empty($buffer)) {
print '<a href="http://www.e-solat.gov.my/">Prayer Time</a>';
} else {
$waktu_s = array('imsak', 'subuh', 'syuruk', 'zohor', 'asar', 'maghrib', 'isyak');
$w = array();
foreach ($waktu_s as $waktu) {
$w[] = "<tr.*?>.*?<td.*?>.*?$waktu.*?<\/td>.*?<td.*?>.*?(?P<
$waktu>\d?\d:\d\d).*?<\/td>.*?<\/tr>";
}
$t = join(".*?", $w);
$regex = "/<table.*?>.*?$t.*?<\/table>/si";
$result = "";
if (preg_match($regex, $buffer, $matches)) {
$result = '<table border="1"><caption>Kuala Lumpur</caption>';
$result .= '<thead><tr>';
foreach ($waktu_s as $waktu) {
$result .= "<th>".ucfirst($waktu)."</th>";
}
$result .= '</tr></thead>';
$result .= '<tbody><tr>';
foreach ($waktu_s as $waktu) {
$result .= "<td>".$matches[$waktu]."</td>";
}
$result .= '</tr></tbody>';
$result .= '</table>';
}
print $result;
}

?>


Example of output as below:
Kuala Lumpur
ImsakSubuhSyurukZohorAsarMaghribIsyak
5:295:396:5813:0016:1918:5820:09


I'll leave to you as exercise to show the date of prayer times, GMT and qiblat direction.

31 August 2007

use onmousedown instead of onclick

Joseph Smarr give great talk about javascript performance, recommend to watch it. I'm not big fan of optimization, but in web application, load time (performance) matter. It interesting he claim that better performance when using onmousedown instead of onclick. And combine to setTimeout trick, setTimeout(func, 0), I can feel the difference in his demo. He also mention some other tips to improve javascript performance, so, watch it :-)

Hey, A Pattern Library for Interaction Design -- they update their website contents

03 August 2007

vim: Don't use escape key!

Esc is exactly equivalent to control-[ 
(that's the control key plus the left square bracket key)
For quite long time I hit Ctrl+c instead of Esc (mentioned in http://helmi-blebe.blogspot.com/2007/07/autodesk-mapguide-jakarta.html ), until vim7. Ctrl+c in vim7 don't behave Esc when indent lines of code using visual mode blockwise (:h blockwise). Also Ctrl+o in insert mode will switch to normal mode for one command only and automatically switch back.

Heh, learn 2 new tricks in vim today and still learning.

Somehow, the toolbar that supposed to assist compose this blog (in www.blogger.com) don't want to appear in my browser. Anyway, I compose in gmail instead.

http://vim.wikia.com/wiki/Don%27t_use_the_escape_key%21

22 July 2007

Autodesk Mapguide - Jakarta

Last week, went field trip to Jakarta for Mapguide training. The training quite boring for me since I familiar most of it, but at least, I learn properly.



You can use php to program the mapguide and can use ajax too. It quite easy for beginner, and have good API for advance user to extend it. In theory, you can implement your own ala google maps for Malaysia. My hands itchy now to programming, but where is public data for Malaysia???

Tip for vim user: You can also use 'Ctrl+C' to exit Insert Mode instead of 'Esc'. So keyboard layout user like below don't worry to mistakenly hit 'Power' key instead of 'Esc';

10 June 2007

ctags with PHP in vim

Another tip to code PHP effectively

#!/bin/bash
cd /path/to/framework/library
exec ctags-exuberant -f ~/.vim/mytags/framework \
-h ".php" -R \
--exclude="\.svn" \
--totals=yes \
--tag-relative=yes \
--PHP-kinds=+cf \
--regex-PHP='/abstract class ([^ ]*)/\1/c/' \
--regex-PHP='/interface ([^ ]*)/\1/c/' \
--regex-PHP='/(public |static |abstract |protected |private )+function ([^ (]*)/\2/f/'


to load it,
:set tags=~/.vim/mytags/framework

Ctrl-], and you'll jump to the file and line of its declaration; Ctrl-T then takes you back
Ctrl-W ], it will split the current window and open the declaration in the new pane

20 April 2007

VIM tips: blockwise selection mode and recording macros

Here a table schema from postgresql


col1 | integer | not null default nextval('sc.col1_seq'::regclass)
col2 | timestamp without time zone | not null
col3 | character varying(100) |
col4 | numeric |
col5 | numeric |
col6 | integer |
col7 | integer |
col8 | numeric |
col9 | numeric |
col10 | character varying(100) |
col11 | character varying |
col12 | character varying(100) | not null
col13 | character varying |
col14 | character varying |
col15 | numeric |
col16 | numeric |
col17 | numeric |
col18 | character varying |
col19 | numeric |


and I want using VIM to convert to

$ary = array('col1', 'col2', 'col3', 'col4', 'col5', 'col6', 'col7', 'col8', 'col9',
'col10', 'col11', 'col12', 'col13', 'col14', 'col15', 'col16', 'col17',
'col18', 'col19');


How I do it?
The idea is use blockwise selection mode to insert (') in beginning of each line, and use recording macro to append (',) for each line. Format it (not exceed 80 characters per line). More details step by step

  1. <Ctrl+V>GI'<Esc> -- blockwise selection mode and insert (')

  2. 0qaelC',<Ctrl+c>j0q -- record macro to regiser a

  3. 18@a -- replay macro in register a

  4. insert the $ary = array(

  5. VGgq -- to format it, i.e. each line max chars=80



I do a lot of migration work currently, and frequently use these tips. Not sure for other editor, but I believe Kate don't have these features. Sorry Kate, I just don't like U! Someone look impress when saw me using blockwise selection, and that motivate me to write this blog :-)

more tips, http://jmcpherson.org/editing.html

11 February 2007

Back References in trac 0.10.2

Back References lists all references to an ticket inside the details of it. I want this feature in my trac, but the patch is for version 0.11beta. So I spent half an hour to implement my patch. Not perfect, but just fit my need. (sorry, give up to create proper patch after 7 minute rtfm)
helmi@hix2:~> cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=6.10
DISTRIB_CODENAME=edgy
DISTRIB_DESCRIPTION="Ubuntu 6.10"
helmi@hix2:~> trac-admin --version
Trac Admin Console 0.10.2

10 February 2007

Broadband Throttling

Broadband throttling is:
  • try to move backward
  • MISLEADING THE PUBLIC WITH CHEATING MARKETING STRATEGY DESERVES A GOOD LAWSUIT
  • Better call it Streamyx Narrowaband or Streamyx Limitband
  • 4 days finish bandwidth and sit down there wait for another f***ing month to get another bandwidth usage
  • wanna throw up whenever i see the advert "breaking the speedometre"
  • "jaguh kampung" mentality? or the "we are still better than ghana" thinking?
  • definately ridiculous
as A. Asohan says in Throttling broadband access for all

Maxis did it first when it rolled out its wireless broadband service last year. Under the “Terms and Conditions” of usage, it had this little gem: “Maxis may, at its sole discretion, automatically disconnect the customer’s Internet session after a period of inactivity, which may vary from 20 minutes to 30 minutes.”

And if that’s not all, here’s the clincher: “Each customer’s total usage per month shall NOT exceed 3GB of data volume transmitted ...”

and I want add more complaint, bandwith during weekend is reaaaally suck (dial-up standard)

Average bandwith during weekend, 1.5Kb/s

@see http://www.lowyat.net/v2/latest/broadband-throttling-the-star-takes-notice.html
p/s: I am one of the Maxis broadband subscriber

21 January 2007

How I setup my 64bit machine to play flash in firefox

Use swiftfox instead of standard firefox as browser and install the flash plugin. I use automatix to install that packages.

Screenshot: swiftfox browser+plugins installed using automatix2
helmi@hix2:~> uname -a
Linux hix2 2.6.15-26-amd64-k8 #1 SMP PREEMPT Thu Aug 3 03:11:38 UTC 2006 x86_64 GNU/Linux
helmi@hix2:~> cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=6.10
DISTRIB_CODENAME=edgy
DISTRIB_DESCRIPTION="Ubuntu 6.10"
I tried gnash as flash player, but it eat a lot of CPU resource for some of the websites. Yeah I have dual core CPU, but still irritate me when gkrellm show CPU busy working. Another idea is setup 32bit OS in vmware and install the firefox. Swiftfox=32bit app, i.e. not fully utilize 64 bit machine.

One issue with swiftfox, my firebug don't work, i.e. hard for me to do web app development using swiftfox :-(

** not related to any geeky stuff ** Really bored recently. So, I decide to learn new skill that not related to computer - juggle 3 objects. I believe in repetition is mother of skill (liliadandelion say: mother of boredom), so after a lot of practising I can YIPPEE! now. Highscore=64

11 December 2006

Configure RADEON X550 on Kubuntu Edgy

Here I want to share how I configured my ATI RADEON X550 on Kubuntu Edgy.

I installed the driver in Kubuntu edgy manually. In short, download ati-driver-installer-8.31.5-x86.x86_64.run and follow the ATI linux driver guide.

Work in theory but give me pain before I get the 3D properly. Here the 'bad' messages:

helmi@hix2:~> vim /var/log/Xorg.0.log
...
[drm] failed to load kernel module "fglrx"
(II) fglrx(0): [drm] drmOpen failed
(EE) fglrx(0): DRIScreenInit failed!
(WW) fglrx(0): ***********************************************
(WW) fglrx(0): * DRI initialization failed! *
(WW) fglrx(0): * (maybe driver kernel module missing or bad) *
(WW) fglrx(0): * 2D acceleraton available (MMIO) *
(WW) fglrx(0): * no 3D acceleration available *
(WW) fglrx(0): ********************************************* *
...
helmi@hix2:~> glxinfo | grep 'direct rendering'
direct rendering: No
helmi@hix2:~> fglrxinfo
display: :0.0 screen: 0
OpenGL vendor string: Mesa project: www.mesa3d.org

After googling, I realize that the driver don't match to the kernel
helmi@hix2:~> uname -a
Linux hix2 2.6.15-26-amd64-k8 #1 SMP PREEMPT Thu Aug 3 03:11:38 UTC 2006 x86_64 GNU/Linux
helmi@hix2:~> gcc --version
gcc (GCC) 4.1.2 20060928 (prerelease) (Ubuntu 4.1.1-13ubuntu5)

I compile the ATI driver using gcc-4.1.2 but my kernel compiled using gcc-4.0. So the workaround is (follow the guide, copied here as my future reference):

sudo apt-get install gcc-4.0
sudo ln -sf /usr/bin/gcc-4.0 /usr/bin/gcc

After doing the module-assistant steps, you may want to return gcc to 4.1 by default:

sudo ln -sf /usr/bin/gcc-4.1 /usr/bin/gcc


After reboot,
helmi@hix2:~> glxinfo | grep 'direct rendering'
direct rendering: Yes
helmi@hix2:~> fglrxinfo
display: :0.0 screen: 0
OpenGL vendor string: ATI Technologies Inc.
OpenGL renderer string: RADEON X550 Generic
OpenGL version string: 2.0.6174 (8.31.5)
Yey! Next is Xgl/Beryl ...

If you notice I use kernel 2.6.15-26, and Edgy use 2.6.17-10. That new kernel just refused to start properly and I too lazy to debug it - my current kubuntu just `work for me`

04 December 2006

Page load faster after first request

It hard for me to explain why web page load faster when you visit the same url for second time. Non-geek just don't know how to visualize it, or people don't know what I'm talking about :-)
Now I have pictures

First request:

Second request:

Now understand? ... What, still don't understand???

24 November 2006

Why vmware snapshot is good idea?

Because you will know what to do when get Blue Screen of Death.
Here mine:
I want to get rid of message 'VMware Tools out of date'. After install and reboot, vmware give me this nice screen, yey!

01 November 2006

/bin/sh: bad interpreter: Permission denied

Got permission problem when run firefox2.

# ./firefox
# ./firefox: Permission denied

Just realize that all executable script have permission problem although give all permission to the file, i.e. chmod 777 script.sh. Even root have this permission problem.

Don't know how I edit the /etc/fstab, but my /home directory mount as 'auto'.
# cat /etc/fstab
/dev/hda1 /boot ext2 defaults 1 2
/dev/hda3 /home auto defaults,user 0 0

So, the solution is add option exec to the filesystem at /etc/fstab. My new /etc/fstab
# cat /etc/fstab
/dev/hda1 /boot ext2 defaults 1 2
/dev/hda3 /home auto defaults,user,exec 0 0


ref: http://forums.fedoraforum.org/archive/index.php/t-19374.html

21 July 2006

putty on nokia3230

Access to my home server using PuTTY on my Nokia 3230. I can even edit text using vim.





Buzzword for today = cometd (hint: ajax)

I'm in mode 'Korean movies'. My Little Bride, My Boss My Student, Please Teach Me English, My Tutor Friend

26 June 2006

An Optimization That’s Never Premature

I like this example about optimization:

Writing code that is difficult to read is like running up your credit card buying expensive toys; even though you don’t pay today, the bill is going to come due eventually — and the longer you wait the more it’ll cost.


I'm in Futurama fever. Now in Season 3, episode 9.

24 April 2006

vmware, apache, mplayer under kubuntu dapper [beta]

I follow this guide by Stoltenow, and it works for me.

apache2+kubuntu=SUCK!. I expect directory public_html in my home directory will be in apache DocumentRoot [like Suse and FreeBSD], but it not as expected. Have to edit the apache2.conf manually.

No mplayer in kubuntu dapper[beta]! Had uncomment /etc/apt/sources.list for universe and multiverse, but still no mplayer after `sudo apt-get update; sudo apt-get upgrade; apt-cache search --names-only mplayer`. Also had add `deb http://honk.sigxcpu.org/linux-ppc/debian/ mplayer/` in /etc/apt/sources, still no mplayer. I try the hard way, but the video don't want to come out.
VDec: vo config request - 208 x 170 (preferred csp: Planar YV12)
Could not find matching colorspace - retrying with -vf scale...
Opening video filter: [scale]
The selected video_out device is incompatible with this codec.

FATAL: Could not initialize video filters (-vf) or video output (-vo).

Can't restore text mode: Invalid argument

Hey! the mplayer Makefile don't want me to uninstall mplayer.

make uninstall
...
...
/bin/sh: -c: line 6: syntax error: unexpected end of file
make: *** [uninstall] Error 2


Conclusion, my VMware Workstation 5.5.1 build-19175 works! (apache or mplayer)+kubuntu dapper[beta]=SUCK!

Kubuntu? What happen to FreeBSD?
FreeBSD is retired from my harddisk. Sayonara...

18 April 2006

Firefox problem in FreeBSD 6.0 after portupgrade

After portupgrade FreeBSD 6.0 then you got this error when run firefox:

(Gecko:7209): GLib-GObject-WARNING **: cannot register existing type `GConfClient'


Panic, panic. What to do? Google ... :)

I had try several methods, read /usr/port/UPDATING, `portupgrade -varR -PP`, etc. FreeBSD only like the hard way `portupgrade -vaR`. It means when you portupgrade the first time, firefox don't like one of it upgraded version dependency. Which package? argh... I don't know :/ . So, have to do the hard way, ask FreeBSD upgrade the ports by compile it from source, wait it finish compiling, cross your finger hopefully the blue screen that ask package option don't appear, bla bla ... 2 days fighting with this, then my firefox is alive back, YEY!

tips: GConf involved with GNOME. Give `portupgrade -vPP libgnome-2.10.1` a try before `portupgrade -vaR` is a GOOD idea.

While compiling port, the FreeBSD give me this error:
ad0: timeout waiting to issue command
ad0: error issueing READ_DMA command
g_vfs_done():ad0s1f[READ(offset=29776416768, length=12288)]error = 5
vnode_pager_getpages: I/O read error
vm_fault: pager read error, pid 71516 (rtorrent)
ad0: TIMEOUT - READ_DMA retrying (1 retry left) LBA=61351999
ad0: TIMEOUT - WRITE_DMA retrying (1 retry left) LBA=62304671
ad0: TIMEOUT - WRITE_DMA retrying (1 retry left) LBA=62311103


Please don't tell me that you FreeBSD sucker cause my 80G, WD harddisk failed.

OK, stop ranting about FreeBSD.

Hey! Tab Mix Plus is COOL, recommended.

13 April 2006

Why lah UNO hate me?

I HATE this line:
Error (<class conversion.com.sun.star.lang.IllegalArgumentException at 0xb7bc8d1c>) during conversion:URL seems to be an unsupported one.

Because of this line, I'm keep whining for whole day!

I want OpenOffice convert my document to PDF using UNO. Works perfectly in my development box, but when using different box it don't like me. Hate deployment, hate hate ...

I wish that I'm get paid by the line :D , so I can apply this cheat in my code:
If Request.QueryString("source_url") = "" Then
strRedirect = strRedirect & "&verify=1"
If Request.QueryString("process") = "1" Then
strRedirect = strRedirect & "&process=1"
End If
Response.Redirect(strRedirect)
Else
strRedirect = strRedirect & "&verify=1"
If Request.QueryString("process") = "1" Then
strRedirect = strRedirect & "&process=1"
End If
Response.Redirect(strRedirect)
End If

12 February 2006

Why REST?

This is about Representational State Transfer not rest, verb.

Quote from ajaxpatterns:

" Witness the the debacle caused by the Google Accelerator interacting with non-RESTful services in mid-2005. The accelerator jumps ahead of the user and prefetches each link in case they should click on it (a non-Ajaxian example of Predictive Fetch). The problem came when users logged into non-RESTful applications like Backpack. Because Backpack deletes items using GET calls, the accelerator - in its eagerness to activate each GET query - ended up deleting personal data. This could happen with regular search engine crawlers too ... "


REST compared to RPC

08 February 2006

Where should define database schema?

Where should define database schema? in python (hint: django) or DDL.

Jonathan Ellis explain why schema definition belongs in the database. Yes, why reinventing the wheel create another database schema in .py (hint: django). Runtime introspection is good idea (hint: sqlalchemy, pydo).

After read Adrian Holovaty (hint: django) comment "Cache that, man. Cache it." my eyes wink wink ...

p/s: Nesting UnitOfWork in a Database Transaction seems more interesting compared to adodb CompleTrans()

12 January 2006

Short memory problem

My pair programming partner always complaint that I have bad short memory.

Is it because of my foods? :D

After read article, 12 Steps to Better Code, point #8, I guess I found the right answer.

... Productivity depends on being able to juggle a lot of little details in short term memory all at once. Any kind of interruption can cause these details to come crashing down. When you resume work, you can't remember any of the details (like local variable names you were using, or where you were up to in implementing that search algorithm) and you have to keep looking these things up, which slows you down a lot until you get back up to speed.

28 December 2005

Java is portable?

Snippet for a java code:

public static MultipartRequest createMultipartRequest (HttpServletRequest req)
throws IOException
{
[SNIP]

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

File check = new File (Constants.UPLOAD_PATH);

[SNIP]

}


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):

Array
(
[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>
<div>
<br/><input type="submit" value="Send">
</div>

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


main
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

Flickr

This is a test post from flickr, a fancy photo sharing thing.

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];

$v->set_style('background-color:red');

unset($v);
}

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() {
document.myform.foc.focus()
});


Usable form, example
Enhance structural markup with javascript, example

08 June 2005

YAGNI.

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
Message:/roundup/
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
"/usr/ports/databases/postgresql74-client/work/postgresql-7.4.8/config.log"
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"
end

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

COOL!

05 May 2005

Recompile MPlayer 1.0pre7 and install xfce4

My mplayer is recompiled today. This time, I add some flag in Makefile
WITH_OPTIMIZED_CFLAGS="TRUE"
WITHOUT_RUNTIME_CPUDETECTION="TRUE"

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:
PORT STATE SERVICE
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,
domain=hi.bsd
host=hi.bsd

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
18
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

Javascript

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. http://192.168.1.30/flyspray 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'

dependencies:
- 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