Skip to content

Teguh Eko Budiarto

Web Programming and Sharing Experience

If you use netbeans and somehow, the IDE’s fonts are not smooth enough comparing to gnome display you can fix it with below steps.
Go into your Netbeans install directory. For me, it was in /usr/local/netbeans-7.0/.
Look for the etc directory and open the file named netbeans.conf in your favorite text editor.

Add the following to your netbeans_default_options:

-J-Dawt.useSystemAAFontSettings=lcd

Start netbeans, and your font will be as smooth as ever.

Bookmark and Share

CSSTidy is the best tool to optimize your css code. However, due to development of CSS3 nowadays, there are already some property are not being converted properly. One of them is the gradient feature.

Timothée Carry-Caignon had a patch already for the PHP code, but I am using the executable files to generate it on the fly with django-compress extension. Therefore, I tried to give it a shot on the C++ source code.

To make it short, here you can find the csstidy1.3.patch file. Apply it against the original source code by Florian Schmitz (the original CSSTidy author) from sourceforge.

After that, you can compile it using below command:
g++ *.cpp -o csstidy

I hope you guys find it useful, cheers!

Bookmark and Share

I spent couple of hours to find the solution of this bug, so I just post it here hope it can help somebody else. Btw, the IE version was 8 in windows XP environment.

The problem is introduced here http://www.quirksmode.org/bugreports/archives/2006/01/Explorer_z_index_bug.html

and here
http://therealcrisp.xs4all.nl/meuk/IE-zindexbug.html

Some of the solutions proposed are here:
http://brenelz.com/blog/squish-the-internet-explorer-z-index-bug/
http://systembash.com/content/css-z-index-internet-explorer/

(try to open those pages in IE and FF / Chrome to compare)

What really worked for me was the combination of two solution above, set position:relative to the containing divs and give each containing div higher value of z-index of the contained one.

Case example :

1
2
3
4
5
6
7
8
9
10
<div style="z-index:5; position:relative">
    <div style="z-index:4">
        <div style="z-index:3">
        </div>
    </div>
</div>
<div style="z-index:2; position:relative">
    <div style="z-index:1">
    </div>
</div>

For the code above, we should be able to see the div with z-index 3 on top of the divs positioned after it (z-index 2 and 1).

Bookmark and Share

This is to note that the username for LAMPP process for MySQL and Apache is nobody. It is different than the default username for apache process which is www-data. To easily granted access for the web server apps, just change the owner of the accessed directory to nobody by using below code:

sudo chown nobody <path-to-folder>
Bookmark and Share

We are using SVN to save our works and hooking a post-commit script which one of the function is to send e-mail regarding the changes that had just made. We are using the wonderful SVN::Notify, a perl application to do the job. It already have the functionality to produce a beautifully diff colored HTML email using the SVN::Notify::HTML::ColorDiff module as the handler.

However, since we are using web based Google Apps Gmail interface as our email client, the HTML was not rendered nicely because the CSS is not applied inside the interface. We need to change the CSS to the inline style. And then I found a patch done here. Because it is a direct hack, I want it to be more generic that the user can choose the inline style or not, then I modified a little bit more. I added optional parameter –css-inline to generate CSS style directly inline with the HTML tags. I had submitted the changes to the original author hoping he will include this option in the next revision. Just in case, I also put it here.

Snippets to add the additional parameter:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
package SVN::Notify::HTML;
 
# $Id: HTML.pm 4617 2009-03-19 17:04:53Z david $
 
use strict;
use HTML::Entities;
use SVN::Notify ();
 
$SVN::Notify::HTML::VERSION = '2.79';
@SVN::Notify::HTML::ISA = qw(SVN::Notify);
 
__PACKAGE__->register_attributes(
    linkize   => 'linkize',
    css_url   => 'css-url=s',
    wrap_log  => 'wrap-log',
    css_inline => 'css-inline',
);

You may download the full source below:

Bookmark and Share

Since Python is not a strongly typed programming language, you do not have to specify your variable type. This is nice but have some drawback for Netbeans, which it can not recognize the type easily so you can not have good suggestion for the intellisense feature. To fix that you have to specify the type of your variable and make sure you already import the correct module.

For example, when you have this kind of code (below code are for example purpose only)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
from datetime import datetime
from django.db import models
from django.utils.translation import gettext_lazy as _
 
class Poll(models.Model):
    question = models.CharField(max_length=200)
    password = models.CharField(max_length=200)
    pub_date = models.DateTimeField(_('date published'), 
                          default=datetime.now)
    class Admin:
        pass
    def __str__(self):
        return self.question
    def get_choice_list(self):
        return list(self.choice_set.order_by('id'))
    def get_choice_from_num(self, choice_num):
        try:
            return self.get_choice_list()[int(choice_num)-1]
        except IndexError:
            raise Choice.DoesNotExist
 
class Choice(models.Model):
    poll = models.ForeignKey(Poll)    
    choice = models.CharField(max_length=200)
    votes = models.IntegerField()
    class Admin:
        pass
    def __str__(self):
        return self.choice
    def get_num(self):
        try:
            return self.poll.get_choice_list().index(self)+1
        except ValueError:
            raise Choice.DoesNotExist

For people like me, usually the first thing I do when want to use a defined variable is to hit the ctrl-space button to display the Intellisense suggestion. But in this case, when I want to use functions or variables defined in the attribute poll in Choice class, it displays :
specify type netbeans python

