Skip to content

Instantly share code, notes, and snippets.

View jaspervdj's full-sized avatar
🧀
eating cheese

Jasper Van der Jeugt jaspervdj

🧀
eating cheese
View GitHub Profile
@jaspervdj
jaspervdj / tryhaskell.nix
Last active June 16, 2023 21:29
reproducibly build a docker image for tryhaskell
{ }:
let
pkgs = import (fetchTarball https://github.com/NixOS/nixpkgs/archive/17.03.tar.gz) { };
exactOverride = self: pkg: version: pkgs.haskell.lib.dontCheck (self.callCabal2nix
pkg
(builtins.fetchTarball {
url = "https://hackage.haskell.org/package/${pkg}-${version}/${pkg}-${version}.tar.gz";
})
{ }
{-# LANGUAGE ScopedTypeVariables #-}
module Subscribe where
import qualified Data.IORef as IORef
import Data.Proxy (Proxy (..))
import qualified Data.Map as Map
-- Event types, just stupid examples
data Event
@jaspervdj
jaspervdj / README.md
Last active April 13, 2023 13:59
ZuriHac Calendar
#!/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')
@jaspervdj
jaspervdj / traverse.hs
Created September 30, 2020 11:18
It's traverse
-- 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
jaspervdj / minidlnad.sh
Created February 7, 2020 19:53
Zero-config MiniDLNA/ReadyMedia
#!/bin/bash
set -o nounset -o errexit -o pipefail
# Create temporary locations for the configuration and data directories.
CONFIG="$(mktemp)"
DATADIR="$(mktemp -d)"
# Write the configuration to the temporary location.
echo "media_dir=$PWD" >>"$CONFIG"
echo "db_dir=$DATADIR" >>"$CONFIG"
install:
ln -sf $(PWD)/badtv.sh $(HOME)/.local/bin/
@jaspervdj
jaspervdj / readprec.hs
Created December 6, 2019 11:56
Parser for readPrec
-- 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
jaspervdj / specialize-handle.hs
Created October 14, 2019 18:05
Specializing "Handle" functions
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
data Handle = Handle
generic1 :: Handle -> Char -> Bool -> IO ()
generic1 = undefined
generic2 :: Handle -> String -> Char -> Bool -> IO ()
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.