Skip to content

Instantly share code, notes, and snippets.

View danesparza's full-sized avatar
:octocat:
The best way to predict the future is to invent it - Alan Kay

Dan Esparza danesparza

:octocat:
The best way to predict the future is to invent it - Alan Kay
View GitHub Profile
//  First, make sure our browser supports HTML 5 local storage
if (typeof(localStorage) == 'undefined' )
{
alert('Your browser does not support HTML5 localStorage. Try upgrading.');
}
else
{
    try
    {
        //  saves to the database using key/value
@danesparza
danesparza / gist:809951
Created February 3, 2011 18:57
jQuery selectors: Multiple items
$("#itemone, #itemtwo").hide();
$("#itemthree, #itemfour").show();
@danesparza
danesparza / gist:908231
Created April 7, 2011 17:14
Bad usage of status codes
// Example of poor design...
// Note the lack of any useful constraints on the 'status' member. You can type anything there!
// What happens if you're trying to pass this across a web service boundary to somebody consuming
// your service and you made a typo in one of your status responses. Tracking down this bug is hard.
// Pandas are very sad.
public class WsResponse
{
public string Status;
public string StatusDescription;
dig www.stackoverflow.com
@danesparza
danesparza / gist:973900
Created May 16, 2011 03:48
jQuery validation - HTML
<div id="content" style="padding: 10px;">
<form id="frmTest" method="get">
Lots of other content here<br />
Lots of other content here<br />
Lots of other content here<br />
Lots of other content here<br />
Lots of other content here<br />
Lots of other content here<br />
<input id="txtEmail" name="txtEmail" type="text" class="required email"/>
<br />
@danesparza
danesparza / gist:973902
Created May 16, 2011 03:50
jQuery validation - CSS class
label.invalid
{
color: Red;
font-style: italic;
padding: 1px;
margin: 0px 0px 0px 5px;
}
@danesparza
danesparza / gist:973906
Created May 16, 2011 03:51
jQuery validation - Javascript
$(document).ready(function ()
{
// Bind validation rules
$("#frmTest").validate({
errorClass: "invalid"
});
// Bind click handler:
$("#btnValidate").click(function ()
{
@danesparza
danesparza / gist:973910
Created May 16, 2011 03:54
JSON dates - returned date
/Date(1224043200000)/
@danesparza
danesparza / gist:973911
Created May 16, 2011 03:55
JSON dates - parsing javascript
var date = new Date(parseInt(jsonDate.substr(6)));
@danesparza
danesparza / gist:973913
Created May 16, 2011 03:56
JSON dates - javascript formatting
date.toDateString();