Skip to content

Instantly share code, notes, and snippets.

@juxtin
juxtin / Main.hs
Last active Aug 29, 2017
Hiding STM behind a generic IO storage interface
View Main.hs
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 Aug 18, 2017
Perform a curl GET request to the given puppet server endpoint in PE
View puppetserver-get.sh
#!/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" \
View one.cry
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 Mar 23, 2016
Working mtrack config
View 50-mtrack.conf
Section "InputClass"
MatchIsTouchpad "on"
Identifier "Touchpads"
Driver "mtrack"
Option "Sensitivity" "0.35"
Option "IgnoreThumb" "true"
Option "IgnorePalm" "true"
Option "TapButton1" "1"
Option "TapButton2" "3"
View packages.el
(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")
View project.clj
(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"]])
View types.clj
(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))
View Fill.asm
// 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.
View helm-clojure-headlines.el
(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))
View LearnYouAn.agda
module LearnYouAn where
data ℕ : Set where
zero :
suc :
_+_ :
zero + zero = zero
zero + n = n
(suc n) + n′ = suc (n + n′)