Skip to content

Instantly share code, notes, and snippets.

View krasnoperov's full-sized avatar
🎯
Focusing

Aleksei Krasnoperov krasnoperov

🎯
Focusing
View GitHub Profile
@beshkenadze
beshkenadze / errors_monitoring_service.md
Last active August 29, 2015 14:23
Compare the services to collect errors.
@Dr-Nikson
Dr-Nikson / README.md
Last active January 14, 2019 06:35 — forked from vjpr/README.md

Reduce boilerplate in Redux

  • Create actions similar to Flummox.
  • Generate action ids.
  • Supports actions with decorators, promises, and therefore ES7 async.
@donmccurdy
donmccurdy / wildcard-to-regexp.js
Last active February 21, 2024 06:49
Wildcard and glob matching in JavaScript.
/**
* Creates a RegExp from the given string, converting asterisks to .* expressions,
* and escaping all other characters.
*/
function wildcardToRegExp (s) {
return new RegExp('^' + s.split(/\*+/).map(regExpEscape).join('.*') + '$');
}
/**
* RegExp-escapes all characters in the given string.
@ndrbrt
ndrbrt / wait-for-open-websocket-connection.js
Last active April 12, 2024 18:19
Wait for the WebSocket connection to be open, before sending a message.
const waitForOpenConnection = (socket) => {
return new Promise((resolve, reject) => {
const maxNumberOfAttempts = 10
const intervalTime = 200 //ms
let currentAttempt = 0
const interval = setInterval(() => {
if (currentAttempt > maxNumberOfAttempts - 1) {
clearInterval(interval)
reject(new Error('Maximum number of attempts exceeded'))