Skip to content

Instantly share code, notes, and snippets.

View dominictarr's full-sized avatar

Dominic Tarr dominictarr

View GitHub Profile
@dominictarr
dominictarr / level-magic.js
Last active August 29, 2015 14:01
Automagically join sql tables loaded into level
/*
Each table is put into it's own sublevel.
It's assumed that every table's primary key is ID.
and a foreign key is always {table}ID
If there isn't A table with that name, assume it's a self link.
(like ManagerID points back to the Employee table)
*/
//Automagically join two tables that have conventionally named fields.
// magic (nameOfLeftTable, nameOfRightTable)
@dominictarr
dominictarr / schema.js
Created August 6, 2014 22:19
git's secure datastructure described by a schema thingee
//top level is types, key:values are the structure that object must have,
//and the types of the values.
//Link means the hash of an object of the named type.
//Plus and Star define sets. And are just like regular expression + and *
//you could also have ? (Maybe) but it's not necessary to describe git.
{
COMMIT: {
//a cypherlink to a commit object
@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 / 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)
}
@dominictarr
dominictarr / async_testing.runfile.asynct.js
Created November 20, 2010 05:31
break async_testing.runFile
//async_testing.runfile.asynct
exports ['does not call onSuiteDone twice'] = function (test){
var file = 'async_testing/test/test-stderr'
require('async_testing').runFile(file,{onSuiteDone:suiteDone})
function suiteDone (status,report){
console.log("suiteDone - " + status + "'" + file + "'")
@dominictarr
dominictarr / stats_parse.rb
Created December 2, 2010 00:27
parse the monthy stats from awstats.***.tld
#! ruby
require "eregex"
@patterns = Hash.new
@keys = []
def path(dir, group=nil)
if (dir.is_a? String) then
dir = Regexp.escape(dir)