Skip to content

Instantly share code, notes, and snippets.

data Graph = Graph
{ pointsLeft :: Set.Set (V2 Double)
-- ^ All the points in the whole graph left to be connected
, branches :: Set.Set LineSegment
-- ^ All branches we have found, connecting two points
, currentPoints :: [V2 Double]
-- ^ Points that are currently being processed
, maxDist :: Double
-- ^ Maximum distance a thing can be away from a thing
}
@5outh
5outh / Auth.hs
Last active July 3, 2018 19:35
Authorized
orNotFound :: MaybeT Handler a -> Handler a
orNotFound mHandler = do
act <- runMaybeT mHandler
maybe notFound act
withStudentToken :: (StudentId -> CourseId -> Handler a) -> MaybeT Handler a
withStudentToken action = do
mStudentToken <- MaybeT optionalStudentToken
case mStudentToken of
Nothing -> mempty
newtype Face = Face { getFace :: Polygon }
newtype Box = Box { getBox :: [Face] }
drawFace face = do
brightness <- getRandomR (0.4,0.6)
cairo $ do
draw (getFace face)
setSourceHsv (HSV 0 0 brightness) *> fillPreserve
setSourceHsv (HSV 0 0 0) *> stroke
@5outh
5outh / write
Created July 1, 2019 12:44
Journal setup
#! /bin/bash
DATE=`date +%Y-%m-%d`
FILE="./entries/$DATE.md"
if [ ! -f $FILE ]; then
printf "# $DATE\n" >> $FILE
fi
nvim $FILE
git add entries -A