Skip to content

Instantly share code, notes, and snippets.

@tfausak
tfausak / circle-of-fifths.ly
Created November 16, 2012 02:44
Syntax highlighting for sheet music.
\version "2.16.1"
sharp = #(define-music-function (parser location note) (ly:music?) #{
\once \override NoteHead #'color = #(rgb-color .75 .25 0)
\once \override Stem #'color = #(rgb-color .75 .25 0)
#note
#})
flat = #(define-music-function (parser location note) (ly:music?) #{
\once \override NoteHead #'color = #(rgb-color 0 .25 .75)
module Main1 where
data HashSet a = native java.util.HashSet where
native new :: () -> STMutable s (HashSet a)
native size :: Mutable s (HashSet a) -> ST s Int
native add :: Mutable s (HashSet a) -> a -> ST s Bool
native remove :: Mutable s (HashSet a) -> a -> ST s Bool
main :: IO ()
main = do
@tfausak
tfausak / purescript-error.txt
Last active October 30, 2015 03:20
An excessively long PureScript error.
Error found:
in module Test.Main
at /Users/tfausak/Documents/GitHub/purescript-ax/test/Main.purs line 6, column 8 - line 135, column 1
Could not match expected type
( output :: OUTPUT
)
with actual type
@tfausak
tfausak / link-rot.rb
Created March 6, 2013 04:16
Check for link rot in a GitHub Pages repository.
@tfausak
tfausak / ppy.hs
Created March 15, 2016 15:40
Pretty print YAML with Haskell.
#!/usr/bin/env stack
-- stack --install-ghc --resolver nightly runghc --package bytestring --package yaml -- -Wall
import qualified Control.Exception as X
import qualified Data.ByteString.Char8 as B
import qualified Data.Yaml as Y
import qualified Data.Yaml.Pretty as Y
import qualified System.Environment as E
import qualified System.IO as IO
@tfausak
tfausak / upgrade-stackage-nightly.hs
Last active March 29, 2016 00:11
Automatically upgrades a Haskell Stack project to the latest Stackage nightly snapshot.
#!/usr/bin/env stack
{-
stack
--install-ghc
--resolver lts-5.10
runghc
--package aeson
--package bytestring
--package http-client
--package http-client-tls
@tfausak
tfausak / reader-example.hs
Created April 2, 2016 13:09
Reader monad example in Haskell.
-- https://www.stackage.org/package/transformers
import qualified Control.Monad.Trans.Reader as Reader
main :: IO ()
main = do
let result = Reader.runReader computationToRun initialValue
putStrLn result
{- Output:
There are 3 thing(s) in the environment.
compiler-check: match-exact
resolver: ghc-8.0.0.20160204
setup-info:
ghc:
macosx:
8.0.0.20160204:
sha1: 4ef73c4bc4345d45dd171515b94bd6de1e04a4b2
url: https://downloads.haskell.org/~ghc/8.0.1-rc2/ghc-8.0.0.20160204-x86_64-apple-darwin.tar.xz
@tfausak
tfausak / hackage-version-stats.hs
Created April 17, 2016 15:54
Statistics about major version numbers of Haskell packages on Hackage.
#!/usr/bin/env stack
{- stack --install-ghc --resolver lts-5 runghc
--package containers
--package HTTP
--package network-uri
--package tar
--package text
--package zlib
-}
module System.Metrics.Dynamic
( findOrCreateCounter
, findOrCreateDistribution
, findOrCreateGauge
, findOrCreateLabel
) where
import qualified Data.IORef as IORef
import qualified Data.Map.Strict as Map
import qualified Data.Text as Text