GitHub Avatar

parsehex

My specialty is unintentionally making useless things - mostly software.

Gists by parsehex

Created: Dec 7, 2025
Updated: Dec 7, 2025
list-dir.py Python
import argparse
import os

if __name__ == '__main__':
	parser = argparse.ArgumentParser(description="List a directory's structure.")
	parser.add_argument('path', help='Directory to list (relative or absolute)')
	args = parser.parse_args()
	first_arg = args.path

	if not os.path.exists(first_arg):
		print(f'Provided path {first_arg} does not exist')
		exit(1)
	if not os.path.isdir(first_arg):
		print(f'Provided path {first_arg} is not a directory')
		exit(1)

	for root, _dirs, files in os.walk(first_arg):
		print(root + '/')
		indent = ' ' * len(root)
		for file in files:
			print(indent, file)
Created: Nov 28, 2025
Updated: Dec 6, 2025
cracklepop.js JavaScript
const lines = new Array(100).fill(0).map((_value, index) => {
	const thisLineNum = index + 1;
	const evenlyDivisibleBy3 = thisLineNum % 3 === 0;
	const evenlyDivisibleBy5 = thisLineNum % 5 === 0;
	const evenlyDivisibleBy3And5 = evenlyDivisibleBy3 && evenlyDivisibleBy5;

	// catch the divisible-by-both condition first
	if (evenlyDivisibleBy3And5) return 'CracklePop';
	if (evenlyDivisibleBy3) return 'Crackle';
	if (evenlyDivisibleBy5) return 'Pop';
	// handle other lines:
	return thisLineNum;
});

for (const line of lines) {
	console.log(line);
}