Skip to content

Instantly share code, notes, and snippets.

View Uvacoder's full-sized avatar

uvacoder Uvacoder

View GitHub Profile
// via https://yeun.github.io/open-color/
const palette = {
dark: [
'#d5d7e0',
'#acaebf',
'#8c8fa3',
'#666980',
'#4d4f66',
'#34354a',
@Uvacoder
Uvacoder / appendArguments.js
Created January 2, 2022 00:15 — forked from DavidWells/appendArguments.js
Automagically append arguments to function calls or add to `this` within function
/* Append arguments to functions */
function appendArguments(fn, append, context) {
if (!append) return fn
// console.log('context', context)
return function () {
/* Original args */
const args = Array.prototype.slice.call(arguments)
// console.log('original args', arguments)
/* Create clone of args */
@Uvacoder
Uvacoder / list-all-methods-of-class.js
Created January 2, 2022 00:16 — forked from DavidWells/list-all-methods-of-class.js
Debugging utility for enumerating function methods on a class instance in Javascript
function getMethods(obj) {
const excludeBuiltIns = Object.getOwnPropertyNames(Object.prototype)
let properties = new Set()
let currentObj = obj
do {
Object.getOwnPropertyNames(currentObj).map(item => properties.add(item))
} while ((currentObj = Object.getPrototypeOf(currentObj)))
return [
...properties.keys()
].filter((item) => {
// via https://github.com/idleberg/web-porridge/blob/7d43f9cd01a2e7ad902b0ce37045e38a187fe118/src/util.ts
/**
* Checks whether input data requires deserialization after reading it from WebStorage
* @param {*} inputData
* @returns {boolean}
*/
function maybeDeserialize(inputData): boolean {
const serializables = [
'[object Array]',
@Uvacoder
Uvacoder / parse-csv-and-iterate-with-delay.js
Created January 2, 2022 00:18 — forked from DavidWells/parse-csv-and-iterate-with-delay.js
Parse CSV file and iterate over values with artificial delay
/*
"csv-parse": "^4.15.3",
"follow-redirects": "^1.13.3",
*/
const path = require('path')
const fs = require('fs').promises
const parse = require('csv-parse')
const { https } = require('follow-redirects')
const parseFullName = require('./src/utils/parse-name')
@Uvacoder
Uvacoder / string-to-boolean.js
Created January 2, 2022 01:40 — forked from DavidWells/string-to-boolean.js
Convert string, number to boolean value
function cleanBooleanParam(value) {
switch(value.toString().toLowerCase()) {
case "true":
case "on":
case "yes":
case "1":
return true;
case "false":
case "off":
case "no":
// From https://github.com/sw-yx/swyxdotio/blob/60b088cea0439d3e2536a78dc922af3146ba40fd/screenshot-plugin/screenshot.js
const puppeteer = require('puppeteer')
const fs = require('fs')
const path = require('path')
module.exports = screenshot
async function screenshot(PostArray) {
const headless = true
// const headless = false // for debug
const browser = await puppeteer.launch({ headless })
@Uvacoder
Uvacoder / install-all-dependancies.js
Created January 2, 2022 01:46 — forked from DavidWells/install-all-dependancies.js
Install dependancies in every folder with package.json file
const path = require('path')
const fs = require('fs')
const globby = require('globby')
const cp = require("child_process")
function installDeps(functionDir, cb) {
cp.exec("npm i", { cwd: functionDir }, cb)
}
async function installAllDeps(additionalDirs = []) {
const pattern = /^(?:\S+:\/\/)?(?:\S+@)?(?'host'\S+?)[:\/](?'owner'\S+?)[\/](?'repository'\S+)$/gm
/*
https://github.com/rawkode/dotfiles
https://github.com/rawkode/dotfiles/2
[email protected]:rawkode/dotfiles
[email protected]:rawkode/dotfiles/micro/1/2
ssh://[email protected]/rawkode/dotfiles