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.