Skip to content

Instantly share code, notes, and snippets.

View purcell's full-sized avatar

Steve Purcell purcell

View GitHub Profile
@purcell
purcell / MontyHall.hs
Last active December 19, 2015 12:49
Monty Hall problem simulated in Haskell: see http://en.wikipedia.org/wiki/Monty_Hall_problem
module MontyHall
where
import System.Random
import Control.Monad
import qualified Data.Set as Set
data Result = Win | Lose deriving (Eq, Show)
data Door = Door Int deriving (Eq, Show, Ord)
type Doors = Set.Set Door
@purcell
purcell / *Diff*
Created August 21, 2013 16:55
Patch for thrift.el
diff -c /tmp/b/thrift.el /tmp/a/thrift.el
*** /tmp/b/thrift.el 2013-08-21 17:54:54.000000000 +0100
--- /tmp/a/thrift.el 2013-08-21 17:50:04.000000000 +0100
***************
*** 1,7 ****
! ;;; thrift.el --- Major mode for Apache Thrift files
!
! ;; Keywords: files
!
;; Licensed to the Apache Software Foundation (ASF) under one
config defaultToCurrentScreen true
config nudgePercentOf screenSize
config resizePercentOf screenSize
config focusPreferSameApp false
config focusCheckWidthMax 3000
config checkDefaultsOnLoad true
alias air 1440x900
alias dell 2560x1440
@purcell
purcell / ensime-byte-compilation.txt
Created October 17, 2013 12:53
Ensime byte compilation warnings / errors
Compiling file /Users/steve/.emacs.d/elpa/ensime-20130904.40/ensime-auto-complete.el at Thu Oct 17 13:49:57 2013
Entering directory `/Users/steve/.emacs.d/elpa/ensime-20130904.40/'
In ensime-ac-complete-action:
ensime-auto-complete.el:148:11:Warning: reference to free variable `candidate'
In ensime-ac-enable:
ensime-auto-complete.el:322:15:Warning: assignment to free variable
`ac-delete-dups'
@purcell
purcell / proxy-mode.el
Created October 24, 2013 14:03
proxy-mode.el
;;; proxy-mode.el --- Provides proxy minor mode.
;; Copyright (C) 2013 by Sachin Patil
;; Author: Sachin Patil <isachin@iitb.ac.in>
;; URL: http://github.com/psachin/proxy-mode
;; Keywords: network, proxy, tool, convenience
;; Version: 0.9
;; This file is NOT a part of GNU Emacs.
@purcell
purcell / no-proxy-mode.el
Created October 25, 2013 09:23
no-proxy-mode.el
;;; no-proxy-mode.el --- Temporarily disable built-in proxy settings
;; Copyright (C) 2013 by Sachin Patil
;; Author: Sachin Patil <isachin@iitb.ac.in>
;; URL: http://github.com/psachin/proxy-mode
;; Keywords: network, proxy, tool, convenience
;; Version: 0.9
;; This file is NOT a part of GNU Emacs.
@purcell
purcell / elpa-compare.el
Created June 27, 2012 12:42
Compare melpa and marmalade package lists
(defun elpa/package-names (archive-name)
(let* ((archive-contents (expand-file-name (concat "archives/" archive-name "/archive-contents")
package-user-dir))
(names (mapcar 'car (rest (pb/read-from-file archive-contents)))))
(sort names 'string<)))
(defun list-minus (a b)
(let ((result (copy-seq a)))
(dolist (e b)
(delq e result))
module Main where
import Text.Parsec
import Text.Parsec.String
main :: IO ()
main = do
input <- getLine
module Puzzle where
import Data.List (permutations)
import Control.Monad (guard)
solution = do
[a,b,c,d,e,f] <- permutations "123456"
guard $ multiple 6 [a,b,c,d,e,f]
guard $ multiple 5 [a,b,c,d,e]
guard $ multiple 4 [a,b,c,d]
@purcell
purcell / migrations.sql
Last active September 16, 2017 10:10
PostgreSQL schema migrations system
This code now lives in its own repo at https://github.com/purcell/postgresql-migrations