Skip to content

Instantly share code, notes, and snippets.

View hediet's full-sized avatar

Henning Dieterichs hediet

View GitHub Profile
@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)();
}
/**
@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 / 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
};
}
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 / types.ts
Created July 23, 2019 10:49
DestructureTuple & DeepSelect
export type DestructureTuple<T extends any[]> = T extends []
? false
: ((...tuple: T) => void) extends ((
first: infer TFirst,
...rest: infer TRest
) => void)
? { first: TFirst; rest: TRest }
: false;
@hediet
hediet / I18n.ts
Created August 20, 2019 13:26
I18n.ts
interface FormatDescriptor {
id: string;
defaultTemplate?: string;
}
export type Formatted =
| { kind: 'text'; value: string }
| { kind: 'sequence'; items: Formatted[] }
| { kind: 'object'; items: Record<string, Formatted> };
@hediet
hediet / createProgram.ts
Created September 11, 2019 13:59
createProgram from tsConfigSearchPath
import * as ts from "typescript";
import { dirname, resolve } from "path";
export function createProgram(tsConfigSearchPath: string): ts.Program {
const configPath = ts.findConfigFile(
tsConfigSearchPath,
ts.sys.fileExists,
"tsconfig.json"
);
@hediet
hediet / WebBrowserIE11Fix.cs
Created August 17, 2016 03:42
A fix that enables IE11 for the WPF browser control.
internal static class WebBrowserIE11Fix
{
public static void SetIE11KeyforWebBrowserControl(string processPath = null)
{
if (processPath == null)
{
processPath = Process.GetCurrentProcess().ProcessName + ".exe";
}
RegistryKey Regkey = null;
@hediet
hediet / after.ts
Created April 3, 2020 12:37
Mobx Complex Observable Example
type State = { kind: 'loading' } | { kind: 'loaded'; service: unknown };
@injectable()
class LoadServiceModel {
constructor(
@injectProps()
private readonly props: {
service: ServiceId<unknown>;
module?: Module;
},
@hediet
hediet / feedback.md
Last active May 11, 2020 09:49
Binary Custom Editor API Feedback

Blocker

This issue is a blocker for the .drawio.png feature. This is my context. I hope something can be done there ;)

Confusion Points

  1. Default Generic Type Argument

I have to admit, I failed to recognize that CustomEditorProvider is generic when I exploratively implemented my first prototype.