Skip to content

Instantly share code, notes, and snippets.

View heikkipesonen's full-sized avatar

Heikki Pesonen heikkipesonen

View GitHub Profile
@heikkipesonen
heikkipesonen / deep-typed-path.ts
Last active February 22, 2019 20:38
typesafe deep object path
type KeyOf<T> = keyof T
function get<T, K1 extends KeyOf<T>>(o: T, p1: K1): T[K1]
function get<T, K1 extends KeyOf<T>, K2 extends KeyOf<T[K1]>>(o: T, p1: K1, p2: K2): T[K1][K2]
function get<T, K1 extends KeyOf<T>, K2 extends KeyOf<T[K1]>, K3 extends KeyOf<T[K1][K2]>>(o: T, p1: K1, p2: K2, p3: K3): T[K1][K2][K3]
function get<T, K1 extends KeyOf<T>, K2 extends KeyOf<T[K1]>, K3 extends KeyOf<T[K1][K2]>, K4 extends KeyOf<T[K1][K2][K3]>>(o: T, p1: K1, p2: K2, p3: K3, p4: K4): T[K1][K2][K3][K4]
function get<T, K1 extends KeyOf<T>, K2 extends KeyOf<T[K1]>, K3 extends KeyOf<T[K1][K2]>, K4 extends KeyOf<T[K1][K2][K3]>, K5 extends KeyOf<T[K1][K2][K3][K4]>>(o: T, p1: K1, p2: K2, p3: K3, p4: K4, p5: K5): T[K1][K2][K3][K4][K5]
function get<T, K1 extends KeyOf<T>, K2 extends KeyOf<T[K1]>, K3 extends KeyOf<T[K1][K2]>, K4 extends KeyOf<T[K1][K2][K3]>, K5 extends KeyOf<T[K1][K2][K3][K4]>>(o: T, p1: K1, p2?: K2, p3?: K3, p4?: K4, p5?: K5) {
return p5 && p4 && p3 && p2 ? o[p1][p2][p3][p4][p5] :
p4 && p3 && p2 ? o[p1][p2]
@heikkipesonen
heikkipesonen / gh-pages-deploy.md
Created March 13, 2016 17:48 — forked from cobyism/gh-pages-deploy.md
Deploy to `gh-pages` from a `dist` folder on the master branch. Useful for use with [yeoman](http://yeoman.io).

Deploying a subfolder to GitHub Pages

Sometimes you want to have a subdirectory on the master branch be the root directory of a repository’s gh-pages branch. This is useful for things like sites developed with Yeoman, or if you have a Jekyll site contained in the master branch alongside the rest of your code.

For the sake of this example, let’s pretend the subfolder containing your site is named dist.

Step 1

Remove the dist directory from the project’s .gitignore file (it’s ignored by default by Yeoman).