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 flipMatrix = matrix => ( | |
matrix[0].map((column, index) => ( | |
matrix.map(row => row[index]) | |
)) | |
); | |
const rotateMatrix = matrix => ( | |
flipMatrix(matrix.reverse()) | |
); |
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 flipMatrix = matrix => ( | |
matrix[0].map((column, index) => ( | |
matrix.map(row => row[index]) | |
)) | |
); | |
const rotateMatrix = matrix => ( | |
flipMatrix(matrix.reverse()) | |
); |
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 rotateMatrix = matrix => ( | |
matrix[0].map((column, index) => ( | |
[...matrix].reverse().map(row => row[index]) | |
)) | |
); | |
const flipMatrixCounterClockwise = matrix => ( | |
rotateMatrix(matrix).reverse() | |
); |
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 flipMatrix = matrix => ( | |
matrix[0].map((column, index) => ( | |
matrix.map(row => row[index]) | |
)) | |
); |
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
.drawer { | |
position: absolute; | |
z-index: 10; | |
top: 0; | |
left: 0; | |
right: 0; | |
bottom: 0; | |
overflow: hidden; | |
.backdrop { |
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
////// Fun with ES2015 Generators & Fibonacci Sequence ////// | |
// | |
// Generators are awesome for lazy calculations, but they're less | |
// than ideal for certain use-cases (give me the result of the | |
// 1000th iteration). | |
// | |
// This is an experiment where I try to have my cake and eat it too, | |
// by wrapping a generator with a factory function. | |
// | |
//// Note: This is the comment-free version! |
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
////// Fun with ES2015 Generators & Fibonacci Sequence ////// | |
// | |
// Generators are awesome for lazy calculations, but they're less | |
// than ideal for certain use-cases (give me the result of the | |
// 1000th iteration). | |
// | |
// This is an experiment where I try to have my cake and eat it too, | |
// by wrapping a generator with a factory function. | |
// | |
//// Note: This is the annotated version! |
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
app.post('/process-upload', upload.single('image'), (req, res) => { | |
// Define some helper methods that provide semantic names to the | |
// actions in our route. | |
const resizeAndConvert = buffer => ( | |
imConvertPromise({ | |
srcData: buffer, | |
width: 32, | |
height: 16, | |
format: 'PNG' | |
}) |
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
// If the function does not take an 'errback' callback, we can still wrap our | |
// functions. Let's use a fictional method: | |
fictionalMethod(data, successCallback, failureCallback) { | |
fictionalAsyncOperation(data, result => { | |
if ( !result ) { | |
return failureCallback(new Error('Result not found')) | |
} else { | |
return successCallback(result); | |
} | |
}) |
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
class LetterDemo extends Component { | |
constructor(props) { ... } | |
componentWillMount() { ... } | |
componentWillUnmount() { ... } | |
onStart({entering, leaving}, node) { | |
if (entering) { | |
node.classList.add('enter'); |