View UnionIntersection.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends ((k: infer I) => void) ? I : never | |
type IntersectionToUnion<I> = (I extends any ? (x: I) => any : never) extends ((x: infer U) => any) ? U : never; |
View islanders.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Random Integer from m to n excluding e | |
const randInt = (m: number, n: number, e?: number): number => { | |
const result = Math.floor(Math.random() * m) + n; | |
return e == undefined ? result : | |
result == e ? randInt(m, n, e) : | |
result | |
} | |
class Person { constructor(public weight: number) {} } |
View Functional.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** Number Expressions */ | |
// data | |
type Exp = | |
{ tag: 'Lit', value: number } | | |
{ tag: 'Add', left: Exp, right: Exp } | |
// operations | |
function evaluate(exp: Exp): number { | |
switch (exp.tag) { |
View error.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Context: <https://groups.google.com/a/magnolia-cms.com/g/user-list/c/MRpHYKkOMhA> | |
Type Exception Report | |
Message com.machinezoo.noexception.WrappedException: java.net.ConnectException: Connection refused (Connection refused) | |
Description The server encountered an unexpected condition that prevented it from fulfilling the request. | |
Exception |
View cyclicPerms.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// cyclicPerms(5) | |
// "1,2,3,4,5 | |
// 2,3,4,5,1 | |
// 3,4,5,1,2 | |
// 4,5,1,2,3 | |
// 5,1,2,3,4" | |
const cyclicPerms = (n) => | |
Array.from({length: n},(_,i) => i + 1) | |
.map((_, i, xs) => [...xs, ...xs].slice(i, i+n)) | |
.join('\n') |
View bool.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface Boolean { | |
ifTrue<T>(fn: () => T): T | undefined | |
ifFalse<T>(fn: () => T): T | undefined | |
} | |
Object.assign(Boolean.prototype, { | |
ifTrue(fn: Function) { | |
return this ? fn.apply(this) : undefined | |
}, | |
ifFalse(fn: Function) { |
View databinding.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Bindable(proto: any, name: PropertyKey) { | |
const desc = Object.getOwnPropertyDescriptor(proto, name) | |
delete proto.name | |
if ((proto['_dispatchEvent']) == undefined) { | |
Object.defineProperty(proto, '_dispatchEvent', { | |
value(event: Event) { | |
} |
View arith-bool.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// x, y :: {0,1} | |
var and = (x,y) => x * y, | |
not = (x) => 1 - x, | |
or = (x,y) => 1 - (1 - x) * (1 - y) | |
and(0,0) // 0 | |
and(0,1) // 0 | |
and(1,0) // 0 | |
and(1,1) // 1 |
View README.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- The application is currently single threaded | |
- The following commands have been implemented: | |
- exit | |
- create <PATH> | |
- open <PATH> | |
- display | |
- ls | |
- cd <TFS> (partial) | |
- mkdir <TFS> (partial). currently buggy due to nibble manipulation | |
- import <PATH> <TFS> (partial) stub + error checking only |
View hackathon-2016.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function main() { | |
console.log("question1(0) == 0"); | |
console.assert(question1(0) == 0, `${question1(0)}`); | |
console.log("question1(1) == 1"); | |
console.assert(question1(1) == 1, `${question1(1)}`); | |
console.log("question1(7) == 13"); | |
console.assert(question1(7) == 13, `${question1(7)}`); | |
console.log("question1(12) == 144"); | |
console.assert(question1(12) == 144, `${question1(12)}`); |
NewerOlder