Skip to content

Instantly share code, notes, and snippets.

View rcook's full-sized avatar

Richard Cook rcook

View GitHub Profile
@rcook
rcook / JoinWordsAppend.hs
Last active March 30, 2020 05:47
Criterion experiment
joinWordsAppend :: [String] -> String
joinWordsAppend (w : ws) = w ++ joinWordsAppend ws
joinWordsAppend _ = ""
@rcook
rcook / SerializationUsingBinary.hs
Last active April 9, 2018 23:12
Rosetta Code serialization example - no inheritance
{-# LANGUAGE DeriveGeneric #-}
module Main (main) where
import qualified Data.ByteString.Lazy as ByteString (readFile, writeFile)
import Data.Binary (Binary)
import qualified Data.Binary as Binary (decode, encode)
import GHC.Generics (Generic)
data Employee = Employee
@rcook
rcook / LICENSE
Last active March 30, 2020 05:47
What was the time difference between Bothell, Washington and Haworth, West Yorkshire over time?
The MIT License (MIT)
Copyright (c) 2018 Richard Cook
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
@rcook
rcook / Leetcode158.hs
Last active April 14, 2018 03:26
Leetcode 158: Read N Characters Given Read4 II
module Main (main) where
import Control.Monad (foldM, replicateM)
import System.IO (Handle, IOMode(..), hGetChar, withFile)
-- Used to thread state between calls to readXXX functions
data ReadState = ReadState [Char] Handle
fileName :: FilePath
fileName = "test.txt"
@rcook
rcook / Main.hs
Created June 7, 2018 13:50
ynab-demo: Parsing CSV in Haskell
{-
Simple program demonstrating how to extract register data from data
downloaded from YNAB (https://www.youneedabudget.com/)
You'll need the following Haskell packages in your .cabal file in addition to "base":
* bytestring
* cassava
* directory
* filepath
* text
@rcook
rcook / LICENSE
Last active March 30, 2020 05:47
My first Eta program
The MIT License (MIT)
Copyright (c) 2018 Richard Cook
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
@rcook
rcook / .gitignore
Last active March 30, 2020 05:47
Elm with Google Auth
/elm-stuff/
/elm.js
/google-api-client-id.txt
/jquery.min.js
@rcook
rcook / LICENSE
Last active March 30, 2020 05:47
Demonstration of hello.js page display login mode
The MIT License (MIT)
Copyright (c) 2018 Richard Cook
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
@rcook
rcook / 0.sh
Last active June 21, 2020 17:46
Twurl on Windows
twurl "/1.1/search/tweets.json?q=nasa&result_type=popular"
#!/usr/bin/env python
import os
import logging
import hashlib
def prune(dic):
return {key:value for key, value in dic.iteritems() if len(value) > 1}