Skip to content

Instantly share code, notes, and snippets.

View joncol's full-sized avatar

Jonas Collberg joncol

View GitHub Profile
@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;
@joncol
joncol / gist:043b75f8fe5866c9c6c84ce8ad481aa6
Last active November 9, 2021 08:28
Basic NixOS configuration
{ config, pkgs, ... }:
{
imports =
[
./hardware-configuration.nix
];
boot.kernelPackages = pkgs.linuxPackages_latest;
@joncol
joncol / suggestion.clj
Last active June 25, 2020 09:53
pr-suggestion
(defn get-callback-success [request id]
(jdbc/with-db-transaction [db (-> request :opts :db)]
(let [config (-> request :opts :config)
boundaries (-> request :opts :boundaries)
merchant (:merchant boundaries)
mantis (:mantis boundaries)
deposit (db/get-deposit db {:id id})
identification (delay (db/get-identification db {:id id}))
withdrawal (delay (update-withdrawal! (:opts request) id))]
(cond
@joncol
joncol / main.clj
Created January 10, 2020 08:31
No-exit
(ns nordea-deposits-scraping.main
(:gen-class)
(:require [clojure.spec.alpha :as s]
[clojure.tools.cli :refer [parse-opts]]
[clojure.tools.logging :as log]
[clojure.tools.logging.impl :as log-impl]
;; [duct.core :as duct]
nordea-deposits-scraping.app
[nordea-deposits-scraping.config :refer [read-config]]
nordea-deposits-scraping.postgres
@joncol
joncol / core.clj
Created December 16, 2019 16:09
hello-selenium
;; Project dependencies:
;; [org.seleniumhq.selenium/selenium-chrome-driver "3.141.59"]
;; [org.seleniumhq.selenium/selenium-java "3.141.59"]
(ns hello-selenium.core
(:gen-class)
(:import [org.openqa.selenium By WebDriver WebElement]
[org.openqa.selenium.chrome ChromeDriver]))
(defn -main []
@joncol
joncol / place-cider-test-report-window.el
Last active December 3, 2019 17:36
place-cider-test-report
(defun create-test-report-window (&rest _)
"Create window to show test report buffer, if one exists.
Place it to the right of the current window. If a window for the test report
buffer already exists, don't create a new one."
(when-let* ((buf (get-buffer cider-test-report-buffer)))
(unless (get-buffer-window buf)
(let ((buffer-window (split-window (selected-window)
(/ (window-width) 2)
'right)))
(set-window-buffer buffer-window buf)
@joncol
joncol / math.ipynb
Last active October 29, 2019 08:36
Norwegian graphs
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.