Skip to content

Instantly share code, notes, and snippets.

@emmanuelnk
emmanuelnk / script.bash
Last active July 1, 2022 11:29
Installing vscode transparency/blur ubuntu 18.04
# [UPDATE]
# Its no longer complicated! Yay!
# Install Glassit Linux VSCode Extension
# then install this:
sudo apt install -y wmctrl x11-utils bash
# then restart VSCode. Done!
@emmanuelnk
emmanuelnk / git_clean.bash
Created July 4, 2019 08:17
Git: Clean out branches merged to master branch from local git repository (without deleting master branch)
git branch --merged master | grep -v "\master" | xargs -n 1 git branch -d
@emmanuelnk
emmanuelnk / timestampUpdate.js
Last active August 14, 2019 03:01
Recursively update all timestamps in a document to current timestamps based on when the document/fixture was created (Moment.js, Node.js)
// great for fixtures used in tests that need to stay up to date
// needs moment.js
const moment = require('moment')
const updateTimestamps = (entity, baseTimestamp, path = '', tsFields) => {
// usage: recusrively updates all Timestamps in a json fixture for tests
const nowTs = moment().clone().startOf('hour')
const diff = Math.abs(nowTs.diff(baseTimestamp, 'hours'))
@emmanuelnk
emmanuelnk / .gitconfig
Last active January 6, 2020 07:10
Git Recent: Add git alias to display recently accessed branches in descending order (and with color!)
[alias]
recent = "!r(){ git for-each-ref --sort=-committerdate refs/heads --format='%(HEAD)%(color:yellow)%(refname:short)|%(color:bold green)%(committerdate:relative)|%(color:blue)%(subject)|%(color:magenta)%(authorname)%(color:reset)' --color=always|column -ts'|'; }; r"
@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
@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 / 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 / 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 / .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 / 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