Skip to content

Instantly share code, notes, and snippets.

@drewr
drewr / chat.md
Created January 17, 2018 20:30
Phil Freeman explaining the free monad

10:44] @loganmac Another way to think of the free monad over f is to say we want expressions of the form x >>= \a -> y >>= \b -> z ... where x, y, z :: f _

[10:45] So we just make a type by expanding f to include those terms, purely symbolically. But then to be a Monad we need the laws to hold, so we equate terms which the laws say have to be equal

[10:46] So finding the free monad over f is to find the "smallest" lawful monad which includes all such terms

@drewr
drewr / core.clj
Created January 14, 2018 05:46
Slack websocket experiment
(ns shia.core
(:require [cheshire.core :as json]
[clj-http.client :as http]
[clojure.spec.alpha :as s])
(:import (org.java_websocket.client WebSocketClient)
(java.net URI)))
(s/def :rtm/connect (s/keys :req-un [::ok ::self ::team ::url]))
(def ord (atom 0))
module PagerDuty (main) where
import Prelude
import Control.Monad.Aff (launchAff)
import Control.Monad.Eff (Eff)
import Control.Monad.Eff.Class (liftEff)
import Control.Monad.Eff.Console (CONSOLE, log, logShow)
import Data.Config (Config, string)
import Data.Config.Node (fromEnv)
import Data.Either (Either(..))
diff --git a/keyboard/atreus/config.h b/keyboard/atreus/config.h
index 5fba78e..bc3b092 100644
--- a/keyboard/atreus/config.h
+++ b/keyboard/atreus/config.h
@@ -24,7 +24,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define PRODUCT_ID 0xA1E5
#define DEVICE_VER 36
#define MANUFACTURER technomancy
-#define PRODUCT Atreus
+#define PRODUCT Atreus2
@drewr
drewr / go.sh
Last active November 5, 2017 22:01
Heartbeat on RaspberryPi
export ELASTIC_GO_LIB=$HOME/go/src/github.com/elastic
export GOPATH=$HOME/go
sudo apt-get update --fix-missing
sudo apt-get install -y git build-essential lsb-release
wget --no-clobber https://redirector.gvt1.com/edgedl/go/go1.9.2.linux-armv6l.tar.gz
tar zxpf go1.9.2.linux-armv6l.tar.gz
mkdir -p $ELASTIC_GO_LIB
@drewr
drewr / delete-closed.sh
Created July 4, 2017 18:14
Deleting all the closed indices in a cluster
ES=http://localhost:9200
curl -s ${ES}/_cat/indices\?h=status,index | \
awk '/^close/ { print $2 }' | \
while read i; do echo curl -s -XDELETE ${ES}/$i; done
@drewr
drewr / syscalls.c
Last active June 20, 2017 18:20
Utility to find syscall ordinals on ARMv8 64-bit
/*
* gcc -D__ARCH_WANT_SYSCALL_DEPRECATED syscalls.c
*
* Thank you rmuir!
*/
#include <linux/audit.h>
#include <asm/unistd.h>
#include <stdio.h>
@drewr
drewr / syslog.log
Created May 12, 2017 03:25
JVM panic on Type 2a
May 12 00:00:01 slave-armv8-001 CRON[89919]: (jenkins) CMD (find /var/lib/jenkins/core-dumps -maxdepth 1 -type f -mtime +3 -name 'core-*' -delete)
May 12 00:05:01 slave-armv8-001 rsyslogd-2007: action 'action 11' suspended, next retry is Fri May 12 00:06:31 2017 [v8.16.0 try http://www.rsyslog.com/e/2007 ]
May 12 00:05:01 slave-armv8-001 CRON[1909]: (root) CMD (command -v debian-sa1 > /dev/null && debian-sa1 1 1)
May 12 00:05:54 slave-armv8-001 kernel: [ 9936.746290] Bad mode in Error handler detected, code 0xbe000000 -- SError
May 12 00:05:54 slave-armv8-001 kernel: [ 9936.753091] CPU: 48 PID: 920 Comm: multipathd Not tainted 4.4.0-38-generic #57-Ubuntu
May 12 00:05:54 slave-armv8-001 kernel: [ 9936.760908] Hardware name: FOXCONN R2-1221R-A4/C2U4N_MB, BIOS G31FB12A 10/26/2016
May 12 00:05:54 slave-armv8-001 kernel: [ 9936.768379] task: ffff800fb3ab4e00 ti: ffff800faf978000 task.ti: ffff800faf978000
May 12 00:05:54 slave-armv8-001 kernel: [ 9936.775853] PC is at 0xffff84918c18
May 12 00:05:54 slave-armv8-001
@drewr
drewr / Main.purs
Created March 6, 2017 20:41 — forked from leighman/Main.purs
A Tale of 3 Nightclubs
module Main where
import Prelude
import Control.Monad.Eff (Eff)
import Control.Monad.Eff.Console (CONSOLE, logShow)
import Data.Either (Either(..))
import Data.Foldable (elem, notElem)
import Data.Int (toNumber)
import Data.Traversable (traverse)
import Data.Validation.Semigroup (invalid)
#!/usr/bin/env zsh
setopt ERR_EXIT
VERSION=25.1.91
TAG=emacs-${VERSION}
DIR=~/src/emacs/emacs
PREFIX=/usr/local/emacs/emacs-${VERSION}
cd $DIR