Skip to content

Instantly share code, notes, and snippets.

View bkinsey808's full-sized avatar
💭
looking for a moonlighting remote position

Ben Kinsey bkinsey808

💭
looking for a moonlighting remote position
View GitHub Profile
import { FormControl, InputLabel, MenuItem, Select } from '@material-ui/core';
import { memo } from 'react';
import { Controller } from 'react-hook-form';
import {
Control,
Path,
PathValue,
UnpackNestedValue,
} from 'react-hook-form/dist/types';
<?xml version="1.0" encoding="UTF-8"?>
<opml version="1.0">
<head>
<title>Ben subscriptions in feedly Cloud</title>
</head>
<body>
<outline text="webdev" title="webdev">
<outline type="rss" text="Web.Dev - Channel 9" title="Web.Dev - Channel 9" xmlUrl="https://channel9.msdn.com/Shows/webdevshow/RSS" htmlUrl="https://s.ch9.ms/Shows/webdevshow"/>
<outline type="rss" text="Alter Conf" title="Alter Conf" xmlUrl="https://www.youtube.com/feeds/videos.xml?channel_id=UC4Av66gi0KiboNzqJy5rAPQ" htmlUrl="https://www.youtube.com/channel/UC4Av66gi0KiboNzqJy5rAPQ"/>
@bkinsey808
bkinsey808 / recursive flatten
Created January 26, 2019 17:47
takes an array and returns a flattened array
const flatten = arr =>
arr.reduce((flatArr, arrElement) =>
flatArr.concat(
Array.isArray(arrElement) ? flatten(arrElement) : arrElement
)
, []);

Keybase proof

I hereby claim:

  • I am bkinsey808 on github.
  • I am bkinsey808 (https://keybase.io/bkinsey808) on keybase.
  • I have a public key ASABgt60ToqtxR60jx3lj-SLgk1i-Yk38Il5YftoDV99Bwo

To claim this, I am signing this object:

/** Identity */
const I = x => x
/** self apply */
const S = s => s(s)
// Church Numerals
const churchZero = f => I
const nextChurch = n => f => x => f(n(f)(x))
const churchToInt = c => c(x => x + 1)(0)
// consider the following case
let a, b, c
if (condition) {
a = 1
b = 2
c = 3
}
// how would this be refactored into constantly const?
// suppose I have the following function.
// in this case message is declared as const following the constantly const convention
const TEMPLATE = `Howdy ${PLACEHOLDER}!`
function welcome(name) {
const message = TEMPLATE.replace(PLACEHOLDER, name)
const wordCount = message.split(' ').length
return {message, wordCount}
}
// suppose I have the following:
const x = { a: 1 }
x.a = 2
// if I want to make x.a itself sort of like a const, i have to do it like this:
const x = {}
Object.defineProperty(x, 'a', { value: 1 })
// suppose I have the following:
const a = expensiveFunction() ? 1 : 0
const b = expensiveFunction() ? 10 : 0
const c = expensiveFunction() ? 100 : 0
// liberal let would let you refactor like this:
let a, b, c
if (expensiveFunction()) {