Wednesday, November 08, 2006

favicon.ico

A favicon (short for "favorites icon"), also known as a page icon, is an icon associated with a particular website or webpage. A web designer can create such an icon, and many graphical web browsers—such as recent versions of Internet Explorer, Firefox, Mozilla, Opera, Safari, iCab, AOL Explorer, Epiphany, Konqueror, and Flock—can then make use of them. Browsers that support favicons may display them in the browser's URL bar, next to the site's name in lists of bookmarks, and next to the page's title in a tabbed document interface.

The original means of defining a favicon was by placing a file called favicon.ico in the root directory of a webserver. This would then automatically be used in Internet Explorer's favorites (bookmarks) display. Later, however, a more flexible system was created, using HTML to indicate the location of an icon for any given page. This is achieved by adding two link elements in the <head> section of the document as detailed below. In this way, any appropriately sized (16×16 pixels or larger) image can be used, and although many still use the .ico format, other browsers now also support the animated GIF and PNG image formats.

The "favicon.ico" facility is by no means essential to your website's operation. In fact, few people even notice its existence, and its really too small to put anything useful in it.

However, creating one can save your site some bandwidth if you have created a custom 404 File Not Found error file - that file will be sent by your web server everytime there is a request for a nonexistent "favicon.ico" file.

Perhaps more importantly, creating such an icon adds to the professionalism of your site, marking you as a web designer who attends to detail.

Monday, August 07, 2006

IE Bug Using document.getElementById()

If you are using either document.getElementById() or prototype's $() and you have an element in your page with it's name that is the same as the id of an element that comes after it, DON'T DO IT!!!

IE treats the id and name attributes of elements equally when using document.getElementById().

For an example, use the following HTML code.


<html>
<body>
name: testMe
<input type="text" name="testMe" value="First Element" /><br />
name: dontTestMe id: testMe
<input type="text" name="dontTestMe" id="testMe" value="Second Element" />
<br />
<input type="button" onclick="alert(document.getElementById('testMe').value);" value="Click me to see what happens." " />
</body>
</html>


Working Example


name: testMe


name: dontTestMe id: testMe



Friday, May 26, 2006

Security Warning on MSDN



I got this warning when trying to go to MSDN from a search.

How comical is this!?

Tuesday, May 02, 2006

SQL index tip

This where clause can be made more simple and avoid unnecessary formatting by Oracle if you use the default Oracle format for the date test. Sometimes function calls will cause Oracle to disregard the index.

This:
update rad.dcd10dm
...
where dep > to_date('03/20/2006', 'MM/DD/YYYY');


Can be coded like this:
update rad.dcd10dm
...
where dep > '20-mar-06';

Wednesday, April 26, 2006

Oracle Tuning

For most efficient access, the order that tables are specified can make a difference. The optimiser will re-order table access based on the indexes available. If access paths on two tables seem equally efficient, Oracle will use the order of tables specified in the FROM clause to determine the execution path.
The rule is to place the table that reduces the number of returned rows by the largest factor last. This table tends to be the one that has most WHERE conditions reducing the data, or it is the smallest table. If in doubt, consult the DBA team.
Just to remind you that this order of tables is important only if you are using Rule Based Optimizer. If that is the case, then table with fewer rows should be listed LAST in the FROM clause (because that should be the driving table, and parser processes table names from right to left).


2.5 WHERE Clause
The bulk of SQL performance tuning relates to the careful specification of the WHERE clause. Each clause within the WHERE clause can be executed with varying degrees of efficiency. The efficiency of a particular WHERE clause is a function of the size of the table, and the indexes that are available on the selecting column(s).
2.5.1 Access Paths and Indexes
To obtain a row from a given table in the database, Oracle uses an access path. An access path is a mechanism of obtaining particular rows. A set of access paths for all tables involved in a query and the internal Oracle operations that join the results from the access paths form a complete execution plan.
Oracle supports many different access paths, of which at least one is available for every row required for each table used within a query. The following table shows the types of access paths supported by Oracle, where ranked number one is the most efficient and ranked 15 is the least efficient. Oracle uses the relative efficiencies in this table as part of the process of determining cost for a particular execution plan..

