Skip to content

Instantly share code, notes, and snippets.

Brad bradparker

Block or report user

Report or block bradparker

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
@bradparker
bradparker / index.html
Last active Mar 31, 2020
WebCrypto based SRP
View index.html
<!DOCTYPE html>
<html>
<head>
<title>SRP</title>
<meta charset="utf8" />
</head>
<body>
<script type="module">
import { modPow } from "https://unpkg.com/bigint-mod-arith@1.3.1/src/main.js";
View SKI.hs
{-# LANGUAGE RankNTypes #-}
-- Prelude> :set -XTypeApplications
-- Prelude> :t id
-- id :: a -> a
-- Prelude> :t const
-- const :: a -> b -> a
-- Prelude> :t (<*>) @((->) _)
-- (<*>) @((->) _) :: (w -> a -> b) -> (w -> a) -> w -> b
@bradparker
bradparker / Networking.hs
Last active Dec 8, 2019
Low-level Networking in Haskell (largely C so far)
View Networking.hs
{-# LANGUAGE InstanceSigs #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeApplications #-}
{-# OPTIONS_GHC -Wall #-}
module Main where
@bradparker
bradparker / iterate.js
Last active Nov 1, 2019
Flattening nested iterators ... for use with weird DynamoDB scan API
View iterate.js
const testItems = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
const limit = 2;
const getBatch = (cursor = null) => {
const currentCursor = cursor || 0;
const nextPotentialCursor = currentCursor + limit;
const nextCursor = nextPotentialCursor > 10 ? null : nextPotentialCursor;
return new Promise(resolve =>
setTimeout(() => resolve({
@bradparker
bradparker / Ind.hs
Created Jul 28, 2019
Trying to figure out B. Milewski's slide from Lambda Jam 2019
View Ind.hs
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE TypeApplications #-}
{-# OPTIONS_GHC -Wall #-}
@bradparker
bradparker / Refined.ts
Last active Jul 25, 2019
Refinement type-y kinda things
View Refined.ts
interface Refinement<A> {
tag: string;
value: A;
}
interface Refined<A, R> {
value: A;
refinement: R;
}
View Bits.hs
import Control.Monad.State
import Data.Traversable
import Data.Tuple
toByteBits :: Integral n => n -> [n]
toByteBits =
evalState (for [1..8] (\_ -> state (\s -> swap (divMod s 2))))
main = do
print $ toByteBits 1
@bradparker
bradparker / Byte.hs
Last active Jul 6, 2019
Bytes and Folds / Traversals
View Byte.hs
{-# OPTIONS_GHC -Wall #-}
{-# LANGUAGE RankNTypes #-}
module Byte where
import Data.Bool (bool)
import Data.Functor.Const (Const(Const, getConst))
import Data.Bits ((.&.), (.|.), xor)
import Prelude hiding (sum)
@bradparker
bradparker / concurrency.ts
Created Jul 1, 2019
JS concurrency _stuff_
View concurrency.ts
interface Person {
name: string;
age: number;
}
const people: Person[] = [{ name: "Bob", age: 100 }, { name: "Jane", age: 50 }];
const findPeople = (candidate: string): Promise<Person[]> => {
return new Promise(resolve => {
const timeout = Math.floor(Math.random() * 100);
@bradparker
bradparker / App.ts
Created Jun 16, 2019
Geneator function do notation experiment
View App.ts
import * as Either from "./Either";
type Action<I, E, A> = (input: I) => Promise<Either.Either<E, A>>;
export class App<I, E, A> {
public run: Action<I, E, A>;
public constructor(action: Action<I, E, A>) {
this.run = action;
}
You can’t perform that action at this time.