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
/** | |
Given two sorted arrays, merge them into one big sorted array | |
Ex: | |
merge([1,3,5],[2,4,6]) | |
returns [1,2,3,4,5,6] | |
You cannot use array.sort(). | |
Try to solve this in O(n+m) runtime. | |
Where n is the length of the first array | |
and m is the length of the second array. |
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
./node_modules/.bin/prettier --single-quote --trailing-comma all --write "{,!(node_modules)/**/}*.js" |
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 foo(a) { | |
return a() | |
} | |
function bar(a) { | |
return 1 | |
} | |
// I am passing bar in to foo. bar is a callback function to foo | |
function woof() { |
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 map(arr, func) { | |
return arr.map(func); | |
} | |
// IF you are super particular about ordering | |
function parseCSV(csv) { | |
var peopleArray = csv.split('\n'); | |
var peopleArrayWithSplitNameElements = map(peopleArray, function(str){ | |
return str.split(','); | |
}) |
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 Form extends React.Component { | |
state = { | |
addressLineOne: '', | |
}; | |
addressLineOneOnChange = addressLineOne => this.setState({ addressLineOne }); | |
addressLineOneOnBlur = () => console.log('on blur'); | |
render() { | |
const { addressLineOne } = this.state; | |
return ( | |
<TextValidator |
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
alias bashdir='cd ~' | |
alias prof='code ~/.bash_profile' | |
alias cassandra='cd ~/Documents/apache-cassandra-3.11.3/bin && ./cassandra' | |
alias ms='cd ~/ONEHOPEWINE/microservice' | |
alias hc='cd ~/ONEHOPEWINE/hopecommerce' | |
alias devWatch='hc && npm run relayWatch' | |
alias devApp='hc && npm run dev-a' | |
alias devGQL='hc && npm run dev-g' | |
alias msDev='ms && npm run dev' |
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
/** | |
* Can you explain splice for me? I know what it is, | |
* but there aren't many example to use it so I don't understand | |
* everything that goes inside the parentheses | |
*/ | |
/** | |
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/splice | |
* Array.splice(x,y) |
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 { commitMutation, graphql } from 'react-relay'; | |
import { ConnectionHandler } from 'relay-runtime'; | |
const mutation = graphql` | |
mutation ProductReviewAddMutation($input: CreateProductReviewInput!) { | |
productReviewAdd(input: $input) { | |
user { | |
id | |
role | |
productReviews { |
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 Relay from 'react-relay/classic'; | |
export default class ProductReviewAddMutation extends Relay.Mutation { | |
static fragments = { | |
user: () => Relay.QL` | |
fragment on User { | |
id, | |
role, | |
} | |
`, |
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
/* | |
Given a graph of nodes, find the shortest path. | |
The nodes can potentially be circular. | |
*/ | |
const visitedNodeBefore = (visitedList, currentNode) => | |
visitedList.find(visitedNode => visitedNode.value === currentNode.value); | |
const getDestinationNode = (currentNode, nodeDestination) => | |
currentNode.nextNodes.find(({ node }) => node === nodeDestination); |