Skip to content

Instantly share code, notes, and snippets.

@philandstuff
philandstuff / codemesh2015.org
Last active November 16, 2015 19:37
Code mesh 2015 notes

Kush, an introduction to schedulers

about me

  • I work for GDS
  • Cabinet Office
  • we started by building GOV.UK
    • replaced older sites like direct gov, business link
  • we’re not just fixing websites
    • we also build and run digital services
    • working with depts across the country
    • eg: register to vote
@tonymorris
tonymorris / fuck-you.md
Last active February 26, 2016 01:30
Ignorance has real-world practical effects.

I was just sitting in a doctor surgery 45 minutes ago with an orthopaedic spine surgeon, who is one of the few who has worked out how to use software to his advantage. We were measuring a deformity that the previous surgeon has created. After 20 minutes of drawing lines and measurements all over this DICOM image, the following happened

Access Violation at address 0xGOFUCKYOURSELF

…so now I have to go back in two weeks while he can restart a plan for a difficult corrective surgery.

@3noch
3noch / install-ghcjs-for-stack.hs
Last active August 28, 2016 12:48
Install GHCJS for Stack
#!/usr/bin/env stack
-- stack --install-ghc runghc --package turtle --package wreq
{-# LANGUAGE OverloadedStrings #-}
import qualified Control.Foldl as Fold
import Control.Lens ((^.))
import Control.Monad (when)
import Data.ByteString.Lazy (hPut)
import Data.Maybe (fromMaybe)
@gneuvill
gneuvill / Free.java
Last active October 24, 2016 19:59
@Data(flavour = Flavour.FJ)
public abstract class Free<f, A> implements __2<Free.µ, f, A> {
Free() {}
interface Cases<f, A, R> {
R Return(A a);
R Suspend(__<f, A> fa);
R Gosub(Sub<f, A, ?> sub);
}
abstract <R> R match(Cases<f, A, R> cases);
@pchiusano
pchiusano / traverse.scala
Created March 23, 2017 15:02
Another encoding of `Traverse` in terms of `mapAccumulate`
/**
* In this version of `Traverse`, sequencing always goes through `List` (or some other canonical sequence type),
* which can be done in a stack-safe manner using a balanced fold as in https://gist.github.com/pchiusano/7667597.
* It's quite nice that `sequence` and `traverse` are now derived functions.
*/
trait Traverse[F[_]] extends Functor[F] {
/** Inefficient but correct implementation of `toList` in terms of `mapAccumulate`. */
def toList[A](f: F[A]): List[A] = mapAccumulate(f, List())((a, rbuf) => (a, a :: rbuf))._2.reverse
/** The only function that must be implemented. Must be consistent with `map`. */
@tonymorris
tonymorris / free-classy-prisms.hs
Created April 28, 2017 07:35
Free monad with classy prisms on grammar
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE DeriveFunctor #-}
import Control.Lens
import Prelude hiding (readFile, writeFile, print)
import qualified Prelude as Prelude(readFile, writeFile, print)
@pchiusano
pchiusano / Interpreters.scala
Created September 21, 2017 20:51
Code for Scala World 2017 talk on eliminating interpreter overhead via partial evaluation
package scalaworld.interpreters
/*
This file shows a simple language, an interpreter, and two
partial evaluators for that language, along with a profiling suite.
*/
trait Expr // denotes a Vector[Double] => Vector[Double]
object Expr {
@taktoa
taktoa / incremental.nix
Last active January 8, 2018 12:57
Build the profunctors library incrementally using Nix.
with builtins;
rec {
pkgs = import <nixpkgs> {};
testGHC = pkgs.haskellPackages.ghcWithPackages (p: with p; [
base base-orphans bifunctors comonad contravariant distributive
tagged transformers
]);
@paulp
paulp / global.sbt
Last active October 16, 2018 19:09
continuous compilation of the sbt build
// These lines go in ~/.sbt/0.13/global.sbt
watchSources ++= (
(baseDirectory.value * "*.sbt").get
++ (baseDirectory.value / "project" * "*.scala").get
++ (baseDirectory.value / "project" * "*.sbt").get
)
addCommandAlias("rtu", "; reload ; test:update")
addCommandAlias("rtc", "; reload ; test:compile")
addCommandAlias("ru", "; reload ; update")
@jdegoes
jdegoes / HigherKindedJava.java
Last active January 9, 2019 11:23
Modeling higher-kinded types in a language without them.
class Option<A> {
protected Option() { }
}
interface App<F, A> {
F proof();
}
class OptionF {
private OptionF() {}
private static class AppOption<A> implements App<OptionF, A> {