Skip to content

Instantly share code, notes, and snippets.

View rjhilgefort's full-sized avatar

Rob Hilgefort rjhilgefort

View GitHub Profile
import React, { FC, CSSProperties } from 'react'
import { string, number, object, shape } from 'prop-types'
import { getTheme, GetThemeProps } from '@dcf/theme'
import { baseIcons } from './iconMapping'
type P = {
icon: string
size?: number
viewBox?: string
// input array of words - ['tea', 'eat', 'ate', 'leap', 'peak', 'foo', 'bar']
// output - [ ['eat', 'ate', 'tea'], ['foo'], {'bar'}, {'leap', 'peal'}]
const foo = (words) => {
const wordsGrouped = words.reduce(
(acc, word) => {
const sortedWord = word.split('').sort().join('')
// Make sure we have an entry for this sorted word
if (!acc[sortedWord]) {
import { isArray, curry, isPlainObject, isFunction, isNil } from 'lodash/fp'
import { mapValuesWithKey } from './mapValuesWithKey'
import { mapWithKey } from './mapWithKey'
const iteratee = (spec, full) => (val, key) => fn(spec[key], val, full)
const fn = (spec, data, full) => {
if (isNil(spec)) return data
if (isFunction(spec)) return spec(full)
if (isPlainObject(spec)) return mapValuesWithKey(iteratee(spec, full), data)
export const NonEmptyStrT = new t.Type<string, string, unknown>(
'NonEmptyStrT',
(input): input is string => typeof input === 'string',
(input, context) =>
typeof input === 'string' &&
pipeVal(input, trim, allPass([isString, isNotEmpty]))
? right(input)
: t.failure(input, context, 'string cannot be empty'),
t.identity,
)
import { tap, prop, chain, invoker, map } from 'ramda';
// https://monet.github.io/monet.js/
import { Maybe, Just, Some } from 'monet';
// https://github.com/fluture-js/Fluture
import { encaseP, fork } from 'fluture';
const { log, error } = console;
const fetchF = (...args) =>
encaseP(fetch)(...args)
export const poop =
({ prismaClient }: { prismaClient: PrismaClient }) =>
<T extends Prisma.IncidentFindManyArgs>(
slackChannelId: ChannelId,
args?: Prisma.SelectSubset<T, Prisma.IncidentFindManyArgs>,
) => {
const args_ = { ...args, where: { slackChannelId } } as Prisma.SelectSubset<
T,
Prisma.IncidentFindManyArgs
>
const isNegative = (num) => Math.sign(num) === -1
const isPositive = (num) => Math.sign(num) === 1 || Math.sign(num) === 0
const offsetString_from_number = (data) => {
const data_ = Math.abs(data).toString().padStart(2, '0').concat(':').padEnd(5, '0')
return isNegative(data) ? `-${data_}` : `+${data_}`
}
offsetString_from_number(-5)
offsetString_from_number(+5)