This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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]) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { log, clear } = console | |
clear() | |
const logHof = (fn) => (...args) => pipe( | |
tap(() => log('-----------------------------')), | |
tap((args) => log(`args: ${args}`)), | |
fn, | |
tap((res) => log(`res: ${res}`)), | |
)(...args) |
NewerOlder