Skip to content

Instantly share code, notes, and snippets.

@derrickturk
Last active October 24, 2024 15:16
Show Gist options
  • Save derrickturk/2d44286cca6f0f1098a95539d8bd2bf9 to your computer and use it in GitHub Desktop.
Save derrickturk/2d44286cca6f0f1098a95539d8bd2bf9 to your computer and use it in GitHub Desktop.
A dinky "productivity app"
let Block = { level: Natural, list: List Text }
let blacklist: List Block =
[ { level = 0
, list =
[ "reddit.com"
, "old.reddit.com"
, "www.reddit.com"
, "twitter.com"
, "x.com"
, "nitter.poast.org"
, "xcancel.com"
]
}
, { level = 1
, list =
[ "linkedin.com"
, "news.ycombinator.com"
, "lobste.rs"
]
}
, { level = 2
, list =
[ "news.google.com"
, "theatlantic.com"
]
}
]
let List/concat = https://raw.githubusercontent.com/dhall-lang/dhall-lang/v23.0.0/Prelude/List/concat.dhall
let List/filterMap = https://raw.githubusercontent.com/dhall-lang/dhall-lang/v23.0.0/Prelude/List/filterMap.dhall
let Natural/lessThanEqual = https://raw.githubusercontent.com/dhall-lang/dhall-lang/v23.0.0/Prelude/Natural/lessThanEqual.dhall
let Text/concatMap = https://raw.githubusercontent.com/dhall-lang/dhall-lang/v23.0.0/Prelude/Text/concatMap.dhall
in λ(level: Natural) →
let filtered = List/filterMap Block (List Text)
(λ(b: Block) →
if Natural/lessThanEqual b.level level
then Some b.list
else None (List Text))
blacklist
let catted = List/concat Text filtered
in Text/concatMap Text (λ(url: Text) → "0.0.0.0 ${url}\n") catted
#! /bin/env bash
sudo sh -c 'echo \# Static table lookup for hostnames. >/etc/hosts'
sudo sh -c 'echo \# See hosts\(5\) for details. >>/etc/hosts'
dhall text <<<"$(dirname "$0")/blacklist.dhall $1" | sudo tee -a /etc/hosts >/dev/null
#! /bin/env bash
sudo sh -c 'echo \# Static table lookup for hostnames. >/etc/hosts'
sudo sh -c 'echo \# See hosts\(5\) for details. >>/etc/hosts'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment