Skip to content

Instantly share code, notes, and snippets.

eating cheese

Jasper Van der Jeugt jaspervdj

eating cheese
View GitHub Profile
jaspervdj / Main.js
Last active Jun 8, 2021
ZuriHac Calendar
View Main.js
"use strict";
exports.innerText = function(element) {
return function() {
return element.innerText;
exports.renderDateTime = function(date) {
return function() {
#!/usr/bin/env python
import os.path
import sys
import time
import urllib.parse
import urllib.request
from typing import Iterable
def get_segment_urls(m3u8_url: str) -> Iterable[str]:
m3u8_text: str = urllib.request.urlopen(m3u8_url).read().decode('utf-8')
View traverse.hs
-- Imagine you're trying to guess someone's PIN code, and you have limited
-- info on each digit, e.g. if the digit is odd or even.
type Predicate a = a -> Bool
-- This is the info we have about the PIN code.
info :: [Predicate Int]
info = [odd, even, even, odd]
-- A helper to produce all digits satisfying a predicate.
digits :: Predicate Int -> [Int]
jaspervdj /
Created Feb 7, 2020
Zero-config MiniDLNA/ReadyMedia
set -o nounset -o errexit -o pipefail
# Create temporary locations for the configuration and data directories.
DATADIR="$(mktemp -d)"
# Write the configuration to the temporary location.
echo "media_dir=$PWD" >>"$CONFIG"
echo "db_dir=$DATADIR" >>"$CONFIG"
View Makefile
ln -sf $(PWD)/ $(HOME)/.local/bin/
jaspervdj / readprec.hs
Created Dec 6, 2019
Parser for readPrec
View readprec.hs
-- Quick example of how to "properly" use readPrec with a "real" parser
import Data.Char (isDigit, toUpper)
import qualified Text.ParserCombinators.ReadP as P
import qualified Text.Read as R
data WirePath = WirePath {d :: Char, a :: Int} deriving (Show)
instance R.Read WirePath where
readPrec = R.readP_to_Prec $ const $ do
c <- P.get
jaspervdj / specialize-handle.hs
Created Oct 14, 2019
Specializing "Handle" functions
View specialize-handle.hs
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
data Handle = Handle
generic1 :: Handle -> Char -> Bool -> IO ()
generic1 = undefined
generic2 :: Handle -> String -> Char -> Bool -> IO ()
View prism.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
jaspervdj / list-vs-non-empty.hs
Created Apr 3, 2019
Is List or NonEmpty "simpler"? Neither.
View list-vs-non-empty.hs
-- Is List or NonEmpty "simpler"? Neither:
type NonEmpty a = Fix (Compose ((,) a) Maybe)
type List a = Fix (Compose Maybe ((,) a))
newtype Fix f = Fix {unFix :: f (Fix f)}
jaspervdj / cat-image.hs
Created Aug 25, 2018
Display an image in the terminal using w3mimagedisplay
View cat-image.hs
import Control.Monad (unless)
import qualified System.Directory as Directory
import System.Environment (getArgs)
import qualified System.Process as Process
import Text.Read (readMaybe)
newtype W3mImageDisplay = W3mImageDisplay FilePath deriving (Show)
findW3mImageDisplay :: IO W3mImageDisplay
findW3mImageDisplay = do