Friday, August 10, 2007

Notes from Peepcode tutorial on Prototype.js

Notes from Peepcode tutorial on Prototype.js
ver 1.5.1


for Hash Object and Array Objects

var smedly = {ape:'brown',frog:'green'}

var smedly = $H({ape:'brown',frog:'green'})

$A isn't really needed...
var asmedly = ['ape','frog','toad']






Anonymous Functions:



Other selector syntaxes (generally uses CSS):
$$('a,p') selects both a's and p's
$$('div p') selects all p's in a div
$$('img') selects all images
$$('img[alt=mephisto-badge]') selects all images with 'mephisto-badge' as alt parm

This is pure JavaScript. Create modules using Hashes.

var myHash = {mykey:myvalue, mykey2:myvalue2}

Now just put function in for the key:value pairs:

var HandyFunctions = {hideLinks: function(){}, showLinks: function(){}}
var HandyFunctions = {
hideLinks: function(){
showLinks: function(){

Note: when you call these functions, even though they are Hash keys, make sure to put parentheses at end:

Note: see Yahoo video for painfully in-depth exploration of JavaScript classes.
Prototype makes it simpler. Just use Class.create() !!
They are similar to the Module concept above, but with some added functionality:
parameters that can be passed to functions,
and you can use "this" keyword.

var Butter = Class.create()
Butter.prototype = {mykey:myvalue}

Butter.prototype = {
initialize: function(brand) {
this.brand = brand;
this.melted = false;
melt: function(){
this.melted = true;

var parkay = new Butter('Parkay');



See Quirksmode for list of cross-browser behaviors (onmousever, onclick, etc)

JavaScript Hash

var animalColors = {'ape':'black', 'pig':'pink', 'frog':'green'}

Monday, August 6, 2007

Too Many Stored Procedures

Is there such a thing as Too Many Stored Procedures?
Jeff Atwood at Coding Horror makes some great points that reflect my own thoughts over at:

I think SQL Server's Object Explorer needs to have a built-in mechanism for managing the thousands of stored procedures that occupy a database, instead of trusting that a sensible naming convention will be used.  In my experience, eventually any naming convention breaks down after time, as new developers and technologies arrive.

Linked to in Atwood's post is this by Frans Bouma, who seems to be the main promoter of cautionary use of Stored Procedures:

Thursday, August 2, 2007

Quick ASP Log

Handy for debugging errors:
function writeLog(msg)
 Dim fso
 Dim logfile
 Dim logFileName
 Dim strLog 
 logFileName  = Server.MapPath("logfile.txt")
 Set fso = Server.CreateObject("Scripting.FileSystemObject")
 Set logfile = FSO.OpenTextFile(logFileName, 8, True)
 logfile.writeline now() & ":" & msg
 set fso = nothing
 set logfile = nothing
end function

Wednesday, August 1, 2007

Most Common Validators for ASP.NET

<asp:requiredfieldvalidator id="reqResendWaitDays" Runat="server" ErrorMessage="Required Field" ControlToValidate="txtResendWaitDays"

<asp:CompareValidator id="comResendWaitDays" Runat="server" ErrorMessage="Must be numeric" ControlToValidate="txtResendWaitDays"
type="Integer" operator="DataTypeCheck">