Skip to content

Instantly share code, notes, and snippets.

View danielwaterworth's full-sized avatar

Daniel Waterworth danielwaterworth

View GitHub Profile

Keybase proof

I hereby claim:

To claim this, I am signing this object:

@danielwaterworth
danielwaterworth / output.log
Created April 25, 2019 07:43
comparative performance of spec files before and after prefabrication of objects for discourse.
+ git diff-tree --no-commit-id --name-only -r prefabrication
+ git checkout master
+ bundle exec rspec spec/components/admin_confirmation_spec.rb
Randomized with seed 36167
...
Finished in 0.67291 seconds (files took 2.66 seconds to load)
3 examples, 0 failures

Heroku Python

Step 0 - requirements file

Make sure you have your dependencies in your requirements file. (The arrow is a bash thing, it may not work on windows. We want the output from pip freeze into requirements.txt).

pip freeze > ./requirements.txt

Step 1 - Django-Heroku

module main
data FormatString : List Char -> Type -> Type where
Empty : FormatString [] String
InsertNumber : FormatString s t -> FormatString ('%' :: 'd' :: s) (Int -> t)
InsertString : FormatString s t -> FormatString ('%' :: 's' :: s) (String -> t)
Other : (x /= '%' = True) -> FormatString s t -> FormatString (x :: s) t
printf' : List Char -> FormatString format ty -> ty
printf' s Empty = pack (reverse s)
@danielwaterworth
danielwaterworth / interpreter.py
Created December 7, 2012 18:48
idris bytecode interpreter
import sys, os
trace = False#True
debug = False#True
step = False#True
class Data(object):
pass
class Type(Data):
@danielwaterworth
danielwaterworth / article.md
Created August 9, 2012 07:48
How much of your codebase is only understood by one person?

How much of your codebase is only understood by one person?

Have you seen this question before? If you're a programmer then you're likely to have. It's a question that is strongly related the concept of a bus factor; the minimum number of people that understand any part of a system. This question annoys me though, because by asking it you are assuming that the system in question is so complicated and ill documented that at least parts of it can only be understood by the people that created it or those who that knowledge was shared with.

Why is this the norm? Why is it that we accept complexity? Edsger Dijkstra famously said "Simplicity is prerequisite for reliability" and I don't anyone who would disagree. When we accept complexity by not striving for simplicity, we accept unreliability and bugs.

@danielwaterworth
danielwaterworth / main.hs
Created February 26, 2012 10:21
Error conscious, pure iteratee library (based on pipes)
{-# LANGUAGE FlexibleInstances, DeriveDataTypeable #-}
import Data.Char
import Data.Typeable
import Control.Monad
import Control.Exception
import Control.Monad.Trans
import System.IO
@danielwaterworth
danielwaterworth / StateMachine.hs
Created December 21, 2011 18:30
State Machine Library
{-# LANGUAGE GADTs #-}
module StateMachine where
-- A library for managing complexity of state machines by making them composable, feel free to contribute/steal
data StateMachine state where
Simple :: (state -> state -> Bool) -> StateMachine state
OrMachine :: StateMachine a -> StateMachine b -> (a -> b -> Bool) -> (b -> a -> Bool) -> StateMachine (Either a b)
AndMachine :: StateMachine a -> StateMachine b -> StateMachine (a, b)
@danielwaterworth
danielwaterworth / STM.hs
Created December 10, 2011 12:03
Alternative STM implementation for Haskell
{-# LANGUAGE ExistentialQuantification #-}
{-
The idea is that each variable is an IORef that is either in a stable state
or is being transformed. If it is being transformed then the IORef contains a
MidChange value. The first argument of the constructor is the state before
the modification, the second argument is the state afterwards and the third
argument is an IORef that says whether the transaction has completed.
-}