Skip to content

Instantly share code, notes, and snippets.

@taroyanaka
taroyanaka / ramda4.js
Created October 24, 2018 02:36 — forked from sebabouche/ramda4.js
ramda: has, path, propOr, pathOr, keys, values
import { has, path, propOr, pathOr, keys, values } from "ramda"
const one = {
a: "Bingo",
b: {
c: "Bingo",
},
}
const two = {
@taroyanaka
taroyanaka / permutations.js
Created October 23, 2018 04:26 — forked from CrossEye/permutations.js
Find permutations of a list of (distinct) values. Uses Ramda
// https://codepen.io/taroyanaka/pen/bmxoMw?editors=0011
const R = require('ramda');
const permutations = (tokens, subperms = [[]]) =>
R.isEmpty(tokens) ?
subperms :
R.addIndex(R.chain)((token, idx) => permutations(
R.remove(idx, 1, tokens),
R.map(R.append(token), subperms)
), tokens);
@taroyanaka
taroyanaka / StreamToString.go
Created October 18, 2018 08:11 — forked from tejainece/StreamToString.go
Golang: io.Reader stream to string or byte slice
import "bytes"
func StreamToByte(stream io.Reader) []byte {
buf := new(bytes.Buffer)
buf.ReadFrom(stream)
return buf.Bytes()
}
func StreamToString(stream io.Reader) string {
buf := new(bytes.Buffer)