This file contains hidden or 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
{ | |
"name": "watsonFrontendV2", | |
"version": "1.0.0", | |
"description": "Change app/views/layouts/application.html.erb before deploying. Or bad things will happen.", | |
"main": "index.js", | |
"scripts": { | |
"test": "mocha --compilers js:babel-core/register --require ./frontend/test/test_helper.js 'frontend/test/' --recursive", | |
"dev": "webpack-dev-server --config webpack.dev.js --hot --progress --inline --colors", | |
"devNoTools": "webpack-dev-server --config webpack.devNoTools.js --hot --progress --inline --colors", | |
"prod": "./node_modules/.bin/webpack -p --config webpack.prod.js", |
This file contains hidden or 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
const usersTable = (props) => { | |
const shrug = '¯\_(ツ)_/¯' | |
if (props.users) { | |
/** | |
* Returns | |
* <div>John</div> | |
* <div>Mary</div> | |
* <div>Sherry</div> | |
*/ | |
return ( |
This file contains hidden or 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 { Component } from 'react' | |
import usersTable from './usersTable' | |
import fetch from 'fetch' | |
class UserTableContainer extends Component { | |
componentDidMount() { | |
/** | |
* When component is loaded on the page, | |
* get the user list from api and mutate state. | |
*/ |
This file contains hidden or 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
//Let's say you have a function that accepts a callback, and applies that call back to each element: | |
forEach(array, callback) { | |
// loop start at 0 index, until it reaches the end of the array, one at a time | |
for(var i=0; i < array.length; i++) { | |
// at the index of that array, have it equal to the result of the callback with "the result of that index of that array" as a parameter | |
array[i] = callback(array[i]) | |
} | |
} |
This file contains hidden or 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 React from 'react'; | |
import { connect } from 'react-redux'; | |
import { | |
loadOrdersPage, | |
pageInitialized, | |
pageFinishedLoading, | |
updateSyncStatus, | |
updateFilter, | |
selectRow, | |
updateColumnSort, |
This file contains hidden or 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
// pushOne(10,[]) results in [1,2,3,4,5,6,7,8,9,10] | |
// Imperative Programming | |
function pushOne(max, indexes) { | |
while (indexes.length < max) { | |
indexes.push(indexes.length+1) | |
} | |
return indexes | |
} | |
// Functional, Declarative Programming | |
function pushOne(max, indexes) { |
This file contains hidden or 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
// basically it asks to create a function that reverse the whole string without reverse the positions of the words. | |
// "Three Blind mice" | |
// "eerhT dnilB ecim" | |
var stringToArray = function (str) { | |
return str.split(' ') | |
} | |
// ['Three', 'Blind', 'mice'] | |
var reverseElementsInArray = function (arr) { | |
return arr.map(function(element) { |
This file contains hidden or 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
/** A frog can jump on an array of lilypads that is dropped into the river in seconds according the index. | |
* Given [10,5,8]. A lilypad 10cm away from start drops at 0 seconds, | |
* then a pad 5cm away from start drops 1 second from start, | |
* then one 8cm away from start drops in 2 seconds from start | |
* The function takes an array of lilypads, how far the frog can jump, and how wide the river is. | |
* How much time does it take for the frog to get to the other side of the river? | |
* If the frog can't cross the river, return -1 | |
* Otherwise, return the seconds it takes for the frog to cross. | |
*/ |
This file contains hidden or 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
// It was basically with a set of numbers in an array | |
// Give back a count of numbers with the most frequent numbers that are the same | |
// superoptimized version | |
var numberSet = function (set) { | |
var counts = {}; | |
var highestCount = 0; | |
var numbers = []; |
This file contains hidden or 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
Show hidden characters
{ | |
"plugins": ["babel-relay-plugin-loader"], | |
"presets": ["react", "es2015", "stage-0"], | |
"passPerPreset": true, | |
"env": { | |
"development": { | |
"plugins": [ | |
["react-transform", { | |
"transforms": [{ | |
"transform": "react-transform-hmr", |