Skip to content

Instantly share code, notes, and snippets.

Avatar

William Wolf throughnothing

View GitHub Profile
@throughnothing
throughnothing / Promise.js
Last active Jun 9, 2020
Promise.all implementations ... for fun
View Promise.js
// Reduce Implementation
function promiseAllReduction(promises) {
return promises.reduce(function(acc, i) {
return acc.then(rs => i.then(r => [...rs, r]))
}, Promise.resolve([]));
}
// Recursive Implementation
function promiseAllRecursive(promises) {
if(promises.length === 0) {
@throughnothing
throughnothing / recommended-routine.md
Created Jun 7, 2020 — forked from sgup/recommended-routine.md
Recommended Routine (Updated Dec 2019)
View recommended-routine.md
View gdrive-pdf.js
(function() {
let jspdf = document.createElement("script");
jspdf.onload = function () {
let pdf = new jsPDF();
let elements = document.getElementsByTagName("img");
for (let i in elements) {
let img = elements[i];
console.log("add img ", img);
@throughnothing
throughnothing / Either.ts
Created May 17, 2020
very simple Either in Typescript
View Either.ts
export interface Either<E, A> {
map<B>(f: (a: A) => B): Either<E, B>;
mapLeft<F>(f: (e: E) => F): Either<F, A>;
flatMap<B>(f: (a: A) => Either<E, B>): Either<E, B>;
flatMapLeft<F>(f: (e: E) => Either<F, A>): Either<F, A>;
ap<B>(f: Either<E, (a: A) => B>): Either<E, B>;
match<R>(result: (success: A) => R, error: (err: E) => R): R;
}
@throughnothing
throughnothing / TinyServant.hs
Created Jun 5, 2019 — forked from kosmikus/TinyServant.hs
Implementation of a small Servant-like DSL
View TinyServant.hs
{-# LANGUAGE DataKinds, PolyKinds, TypeOperators #-}
{-# LANGUAGE TypeFamilies, FlexibleInstances, ScopedTypeVariables #-}
{-# LANGUAGE InstanceSigs #-}
module TinyServant where
import Control.Applicative
import GHC.TypeLits
import Text.Read
import Data.Time
@throughnothing
throughnothing / ServantGADT.hs
Created May 30, 2019
Servant with GADT types experiment
View ServantGADT.hs
{-#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
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.
View DBTypes.purs
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
View gist:e8373251337f50fefdd278e3ebb0954b

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.

View spacemacs-cheshe.md

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
View purescript-gadt.purs
module GADT.Main where
import Prelude (class Category, class Semigroupoid, (<<<), flip, identity, ($), (+), (==))
import Unsafe.Coerce (unsafeCoerce)
newtype Leibniz a b = Leibniz (forall f. f a -> f b)
infix 4 type Leibniz as ~
instance semigroupoidLeibniz :: Semigroupoid Leibniz where
You can’t perform that action at this time.