const Promise = require('bluebird');
const batch = async (args, callback, options = {}) => {
const { max = 2 } = options;
const results = [];
let running = args.slice(0, max).map(a => callback(...a));
let picked = running.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
| import { useState } from 'react' | |
| const useRandom = (min = 0, max = Number.MAX_SAFE_INTEGER) => { | |
| const [value, setValue] = useState(undefined) | |
| const rand = () => { | |
| setValue(Math.floor(Math.random() * max) + min) | |
| } | |
| if (value === undefined) rand() |
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 withMouseTracker from './withMouseTracker' | |
| class Timeline extends Component { | |
| render() { | |
| console.log(this.props.mouseTracker) | |
| return ( | |
| <div | |
| className="timeline" | |
| ref={this.props.trackerRef} |
Upgrade all dependencies to the latest version within you workspace
yarn upgrade-interactive --latest
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 update = (entity, delta) => { | |
| const { body } = entity | |
| // move using `setPosition` and scale it with time since `setVelocity` doesn't scale with time (yet ?) | |
| Body.setPosition( | |
| body, | |
| Vector.add( | |
| body.position, | |
| Vector.mult( | |
| { x: 1, y: 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
| /* eslint-env jest */ | |
| // init avec default data | |
| // 100 SET d'un tableau de 1000 | |
| // 100 ADD | |
| // 100 UPDATE | |
| // 100 ADD_OR_UPDATE | |
| // 100 REMOVE | |
| // <time> | |
| // 1000 de chaque selector | |
| const { keyValue } = require('.') |
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
| git branch -vv | awk '{print $1}' | grep -v HEAD | grep -v master | grep -v '*' | xargs git branch -d --force |
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 crypto = require('crypto') | |
| const toMD5 = object => crypto.createHash('md5').update(JSON.stringify(object)).digest('hex') | |
| module.exports = ({ | |
| timeout = (/* 1 h */ 1 * 60 * 60 * 1000), | |
| maxEntries = 100, | |
| name = 'cache', | |
| log = console.log, | |
| } = {}) => { |
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
| git branch -vv | awk '{print $1}' | grep -Ev 'HEAD|master|*' | xargs git branch -d --force |
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 getKey = args => JSON.stringify(args) | |
| const callAndSave = cache => callback => async (...args) => { | |
| const value = await callback(...args) | |
| cache[getKey(args)] = { // eslint-disable-line no-param-reassign | |
| timestamp: Date.now(), | |
| value, | |
| } |
NewerOlder