Skip to content

Instantly share code, notes, and snippets.

View Singleton
using System;
public class Singleton
{
private static Singleton instance;
private Singleton() {}
public static Singleton Instance
{
@dmjio
dmjio / Recursive DOM Example
Created Aug 17, 2011
Walking the DOM Recursively
View Recursive DOM Example
function walkTheDOM(node, F)
{
F(node);
node = node.firstChild;
while (node)
{
walkTheDom(node, F);
node = node.nextSibling; //Changes state here, destroying node
}
}
@dmjio
dmjio / gist:1152858
Created Aug 17, 2011
GetIncrementFunction
View gist:1152858
function GetIncrementFunc(incBy)
{
var temp = 0;
return function() { temp += incBy; return temp; }
}
var c = GetIncrementFunc(3);
document.write(c());
document.write(c());
document.write(c());
@dmjio
dmjio / 3JWebGL
Created Aug 26, 2011
WebGL BoilerPlate Code
View 3JWebGL
<!doctype html>
<html>
<head>
<title></title>
</head>
<body>
<div id="container">
</div>
</body>
<script src="Three.js" type="text/javascript"></script>
@dmjio
dmjio / F# Factorial Simple
Created Aug 29, 2011
Calculating all factorials of numbers 1 to 51,000
View F# Factorial Simple
open System
open System.Diagnostics
let rec fac x = if x < 1.0 then 1.0 else x * fac(x-1.0)
let watch = new Stopwatch()
watch.Start()
let simpleComputation = [for i in 0.0..51000.0 -> fac(i)]
watch.Stop()
let result = watch.Elapsed.Seconds.ToString()
printfn "%s" result;;
@dmjio
dmjio / Factorial Async Parallel F#
Created Aug 29, 2011
Calculating all factorials of numbers 1 to 51,000
View Factorial Async Parallel F#
open System
open System.Diagnostics
let rec fac x = if x < 1.0 then 1.0 else x * fac(x-1.0)
let watch = new Stopwatch()
watch.Start()
let complexComputation = Async.Parallel [for i in 0.0..51000.0 -> async { return fac(i) }] |> Async.RunSynchronously;;
watch.Stop()
@dmjio
dmjio / How to get SQL for ASPNET Membership Provider
Created Aug 31, 2011
How to gen your database in aspnet_regsql.exe
View How to get SQL for ASPNET Membership Provider
cd %windir%\Microsoft.NET\Framework\v4.0.30319
aspnet_regsql.exe -sqlexportonly C:\file.sql -A all
@dmjio
dmjio / ConvertOBJtoJSON
Created Sep 7, 2011
How to generate a 3D Model from .obj to JSON (execute python script Three.js)
View ConvertOBJtoJSON
C:\Program Files (x86)\IronPython 2.7>ipy.exe "C:\Users\djohnson\Desktop\Convert
OBJToJSON\convert_obj_three.py" -i "C:\users\djohnson\Desktop\ConvertOBJToJSON\B
razile.obj" -o "C:\users\djohnson\Desktop\outfile.js"
@dmjio
dmjio / VSDOC
Created Sep 28, 2011
jQuery VSDOC
View VSDOC
<script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.6.4-vsdoc.js" type="text/javascript"></script>
@dmjio
dmjio / Towers of Hanoi
Created Oct 10, 2011
Towers of Hanoi in Javascript
View Towers of Hanoi
var hanoi = function(disc,src,aux,dst) {
if (disc > 0) {
hanoi(disc - 1, src,dst,aux);
document.write('Move disc ' + disc + ' from ' + src + ' to ' + dst);
hanoi(disc-1,aux,src,dst);
}
}
hanoi(3, 'src','aux','dst');