This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for i in $( ls | grep [A-Z] ); do mv -i $i `echo $i | tr 'A-Z' 'a-z'`; done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Export the vars in .env into your shell: | |
export $(egrep -v '^#' .env | xargs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ./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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git branch --merged master | grep -v "\master" | xargs -n 1 git branch -d |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# [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! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 0.XX.XX is the terraform version you need | |
wget https://releases.hashicorp.com/terraform/0.XX.XX/terraform_0.XX.XX_linux_amd64.zip -P ~/Downloads/terraform/ | |
cd ~/Downloads/terraform && unzip terraform_0.11.8_linux_amd64.zip && cd terraform | |
sudo mv terraform /usr/local/bin/ | |
nano ~/.bashrc | |
export PATH="$PATH:/usr/local/bin/terraform" | |
source ~/.bashrc | |
# then from anywhere |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# based off the excellent gist by Martina Pugliese | |
# https://gist.github.com/martinapugliese/cae86eb68f5aab59e87332725935fd5f | |
import boto3 | |
from boto3.dynamodb.conditions import Key, Attr | |
from boto3.dynamodb.types import DYNAMODB_CONTEXT | |
dynamodb = boto3.resource("dynamodb") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// TL,DR : | |
// here is a wrapper for PromiseAll that handles rejection and avoids fast fail behavior | |
const softPromiseAll = arr => { | |
return Promise.all(arr.map( | |
promise => new Promise( | |
resolve => promise.then(resolve).catch(resolve) | |
) | |
)).then(results => results) | |
} |