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
const moment = require('moment') | |
const momentTz = require('moment-timezone') | |
const getWeek = (timestamp, stage) => { | |
// Use momentjs to get number of weeks since start of stage | |
return ' ??? ' | |
} | |
const getOpponent = competitors => { |
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
// How do I initialize state when I do *NOT* want to use hard-coded values? | |
// in MyComponent.js ... | |
const mapStateToProps = (state, ownProps) => { | |
return { | |
usernames: state.MyComponent.usernames, | |
selectedDesserts: state.MyComponent.selectedDesserts || ownProps.availableDesserts | |
}; | |
}; |
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
.foo { | |
margin: 10px; | |
} | |
.banner { | |
padding: 10px; | |
text-align: center; | |
} | |
.error { |
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
// See this blog post for full explanation: | |
// https://rebootjeff.github.io/blog/2015/12/11/example-refactoring-to-functional-js-combine-keyed-lists/ | |
// Dependencies | |
var _ = require('lodash'); | |
var R = require('ramda'); | |
// Example input | |
var usersBySocialNetwork = { | |
twitter: [ |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<style> | |
body, h1, p { | |
border: 2px solid red; | |
} | |
h1, p { | |
margin: 10px; |
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
function makeConverter(pairs) { | |
function converter(value) { | |
for(var i = 0; i < pairs.length; i++) { | |
var predicate = pair[0]; | |
var func = pair[1]; | |
if(predicate(value)) { | |
return converter(func(value)); | |
} |
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
// ============================================================================= | |
// Example for unit testing an async func that doesn't already support promises | |
var Q = require('q'); // You must do `npm install q` first | |
// Async function that uses callbacks instead of promises | |
function authenticate(dataToSubmit, callback) { | |
// blah blah blah | |
} |