Thursday, February 02, 2006

Top Ten Javascript

Accidentially stumble upon this 10 common custom Javascript and from the look of it, I find it useful for some of the functionalities. Hope it serves useful to you too.

http://www.dustindiaz.com/top-ten-javascript/

Thursday, July 21, 2005

.NET form post

Some good links for WebRequst on .NET

http://www.netomatix.com/HttpPostData.aspx
http://www.developerfusion.co.uk/show/4637/
http://weblogs.asp.net/jan/archive/2003/12/04/41154.aspx
http://weblogs.asp.net/wim/archive/2004/04/02/106281.aspx

Tuesday, February 22, 2005

ASP - Get vs Post

Most of the common form method handling will not escape the usage of GET or POST method to submit the data. While working on a project and experimenting both the methods I found out an interesting result...

GET got priority over POST method. If you use the Request.Querystring method in ASP, it will obtain all the required parameters. But for the POST method, doing a Request.Form method will not necessary obtain all the values. It seems that there is some kind of priority on the values obtain.

This lead me to wonder if anyone knows the sequence of which overwrites the priority first? I know that in php, the php.ini file allows you to edit the global, get, post objects and method, and that you could set the priority of the objects to be used first and overwritten priority. Thus I wonder if there is any for ASP Request.Form & Request.Querystring objects?

25+ ASP Tips to Improve Performance and Style

Found a good link from Microsoft on tips to improve performance and style for ASP!

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnasp/html/asptips.asp

Saturday, February 19, 2005

Base64 Encoding Fun

And now for some encoding fun :P

The most common encoding that I like to use is Base64 Encode. Over the past 1 years plus, this encoding have proved to be very useful and I shall some tricks and tips that I discover! For fun with online base64 encode or decode check this site out.

1) Base64 encoding and decoding is dependent on the language charset that you set in. For example if you are encoding in a page with iso-8859-1 and a utf-8, the result encoding is different. I believed this is due to the different byte used and the character set used in the encoding.

2) Base64 encoding is useful to hide away clear text message.

3) My most important topic here! Base64 encoding can used in email subject and content. While working with mult-lingual email. the challenge is always to get the correct character displayed with showing gibberish stuffs. For my experiments before, I found out that base64 encode subject line are more reliable than quote-text for double-byte language email.

Due to the various different sytems operating in their settings and configuration, when a double-byte mail subject is quote-text, the result maybe displayed incorrectly. On some machine, it might displayed as you wanted, but not for some especially for those web-based email viewed online!

To send out double-byte character email ,the provided CDONTS and CDOSYS system on Microsoft Windows platform needs you to set the correct Session Codepage and encode the mail subject using quote-texted. When checked the reference, both the CDONTS and CDOSYS does not allow the mail subject to be base64 encoded! So for those mail subject that I received and does not appear correctly, how do we tackle this problem? One way you can do is change the subject liner to some other content. But what if the client insisted on it?

My solution that I discovered that it worked.

  • With the double byte mail subject, go to the online base64 encoding/decoding site link.
  • Set the page to the correct charset, ie: for Simplified Chinese, set the charset encoding to "gb2312"
  • Paste the subject string into the text box and encode it.
  • Copy the encoded string from the site.
  • In your server script, (I am using asp with CDONTS as example below), set the mail subject line to the use the base64 encoded text with defined encoding used.
    ie: =?gb2312?b?xxxxxSubject-base64xxxxx==?=
    Example with ASP using CDONTS
    <%
    'Create the e-mail server object
    Set objCDOSYSMail = Server.CreateObject("CDO.Message")

    'Update the CDOSYS Configuration
    Set objCDOSYSMail.Configuration = objCDOSYSCon
    With objCDOSYSMail
    .From = strEmail
    .To = strFriendEmail
    .Subject = "=?gb2312?b?" & strSubject & "==?="
    End With ' objCDOSYSMail
    %>

  • Send out the email in the script, and when you receive your email, you see that the subject is displayed in the correct encoding! The above mail subject is set to follow the rfc mail header standard and it seems that once you specify the encoding there, it will overwrite the quote-text encoding in there!

Friday, February 18, 2005

Javascript Error - submit

A few days back while doing a javascript form submit status, I encountered the weird error in my javascript-ing life. The problem is with the statement below:

