Skip to content

Instantly share code, notes, and snippets.

View throughnothing's full-sized avatar

William Wolf throughnothing

View GitHub Profile
@throughnothing
throughnothing / ServantGADT.hs
Created May 30, 2019 08:08
Servant with GADT types experiment
{-#LANGUAGE GADTs #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeOperators #-}
module Lib where
import Servant
import Servant.API ()
data Query t where
@throughnothing
throughnothing / DBTypes.purs
Created May 25, 2019 06:23
Is this a "clever" way to handle DB models? It keeps it POJO, and reduces redundancy for non-id'ed (and non-createdAt'ed) objects.
type WithId r = ( id :: Int | r )
type WithCreatedAt r = ( createdAt :: String | r )
type DB r = { | (WithId (WithCreatedAt r)) }
type DBUser = DB UserRows
type User = { | UserRows }
type UserRows =
( googleId :: String
, name :: String
, email :: String
@throughnothing
throughnothing / Either.pm
Last active May 6, 2019 15:45
Perl Either
package Either;
use strict; use warnings;
use Exporter qw/import/;
use Function::Parameters;
use syntax qw(try);
use vars qw{$AUTOLOAD};
our @EXPORT = qw/left right either either_try/;
use overload '""' => '_stringify';

Operational PGP

This is a guide on how to email securely.

There are many guides on how to install and use PGP to encrypt email. This is not one of them. This is a guide on secure communication using email with PGP encryption. If you are not familiar with PGP, please read another guide first. If you are comfortable using PGP to encrypt and decrypt emails, this guide will raise your security to the next level.

@throughnothing
throughnothing / spacemacs-cheshe.md
Created January 4, 2019 20:33 — forked from robphoenix/spacemacs-cheshe.md
Spacemacs Cheat Sheet

Useful Spacemacs commands

  • SPC q q - quit
  • SPC w / - split window vertically
  • SPC w - - split window horizontally
  • SPC 1 - switch to window 1
  • SPC 2 - switch to window 2
  • SPC w c - delete current window
  • SPC TAB - switch to previous buffer
  • SPC b b - switch buffers
@throughnothing
throughnothing / Algebra.purs
Created December 4, 2018 19:33 — forked from LukaJCB/Algebra.purs
Alternative Tagless Final encoding in PureScript
module Algebra where
import Prelude
import Control.Monad.Eff (Eff)
import Data.Maybe (Maybe(..))
newtype ConsoleAlg f = ConsoleAlg
{ printLn :: String -> f Unit
, readLn :: f String
@throughnothing
throughnothing / Loeb.purs
Last active October 8, 2018 17:29
Loeb in Purescript
module Loeb where
import Prelude
import Data.Lazy (Lazy, defer, force)
import Data.Array ((!!))
import Data.Maybe (fromMaybe)
loeb :: ∀ f a. Functor f => f (f (Lazy a) -> a) -> f (Lazy a)
loeb x = go where go = map (\y -> defer (\_ -> y go)) x
@throughnothing
throughnothing / Money.java
Last active August 23, 2018 17:13
Phantom Types in Java for Number Constraints
import com.sun.istack.internal.NotNull;
import static io.vavr.API.*;
import io.vavr.collection.List;
import io.vavr.control.Option;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Value;
import java.math.BigDecimal;
module BlockChain
%default total
data Money = MkMoney Int
record Tx sig addr where
constructor MkTx
txSrc, txDst : addr
txAmount, txFee : Money
txSig : sig
@throughnothing
throughnothing / EllipticCurve.idr
Last active August 22, 2018 06:12
Naive attempt at a simple implementation of secp256k1 in Idris
module EllipticCurve
%default total
-- Resources:
-- Bitcoin secp256k1 https://en.bitcoin.it/wiki/Secp256k1
-- SafeCurves: https://safecurves.cr.yp.to/base.html
-- https://github.com/iCHAIT/Elliptical-Curve-Cryptography
-- https://github.com/mfourne/eccrypto/
-- secp256k1 can't ladder? https://safecurves.cr.yp.to/ladder.html