Skip to content

Instantly share code, notes, and snippets.

View msgodf's full-sized avatar

Mark Godfrey msgodf

View GitHub Profile
@msgodf
msgodf / algorithms-to-live-by.md
Last active June 19, 2023 03:40
Notes on Algorithms to Live By by Brian Christian and Tom Griffiths
@msgodf
msgodf / condition-systems.md
Created December 15, 2015 08:23
Condition Systems in an Exceptional Language by Chris Houser

Condition Systems in an Exceptional Language by Chris Houser

I recently watched Chris Houser's talk from Clojure/conj 2015 on condition systems in Clojure. I enjoyed the subject, so I decided to write up the talk as a way of encouraging me to really understand it, and in the hope that it might help others understand it.

The last time I heard about Common Lisp's condition system was at a talk by Didier Verna at ACCU in Bristol in 2013 (slides here). It sounded really interesting, but I didn't understand it well enough.

tl;dr

Chris Houser talks about different ways of handling errors in Clojure. Based on examples from Peter Seibel's book, Practical Common Lisp, he describes condition systems, which are also known as resumable exceptions, or restarts.

@msgodf
msgodf / aoc2022-day1-puzzle1.tf
Created December 3, 2022 14:43
Day 1, Puzzle 1 of AOC 2022
locals {
most_calories = reverse([for elf_calories in sort([for elf_calories in split(" ", replace(file("input1.txt"), "\n", " ")) : format("%08d", sum([for food_calories in split(" ", elf_calories) : food_calories == "" ? 0 : parseint(food_calories, 10)]))]) : tonumber(elf_calories)])[0]
}
output "answer" {
value = local.most_calories
}
@msgodf
msgodf / core_async_merge_behaviour.clj
Created March 5, 2014 17:07
Some code to test the behaviour of Clojure core.async's merge function. Given two channels that produce values at a given intervals, merge them and see whether the two sequences are interleaved or concatenated.
(require '[clojure.core.async :as async refer [<! go timeout])
(defn sleepy-val
[v t]
(go (<! (timeout t)) v))
;; Will this produce [1 2 3 1.5 2.5 3.5] or [1 1.5 2 2.5 3 3.5]?
(go
(prn (<! (async/into []
(async/merge [(.async/merge [(sleepy-val 1 1000)
@msgodf
msgodf / kiczales-oopsla94-black-boxes-reuse.md
Last active March 28, 2022 22:23
Gregor Kiczales "Why are black boxes so hard to reuse?"

This talk was given by Gregor Kiczales of Xerox PARC at OOPSLA ’94, 10/26/94. © 1994, University Video Communications. A transcript, with point- and-click retrieval of the slides, is available at http:/www.xerox.com/PARC/spl/eca/oi/gregor-invite/gregor- transcript.html

Why are black boxes so hard to reuse?

I think our field will go through a revolution. We will fundamentally change the way we think about and use abstraction in the engineering of software.

The goal of this talk is to summarize the need for and the basic nature of this abstraction framework.

The change is not new problems or new systems, but a new way of thinking about existing problems and existing systems.

@msgodf
msgodf / rickshaw-full-demo.cljs
Created January 18, 2014 20:26
Full Rickshaw Example in Clojurescript
;; Original example (in Javascript) at: http://code.shutterstock.com/rickshaw/examples/lines.html
(def graph-with-legend
(let [series-data (array (array) (array) (array))
random (Rickshaw.Fixtures.RandomData. 150)]
(dotimes [i 150]
(.addData random series-data))
(doto
(Rickshaw.Graph. (clj->js {:element (.getElementById js/document "chart")
:renderer "line"
:width 960
@msgodf
msgodf / core.cljs
Created March 1, 2014 20:26
A Clojurescript port of the first of the Web Audio API examples from HTML5 Rocks (http://www.html5rocks.com/en/tutorials/webaudio/intro/)
(ns cljsaudio.core
(:require [goog.net.XhrIo]
[cljs.core.async :as async :refer [<! >! chan close!]])
(:require-macros [cljs.core.async.macros :refer [go]]))
(defn decode-audio-data
[context data]
(let [ch (chan)]
(.decodeAudioData context
data
@msgodf
msgodf / sl2018.md
Last active September 28, 2018 19:36
Strange Loop 2018
@msgodf
msgodf / pwlconf2018.md
Last active September 27, 2018 14:08
PWLConf 2018 notes

Computer-aided Concurrent Programming - Roopsha Samanta

https://pwlconf.org/2018/roopsha-samanta/

Clarke and Emerson - Design and Synthesis of Sychnronization Skeletons using Branching-Time Temporal logic - Workshop on Logics of Programs (1981)

Processes are Finite-state synchronization skeletons - supress details about synchronization Communication model: Shared memory, interleaving based - one thread takes a step at a time Specification: Temporal logic Synchronization: Guarded commands

@msgodf
msgodf / Main.hs
Last active September 29, 2017 20:42
Example of Eta code that gives `java.lang.VerifyError: Bad type on operand stack` error.
{-# LANGUAGE FlexibleContexts #-}
module Main where
import Java
import Java.Do
main :: IO ()
main = putStrLn $
mconcat $
fmap (\x -> let _ = x :: JInteger in show x) $