Snippets code from my daily experience

June 30, 2007

Flock is a bug!!!!

Filed under: firefox,flock,mozilla,xpcom — dafi @ 9:34 am

The browser flock is developed starting from Mozilla Gecko code but has many specific features.

Together with many cool features the flock team has added many bugs not present in original Gecko code!

The last I found involves the DOMAttrModified event listener.
The code below works on Firefox 1.5, 2.x and 3.x (thunks) but doesn’t work on flock!!!

onLoad : function() {

var feedButton = document.getElementById("feed-button");

if (feedButton) {

// add the listener for feedButton

document.addEventListener("DOMAttrModified", RichFeed.onAttrModified, false);

// triggers a modification only to test the listener

feedButton.setAttribute("feeds", "true");

// onAttrModified should receive the modification but this doesn't occur on Flock

var v = feedButton.getAttribute("feeds");

}

}

onAttrModified : function(event) {

if (event.target.id == "feed-button") {

// never called with Flock browser

}

}

So my decision is to stop the flock support on my bonzai extensions, I have no time to search workarounds to all flock bugs.

Who cares for my decision? Nobody I know 😦

June 24, 2007

RichFeedButton: my new bonsai Firefox extension

Filed under: firefox — dafi @ 9:03 am

Finally I’ve found enough time to write a new extension for Firefox that fits my needs

I use Thunderbird as email client but also as rss feeder, I prefer Thunderbird because when I read new emails immediately I can see new contents on my subscribed feeds.

Adding feeds to Thunderbird is easy but if you come from a browser navigation you must get the feed url from page and then type it on Thunderbird.

I prefer to have feeds on clipboard and paste them on Thunderbird!

RichFeedButton makes exactly this! Copy your feeds on clipboard, period!

Simulating top level domains on localhost

Filed under: apache_httpd — dafi @ 8:44 am

On my local Apache test server I’ve configured many fake TLDs that take their contents from different directories (DocumentRoots).

But I found the problem to allow web browser to serve the correct content.

For example if I type the url http://dafizilla.stage I want to get content from /dafi/stage/dafizilla

if I type the url http://svn.myjavasrc I want to get content from /dafi/src/svn

Obviously dafizilla.stage and svn.myjavasrc are fake TLD and they are hosted on same Apache Server on my localhost.

Well the solution is to use Apache VirtualHost.

Add to /etc/hosts on Linux or C:/WINDOWS/…/etc/hosts on Windows the fake TLDs for localhost

127.0.0.1 dafizilla.stage svn.myjavasrc

Then define in httpd.conf the VirtualHosts:

NameVirtualHost localhost

<VirtualHost localhost>
DocumentRoot /dafi/stage/dafizilla
ServerName dafizilla.stage
ErrorLog logs/stage-dafizilla-host-error_log
</VirtualHost>

<VirtualHost localhost>
DocumentRoot /dafi/src/svn
ServerName svn.myjavasrc
ErrorLog logs/svn-host-error_log
</VirtualHost>

The browser inserts into HTTP headers the domain name that is lookedup by Apache server

June 22, 2007

Using UTF-8 with Apache and Jboss

Filed under: apache_httpd,java,jboss,utf-8 — dafi @ 2:26 am

I’ve found a strange problem with my first real UTF-8 web application…

The urls sent in GET didn’t decoded properly and I was very astonished, my code was written correctly but the problem was present.

BTW the problem wasn’t on my code but in Jboss (in Tomcat embedded instance).

The connector must have the attribute URIEncoding otherwise the webapp never will work.

Due to the fact I use mod_jk (ie AJP13 protocol) this lifesaver attribute must be added in AJP13 connector, too

I love when problems disappear modifing only a configuration file 🙂

For sanity check I’ve added UTF-8 support also in Apache Server but I suspect this isn’t really necessary 😉

In http.conf be sure to have the AddDefaultCharset directive set as shown below

AddDefaultCharset utf-8

June 16, 2007

The launched commands top ten

Filed under: cygwin,unix — dafi @ 7:57 am

topyli shows a bash command line to list the launched commands top ten

A very simple command line

history | awk '{print $2}' | awk 'BEGIN {FS="|"} {print $1}'|sort|uniq -c | sort -rn | head -10

June 9, 2007

Cygwin managed mount points and bad filenames… when UGLY == %55%47%4C%59

Filed under: cygwin — dafi @ 5:10 pm

I love cygwin, I can’t live without it but not all features are so cool.

Recently I’ve used cygwin managed mount points, a cool feature that allows you to create symbolic links in Microsoft Windows. So if you write

mount -f -s -b -o managed "c:/prj/src/java" /srcjava

you can use /srcjava to access to mounted directory, e.g. ls /srcjava

But if you create files containing uppercase letters in names they are shown in strange manner.

For example the file UGLY is shown as %55%47%4C%59 (percent sign followed by decimal ASCII value for every character).

This behaviour is ugly for me and so I’ve dropped all managed mountpoints!

Jdbc Oracle timestamps lose hours/minutes and seconds

Filed under: java,jdbc,oracle — dafi @ 9:30 am

Every Friday about thirdy minutes before I go to home to begin my weekend my collegues make my a very strange question.

This time the question is:

“Hey Davide! Java truncates the timestamps how is this possibile?”

and they continues

“I need this code works before yesterday, please help me to resolve this bug”

Well after some googling I found the motivation, Oracle 10g JDBC driver must be done retrocompatible

Add this line to you application server, Swing application or where you prefer

JAVA_OPTS="$JAVA_OPTS -Doracle.jdbc.V8Compatible=true"

The example refers to JBoss

More Jboss on same machine (shutdown)

Filed under: java,jboss — dafi @ 9:19 am

When you run the shutdown.sh script Jboss receives a “communication” through the NamingService port (default 1099) so if you want to stop a second Jboss instance you must modify the shutdown.sh script adding the line shown below:

JAVA_OPTS=-Djava.naming.provider.url=jnp://localhost:2099

Change the port number (in example 2099) to your Jboss correct value

More Jboss on same machine (startup)

Filed under: java,jboss — dafi @ 9:11 am

Bad practice, I know…

But when it’s necessary you need to change many port numbers to allow two (or more) JBosses to cohabit together.

Take a look at JBoss port table to save many hours and spend them on another problem 😉

Create a free website or blog at WordPress.com.