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
// render the given branch, which is specified by its startingPoint, length, and angle | |
// If there are more branches to grow, grow randomly to the left and right | |
function growBranch({ startingPoint, length, angle, remainingBranches }) { | |
endingPoint = computeEndpoint({ startingPoint, length, angle }); | |
renderBranch({ startingPoint, endingPoint }); | |
const newRemainingBranches = remainingBranches - 1; | |
if (newRemainingBranches <= 0) { | |
// Return the endingPoint immediately: we know the end of this branch. | |
// We return this as a promise that can be resolved immediately so |
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
// render the given branch, which is specified by its startingPoint, length, and angle | |
// If there are more branches to grow, grow randomly to the left and right | |
function growBranch({ startingPoint, length, angle, remainingBranches }) { | |
endingPoint = computeEndpoint({ startingPoint, length, angle }); | |
renderBranch({ startingPoint, endingPoint }); | |
const newRemainingBranches = remainingBranches - 1; | |
if (newRemainingBranches <= 0) { | |
return; | |
} |
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
// Link.react-test.js | |
import React from 'react'; | |
import Link from '../Link.react'; | |
import renderer from 'react-test-renderer'; | |
test('Link changes the class when hovered', () => { | |
const component = renderer.create( | |
<Link page="http://www.facebook.com">Facebook</Link> | |
); | |
let tree = component.toJSON(); |
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 colors = require('colors/safe'); | |
const path = require('path'); | |
const fs = require('fs'); | |
function captureLogs(filename) { | |
const output = path.join(BROWSER_LOGS_DIR, filename); | |
console.log(colors.red.bold('📜 capturing logs to'), output); | |
return browser.manage().logs().get('browser').then(browserLog => { | |
fs.writeFileSync(output, JSON.stringify(browserLog)); | |
}); |
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 sanitize = require('sanitize-filename'); | |
// Declared outside any describe() or context() block so that it's called after every test. | |
// this is bound by Mocha to let us have access to the current test state, so we make sure | |
// to avoid a fat-arrow function declaration here. | |
afterEach(function(){ | |
const filename = `${sanitize(this.currentTest.title.replace(/\s+/g, '-'))}-${+new Date()}`; | |
if (this.currentTest.state === 'failed') { |
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
#!/bin/bash | |
set -ex | |
google-chrome --version | |
wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add - | |
sudo sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' | |
sudo apt-get update | |
sudo apt-get --only-upgrade install google-chrome-stable | |
google-chrome --version |
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
#!/bin/bash | |
echo "Waiting for servers to start..." | |
while true; do | |
curl -f http://localhost:8000/health > /dev/null 2> /dev/null | |
if [ $? = 0 ]; then | |
echo "Frontend started" | |
curl -f http://localhost:3000/health > /dev/null 2> /dev/null | |
if [ $? = 0 ]; then |
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
dependencies: | |
cache_directories: | |
- client-cache | |
- service-cache | |
post: | |
- bash scripts/get-latest-chrome.sh | |
- bash scripts/run-client.sh: | |
background: true |
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 original = [0,1,2,3]; | |
const copy = Object.assign([], original, { 2: 42 }); // [0,1,42,3] | |
console.log(original); | |
// [ 0, 1, 2, 3 ] | |
console.log(copy); | |
// [ 0, 1, 42, 3 ] |
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 WhySoManyProps(props) { | |
const user = extractUser(props); | |
const fudge = calculateFudge(); | |
const bits = computeBits(); | |
// This is soooooo redundant. | |
return <SomeComponent user={user} fudge={fudge} bits={bits} />; | |
} | |
function Shorthand(props) { |