Skip to content

Instantly share code, notes, and snippets.

View samcorcos's full-sized avatar

Sam Corcos samcorcos

View GitHub Profile
@samcorcos
samcorcos / local_control.jsx
Created February 24, 2017 01:01
Locally controlled react form
import React from 'react'
export class Form extends React.PureComponent {
constructor(props) {
super(props)
this.state = {
input1: null,
input2: null,
}
}
class MockDynamoDB {
constructor() {
this.tables = {}
}
get(params, callback) {
/** if table does not exist, return with an error */
if (!this.tables[params.TableName]) callback({ message: 'no items in table', }, null)
else {
const key = Object.keys(params.Key)[0] // e.g. user_id
"scripts": {
"test": "sh test.sh",
"watch": "sh watch.sh",
"cover": "sh cover.sh",
"deploy": "sh deploy.sh",
"build": "sh build.sh"
}
"scripts": {
"start": "node server.js",
"test": "mocha test/ --recursive"
}
"scripts": {
"start": "node server.js",
"cover": "nyc -x '**/*spec.js' -n 'app' -r text -r html -r lcov npm test",
"test": "mocha --compilers js:babel-register -r babel-polyfill -r whatwg-fetch -r jsdom-global/register -r .test-setup.js -R spec app/**/spec.js app/**/*spec.js app/redux/actions/*spec.js",
"test:watch": "npm test -- --watch",
"prodbuild": "webpack -p --config ./webpack.prod.config.js"
},
import React from 'react'
import { View, Text, TouchableOpacity, } from 'react-native'
import style from './style'
const pipe = (fns, init) => fns.reduce((acc, fn) => fn(acc), init)
const monthLabels = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']
const getDaysInMonth = (month, year) => {
if (month === 1) {
export const makes = {
"makes": [{
"id": "279a091a-32c1-46c7-80d2-b3423320f18f",
"name": "AM General"
}, {
"id": "72cadfa6-e1c0-4507-9bdd-835f93951dd6",
"name": "Acura"
}, {
"id": "02a97e0d-eb73-48e3-898a-567a3c81c0ee",
"name": "Alfa Romeo"
const formatData = data => {
// We're sorting by alphabetically so we need the alphabet
const alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.split('');
// Need somewhere to store our data
const dataBlob = {};
const sectionIds = [];
const rowIds = [];
// Each section is going to represent a letter in the alphabet so we loop over the alphabet
@samcorcos
samcorcos / file.js
Last active November 8, 2016 23:31
simple structure
const makesModels = {
"Acura": {
"ILX": {
"years": [
2016,
2015,
2014,
2013,
2012
]