Seems to me some kind of black magic goes on behind the scenes. The example below might not be an MRE, but it's prety intuitive. Experiment with it in the [playground](https://www.typescriptlang.org/play?#code/PTAEGEHsFcDsBcA8sB8oC8oDaAGANKAIwEB0ZBsAugLABQ8AngA4CmEMCiAMi7KCwA94vACYBnULGgBbAEYsATgQCCChfyGiJUuYqyUM2SmnR1QoVQqwByADa8A5vAAW1g4OGxxoHnwD8FmqgAFzscEi+BFhkJJYqajb2sE6ulMZ0dCCgAKI6igCGwsgmoDigAD5EFaAx1bB0jKw5eQqFLNy8Gp7eOvJKgeoeWpIyffqG+iZmA4mOLm5dw76gAZZYvYoGobkyBUWR2DFxM3Zzqem0mWAAKvkAlraIWPkEsgQAxqRkxhNvoJ81b4NZhsW4PRDXRZeCT5WAMSaGSFDaHYUCwhhfEh3WAAM0UzREoAMAVyhNC+gA3BlaFkAAoKFgiYqGWAAWkIwKa9MZiGUUJ6o0UJTBj2iZCg4V5KGMs2S8xolxpYAAQgxhAA5QXqTBlSqEaq1SoAJgArCbOWxVRqtYYdtI9u1TQA2FDUrIASVpADcACwAZXgCmxDkMAAMACQAbytLE1ugUAF8ABQkKMxuN9BMASgAVKGLaBPb6A0HkhD+RIxIHgwQAGqIqa0cxIzQoiPRtWxrUJ1OR7F49QAJQT+abK0L3v91bLg7rrrHoRb3Qk7fT3dH5gCtemoVgLC9imp70gsCroGEVaLU9LIcw5eR3irN5QSdgoSvJeDEJQWYwaFgVL0Cwl6Tp+yRJtYhA4Ca1hZg0wHwB+04OBBhA+kaJDOrB8EgcWyEQUaADMPokAA7CQhAAByESQhEYSahC0
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
{-# LANGUAGE OverloadedStrings #-} | |
import qualified Data.ByteString.Lazy as BL | |
import qualified Data.Text as T | |
import qualified Data.Text.Encoding as TE | |
import qualified Network.Wai as Wai | |
import qualified Network.Wai.Handler.Warp as Warp | |
import qualified Network.Wai.Middleware.RequestLogger as RequestLogger | |
import qualified Network.Wai.Middleware.Static as Static | |
import qualified Network.Wai.Parse as Parse |
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
# Setup headless raspbian | |
# Install PulseAudio and vlc for http stream sinks | |
sudo apt install pulseaudio vlc | |
# Install librespot via raspotify, but disable raspotify | |
curl -sL https://dtcooper.github.io/raspotify/install.sh | sh | |
sudo systemctl disable raspotify.service | |
# Install librespot user service |
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
{ nixpkgs ? import <nixpkgs> { } | |
, pkgs ? nixpkgs.pkgs | |
, lib ? pkgs.lib | |
, nixos ? import <nixpkgs/nixos> | |
}: | |
let | |
config = (nixos { | |
configuration.security.acme.certs."example.com".email = "[email protected]"; | |
configuration.services.nginx = { | |
enable = true; |
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
-- Based off https://www.youtube.com/watch?v=fVBck2Zngjo | |
module Fmt | |
%default total | |
data FPart | |
= FShow -- "{}" (Show a => a) | |
| FInt -- "{i}" (Int) | |
| FString -- "{s}" (String) |
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
// Define our configuration as specific as possible | |
/////////////////////////////////////////////////// | |
type Natural = number & { __nat__: void }; | |
function isNatural(val: unknown): val is Natural { | |
return typeof val === "number" && val % 1 === 0 && val >= 0; | |
} | |
type Version = 1; | |
function isVersion(val: any): val is Version { |
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
// is :: (U String Constructor) ---> T --(Predicate for `object` being a `test`)--> Bool | |
const is = test => object => | |
typeof test === 'string' | |
? typeof object === string // object is assured to be a string | |
: object instanceof test // Object can be anything but a string | |
const x = [1, 2, 3] | |
if ( is(Array)(x) ) { | |
// x is assured to be an array | |
x.push(5) |
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
// ==UserScript== | |
// @name Overleaf Vim File Select | |
// @namespace Violentmonkey Scripts | |
// @version 1 | |
// @grant unsafeWindow | |
// @include https://www.overleaf.com/project/* | |
// @run-at document-idle | |
// ==/UserScript== | |
const getFileTree = () => document.getElementsByClassName('file-tree-inner')[0] |
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
" I need to forget arrows | |
noremap <Up> <NOP> | |
noremap <Down> <NOP> | |
noremap <Left> <NOP> | |
noremap <Right> <NOP> | |
vnoremap <Up> <NOP> | |
vnoremap <Down> <NOP> | |
vnoremap <Left> <NOP> | |
vnoremap <Right> <NOP> | |
inoremap <Up> <NOP> |
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
% Forgetting an unexpandable after advance has unpredictable errors | |
% creeping up when numbers are processed afterwards. | |
\advance\ThrottleCounter by -1% | |
\ifnum\the\ThrottleCounter=0% | |
#1% | |
\fi | |
% The above fails misserably if the counter is on 0 and the first | |
% argument happens to be a number, then it will be expanded to. | |
\advance\ThrottleCounter by -1#1 | |
% which turns out to be |
NewerOlder