Skip to content

Instantly share code, notes, and snippets.

View distributedlife's full-sized avatar

Ryan Boucher distributedlife

View GitHub Profile
@distributedlife
distributedlife / cf.yaml
Created August 23, 2018 02:11
Hosting assets from S3 via API Gateway.
Resources:
AssetsBucket:
Type: AWS::S3::Bucket
Properties:
BucketName: !Sub ${AWS::StackName}-assets
GetAssetsRole:
Type: "AWS::IAM::Role"
Properties:
AssumeRolePolicyDocument:
Version: 2012-10-17
@distributedlife
distributedlife / BestWithHeadphones.js
Created March 6, 2018 04:03
best-with-headphones medium code samples
const BestWithHeadphones = ({ duration }) => (
<FullScreenMessage icon={HelmetWithHeadphones} colour={White}>
<Title>BEST WITH HEADPHONES</Title>
<FloatingNotes />
<PulsingTitle duration={duration}>FETCHING RACE</PulsingTitle>
</FullScreenMessage>
);

Keybase proof

I hereby claim:

  • I am distributedlife on github.
  • I am distributedlife (https://keybase.io/distributedlife) on keybase.
  • I have a public key ASCJL2PEj0UdLB5seNMsR_2jf_zbCUeWG_Y4D9MOl2z4IAo

To claim this, I am signing this object:

@distributedlife
distributedlife / BranchByAbstraction.jsx
Last active May 10, 2017 04:36
Feature Toggling Playbook
const MyComponent = ({ toggle, ...props }) => (
toggle ? <ComponentA {...props} /> : <ComponentB {...props} />
);
@distributedlife
distributedlife / example.js
Created February 22, 2017 00:53
React component that only provides lifecycle events
import React from 'react';
import { connect } from 'react-redux';
import { browserHistory } from 'react-router';
import makeLifecyleComponent from './lifecycle-only';
const redirectToRoot = (props) => {
if (!props.isLoggedIn) {
browserHistory.push('/');
}
};
@distributedlife
distributedlife / app.js
Created February 6, 2017 00:06
An example of a lambda using claudia.js
const ApiBuilder = require('claudia-api-builder');
const api = new ApiBuilder();
const cheerio = require('cheerio')
const fetch = require('node-fetch')
const text = (element) => element.text().trim()
const numbers = (text) => text.match(/^([0-9]+)/g)
const count = (text) => (numbers(text) && numbers(text)[0]) || 0
const followers = (text) => numbers(text)[0] || 0
@distributedlife
distributedlife / DataDrivenLogic.js
Last active February 2, 2017 10:28
A crack at data-driven action dispatch using react(native) and redux
import { makeDataDriven } from './DataDriven';
import { findSpecifiedGameOrLatest, getBowlingTeam, findCurrentInnings } from '../util/queries';
import { setField } from '../actions/field';
import { bowlOver, endOfOver } from '../actions/bowling';
const isAI = (team) => team.type === 'AI';
const mapDispatchToProps = {
setField,
bowlOver,
@distributedlife
distributedlife / react-loading-error-async.es6
Created January 4, 2017 04:16
A react component example that shows loading while an async action is in progress, an error if the promise is rejected and the true component if everything works out for the best
class ExampleComponent extends React.Component {
constructor(props) {
super(props);
this.state = { error: false };
}
componentWillMount() {
const { asyncAction, id, loading } = this.props;
@distributedlife
distributedlife / ensemble-demo.js
Last active September 20, 2016 09:09
a very small ensemble demo
import define from 'ensemblejs/lib/define';
import { on } from 'ensemblejs/lib';
const bel = require('bel');
define('StateSeed', () => ({
game: {
space: 0,
continuous: 0,
}
}));
const validate = (data, callback) => {
if (!data.email) {
Promise.reject({ email: 'Useful validation message here.'})
}
callback(data);
}
class MyForm extends Component {
constructor() {