Skip to content

Instantly share code, notes, and snippets.

View dinocarl's full-sized avatar

Carl Albrecht-Buehler dinocarl

View GitHub Profile
const data = {'a.b': 1, 'c.d': 7, 'c.d': 9}
const assocPathDataLast = curry(
(mergeAble, pathList, val) => assocPath(pathList, val, mergeAble)
);
const processKeys = compose(
split('.'),
head
);
@dinocarl
dinocarl / clamp.js
Last active January 19, 2022 20:03
const clamp = (min, max, x) => Math.min(Math.max(x, min), max);
const clmp = (minVal, maxVal) => compose(
min(maxVal),
max(minVal)
);

Keyboard Basics

Basic Terms

  • Keycap: [Plastic outer covering][keycaps] of a particular key typically inscribed with the character that gets sent to the computer when struck.
  • PCB: Printed Circuit Board (really, just a circuit board), which registers keystrokes and sends them to the computer.
  • Switch: underlying mechanism that the keycap covers, and in some way creates contact with the PCB to let it know that a keystroke needs
@dinocarl
dinocarl / everyByProp.js
Created August 4, 2021 15:04
Ramda-based every and some Fns that rely on a specific prop
const data1 = [
{id: 1, status: true},
{id: 2, status: false},
{id: 3, status: true},
];
const data2 = [
{id: 1, status: true},
{id: 2},
{id: 3, status: true},
@dinocarl
dinocarl / input.scss
Created January 19, 2021 16:55
Generated by SassMeister.com.
// Given a value with a unit
// return the value without the unit
@function strip-unit($item) {
@if type-of($item) == 'number' and not unitless($item) {
@return $item / ( $item * 0 + 1 );
}
@return $item;
}

Keybase proof

I hereby claim:

  • I am dinocarl on github.
  • I am dinocarl (https://keybase.io/dinocarl) on keybase.
  • I have a public key ASDKE0ZRqX9N0qWa_W_hgF_DGsLmbgaWta9UtVWiQUAV2go

To claim this, I am signing this object:

@dinocarl
dinocarl / input.scss
Created December 14, 2020 16:22
Generated by SassMeister.com.
// meta-programming part
@mixin dynamicallyAvailableExtend($placeholder) {
%#{$placeholder} {
@content;
}
}
@mixin extend($placeholders...) {
@each $placeholder in $placeholders {
@extend %#{$placeholder};
// use transducers
const appendTo = flip(append);
const apCh = (fn, accVal) => (item) => accVal = fn(accVal, item);
const steps = [
filter(test(/[()]/)),
map((item) => item === '(' ? 1 : -1),
map(apCh(add, 0)), // scan transducer
];
@dinocarl
dinocarl / scan.js
Last active November 12, 2020 04:35
JS Scan function
const apCh = (fn, accVal) => (item) => accVal = fn(accVal, item);
const scanr = curry((fn, acc, xs) => map(
apCh(fn, acc),
xs
))
scanr(add, 0)(
[5,6,7,8]
);
const isntEmpty = complement(isEmpty);
const isntNil = complement(isNil);
const isntNaN = complement(isNaN);
const pageLens = lensProp('page');
const numberValidations = [
isntNaN,
isntNil,
isntEmpty,