Skip to content

Instantly share code, notes, and snippets.

View clarkj99's full-sized avatar

Clark Johnson clarkj99

View GitHub Profile
@clarkj99
clarkj99 / sim.py
Last active October 16, 2023 13:06
simulation script
import numpy as np
import matplotlib.pyplot as plt
from datetime import datetime, timedelta
from prettytable import PrettyTable
initial_time = 8 # 8:00 AM
number_of_days = 10
minutes_after_midnight = initial_time * 60
# mean appointment time and standard deviation
// Group by region
windowsRules?.reduce((acc, curr) => {
const startDate = moment(curr?.options?.open_time).format('L');
if (!acc[startDate]) acc[startDate] = {};
if (!acc[startDate][curr?.region?.id]) acc[startDate][curr?.region?.id] = {};
if (!acc[startDate][curr?.region?.id].windows)
acc[startDate][curr?.region?.id].windows = [];
acc[startDate][curr?.region?.id].region = curr?.region;
acc[startDate][curr?.region?.id].windows = [
...acc[startDate][curr?.region?.id].windows,
@clarkj99
clarkj99 / FeatureFlags.jsx
Last active April 25, 2023 13:22
Feasture Flag Wrapper
import { useGetUserByIdQuery } from '../redux/services/movesApi';
// Hook to provide wrappers for new features.
// Wrap new components in the NewFeatureWrapper to only show them to users who have opted in to the beta.
// Wrap original code in the DefaultFeatureWrapper for users who have not opted in.
//
// Example:
// import {NewFeatureWrapper, DefaultFeatureWrapper} from './FeatureFlags';
// ...
// <NewFeatureWrapper feature="newFeature">
@clarkj99
clarkj99 / getUniqueArray.ts
Created September 22, 2022 03:06
Returns an array of unique objects
// return an array of unique objects
const getUniqueArray = (array: any) => {
const objectsEqual = (obj1: any, obj2: any) => {
let notEqual = false;
const keys = obj1 && Object.keys(obj1);
for (const key of keys) {
if (obj2[key] !== obj1[key]) {
notEqual = true;
break;
}
@clarkj99
clarkj99 / getOrdinal.js
Created February 8, 2022 14:25
Add the ordinal suffix to any number.
const getOrdinal = number => {
const b = number % 10;
const c = number % 100;
const exceptions = [11, 12, 13];
switch (true) {
case exceptions.includes(c):
return number + 'th';
case b === 1:
return number + 'st';
case b === 2:
@clarkj99
clarkj99 / 2darraysum.js
Created May 11, 2020 02:48
2d array sum
for (let j = 0; j < 4; j++) {
let sum = 0
sum = (arr[i][j] + arr[i][j + 1] + arr[i][j + 2] + arr[i + 1][j + 1] + arr[i + 2][j] + arr[i + 2][j + 1] + arr[i + 2][j + 2])
}
@clarkj99
clarkj99 / db.json
Created March 23, 2020 02:26
Data for GraphQL demo
{
"users": [
{ "id": "23", "firstName": "Bill", "age": 20, "companyId": "1" },
{ "id": "34", "firstName": "John", "age": 27, "companyId": "2" },
{ "id": "47", "firstName": "Samantha", "age": 21, "companyId": "2" }
],
"companies": [
{ "id": "1", "name": "Apple", "description": "iphone" },
{ "id": "2", "name": "Google", "description": "search" }
]
@clarkj99
clarkj99 / server.js
Created March 23, 2020 02:14
Node.js Setup for GraphQL example
const express = require('express')
const expressGraphQL = require('express-graphql')
const schema = require('./schema/schema')
const app = express()
app.use('/graphql', expressGraphQL({
schema,
graphiql: true
}))
@clarkj99
clarkj99 / server.js
Created March 23, 2020 02:12
Node.js Setup fir GraphQL
const express = require('express')
const expressGraphQL = require('express-graphql')
const schema = require('./schema/schema')
const app = express()
app.use('/graphql', expressGraphQL({
schema,
graphiql: true
}))
@clarkj99
clarkj99 / schema.js
Created March 23, 2020 02:11
GraphQL Sample Schema
const graphql = require('graphql')
const axios = require('axios')
const {
GraphQLObjectType,
GraphQLString,
GraphQLInt,
GraphQLSchema,
GraphQLList
} = graphql;