Skip to content

Instantly share code, notes, and snippets.

@joelbarba
joelbarba / copy.js
Created August 26, 2025 10:43
Node.js terminal tool for linux folder assisted copy
import fs from 'fs';
import path from 'path';
import process from 'process';
import { exec } from 'child_process';
import readline from 'readline';
// const rl = readline.createInterface({ input: process.stdin, output: process.stdout, });
// function ask(text = '') { return new Promise((resolve) => rl.question(text, (answer) => resolve(answer))); }
readline.emitKeypressEvents(process.stdin);
@joelbarba
joelbarba / invited_customers_list.html
Last active February 8, 2016 19:17
Customer selector by distance between 2 positions.
<!DOCTYPE html>
<html>
<head>
<title>Invited customers</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
<!-- <script src="JS/lib/jquery.js"></script>-->
@joelbarba
joelbarba / get_flattened_array_test.js
Created February 6, 2016 01:44
Random nested array generator to test the get_flattened_array() function
// Random test
for (var test_num = 0; test_num <= 20; test_num++){
var nested_array = set_nested_array(0);
console.log('Test ' + test_num + '; nested_array = ');
console.log(nested_array);
console.log('Flattened array -> ' + nested_array.get_flattened_array());
}
@joelbarba
joelbarba / get_flattened_array.js
Last active February 9, 2016 11:36
Recursive function (extended from Array type) to flatten a nested array
/********************************************************************************************/
/* Recursive function to flatten all nested elements of an array. */
/* */
/* - Each recursive iteration returns a new the flatered array with all its nested levels. */
/* - The flattened array is built by a plain concatenation of each return callback. */
/* */
/* Example: [[1,2,[3]],4].get_flattened_array(); */
/********************************************************************************************/
Array.prototype.get_flattened_array = function() {
return this.reduce(