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
# Make sure to export EDITOR in your .bashrc as either vim or nano. | |
# Make sure to install vipe (npm i -g juliangruber/vipe) | |
# Make sure to install hub (brew install hub) | |
# Don't forget to add your PR title as the first block | |
alias pr="cat .github/PULL_REQUEST_TEMPLATE.md | vipe | hub pull-request -b develop -F -" |
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 List = require('./list'); | |
const l = new List(50); | |
// setup | |
for (let i = 0; i < 50; i++) { | |
l.set(i, i); | |
} | |
console.log(l.get(5) === 5); |
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 getPrivateContainer = () => { | |
const privateProperties = new WeakMap(); | |
const getPrivate = (instance, prop) => { | |
if (!privateProperties.has(instance)) { | |
privateProperties.set(instance, {}); | |
} | |
return privateProperties.get(instance)[prop]; | |
}; | |
const setPrivate = (instance, prop, value) => { | |
if (!privateProperties.has(instance)) { |
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 _ from 'lodash'; | |
import { ObjectId } from 'mongoose'; | |
import ensureObjectId from './utils'; | |
exports default function ensureObjectIdProps(obj, paths) { | |
paths.forEach(prop => { | |
const currentValue = _.get(obj, prop); | |
_.set(obj, prop, currentValue ? ensureObjectId(currentValue) : new ObjectId()); | |
}); | |
return obj; |
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 { withRouter, Route } from 'react-router-dom'; | |
const RelativeRoute = ({ match, path, ...props }) => <Route path={`${match.path}${path}`} {...props} />; | |
export default withRouter(RelativeRoute); |
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 composeMiddleware(...middleware) { | |
return (req, res, next) => middleware | |
.reverse() | |
.reduce( | |
(next, mw) => | |
() => mw(req, res, next), | |
next | |
)(); | |
} |
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 { observable, action } from "mobx"; | |
import { inject, Provider, observer } from "mobx-react"; | |
import "./App.css"; | |
declare module "mobx-react" { | |
type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>; | |
type Diff<MasterObject extends SubObject, SubObject extends Object> = Omit< | |
MasterObject, |
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
alert(); |
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 blackBox() { | |
var input = [0, 1, 2, 3, 4]; | |
var results = []; | |
for (var i = 0; i < input.length; i++) { | |
results.push( | |
new Promise(function(resolve) { | |
setTimeout(function() { | |
resolve(i); | |
}, 200); | |
}) |
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, { | |
useState, | |
useCallback, | |
useLayoutEffect, | |
createContext, | |
useContext, | |
useMemo, | |
} from 'react'; | |
import qs from 'qs'; | |
import { useLocation, useHistory } from 'react-router-dom'; |