Skip to content

Instantly share code, notes, and snippets.

View afbroman's full-sized avatar

Andrew Broman afbroman

  • University of Wisconsin-Madison
  • Madison, Wisconsin
  • X @afbroman
View GitHub Profile
@afbroman
afbroman / machine.js
Created August 6, 2020 04:23
Generated by XState Viz: https://xstate.js.org/viz
Machine(
{
initial: "hidden",
states: {
hidden: {
on: {
TURN_ON: "visible",
},
},
visible: {
@afbroman
afbroman / machine.js
Created August 3, 2020 23:34
Generated by XState Viz: https://xstate.js.org/viz
const displayMachine = Machine(
{
initial: "hidden",
states: {
hidden: {
on: {
TURN_ON: "visible",
},
},
visible: {
@afbroman
afbroman / machine.js
Created August 3, 2020 23:19
Generated by XState Viz: https://xstate.js.org/viz
const displayMachine = Machine({
initial: "hidden",
states: {
hidden: {
on: {
TURN_ON: "visible",
},
},
visible: {
type: "parallel",
@afbroman
afbroman / machine.js
Created August 3, 2020 23:04
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@afbroman
afbroman / machine.js
Last active May 5, 2020 07:31
Generated by XState Viz: https://xstate.js.org/viz
const fetchMachine = Machine(
{
id: 'fetch',
initial: 'idle',
context: {
results: [],
message: '',
},
states: {
idle: {
function validate(inputs) {
return {
name: inputs.name.length > 3 ? null : 'Company name should be longer than 3 characters',
shareholders: inputs.shareholders.map(shareholder => {
return {
name: shareholder.name.length > 3 ? null : 'Shareholder name should be longer than 3 characters',
shares: shareholder.shares > 0 ? null : 'Shareholder should have at least one share'
};
}),
}
@afbroman
afbroman / faraday_stubbing
Created June 3, 2016 15:10 — forked from anonymous/faraday_stubbing
Stubbing with Faraday
def stub_request
faraday_stub = Faraday.new do |builder|
builder.adapter :test do |stub|
stub.post('/api/service', {id: '111', data: {'a': 1}}) {|env| [200, {}, mock_response]}
stub.get('/api/another_service', {query: 'foo'}) {|env| [200, {}, second_mock_response]}
end
end
Service::Something.stubs(:connection).returns(faraday_stub)
end
import React from "react";
import { render } from "react-dom";
const ParentComponent = React.createClass({
getDefaultProps: function() {
console.log("ParentComponent - getDefaultProps");
},
getInitialState: function() {
console.log("ParentComponent - getInitialState");
return { text: "" };

Keybase proof

I hereby claim:

  • I am afbroman on github.
  • I am afbroman (https://keybase.io/afbroman) on keybase.
  • I have a public key ASBpBj6Tyd21vd4d9VJlqSeq4f4oDczv840vBXn-UHYnkgo

To claim this, I am signing this object:

@afbroman
afbroman / new.html.erb
Created July 14, 2015 20:31
Reform multiparameter date issue
<%= simple_form_for @form do |f| %>
<%= f.input :username %>
<%= f.input :birthdate, as: :date %>
<%= f.button :submit %>
<% end %>