Skip to content

Instantly share code, notes, and snippets.

Emmanuel N Kyeyune emmanuelnk

Block or report user

Report or block emmanuelnk

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@emmanuelnk
emmanuelnk / cleanEmpty.js
Created May 13, 2020
Clean js object by recursive removal of undefined, null, NaN and empty strings
View cleanEmpty.js
// 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 Apr 17, 2020 — forked from boneskull/README.md
example of how to debug mocha v4 if hanging
View README.md

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 Apr 8, 2020 — forked from Geoff-Ford/master-javascript-interview.md
Eric Elliott's Master the JavaScript Interview Series
View master-javascript-interview.md
@emmanuelnk
emmanuelnk / composing-software.md
Created Apr 8, 2020 — forked from Geoff-Ford/composing-software.md
Eric Elliott's Composing Software Series
View composing-software.md

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 Feb 14, 2020 — forked from ankurk91/npm-commands.md
Useful npm commands and tricks
View npm-commands.md

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 Jan 17, 2020
Installing virtual node environments with nodeenv.
View .bashrc
# 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 Jan 15, 2020
Start Dyanmodb Local docker with sharedDb param to enable dyanmodb-admin and localhost:8000/shell to view tables
View start_dynamodb_local_docker.bash
docker run -p 8000:8000 amazon/dynamodb-local -jar DynamoDBLocal.jar -sharedDb
@emmanuelnk
emmanuelnk / oneliner.bash
Created Jan 10, 2020
Convert all filenames in current directory to lowercase (Bash)
View oneliner.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 Jan 6, 2020 — forked from judy2k/parse_dotenv.bash
Parse a .env (dotenv) file directly using BASH
View parse_dotenv.bash
# Export the vars in .env into your shell:
export $(egrep -v '^#' .env | xargs)
@emmanuelnk
emmanuelnk / argument_parser.bash
Created Nov 21, 2019
Parse command-line arguments in bash easily
View argument_parser.bash
# ./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
You can’t perform that action at this time.