Skip to content

Instantly share code, notes, and snippets.

View chrisoverstreet's full-sized avatar

Chris Overstreet chrisoverstreet

  • BoomPop, Inc.
  • Lynchburg, VA
  • 22:57 (UTC -12:00)
View GitHub Profile
import { z } from 'zod';
const DEFAULT_HEX_OPTIONS = ['#000000', '#FFFFFF'];
const hexColorSchema = z.string().regex(/^#[0-9A-F]{6}$/i);
// https://www.w3.org/TR/AERT/#color-contrast
export function bestContrastingColor(backgroundHexColor: string, ...hexOptions: string[]) {
hexColorSchema.parse(backgroundHexColor);
import { CustomNextPage } from '../_app';
import { Stack, Typography } from '@mui/material';
import { EventProvider, useEvent, useEventGuests } from '@events';
import { useEffect, useState } from 'react';
export const TestPage: CustomNextPage = () => {
const [show, setShow] = useState(false);
useEffect(() => {
const timeoutId = setTimeout(() => setShow((prev) => !prev), 1000);
@chrisoverstreet
chrisoverstreet / readme.md
Last active January 7, 2022 21:46
Payments v1

V1 - Support charging final payments + showing payment in-app

Goal of V1 is to support adding line items to an order, auto-charging final payment (including notification to organizers).

To reduce risk, we will have a flag per order to turn auto-charging on or off. This can be used to show or hide the payments tab as well.

Steps

  1. BE - Add an autocharge_balance flag to orders.
{
"editor.formatOnSave": true,
"javascript.validate.enable": false,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.tabSize": 2,
"editor.renderWhitespace": "all"
}
type Result<Response> = {
get(): Promise<Response>;
delete(): Promise<Response>;
post(body?: BodyInit): Promise<Response>;
put(body?: BodyInit): Promise<Response>;
patch(body?: BodyInit): Promise<Response>;
};
type Options = {
headers?: Record<string, string>;
class DbHandler
{
private $conn;
private $pdo;
/**
* DbHandler constructor.
* Pass in connections to prevent race conditions being cause by multiple connections being created
* @param {mysqli} $dbConnection - optional mysqli connection
* @param {PDO} $pdoConnection - optional pdo connection
export const patchEstimateHandler = async (req, res) => {
const {
body: { canStartToday },
params: { estimateId },
userId
} = req;
const originalEstimate = await getEstimateById(estimateId);
if (!originalEstimate) {
return responseService.createErrorResponse(res, createError.NotFound());
import DataLoader from 'dataloader';
import UserPermission from '../../../models/user-permission.model';
async function batchUserPermissions(userIds) {
const userPermissionListMap = new Map();
const userPermissions = await UserPermission.query()
.select(['userId', 'permission'])
.whereIn('userId', userIds);
@chrisoverstreet
chrisoverstreet / test.jsx
Created June 24, 2020 14:39
pages/test.jsx
// @flow
// pages/test.jsx
import React from 'react';
import Link from 'next/link';
import LinkButton from '../components/homee-ui/LinkButton';
export default () => (
<div>
<Link href="/workbench/[bucket]" as="/workbench/active" passHref>