This is a collection of code patterns for some of the common Internet programming tasks which tend to repeat from time to time. When not singled out and classified these patterns get easily lost in the bulk of an application-specific code, and constant rewriting (and debugging) of them from scratch is a senseless waste of time.
Normally there are several ways to code the same logic, and some ways are better than the other in terms or size, effectiveness, readability and ease of modification. These criteria are rather fuzzy (except for the "size"), and are affected by personal preferences. Yet, there seems to exist a certain common sense consensus of what is "good" – like mnemonic names and labels, use of indentation, commenting, etc.
This selection is my attempt to collect the most usable of such "good" code patterns into one document hyperlinked for the ease of use, and accessible from anywhere and by anybody who might have interest in it. However, this selection is not compiled for the Web only – rather it's my working reference which I try to maintain as accurate and current as possible. As such it inevitably will always lack an overall integrity and completeness, yet it is still a rather useful tool that often saves time.
Most of the tasks originated from a real-life experience of an Internet programmer. Most of the solutions were coded and debugged in the process of practical programming of various applications. Every pattern was checked to the best of my competence, and as a rule was tested by a substantial time of repeated usage. This is not to suggest that it is in any way guaranteed to be error-free – you will be using any code you pick from this selection entirely at your own risk, and will be completely responsible yourself for any problems that might arise from this usage. So when trying a code, please exercise the common sense precautions, and test it most thoroughly yourself before applying it to anything serious.
This legal mantra been chanted, I want to mention that all error reports and any comments about this code pattern selection are most welcome, and I'll try to do my best to fix any known problem as quick as I'll be able to do this.
Note: To maintain a proper formatting of this document some excessively long lines of code have been split into parts (for a presentation purpose only). Those line split points are indicated either by a light green highlighted space " " (line splicing is optional), or by a light red highlighted space " " (line splicing is required for code to be valid). Regardless of the sliced line parts' indentation, line splicing should be done in such a way that first character of the next line part follows immediately the corresponding split point indicator (highlighted space) of the previous line part.
<!-- AutoSwitch for it.davar.net SubDomain 02/05/2005–02/05/2005 -->
<!-- ------------------------------------------------- 02/05/2005 -->
<!-- www.davar.net/IT/_SUB-DOM/index.htm -->
<HTML>
<HEAD>
<META HTTP-EQUIV="Refresh" CONTENT="0;URL=http://www.davar.net/IT">
</HEAD>
<BODY>
</BODY>
</HTML>
. . . . .
<STYLE TYPE="Text/CSS">
A:HOVER {COLOR:Red; BACKGROUND:#FFFF66}
P {TEXT-INDENT:50px; TEXT-ALIGN:Justify}
</STYLE>
</HEAD>
<A HREF=../../index.htm>
<IMG SRC="../../USA-FLAG.GIF" TITLE="USA Flag" WIDTH=100 HEIGHT=55 BORDER=0></A>
|
|
Code above displays Flag image, which is here
a relative link to the entry page of Davar web site (try
clicking it or watch status bar as mouse moves over).
|
<A HREF=../../index.htm>
<IMG SRC="../../USA-FLAG.GIF" TITLE="USA Flag" WIDTH=100 HEIGHT=55></A>
|
|
Code above is almost identical to the previous
one with only one exception – border suppression parameter
BORDER=0 is omitted, which leads to image border
being displayed.
|
<!-- Calculation of Rectangle and Polygon definition coordinates (in pixels):
0 44 9
0 01 9
00 a-----+w-------x Rect: a - 00,00 Top-Left corner (coordinate origin)
¦ ¦¦ ¦ b - 40,30 Bottom-Right corner
30 +-----b¦ ¦
31 u------v ¦ Poly: u - 00,31 First coordinate (moving clockwise)
¦ ¦ v - 41,31
54 z--------------y w - 41,00
x - 99,00
y - 99,54
z - 00,54 Last coordinate (moving clockwise)
Rect: 00,00,40,30
Poly: 00,31,41,31,41,00,99,00,99,54,00,54 -->
<IMG SRC="../../USA-FLAG.GIF" TITLE="USA Flag" WIDTH=100 HEIGHT=55 BORDER=0 USEMAP="#Flag_Map">
<MAP NAME="Flag_Map">
<AREA SHAPE=Rect COORDS="00,00,40,30" HREF="../../index.htm">
<AREA SHAPE=Poly COORDS="00,31,41,31,41,00,99,00,99,54,00,54" HREF="../../ABOUT.HTM">
</MAP>
|
|
Code above displays Flag image, which has
a relative link to the entry page of Davar web site (index.htm)
from the blue star field and to "About" text (ABOUT.HTM) from
the rest of the image (try clicking those areas or watch
status bar as mouse moves over).
|
<NOSCRIPT> <BODY BACKGROUND="../../PAPER1.JPG" BGCOLOR=White TEXT=Black LINK=Blue ALINK=Fuchsia VLINK=Purple> </NOSCRIPT> <SCRIPT LANGUAGE=JavaScript> <!-- if (sessionStorage.getItem("BG")=="On") {N=Math.floor(Math.random()*9)%9+1 document.write("<BODY BACKGROUND='../../PAPER",N,".JPG' BGCOLOR=White TEXT=Black LINK=Blue ALINK=Fuchsia VLINK=Purple>") //--> </SCRIPT>
<NOSCRIPT>
<TABLE BORDER=3 CELLPADDING=10 BORDERCOLOR=Gray BACKGROUND="../PAPER010.JPG">
</NOSCRIPT>
<SCRIPT LANGUAGE=JavaScript>
<!--
if (sessionStorage.getItem("BG")=="On")
{N=Math.floor(Math.random()*9)%9+1
document.write("<TABLE BORDER=3 CELLPADDING=10 BORDERCOLOR=Gray
BACKGROUND='../PAPER0",N,"0.JPG'>")
//-->
</SCRIPT>
... please e-mail it to
<NOSCRIPT>
me (<FONT COLOR=Blue>VladV<SPAN>@</SPAN>verizon<SPAN>.</SPAN>net</FONT>)
</NOSCRIPT>
<SCRIPT LANGUAGE=JavaScript>
<!--
Id="VladV"
Pr="verizon"
Dm="net"
Ad="<A "+"HREF=\'"+"m"+"a"+"i"+"l"+"t"+"o"+":"+Id+"@"+Pr+"."+Dm+"'>me</A>"
document.write(Ad)
//-->
</SCRIPT>
as a file attachment...
<NOSCRIPT>
Vladimir Veytsel <BR>
<FONT COLOR=Blue>VladV<SPAN>@</SPAN>verizon<SPAN>.</SPAN>net</FONT>
</NOSCRIPT>
<SCRIPT LANGUAGE=JavaScript>
<!--
Id="VladV"
Pr="verizon"
Dm="net"
Ad="<A "+"HREF=\'"+"m"+"a"+"i"+"l"+"t"+"o"+":"+Id+"@"+Pr+"."+Dm+"'>Vladimir Veytsel</A>"
document.write(Ad)
//-->
</SCRIPT>