A Pen by Artur Sedlukha on CodePen.
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
| { | |
| "parser": "@typescript-eslint/parser", | |
| "parserOptions": { | |
| "ecmaFeatures": { "jsx": true }, | |
| "ecmaVersion": 2018, | |
| "sourceType": "module" | |
| }, | |
| "extends": [ | |
| "airbnb", | |
| "prettier", |
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
| func Reduce(arr, reduceFunc, acc interface{}) float64 { | |
| arrValue := redirectValue(reflect.ValueOf(arr)) | |
| if !IsIteratee(arrValue.Interface()) { | |
| panic("First parameter must be an iteratee") | |
| } | |
| returnType := reflect.TypeOf(Reduce).Out(0) | |
| isFunc := IsFunction(reduceFunc, 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
| const path = require('path'); | |
| const webpack = require('webpack'); | |
| const UglifyJsPlugin = require('uglifyjs-webpack-plugin'); | |
| module.exports = { | |
| entry: "./src/index.tsx", | |
| output: { | |
| path: path.resolve(__dirname, '../public'), | |
| filename: "bundle.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
| const path = require('path'); | |
| const UglifyJsPlugin = require('uglifyjs-webpack-plugin'); | |
| module.exports = { | |
| entry: './src/index.js', | |
| output: { | |
| path: path.resolve(__dirname, '../public'), | |
| filename: 'bundle.js', | |
| }, | |
| devtool: 'source-map', |
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 nominals = ['BTC', 'ETH', 'USD']; | |
| const timeIntervals = ['1m', '5m', '15m', '1h', '4h', '1d']; | |
| const loadingResult = await Promise.all(nominals.map( | |
| (nominal, nominalKey) => Promise.all(timeIntervals.map( | |
| (interval, intervalKey) => models[`Price${interval + nominal}`] | |
| .bulkCreate(comparedSplittedPrices[nominalKey][intervalKey]), | |
| )), | |
| )); |
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 timingWrapper = <T>(fn: Function, ms: number): Promise<T> => new Promise( | |
| resolve => setTimeout( | |
| async () => resolve(await fn()), | |
| ms, | |
| ), | |
| ); | |
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 compose = (...args) => (...currentArgs) => { | |
| let result = args[0](...currentArgs) | |
| for (let i = 0; i < currentArgs.length; i++) { | |
| result = args[i + 1](result) | |
| } | |
| return result | |
| } |
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
| // HEX to RGB function | |
| const hexToRgb = hex => | |
| hex.replace(/^#?([a-f\d])([a-f\d])([a-f\d])$/i, (m, r, g, b) => `#${r + r + g + g + b + b}`) | |
| .substring(1) | |
| .match(/.{2}/g) | |
| .map(x => parseInt(x, 16)) | |
| // Determine relation of luminance in color | |
| const luminance = (r, g, b) => { | |
| const a = [r, g, b].map((v) => { |
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 grabStage(e) { | |
| const stage = document.getElementById('large-stage-container') | |
| const { layerX: endX, layerY: endY } = e | |
| const { x: startX, y: startY } = window.grabCoords // this coords are coords from the event.layer(X-Y) and we got them while first mousedown on stage | |
| const distance = { x: Math.abs(endX - startX), y: Math.abs(endY - startY) } | |
| if (!distance.x && !distance.y) return | |
| const direction = { | |
| x: (endX < startX) ? 'right' : 'left', | |
| y: (endY < startY) ? 'down' : 'up', | |
| } |
NewerOlder