Skip to content

Instantly share code, notes, and snippets.

@juxtin
juxtin / Main.hs
Last active August 29, 2017 01:14
Hiding STM behind a generic IO storage interface
module Main where
import Control.Concurrent.STM
import Data.Map as M
type MapDB = M.Map Integer String
main :: IO ()
main = do
stg <- initStorage
@juxtin
juxtin / puppetserver-get.sh
Created August 18, 2017 23:11
Perform a curl GET request to the given puppet server endpoint in PE
#!/bin/bash
# example:
# ./puppetserver-get /puppet/v3/environments
FQDN=$(facter fqdn)
CERTS="/etc/puppetlabs/puppet/ssl/certs"
KEYS="/etc/puppetlabs/puppet/ssl/private_keys"
curl "https://${FQDN}:8140$1" \
b64map : [64][8]
b64map = ['A' .. 'Z'] # ['a' .. 'z'] # ['0' .. '9'] # ['/', '+']
toB64Char : [6] -> [8]
toB64Char x = b64map @ x
base64 xs = [ toB64Char x | x <- hexBytes ]
where hexBytes = groupBy`{6} xs
passes = actual == expected
@juxtin
juxtin / 50-mtrack.conf
Created March 23, 2016 06:44
Working mtrack config
Section "InputClass"
MatchIsTouchpad "on"
Identifier "Touchpads"
Driver "mtrack"
Option "Sensitivity" "0.35"
Option "IgnoreThumb" "true"
Option "IgnorePalm" "true"
Option "TapButton1" "1"
Option "TapButton2" "3"
(defun abclj--other-ns (ns)
"If `ns' ends in `-test', strip that off. Otherwise, add `-test'."
(if (string-match-p "-test$" ns)
(string-remove-suffix "-test" ns)
(concat ns "-test")))
(defun abclj-jump-to-test-ns-or-back (&optional arg)
"If the point is in `project.namespace', jump to `project.namespace-test'. If
the point is in `project.namespace-test', jump to `project.namespace'."
(interactive "P")
(defproject typed-rbac "0.1.0-SNAPSHOT"
:description "FIXME: write description"
:url "http://example.com/FIXME"
:license {:name "Eclipse Public License"
:url "http://www.eclipse.org/legal/epl-v10.html"}
:core.typed {:check [typed-rbac.types]}
:dependencies [[org.clojure/clojure "1.8.0"]
[org.clojure/core.typed "0.3.22"]])
(ns typed-test.types
{:lang :core.typed}
(:require [clojure.core.typed :as t]))
(def BaseUser
(t/HMap
:mandatory
{:id java.util.UUID
:login t/Str}
:complete? true))
// This file is part of www.nand2tetris.org
// and the book "The Elements of Computing Systems"
// by Nisan and Schocken, MIT Press.
// File name: projects/04/Fill.asm
// Runs an infinite loop that listens to the keyboard input.
// When a key is pressed (any key), the program blackens the screen,
// i.e. writes "black" in every pixel. When no key is pressed, the
// program clears the screen, i.e. writes "white" in every pixel.
@juxtin
juxtin / helm-clojure-headlines.el
Created July 9, 2015 17:41
helm-clojure-headlines
(defun helm-clojure-headlines ()
"Display headlines for the current Clojure file."
(interactive)
(setq helm-current-buffer (current-buffer)) ;; Fixes bug where the current buffer sometimes isn't used
(jit-lock-fontify-now) ;; https://groups.google.com/forum/#!topic/emacs-helm/YwqsyRRHjY4
(helm :sources (helm-build-in-buffer-source "Clojure Headlines"
:data (with-helm-current-buffer
(goto-char (point-min))
(cl-loop while (re-search-forward "^(\\|testing\\|^;.*[a-zA-Z]+" nil t)
for line = (buffer-substring (point-at-bol) (point-at-eol))
module LearnYouAn where
data ℕ : Set where
zero : ℕ
suc : ℕ → ℕ
_+_ : ℕ → ℕ → ℕ
zero + zero = zero
zero + n = n
(suc n) + n′ = suc (n + n′)