Skip to content

Instantly share code, notes, and snippets.

View kisom's full-sized avatar

Kyle Isom kisom

View GitHub Profile
> import Control.Applicative
This post is a [literate
Haskell](https://gist.github.com/kisom/09e471e145bf1eca9124) file,
converted to org-mode with [Pandoc](http://pandoc.org).
Time to explore the `Applicative` type.
First, `fmap`:
;; -*-lisp-*-
;; Load swank.
;; *prefix-key* ; swank will kick this off
(ql:quickload :swank)
(ql:quickload :manifest)
(defvar *manifest-url*
(manifest:start))
ATTRS{idVendor}=="5332", ATTRS{idProduct}=="1300", ACTION=="add", SUBSYSTEM=="usb", ATTR{power/control}="on"
#!/bin/sh
# convert Nikon NEF RAW images to FITS.
#
# depends on dcraw and imagemagick:
# apt-get install dcraw imagemagick
IMAGE_LIST="$1"
if [ -z "$IMAGE_LIST" ]
then
@kisom
kisom / count-macroexpansions.lisp
Created April 7, 2015 22:28
Fun little function to count the number of times a macro gets expanded.
(defun count-macroexpansions (form)
(labels ((count-expansions (form n)
(multiple-value-bind
(expansion expanded)
(macroexpand-1 form)
(if expanded
(count-expansions expansion (+ n 1))
n))))
(count-expansions form 0)))
@kisom
kisom / Purity.lhs
Last active May 31, 2016 13:00
"Why Purity Matters" blog post.
Purity is a useful construct that forces programmers to consider that the
environment that they are operating in is unclean, and this introduces
barriers to formally defining the behaviour of the system comprising
the program and its environment.
This file is a [literate Haskell
file](https://gist.github.com/kisom/3863f17636d99b4f8401) run through
[pandoc](http://johnmacfarlane.net/pandoc/) to produce a Markdown
post. There might be a few glitches as I'm still developing a workflow
in this style.
@kisom
kisom / Monads.lhs
Last active August 29, 2015 14:09
Source file for the monad post.
(This post is a Literate Haskell file that was run through pandoc to
produce markdown).
It seems customary in the Haskell space to write an introduction to
monads; my attempt in this exposition is not to outdo anyone else, but
to make the topic clear enough that I can write about it. My hope is
that by doing so, it becomes more clear to me.
> module Perhaps where
@kisom
kisom / dump-container
Created November 14, 2014 17:34
Export a container to a GPG-encrypted tarball.
#!/bin/sh
CONTAINER="$1"
BASENAME="$2"
OWNER="kyle@tyrfingr.is"
if [ -z "$BASENAME" ]
then
echo "No basename provided."
exit
@kisom
kisom / gtcov
Created October 19, 2014 01:24
gtcov
#!/bin/sh
# Produce an HTML file displaying code coverage. Dependencies:
# - cloc (apt-get install cloc)
# - cover (go get code.google.com/p/go.tools/cmd/cover)
if [ -z "$1" ]; then
PKG=""
else
PKG=$1
fi
// This program is a simple web server that listens for IP address
// updates. There's no authentication or security at all; I use it
// to keep track of beaglebones on a LAN.
package main
import (
"fmt"
"log"
"net/http"
"os"