Rank Condition
1 Single row by ROWID
2 Single row by cluster join (only for clustered table)
3 Single row by hash cluster key with unique or primary key (only for hash clusters)
4 Single row by unique or primary key (where unique index exists)
5 cluster join (for cluster tables)
6 Hash cluster key (for cluster columns)
7 Indexed cluster key (for clustered columns)
8 Composite Index
9 Single column indexes
10 Bounded range searches
11 Unbounded range searches on indexes columns
12 Sort-merge join (join of non-indexed columns)
13 MAX or MIN of indexed column (where these group functions appear in the column list of the SQL statement.
14 ORDER BY on indexed columns
15 Full table scan. This access path is always available.
An index is an additional database structure that is manually created but automatically maintained by Oracle. One or more columns in a single table may be included in a single indexed, and there may be many indexes for a particular table.
An index allows rapid access to particular rows in a table when a WHERE clause selects
* all of the columns referenced by a particular index
* the leading columns of an index created over multiple columns.
Unless an index exists on columns used in the WHERE clause, access paths that use indexes are not available.
Cluster and hash indexes are characteristics of the way that tables are physically built in the database. As we can see from the table listed above that indexes and clustering make the most efficient access paths available to Oracle.
Accesses to non indexed columns in tables can only be made via a full table scan. For large tables, a full table scan will take a long time and is to be avoided. If the application needs to locate records in a large table by a non indexed column, seek advice from the DBA team.

3 Summary
This section summarises the following good practices which application developers should bear in mind when developing SQL scripts:
* Table Aliases - always use table aliases when more than one table is involved in a query. The advantages of this method are to prevent future syntax errors when ambiguously named columns is added to table.The SQL statement is more readable.
* Sequencing of WHERE clause conditions - Note that non-index WHERE clause conditions are evaluated one by one after retrieving the rows. The AND statements are evaluated bottom-up, and the OR statements are evaluated top-down. Always place complex AND conditions in the beginning and placing complex OR conditions at the end.
* Reduce the number of trips to the database - Every time a SQL is executed the statements are parsed, indexes are evaluated, variables are bound, and in a client-server environment, SQL and results are transferred over the network. In order to maintain efficiency developers should minimises the number of statements executed.
* WHERE vs HAVING - HAVING filters the groups after the rows have been fetched, sorted and grouped. WHERE filters the rows when they are fetched. Therefore, the WHERE statement will reduce the overheads involved in reading the data blocks and sorting. This in turn improves the performance.
* EXISTS in place of DISTINCT - EXISTS does not result in sorting and it is more efficient when an index is available. DISTINCT is always sorts the results and eliminates the duplicates.
* NOT EXISTS in place of NOT IN - NOT IN with a sub-query results in an internal sort. Replacing NOT IN (sub-query) with NOT EXISTS (co-related sub-query) may improve performance. Use this method ONLY WHEN an index is available for co-related sub-query.
* Using Indexes - Using indexes improves the performance only when the number of records to be retrieved are about 20% of total records in the table. To make the indexes available always avoid using calculations on indexed columns, and indexed_column <> value or using indexed_column IS NULL statements.

Tuesday, April 18, 2006

Data Access using ADO.NET Objects

prepared by John Papproth
on June 29th, 2005

ADO.NET is a disconnected data access model.
The model contains several classes that are found in the System.Data namespace.

There are two mirrored class groups in Visual Studio.NET 2003:
SQL prefixed classes (SQLConnection, SQLDataAdapter) are especially tuned for a Microsoft SQL Server Environment.
OleDb prefixed classes (OleDbConnection, OleDbDataAdapter) are intended for non SQL Server Environments such as Oracle, DB2, and Microsoft Access.

The following example uses Microsoft Access, the OleDb ADO.NET objects, and Visual Basic.NET to create a simple form driven update.

Example:
1. Create the data base and tables.
2. Create the form.
3. Create the ADO.NET class references.
4. Write code to instantiate the classes.

1. Create the data base and tables.
Create an Access Database.
Create a Table within the Access Database.

2. Create the form.
Create one label and textbox pair for each column in your table.

3. Create the ADO.NET class references.
Private cn As OleDb.OleDbConnection
Private da As OleDb.OleDbDataAdapter
Private ds As DataSet
Private dt As DataTable


4. Write code to instantiate the classes.

Create the connection
cn = New OleDb.OleDbConnection
cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & _
Application.StartupPath & "\YourDatabaseNameHere.mdb"


Create a new adapter, and set the connection in the command objects
(Replace the Select * with your Column Names)
da = New OleDb.OleDbDataAdapter("Select * from YourTableNameHere", cn)
da.SelectCommand.Connection = cn


Create an empty dataset
ds = New DataSet

Fill the dataset
da.Fill(ds, "YourTableNameHere")

Create the data table
dt = ds.Tables("YourTableNameHere")

Bind the fields to the data table

Binding a combo box control:
cboComboBox.DataSource = dt
cboComboBox.DisplayMember = "YourColumnNameHere"


Binding a text box control:
txtTextBox.DataBindings.Add("Text", dt, "YourColumnNameHere")

Tuesday, April 04, 2006

Texas Cowboy

A Texas cowboy was tending to his herd in a remote pasture when suddenly a brand new BMW advanced out of a dust cloud towards him. The driver, a young man in a Brioni suit, Gucci shoes, Ray Ban sunglasses and YSL tie, leaned out the window and asked the cowboy... "If I tell you exactly how many cows and calves you have in your herd, will you give me a calf?"

The cowboy looks at the man, obviously a yuppie, then looks at his peacefully grazing herd and calmly answers, "Sure, Why not?"

The yuppie parks his car, whips out his Dell notebook computer, connects it to his AT&T cell phone, and surfs to a NASA page on the Internet where he calls up a GPS satellite navigation system to get an exact fix on his location which he then feeds to another NASA satellite that scans the area in an ultra-high-resolution photo. The young man then opens the digital photo in Adobe Photoshop and exports it to an image processing facility in Hamburg, Germany.

Within seconds, he receives an email on his Palm Pilot that the image has been processed and the data stored. He then accesses a MS-SQL database through an ODBC connected Excel spreadsheet with hundreds of complex formulas. He uploads all of this data via an email on his Blackberry and, after a few minutes, receives a response. Finally, he prints out a full-color, 150-page report on his hi-tech, miniaturized HP LaserJet printer and turns to the cowboy and says, "You have exactly 1586 cows and calves."

"That's right. Well, I guess you can take one of my calves," says the cowboy. He watches the young man select one of the animals and looks on amused as the young man stuffs it into the trunk of his car.

Then the cowboy says to the young man, "Hey, if I can tell you exactly what your business is, will you give me back my calf?"

The young man thinks about it for a second and then says, "Okay, why not?"

"You're a consultant for the U. S. Government," says the cowboy.

"Wow! That's correct," says the yuppie, "but how did you guess that?"

"Simple," answered the cowboy. "You showed up here even though nobody called you; you want to get paid for an answer I already knew, to a question that I never asked; and you don't know anything about cows."

"Now give me back my dog."

Some Actual Tech Support Transcripts

Call 1
Tech support: What kind of computer do you have?
Female customer: A white one...

Call 2
Customer: Hi, this is Celine. I can't get my diskette out.
Tech support: Have you tried pushing the button?
Customer: Yes, sure, it's really stuck.
Tech support: That doesn't sound good; I'll make a note.
Customer: No . Wait a minute... I hadn't inserted it yet... it's still on my desk... Sorry....

Call 3
Tech support: Click on the 'my computer' icon on to the left of the screen.
Customer: Your left or my left?

Call 4
Tech support: Good day. How may I help you?
Male customer: Hello... I can't print.
Tech support: Would you click on "start" for me and...
Customer: Listen pal; don't start getting technical on me! I'm not Bill Gates. -

Call 5
Customer: Hi, good afternoon, this is Martha, I can't print. Every time I try, it says 'Can't find printer'. I've even lifted the printer and placed it in front of the monitor, but the computer still says he can't find it...

Call 6
Customer: I have problems printing in red...
Tech support: Do you have a color printer?
Customer: Aaaah....................thank you.

Call 7
Tech support: What's on your monitor now, ma'am?
Customer: A teddy bear my boyfriend bought for me at the 7-11.

Call 8
Customer: My keyboard is not working anymore.
Tech support: Are you sure it's plugged into the computer?
Customer: No. I can't get behind the computer.
Tech support: Pick up your keyboard and walk 10 paces back.
Customer: OK
Tech support: Did the keyboard come with you?
Customer: Yes
Tech support: That means the keyboard is not plugged in. Is there another keyboard?
Customer: Yes, there's another one here. Ah...that one does work...

Call 9
Tech support: Your password is the small letter a as in apple, a capital letter V as in Victor, the number 7.
Customer: Is that 7 in capital letters?

Call 10
Customer: I can't get on the Internet.
Tech support: Are you sure you used the right password?
Customer: Yes, I'm sure. I saw my colleague do it.
Tech? support: Can you tell me what the password was?
Customer: Five stars.

Call 11
Tech support: What anti-virus program do you use?
Customer: Netscape.
Tech support: That's not an anti-virus program.
Customer: Oh, sorry...Internet Explorer.

Call 12
Customer: I have a huge problem. A friend has placed a screen saver on my computer, but every time I move the mouse, it disappears.

Call 13
Tech support: How may I help you?
Customer: I'm writing my first e-mail.
Tech support: OK, and what seems to be the problem?
Customer: Well, I have the letter 'a' in the address, but how do I get the circle around it?

Call 14
A woman customer called the Canon help desk with a problem with her printer.
Tech support: Are you running it under Windows?
Customer: "No, my desk is next to the door, but that is a good point. The man sitting in the cubicle next to me is under a window, and his printer is working fine."

Call 15
Tech support: "Okay, Bob, let's press the control and escape keys at the same time. That brings up a task list in the middle of the screen. Now type the letter "P" to bring up the Program Manager."
Customer: I don't have a P.
Tech support: On your keyboard, Bob.
Customer: What do you mean?
Tech support: "P".....on your keyboard, Bob.
Customer: I'M NOT GOING TO DO THAT!

Thursday, March 23, 2006

JavaScript Tip

When dynamically creating an anchor in javascript, be sure to set not only the innerText (the text that appears between the open and closing tags), but also the innerHTML. Otherwise, if you try to view the said anchor in Firefox, it doesn't render.

Example:

var linkClose = document.createElement("A");

linkClose.href = "javascript:void(null)";
linkClose.innerText = "Close Window";
linkClose.innerHTML = "Close Window";

Wednesday, March 15, 2006

Why Computers Sometimes Crash! by Dr. Seuss.

If a packet hits a pocket on a socket on a port, and the bus is interrupted at a very last resort, and the access of the memory makes your floppy disk abort, then the socket packet pocket has an error to report.

If your cursor finds a menu item followed by a dash, and the double-clicking icon puts your window in the trash, and your data is corrupted cause the index doesn't hash, then your situation's hopeless and your system's gonna crash!

If the label on the cable on the table at your house, says the network is connected to the button on your mouse, but your packets want to tunnel to another protocol, that's repeatedly rejected by the printer down the hall...

And your screen is all distorted by the side effects of gauss, so your icons in the window are as wavy as a souse; then you may as well reboot and go out with a bang, 'cuz sure as I'm a poet, this whole sucker's gonna hang.

When the copy on your floppy's getting sloppy in the disk, and the macro code instructions's putting everything at risk, then you'll have to flash the memory and you'll want to RAM your ROM, and then quickly switch the power off and go and tell your Mom!

Well, that certainly clears things up for me. How about you?