Skip to content

Instantly share code, notes, and snippets.

(ns spec.extras.valid
(:require [clojure.spec.alpha :as s]))
(defn valid!
"`#'s/valid?` but throws an `ex-info` with `#'s/explain-data` of the
failure when `val` doesn't conform to `spec`.
Intended for always-on postconditions because `#'s/assert` is off by
default."
[spec val]
(if (s/valid? spec val)
@arrdem
arrdem / PKGBUILD
Created October 29, 2018 09:23
clojure-tools for Arch Linux
# Maintainer: Reid 'arrdem' McKenzie <me@arrdem.com>
pkgname=clojure-tools
pkgver=1.9.0.397
pkgrel=2
pkgdesc="clojure-tools (clj, clojure)"
arch=('i686' 'x86_64')
url="https://clojure.org/guides/getting_started"
license=('EPL')
depends=('java-runtime-headless>=8')
source=("$pkgname-$pkgver.tar.gz")
(ns doc-test
(:require [clojure.test :as t]
[clojure.java.shell :refer [sh]]
[clojure.string :as str]
[clojure.java.io :as io])
(:import [java.io StringReader]))
(def aspell-pattern
#"& (?<word>\w+) (?<offset>\d+) (?<count>\d+): (?<alternatives>.*?)$")
struct MyVec<T>(T);
impl fmt::Display for MyVec<&Vec<i32>> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "[");
for (i, el) in *(self.0).iter().enumerate() {
if i != 0 {
write!(f, ", ");
}
@arrdem
arrdem / install.sh
Last active April 5, 2017 07:48
A bootleg puppet
# -*- mode: bash; indent-tabs-mode: nil; sh-basic-offset: 2; fill-column: 100; -*-
# About
# ==============================
# A bootleg dotfiles installer.
#
# Usage
# ==============================
#
# $FORCE - if non-empty then install.sh will happily clobber existing files/dirs
@arrdem
arrdem / 20-markdown.el
Created January 20, 2017 02:40
My markdown support
;; 20-markdown.el
(require 'markdown-mode)
;; One space per line implementation
(defun arrdem:markdown-nobreak-p ()
"Return nil if it is acceptable to break the current line at the point.
Supports Markdown links, liquid tags."
;; inside in square brackets (e.g., link anchor text)
@arrdem
arrdem / rendering.clj
Last active January 1, 2017 00:59
Textual programs as views of ASTs.
;; I write
(ns foo)
(defn adds-one [x]
(+ x 1))
(def another-adds-one
(partial + 1))
;; SYMBOL TABLE (name -> UUID)
@arrdem
arrdem / -
Created December 20, 2016 01:44
#!/bin/bash
function install_package() {
if [ -e "$1/build.sh" ]; then
( cd "$1";
bash "build.sh")
fi
stow --ignore="build.sh" --ignore="README.md" -t ~ "$f"
}
War Room Army
Cygnar - Sloan and six hunters
Theme: No Theme Selected
73 / 75 Army
Captain Kara Sloan - WJ: +28
- Reinholdt, Gobber Speculator - PC: 4
[1] Handed out (0, 0, 0) * STEP
[2] Handed out (0, 0, 1) * STEP
[3] Handed out (0, 1, 0) * STEP
[4] Handed out (0, 1, 1) * STEP
[5] Handed out (0, 1, 2) * STEP
[6] Handed out (1, 0, 0) * STEP
[7] Handed out (1, 0, 1) * STEP
[8] Handed out (1, 1, 0) * STEP
[7] [ANSWER] Got one! (1008, 960, 1100)
[8] [ANSWER] Got one! (1008, 1100, 960)