Skip to content

Instantly share code, notes, and snippets.

Kasey Speakman kspeakman

Block or report user

Report or block kspeakman

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@kspeakman
kspeakman / Ssm.fs
Last active Dec 13, 2018
Update-Perform style fetching parameters from AWS SSM
View Ssm.fs
module Ssm
module GetParametersWorkflow =
open Amazon.SimpleSystemsManagement.Model
open System.Net
type Failure =
| ParameterRequestFailed of exn
| ParameterRequestError of HttpStatusCode * Amazon.Runtime.ResponseMetadata
View Async.fs
namespace Utils
module Async =
let retn x =
async { return x }
let lift f =
f >> retn
@kspeakman
kspeakman / GuidBits.cs
Last active Apr 24, 2018
Utf8Json Short GUID parser
View GuidBits.cs
// differences from Utf8Json GuidBits
// * parses Base64 encoded Guids
// * writes Guids without '-' character
[StructLayout(LayoutKind.Explicit, Pack = 1)]
public struct GuidBits
{
[FieldOffset(0)]
public readonly Guid Value;
@kspeakman
kspeakman / ListFolds.elm
Created Feb 14, 2018
Fixing Elm's List folds
View ListFolds.elm
module ListFolds exposing (..)
{-| Alternative implementations of List.foldl and List.foldr
-- this will add the `fold` and `foldBack` functions to the List module
import ListFolds as List
List.fold (++) "" [ "Hello", " ", "World", "!" ] == "Hello World!"
-}
@kspeakman
kspeakman / Combinators.fs
Last active Aug 19, 2017
Idiomatic F# routing with ASP.NET Core
View Combinators.fs
module Combinators
// These are basic combinators that work with ASP.NET HttpContext.
// Feel free to add your own.
//
// most of this adapted from Giraffe v0.1.0-alpha025
// https://github.com/dustinmoris/Giraffe/blob/v0.1.0-alpha025/src/Giraffe/HttpHandlers.fs
// Some combinators adapted from Suave
// https://github.com/SuaveIO/suave
// Both projects are Apache 2.0 Licensed
@kspeakman
kspeakman / FileUtils.elm
Last active Nov 14, 2017
Elm file uploads as simple as I could make them
View FileUtils.elm
module FileUtils exposing (..)
import Native.FileUtils
import Html exposing (..)
import Html.Events exposing (..)
import Http exposing (Body)
import Json.Decode as Json
type alias File =
@kspeakman
kspeakman / Example.elm
Last active Apr 13, 2017
JWT expiration notification
View Example.elm
-- Try to setup auto logout. But JWT parsing can fail in several ways.
--
-- Failure strategy:
-- 1. Console log failure.
-- 2. The fallback (not shown below) is to instruct the user to
-- manually log out and back in when we receive 401 Unauthorized.
--
-- TODO send failure to logging infrastructure.
notifyOnExpired : String -> Cmd Msg
@kspeakman
kspeakman / Api.elm
Last active Aug 4, 2018
JsonStuff - Elm native module to auto-encode/decode JSON
View Api.elm
port module Api exposing (..)
import JsonStuff exposing (ToJson, FromJson, getEncoder, getDecoder)
import Http
helpPostJson : String -> ToJson a msg -> FromJson b msg -> a -> Http.Request b
helpPostJson url toJson fromJson o =
Http.request
{ method = "POST"
, headers = []
You can’t perform that action at this time.