This file contains hidden or 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
| # Information about arguments and the current script | |
| echo "# arguments called with ----> ${@} " | |
| echo "# \$1 ----------------------> $1 " | |
| echo "# \$2 ----------------------> $2 " | |
| echo "# path to me ---------------> ${0} " | |
| echo "# parent path --------------> ${0%/*} " | |
| echo "# my name ------------------> ${0##*/} " | |
| # Check that a variable is defined and not empty ("") | |
| if [ -z "$1" ]; then |
This file contains hidden or 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
| // Use Gists to store code you would like to remember later on | |
| console.log(window); // log the "window" object to the console |
This file contains hidden or 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
| PS1="\033[32m\u\033[m@\033[33m\h \033[34m\w\n\033[m$ " |
This file contains hidden or 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
| lsof -ti :<port> | xargs kill |
This file contains hidden or 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
| -- Lowercase all files in a directory | |
| for f in `ls`; do mv "$f" "`echo "$f" | awk '{print tolower($0)}'`"; done |
This file contains hidden or 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
| # property validation | |
| expect(result).to.all.have.property('propName'); | |
| expect(result).to.all.have.property('propName', 'propVal'); | |
| expect(obj).to.have.deep.property('field1.field2').that.is.oneOf([ 0, 1, 2 ]) | |
| expect(obj).to.have.deep.property('field1.field2').that.is.within(0, 2) |
This file contains hidden or 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
| fetch('/myurl', { | |
| method: 'POST', | |
| credentials: 'include', | |
| headers: { 'Content-Type': 'application/json' }, | |
| body: JSON.stringify({ foo, bar }) | |
| }) |
This file contains hidden or 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
| psql --host=mypostgresql.c6c8mwvfdgv0.us-west-2.rds.amazonaws.com --port=5432 --username= |
This file contains hidden or 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
| const extractJWTPayload = (jwt) => { | |
| const jwtComponents = jwt.split('.'); | |
| // A JWT string is divided into 3 components, the second of which | |
| // contains the payload (user information) which is what we care about. | |
| if (jwtComponents.length !== 3) | |
| throw new Error('invalid jwt'); | |
| // Base64 decode with urlsafe character set | |
| const decoded = atob(jwtComponents[1].replace(/_/g, '/').replace(/-/g, '+')); | |
| return JSON.parse(decoded).data; | |
| } |
This file contains hidden or 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
| "$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" |
OlderNewer