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
## YouTube thumbnail URLs | |
- `ytimg.com` is owned by Google | |
- Use in compliance with owner copyright and YouTube terms | |
Player Background Thumbnail (480x360): | |
- https://i.ytimg.com/vi_webp/VIDEO_ID/0.webp | |
- https://i.ytimg.com/vi/VIDEO_ID/0.jpg | |
Video frames thumbnails (120x90) |
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
#!/usr/bin/env node | |
async function run() { | |
// do async stuff | |
console.log('') | |
} | |
// Start | |
run() | |
.then(() => { |
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
// Accessing dns module | |
const dns = require('dns'); | |
async function run() { | |
const names = [ | |
'hostname1.com', | |
'hostname2.com', | |
] | |
for await (const name of names) { |
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
function loadScript(id, src, async = true, onload = undefined, onerror = undefined) { | |
var elScript = Object.assign(document.createElement('script'), { | |
id, src, async, type: 'text/javascript' | |
}) | |
if (onload) elScript.addEventListener("load", onload); | |
if (onerror) elScript.addEventListener("error", onerror); | |
document.head.appendChild(elScript) | |
} | |
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
const removeAccents = (name) => name.normalize('NFD').replace(/[\u0300-\u036f]/g, ''); |
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
// Requires Node 16 or later | |
import { setTimeout } from 'timers/promises'; | |
const result = await setTimeout(2000, 'done'); |
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 * as functions from "firebase-functions"; | |
import * as firebase from "firebase-admin"; | |
import { parseAsync } from 'json2csv'; | |
import { v4 as uuidv4 } from 'uuid'; | |
import * as fs from "fs"; | |
import * as path from "path"; | |
import * as os from "os"; | |
firebase.initializeApp({ | |
storageBucket: 'storage-bucket-name', |
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
/* | |
* Middleware for Firebase GRPC Callable functions | |
* | |
* Reference: https://stackoverflow.com/a/70057694/365261 | |
* | |
* Example: | |
* export const myCallableFunction = functions.https.onCall( | |
* return withMiddlewares([assertAppCheck, assertAuthenticated], async (data, context) => { | |
* // Your callable function handler | |
* }) |
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
alias urlencode='node --eval "console.log(encodeURIComponent(process.argv[1]))"' |
NewerOlder