Skip to content

Instantly share code, notes, and snippets.

type ChildAndParent<TParent, TChild> = TParent extends string
? `${TParent}.${TChild extends string ? TChild : never}`
: TChild;
type DotNotation<T, TParent = false> = T extends object
? { [K in keyof T]: TParent | DotNotation<T[K], ChildAndParent<TParent, K>> }[keyof T]
: TParent
type Foo = DotNotation<{
a: "hello"
b: "darkness"
@acacio
acacio / upnp.js
Created January 12, 2012 21:17
UPNP Port Forwarding for node.js
/* node UPNP port forwarding PoC
This is a simple way to forward ports on NAT routers with UPNP.
This is a not-for-production hack that I found useful when testing apps
on my home network behind ny NAT router.
-satori
usage: