Skip to content

Instantly share code, notes, and snippets.

View samcorcos's full-sized avatar

Sam Corcos samcorcos

View GitHub Profile
"scripts": {
"start": "node server.js",
"test": "mocha test/ --recursive"
}
"scripts": {
"test": "sh test.sh",
"watch": "sh watch.sh",
"cover": "sh cover.sh",
"deploy": "sh deploy.sh",
"build": "sh build.sh"
}
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
@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,
}
}
@samcorcos
samcorcos / local_control_native.jsx
Created February 24, 2017 01:07
React native local control
import React from 'react'
import { View, TextInput, } from 'react-native'
export class Form extends React.PureComponent {
constructor(props) {
super(props)
this.state = {
input1: null,
input2: null,
}
// Reducer.js
const initialState = {
user: {
email: null,
name: null,
},
myForm: { // define our form in advance
input1: null,
input2: null,
},
import React, { Component } from 'react';
import {
StyleSheet,
Text,
View,
} from 'react-native';
import Camera from 'react-native-openalpr';
const styles = StyleSheet.create({
container: {
let containerId
module.exports.hello = (event, context, callback) => {
if (!containerId) containerId = context.awsRequestId
console.log(containerId)
callback(null, {
statusCode: 200,
body: JSON.stringify({
@samcorcos
samcorcos / california.js
Created April 22, 2017 00:20
California Cities Hash Map
const california = {
'acalanes-ridge':
{ name: 'Acalanes Ridge',
id: 'acalanes-ridge',
stateAbbr: 'CA',
state: 'California' },
acampo:
{ name: 'Acampo',
id: 'acampo',
stateAbbr: 'CA',