Skip to content

Instantly share code, notes, and snippets.

Rob Hilgefort rjhilgefort

Block or report user

Report or block rjhilgefort

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View propTypes.js
import { curry } from 'lodash/fp'
import PropTypes, { func, shape } from 'prop-types'
const args = {
openEntity: func.isRequired,
closeEntity: func.isRequired,
gridApi: shape({
getDisplayedRowCount: func.isRequired,
isQuickFilterPresent: func.isRequired,
}).isRequired,
View csv-to-json.js
const fs = require('fs')
const path = require('path')
const _ = require('lodash')
const parser = require('csv-parse/lib/sync')
const JsonStringify = x => JSON.stringify(x, null, 2)
const SRC_DIR = path.join(__dirname, '..', 'src')
_.forEach(
@rjhilgefort
rjhilgefort / ramda.js
Last active May 1, 2019
Example of vanilla JS to Ramda (Reason in Notion)
View ramda.js
const { log, clear } = console
clear()
const logHof = (fn) => (...args) => pipe(
tap(() => log('-----------------------------')),
tap((args) => log(`args: ${args}`)),
fn,
tap((res) => log(`res: ${res}`)),
)(...args)
View cli.js
#!/usr/bin/env node
/* eslint-disable import/no-commonjs */
;(async () => {
const util = require('util')
const child_process = require('child_process')
const { tap } = require('ramda')
const execP = util.promisify(child_process.exec)
const exec = command => execP(command).then(({ stdout, stderr }) => {})
View then.js
console.clear()
const upperAsync = (x) => Promise.resolve(toUpper(x))
const splitChars = split('')
const handleResponse = curry((tag, promise) =>
pipe(
then((data) => {
console.log(`${tag}-SUCCESS: ${data}`)
return data
View logHof.js
const { log, clear } = console;
clear();
log('=================================================');
const add2 = (x, y) => x + y;
const add2P = (x, y) => Promise.resolve(x + y);
const logFn =
const logAdd2 = logFn(add2);
View proxy.js
const { log, clear } = console
clear()
class Foo {
constructor() {
this.state = {}
this.util = {
nested: {
mergeRight,
identity,
View maybeHof.js
const maybeHof = compose(when, complement)(isNil)
const maybeToUpper = maybeHof(toUpper)
maybeToUpper(null) // null
maybeToUpper(undefined) // undefined
maybeToUpper('foo') // 'FOO'
View evolveAll.js
const evolveAll = spec => compose(
evolve(spec),
compose(pickAll, keys)(spec),
)
const maybeHof = compose(when, complement)(isNil)
const maybeToUpper = maybeHof(toUpper)
evolveAll({
@rjhilgefort
rjhilgefort / pipeAny_composeAny.js
Last active Dec 4, 2018
`pipeAny` (`pipe` + `pipeP`) and `composeAny` (`compose` + `composeP`) allows sync and async functions mixed together in a pipeline. ramda repl: https://goo.gl/DD6jS5
View pipeAny_composeAny.js
console.clear()
// util.js
/////////////////////////////////////////////////////////////////
const PromiseResolve = x => Promise.resolve(x)
// pipeAny.js
/////////////////////////////////////////////////////////////////
const pipeAny = compose(
apply(pipeP),
You can’t perform that action at this time.