Skip to content

Instantly share code, notes, and snippets.

Larry Botha larrybotha

Block or report user

Report or block larrybotha

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View machine.js
// Luna Med user auth machine
const authUserMachine = Machine({
id: 'user',
initial: 'noUser',
context: {
error: undefined,
user: undefined,
View machine.js
// LunaMed organization authorisation
const fetchTargets = [{target: 'select', cond: 'hasOrgs'}, {target: 'fetching'}];
const xeroTokenExchangeTargets = [
{target: '#org.xeroSelect.exchangingToken', cond: 'hasOrgs'},
{target: 'fetchingOrgsForXeroTokenExchange'},
];
@larrybotha
larrybotha / A.markdown
Last active Oct 7, 2019
XState + AWS Amplify example
View A.markdown

XState + AWS Amplify example

A breakdown of a project that uses XState to manage state for authenticating a user with Cognito, and then finding the authorized application user with an invoked machine.

  1. create auth machine
  2. create auth context
  3. handle AWS authentication
  4. once user authenticates with Cognito, redirect to user route to get user from db
  5. at user route use userMachine service from authMachine to get application user
  6. once associated application user is found, send user to organization route to allow user to associate session with specific organization
View machine.js
const bullishMachineConfig = {
initial: 'findingStock',
on: {
MARKET_TRENDING_DOWN: 'bearish',
MARKET_TRENDING_SIDEWAYS: 'evaluatingGeneralMarket',
},
states: {
findingStock: {
View machine.js
// Luna Med auth machine
const fetchMachine = Machine({
id: 'auth',
initial: 'unknown',
states: {
unknown: {
entry: 'storeRequestUrl',
View machine.js
const tradingStrategyMachine = Machine({
id: 'three-step-trading-process',
initial: 'backtesting',
context: {
timesRefactored: 0,
},
states: {
View machine.js
const xeroOrgMachine = Machine({
id: 'xeroOrg',
initial: 'noOrg',
states: {
noOrg: {
invoke: {
src: "requestAuthUrl",
onDone: "exchangingToken",
View machine.js
const userMachine = Machine({
id: "user",
initial: "noUser",
states: {
noUser: {
invoke: {
src: "getUser",
onDone: "userFound",
@larrybotha
larrybotha / A.markdown
Last active Apr 7, 2017
Two.js Renderer for PhysicsJS
View A.markdown

Two.js Renderer for PhysicsJS

A starting point for a Two.js renderer for PhysicsJS.

@larrybotha
larrybotha / A.markdown
Last active Sep 16, 2019
Mac OS Sierra MySQL my.conf
View A.markdown

Fixing Mac OS Sierra MySQL Woes

MySQL throwing ERROR 2006 (HY000): MySQL server has gone away?

mysql -u root -p
# enter password

mysql > SET GLOBAL max_allowed_packet=1073741824;
You can’t perform that action at this time.