Skip to content

Instantly share code, notes, and snippets.

@neoeinstein
neoeinstein / proptest_fix.sh
Created June 3, 2019 16:30
Wrapper for rustc that handles problems when trying to compile `proptest` with `cargo-tarpaulin` (or in general when using `-C link-dead-code`). Used by setting `RUSTC_WRAPPER=proptest_fix.sh` before executing `cargo-tarpaulin`.
#!/usr/bin/env bash
set -euo pipefail
ARGS=$@
CARGO_HOME=${CARGO_HOME-}
CARGO_PKG_NAME=${CARGO_PKG_NAME-}
if [[ "$CARGO_PKG_NAME" = "proptest" ]]
then
@neoeinstein
neoeinstein / 0___rust_serde_json_wasm_parcel___0.md
Created January 26, 2018 17:18 — forked from asaaki/0___rust_serde_json_wasm_parcel___0.md
Rust-to-JS JSON string exchange (parcel.js, wasm)

Rust, serde-json, wasm, parcel.js

With this combination it is fairly easy to get things done in Rust and utilize it in JavaScript. Yay!

@neoeinstein
neoeinstein / transition.md
Created January 4, 2018 23:40
PGP Key Transition

-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256

Date: January 4, 2018

For a number of [reasons][0], I, Marcus Griep, have recently set up a new OpenPGP key, and will be transitioning away from my old one.

The old key will continue to be valid for some time, but I prefer all future correspondence to come to the new one. I would also like this

@neoeinstein
neoeinstein / Api.fs
Created April 11, 2017 15:27
Minimal example resulting in a 410 Gone response
module Api
open Freya.Machines.Http
let root = HttpMachine.Freya <| freyaMachine {
exists false
gone true
}
@neoeinstein
neoeinstein / OptionModule_Decompiled.cs
Last active November 22, 2016 18:03
A decompiled version of the `Option` module fin FSharp.Core, along with the correlating IL. Produced with dotPeek 2016.2.2
// Decompiled with JetBrains decompiler
// Type: Microsoft.FSharp.Core.OptionModule
// Assembly: FSharp.Core, Version=4.4.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
// MVID: 58348223-904C-F4DA-A745-038323823458
// Assembly location: C:\dev\neoeinstein\visualfsharp\release\net40\bin\FSharp.Core.dll
// Compiler-generated code is shown
// IL code is shown in comments
using Microsoft.FSharp.Collections;
using System;
@neoeinstein
neoeinstein / Dockerfile
Last active October 6, 2016 03:53
Freya on .NET Core Proof of Concept
FROM debian:jessie
EXPOSE 8080
RUN apt-get update && \
apt-get install -y libunwind8 libicu52 && \
rm -rf /var/lib/apt/lists/*
ADD bin/Release/netcoreapp1.3/debian.8-x64/publish/* /usr/local/lib/freya-svc/
ENTRYPOINT /usr/local/lib/freya-svc/freya-poc
@neoeinstein
neoeinstein / Supervision.fs
Last active September 1, 2016 17:27
Hopac Supervisor using Proc (Based on https://gist.github.com/mavnn/57e39ce97c7de1aa3f24da77478412fc) and incorporated into Hopac.Plus (https://github.com/neoeinstein/Hopac.Plus)
// Source: https://github.com/neoeinstein/Hopac.Plus/blob/master/src/Hopac.Plus/Supervision.fs
namespace Hopac.Plus.Supervision
open Hopac
open Hopac.Infixes
open Hopac.Plus
open Hopac.Plus.Extensions
type Policy =
| Restart
@neoeinstein
neoeinstein / EventStore.fs
Last active June 14, 2017 05:59
EventStore projections from Fable. A noble attempt.
namespace Fable.Import
open System
open Fable.Core
open Fable.Import.JS
module EventStore =
type [<Erase>] Initializer<'state> = unit -> 'state
type [<Erase>] EventHandler<'state,'event> = System.Func<'state,EventEnvelope<'event>,'state>
and [<Erase>] EventHandler<'state,'event,'metadata> = System.Func<'state,EventEnvelope<'event,'metadata>,'state>
@neoeinstein
neoeinstein / Auth0.elm
Last active March 2, 2017 08:22
Elm Example for interoperating with Auth0. Note that much of this was culled out of an existing code-base, so may need some minor edits to work correctly for you. Presumes that Elm.Main is transpiled into elm.js
module Auth0
( AuthenticationState(..), AuthenticationError, AuthenticationResult
, Options, defaultOpts
, LoggedInUser, UserProfile, Token
, showLock, showLockSignal
, mapResult
) where
// Your location of the Jwt source
#I @"packages/System.IdentityModel.Tokens.Jwt/lib/net45"
#r "System.IdentityModel.Tokens.Jwt.dll"
#r "System.IdentityModel"
open System.IdentityModel.Tokens
let token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiYWRtaW4iOnRydWUsImV4cCI6MTU3NzgzNjgwMCwiaXNzIjoiSVNTVUVSIiwiYXVkIjoiQVVESUVOQ0UifQ.POsywz2VWFrISYj8PBFaeOsPMqaEaQIOJ1eZyaM9JsA"
let secretSecurityKey = InMemorySymmetricSecurityKey(System.Text.Encoding.UTF8.GetBytes("secret\000\000\000\000\000\000\000\000\000\000"))
let tokenParams = TokenValidationParameters(IssuerSigningKey = secretSecurityKey,ValidAudience="AUDIENCE",ValidIssuer="ISSUER")
let handler = JwtSecurityTokenHandler()