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, {Component} from 'react'; | |
| import differenceInSeconds from 'date-fns/difference_in_seconds'; | |
| import distanceInWordsToNow from 'date-fns/distance_in_words_to_now'; | |
| class TimeAgo extends Component { | |
| componentDidMount() { | |
| if (this.props.isLive) { | |
| this.updateTime(); | |
| } |
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
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <script src="https://cdnjs.cloudflare.com/ajax/libs/immutable/3.7.3/immutable.min.js"></script> | |
| <script src="https://cdn.jsdelivr.net/lodash/4/lodash.min.js"></script> | |
| <script src="http://fb.me/react-0.13.1.js"></script> | |
| <meta charset="utf-8"> | |
| <title>React Hello World w/ JSBin</title> | |
| <style id="jsbin-css"> | |
| .imgs-grid { |
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
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <script src="https://cdnjs.cloudflare.com/ajax/libs/immutable/3.7.3/immutable.min.js"></script> | |
| <script src="https://cdn.jsdelivr.net/lodash/4/lodash.min.js"></script> | |
| <script src="http://fb.me/react-0.13.1.js"></script> | |
| <meta charset="utf-8"> | |
| <title>React Hello World w/ JSBin</title> | |
| <style id="jsbin-css"> | |
| .imgs-grid { |
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
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <script src="https://cdnjs.cloudflare.com/ajax/libs/immutable/3.7.3/immutable.min.js"></script> | |
| <script src="https://cdn.jsdelivr.net/lodash/4/lodash.min.js"></script> | |
| <script src="http://fb.me/react-0.13.1.js"></script> | |
| <meta charset="utf-8"> | |
| <title>React Hello World w/ JSBin</title> | |
| <style id="jsbin-css"> | |
| .imgs-grid { |
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'; | |
| export default function requireAuth(WrappedComponent) { | |
| class AuthenticatedComponent extends React.Component { | |
| componentDidMount() { | |
| this.checkAuth(this.props.isLoggedIn); | |
| } | |
| checkAuth(isLoggedIn) { |
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
| function fizzbuzz(num) { | |
| let returnValue = ''; | |
| let isFizz = num % 3 === 0; | |
| let isBuzz = num % 5 === 0; | |
| returnValue = (isFizz ? 'Fizz' : '') + (isBuzz ? 'Buzz' : ''); | |
| if (returnValue !== '') { | |
| console.log(returnValue + ' - ' + num); |
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
| function solution(A) { | |
| let arr = [1]; | |
| while (arr[arr.length - 1] < A) { | |
| let prev = arr[arr.length - 1]; | |
| let next = prev * 2; | |
| if (next > A) { | |
| prev = arr[arr.length - 2] + 1; |
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
| function solution(A) { | |
| const rep = (A >>> 0) | |
| .toString(2) | |
| .split(1) | |
| .filter(x => x !== "") | |
| .sort(function(a, b) { | |
| return b.length - a.length; | |
| }); | |
| return rep.length === 0 ? 0 : rep[0].length; |
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
| function solution(x, y, d) { | |
| const afterFirstJump = (85 - 10); | |
| if (afterFirstJump % d == 0) { | |
| return Math.floor(afterFirstJump / d); | |
| } | |
| return Math.floor(afterFirstJump / d + 1); | |
| } |
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
| function solution(A) { | |
| var min = 1; | |
| A.sort(function(a,b){ | |
| return a - b; | |
| }); | |
| for (var i in A) { | |
| if (A[i] > -1 && A[i] === min) { | |
| min++; |