Skip to content

Instantly share code, notes, and snippets.

@emmanuelnk
emmanuelnk / cleanEmpty.js
Created May 13, 2020 08:07
Clean js object by recursive removal of undefined, null, NaN and empty strings
// A SO answer to https://stackoverflow.com/questions/286141/remove-blank-attributes-from-an-object-in-javascript
// based off the recursive cleanEmpty function by @chickens.
// This one can also handle Date objects correctly
// and has a defaults list for values you want stripped.
const cleanEmpty = function(obj, defaults = [undefined, null, NaN, '']) {
if (defaults.includes(obj)) return
if (Array.isArray(obj))
return obj
@emmanuelnk
emmanuelnk / README.md
Created April 17, 2020 07:36 — forked from boneskull/README.md
example of how to debug mocha v4 if hanging

Here's an example of how to debug Mocha v4 if it hangs.

Ensure you're using a Node.js 8 or newer (or any version with async_hooks support).

If you run your test, you'll notice it hangs:

$ mocha test.js
@emmanuelnk
emmanuelnk / master-javascript-interview.md
Created April 8, 2020 09:11 — forked from Geoff-Ford/master-javascript-interview.md
Eric Elliott's Master the JavaScript Interview Series
@emmanuelnk
emmanuelnk / composing-software.md
Created April 8, 2020 09:11 — forked from Geoff-Ford/composing-software.md
Eric Elliott's Composing Software Series

Eric Elliott's "Composing Software" Series

A collection of links to the excellent "Composing Software" series of medium stories by Eric Elliott.

Edit: I see that each post in the series now has index, previous and next links. However, they don't follow a linear flow through all the articles with some pointing back to previous posts effectively locking you in a loop.

@emmanuelnk
emmanuelnk / npm-commands.md
Created February 14, 2020 03:33 — forked from ankurk91/npm-commands.md
Useful npm commands and tricks

npm v3.10 - ◾

If you are learning npm then i would suggest to go for yarn, dont waste your time in learning npm

⚠️ This gist is outdated, but most of the commands are still relevant.

Update npm itself

npm install -g npm
# Downgrade to a specific version
@emmanuelnk
emmanuelnk / .bashrc
Last active January 17, 2020 05:32
Installing virtual node environments with nodeenv.
# start nodeenv virtual env if it exists
# for whenever you open integrated terminal in vscode
if [ -d ".nenv" ]; then
. ".nenv/bin/activate"
fi
@emmanuelnk
emmanuelnk / start_dynamodb_local_docker.bash
Last active January 15, 2020 01:59
Start Dyanmodb Local docker with sharedDb param to enable dyanmodb-admin and localhost:8000/shell to view tables
docker run -p 8000:8000 amazon/dynamodb-local -jar DynamoDBLocal.jar -sharedDb
@emmanuelnk
emmanuelnk / oneliner.bash
Created January 10, 2020 08:08
Convert all filenames in current directory to lowercase (Bash)
for i in $( ls | grep [A-Z] ); do mv -i $i `echo $i | tr 'A-Z' 'a-z'`; done
@emmanuelnk
emmanuelnk / parse_dotenv.bash
Last active January 6, 2020 07:09 — forked from judy2k/parse_dotenv.bash
Parse a .env (dotenv) file directly using BASH
# Export the vars in .env into your shell:
export $(egrep -v '^#' .env | xargs)
@emmanuelnk
emmanuelnk / argument_parser.bash
Created November 21, 2019 03:12
Parse command-line arguments in bash easily
# ./my_script.sh --arg1 value1 --arg2 value2 --arg3 value3
# ./my_script.sh -a value1 -b value2 -c value3
#!/usr/bin/env bash
while [[ "$#" -gt 0 ]]; do case $1 in
-a|--arg1) var1="$2"; shift;;
-b|--arg2) var2="$2"; shift;;
-c|--arg3) var3="$2"; shift;;
*) echo "Unknown parameter passed: $1"; exit 1;;
esac; shift; done