Skip to content

Instantly share code, notes, and snippets.

View MossTheFox's full-sized avatar
🦜
Learning

Moss Joe MossTheFox

🦜
Learning
  • Nanjing, China
View GitHub Profile
@MossTheFox
MossTheFox / removeEmptyDirs.mjs
Created April 29, 2023 13:26
Node.js script to remove empty sub-dirctories. Run in the parent dir. Remember to backup files before running it in case of unexpected behaviors.
import { readdir, rmdir, lstat } from "fs/promises";
import { join } from "path";
const emptyDirs = [];
/**
*
* @returns {Promise<string[]>}
*/
const iterateDirs = async (startPath = ".") => {
@MossTheFox
MossTheFox / udp_ping_pong.mjs
Last active April 29, 2023 13:27
A node.js script for testing network reliability with UDP packages.
const TIP_TEXT = `udp_ping_pong.mjs
Server:
node ./udp_ping_pong.mjs --server --port 8999
Client (assume the target server ip is 1.1.1.1, port 8999):
node ./udp_ping_pong.mjs --client 1.1.1.1:8999 --interval 100 --timeout 1000
Ctrl + C to end the ping and see results.
Args: