Skip to content

Instantly share code, notes, and snippets.

View simon-brooke's full-sized avatar
💭
Semper in faecibus sumus, sole profundam variat.

Simon Brooke simon-brooke

💭
Semper in faecibus sumus, sole profundam variat.
View GitHub Profile
(ns game-of-life.core)
(def world [[2 1] [2 2] [1 1]])
(defn neighbours [[x y]]
[[(dec x) (dec y)] [x (dec y)] [(inc x) (dec y)]
[(dec x) y] [(inc x) y]
[(dec x) (inc y)] [x (inc y)] [(inc x) (inc y)]])
(neighbours [2 2])
@simon-brooke
simon-brooke / minesweeper-core.clj
Last active August 29, 2015 14:02
An attempt to solve the minesweeper kata in Clojure
(ns minesweeper.core)
;; # minesweeper
;; An attempt to solve the Minesweeker kata from http://codingdojo.org/ in Clojure.
;; ## Limitations
;; The parser cannot handle new lines, as I couldn't think of a regular expression
;; to divide the input string on which would produce the new line character as a
@simon-brooke
simon-brooke / ifdef.awk
Last active July 19, 2023 02:18
I needed a little tool to do ifdefs, for conditional inclusion of text; I didn't want the full panoply of the C preprocessor. I like this. Test-driven development in awk.
#!/usr/bin/awk -f
# Experimental implementation of ifdef in awk
BEGIN {
depth = 0;
defined = "";
printing = 1;
}
$1 ~ /#DEFINE/ {
@simon-brooke
simon-brooke / lt
Created August 16, 2016 14:20
Launcher for LightTable, which also launches Butterfly. Butterfly is a terminal in a browser window, which can be connected to inside LightTable by pointing a browser connection at http://localhost:57575
#!/bin/bash
# Experimental launcher for LightTable; starts Butterfly if it is not
# already running, in order to have a terminal which works inside
# LightTable
if [ "$#" != "0" ]
then
shift
fi
@simon-brooke
simon-brooke / core.clj
Created September 11, 2016 14:29
Getting Timbre v 4.x logging working
;; Taoensso.timbre has been a very good Clojure logging library, but v4.0 was a
;; breaking change and it took me a while to get my head round it, although in
;; fact it's very simple. If you're having trouble with it, try this, which is
;; very simple and works with Timbre 4.7.4
(ns ^{:doc "After upgrading Timbre from 3.x to 4.x, all my applications broke.
I wrote this little test piece to understand what was going wrong. It works."
:author "Simon Brooke"}
chainsaw.core
(:require
@simon-brooke
simon-brooke / keybase.md
Created October 12, 2016 10:24
Proof of identity

Keybase proof

I hereby claim:

  • I am simon-brooke on github.
  • I am simon_brooke (https://keybase.io/simon_brooke) on keybase.
  • I have a public key ASDqWd060Fp973txUuQTP2MwigXHGbjeXF2L3_szPdn6Vgo

To claim this, I am signing this object:

@simon-brooke
simon-brooke / clean-all-repositories.sh
Created December 20, 2016 10:22
Little script for cleaning up all my git repositories
#!/bin/bash
# Little script for cleaning up all my git repositories (i.e. ones I am responsible
# for) in my workspace dir and pushing them back to gihub or to my own server.
pushd ~/workspace
for dir in *
do
if [ -d ${dir} ]
then
@simon-brooke
simon-brooke / .gitconfig
Created June 3, 2017 13:24
Windows .gitconfig for Meld
[user]
email = [email protected]
name = Simon Brooke
[diff]
tool = meld
[difftool]
prompt = false
[difftool "meld"]
path = C:\\Program Files (x86)\\Meld\\meld.exe
@simon-brooke
simon-brooke / mountain_sort.clj
Created July 12, 2017 21:46
Mountain sort: sort the largest elements in a sequence to the middle
;; gorilla-repl.fileformat = 1
;; **
;;; # Mountain Sort
;;;
;;; A sorting function that sorts largest to the middle.
;;;
;;; ## A bit about Gorilla Repl
;;;
;;; This file was written in, and can be run and edited in,
@simon-brooke
simon-brooke / doxygen-snippet.msbuild
Created August 24, 2017 16:38
How to build documentation with Doxygen from an msbuild script
<PropertyGroup>
<DocDirectory>..\Documentation\</DocDirectory>
<Doxyfile>..\Doxyfile</Doxyfile>
</PropertyGroup>
<Target Name="Doxygen">
<MakeDir Directories="$(DocDirectory)" />
<Exec Command="doxygen.exe $(Doxyfile)" />
</Target>
<Target Name="DoxyClean">
<RemoveDir Directories="$(DocDirectory)\html" />