// Get all databases
var dbNames = db.adminCommand( { listDatabases: 1 } ).databases.map(function(dbObj) {
return dbObj.name;
});
// Size functions
var reduceSize = function(values) {
return Array.sum(values);
};
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
aws s3 mb s3://my-react-site-bucket | |
aws s3api put-bucket-acl --bucket my-react-site-bucket --grant-read 'uri="http://acs.amazonaws.com/groups/global/AllUsers"' | |
aws s3 website s3://my-react-site-bucket --index-document index.html --error-document index.html | |
aws s3api put-bucket-policy --bucket my-react-site-bucket --policy file://bucket.policy.json |
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
version: 0.2 | |
phases: | |
install: | |
runtime-versions: | |
nodejs: 10 | |
commands: | |
- export SKIP="false" | |
- if [[ "$(git log -1 HEAD --pretty=format:%s)" == *\[test\]* ]]; then echo "Installing yarn..." && npm install -g yarn; else export SKIP="true"; fi | |
pre_build: |
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
// Given a string containing a list of dates in either format dd/mm/yyyy or mm/dd/yyyy | |
// where there's one date per line within the string | |
let a=`28/09/2019 | |
30/09/2019 | |
30/09/2019`; | |
// Reverse the date's day and month values and return a string with same input format | |
a = a.split("\n").map((d)=>d.split('/')).map((da)=>([da[1],da[0],da[2]]).join('/')).join("\n") |
How to setup an EC2 instance to run Chrome Headless for usage with Puppeteer
ssh [email protected]
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
npx browser-sync start -s -f . --no-notify --host `ifconfig | grep "inet " | grep -v 127.0.0.1 | cut -d\ -f2` --port 8080 |
function renameObjectKeys(objArr, renameMap) {
const keys = Object.keys(renameMap);
for (let i = objArr.length - 1; i >= 0; i -= 1) {
for (let j = keys.length - 1; j >= 0; j -= 1) {
delete Object.assign(
objArr[i],
{[renameMap[keys[j]]]: objArr[i][keys[j]] }
)[keys[j]];