Skip to content

Instantly share code, notes, and snippets.

@corymartin
corymartin / Person.cs
Created August 8, 2012 20:15
Parsing JSON array in C# :/
public class Person {
public string name { get; set; };
public byte age { get; set; };
}
@corymartin
corymartin / gist:3156752
Created July 21, 2012 18:50
Learning Go. First attempt at serving JSON.
package main
import (
"encoding/json"
"fmt"
"net/http"
)
// Learning Go
// First try at serving JSON
@corymartin
corymartin / gist:2434311
Created April 21, 2012 05:33
isInvalidDate()
function isInvalidDate( /*Date*/date ) {
if (date == null || !(date instanceof Date)) return true;
var ts = date.getTime();
if (ts !== ts) return true; // NaN
var str = date.toString();
return str === 'Invalid Date' || str === 'NaN';
}
@corymartin
corymartin / flags.js
Created April 15, 2012 14:55
Flag Enumerations in JavaScript
// Flag Enumerations in JavaScript
// ===============================
// Flag enums
// ----------
// Values must increment by powers of 2
var SEASONS = {
Spring : 1,
Summer : 2,
@corymartin
corymartin / Friends.cs
Created February 23, 2012 23:05
Using SQL Server's XML type to pass an "array" of values for multiple inserts, updates, etc.
using System.Data;
using System.Data.SqlClient;
using System.Text;
namespace Gists.Data
{
public class Friends
{
/// <summary>
/// Inserts each friends' name into a table.
@corymartin
corymartin / gist:1518841
Created December 25, 2011 07:15
jQuery Fast
//
// For simple selectors, these return a jQuery object
// faster via native element selection.
//
(function(window) {
var
doc = window.document,
$ = window.jQuery;
@corymartin
corymartin / gist:1518824
Created December 25, 2011 06:42
jQuery pseudo selectors for HTML5 input types
//
// Adds jQuery Pseudo Selectors for HTML5 input types.
//
// Example:
// HTML:
// <input type="email" name="user_email">
// jQuery:
// $(':email');
//
//