This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import randomString from 'random-string'; | |
import Uuid from 'node-uuid'; | |
import {couchUpdate, couchSave, couchView, couchDesignDoc} from '../helpers/couch'; | |
const TYPE = 'Location'; | |
export const save = (location) => { | |
return couchSave(Uuid.v4(), { | |
type: TYPE, | |
address: location.address, | |
postcode: location.postcode, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var LCD = require('jsupm_i2clcd'); | |
var myLcd = new LCD.Jhd1313m1 (0, 0x3E, 0x62); | |
var messages = [['Old Mc Donald', 'Had A farm', [18,239,99]], | |
['Eee I Eee I Oh', 'an on that farm he had a ', [18,239,99]], | |
['DUck', 'There a quack everwhere a quack quack', [18,239,99]]]; | |
var pos = 0; | |
setInterval(function() { | |
var message=messages[pos]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requestOnLoad from 'request-on-load'; | |
const {myApiRequest} from '../ApiClient'; | |
| |
class MyComponent extends React.Component { | |
| |
componentWillMount() { | |
this.props.request(() => myApiRequest()); | |
} | |
| |
return ( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
export NOHGHOOK=true | |
TO="$1" | |
SEMVER_ACTION="$2" | |
FROM="$(hg branch)" | |
echo "promoting $FROM to $TO" | |
if [[ "$TO" == "qa" ]] || [[ "$TO" == "uat" ]] || [[ "$TO" == "default" ]]; then | |
if [[ "$SEMVER_ACTION" == "major" ]] || [[ "$SEMVER_ACTION" == "minor" ]] || [[ "$SEMVER_ACTION" == "patch" ]]; then | |
npm version $SEMVER_ACTION | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
rm -rf views containers components | |
mkdir views && cd views | |
react-docgen ../../src/views/ --resolver findAllComponentDefinitions --ignore test | ../buildDocs && cd .. | |
mkdir containers && cd containers | |
react-docgen ../../src/containers/ --resolver findAllComponentDefinitions --ignore test | ../buildDocs && cd .. | |
mkdir components && cd components | |
react-docgen ../../src/components/ --resolver findAllComponentDefinitions --ignore test | ../buildDocs && cd .. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Utility method to create a reducer from a map, | |
* with initial state | |
* @param initialState | |
* @param reducerMap | |
* @returns {Function} | |
*/ | |
export default function createReducer(initialState, reducerMap) { | |
return (state = initialState, action) => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import compose from 'recompose/compose'; | |
import EventEmitter from 'event-emitter'; | |
const combineReducers = reducersMap => { | |
const arrayOfReducers = Object.keys(reducersMap) | |
.reduce((acc, r) => [...acc, reducersMap[r]], []); | |
return compose.apply(null, arrayOfReducers); | |
} | |
const dispatch = reducers => action => reducers(action); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
yarn add webpack@^2 babel-core babel-loader babel-preset-react babel-preset-stage-2 prettier eslint@^3 react@^15 react-dom@^15enzyme nightmare jest eslint-config-prettier prettier-eslint-cli styled-components --dev && git init && git ignore-io node && echo '{"extends":"prettier"}' > .eslintrc && echo '{"presets": ["stage-2", "react"]}' > .babelrc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { compose, pure } from 'recompose' | |
import { Component } from 'react' | |
import Radium from 'radium' // great styling library! I | |
// I'd also consider styled-components now its really neat and much more react style | |
/** for example purposes we've got some other components that are not defined, | |
I've added a spinner which would render a CSS animation in place of the table. | |
I've got a Button comonent which renders the styled buttons we have in the screenshot, they could have clicks attached. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require('dotenv').config(); | |
const { GraphQLClient } = require('graphql-request'); | |
const client = new GraphQLClient(process.env.ENDPOINT, { headers: { | |
'Authorization': `Bearer ${process.env.ACCESS_TOKEN}` | |
}}); | |
const query = T => ` | |
query Get${T}s { | |
all${T}s { | |
id |