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
#!/bin/bash | |
mysqlContainer=$(docker ps | grep 'mysql\|maria' | awk {'print $NF'}) #gets every container with a name containing mysql/mariadb | |
postgreContainer=$(docker ps | grep -Ei 'postgre'| grep -Eiv 'gitlab' | awk {'print $NF'}) #gets every container with a name containing postgre | |
gitlabPotsgreContainer=$(docker ps | grep -Ei 'postgre'| grep -Ei 'gitlab' | awk {'print $NF'}) #special gitlab because it use other env variables | |
timestamp=$(date +%Y-%m-%d_%H-%M-%S) | |
for container in $mysqlContainer; do | |
containerStringParts=$(echo $container | tr "." "\n") | |
for single in $containerStringParts; do | |
simpleName=$single |
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
#!/bin/bash | |
filepath=`pwd` | |
if [[ $filepath == *"test-suite/live-deploy" ]]; then | |
read -p "choose environment 'prod' or 'demo': " updateEnv | |
else | |
echo "it seems that you are in the wrong folder, pls got to test-suite/live-deploy" | |
exit 1 | |
fi |
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
#!/bin/bash | |
TIME=$(date +%Y-%m-%d) | |
HOST=$(hostname) | |
BACKUPSAVEPATH=/root/backups_encrypted/ | |
BACKEDUPFILE=$BACKUPSAVEPATH/db-backups-$HOST-$TIME.enc | |
TARGET=gs://f1nalboss-db-backups/ | |
cd /root/backups/db || exit 1 | |
if [ -z "$(ls -A .)" ]; then | |
exit 1 |
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
// 1. Shorten the console log | |
const log = console.log.bind(document) | |
log("does it work?") | |
log("yes") | |
log(5) | |
// 2. Merge two arrays into one | |
const array1 = ["One", "Two", "Three"] | |
const array2 = ["Four", "Five", "Six"] |
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
// 1. Destructive Assignment | |
const data = ["Paul", "too old", "Software Engineer"] | |
const [name, age, job_title] = data | |
console.log(name, age, job_title) // Paul too old Software Engineer | |
// 2. Find an object in Array | |
const employess = [ | |
{name: "Paul", job_title: "Software Engineer"}, |
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
// 1. Max Number | |
const maxN = (arr, n = 1) => [...arr].sort((a, b) => b - a).slice(0, n); | |
maxN([1, 2, 3, 4]); // [4] | |
maxN([2, 4, 6, 4, 3], 2); // [6, 4] | |
// 2. Ternary Operator | |
function temparature(temp) { | |
return temp > 39 || temp < 35.5 |
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
// 1. Valid Json | |
const isValidJSON = (str) => { | |
try { | |
JSON.parse(str); | |
return true; | |
} catch (e) { | |
return false; | |
} | |
}; |
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
//1. Retrieve the First/Last Item In Any JavaScript Array | |
const head = (arr) => arr[0]; | |
const last = (arr) => arr[arr.length - 1]; | |
head([1, 2, 3, 4, 5, 6, 7, 8]); // 1 | |
last([1, 2, 3, 4, 5, 6, 7, 8]); // 8 | |
//2. Comma operator in JavaScript | |
console.log([1, 2, 3, 4][1]); // 2 |