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
import { | |
type AnyVariables, | |
cacheExchange, | |
Client, | |
type DocumentInput, | |
fetchExchange, | |
type UseQueryArgs, | |
type UseQueryState | |
} from "urql" | |
import { assign, createActor, fromPromise, setup } from "xstate" |
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
#paste this in your .bashrc/.zshrc file | |
purgenodemodules() { | |
perl -e 'use File::Find; find(sub { unlink $File::Find::name if (-f && $File::Find::dir =~ /node_modules/) }, ".")' && find . -name 'node_modules' -type d -exec rm -rf {} + | |
} |
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
# Bun is now officially supported and these environments variables are no longer needed. Keeping this gist for legacy purposes. | |
# SKIP_DEPENDENCY_INSTALL=true | |
# UNSTABLE_PRE_BUILD=asdf install bun latest && asdf global bun latest && bun i |
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
async function processItems ( | |
items: unknown[], | |
operation: () => Promise, | |
concurrency = 25 | |
) { | |
const errors = [] | |
let id = 0 | |
const exec = async () => { | |
if (id === items.length) return | |
const item = items[id++] |
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
--- | |
version: "2" | |
services: | |
emby: | |
image: linuxserver/emby | |
container_name: emby | |
environment: | |
- PUID=998 | |
- PGID=100 | |
- TZ=America/Denver |
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
/** | |
* Retries the given function until it succeeds given a number of retries and an interval between them. They are set | |
* by default to retry 5 times with 1sec in between. There's also a flag to make the cooldown time exponential | |
* @param {Function} fn - Returns a promise | |
* @param {Number} retriesLeft - Number of retries. If -1 will keep retrying | |
* @param {Number} interval - Millis between retries. If exponential set to true will be doubled each retry | |
* @param {Boolean} exponential - Flag for exponential back-off mode | |
* @return {Promise<*>} | |
*/ | |
const retryPromise = ({fn, retriesLeft = 5, interval = 1000, exponential = false}) => { |
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
[1,2,3,4,5,6].reduce(async(previousPromise, thing) => { | |
await previousPromise | |
return asyncOperation(thing) | |
}, Promise.resolve()) |
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
import fs from "fs" | |
import path from "path" | |
import { inspect } from "util" | |
const { Console } = console | |
const makeFile = (name = "result") => fs.createWriteStream(path.join(__dirname, `../${name}.log`)) | |
const inspectOptions = { maxArrayLength: null, depth: null } |
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
//Let's create some arguments as functions | |
let message = () => "hello" | |
let content = () => "world" | |
let text = () => "lorem" | |
//Let's change the function internal name value... | |
Object.defineProperty(text, "name", {writable:true}); | |
text.name = "book" | |
//Now we create a class |
NewerOlder