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
/* | |
* Debounce a function | |
* | |
* Given a function and a delay in milliseconds create a way to debounce the given function so that, | |
* as long as it continues to be invoked, will not be triggered. | |
* The function will be called after it stops being called the given delay. | |
* | |
*/ | |
const debounce = (fn, delay) => { |
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
/* | |
* Two Sum | |
* | |
* Given an array of integers, return indices of the two numbers | |
* such that they add up to a specific target. | |
* | |
* You may assume that each input would have exactly one solution, | |
* and you may not use the same element twice. | |
* | |
* Example: |
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 compat(arr) { | |
const compatMap = new Map(); | |
arr.forEach(tuple => { | |
const tupleToCompat = compatMap.get(tuple[0]); | |
if (tupleToCompat) { | |
compatMap.set(tuple[1], tupleToCompat.concat(tuple[1])); | |
compatMap.delete(tuple[0]); | |
} else { | |
compatMap.set(tuple[1], tuple); |
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 characteristic of a shifted sorted array | |
// is that if you brake it into two halves, | |
// at LEAST ONE half is ALWAYS going to be sorted: | |
// 4 5 6 [7] 0 1 2 -> left side is sorted | |
// 6 7 0 [1] 2 4 5 -> right side is sorted | |
// ... | |
// 5 6 7 [0] 1 2 4 -> both side sorted (pivot === shift) | |
// This means we can use this informatin to apply a BST strategy without having to look for the pivot |
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 http = require('http'); | |
const url = require('url'); | |
const querystring = require('querystring'); | |
const oc = require('oc'); | |
const client = new oc.Client({ | |
registries: { | |
clientRendering: 'http://localhost:3000/', | |
serverRendering: 'http://localhost:3000/' | |
} |
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 styles from './map.css'; | |
import GoogleMap from './google-map'; | |
import mapData from '../../test/geo.json'; | |
export function Map(props) { | |
let map = ( | |
<GoogleMap | |
markerData={mapData.features} | |
centerPoint={{ lat: 0, lng: 0 }} |
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 styles from './map.css'; | |
import GoogleMap from './google-map'; | |
import mapData from '../../test/geo.json'; | |
export function Map(props) { | |
let map = ( | |
<GoogleMap | |
markerData={mapData.features} | |
centerPoint={{ lat: 51.5285, lng: -0.0847 }} |
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 xs from 'xstream'; | |
const model = action$ => { | |
const reducer = (state = 0, action) => { | |
switch(action.type) { | |
case 'INCREASE': | |
return state + 1 | |
case 'DECREASE': | |
return state - 1 | |
default: |
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 reducer, { types, actions, cycle } from './user' | |
describe('actions', () => { | |
// snapshot tests | |
it('should export specific action types', () => { | |
expect(types).toMatchSnapshot() | |
}) | |
it('should export specific action creators', () => { | |
expect(actions).toMatchSnapshot() | |
}) |
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 xs from 'xstream' | |
import { combineCycles } from 'redux-cycle-middleware' | |
import { push } from 'react-router-redux' | |
import { API_URL } from '../constants/api' | |
// ACTION TYPES (Format: app-name/reducer/ACTION_TYPE) | |
// ======================================================= | |
const LOGIN = 'app-name/auth/LOGIN' | |
const LOGIN_SUCCESS = 'app-name/auth/LOGIN_SUCCESS' | |
const LOGIN_FAIL = 'app-name/auth/LOGIN_FAIL' |
NewerOlder