Skip to content

Instantly share code, notes, and snippets.

View codingwithchris's full-sized avatar

Chris Hahn codingwithchris

View GitHub Profile
export const FeatureReservation (id) => {
return (
<ErrorBoundary fallbackComponent={ReservationError}>
<Suspense loading={ReservationLoading}>
<ReservationStateProvider>
<ReservationComposed id={id} />
<ReservationStateProvider>
</Suspense
</ErrorBoundary>
)
@codingwithchris
codingwithchris / KEYSTONE-JS-ACCESS-CONTROL.MD
Last active March 16, 2022 09:25
Unpacking Keystone JS Access Control (a security-focused perspective)

Access Control (Creating a Secure and Trusted Application)

Access control is critical to the security of our application. Beyond proper credential encryption, hashing, SALTing etc, access control is the next line of defense in protecting our users data.

Role Based Access Control Methodology (RBAC)

When giving elevated access to a User for a particular part of the system, we use a methodology called RBAC. This means that we create Roles where we assign permissions and apply filter policies. These Roles then get assigned to Users who have their CRUD access to Lists, Records, and Fields determined accordingly.

Our Access Control Philosophy

@codingwithchris
codingwithchris / AppStateContext.tsx
Last active October 30, 2022 17:55
App State Reducer Context Example -- Easily manage the state of a small application by passing userReducer into Context.
import { createContext, useContext, useReducer, Dispatch } from 'react';
/**
* Manages the state for our entire app
*
** For larger, more complex applications, this pattern can be split into multiiple contexts.
** For example: `form`, and `user` would have theor own contexts, each with their own reducer.
*/
// Init an empty context
@codingwithchris
codingwithchris / ResponsiveLayout.tsx
Last active April 27, 2020 22:14
React Client-side Responsive Layout Component (with Context & Custom Hook)
import * as React from 'react';
import { useViewport } from '@hooks';
import { mediaQuerySizes, AvailableBreakpoint } from '@tokens';
/**
*
* @param breakpoint
* @param mobileView
* @param desktopView
*/
@codingwithchris
codingwithchris / wc-all-products-in-stock-sql.txt
Created September 7, 2019 14:59
Update all products in WooCommerce to "InStock"
UPDATE table_name
SET meta_value = 'instock'
WHERE meta_key = '_stock_status'
@codingwithchris
codingwithchris / wc-disable-manage-stock-sql.txt
Last active July 21, 2020 15:48
Disable "Stock Management" for all products in WooCommerce.
// Set "Manatge Stock" setting forall products
UPDATE table_name
SET meta_value = 'no'
WHERE meta_key = '_manage_stock'
// Allow backorders for all products
UPDATE table_name
SET meta_value = 'yes'
WHERE meta_key = '_backorders'
@codingwithchris
codingwithchris / wp-config-set-environment.php
Created May 5, 2019 16:11
Set environment in wp-config.php file based on current URL
// ==============================================================================
// Set Current Environment
// ==============================================================================
/**
* Define Environment/URL pairs for this project.
*
* Please include any possible URLs in each
* environment as these will be checked against to set an environment constant
* which can be easily used to create custom environment functionality and
@codingwithchris
codingwithchris / .editorconfig
Created May 5, 2019 16:07
An config file to unify basic coding style across various IDEs & projects
# This file is for unifying the coding style for different editors and IDEs
# editorconfig.org
root = true
[*]
indent_style = tab
indent_size = 4
charset = utf-8
trim_trailing_whitespace = true
@codingwithchris
codingwithchris / bug-report.md
Created May 5, 2019 16:06
Github Issue Starter Templates ( place inside .github/${TEMPLATE_TYPE}/${template-name.md} )
name about assignees
Bug Report
Report a bug so we can fix it!
codingwithchris

Overview of Bug

  • A short summary of the bug here.

To Do (o)

  • Build a checklist for finding & fixing the bug
@codingwithchris
codingwithchris / wp-atomic-deploy.sh
Last active May 5, 2019 16:14
An atomic deployment shell script for WordPress
# This script was inspired in part by this Delicious Brains article: https://deliciousbrains.com/wordpress-workflow-atomic-deployments/
# ----------------
# Configs
# ----------------
# ------
# Colors
# ------
WHITE='\033[1;37m'