Skip to content

Instantly share code, notes, and snippets.

View joncol's full-sized avatar

Jonas Collberg joncol

View GitHub Profile

Understanding the Phases Applicative

While I was researching how to do level-order traversals of a binary tree in Haskell, I came across a library called tree-traversals which introduced a fancy Applicative instance called Phases. It took me a lot of effort to understand how it works. Although I still have some unresolved issues, I want to share my journey.

Note: I was planning to post this article on Reddit. But I gave up because it was too long so here might be a better place.

See the discussion.

Note: This article is written in a beginner-friendly way. Experts may find it tedious.

Setting up qemu VM using nix flakes

Did you know that it is rather easy to setup a VM to test your NixOs configuration?

Create simple flake:

# flake.nix
{
  inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
@bashbunni
bashbunni / .zshrc
Created January 4, 2023 16:28
CLI Pomodoro for Linux
# study stream aliases
# Requires https://github.com/caarlos0/timer to be installed. spd-say should ship with your distro
declare -A pomo_options
pomo_options["work"]="45"
pomo_options["break"]="10"
pomodoro () {
if [ -n "$1" -a -n "${pomo_options["$1"]}" ]; then
val=$1
@fufexan
fufexan / cpp-dev-env-flake.nix
Last active April 17, 2024 12:52
C/C++ dev environment in Nix, using Clang
{
description = "C/C++ environment";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, utils, ... }@inputs:
utils.lib.eachDefaultSystem (
@vivshaw
vivshaw / README.md
Last active May 2, 2022 20:55
🙈🙉🙊 Three Wise Monkeys 🙈🙉🙊
@rksm
rksm / init.el
Created February 7, 2021 20:16
shackle
(defun rk/open-compilation-buffer (&optional buffer-or-name shackle-alist shackle-plist)
"Helper for selecting window for opening *compilation* buffers."
;; find existing compilation window left of the current window or left-most window
(let ((win (or (loop for win = (if win (window-left win) (get-buffer-window))
when (or (not (window-left win))
(string-prefix-p "*compilation" (buffer-name (window-buffer win))))
return win)
(get-buffer-window))))
;; if the window is dedicated to a non-compilation buffer, use the current one instead
(when (window-dedicated-p win)
@hadilq
hadilq / NixOS-guide.md
Last active July 6, 2024 15:30
Encypted LUKS LVM Btrfs Root with Opt-in State on NixOS

I'm trying to follow this guide to install NixOS using Btrfs, LUKS and LVM. The main usage of this page for me will be remembering what I did! My laptop is ASUS ROG GL553VD.

Just downloaded Plasma Desktop, 64bit and create a bootable Flash Drive. Then boot up to NixOS Live CD. Using gparted to create two partitions, One 200MB vfat EFI partittion and the rest of SSD drive will be an encrypted partition.

DISK=/dev/nvme0n1
@stoand
stoand / kakrc
Created April 29, 2020 06:06
Use ripgrep instead of grep with kakoune
# Install: https://github.com/BurntSushi/ripgrep#installation
# Use ripgrep instead of grep
set-option global grepcmd 'rg -Hn --no-heading'
@thalesmg
thalesmg / dhall-lsp.el
Created January 24, 2020 22:58
Using Dhall LSP Server on Emacs
(add-to-list 'lsp-language-id-configuration '(dhall-mode . "dhall"))
(lsp-register-client
(make-lsp-client :new-connection (lsp-stdio-connection "dhall-lsp-server")
:major-modes '(dhall-mode)
:server-id 'dhall-lsp-server))
@mvolfik
mvolfik / AoCleaderboard.py
Created December 12, 2019 15:19
View timestamps when people solved specific task of Advent of Code
import json
from datetime import datetime as dt
import requests
import re
y = input("YEAR: ")
cookie = {'session': "YOUR SESSION COOKIE HERE (it's valid for 30 days)"}
homepage = requests.get('https://adventofcode.com/'+y+'/leaderboard/private', cookies=cookie)
for id in re.compile(r"(?<=\/"+y+r"\/leaderboard\/private\/view\/)(\d+)").findall(homepage.content.decode()):
print("\n"*5)
data = json.loads(requests.get('https://adventofcode.com/'+y+'/leaderboard/private/view/'+id+'.json', cookies=cookie).content)