Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am jauco on github.
  • I am jauco (https://keybase.io/jauco) on keybase.
  • I have a public key whose fingerprint is F404 1AEC 660A 74A5 4134 3D78 2C16 53D0 B24C 9377

To claim this, I am signing this object:

@jauco
jauco / elevator.js
Last active August 29, 2015 14:14
Elevator saga
//level 9
//level 9
{
init: function(elevators, floors) {
function reorderDestinationqueue(q) {
var qnew = [];
var alreadyInQueue = {};
for (var i=0; i < q.length ; i++) {
if (!alreadyInQueue[q[i]]) {
qnew.push(q[i]);
@jauco
jauco / gist:201307
Created October 4, 2009 11:05
Design by contract in javascript
//Design by contract function
function $contracted(pre, post, func){
return function(){
var paramsAsArray,
funcName,
retVal;
paramsAsArray = Array.slice(arguments)
funcName = func.toString().substr('function '.length);
funcName = funcName.substr(0, funcName.indexOf('('));//strip of everything, but the name
@jauco
jauco / params.js
Created June 12, 2010 12:02
Jquery plugin for passing paramaters to scripts without dirtying the global scope
//Jquery plugin to for passing paramaters to scripts without dirtying the global scope
"use strict";
(function createGetScriptParameters($) {
$.getScriptParameters = function getParams() {
//From the comments on http://bit.ly/dw5eYp
var scripts = document.getElementsByTagName("script"),
thisScript = scripts[scripts.length - 1], //Get the current script tag
paramString = "{" + thisScript.innerHTML.replace(/[\r\n]+\s*\/\//g, '') + "}";
@jauco
jauco / Blueprint.cs
Created October 12, 2011 07:46
A object templator for your unittests, like factorygirl
using System;
namespace Blueprint {
public class Blueprint<T> {
Func<IdGenerator, T> constructor;
//IdGenerator is static, so all objects of type T will have a different Id
private static IdGenerator idgen = new IdGenerator();
public Blueprint(Func<IdGenerator, T> constructor) {

Keybase proof

I hereby claim:

  • I am jauco on github.
  • I am jauco (https://keybase.io/jauco) on keybase.
  • I have a public key ASD9YOcwPvQM5klEAt2Is6PLIw68O0X_g9lTSzvOWUpPmgo

To claim this, I am signing this object: