Skip to content

Instantly share code, notes, and snippets.

View robertmarriott's full-sized avatar
🏠
Working from home

Robert Marriott robertmarriott

🏠
Working from home
  • Langley BC, Canada
  • 20:53 (UTC -08:00)
View GitHub Profile
@robertmarriott
robertmarriott / formik-dependent-select-demo.js
Last active December 28, 2021 04:37
Formik MUI Filtered Select Demo
import { Box, Button, MenuItem } from '@mui/material';
import { Field, Form, Formik } from 'formik';
import React, { useState } from 'react';
import { TextField } from 'formik-mui';
export default function SelectDemo({ regions, countries, cities, cityId }) {
const { countryId = 0 } = cities.find((city) => city.id === cityId);
const { regionId = 0 } = countries.find(
(country) => country.id === countryId
@robertmarriott
robertmarriott / relative_dates.py
Last active October 15, 2021 03:55
Python relative date handling routine. Useful for scheduling daily, weekly and monthly reports.
from datetime import datetime
from dateutil.relativedelta import *
FIRST_DAY = 1
LAST_DAY = 31
TODAY = datetime.combine(datetime.today(), datetime.min.time())
#args_string = '@months=-1,weekday=MO(-1),hour=12'
args_string = '@months=-1,day=LAST_DAY,hour=12'
@robertmarriott
robertmarriott / postgresql-error-codes.ts
Created December 13, 2020 00:26
A series of TypeScript enums containing PostgreSQL error codes
// Adapted from https://www.postgresql.org/docs/12/errcodes-appendix.html
export enum PgSuccessfulCompletion {
SuccessfulCompletion = '00000',
}
export enum PgWarning {
Warning = '01000',
DynamicResultSetsReturned = '0100C',
ImplicitZeroBitPadding = '01008',