Which means Netbeans does’nt understand the type and the intellisense just throw all the types available to you and it become garbage, instead of suggestion. To teach Netbeans the type of the variable, just click the Specify type of [the variable name] menu, and then type your variable’s type. After that the intellisense will give you nice result, like this picture below:
specified type netbeans python

Other thing is to make sure you have imported your class in your file so Netbeans will recognized it properly. Hope it helps, Cheers! :)

Bookmark and Share

This tip is for windows XP user ( some other windows version will also have similar procedure).

If you are using an automatic configuration script for your internet setting, most probably, Python will not be able to connect to internet. This is troublesome if you want to install some packages which has dependencies which need to be fetched from the net. You need to change your internet options setting to use the proxy address directly.

Below is how to do that:

  • Go to Control Panel
  • Open Internet Options
  • Open Connection Tab
  • Click on LAN Settings button
  • Check the Use a proxy server for your LAN…
  • Enter the proxy IP Address and its port. If you do not know where it is, ask your network administrator or just open the configuration script to find out where is the IP you need to use.
  • Press OK until all the setting windows are closed.

Below is the screen shot of the internet options screen.

Windows XP Professional Internet Options Screen

Windows XP Professional Internet Options Screen

Bookmark and Share

I wrote this post in my journey to adapt Python with Django framework as my tool in the next project. A little bit skeptical and some holding back since I had background in PHP and C# .Net. But, I have no choice because Python is already team’s decision for new projects. So, here I go with learning new language and framework again.

In the way, sometimes I can not find a distributable package for your Python version. In one case, I would like to install setuptools to install other packages, soaplib which I need to build a SOAP web service. This is because most of our legacy applications are using C# which using SOAP to interface with web services, otherwise, I prefer to create REST based web service. Anyway, this is just my beginner way of thinking.

So, enough with the mumbling, below is how it is:

  • Unpack the source into a folder.
  • Using command prompt, go to the folder and run command below ( I assume that you already set your python PATH and can run Python command from command prompt).
  • python setup.py bdist_wininst
  • Voila! An executable installer for your installed Python version will be available in dist sub folder.

Very easy isn’t it? Yeah, if it is that easy for me to find how in the first place, I would’nt write this post.

Bookmark and Share

I just upgraded my laptop harddisk. It is not that I need more space, but the old harddisk was failed several times, in a very critical moment when having tele-screen-sharing-conference with my client :( . Anyway, that was a different story. The story here is that I have to re-install my computer, and unfortunately, I haven’t got image backup of my HDD yet…another big mistake. However, I managed in a single, almost sleepless night to make it ready for to code again, and now already create the image for clean backup :) .

One of the main application I used to code is Netbeans. I love this editor. However, I am using Japanese as my windows locale, so as default, Netbeans will use that setting and display japanese menu. Even though until now, I am already living in Japan for 5 years, I still prefer English as my application menu language, so I don’t have to bother searching difficult kanji which can waste my productive time.

I did the setting before to change the locale to English after some time searching the web for the correct setting. And now, I have to do it again, but I don’t know where to find it anymore since I did not write about it anywhere. So, here it is. You may change the configuration of Netbeans, following instructions from this Netbeans Wiki.

To change the locale, you need to add text below after the last configuration in netbeans_default_options.

-J-Duser.language=en -J-Duser.region=US -J-Dfile.encoding=UTF-8

This is valid for Netbeans 6.5, and 6.71 when this post is written. I hope this can be useful for somebody besides me :) .

Bookmark and Share

I was using JQuery autocomplete from Jörn Zaefferer to finish a small project for Computer Telephony – IPX PBX user interface. I think this is an awesome plugin ad it is suited very well for my project.

For the project, I need the autocomplete to be able to search all data containing words which begins with the text being typed in the input textbox. However, after browsing through the documentation and try the possible combination of matchContains and matchSubset options of the plugin, it seems that it was not able to do what I want it to do. So, I decided to debug the javascript and go into the code to modify the search algorithm.

When I look into the code, I found this part of code:

1
2
3
4
5
6
7
8
9
10
function matchSubset(s, sub) {
    if (!options.matchCase) 
        s = s.toLowerCase();
    var i = s.indexOf(sub);
    if (options.matchContains == "word"){
        i = s.toLowerCase().search("\\b" + sub.toLowerCase());
    }
    if (i == -1) return false;
    return i == 0 || options.matchContains;
};

In the fifth line of the function, there is a value check for matchContains option which implies that it received “word” value besides boolean true or false. The code uses the javascript search function with regex using \b tag which means word boundary. This means that it already have the functionality to search for subset contained in each word of the search data.
I immediately changed my code to try to use the option by adding this line:

matchContains:"word"

So, the whole code to activate the autocomplete textbox is as below:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
 $("#searchInput").autocomplete(json.Data, {
    cacheLength:1,
    delay:0,
    formatItem: function(row)
    {
        var sShow = row.Name + " - (" + row.TypePhone + ") " + row.Phone;
        return sShow;
    },
    matchContains:"word",
    matchSubset:true,
    max:100,
    minChars:1,
    width:285,
    selectFirst:true,
    scrollHeight:"100px"
});

After that, I try to find in the author’s website and JQuery documentation where in the world that option is being documented. At last I found it in the change log for the latest version 1.1 (per this post date). It should be also written in the JQuery plugin documentation, since it is a very useful feature, at least for me at the time :) . I hope the author would update the documentation accordingly soon.

Bookmark and Share