Skip to content

Instantly share code, notes, and snippets.

@josher19
josher19 / gist:749343
Created December 21, 2010 01:34
User Story Mapping
# Three levels #
Personal : Organizational
---------------------------
Goals : business objectives
Tasks : business processes
Tools/Features : employees, vendors & systems
# Business Goals #
@josher19
josher19 / gist:779245
Created January 14, 2011 06:01
working-invoice.yaml
invoice: 34843
date: "2001-01-23"
billTo: &id001
given : Chris
family : Dumars
address:
lines: [ "458 Walkman Dr.", "Suite #292"]
city : Royal Oak
state : MI
postal : 48046
/**
* Array.prototype.map Polyfill
*/
Array.prototype.map = function(fun, thisp) {
"use strict";
if (this === void 0 || this === null) {
throw new TypeError();
}
var t = Object(this);
@josher19
josher19 / incrpad.py
Created October 21, 2011 22:35
python script to go from '000' to '999'
import readline, rlcompleter
readline.parse_and_bind("tab: complete")
def zeropad(n,zeros=3):
"Pad number n with zeros. Example: zeropad(7,3) == '007'"
nstr = str(n)
while len(nstr) < zeros:
nstr = "0" + nstr
return nstr
@josher19
josher19 / matrix.pde
Created December 1, 2011 20:25
Using matrix multiplication in processingjs for an attractor
// matrix.pde
// Using matrix multiplication in processingjs for an attractor
void setup() {
size(250,250);
frameRate(20);
strokeWeight(2);
translate(125,125);
text("click mouse", 0, 0);
text(matrixA, -100, 20);
<!DOCTYPE html>
<html>
<head>
<title>jQuery UI Icons</title>
<link rel="stylesheet" type="text/css" media="all"
href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/themes/ui-lightness/jquery-ui.css"/>
<script type="text/javascript"
src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js">
@josher19
josher19 / matrix3.pde
Created December 16, 2011 18:02
Linear Attractor using matrix multiplication. Click inside the square to change x or y attraction values.
// matrix.pde
// Using matrix multiplication in processingjs for an attractor
bool running = true;
int sz=250;
int dx = sz/2;
int dy = sz/2;
int sq = 20;
int counter = 1;
@josher19
josher19 / good-strategy.md
Created December 16, 2011 20:38
The kernel of good strategy

The kernel of good strategy

  1. A diagnosis: an explanation of the nature of the challenge. A good diagnosis simplifies the often overwhelming complexity of reality by identifying certain aspects of the situation as being the critical ones.
  2. A guiding policy: an overall approach chosen to cope with or overcome the obstacles identified in the diagnosis.
  3. Coherent actions: steps that are coordinated with one another to support the accomplishment of the guiding policy.

Source: https://www.mckinseyquarterly.com/Strategy/Strategic_Thinking/The_perils_of_bad_strategy_2826

@josher19
josher19 / cachedWorkerInfo.js
Created December 21, 2011 08:58
Caching in Javascript
cachedWorkerInfo = {
cacheTimeSecs: 60 /* 60 seconds == 1 minute */
, timeoutId : 0
, get: function (workerId, sql) { return this._checkCached(workerId, sql) && this[workerId]['sqlResults']}
, put: function (workerId, sql, sqlResults) { return this[workerId] = {'sql': sql, 'sqlResults': sqlResults, 'queryTime': new Date()}; }
, scheduleCleanup : function() { if (!cachedWorkerInfo.timeoutId) cachedWorkerInfo.timeoutId = setTimeout(cachedWorkerInfo.clear, cachedWorkerInfo.cacheTimeSecs * 2 * 1000); /* called maximum of once per 2 minutes */ }
, clear : function clear(everything) { var that=cachedWorkerInfo, now = new Date(); for (var x in that) {if (typeof that[x] != "function" && null != that[x] && null != that[x].queryTime) {if (true == everything || false == that._stillValid(x, now)) {delete that[x] ;}}} that.timeoutId = 0; }
, _checkCached: function (workerId,sql) { return this[workerId] != null && this[workerId]['sql'] === sql && this._stillValid(workerId, new Date()); }
, _stillValid: function (workerId
@josher19
josher19 / geohash.js
Created December 22, 2011 02:48
Convert Geohash to Lat-Lon pair.
GEOHASH = {
BASE32: "0123456789bcdefghjkmnpqrstuvwxyz"
, binlat: function (geobinary) { return geobinary.filter(GEOHASH.odd).join("") }
, binlong: function (geobinary) { return geobinary.filter(GEOHASH.even).join("") }
, even: function (item,ndx) { return (ndx + 1) % 2 }
, getGeobinary: function (geohash) { return GEOHASH.toBinary(geohash).join("").split(""); }
, odd: function (item,ndx) { return ndx % 2 }
, toBinary: function toBinary(geohash) { return geohash.toLowerCase().split("").map(function(g) { return GEOHASH.zeropad(GEOHASH.BASE32.indexOf(g).toString(2)) }); }
, toDecimal: function toDecimal(blat, mult) {
var min=-90*mult, max=90 * mult, mid=0.0;