This file contains hidden or 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
| const { pbkdf2: deriveKey } = require("pbkdf2"); | |
| const crypto = require("crypto"); | |
| const DERIVATION_ROUNDS = 200000; | |
| const HMAC_KEY_SIZE = 32; | |
| const PASSWORD_KEY_SIZE = 32; | |
| function pbkdf2(password, salt, rounds, bits) { | |
| return new Promise((resolve, reject) => { | |
| deriveKey(password, salt, rounds, bits / 8, "sha256", (err, key) => { |
This file contains hidden or 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
| app.get("/some-endpoint", validate({...}), (req, res, next) => {}); |
This file contains hidden or 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 Main where | |
| import Prelude | |
| import Data.Exists (Exists, mkExists, runExists) | |
| import Unsafe.Coerce (unsafeCoerce) | |
| -- Leibniz equality: | |
| -- Two things are equal if they are substitutable in all contexts. | |
| type Leib a b = forall f. f a -> f b |
This file contains hidden or 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
| #!/bin/sh | |
| # OUTDATED: please refer to the link below for the latest version: | |
| # https://github.com/rancherlabs/support-tools/blob/master/extended-rancher-2-cleanup/extended-cleanup-rancher2.sh | |
| docker rm -f $(docker ps -qa) | |
| docker volume rm $(docker volume ls -q) | |
| cleanupdirs="/var/lib/etcd /etc/kubernetes /etc/cni /opt/cni /var/lib/cni /var/run/calico /opt/rke" | |
| for dir in $cleanupdirs; do | |
| echo "Removing $dir" | |
| rm -rf $dir | |
| done |
This file contains hidden or 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
| const compose = (f, g) => x => f(g(x)) | |
| const Id = x => | |
| ({ | |
| fold: f => f(x), | |
| map: f => Id(f(x)) | |
| }) | |
| Id.of = Id | |
| const Tuple = (_1, _2) => |
This file contains hidden or 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 NoImplicitPrelude #-} | |
| {-# LANGUAGE ScopedTypeVariables #-} | |
| {-# LANGUAGE OverloadedStrings #-} | |
| module Main where | |
| import Protolude | |
| import qualified Web.Scotty as Sc | |
| import qualified Data.Text as Txt | |
| import qualified Network.Wai.Middleware.Gzip as Sc |
This file contains hidden or 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
| const createSelector = (...fns) => R.memoize(R.converge(R.last(fns), R.init(fns))) | |
| // test case | |
| const selector = createSelector( | |
| state => state.a, | |
| state => state.b, | |
| (a, b) => console.log('Called!') || ({ | |
| c: a * 2, | |
| d: b * 3 |
This file contains hidden or 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 ReasonML | |
| Based on Kris Jenkins original writing. | |
| http://blog.jenkster.com/2016/06/how-elm-slays-a-ui-antipattern.html | |
| */ | |
| type remoteData 'e 'a = | |
| | NotAsked | |
| | Loading | |
| | Failure 'e | |
| | Success 'a; |
This file contains hidden or 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
| import React from 'react' | |
| // Comp:: a -> JSX; | |
| const Comp = g => ({ | |
| fold: g, | |
| contramap: f => Comp(x => g(f(x))), | |
| concat: other => Comp((x) => <div> {g(x)} {other.fold(x)} </div>) | |
| }); | |
| // Reducer :: (a, b) -> a |
This file contains hidden or 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
| CREATE TABLE accounts( | |
| id serial PRIMARY KEY, | |
| name VARCHAR(256) NOT NULL | |
| ); | |
| CREATE TABLE entries( | |
| id serial PRIMARY KEY, | |
| description VARCHAR(1024) NOT NULL, | |
| amount NUMERIC(20, 2) NOT NULL CHECK (amount > 0.0), | |
| -- Every entry is a credit to one account... |
NewerOlder