Skip to content

Instantly share code, notes, and snippets.

@domizai
domizai / lines-of-code.js
Last active July 27, 2024 21:18
Count lines of code
#!/usr/bin/env node
/*
* ./lines-of-code.js ./directory .js,.mjs,.php
*
* Ignores comments, blank lines and lines with less than <minl> chars.
* Add additional languages and rules in 'lang' object.
*/
const fs = require('fs/promises');
@domizai
domizai / simple-cli.js
Last active September 4, 2022 20:18
Simple command line arguments parser in node
#!/usr/bin/env node
/*
* ./simple-cli.js --agave hello world --eggs 123
*/
function processArguments(flagCallbackMap, argv) {
const groups = argv.reduce((a,s) => {
if(s[0] === '-') a.push([]);
if(a.length > 0) a[a.length-1].push(s);
@domizai
domizai / SimpleCLI.java
Last active September 4, 2022 11:11
Simple command line arguments parser in java
/*
* java SimpleCLI --agave hello world --eggs 123
*/
import java.util.*;
import java.util.function.*;
public final class SimpleCLI {
static Consumer<String[]> CallAgave = args -> {
if(args.length < 3)
@domizai
domizai / progress
Last active May 11, 2019 21:07
Bash progress bar
#!/usr/bin/env bash
# Options:
# max <int> - set maximum amount of elements
# current <int> - set current index (starting from 0)
# update - update and print progress bar
# clear - clear progress bar
# time - print elapsed time
# reset - reset time and progress
# width <int> - set the width of the progress bar
@domizai
domizai / removeClass.js
Last active August 29, 2015 14:09
Removes all classes from the element matching a pattern.
// ------------------------------------------------------------------
// HTMLElement.removeClass( search [, exeption] )
// ------------------------------------------------------------------
//
// Description:
// Removes all classes from the element matching a pattern.
//
//
// Parameter:
// search: A string or an array of strings.
@domizai
domizai / findChildClass.js
Last active August 29, 2015 14:09
Will recursively search down the DOM tree for Elements with the specified class.
// ------------------------------------------------------------------
// array HTMLElement.findChildClass( string )
// ------------------------------------------------------------------
//
// Description:
// Will recursively search down the DOM tree for Elements with the specfied class.
//
// Parameter:
// string: The name of the class to search for.
//