Skip to content

Instantly share code, notes, and snippets.

@Hebilicious
Hebilicious / proxy.js
Last active Jul 27, 2021
Proxy useful use case
View proxy.js
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 }
View gist:82689144288418f480477addeb4ceaed
---
version: "2"
services:
emby:
image: linuxserver/emby
container_name: emby
environment:
- PUID=998
- PGID=100
- TZ=America/Denver
@Hebilicious
Hebilicious / smoke.md
Last active Feb 17, 2021
Smoke Finance
View smoke.md
@Hebilicious
Hebilicious / demo.js
Created Jan 22, 2018
ES Class constructor spread operator arguments
View demo.js
//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
View retry.js
/**
* 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}) => {
@Hebilicious
Hebilicious / reduce.js
Created Nov 20, 2019
await for...of =>reduce
View reduce.js
[1,2,3,4,5,6].reduce(async(previousPromise, thing) => {
await previousPromise
return asyncOperation(thing)
}, Promise.resolve())
@Hebilicious
Hebilicious / node.webpack.config.js
Created Jan 19, 2018
Webpack & Node 2018 Starter Config
View node.webpack.config.js
/**
* Inspired by https://jlongster.com/Backend-Apps-with-Webpack--Part-I
*/
const webpack = require('webpack');
const path = require('path');
const fs = require('fs');
//Use nodemon to livereload when using webpack --watch.
const NodemonPlugin = require('nodemon-webpack-plugin');
//Ignore node externals when bundling
const nodeExternals = require('webpack-node-externals');