Skip to content

Instantly share code, notes, and snippets.

View hediet's full-sized avatar

Henning Dieterichs hediet

View GitHub Profile
import * as remarkAbstract from "remark";
interface Position {}
interface Node<T extends string = string> {
position: Position;
type: T;
}
interface NodeList<T extends string = string, TItem extends Node = Node>
@hediet
hediet / helper.ts
Last active June 3, 2019 14:36
React Dependency Injection
import * as React from "react";
import { Container } from "inversify";
export function ref<T>(name: string): { T: T; id: string } {
return {
T: null!,
id: name
};
}
@hediet
hediet / A
Last active April 28, 2019 19:30
Solution for A and B so that AB = (Q ∪ { ϵ }) for all words up to length 9 and a ϵ A and ab ϵ B
a
aaaaababb
ababa
abababa
b
babab
babababab
@hediet
hediet / Config.ts
Last active April 25, 2019 17:36
Config System
// tslint:disable: no-shadowed-variable
/**
* Describes a new configuration.
*/
export function newConfig(): Config {
return new (Config as any)();
}
/**
// shared
export const debuggerProxyContract = contract({
server: {
keepAlive: notificationContract({}),
},
client: {
serverStarted: notificationContract({ params: type({ port: number }) }),
clientConnected: notificationContract({}),
},
});
type SchemaType = PrimitiveSchema | ObjectSchema | ParametrizedObjectSchema;
interface PrimitiveSchema<T = any> {
kind: "primitive";
type: T;
}
interface Fields {
[name: string]: SchemaType;
}
function tex(str: TemplateStringsArray, ...data: string[]) { }
const c = Sigma* *1
const Sigma = "uiae";
const SigmaS = "";
const x =
(
<def>
Ein {Sigma}-{Sigma}-Advice (Hinweis) {A} ist eine Abbildung
{A : Sigma* -> Pot(Gamma*)}
@hediet
hediet / installation.json
Created July 9, 2017 13:09
Alternative to node_modules
{
"dependencies": {
"classnames": {
"ref": "classnames@2.2.5_1"
},
"mobx": {
"ref": "mobx@3.2.0_2"
},
"mobx-react": {
"ref": "mobx-react@4.2.2_3"
@hediet
hediet / main.ts
Created April 21, 2017 19:29
Acceptor / User Pattern for TypeScript
interface Acceptor<T extends string> {
accept(x: UserOf<T>): any;
allow<T1 extends string>(x: T1): Acceptor<T|T1>;
}
interface UserOf<T extends string> {
_brand: T;
}
function use<T extends string>(name: T): UserOf<T> { return null!; }
@hediet
hediet / main.md
Last active March 11, 2024 15:05
Proof that TypeScript's Type System is Turing Complete
type StringBool = "true"|"false";


interface AnyNumber { prev?: any, isZero: StringBool };
interface PositiveNumber { prev: any, isZero: "false" };

type IsZero<TNumber extends AnyNumber> = TNumber["isZero"];
type Next<TNumber extends AnyNumber> = { prev: TNumber, isZero: "false" };
type Prev<TNumber extends PositiveNumber> = TNumber["prev"];