Skip to content

Instantly share code, notes, and snippets.

View brookslybrand's full-sized avatar

Brooks Lybrand brookslybrand

View GitHub Profile
[
{
"field1": "1",
"TV": "230.1",
"radio": "37.8",
"newspaper": "69.2",
"sales": "22.1"
},
{
"field1": "2",
sepalLength sepalWidth petalLength petalWidth type
5.1 3.5 1.4 0.2 Iris-setosa
4.9 3.0 1.4 0.2 Iris-setosa
4.7 3.2 1.3 0.2 Iris-setosa
4.6 3.1 1.5 0.2 Iris-setosa
5.0 3.6 1.4 0.2 Iris-setosa
5.4 3.9 1.7 0.4 Iris-setosa
4.6 3.4 1.4 0.3 Iris-setosa
5.0 3.4 1.5 0.2 Iris-setosa
4.4 2.9 1.4 0.2 Iris-setosa
import React from 'react'
import ReactDOM from 'react-dom'
import './index.css'
import App from './App'
import * as serviceWorker from './serviceWorker'
ReactDOM.render(<App />, document.getElementById('root'))
serviceWorker.register()
import React, { useState } from 'react'
import Dexie from 'dexie'
import Form from './Form'
const App = () => {
const [open, setOpen] = useState(true)
return (
<div style={{ margin: '2rem auto', width: '200px' }}>
// sets the name in the store and in the state hook
const setName = id => value => {
// update the store
db.formData.put({ id, value })
// update the state hook
setNames(prevNames => ({ ...prevNames, [id]: value }))
}
import React, { useEffect, useState } from 'react'
import { Offline, Online } from 'react-detect-offline'
// some inline styling so everything isn't squished
const formStyle = { padding: '2rem 0rem' }
const inputStyle = { margin: '1rem 0rem' }
// a simple form with a first name, last name, and submit button
const Form = ({ db }) => {
// store form values in a state hook
const reducer = produce((state, action) => {
// eslint-disable-next-line default-case
switch (action.type) {
case REVERSE: {
state.reverse();
break;
}
case SET_OPTION: {
const { id, option } = action;
const itemOptions = state.find(item => item.id === id).options;
const incrementTime = assign({
time: (context, e) => context.time + 1
});
// Guard to check if the max count was reached
function maxCountReached(context, event) {
return context.time >= 3;
}
const timerMachine = Machine(
title id
Bill's Pump P-201 0SMXdqEPUWGzhgMzJ2UX
16E1 Brine Exchanger 2Ghc9mqNC4J7xUBusiZg
Demo Pump P-0100 4frqz1OOo6FAY2dpnzP3
C Ditch 4mivCBjk9B4FsMYQ9dWL
V-1267 5z7NEvpQgsYwF5hFt2ix
16Z1 C Refrigeration Compressor 85RdTIPCLYvrJ0Ma5ybG
Leveling Pond 8doLIoXUMKA7fGIRf2hh
xxxxx 97z1kTNJB9W2oT9R28tG
16P1-2 Chilled Brine Pump AI4wFNxUTKaJBRuOeKsL
@brookslybrand
brookslybrand / machine.js
Last active January 17, 2020 15:53
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions