This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
next-i = do -> | |
j = 1 | |
(i) -> | |
success, reject <- new Promise _ | |
success i + j | |
spawn = (gen) -> | |
success, reject <- new Promise _ | |
next = (last) -> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE OverloadedStrings #-} | |
{-# LANGUAGE GADTs #-} | |
{-# LANGUAGE StandaloneDeriving #-} | |
{-# LANGUAGE TypeFamilies #-} | |
{-# LANGUAGE FlexibleInstances #-} | |
{-# LANGUAGE MultiParamTypeClasses #-} | |
{-# LANGUAGE GeneralizedNewtypeDeriving #-} | |
{-# LANGUAGE DeriveDataTypeable #-} | |
module Main where |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### GENERATE PRIVATE KEY (key.pem) | |
# openssl req -newkey rsa:2048 -new -nodes -keyout key.pem -out csr.pem | |
### GENERATE CERTIFICATE (cert.pem) | |
# openssl req -newkey rsa:2048 -new -nodes -x509 -days 3650 -keyout key.pem -out cert.pem | |
express = require("express") | |
fs = require('fs') | |
https = require('https') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- This is based on ideas from the excellent article "Beautiful Aggregations | |
-- with Haskell" by Evan Borden: https://tech.freckle.com/2017/09/22/aggregations/ | |
module Aggregation where | |
import Prelude | |
import Data.Foldable (foldMap) | |
import Data.Monoid.Additive (Additive(..)) | |
import Data.Newtype (un) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Slaying a UI Anti Pattern in Reason */ | |
type remoteData 'e 'a = | |
| Nothing | |
| Loading | |
| Failure 'e | |
| Success 'a; | |
type item = { | |
userId: int, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// NOTE: code now moved to https://github.com/tycho01/typical | |
// older revision left here, but it no longer runs well in TS Playground | |
export type Obj<T> = { [k: string]: T }; | |
export type NumObj<T> = { [k: number]: T }; | |
// export type List = ArrayLike; // no unapplied generic types :( | |
export type List<T> = ArrayLike<T>; | |
// progress: https://github.com/Microsoft/TypeScript/issues/16392 | |
export function force<T, V extends T>() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
autoload -U add-zsh-hook | |
load-nvmrc() { | |
if [[ -f .nvmrc && -r .nvmrc ]]; then | |
nvm use | |
fi | |
} | |
add-zsh-hook chpwd load-nvmrc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Example () where | |
import Network.HTTP | |
-- Non HTTPS | |
-- 1. Perform a basic HTTP get request and return the body | |
get :: String -> IO String | |
get url = simpleHTTP (getRequest url) >>= getResponseBody |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# unregister broken GHC packages. Run this a few times to resolve dependency rot in installed packages. | |
# ghc-pkg-clean -f cabal/dev/packages*.conf also works. | |
function ghc-pkg-clean() { | |
for p in `ghc-pkg check $* 2>&1 | grep problems | awk '{print $6}' | sed -e 's/:$//'` | |
do | |
echo unregistering $p; ghc-pkg $* unregister $p | |
done | |
} | |
# remove all installed GHC/cabal packages, leaving ~/.cabal binaries and docs in place. |
OlderNewer