Get caller from Error.protoype.stack in Chrome/Firefox/Safari browsers on Windows/macOS

Typically in JavaScript and Node.js projects, use of console is disallowed and is enforced using the no-console rule in ESLint. Logging would then be done thru a centralized function, e.g. log(), which may use console.log with the ESLint rule disabled just for that line of code, instead of having multiple console.log statements throughout the codebase …

Range of integers/floats/dates in programming languages when using BIGINT in PostgreSQL

Was trying to migrate a database from MySQL to PostgreSQL recently when I “discovered” that UNSIGNED is not supported in PostgreSQL, as it is not part of the ANSI SQL standard which it follows closely. Other findings were that non-aggregate columns are not allowed in queries with GROUP BY clauses (which MySQL/SQLite “allows” by selecting …

JavaScript code that can be used client-side in the browser and server-side in Node.js

Sample code as follows, read comments for more details ๐Ÿ™‚ /** * Example of JavaScript code that can be used client-side in the browser and server-side in Node.js * * Usage in browser: * <script src=”shared.js”></script> * <script> * console.log(shared.STATUS_SUCCESS, shared.test()); // note that shared.getTimestamp() won’t work * </script> * * Usage in Node.js: * …

Render array of objects together with index in Mustache.js and as Bootstrap rows or dropdown options with selected value

Came across a GitHub issue Collection processing like @index for Mustache.js. It referenced the each() function in another library, GRMustache. Came up with the following and posted my solution back in the Mustache.js GitHub issue ๐Ÿ™‚ Sample output: <h4>Test 1: Loop over array with count & access to existing template vars/fns</h4> <div data-date=”2021-12-03″>item 1/4: ant …

Uploading a folder via HTML form or cURL

References: Upload directory doesn’t send folder name with file Upload files with CURL Multipart formposts How to upload folder using HTML and PHP VGG Image Annotator: Issue 270 – Using Webkitdirectory to import multiple directories and maintain directory hierarchy Contents of folder to be uploaded (drawn using tree –charset unicode –dirsfirst -a -n in bash): …