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
| // You could play around with allowed inputs | |
| import Moment from 'moment'; | |
| import { extendMoment } from 'moment-range'; | |
| const moment = extendMoment(Moment); | |
| function excludesTime(start, end, when) { | |
| let startTime = moment(start, 'HH:mm'); | |
| const endTime = moment(end, 'HH:mm'); |
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
| #!/bin/bash | |
| # $1 = # of seconds | |
| # $@ = What to print after "Waiting n seconds" | |
| countdown() { | |
| secs=$1 | |
| shift | |
| msg=$@ | |
| while [ $secs -gt 0 ] | |
| do | |
| printf "\r\033[KWaiting %.d seconds $msg" $((secs--)) |
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
| function x100(nStr) { | |
| function replacer(match, p1, p2) { | |
| return `${`${p1}${p2.padEnd(2, '0').substr(0,2)}`.padStart(1, '0')}.${p2.padEnd(2, '0').substr(2)}`; | |
| } | |
| return String(nStr) // just in case | |
| .replace(/(\d*)\.?(\d*)/, replacer); | |
| } | |
| const tests = [ | |
| '0.00', |
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
| function toDigits (str = '') { | |
| // replace every (/g) non-digit (\D) with the character code (charCodeAt) for that non-digit. | |
| return str.replace(/\D/g, nondigit => nondigit.charCodeAt(0) ); | |
| } | |
| console.log(toDigits('A1b2C3-4'); |
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
| #!/bin/bash | |
| # $1 - a folder containing multiple git repos; i.e. ~/work | |
| # The Mac way to get number of logical cores | |
| # You can run more parallel processes than the number of cores, | |
| # but at some point the process will slow to a crawl | |
| cores=$( sysctl -n hw.ncpu ) | |
| # list all paths below $1 in single column, and pipe to xargs: | |
| # ls -d1 $1/*/ | | |
| # Run a bash command on each path, using $cores number of processes: | |
| # xargs -I % -n 1 -P $cores bash --login -c |
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 jsonData = JSON.parse(responseBody); | |
| const payload = jsonData.id_token.split('.')[1]; // Assuming the JWT is in id_token | |
| const parsed = JSON.parse(atob(payload)); | |
| pm.environment.set('user_id', parsed.user_id); // Assuming user_id is in the payload |
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
| #!/bin/bash | |
| export GIT_ROOT=/Volumes/Routematch/Git | |
| doit() { | |
| cd $GIT_ROOT/$1 | |
| # What branch is this repo on? | |
| # If master branch, checkout package.json and pull latest updates | |
| # If .nvmrc exists, use specified version, else use node version 4 | |
| # Update dependencies |
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
| #!/bin/bash | |
| # Your bastion username should be in ~/.ssh/config | |
| # on|off platform [container] | |
| # on preprod tripnotificationagent | |
| export setting=$1 | |
| export platform=$2 | |
| export container=$3 | |
| if [ -z ${container} ]; then export container=$(grep '"name":\s*"\w*",' $PWD/package.json | awk -F '"' '{ print $4 }'); fi | |
| export service="rmpay_${container}_1" | |
| case $setting in |
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
| #!/bin/bash | |
| # Your bastion username should be in ~/.ssh/config | |
| # platform [container] | |
| # preprod tripnotificationagent | |
| export platform=$1 | |
| export container=$2 | |
| if [ -z ${container} ]; then export container=$(grep '"name":\s*"\w*",' $PWD/package.json | awk -F '"' '{ print $4 }'); fi | |
| echo "Container: $container" | |
| if [ -z ${container} ]; | |
| 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
| #!/bin/bash | |
| # Your bastion username should be in ~/.ssh/config | |
| # platform path [container] | |
| # preprod /routes/genesys/router.js tripnotificationagent | |
| export platform=$1 | |
| export repo=$(basename "$PWD") | |
| export filename=$2 | |
| export container=$3 | |
| if [ -z ${container} ]; then export container=$(grep '"name":\s*"\w*",' $PWD/package.json | awk -F '"' '{ print $4 }'); fi | |
| export service="rmpay_${container}_1" |