Skip to content

Instantly share code, notes, and snippets.

View joncol's full-sized avatar

Jonas Collberg joncol

View GitHub Profile
@masaeedu
masaeedu / init-haskell.sh
Last active May 20, 2021 15:24
Basic nix haskell setup
#!/usr/bin/env bash
set -Eeuxo pipefail
# Set up git
git init
gitignore haskell
echo '*.cabal' >> .gitignore
# Set up niv
niv init
@hoblin
hoblin / react_upgrading.md
Last active March 9, 2022 07:43
Roadmap to upgrade react from 0.13 to 16

This document is a short how-to. It doesn't contain a lot of details about each change you need to implement, but it contains lots of links to the corresponding documents. Please read these docs for refetence.

Upgrade process in general.

1. Setup eslint

ESLint is the main tool to find deprecations in the code so first of all we need to configure it properly.

Prerequisites

Using PostgreSQL Advisory Locks in Haskell

Recently two different administrative users of a Haskell app I maintain started a long-running background job at the same time. This resulted in some Bad Things happening which I would like to prevent in the future!

So I want a lock. This app runs on at least two servers at any given time, so it needs to be a distributed lock, and for Reasons (not relevant to this blogpost) I can't use our Redis cache. So the PostgreSQL database it is!

@vdorr
vdorr / stmtimeout.hs
Last active April 2, 2025 11:49
Timeout in Haskell STM monad
-- important: compile with -threaded
import Control.Concurrent.STM
import Control.Applicative
-- |Wait for STM action specified amount of time and return value of action or default value if action times out
stmTimeout' :: Int -> a -> STM a -> IO a
stmTimeout' microseconds defVal f
= registerDelay microseconds
@mostafa-asg
mostafa-asg / kafka-console-consumer tip1
Last active June 12, 2024 16:31
Print key of records in kafka-console-consumer
use --property print.key=true
Example : ./kafka-console-consumer.sh --bootstrap-server <BROKERS_ADDRESS> --topic <YOUR_TOPIC> --property print.key=true
@robertpainsi
robertpainsi / commit-message-guidelines.md
Last active April 25, 2025 12:51
Commit message guidelines

Commit Message Guidelines

Short (72 chars or less) summary

More detailed explanatory text. Wrap it to 72 characters. The blank
line separating the summary from the body is critical (unless you omit
the body entirely).

Write your commit message in the imperative: "Fix bug" and not "Fixed
bug" or "Fixes bug." This convention matches up with commit messages
@kirked
kirked / class-utils.cljs
Last active July 2, 2023 21:31
HTML element class manipulations in Clojurescript (no jQuery)
(defn classes-of
"Get the classes of an element as a Clojure keyword vector."
[e]
(let [words (-> e (.getAttribute "class") (string/split " "))]
(mapv keyword words)))
(defn classes->str
"Change a Clojure keyword seq into an HTML class string."
[classes]
(->> classes (mapv name) (string/join " ")))
@martijnvermaat
martijnvermaat / nixos.md
Last active April 27, 2025 13:05
Installation of NixOS with encrypted root
@mikeball
mikeball / core.clj
Last active June 3, 2020 13:22
Postgres listen/notify in Clojure using http://impossibl.github.io/pgjdbc-ng/
; Postgres listen/notify in Clojure using http://impossibl.github.io/pgjdbc-ng/
; in project.clj dependencies
; [com.impossibl.pgjdbc-ng/pgjdbc-ng "0.5"]
(ns pglisten.core
(:import [com.impossibl.postgres.jdbc PGDataSource]
[com.impossibl.postgres.api.jdbc PGNotificationListener]))