Skip to content

Instantly share code, notes, and snippets.

@mmavko
mmavko / enqueue.js
Created December 25, 2021 09:48
enqueue.js - run lots of async tasks concurrently, not more than MAX_RUNNING at a time
const MAX_RUNNING = 5;
const queue = [];
let currentlyRunning = 0;
async function checkQueue() {
if (queue.length === 0 || currentlyRunning >= MAX_RUNNING) return;
const [cb, resolve, reject] = queue.shift();
try {
currentlyRunning++;
@mmavko
mmavko / tailwind classes indentation.jsx
Created November 24, 2021 11:23
Tailwind classes indentation
// single-line props
<Menu.Items className='absolute right-0 z-20 w-40 mt-1 origin-top-right border rounded
bg-neutrals-0 divide-solid border-neutrals-200 focus:outline-none' />
// multi-line props
<Menu.Items
className='absolute right-0 z-20 w-40 mt-1 origin-top-right border rounded
@mmavko
mmavko / stale-branch-notifier.js
Created March 12, 2021 10:13
Stale branch notifier
const simpleGit = require('simple-git/promise')();
/* eslint-disable fp/no-mutating-methods, no-console */
const plural = (n, s, p) => `${n} ${n === 1 ? s : p || `${s}s`}`;
const ALLOWED_DAYS = 60;
async function getUserNames() {
const config = await simpleGit.listConfig();
@mmavko
mmavko / proxy-server.coffee
Created March 12, 2021 10:11
Proxy server
# This is simple proxy server which is aimed to substitude responses from real
# servers with custom data (for debugging). It also handles HTTPS requests by
# running one more HTTPS proxy server for each domain you want to fake, as
# defined in `HTTPS_PROXIES` variable. This of course will make browser to
# notify user that site has changed certificate (which you should generate, by
# the way; for example, here: http://www.selfsignedcertificate.com/).
#
# Dependencies:
#
# - https://www.npmjs.org/package/send
@mmavko
mmavko / marbles.txt
Created March 12, 2021 10:08
Rx marbles
// pip3 install rxmarbles
// marblesgen foo.txt
// https://bitbucket.org/achary/rx-marbles/src/762c9519e58f4cb914c9187c0b3019d5c665b933/docs/syntax.md
marble foo_example
{
source a: +-A-B-- -C-D-- -|
source b: +-----X -----Y -|
operator foo: +-----{AB,X} -----{CD,Y} -|
@mmavko
mmavko / .eslintrc.js
Created March 11, 2021 10:41
Flexum .eslintrc.js
module.exports = {
env: {
browser: true,
es2020: true,
node: true,
},
extends: [
'airbnb-base',
],
parserOptions: {
@mmavko
mmavko / edges-to-tree.js
Created October 24, 2019 15:36
Edges to tree
const edges = [
[0, 6],
[17, 5],
[2, 7],
[4, 14],
[12, 9],
[15, 5],
[11, 1],
[14, 8],
[16, 6],
@mmavko
mmavko / flows-lib.js
Last active July 3, 2019 08:32
Flows lib
// Flows library
// README https://gist.github.com/mmavko/e915661ceb235d3706293f2e7a22187a
let console;
export function setConsole(c) {
console = c;
}
setConsole(global.console);
let globalLogging;
@mmavko
mmavko / custom subject.png
Last active August 27, 2018 11:57
Rx.Observable.log()
custom subject.png
@mmavko
mmavko / zip.js
Created July 6, 2017 16:57
Mega zip
import R from "ramda";
// Just like R.zip but can take any number of lists, not only two.
export function zip(...lists) {
return R.reduce(
(a, l) => {
if (a) {
return R.zipWith((a, b) => R.append(b, a), a, l);
} else {
return R.map(el => [el], l);