Recent Coded Smorgasbord

Inspired by the Pop-up Potpourri, the examples presented here aren't necessarily "bad" code nor do they imply the miserable failure that we're all used to reading here. The examples are more-or-less fun snippets of code like ones that we've all written at one time or another.

Jul 2014

A Priestly Epoch, Running off the Tracts

by in Coded Smorgasbord on

Peter came across this helpful little utility function:

public static DateTime EPOCH_UTC()
{
   DateTime epoch = new DateTime(1980, 1, 1, 0, 0, 0);
   return epoch;
}

Everyone Wants Validation

by in Coded Smorgasbord on

Faibbus works with an international team. Some of his fellow developers don’t quite adhere to the same standards. This code was in a module, and the comments and text were originally in Dutch.

if(this.value.length!=0){

   //because the greater/smaller signs are being escaped  

   if(this.value.length==1){alert('The year must have 4 digits.');this.focus();}

   if(this.value.length==2){alert('The year must have 4 digits.');this.focus();}

   if(this.value.length==3){alert('The year must have 4 digits.');this.focus();}

}