This file contains 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 charactersCounter { | |
constructor(input) { | |
this.inputArr = input.split(''); | |
this.availableLetters = [...new Set(this.inputArr)]; | |
this.mostPopular = { | |
letter: '', | |
amount: 0 | |
} | |
} | |
This file contains 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 sleep = ms => new Promise(resolve => setTimeout(resolve, ms)); | |
setTimeout(() => console.log('1200ms elapsed'), 1200); | |
const foo = () => { | |
let intervalId; | |
const intervalFunction = async() => { | |
clearInterval(intervalId); //clear so it will not execute again after 100ms | |
console.log('interval executed'); | |
await sleep(120); //some long action |
This file contains 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 sleep = require('./utilities/sleep'); | |
const mySetInterval = (callback, ms, ...args) => { | |
let token = { | |
cancelled: false | |
}; | |
let id = setInterval((...args) => { | |
callback(token, ...args); | |
}, ms, ...args); | |
return function cancel() { |
This file contains 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 getPixels = require("get-pixels"); | |
//1px only black https://i.imgur.com/dStJ1Og.png | |
//2px only black https://i.imgur.com/5z46WVp.png | |
//88x62px only black https://i.imgur.com/ZtGMUh9.png | |
//88x62px black and red https://i.imgur.com/67IZCaD.png | |
//220x297px black and red https://i.imgur.com/KTNnJGF.jpg | |
function check(uintArr) { | |
let r = uintArr[0], g = uintArr[1], b = uintArr[2], a = uintArr[3]; | |
for (let i = 0, l = uintArr.length; i < l; i += 4) { |
This file contains 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 getPixels = require("get-pixels"); | |
//1px only black https://i.imgur.com/dStJ1Og.png | |
//2px only black https://i.imgur.com/5z46WVp.png | |
//88x62px only black https://i.imgur.com/ZtGMUh9.png | |
//88x62px black and red https://i.imgur.com/67IZCaD.png | |
//220x297px black and red https://i.imgur.com/KTNnJGF.jpg | |
//3000x4000px black with red dot(1px) https://i.imgur.com/JiHtQuR.jpg | |
getPixels("https://i.imgur.com/JiHtQuR.jpg", function(err, ndarray) { |
This file contains 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
... | |
"plugins": [ | |
[ | |
"@electron-forge/plugin-webpack", | |
{ | |
"mainConfig": "./webpack.main.config.js", | |
"renderer": { | |
"config": "./webpack.renderer.config.js", | |
"entryPoints": [ | |
{ |
This file contains 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
// #bluebird, #bluebird-retry, #bluebird-cancellation, #eventBus | |
const Promise = require('bluebird'); | |
const retry = require('bluebird-retry'); | |
const eventBus = require('js-event-bus')(); | |
Promise.config({warnings: true, longStackTraces: true, cancellation: true, monitoring: true}); | |
//promise child function | |
const child = () => { | |
return new Promise((resolve, reject, onCancel) => { |
This file contains 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
// this is simple 1 file 1 route app; | |
// #bluebird, #bluebird-retry, #bluebird-cancellation, #eventBus | |
// use bluebird retry for 4s; after 1.5s through eventBus invoke bluebird-cancellation which should stop bluebird-retry as well | |
const express = require('express'); | |
const app = express(); | |
const path = require('path'); | |
const bodyParser = require('body-parser'); | |
app.use(bodyParser.json()); |
This file contains 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
// this is simple 1 file 1 route, | |
// app with cancellation of promise with bluebird library | |
// | |
// canellation of promise which have interval also stopping interval with onCancel | |
const express = require('express'); | |
const app = express(); | |
const path = require('path'); | |
const bodyParser = require('body-parser'); | |
const Promise = require('bluebird'); |
This file contains 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
'use strict' | |
const chalk = require('chalk') | |
const electron = require('electron') | |
const path = require('path') | |
const { say } = require('cfonts') | |
const { spawn } = require('child_process') | |
const webpack = require('webpack') | |
const WebpackDevServer = require('webpack-dev-server') | |
const webpackHotMiddleware = require('webpack-hot-middleware') |
NewerOlder