Skip to content

Instantly share code, notes, and snippets.

@pauldorehill
pauldorehill / sqlx_flatten_db_type.rs
Last active February 1, 2021 07:05
Example trait for sqlx to solve issues around returning Vec<T>
// [dependencies]
// sqlx = { version = "0.4", features = ["runtime-async-std-rustls", "postgres"] }
// async-std = { version = "1", features = ["attributes"] }
// dotenv = "0.15"
// anyhow = "1"
// In root of project '.env' file with export DATABASE_URL="postgres://postgres:{DB_PASSWORD}@{DB_HOST}/{DB_NAME}"
// Rough DB Schema
// CREATE TABLE public.giant (
@pauldorehill
pauldorehill / PrimitiveObsession.fsx
Last active November 5, 2019 03:02
A riff on all the ways to create simple wrapper types in F#
open System
[<AutoOpen>]
module Shared =
let equalsOn f thisObj (otherObj : obj) =
match otherObj with
| :? 'T as y -> (f thisObj = f y)
| _ -> false