Skip to content

Instantly share code, notes, and snippets.

@tfausak
tfausak / RTCDataChannel.html
Created September 26, 2015 13:36
WebRTC data channel
<!doctype html>
<html>
<head>
<title>RTCDataChannel</title>
</head>
<body>
<p>
<a href="https://github.com/samdutton/simpl/tree/master/rtcdatachannel">
@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 / Euler.purs
Last active July 27, 2016 16:23
Project Euler solutions in PureScript with Neon. https://github.com/tfausak/purescript-neon
module Euler where
import Neon
main :: Eff (console :: CONSOLE) Unit
main = do
log "https://projecteuler.net/problem=1"
1
:upTo 999
:filter (divisibleBy 3 || divisibleBy 5)
@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