This file contains 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
export const hasDefinedKey = | |
<K extends PropertyKey>(key: K) => | |
<T extends Partial<Record<K, unknown>>>( | |
obj: T, | |
): obj is T & Record<K, Exclude<T[K], undefined>> => | |
key in obj && obj[key] !== undefined; |
This file contains 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
;(_=>{ | |
let hc={'<':'<','&':'&',"'":''','"':'"'},he=x=>x.replace(/[<&'"]/g,c=>hc[c]) //html chars and escape fn | |
,tcs='<-←xx×/\\×:-÷*O⍟[-⌹-]⌹OO○77⌈FF⌈ll⌊LL⌊|_⊥TT⊤-|⊣|-⊢=/≠L-≠<=≤<_≤>=≥>_≥==≡=_≡/_≢L=≢vv∨^^∧^~⍲v~⍱^|↑v|↓((⊂cc⊂(_⊆))⊃[|⌷|]⌷A|⍋V|⍒ii⍳i_⍸ee∊e_⍷'+ | |
'uu∪UU∪nn∩/-⌿\\-⍀,-⍪rr⍴pp⍴O|⌽O-⊖O\\⍉::¨""¨~:⍨~"⍨*:⍣*"⍣oo∘o:⍤o"⍤[\'⍞\']⍞[]⎕[:⍠:]⍠[=⌸=]⌸[<⌺>]⌺o_⍎oT⍕o-⍕<>⋄on⍝->→aa⍺ww⍵VV∇--¯0~⍬'+ | |
'^-∆^=⍙[?⍰?]⍰:V⍢∇"⍢||∥ox¤)_⊇_)⊇O:⍥O"⍥V~⍫\'\'`' | |
,lbs=['←←\nASSIGN',' ','++\nconjugate\nplus','--\nnegate\nminus','××\ndirection\ntimes','÷÷\nreciprocal\ndivide','**\nexponential\npower','⍟⍟\nnatural logarithm\nlogarithm', | |
'⌹⌹\nmatrix inverse\nmatrix divide','○○\npi times\ncircular','!!\nfactorial\nbinomial','??\nroll\ndeal',' ','||\nmagnitude\nresidue', | |
'⌈⌈\nceiling\nmaximum','⌊⌊\nfloor\nminimum','⊥⊥\ndecode','⊤⊤\nencode','⊣⊣\nsame\nleft','⊢⊢\nsame\nright',' ','==\nequal','≠≠\nnot equal', | |
'≤≤\nless than or equal to','<<\nless than','>>\ngreater than','≥≥\ngreater than or equal to','≡≡\ndepth\nmatch','≢≢\ntally\nnot matc |
This file contains 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
say("Hello World"); |
This file contains 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
import slick.jdbc.{GetResult, PositionedResult} | |
import scala.annotation.implicitNotFound | |
import scala.reflect.runtime.universe.TypeTag | |
/** | |
* A type class that allows the user of GenericGetResult to support their own type. | |
* This is mostly used to support `newtype`s (like wrappers around UUIDs). | |
* | |
* A user just has to use the helper to make the type known to GenericGetResult. |
This file contains 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
my @a = ('99 bottles', 'take one down', '98 bottles'); | |
for @a { | |
say "$^a of beer on the wall, $^a of beer.$^b, $^c of beer on the wall.".tc; | |
} | |
my @b = ('99 bottles', 'take one down', '98 bottles'), ('98 bottles', 'take one down', '97 bottles'); | |
say @b.perl; | |
for @b { | |
say "$^a of beer on the wall, $^a of beer.$^b, $^c of beer on the wall.".tc; | |
} |
This file contains 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
macro $do { | |
rule {($($x = $y) (,) ...) $body} => { | |
(function ($x (,) ...) $body)($y (,) ...) | |
} | |
rule {$name ($($x = $y) (,) ...) $body} => { | |
(function $name ($x (,) ...) $body)($y (,) ...) | |
} | |
} | |
macro $var { |
This file contains 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
macro null_helper { | |
rule {($processed ...) ($rest)} => { | |
$processed (.) ... . $rest | |
} | |
rule {($processed ...) ($rest_head $rest ...)} => { | |
$processed (.) ... . $rest_head | |
&& null_helper ($processed ... $rest_head) ($rest ...) | |
} | |
} |
This file contains 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
// y-combinator | |
macro $y { | |
rule {( $var )} => { | |
function(){ | |
return function (f){ | |
return f(f) | |
}(function(f){ | |
return $var(function(x){ | |
return f(f)(x); | |
}) |
This file contains 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
macro to_string { | |
case $x => { (JSON.stringify({ $x: 0 }).slice(2, -4)) } | |
} | |
macro enum { | |
case [ $val:ident (,) ... ] => { | |
(function () { | |
var e = { | |
$( $val : (to_string $val) ) (,) ... | |
}; |
This file contains 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
macro $do { | |
rule {($($x = $y) (,) ...) $body} => { | |
(function ($x (,) ...) $body)($y (,) ...) | |
} | |
rule {$name ($($x = $y) (,) ...) $body} => { | |
(function $name ($x (,) ...) $body)($y (,) ...) | |
} | |
} | |
$do (a = 1, b = 2) { |
NewerOlder