Skip to content

Instantly share code, notes, and snippets.

@briansmith
briansmith / how-to-generate-and-use-private-keys-with-openssl-tool.md
Last active October 6, 2025 11:37
How to generate & use private keys using the OpenSSL command line tool

How to Generate & Use Private Keys using OpenSSL's Command Line Tool

These commands generate and use private keys in unencrypted binary (not Base64 “PEM”) PKCS#8 format. The PKCS#8 format is used here because it is the most interoperable format when dealing with software that isn't based on OpenSSL.

OpenSSL has a variety of commands that can be used to operate on private key files, some of which are specific to RSA (e.g. openssl rsa and openssl genrsa) or which have other limitations. Here we always use

@mrkgnao
mrkgnao / Eftee.hs
Last active September 23, 2019 15:43
An "optimized" version of ElvishJerricco's free arrow type
{-# LANGUAGE Arrows #-}
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE InstanceSigs #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
@wouter-swierstra
wouter-swierstra / Wat.hs
Created September 23, 2016 03:05
Haskell Symposium Lightning Talk
GHCi, version 7.10.3: http://www.haskell.org/ghc/ :? for help
Prelude> 1 + 2
3
Prelude> minimum(100,1)
1
Prelude> minimum(1,100)
100
Prelude> let splat = splitAt 5 [0..10]
Prelude> splat
([0,1,2,3,4],[5,6,7,8,9,10])
@andrejbauer
andrejbauer / algebra.v
Last active August 27, 2025 17:45
Uinversal algebra in Coq
(* An initial attempt at universal algebra in Coq.
Author: Andrej Bauer <Andrej.Bauer@andrej.com>
If someone knows of a less painful way of doing this, please let me know.
We would like to define the notion of an algebra with given operations satisfying given
equations. For example, a group has of three operations (unit, multiplication, inverse)
and five equations (associativity, unit left, unit right, inverse left, inverse right).
*)
@atoponce
atoponce / gist:07d8d4c833873be2f68c34f9afc5a78a
Last active June 2, 2026 13:53 — forked from tqbf/gist:be58d2d39690c3b366ad
Cryptographic Best Practices

Cryptographic Best Practices

Putting cryptographic primitives together is a lot like putting a jigsaw puzzle together, where all the pieces are cut exactly the same way, but there is only one correct solution. Thankfully, there are some projects out there that are working hard to make sure developers are getting it right.

The following advice comes from years of research from leading security researchers, developers, and cryptographers. This Gist was [forked from Thomas Ptacek's Gist][1] to be more readable. Additions have been added from

//: Playground - noun: a place where people can play
//: http://webyrd.net/scheme-2013/papers/HemannMuKanren2013.pdf
typealias Var = Int
typealias Subst = [(Var, Term)]
typealias State = (Subst, Int)
typealias Goal = State -> Stream
indirect enum Stream {
case Nil, Cons(State, Stream), Lazy(() -> Stream)
-- Ornaments explore the transformation of "simple" datatypes by introducing
-- an indexing structure that allows decorating the type with extra information.
module Ornaments where
open import Agda.Primitive
record ⊤ : Set where
constructor ⋆
data _≡_ ..{ℓ} {A : Set ℓ} (x : A) : A → Set ℓ where
@jozefg
jozefg / PatCompile.hs
Created March 25, 2016 07:19
Wadler's classic pattern matching algorithm implemented for a core language with Bound.
{-# LANGUAGE DeriveTraversable #-}
{-# LANGUAGE DeriveFoldable #-}
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
module PatCompile where
import Bound
import Bound.Var
import Bound.Scope
import Control.Monad (ap)
@jozefg
jozefg / PickRandom.hs
Last active August 3, 2017 13:55
A simple trick to pick a random element from a stream in constant memory
{-# LANGUAGE FlexibleContexts #-}
module PickRandom where
import Data.List (group, sort)
import Control.Monad
import Control.Monad.Random (MonadRandom, getRandomR)
import qualified Control.Foldl as F
-- Pick a value uniformly from a fold
pickRandom :: MonadRandom m => a -> F.FoldM m a a
pickRandom a = F.FoldM choose (return (a, 0 :: Int)) (return . fst)
@stoikheia
stoikheia / cue_to_mp3.py
Last active January 30, 2021 17:24 — forked from bancek/cue_to_mp3.py
CUE splitter using ffmpeg (to mp3)
# -*- encoding: utf-8 -*-
import sys
import os.path
import codecs
if len(sys.argv) == 1:
print "Usage: cue_to_mp3.py <CUE file path> [-o]"
print "Options:"
print " -o, execute and output mp3 file"