Skip to content

Instantly share code, notes, and snippets.

View joncol's full-sized avatar

Jonas Collberg joncol

View GitHub Profile
@joncol
joncol / ModKeys.hs
Created November 3, 2022 10:37
ModKeys
module ModKeys where
import Data.Aeson
import Data.Text (Text)
import GHC.Generics (Generic)
import qualified Data.Aeson as Aeson
import qualified Data.ByteString.Lazy as LBS
import qualified Data.Text.Encoding as E
import qualified Data.Text.IO as TIO
@joncol
joncol / arbitrary_trees.hs
Last active January 24, 2022 07:59
Arbitrary trees
import Data.Sequence (Seq((:|>)))
import Data.Tree (Tree(..))
import qualified Data.Sequence as Seq
foobar_test :: TestEnv ()
foobar_test = do
tree :: Tree () <- liftIO . generate $ treeGen 50 `suchThat` ((>= 5) . length . flatten)
ugids <- createUserGroupTree tree
building the system configuration...
warning: Git tree '/home/jco/nixos-flake' is dirty
error: The ‘gnome.vte’ alias was removed on 2022-01-13. Please use ‘pkgs.vte’ directly.
… while evaluating the attribute 'vte'
at /nix/store/yjs0c0h8nwqjjsy4zdg0nmj611rpjypa-source/pkgs/desktops/gnome/default.nix:362:3:
361| libgnomekbd = throw "The ‘gnome.libgnomekbd’ alias was removed on 2022-01-13. Please use ‘pkgs.libgnomekbd’ directly."; # added 2019-02-08
362| vte = throw "The ‘gnome.vte’ alias was removed on 2022-01-13. Please use ‘pkgs.vte’ directly."; # added 2019-02-08
from collections import deque
import fileinput
import itertools
nums = list(itertools.repeat(list(range(9, 0, -1)), 14))
def main():
i = 0
for n in itertools.product(*nums):
num = ''.join(map(str, n))
@joncol
joncol / day24.py
Created January 5, 2022 19:10
day24.py
from collections import deque
import fileinput
def main():
x = y = z = w = 0
for line in fileinput.input():
inp = deque(line)
w = int(inp.popleft())
x *= 0
@joncol
joncol / input24.txt
Created January 3, 2022 22:52
AoC-2021, day 24
inp w
mul x 0
add x z
mod x 26
div z 1
add x 12
eql x w
eql x 0
mul y 0
add y 25
@joncol
joncol / anonymous-gist.hs
Last active December 29, 2021 11:53
GADTs example
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE RankNTypes #-}
module GADTs where
data Subject = Math | English | French
deriving (Eq, Show)
@joncol
joncol / Day12.hs
Last active December 12, 2021 10:52
AoC 2021, day 12
module Day12 where
import Control.Applicative (Alternative((<|>)))
import Data.List ((\\))
import Data.Maybe (isJust)
import Data.Text (Text)
import GHC.Generics (Generic)
import Optics
import Text.Megaparsec (some)
import Text.Megaparsec.Char (char, eol, lowerChar, upperChar)
@joncol
joncol / Lib.hs
Created November 30, 2021 07:10
MonadReader example
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE NamedFieldPuns #-}
module Lib
( foo
, someFunc
) where
import Data.Text (Text)
import Control.Monad.Reader (runReader)
@joncol
joncol / configuration.nix
Last active November 14, 2021 09:58
Basic configuration for bootstrapping NixOS and Home Manager. Requires `sudo nix-channel --add https://nixos.org/channels/nixos-unstable && sudo nix-channel --update` (to get `nix 2.4` with Flake support).
{ config, pkgs, ... }:
{
nix.package = pkgs.nixUnstable;
nix.extraOptions = ''
experimental-features = nix-command flakes
'';
boot.loader.grub.enable = true;
boot.loader.grub.version = 2;