Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am tfausak on github.
  • I am taylorfausak (https://keybase.io/taylorfausak) on keybase.
  • I have a public key whose fingerprint is 9891 6E7D C1ED FC03 DEF6 9A7C 153A 2CC8 FF94 90BF

To claim this, I am signing this object:

@tfausak
tfausak / hairy-example.sh
Created October 22, 2014 00:33
Example usage of Hairy.
$ http post :3000/tasks content='Do something!' created='2014-10-21T00:00:00Z'
{
"content": "Do something!",
"created": "2014-10-21T00:00:00.000Z"
}
$ http :3000/tasks
[
{
"content": "Do something!",
@tfausak
tfausak / explicit-parameters.hs
Created October 28, 2014 22:28
A comparison between explicitly passing function parameters and using a monad transformer stack in Haskell.
{-# LANGUAGE OverloadedStrings #-}
import Control.Concurrent.STM (TVar, atomically, modifyTVar, newTVarIO, readTVar)
import Control.Monad.IO.Class (liftIO)
import Data.ByteString.Lazy.Char8 (pack)
import Network.HTTP.Types (hContentType, status200)
import Network.Wai (Application, Request, Response, rawPathInfo, responseLBS)
import Network.Wai.Handler.Warp (run)
main :: IO ()
Introduction to Haskell
===
*** Introduction ***
This document is in Literate Haskell. This means that you can run this file with
`ghci intro.lhs` and be able to run the functions defined in this file.
These 2 readings here explain very well why Haskell matters, and why programmers
like Haskell:
# coding: utf-8
require 'active_interaction' # 1.4.1
require 'active_record' # 4.2.0
require 'sqlite3' # 1.3.10
ActiveRecord::Base.establish_connection(
adapter: 'sqlite3', database: ':memory:')
ActiveRecord::Schema.define do
@tfausak
tfausak / Euler8.hs
Created April 5, 2015 20:02
Which one of these Haskell programs would you rather read and maintain?
module Euler8 where -- http://projecteuler.net/problem=8
import Data.Char (digitToInt, isDigit)
import Data.List (tails)
main :: IO ()
main = getContents >>= print . euler8
euler8 :: String -> Int
euler8
@tfausak
tfausak / wss.hs
Last active August 10, 2021 18:25
Secure WebSockets in Haskell.
-- base ==4.7.0.1
-- bytestring ==0.10.4.0
-- connection ==0.2.4
-- network ==2.4.2.3
-- text ==1.1.0.0
-- websockets ==0.9.3.1
import Control.Concurrent (forkIO)
import Control.Monad (forever, void)
import qualified Data.ByteString as BS
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