Skip to content

Instantly share code, notes, and snippets.

View brekk's full-sized avatar

Brekk brekk

View GitHub Profile
@brekk
brekk / .vimrc
Created March 15, 2024 23:18
Madlib + Neovim
" Plugins (using vim-plug)
call plug#begin('~/.config/nvim/plugins')
" Core Madlib
Plug 'madlib/vim-madlib'
" Commentary
Plug 'tpope/vim-commentary'
@brekk
brekk / redundo.js
Created July 18, 2023 23:00
Get the common words of a file
const CC = require('change-case')
const {
join,
__: $,
fromPairs,
toPairs,
slice,
sortWith,
descend,
keys,
@brekk
brekk / Function.mad
Created December 31, 2022 07:31
Function.mad
import type {Maybe} from "Maybe"
import {Just, Nothing} from "Maybe"
alias Predicate a = a -> Boolean
alias Transform a b = a -> b
alias PredicateTransformer a b = #[Predicate a, Transform a b]
cond :: List (PredicateTransformer a b) -> a -> Maybe b
export cond = (predlist, x) => pipe(
where {
@brekk
brekk / keybase.md
Created August 10, 2021 19:39
keybase proof

Keybase proof

I hereby claim:

  • I am brekk on github.
  • I am brekk (https://keybase.io/brekk) on keybase.
  • I have a public key ASDovb8gcCJghu48fqn1-p9wbkxYDI8yvfNGPCfxdK1qBAo

To claim this, I am signing this object:

@brekk
brekk / a-primer-on-snang.md
Last active April 11, 2023 16:53
Manipulating files and streams like a boss with snang

Manipulate multiple files and sources with snang

I would like to write today about a personal tool I've written and maintained for the past few years, called snang.

Depending on your frame of reference, you can think of it as a tool similar to sed(1) or awk(1). If you're more familiar with the node ecosystem, snang was inspired by both jayin and pipeable-js, but is designed to be a more re-usable solution.

If you're unfamiliar with anything at all, then this might not be the right document for you; suffice it to say that you can use snang to cut apart files and streams using a JS-based sandbox.

Common Flags

@brekk
brekk / convert-to-png.js
Created November 18, 2020 07:17
Convert globs into max 800 x 800 png files
const fs = require('fs')
const path = require('path')
const sharp = require('sharp')
const globby = require('globby')
const { trace } = require('xtrace')
const { futurizeWithCancel, tacit } = require('ensorcel')
const { parallel, fork: rawFork, Future, chain } = require('fluture')
const { reduce, mergeRight, objOf, pipe, curryN, __: $, map } = require('ramda')
const yargsParser = require('yargs-parser')
const { writeFile, copyFile } = require('torpor')
@brekk
brekk / fp-code-conventions-js.md
Last active August 28, 2020 12:07
FP Code Convention Template

Code Conventions

This codebase uses a functional programming (FP) approach and ideology. For anything which cannot be automatically linted for and resolved automatically, this document will be used to frame conventions used within the code and their rationale.

Use ramda

Use ramda for function composition, data transformation, higher-order functions and automatically curried interface. It is well tested, offers more functions than you will likely ever need to use, but has a core set of very clean utililty functions.

See converter for a good example of potential usage.

@brekk
brekk / functional.js
Last active January 6, 2020 16:45
the difference between implicit and explicit arity iteration functions
import {map} from 'ramda'
const inputs = '54321'.split('')
const results = map(parseInt, inputs)
// const parseInts = map(parseInt)
// const results = parseInts(inputs)
@brekk
brekk / Infrastructure.js
Last active September 2, 2019 09:51
Simplify base calls
import { curry, pathOr, pipe, toPairs, map } from 'ramda';
const prepend = curry((b, a) => a + b);
const nestedInfData = curry((inf, what, label, propPath) =>
pipe(
pathOr('', [what, ...propPath]),
prepend(label + ': ')
)(inf)
);
const renderableLi = curry((fn, key, access) => (
@brekk
brekk / fp-rulez.md
Last active December 27, 2017 16:35
10 rules for a better FP-in-JS
  1. Prefer functions to other forms of expression.
    1. Unary functions (with a single parameter) are best.
      const unary = (x) => x
    2. If not a unary function, use curry when adding parameters.
      const binary = curry((a, b) => a + b)
    3. Prefer functional composition to inline complexity.