This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Exhaustive visitation for discriminated unions. | |
* Let's say you have something like | |
* | |
* type T = { type: "number", value: number } | { type: "string", value: string }; | |
* const t: T = ...; | |
* | |
* Then you can say | |
* | |
* discriminate(t, "type", { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Type guard for cases where one field of a structure determines | |
* the nullability of a selection of other fields. | |
* In the best case this will only check the `discriminator` field | |
* against the given `discriminant`, but you will also get a runtime error | |
* if any of the given `entailed` fields are `null`-ish when you don't | |
* expect them to be. | |
*/ | |
export function checkAndEntail<T, I extends keyof T, J extends keyof T>( | |
t: T, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var global = 42; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Kernel | |
# Define default options for a method. | |
# | |
# def foo(bar, options = {}) | |
# default options, baz: "qux" | |
# end | |
def default(options, default_options) | |
options.replace(default_options.merge(options)) | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
VoodooPad Random Page Script Plugin | |
=================================== | |
A script plugin to add an essential missing feature to the personal desktop | |
wiki VoodooPad: opening a random page. | |
Just hit the button in your Plugins menu to open a page randomly picked from | |
your current document. Every page has an equal probability of appearing; | |
independent of how many aliases it has. Also this plugin does not pick the | |
files you store in your VoodooPad document. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ApplicationHelper | |
def b(value, options = {}) | |
options = { | |
:true => :positive, | |
:false => :negative, | |
:scope => [:boolean], | |
:locale => I18n.locale | |
}.merge options | |
boolean = !!value |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CMAKE_MINIMUM_REQUIRED( | |
VERSION | |
2.8 | |
) | |
PROJECT( | |
speech | |
) | |
FIND_LIBRARY( |