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 lighthouse = require("lighthouse"); | |
const chromeLauncher = require("chrome-launcher"); | |
const runReport = async (url) => { | |
const chrome = await chromeLauncher.launch({ | |
chromeFlags: ["--headless"], | |
}); | |
const options = { output: "json", port: chrome.port }; | |
const runnerResult = await lighthouse(url, options); |
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
// Related to François' question on this video: https://www.youtube.com/watch?v=ThcV5bW62nc | |
const generateQuestion = (countries) => { | |
const randomIndex = Math.floor(Math.random() * countries.length); | |
const country = countries[randomIndex]; | |
const possibilities = []; | |
const selectedIndexes = []; // set of indexes of countries that are selected | |
while (possibilities.length < 3) { |
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
// Installation | |
// - | |
// mkdir yt_download_playlist | |
// cd yt_download_playlist | |
// mkdir download | |
// npm init -y | |
// npm install puppeteer | |
// npm install ytdl-core | |
// touch index.js |
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 {load} from 'cheerio'; | |
const getDefinition = async (word) => { | |
const url = `https://fr.wiktionary.org/wiki/${word}`; | |
// fetch with Node 18+ (or use Axios) | |
const response = await fetch(url); | |
const html = await response.text(); | |
const $ = load(html); |
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 Spline = require("cubic-spline"); | |
const tinycolor = require("tinycolor2"); | |
function clamp(value, min, max) { | |
return Math.min(Math.max(value, min), max); | |
} | |
function generateSwatch(lightColor, seedColor, darkColor, hueInvariance) { | |
const light = tinycolor(lightColor); | |
const seed = tinycolor(seedColor); |
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
// @ts-nocheck | |
import * as ts from "ts-morph" | |
import * as fs from "fs" | |
import * as path from "path" | |
import * as glob from "glob" | |
import { exec } from "child_process" | |
import slugify from "slugify" | |
const project = new ts.Project({ | |
tsConfigFilePath: "./tsconfig.json", |
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
function delay(ts = 100) { | |
return new Promise((resolve) => { | |
setTimeout(resolve, ts) | |
}) | |
} | |
async function typeWord({ word, delayMs = 300 } = {}) { | |
if (!word) { | |
console.log('Word is undefined') |
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
#!/usr/bin/env node | |
const { mkdirSync, writeFileSync } = require('node:fs'); | |
const params = process.argv.slice(2); | |
if (params.length === 0) { | |
console.log('No arguments provided'); | |
process.exit(1); | |
} |