Skip to content

Instantly share code, notes, and snippets.

property tests

how to choose properties

different paths, same destination

  • commutativity
  • associativity
  • map
  • monad & functor laws

there and back again

  • serialization/deserialization
@minimal
minimal / post.md
Last active May 26, 2023 08:52
Event monitoring post

At Skimlinks up until about 20 months ago our service monitoring consisted mostly of Icinga/Nagios checks that only ran about every 5 minutes. The Icinga dashboard was displayed on our monitor wall. While readying the release of a new version of SkimWords we thought we needed some monitoring closer to real-time. Since the API was CPU bound and latency sensitive we needed more insight into the state of the system, especially during new releases and traffic spikes.

As Clojure fans, we had recently come across

@minimal
minimal / link_to_repo.clj
Created April 12, 2022 09:49
babashka script to symlink shell.nix, .envrc etc
/* JSON-Websocket-AMQP bridge */
var amqp_ws = function() {
ws = null;
function recieve_amqp(args) {
console.log(args.msg);
};
@minimal
minimal / githubstatus.py
Created September 28, 2012 11:18
set github commit status from command line
import logging
import json
import argparse
import requests
github_base = "https://api.github.com"
github_status_url = github_base + "/repos/{repo_name}/statuses/{sha}?access_token={token}"
token = ''
@minimal
minimal / core_test.clj
Last active November 27, 2018 15:10
testing monoids with test.check
(defn passes-monoid-props
[f id a b c]
(and (= (f (f a b) c) (f a (f b c))) ;; associativity
(= (f a id) a) ;; identity element
(= (f id a) a)))
(defspec plus-zero-are-monoid 100
(prop/for-all [[a b c] (gen/vector gen/int 3)]
(passes-monoid-props + 0 a b c)))
(require 'package)
(add-to-list 'package-archives '("marmalade" . "http://marmalade-repo.org/packages/"))
(add-to-list 'package-archives '("melpa" . "http://melpa.milkbox.net/packages/"))
(package-initialize)
;; minimally, install use-package
(unless (package-installed-p 'use-package)
(package-refresh-contents)
(package-install 'use-package))
#!/usr/bin/env bash
# check formatting of clj files changed from master
lein cljfmt check $(git diff --name-only origin/master |
grep "\\.clj[sc]\\?$" |
paste -s -d" ")
@minimal
minimal / data.clj
Created September 21, 2016 13:37
ISO now date string in java 8 with clojure
(import
'[java.time ZonedDateTime]
'[java.time.format DateTimeFormatter])
(.. (ZonedDateTime/now) (format DateTimeFormatter/ISO_INSTANT))
@minimal
minimal / jetty.clj
Created January 20, 2010 01:17
Websockets with clojure + jetty
;; Copyright (c) James Reeves. All rights reserved.
;; The use and distribution terms for this software are covered by the Eclipse
;; Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) which
;; can be found in the file epl-v10.html at the root of this distribution. By
;; using this software in any fashion, you are agreeing to be bound by the
;; terms of this license. You must not remove this notice, or any other, from
;; this software.
(ns compojure.server.jetty
"Clojure interface to start an embedded Jetty server."