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 fs = require("fs"); | |
const path = require("path"); | |
// Get the command-line arguments | |
const directory = process.argv[2]; | |
const extArg = process.argv.find((arg) => arg.startsWith("--ext=")); | |
// Validate inputs | |
if (!directory || !extArg) { | |
console.log("Usage: codesoup <directory> --ext=<extensions>"); |
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
# ORGANIZE ELEMENTOR TEMPLATE ARCHIVES FOR PREVIEWING | |
# RUN THIS BASH SCRIPT NEXT TO ZIP ARCHIVES | |
mkdir -p templates preview archives | |
i=100 | |
# iterate archives | |
for archive in *.zip; do | |
archive_name=${archive%%.zip} | |
echo "processing $archive_name..." |
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 os from "os"; | |
import process from "process"; | |
/* GET /api/health */ | |
const stats = { | |
status: "OK", | |
system: { | |
hostname: os.hostname(), | |
free_memory_mb: Math.floor(os.freemem() / 1000000), | |
load_avg: os.loadavg(), |
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
Show hidden characters
{ | |
"compilerOptions": { | |
/***** BASIC OPTIONS *****/ | |
/* target ECMAScript version */ | |
"target": "esnext", | |
/* use ECMAScript module system */ | |
"module": "esnext", | |
/* treat files as isolated independent modules */ | |
"isolatedModules": true, |
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
<style> | |
.switch input{ | |
display: none; | |
} | |
.switch label{ | |
background-color: grey; | |
} | |
.switch input:checked + label{ | |
background-color: red; | |
} |
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
getMACAddress() { | |
let vmMACPrefixes = [ | |
"00:50:56", | |
"00:0C:29", | |
"00:05:69", | |
"00:1C:14", | |
"0A:00:27", | |
"00:03:FF", | |
"00:1C:42", | |
"00:0F:4B", |
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
// CORS policies apply | |
async function download(url, filename){ | |
let res = await fetch(url) | |
let blob = await res.blob() | |
let a = document.createElement("a"); | |
a.href = URL.createObjectURL(blob) | |
a.download = filename; | |
a.click(); | |
} |
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
// go to the course page, press F12 and run this code in Java Script console. | |
// once done you get a list of video download links. Right click and save them or, | |
// download all at once with a tool of your choice (e.g. Chrome Simple Mass Downloader) | |
(async () => { | |
let SELECTOR_CHAPTER_EXPANDERS = '.classroom-toc-chapter__toggle' | |
let SELECTOR_LESSONS = '[data-control-name="toc_item"]' | |
let VIDEO_LOAD_WAIT = 3000 | |
// expand chapters on sidebar except the first |
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 CACHE_VERSION = 'cache-v1' // increment this when you update the web site | |
const filesToCache = [ | |
"./index.html", | |
"./path/an/image.png", | |
// add more static assets to cache | |
] | |
self.addEventListener( | |
'install', |
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
/* | |
reads a file upwards from the given 'startPosition' to the specified length and | |
returns an object with the lines and the final position read | |
if 'startPosition' is not specified it will be the very bottom of the file | |
*/ | |
async function readFileBottomUp(filename, length, startPosition) { | |
return new Promise((resolve, reject) => { | |
// file does not exist |
NewerOlder