Skip to content

Instantly share code, notes, and snippets.

View LambertSchulze's full-sized avatar
🏴󠁧󠁢󠁳󠁣󠁴󠁿

Lambert Schulze LambertSchulze

🏴󠁧󠁢󠁳󠁣󠁴󠁿
View GitHub Profile
@Dibasic
Dibasic / colortest.sh
Created February 24, 2022 17:58
colortest - print terminal foreground/background color combinations in a 16x16 (80 chars x 16 lines) grid
colortest() {
echo "$(tput setaf 1)1 $(tput setaf 2)2 $(tput setaf 3)3 $(tput setaf 4)4 $(tput setaf 5)5 $(tput setaf 6)6 $(tput setaf 7)7 $(tput setaf 8)8 $(tput setaf 9)9 $(tput setaf 10)10 $(tput setaf 11)11 $(tput setaf 12)12 $(tput setaf 13)13 $(tput setaf 14)14 $(tput setaf 15)15 $(tput setaf 16)16 $(tput sgr0)"
local FCR=$(tput setaf 1)
local FCG=$(tput setaf 2)
local FCY=$(tput setaf 3)
local FCB=$(tput setaf 4)
local FCM=$(tput setaf 5)
local FCC=$(tput setaf 6)
local FCW=$(tput setaf 7)
local FCK=$(tput setaf 8)
@LambertSchulze
LambertSchulze / ReduxCounter.js
Last active August 9, 2020 01:28
Redux Counter Example
const INCREMENT = 'INCREMENT';
const DECREMENT = 'DECREMENT';
const counterReducer = (state = 0, action) => {
switch(action.type) {
case INCREMENT:
return (state += 1);
case DECREMENT:
return (state -= 1);
default: return 0;
@JamieMason
JamieMason / group-objects-by-property.md
Created September 14, 2018 07:38
Group Array of JavaScript Objects by Key or Property Value

Group Array of JavaScript Objects by Key or Property Value

Implementation

const groupBy = key => array =>
  array.reduce((objectsByKeyValue, obj) => {
    const value = obj[key];
    objectsByKeyValue[value] = (objectsByKeyValue[value] || []).concat(obj);
    return objectsByKeyValue;