Skip to content

Instantly share code, notes, and snippets.

Magazine
create_issue -> Draft
Subscriber
Subscribed
cancel -> Lapsed
renew -> Subscribed
Lapsed
renew -> Subscribed
Subscriber?
subscribed -> LastIssue?

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!

@emhoracek
emhoracek / adventday1.hs
Last active December 14, 2018 21:22
Advent of Code day 1
{-
After feeling like you've been falling for a few minutes, you look at the device's tiny screen.
"Error: Device must be calibrated before first use. Frequency drift detected. Cannot maintain
destination lock." Below the message, the device shows a sequence of changes in frequency
(your puzzle input). A value like +6 means the current frequency increases by 6; a value like
-3 means the current frequency decreases by 3.
For example, if the device displays frequency changes of +1, -2, +3, +1, then starting from
a frequency of zero, the following changes would occur:

On NOT 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!

<h2>The Basics</h2>
<div class="basics">
<label>
<span>Character name: </span>
<input spellcheck="false" type="text" name="attr_character_name"/>
</label>
<label>
<span>Pronouns: </span>
<input spellcheck="false" type="text" name="attr_pronouns"/>
;;; Personal configuration -*- lexical-binding: t -*-
;; Save the contents of this file under ~/.emacs.d/init.el
;; Do not forget to use Emacs' built-in help system:
;; Use C-h C-h to get an overview of all help commands. All you
;; need to know about Emacs (what commands exist, what functions do,
;; what variables specify), the help system can provide.
;; Add the NonGNU ELPA package archive
(require 'package)