Skip to content

Instantly share code, notes, and snippets.

View jahan-addison's full-sized avatar

Jahan Addison jahan-addison

View GitHub Profile
@jahan-addison
jahan-addison / a.ts
Last active August 16, 2018 20:37
qj2
import { ƛ, Connect, server, message, reply, on } from './lib/dsl';
const sandbox = require('sandbox');
const virtual = new sandbox();
ƛ({
server: 'irc.freenode.org',
nick: 'qj2',
channel: '##frontend'
},
@jahan-addison
jahan-addison / a.ts
Last active December 21, 2017 15:25
DSL in Javascript (Typescript)
ƛ({
server: 'irc.freenode.org',
nick: 'dslbot',
channel: '##dslbottesting'
},
Connect(6667)(
line => on(/PING (\S+)/)(_ => {
server`PONG ${_}`
}),
line => on(/hello/)(_ => {
// Copyright (c) 2016, Jahan Addison
// License: MIT
// @version: 1.2.0
type Tuple<T> = [T];
type Pure<T> = (T: T) => T;
type Pattern = string | number;
type Invoker = Pure<Pattern>;
type Val = Tuple<Pattern>;
type Case = boolean;
var trait = require("../../util/trait");
module.exports = trait("UserServiceInterface", [
"createUser",
"createUserFromForm",
"getUserByEmail",
"authenticateUser",
"authenticateUserFromForm",
"isUserAdmin"
]);
import assert from 'assert';
import co from 'co';
const state1 = (_) => new Promise((resolve, reject) => {
resolve(5);
});
const state2 = (a) => new Promise((resolve, reject) => {
resolve(a + 5);
});
const state3 = (b) => new Promise((resolve, reject) => {
@jahan-addison
jahan-addison / tetrad.js
Last active August 29, 2015 14:09
Non-deterministic tetrad color set for visual applications
var Tetrad = function() {
this.degrees = 30;
this.colors;
};
Tetrad.prototype = (function() {
/**
* Private
*/
@jahan-addison
jahan-addison / category.js
Created August 8, 2014 14:18
Category tree ( 'trie' ) to be used with d3's treemap
/*
Category-tree
Search time: O(n)
Insert time: O(n)
*/
if (!Array.prototype.find) {
Object.defineProperty(Array.prototype, 'find', {
enumerable: false,
@jahan-addison
jahan-addison / colouri.js
Last active August 29, 2015 14:04
A generator of infinite contiguously-good-looking colors
;(function(global, undefined) {
'use strict';
var Colouri = function() {
this.color = '1d9caf';
};
global.Colouri = Colouri;
Colouri.prototype = (function() {
/**
* Private
*/