Here is some trick to let the code run faster, I face this long time ago, finally I am able to write it down.
For CodeA & CodeB:
The different will be very big when the String Array gone larger. If let say the size of the String Array is 100, CodeA will create 100 Integer object to store it's size, the program will end up like this CodeC.
Obviously, every loop set the String Array size is unnecessary. So, it is alway better to keep CodeB practice.
"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." - Martin Fowler
Thursday, October 18, 2007
Wednesday, October 17, 2007
"code" Support
Yo, I add in something that will be useful on my own posting since I am a programmer.
Here is the CSS I used to create this "code" tag:
I am still thinking how to implement this into RSS feed which is a XML, not support CSS. If you didn't understand what I mean, open this post in a browser, then you will see the different.
Here is the CSS I used to create this "code" tag:
I am still thinking how to implement this into RSS feed which is a XML, not support CSS. If you didn't understand what I mean, open this post in a browser, then you will see the different.
How to use Netbeans to generate Javadoc
I guess somebody already know this, but I think there are somebody who didn't know it as well, so, I just put it up here.
Next time when you having development in Netbeans, try to write comments using its Auto Comments feature.
So, after all the comments had been write, you just need to right click on the project and click on "Generate Javadoc", then this will come out.
Next time when you having development in Netbeans, try to write comments using its Auto Comments feature.
So, after all the comments had been write, you just need to right click on the project and click on "Generate Javadoc", then this will come out.
Sunday, July 8, 2007
Microsoft Access SQL Problem
I am having problem with this SQL in MS Access:
This query seem like working fine in most SQL software but not in MS Access. Either I or MS Access suck.
This query seem like working fine in most SQL software but not in MS Access. Either I or MS Access suck.
Saturday, July 7, 2007
SQL Injection
I had been heard "SQL Injection" since last 2 years, but until now I still haven't completely implement it on my website.
Last time Francis Pang hack into my website by login as my username to post here. Owcs also got mention to me about this. Furthermore, my colleague recently keep on remind us to avoid SQL Injection coding style.
Here some nice SQL Injection Walkthrough, teach us how to become web hackers.
Here I found some common solution for "SQL Injection" -- SQL Injection Attacks: Are You Safe?. But I dun think I can implements the killChars() function here. (I already implements stripQuotes() function long time ago)
Other than SQL Injection, I also found this -- Calling MS Access Parameterized Queries from ASP. Something like Hibernate, manage all the queries in one place. I think I will implements this as well.
Last time Francis Pang hack into my website by login as my username to post here. Owcs also got mention to me about this. Furthermore, my colleague recently keep on remind us to avoid SQL Injection coding style.
Here some nice SQL Injection Walkthrough, teach us how to become web hackers.
Here I found some common solution for "SQL Injection" -- SQL Injection Attacks: Are You Safe?. But I dun think I can implements the killChars() function here. (I already implements stripQuotes() function long time ago)
Other than SQL Injection, I also found this -- Calling MS Access Parameterized Queries from ASP. Something like Hibernate, manage all the queries in one place. I think I will implements this as well.
Tuesday, July 3, 2007
Char to Varchar
I am facing some problem in some SQL coding recently.
The problem is like this:
A database field having a data type of Char[3], when using java coding style to execute the SQL, it automatically convert the data to java.lang.Character, which I don't understand why a Char[3] (Example: "abc") can converted into java.lang.Character (Example: "a"). The last 2 characters had been eaten.
So, my solution will be changing the SQL code from [select testAbc from tableAbc] to [select cast(testAbc, varchar(3)) from tableAbc]. With the help of "Cast", it finally manage to convert the data to java.lang.String & output correctly.
The problem is like this:
A database field having a data type of Char[3], when using java coding style to execute the SQL, it automatically convert the data to java.lang.Character, which I don't understand why a Char[3] (Example: "abc") can converted into java.lang.Character (Example: "a"). The last 2 characters had been eaten.
So, my solution will be changing the SQL code from [select testAbc from tableAbc] to [select cast(testAbc, varchar(3)) from tableAbc]. With the help of "Cast", it finally manage to convert the data to java.lang.String & output correctly.
Friday, June 29, 2007
Dynamically Creating PDFs in a Web Application
I found this tutorial pretty useful, creating a PDF using iText without storing it, but stream out to the client browser.
Here the tutorial: Dynamically Creating PDFs in a Web Application
Here the tutorial: Dynamically Creating PDFs in a Web Application
Subscribe to:
Posts (Atom)