Skip to content

Instantly share code, notes, and snippets.

View ZempTime's full-sized avatar

Chris Zempel ZempTime

View GitHub Profile
@ZempTime
ZempTime / processes_controller.rb
Created July 26, 2017 21:55
Controller Setups
module Api
module V2
module Investments
class ProcessesController < Api::V2::BaseController
include InvestmentScoped
def index
end
def show
@ZempTime
ZempTime / LocalStorage.rb
Last active September 12, 2017 17:57
little nested helper class to store some state locally in yaml since the aws-sdk v2 for ruby doesn't support tagging, and thats what we gotta use
require "yaml"
class LocalStorage
class DocumentIdAlreadyExists < StandardError; end
class DocumentKeyAlreadyExists < StandardError; end
# YAML format per-environment
# env: {
# corrected_doc_ids: [],
# corrected_doc_keys: [],
# destroyable_doc_keys:[]
@ZempTime
ZempTime / generate_index.rb
Created October 6, 2017 15:03
Building out index.js files throughout app
require "pathname"
IGNORED_FILES = ['.DS_Store']
def recurse(directory)
current_dir = Pathname.new(directory)
populate_index(current_dir)
current_dir.children.each do |dir|
recurse(dir) if dir.directory?
@ZempTime
ZempTime / polymer 3 & redux forms.md
Last active May 14, 2018 03:05
Exploration of forms in redux

How should we handle linking up forms with a redux store in polymer 3?

This gist is my attempt to do a couple things:

  • Articulate the problem
  • Begin aggregating relevant existing solutions or things we could use
  • Define desired solutions that may or may not exist in usable forms

Problem Articulation

@ZempTime
ZempTime / lit-upgrade.md
Last active November 7, 2018 15:45
Lit Upgrade
@ZempTime
ZempTime / xstate-getting-started.md
Last active September 12, 2019 07:25
Statechart doc example

Thinking in State Charts

  1. Determine your states
  2. Determine your events
  3. Determine your side effects (resulting changes in state)

You can store information in two ways:

  • State nodes (each state node can have one value)
  • Context (can hold arbitrary values because js object)
@ZempTime
ZempTime / machine.js
Created September 17, 2019 17:39
Generated by XState Viz: https://xstate.js.org/viz
const lightMachine = Machine({
id: 'light',
initial: 'green',
type: 'compound',
states: {
green: {
on: {
TIMER: 'yellow'
}
},
@ZempTime
ZempTime / machine.js
Created September 17, 2019 18:37
Generated by XState Viz: https://xstate.js.org/viz
const wordMachine = Machine({
id: 'word',
type: 'parallel',
states: {
bold: {
initial: 'off',
states: {
on: {
on: { TOGGLE_BOLD: 'off' }
},
@ZempTime
ZempTime / machine.js
Created September 18, 2019 21:02
Generated by XState Viz: https://xstate.js.org/viz
const machine = Machine(
{
id: 'multiply',
initial: 'addThenMultiply',
states: {
addThenMultiply: {
on: {
TOGGLE: 'multiplyThenAdd',
INCREMENT: {
@ZempTime
ZempTime / machine.js
Last active November 10, 2019 16:50
Generated by XState Viz: https://xstate.js.org/viz
const buildTask = (taskName, resolver) => {
return {
[taskName]: {
initial: "resolving",
states: {
resolving: {
invoke: {
id: taskName,
src: ctx => resolver(ctx),
onError: "errored",