Skip to content

Instantly share code, notes, and snippets.

View sleepyfox's full-sized avatar
:shipit:

@sleepyfox sleepyfox

:shipit:
  • TypeError
  • The Midlands
View GitHub Profile
@sleepyfox
sleepyfox / tictactoe.pl
Created September 2, 2013 20:20
A board analyser for our 7 Languages in 7 Weeks Prolog session
%% A board is a list of states, each of which can be 'O', '' or 'X'
%% e.g. board('', '', '', '', '', '', '', '', '').
board('X', 'O', '', 'X', '', '', 'X', 'O', '').
row_one_win(X) :- board(X, X, X, _, _, _, _, _, _).
row_two_win(X) :- board(_, _, _, X, X, X, _, _, _).
row_three_win(X) :- board(_, _, _, _, _, _, X, X, X).
row_win(X) :- row_one_win(X) ; row_two_win(X) ; row_three_win(X).
@sleepyfox
sleepyfox / array-of-objects-intersection.coffee
Created December 15, 2013 12:15
Finding the intersection of two arrays of similar objects in CoffeeScript
# General pattern for intersection of two arrays of objects:
# collection1.filter collection2.indexOf
#
# Exercise for the reader: much optimisation can be done
myAlbums = [
{ id: 1, title: "The White Album" },
{ id: 2, title: "The Black Album" },
{ id: 3, title: "Hemispheres" },
{ id: 4, title: "Pure Heroine" } ]
@sleepyfox
sleepyfox / quantification.md
Last active January 4, 2016 00:39
A blog post on Measurement, quantification and violence (as in NVC)

Measurement, quantification and violence

Fox on Software, by @sleepyfox on 21 Jan 2014

Ah, now we see the violence inherent in the system
"Ah, now we see the violence inherent in the system!"

I hope that this provides the reader with some food for thought, and encourages your curiosity enough to ask some of the more challenging questions around metrics, measurement and quantification, both at work and in your broader life.

NVC, or Non-Violent Communication, is a way of communicating invented by Marshall Rosenburg as a way of facilitating and mediating between parties in conflict resolution scenarios between civil rights activists and the administration in 1960s America.

@sleepyfox
sleepyfox / test-HUnit.hs
Created February 19, 2014 16:06
Simple boilerplate for Haskell HUnit
module Main where
import Test.HUnit
test1 = TestCase (assertEqual "This test fails" 1 3)
test2 = TestCase (assertEqual "This test succeeds" 1 1)
tests = TestList [ TestLabel "test-1" test1,
TestLabel "test-2" test2 ]
@sleepyfox
sleepyfox / magna_carta.txt
Created March 17, 2014 18:19
Magna Carta - British Library translation
JOHN, by the grace of God King of England, Lord of Ireland, Duke of Normandy and Aquitaine, and Count of Anjou, to his archbishops, bishops, abbots, earls, barons, justices, foresters, sheriffs, stewards, servants, and to all his officials and loyal subjects, Greeting.
KNOW THAT BEFORE GOD, for the health of our soul and those of our ancestors and heirs, to the honour of God, the exaltation of the holy Church, and the better ordering of our kingdom, at the advice of our reverend fathers Stephen, archbishop of Canterbury, primate of all England, and cardinal of the holy Roman Church, Henry archbishop of Dublin, William bishop of London, Peter bishop of Winchester, Jocelin bishop of Bath and Glastonbury, Hugh bishop of Lincoln, Walter Bishop of Worcester, William bishop of Coventry, Benedict bishop of Rochester, Master Pandulf subdeacon and member of the papal household, Brother Aymeric master of the knighthood of the Temple in England, William Marshal earl of Pembroke, William earl of Salisbury, William ea
module StarterSpec where
-- Details of Hspec at http://hspec.github.io
import Test.Hspec
main :: IO ()
main = hspec $ do
describe "An empty list" $ do
it "should have length zero" $
@sleepyfox
sleepyfox / Build.sbt
Last active August 29, 2015 14:01
Test stub for ScalaTest for London Code Dojo 7L7W Scala day 1
name := "Name goes here"
version := "0.0.1"
libraryDependencies += "org.scalatest" % "scalatest_2.10" % "2.0" % "test"
@sleepyfox
sleepyfox / tdd_starter.erl
Created May 10, 2015 18:35
TDD in Erlang with EUnit
-module(tdd_starter).
-export([sum/2, product/2]).
-include_lib("eunit/include/eunit.hrl").
sum(A, B) -> A + B.
product(A, B) -> A * B.
sum_test() ->
?assertEqual(0, sum(0, 0)),
@sleepyfox
sleepyfox / roman.py
Last active August 29, 2015 14:21
Python TDD starter
"A test suite for a Roman numeral converter"
import unittest
class RomanNumeral():
def toNumeral(self, v):
return True
class RomanNumerals(unittest.TestCase):
1 3600
1 5400
1 1800
1 3600
1 34200
1 10800
1 12600
1 17100
1 15300
1 72000