Skip to content

Instantly share code, notes, and snippets.

@simlrh
simlrh / machine.js
Created March 13, 2020 13:39
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@simlrh
simlrh / machine.js
Last active March 10, 2020 12:42
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@simlrh
simlrh / machine.js
Created March 4, 2020 16:33
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@simlrh
simlrh / getKeys.ts
Last active March 2, 2021 17:45
Miscellaneous TypeScript helpers
// Wrapper for Object.keys which sets the correct type
export function getKeys<T>(obj: T): Array<keyof T> {
return Object.keys(obj) as Array<keyof T>;
}
@simlrh
simlrh / composable.ts
Last active April 17, 2022 05:39
Typescript compose and pipe "infix operators"
interface Composable<B,C> {
(b: B): C;
I: <D>(f: (c: C) => D) => Composable<B,D>;
o: <A>(f: (a: A) => B) => Composable<A,C>;
}
/*
* Non-type safe internal function - type safety of result is guaranteed by
* allowing creation only through `I` and `o` functions and methods
*/
@simlrh
simlrh / indentation.vim
Created February 6, 2017 18:06
Indentation functions for vim
"------------------------------------------------------------
" Indentation options {{{1
"
let g:mytabcolumns = 4
set noexpandtab
set softtabstop=0
set shiftwidth=4
set tabstop=4
@simlrh
simlrh / abc.js
Created January 26, 2017 14:19
Tree shaking example
import { d, e, f } from "./def.js";
// a is used
export const a = d + " is part of a";
// b is unused
export const b = e + " is part of b";
// c is unused
export const c = f + " is part of c";
@simlrh
simlrh / concat.rb
Created November 15, 2016 14:05
Use Liquid's new array concatenation in Jekyll
module Jekyll
module ConcatFilter
def concat(one, two)
one.concat(two)
end
end
end
Liquid::Template.register_filter(Jekyll::ConcatFilter)
@simlrh
simlrh / index.rb
Created November 11, 2016 18:24
A quick and dirty Jekyll plugin to remove 'index.html' from the end of urls when using a clean permalink scheme
# Usage: {{ post.url | remove_index }}
module Jekyll
module RemoveIndexFilter
def remove_index(input)
url = if input
input.split("/")[0..-2].join("/") + "/"
else
input
end
@simlrh
simlrh / osvr_server_config.json
Created November 11, 2016 17:07
OSVR-firmata server config
{
"description": "The default config file, as used with the HDK, is fully auto-detected, so no configuration required. See the JSON-Schema for server config or other samples to see possible options.",
"aliases": {
"/controller/right/joystick/x": "/je_nourish_firmata/StandardFirmata.ino-X.Y/analog/0",
"/controller/right/joystick/y": "/je_nourish_firmata/StandardFirmata.ino-X.Y/analog/1",
"/controller/right/joystick/button": "/je_nourish_firmata/StandardFirmata.ino-X.Y/button/0"
}
}