https://twitter.com/scribblingon/status/823195512182636544
https://www.infoq.com/presentations/Simple-Made-Easy
| { | |
| "presets": ["react-native"], | |
| "plugins": ["transform-decorators-legacy"] | |
| } |
| if(process.env.NODE_ENV !== 'production') { | |
| sequelize.sync({force: true}).then(() => { | |
| // Some sample projects | |
| var projects = { | |
| data: [ | |
| { | |
| name: 'Kitchen', | |
| }, { | |
| name: 'Bathroom', |
| import myDatabaseSchema from './myDatabaseSchema'; | |
| import runDBMigrations from './myMigrations'; | |
| const schemaHash = hash(myDatabaseSchema); | |
| const lastSchemaHash = localStorage.getItem('lastSchemaHash'); | |
| if(lastSchemaHash !== null && lastSchemaHash !== schemaHash) { | |
| localStorage.setItem('lashSchemaHash', schemaHash); | |
| console.log('schema changed! the world was deleted!'); | |
| runDBMigrations(lastSchemaHash, schemaHash); |
| import React, { Component } from 'react'; | |
| import ReactDOM from 'react-dom'; | |
| /** | |
| * Use case: audio player with dynamic source in react | |
| * | |
| * Usage: | |
| * <AudioPlayerDOM src={this.state.currentFile}/> | |
| * | |
| * Todo: make a better api, actually pass props through | |
| * Todo: use children instead of passing |
| // TURNS OUT NOT ALWAYS | |
| const name = "Jim"; | |
| name = "James"; // error cannot mutate constants | |
| const age = 1; | |
| age = 2; // Error | |
| const active = true; | |
| active = false // error |
In Terminal, execute these to create an empty project:
mkdir myproject
cd myproject
git init
npm init --yes
npm install -g testcafe
npm install --save-dev chai
| // THIS ONE HAS UNEXPECTED RESULTS! | |
| // BILL AND JIMS GARAGES ARE THE SAME! WHAT?! | |
| var billsGarage = []; | |
| // Someone stole a car, store it in the garage | |
| function storeCarInGarage(myGarage, car) { | |
| // At the end of the day, the car that was stolen | |
| // should be stored in my garage |
| function getFractionString(numerator, denomenator) { | |
| // if we can divide the numerator and the denomenator | |
| // by the highest possible number without a remainder | |
| if ( (numerator % denomenator) === 0 ) { | |
| console.log('denomenator goes into numerator evenly'); | |
| return numerator/denomenator; | |
| } else { | |
| console.log('denomenator does not go in evenly'); | |
| return Math.floor(numerator/denomenator) + " " + numerator % denomenator + "/" + denomenator | |
| } |
| /** | |
| * Find the largest power of two below the given num | |
| */ | |
| function maxPow2Below(num){ | |
| return Math.pow(2, Math.floor(Math.log(num)/Math.log(2))); | |
| } | |
| /** | |
| * Create an empty bracket given a number of teams entering the round | |
| * This will prefer acheiving a square bracket by taking remainders |