Skip to content

Instantly share code, notes, and snippets.

interface LineItem {
id: string,
amount: number,
name: string,
}
type TransformFn<T1, T2> = (item: T1) => T2
// v0 This function takes a set of transform functions and call them in sequence
// someone could say it "composes" them
@ih2502mk
ih2502mk / Angular - custom structural directives.md
Created September 15, 2021 18:44 — forked from JanMalch/Angular - custom structural directives.md
Writing your own structural directives with context variables

Writing your own structural directives with context variables

Complete code in math.directive.ts

After reading this you will be able to create a structural directive with inputs and context variables and use it like this:

<div *math="10; exponent: 3; let input; 
            let exponent = exponent; let r = root;
 let p = power; let ctrl = controller"&gt;
@ih2502mk
ih2502mk / list.md
Last active December 23, 2024 18:42
Quantopian Lectures Saved
0x1d889fCCB79F8902700Eb313C2255D937F21DC77
@ih2502mk
ih2502mk / index.js
Last active August 29, 2015 14:16
requirebin sketch
var uuid = require("uuid")
var rnd_str = require('random-string')
var m = require('mercury');
var h = m.h;
var diff = m.diff;
var patch = m.patch;
var createElement = m.create;
var array = m.array;
@ih2502mk
ih2502mk / post-receive.sh
Last active August 29, 2015 14:15
post-receive hook
#!/bin/bash
now=`date +"%F_%I-%M-%S"`
project=`pwd | awk '{n=split($0,a,"/"); split(a[n],b,"."); print b[1]}'` # Don't ask...
sandbox=$HOME/tmp/$project
if [ ! -d "$sandbox" ]; then
mkdir -p $sandbox
fi
@ih2502mk
ih2502mk / index.js
Created February 16, 2015 02:26
requirebin sketch
var mercury = require("mercury")
var h = mercury.h
var nextTick = require('next-tick')
var rnd_str = require('random-string')
var events = {
addItem: mercury.input()
};
var state = mercury.struct({
@ih2502mk
ih2502mk / index.js
Last active August 29, 2015 14:15
requirebin sketch
var mercury = require("mercury")
var h = mercury.h
var nextTick = require('next-tick')
var rnd_str = require('random-string')
var events = {
addItem: mercury.input(),
removeItem: mercury.input()
};
@ih2502mk
ih2502mk / index.js
Last active August 29, 2015 14:15
requirebin sketch
var mercury = require("mercury")
var h = mercury.h
var nextTick = require('next-tick')
var rnd_str = require('random-string')
var events = {
addItem: mercury.input(),
removeItem: mercury.input()
};
@ih2502mk
ih2502mk / js-object-key-value-stored.js
Last active August 29, 2015 14:14
js-key-value-storage-objects
universal_getter = function(id, prop_name, cb) {
// get it from db or some data set
// if fails set erro to `new Error()`
//
// if storage is locked wait till it gets unlocked
//
// goGetItFromDB(prop_name, function(err, val) {
return cb(err, val);
// })