Skip to content

Instantly share code, notes, and snippets.



View GitHub Profile
Profpatsch / hlint-to-github-warnings.jq
Created Jun 21, 2022
Convert hlint warnings to github Action “smart” log messages
View hlint-to-github-warnings.jq
# the github message format requires newlines to be escaped with the URL-style %0A
# see
def escapeNewline: gsub("[\\n]"; "%0A");
# depending on the hlint message, we want to display the
# headings and the bodies differently
def prepareTitle:
if .hint == "Unused LANGUAGE pragma"
then { heading: "Unused LANGUAGE pragma: \(.from)"
, suggestion: ""
Profpatsch /
Created Feb 10, 2022
Add a package from nixpkgs to your current fish shell
function with --description 'import all arguments as nixpkgs args and put their /bin on PATH'
set arg ( \
printf '
let pkgs = import <nixpkgs> {};
in pkgs.symlinkJoin {
name = "extra-fish-path";
paths = with pkgs; [ %s ];
' \
"$argv" \
Profpatsch / Incidence.hs
Created Nov 14, 2021
How many people do you have to meet to have a 50% chance somebody has Covid at an incidence of 500 (in 100k people)
View Incidence.hs
module Main where
import System.Random
import Data.Ratio
import Data.Bifunctor
-- | Returns for a bunch of people you meet , with a chance of 1/200 for each person, whether any has Covid
randomPeople200 :: (RandomGen gen) => Int -> gen -> (Bool, gen)
randomPeople200 numberOfPeople =
first anyHasCovid . runGeneratorNTimes numberOfPeople 0 (uniformR (1, 200::Int))
Profpatsch /
Last active Oct 27, 2021
Encoding sum types with json-schema

The goal is to express an ADT like the following in json schema:

data Sum 
  = Foo { hi :: Int }
  | Bar { x :: Bool }

or in rust syntax:

Profpatsch / BitString.hs
Last active Jul 27, 2021
dumb BitString wrapper around ByteString that allows to slice it on bits
View BitString.hs
{-# LANGUAGE TypeApplications, ExplicitForAll, ScopedTypeVariables, BinaryLiterals, NumericUnderscores, TupleSections, ExistentialQuantification, KindSignatures, DataKinds, MultiWayIf, TypeFamilies, ConstraintKinds, TypeOperators, DerivingStrategies, GeneralizedNewtypeDeriving, InstanceSigs, MultiParamTypeClasses, FlexibleInstances #-}
module Main where
import qualified Data.Bits as Bits
import Data.Word
import qualified Data.List as List
import qualified Data.Text as Text
import qualified Data.ByteString as Bytes
import Data.ByteString (ByteString)
Profpatsch / .hlint.yaml
Created Jun 24, 2021
hlint, the helpful parts
View .hlint.yaml
# HLint configuration file
# Run `hlint --default` to see the example configuration file.
# Ignore some builtin hints
# often functions are more readable with explicit arguments
- ignore: {name: Eta reduce}
Profpatsch / filterExact.nix
Created Jun 7, 2021
filter a nix source directory by a list of exact paths
View filterExact.nix
# copies the the given `srcPath` to the nix store,
# but only the files and directories explicitely
# listed in `includePaths`.
# Example:
# filterExact ./. [
# "foo.txt"
# "src"
# "tests/test_"
Profpatsch / Convert Script –
Created Apr 22, 2021 — forked from Zehkul/Convert Script –
Script to quickly convert and crop videos from within mpv
View Convert Script –


This script for mpv intends to offer the fastest and simplest way to convert parts of a video—while you’re watching it and not really more work intensive than making a screenshot. A short demonstration:


You need:

  • yad (at least 0.26) (AUR)
Profpatsch / sets.nix
Last active Dec 29, 2020
Nix set library
View sets.nix
# A set library, using attrsets with hashed keys as internal representation.
{ lib }:
/* The empty set.
Type: sets.empty :: <set a>
View service.nix
{ pkgs }:
{ service-dir }:
let sd = pkgs.lib.escapeShellArg service-dir;
in pkgs.writers.writeDash "service" ''
set -e
CMD=''${1:?please specify command as first argument}