Tech Sharing

Tech Sharing


Posts Tagged ‘ Programming ’

Google for long time regarding how to hide the HTTP header for IIS in order to mask the server identity and finally found out this tools call URLScan.
Basically URLScan is an ISAPI filter that allows Web site administrators to restrict the kind of HTTP requests that the server will process. By blocking specific HTTP requests, the URLScan filter prevents potentially harmful requests from reaching the server and causing damage.
Actually most of the features that provided by URLScan are included in IIS but not the Remove Server Header features as microsfot find out that this is not an important issue that that’s no real security benefit of include in IIS. But that’s some marketing purposes why microsoft not encourage web master to hide the identity.

How to hide the IIS identity:

  1. download the URL scan
  2. Install the URL scan in your server.
  3. go to the URLScan config file at C:WINDOWSsystem32inetsrvurlscanUrlScan.ini
  4. Change RemoveServerHeader=1 (by default is 0)
  5. Save the file
  6. Restart your IIS
  7. Check on your header (
For more detail on the URLScan and the features, you may easily get a lot of information by Google on URLScan

HTML table word wrap

By on September 21, 2009

I created a table to display a link which consist of a long verification code plus some variable to pass to the web site. There is no any space within the long url and query string. This is not the problem, the problem is on my table, because of the link is in one long string without any space, so when it display on the screen, the table is expanded.

I come across few solution, some people suggest that using the javascript to split the string in to 2 or more row when it excess the string lenght limit. I don’t think this is the best solution, and finally get the solution of control the table using the CSS.



<table style=”word-wrap: break-word;” width=100>

Get the array lenght in Coldfusion

By on September 4, 2009

When dealing with array, we cannot run away for looping. Because only with looping, you can cut short your hard coded script to read the value from array. And also you no need to worry about the dynamic of array.

Arraylen is the function that determines the number of elements in an array.

The syntax is ArrayLen(array)


<!— Assigning value into 3D array —>

<cfset ResultsArray[1][1][1] = ‘a’>
<cfset ResultsArray[1][1][2] = ‘b’>

<cfset ResultsArray[1][2][1] = ‘3’>
<cfset ResultsArray[1][2][2] = ‘4’>

<cfset ResultsArray[2][1][1] = ‘z’>
<cfset ResultsArray[2][1][2] = ‘x’>

<cfset ResultsArray[2][2][1] = ‘m’>
<cfset ResultsArray[2][2][2] = ‘p’>

<cfset ResultsArray[3][1][1] = ‘ww’>
<cfset ResultsArray[3][1][2] = ‘xx’>

<cfset ResultsArray[3][2][1] = ’22’>
<cfset ResultsArray[3][2][2] = ‘cc’>

<!— Read the array lenght for 1st D, 2nd D, and 3th D —>
#ArrayLen(ResultsArray)#<br> <!— Get the lehgth of 1st D —>
#ArrayLen(ResultsArray[1])#<br><!— Get the lehgth of 2nd D —>
#ArrayLen(ResultsArray[1][1])#<br><!— Get the lehgth of 3th D —>

There is always the good way to prevent and verify the using enter data, especially for each text box or text area.

The following is script use the event object to check on the key code that the user enter, return false to prevent user to enter.

Disabled space to be enter in javascript

onKeypress=”if (event.keyCode == 32) event.returnValue = false;”


Only allow number and . to be enter in javascript

onkeypress=”if (event.keyCode < 47 || event.keyCode /> 57) event.returnValue = false;”


database-symbolI try to google, call, msn my friend to find out the solution when I stay back in my office until late night yesterday. But still no luck after few hours of trying.

Thinking of gave up when back to office this morning, but one of my friend suddently send me the solution via MSN. That’s the best present I received by today. I’m not sure how many people will looking for this kind of solution, but any way, will post here to share with all and you may take it if you need it.

Basically the idea is that you put all your select, update or delete statment into the variable and use the execute command to execute the whole variable.

My problem:

I have a formula store in a table which is A+B*C+D. My A = 1, B=2, C=3, D=4.

I managed to replace all my variable with the integer using cursor (This maybe not a good solution, but this is not the main discussion in this post)

The finally answer I get is 1+2*3+4. But the bad thing is in the varchar datatype. I only manage to disply 1+2*3+4 but not the answer of 11.

The solution as below:

Declare @MathFomula Varchar(100)

Set @MathFormula = ‘1+2*3+4’

Exec(‘SELECT ‘ + @MathFormula  + ‘ AS Result’

Output: 11

* Remember that * and / will calculate at first before + and –


Normally to get the number of row for a particular table, where we will do is as the following query:

select count(*) from Table_name

Yes, you may get your result very fast if your table is very small, but if your table is more then 100k rows, then you may face some delay on that. What the above query do is actually it run the full table scan to get the row count. The scaning can be Logically or Physically. Logically mean that the SQL server only scan from the catch memory, whereas physically scan mean that it really scan through your table.

Actually there is anther alternative way to get the total row count for a table. You can ultilize the sysindexes system table for this purpose.

There is ROWS column in the sysindexes table. This column contains the total row count for each table in your database. So, you can use the following select statement instead of above one:

FROM sysindexes
WHERE id = OBJECT_ID(‘table_name’) AND indid < 2

There are physical read and logical read operations. A logical read occurs if the page is currently in the cache. If the page is not currently in the cache, a physical read is performed to read the page into the cache. To see how many logical or physical read operations were made, you can use SET STATISTICS IO ON command.

The example:



SELECT count(*) FROM tbTest


SELECT rows FROM sysindexes WHERE id = OBJECT_ID(‘tbTest’) AND indid < 2







(1 row(s) affected)

Table ‘tbTest’. Scan count 1, logical reads 32, physical reads 0, read-ahead reads 0.




(1 row(s) affected)

Table ‘sysindexes’. Scan count 1, logical reads 2, physical reads 0, read-ahead reads 0.

mssql2005This whole morning just spent about 1 hours+ just to try out one very simpel query on MS SQL 2005.

I keeping get the null value whenever i run this query, even in my program or run directly from the MS SQL 2005 management studio.

Finally I found out that is you are concatenate null values, either the concat null yields null setting of sp_dboption or SET CONCAT_NULL_YIELDS_NULL determines the behavior when one expression is NULL.

With either concat null yields null or SET CONCAT_NULL_YIELDS_NULL enabled ON, String + NULL returns NULL. If either concat null yields null or SET CONCAT_NULL_YIELDS_NULL is disabled, the result is String?

This is the case 1

Update tableA
set field1 + ‘My value’
where field2 = 1

This is the case 2

select ‘test ‘ + null + ‘ string’


This is the solution

set concat_null_yields_null off
select ‘test ‘ + null + ‘ string’

test string


By on December 25, 2008

If you are looking for any light, syntax highlight, simple yet useful text editor for your programming, then you should have a look on the Notepad2.


Notepad2 is  open-source Notepad like application for Microsoft Windows, which released under the BSD software license. 


Notepad2 is develop by Florian Balmer using the Scintilla editor component, and was first publicly released in April 2004. Balmer based Notepad2 on the principle of Microsoft Notepad: small, fast and usable.


The most powerful features for Notepad2 is the syntax highlighting. It will detect the following computer language such as ASP, Assembly, C, C++, C#, CGI, CSS, HTML, Java, JavaScript, NSIS, Pascal, Perl, PHP, Python, SQL, VB, VBScript, XHTML and XML. It also will automatically highlight the following file formats such as BAT, DIFF, INF, INI, REG and configuration files (.properties)


Not only that, Notepad2 also including the Auto indentation, Bracket matching, encoding conversion between ASCII, UTF-8 and UTF-16 formats. In addition, it also include the features of Newline conversion, between DOS (CR/LF), Unix (LF) and Mac (CR) formats. Last but not lease, the regular expression based find and replace also including in Notepad2


Click here to download notepad 2 binary file

Click here to download notepad2 source code


Notepad2 Screen Shot on Syntax Highlighting

Notepad2 Screen Shot on Syntax Highlighting

Notepad2 Screen Shot on Syntax Highlighting

Notepad2 Screen Shot on Syntax Highlighting