document.form.submit();
Yes, it look very much like a normal javascript form submit statement. However, on the Mozilla Firefox javascript console, it is throwing back in my face the error message "Object doesn't support this property or method"!

After desperate testing here and there, I search and google around for an answer and found out that I have make a stupid mistake. The problem was caused by having a submit button that has the name "submit", ie:
<input type="submit" name="submit" value="Submit">
As the form submit is a reserved method, any button name or input name that is named "submit" shall encounter this problem. So folks, take note not to name any input object "submit". The error vanished when I renamed the button to "Submit", ie:
<input type="submit" name="Submit" value="Submit">
Thanks to helpful information on the net, especially from this site here: http://www.agape-love.net/?item=document-form-submit-doesn-t-work&catid=13

Stupid Javascript :P

Self-Signed IIS SSL Certificates

While looking around on how to do use self-signed IIS SSL certificate using OpenSSL, I came across the below article content from the author Eric Longman on his site. Thanks for the useful contribution! Other than using a Linux system, windows user can look to using CYGWIN installed with OpenSSL which also does the same work!

=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=


Self-Signed IIS SSL Certificates using OpenSSL

This tutorial assumes that you have a Linux box with OpenSSL installed,and that you want to create a self-signed certificate for IIS5.0

  1. Set up your CA (you only have to do this once)
    ON THE LINUX BOX...
    • Create a private key
      openssl genrsa -des3 -out CA.key 1024
      (You'll need to supply a passphrase. DON'T FORGET THIS!!)

    • Set this to read-only for root for security
      chmod 400 CA.key
    • Create the CA certificate
      openssl req -new -key CA.key -x509 -days 1095 -out CA.crt
      (Provide appropriate responses to the prompts...for Common Name, you might want to use something like "OurCompany CA")

    • Set the certificate to read-only for root for security
      chmod 400 CA.crt
  2. Obtain a CSR
    ON THE IIS BOX...
    • Open the Internet Manager
    • Select the site for which you want to create a key
    • Right-click and choose Properties
    • Select the "Directory Security" tab
    • Click the "Server Certificate" button
    • Follow the prompts to create a CSR
    • Save your CSR, then transfer it to the Linux box for further processing. (For the following steps, we'll refer to your CSR as "new.csr")

  3. Sign the CSR
    ON THE LINUX BOX...
    • Sign the CSR (all of this on one line)
      openssl x509 -req -days 365 -in new.csr -CA CA.crt
      -CAkey CA.key -CAcreateserial -out new.crt
    • Transfer the new.crt file back to the IIS box

  4. Install self-signed certificate
    ON THE IIS BOX...
    • Open the Internet Manager
    • Select the site to install the key
    • Right-click and choose properties
    • Select the "Directory Security" tab
    • Click the "Server Certificate" button
    • Specify that you want to complete the pending request
    • Select the .crt file that you just transferred

Original content from Eric Longman - http://eal.us/blog/_archives/2003/6/2/25109.html
=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=

Thursday, January 13, 2005

Paging Recordset with ASP

First contribution on the paging recordset with ASP.

It has always been annoying to do paging recordset, especially when you have to set many options here and there. Although the ADO recordset have many properties which aids in customising paging and the records to be fetched, the confusion lies within the vast amount of customisaton and try and error for the newbie.

Based on many paging script reference from the net, I have studied the goods and designed out an object oriented class solely for paging. The class requires minimal inputs and yields friendly result on the returend page numbers and recordset.

As this is my first draft, the technical details I have yet to describe it. The source provided is as it is with minimum comments. Hopefully it shall serve useful to you.

Download the source and example here

Kick off with learning process

I am lazy, yes for this fact I do admit that creating a site requires a lot of efforts from creative aspects to coding etc. Being a developer myself, it has always been my idea to generate my own script library, collecting snippets here and there for my reference for future use.

Over the past years of development I have been reusing scripts from the net, and I thanks all those great scripting genius and author out there, which make most of our developer life easier! Having said that I would also want to contribute to share out scripts and knowledge that I feel is benefical to the world out there. Even if it's not beneficial, this can be a archival of my knowledge learning online!

Blogging - a new way of authoring and yes I feel that it shall make my life easier ignoring the design factor while I just post my script and description out here!