Skip to content

Instantly share code, notes, and snippets.

const COLORS = {
info: ['#1E88E5', '#90CAF9'],
success: ['#388E3C', '#A5D6A7'],
error: ['#E53935', '#EF9A9A'],
warning: ['#F4511E', '#FFAB91'],
}
const print = Object.entries(COLORS).reduce(
(api, [name, colors]) => ({
[name]: (shortLabel, longerMessage, optionalSuffix = '') =>
@schabluk
schabluk / index.js
Created September 10, 2018 19:36 — forked from benoitv-code/index.js
d3, jsdom, node.js: server-side rendering
// Instructions:
// npm install --save d3 jsdom
const fs = require('fs');
const d3 = require('d3');
const jsdom = require('jsdom');
const { JSDOM } = jsdom;
const fakeDom = new JSDOM('<!DOCTYPE html><html><body></body></html>');
@schabluk
schabluk / redis-pipe.md
Created July 16, 2019 11:08 — forked from abtrout/redis-pipe.md
Bash script to prepare Redis commands for mass insertion via `redis-cli --pipe`

Redis supports mass insert via redis-cli --pipe, but commands need to be written in redis protocol. For more details, check out the Redis mass insertion page. This script takes care of converting ordinary redis commands to redis protocol.

#!/usr/bin/env bash

while read CMD; do
  # each command begins with *{number arguments in command}\r\n
  XS=($CMD); printf "*${#XS[@]}\r\n"
  # for each argument, we append ${length}\r\n{argument}\r\n
 for X in $CMD; do printf "\$${#X}\r\n$X\r\n"; done