August 23, 2006

[javascript] IE6 & doctype & scrollTop property

Filed under: Programming — HanaDaddy @ 10:41 pm

I just realized that the old javascript that I copied & implemented on this forum does not properly work.

I am talking about the the preview popup window.

The popup window should always appear on the top of the link,but I found that it is shown in a totally different place when the webpage is scrolled down.

So I spent some time on the web and found below resource.

http://www.quirksmode.org/js/doctypes.html

According to him, there are difference accessing javascript body element properties such as clientHeight ,clientWidth , scrollLeft ,scrollTop and etc between IE5 & IE6 with DOCTYPE defined.

The popup window javascript code heavily uses document.body.scrollTop.
In IE5, document.body.scrollTop works fine, but when you use IE6 & DOCTYPE togather, you need to use docuement.documentElement.scrollTop property.

Also, some comparison demo pages
doctype onand doctype off

So I have changed the javascript little bit.

First I defined the IE6&DOCTYPE indicator doctype variable.

//we need to check if IE6 & doctype is on ( is used or not)
//doctype=1 (IE6 & doctype) or regular IE6 IE5
var doctype=0;
if(document.documentElement && document.documentElement.clientHeight )
{ doctype=1; }
else
{ doctype=0; }

Then I use it to get the correct Top & Left position of the popup window.

if (doctype==1)
{ ty=document.documentElement.scrollTop; tx=document.documentElement.scrollLeft;}
else if (doctype==0)
{ ty=document.body.scrollTop; tx=document.body.scrollLeft;}
x=event.x + tx+10;
y=event.y + ty;

And it works perfectly!

By the way, in IE6 & DOCTYPE OFF environment, you need to use document.body.scrollTop property.

[Java] Java Compiling & Execution in Shell

Filed under: Programming — HanaDaddy @ 10:33 pm

I just created this DB transfering class from Oracle to Mysql and tried to run it under linux, but had hard time to compile & run it.

But I successfully did it. And the code works fine too.


javac -classpath /var/www/java_libs/mysql-connector-java-3.1.7-bin.jar:/var/www/java_libs/v9_ojdbc14.jar:/var/www/import importdb/Import.java

java -classpath /var/www/java_libs/mysql-connector-java-3.1.7-bin.jar:/var/www/java_libs/v9_ojdbc14.jar:/var/www/import importdb/Import

The main class is Import and it is a part of package ImportDB.

/var/www/java_libs/mysql-connector-java-3.1.7-bin.jar : MySQL lib downloaded from MySQL website

/var/www/java_libs/v9_ojdbc14.jar : Oracle Lib downloaded from Oracle website

Note that the /var/www/import in the classpath. This is where importdb folder is located. It is necessary. Without it, you will get Exception in thread “main” java.lang.NoClassDefFoundError: importdb/Import.

August 22, 2006

[C] Separate Large Mailbox(IMAP format) into two files based on date

Filed under: Programming — HanaDaddy @ 10:26 pm

You can generate a copy of your IMAP mailbox based on particular date and hour.

Actually this code generate a copy of IMAP mailbox based on the date & optionally hour argument.

Arguments: mailbox_filename date(mm/dd/yyyy) [hour]
hour is optional arg.

For example, if your inbox size is larger than 50 Meg and you are having hard time to read the box with your shell mail client.

Let’s say you want to save mails from ‘usermail’ file upto 09/01/2005.

You should run ( let’s say the compiled program’s name is divide)

$> divide usermail 09/01/2005

Then all mails received after 09/01/2005 will be saved to ‘usermail.bak2′.
You can backup the original mail file and rename the ‘usermail.bak2′ to ‘usermail’.

Here is the actual code.
(more…)

[C] Debugging Segment Error with gdb in Linux

Filed under: Programming, Uncategorized — HanaDaddy @ 10:22 pm

1. Compile the source with -g option.

2. run gdb

(gdb) file exefile
(gdb) run [arg is optional]

After segment error occurs, type ‘up’ until you see the proper source file & line where the segment occurs.

(gdb) up
(more…)

August 21, 2006

[C] CR, LF

Filed under: Programming — HanaDaddy @ 11:41 pm

I always confuse between 0D & 0A.

CR = \r = Hex: 0D = Decimal : 13
LF = \n = Hex: 0A = Decimal : 10

Line Break:
DOS : \r\n
UNIX: \n

Page 3 of 3«123
 

43 queries. 0.376 seconds. Powered by WordPress