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
# i3 config file (v4) | |
# | |
# Please see https://i3wm.org/docs/userguide.html for a complete reference! | |
set $mod Mod4 | |
# Font for window titles. Will also be used by the bar unless a different font | |
# is used in the bar {} block below. | |
font pango:monospace 8 |
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
const R = require('ramda'); | |
const typeEncoder = (mode, type) => { | |
if (mode !== 'fromDynamo' && mode !== 'toDynamo') { | |
throw new Error('Invalid mode: ' + mode); | |
} | |
const numberEncoder = mode === 'fromDynamo' ? Number : String; | |
switch (R.toUpper(type)) { | |
case 'S': return String; | |
case 'N': return numberEncoder; |
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
// Split an array every time the predicate returns true | |
// :: f => (array -> Boolean) -> f a -> f a | |
const segment = R.curry((fn, array) => { | |
const chunks = []; | |
let chunk = []; | |
for (let value of array) { | |
if (fn(value)) { | |
chunks.push(chunk); | |
chunk = []; | |
} |
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
import R from 'ramda'; | |
/* | |
Convert JS maps to/from DynamoDB maps. | |
http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Programming.LowLevelAPI.html#Programming.LowLevelAPI.ResponseFormat | |
*/ | |
// Convert DynamoDB data to/from JS data | |
// :: => 'fromDynamo' => dynamoType => dynamoValue => jsValue | |
// :: => 'toDynamo' => dynamoType => jsValue => dynamoValue |
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
const uuid = () => { // Create a secure V4 UUID | |
const randomHexChars = qty => crypto | |
.randomBytes(Math.ceil(qty / 2)) | |
.toString('hex') | |
.slice(0, qty); | |
const reserved = ['8', '9', 'a', 'b'][crypto.randomBytes(1)[0] % 4]; | |
return [ | |
randomHexChars(8), | |
randomHexChars(4), | |
'4' + randomHexChars(3), |
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
import R from "ramda"; | |
const mapWhile = R.curry(( | |
predicate, // while fn - receives current partial list & value, returns bool | |
transformation, // map fn | |
list // source list | |
) => R.reduce((oldAcc, oldVal) => { | |
const newVal = transformation(oldVal); | |
const newAcc = [ ...oldAcc, newVal ]; | |
return predicate(newAcc, newVal) ? newAcc : R.reduced(oldAcc); |
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
import R from "ramda"; | |
const stringize = value => typeof value === "number" ? value + "" : value; | |
const orphanIds = R.compose( | |
R.reduce((partial, pair) => [ | |
...partial, | |
pair[0], | |
...orphanIds(pair[1].children) | |
], []), |
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
// inst: unix epoch | |
const hist = { | |
"channel1": [ | |
{ inst: 10000, id: "a" }, | |
{ inst: 20000, id: "b" }, | |
{ inst: 30000, id: "c" }, | |
{ inst: 30000, id: "d" }, | |
{ inst: 40000, id: "e" } | |
] | |
}; |
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
const curry = (fn, ...oldArgs) => (...newArgs) => { | |
const args = [...oldArgs, ...newArgs]; | |
return (args.length < fn.length) ? curry(fn, ...args) : fn(...args); | |
}; |
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
const compose = (...args) => initial => args.reduceRight( | |
(result, fn) => fn(result), | |
initial | |
); |