Skip to content

Instantly share code, notes, and snippets.

View unicornware's full-sized avatar
🔥
getting busy with the keyboard

Lex unicornware

🔥
getting busy with the keyboard
View GitHub Profile
@unicornware
unicornware / algolia.ts
Last active May 19, 2023 10:57
Jest Mocks - Algolia
import { createWaitablePromise as waitable } from '@algolia/client-common'
import type {
ChunkedBatchResponse,
DeleteResponse,
SearchResponse,
SetSettingsResponse,
Settings
} from '@algolia/client-search'
import type { SearchIndex } from 'algoliasearch'
import type { PlainObject } from 'simplytyped'
@unicornware
unicornware / VercelRequest.ts
Last active August 27, 2023 02:46
Mock VercelRequest & VercelResponse Classes
import type {
VercelRequest as IVercelRequest,
VercelRequestBody,
VercelRequestCookies,
VercelRequestQuery
} from '@vercel/node'
import isUndefined from 'lodash/isUndefined'
import omit from 'lodash/omit'
import type { MockRequestOptions } from 'mock-http'
import { Request } from 'mock-http'
@unicornware
unicornware / shopify-rest-admin-api.ts
Last active April 14, 2021 06:17
Shopify Type Definitions - REST Admin API (v2021-01) & @shopify/theme-images
import type {
NullishNumber,
NullishString,
PartialOr
} from '@flex-development/json'
import { NumberString } from './utils'
/**
* @file Type Definitions - Shopify REST Admin API (v2021-01)
* @module types/shopify-rest-admin-api
@unicornware
unicornware / shuffle.ts
Created March 25, 2021 20:16
Shuffle an array
import type { ANYTHING } from '@flex-development/json'
/**
* Shuffle an array.
*
* @param {ANYTHING[]} array - Array to shuffle
* @return {ANYTHING[]} Shuffled array
*/
const shuffle = (array: ANYTHING[]): typeof array => {
let c = array.length - 1
@unicornware
unicornware / ignored-build-script.sh
Created February 5, 2021 16:25
Vercel Ignored Build Step - Next.js, Storybook, & Serverless Function API Monorepo
#!/bin/bash
# Vercel Ignored Build Step
# If the following workflow exists with "0", the build will be skipped.
# If a code "1" or greater is returned, then a new deployment will be built.
# See: https://vercel.com/docs/platform/projects#ignored-build-step
# Common files to check for changes in the root of each package
COMMON_FILES="package.json tsconfig.json vercel.json"
@unicornware
unicornware / pino-logger.ts
Last active June 2, 2023 21:57
Pino Logger Configuration
import pino from 'pino'
/**
* @file Pino Logger Configuration
* @module logger
*
* @see {@link https://github.com/pinojs/pino}
* @see {@link https://github.com/pinojs/pino-pretty}
* @see {@link https://docs.feathersjs.com/api/errors.html}
*/
@unicornware
unicornware / _spacing-utils-first-last.scss
Last active January 2, 2021 19:06
Sass Mixin - Utility classes for removing the margin or padding from the first or last element within a container
/// ----------------------------------------------------------------------------
/// @name spacing-utils-first-last
/// @group mixins
/// ----------------------------------------------------------------------------
/// Generates utility classes for removing the margin or padding from the first
/// or last element within a container.
/// @require {function} breakpoint-infix
/// @require {mixin} breakpoint-up
/// @require {variable} $grid-breakpoints
@unicornware
unicornware / reduceObjects.ts
Created December 31, 2020 05:08
Reduce an array of objects into a single object
import { merge } from 'lodash'
/**
* @file Implementation - reduceObjects
* @author Lexus Drumgold <[email protected]>
*/
type AnyObject = Record<string, any>
/**
@unicornware
unicornware / .npmrc
Last active January 3, 2022 05:14
Package Manager Configurations
# NPM Configuration
# See: https://docs.npmjs.com/cli/v6/using-npm/config#npmrc-files
# See: https://stackoverflow.com/questions/53099434/using-auth-tokens-in-npmrc
# Registry Configuration - npm
//registry.npmjs.org/:_authToken=${NPM_TOKEN}
registry=https://registry.npmjs.org/
# Registry Configuration - gpr / @flex-development scope
//registry.yarnpkg.com/:_authToken=${GH_PAT}
@unicornware
unicornware / mdx-scoped-runtime.d.ts
Created November 3, 2020 19:08
mdx-scoped-runtime declaration file
/// <reference types='mdx-js__react' />
declare module 'mdx-scoped-runtime' {
import { FC, ReactNode } from 'react'
type AnyObject = Record<string, any>
interface MDXProps extends MDXProviderProps {
children?: ReactNode
components?: MDXProviderComponents