Skip to content

Instantly share code, notes, and snippets.

@dmjio
dmjio / Singleton
Created July 27, 2011 19:17
Singleton
using System;
public class Singleton
{
private static Singleton instance;
private Singleton() {}
public static Singleton Instance
{
@dmjio
dmjio / Recursive DOM Example
Created August 17, 2011 22:55
Walking the DOM Recursively
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 August 17, 2011 22:57
GetIncrementFunction
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 August 26, 2011 13:41
WebGL BoilerPlate Code
<!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 August 29, 2011 00:44
Calculating all factorials of numbers 1 to 51,000
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 August 29, 2011 00:44
Calculating all factorials of numbers 1 to 51,000
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 August 31, 2011 22:00
How to gen your database in aspnet_regsql.exe
cd %windir%\Microsoft.NET\Framework\v4.0.30319
aspnet_regsql.exe -sqlexportonly C:\file.sql -A all
@dmjio
dmjio / ConvertOBJtoJSON
Created September 7, 2011 21:23
How to generate a 3D Model from .obj to JSON (execute python script Three.js)
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 September 28, 2011 00:13
jQuery 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 October 10, 2011 21:23
Towers of Hanoi in Javascript
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');