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 queue = (id, concurrency = 1) => { | |
const d = { running: 0, queue: [] }; | |
const c = (globalThis._RQ ?? {})[id] ?? d; | |
globalThis._RQ = { ...(globalThis._RQ ?? {}), [id]: c }; | |
const inc = (fn) => (c.running++, fn()); | |
return (task) => | |
(c.running < concurrency | |
? Promise.resolve(inc(task)) | |
: new Promise((res) => c.queue.push(() => res(inc(task)))) | |
).finally( |
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 acorn from "acorn"; | |
import glob from "glob"; | |
import esbuild from "esbuild"; | |
import fs from "fs/promises"; | |
import { resolve, dirname } from "path"; | |
const isNode = (node) => typeof node?.type === "string"; | |
const getChilds = (node) => | |
Object.keys(node) |
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 queue = (fn, delay) => { | |
const queue = [] | |
let curr = null | |
setInterval(() => { | |
curr = queue.shift() | |
}, delay) | |
return (...args) => { | |
const id = Math.random() |
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
#!/bin/bash | |
if [ $(git rev-parse --is-bare-repository) = true ] | |
then | |
REPOSITORY_BASENAME=$(basename "$PWD") | |
else | |
REPOSITORY_BASENAME=$(basename $(readlink -nf "$PWD"/..)) | |
fi | |
REPOSITORY_BASENAME=${REPOSITORY_BASENAME%.git} | |
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
curl localhost:2019/load \ | |
-X POST \ | |
-H "Content-Type: application/json" \ | |
-d "$(caddy adapt)" |
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
echo "$(</dev/stdin)" > myfile.txt | |
# terminate your input with ENTER + ctrl-d |
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
// go to https://www.facebook.com/pages/?category=liked&ref=bookmarks | |
let pages = [] | |
const unlike_all = () => { | |
const all = [...document | |
.querySelectorAll('[aria-label="Liked"],[aria-label="Followed"],[aria-label="Following"]') | |
] | |
pages = [...new Set([...pages, ...all.map((a) => a.parentNode.parentNode.querySelector("span").innerText.trim(" "))])] |
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
<script> | |
navigator.serviceWorker | |
.register("/sw.js") | |
.then(() => console.log("ServiceWorker registration successful")) | |
.catch((err) => console.log("ServiceWorker registration failed: ", err)); | |
</script> | |
<script type="module" src="index.jsx"></script> | |
<div id="root"></div> |
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, { useState, useEffect, useRef, memo } from "react"; | |
import { | |
Chart, | |
Line, | |
LineController, | |
LinearScale, | |
LogarithmicScale, | |
PieController, | |
Point, | |
PolarAreaController, |
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 cssColor = (...color) => | |
`rgb${color.length === 4 ? "a" : ""}(${(color.length === 1 | |
? Array(3).fill(color[0]) | |
: color | |
).join(",")})`; | |
const createP5Api = (ctx, frameCount) => ({ | |
context: ctx, | |
width: ctx.canvas.width, | |
height: ctx.canvas.height, |