# start the server:
mongod --dbpath /path/to/data/to/be/stored --logpath /log/path/mongo.log
# enter the shell:
mongo
# or
mongos
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
# make packages up to date | |
sudo pacman -Syu | |
# install Docker | |
sudo pacman -S docker | |
# start Docker service | |
sudo systemctl start docker.service | |
# stop Docker service |
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
import os | |
def create_folders(num, prefix=''): | |
"""Creates specified numbers of folders with a prefix in front of each""" | |
for num in range(1, num+1): | |
if not os.path.exists(f"{prefix}{str(num)}"): | |
os.makedirs(f"{prefix}{str(num)}") |
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
# add following lines to the .bashrc file | |
alias java11='/usr/lib/jvm/java-11-openjdk/bin/java' | |
alias javac11='/usr/lib/jvm/java-11-openjdk/bin/javac' | |
alias java16='/usr/lib/jvm/jdk-16.0.1/bin/java' | |
alias javac16='/usr/lib/jvm/jdk-16.0.1/bin/javac' | |
alias jshell16='/usr/lib/jvm/jdk-16.0.1/bin/jshell' |
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
sudo pacman -Sy postgresql | |
sudo -u postgres -i initdb /var/lib/postgres/data | |
sudo systemctl start postgresql && sudo systemctl status postgresql | |
sudo systemctl enable postgresql | |
sudo su - postgres | |
psql | |
# SQL commands | |
exit |
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
// Fast: | |
function getMaxSubSum(arr) { | |
let maxSum = 0; | |
let partialSum = 0; | |
for (let item of arr) { // for each item of arr | |
partialSum += item; // add it to partialSum | |
maxSum = Math.max(maxSum, partialSum); // remember the maximum | |
if (partialSum < 0) partialSum = 0; // zero if negative | |
} |
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
const sortArrayObjs = function(arr, prop1, prop2) { | |
let sort1 = [...arr].sort((a, b) => { | |
if (a[prop1] == b[prop1]) { | |
if (a[prop2] === b[prop2]) return 0; | |
return (a[prop2] < b[prop2]) ? -1 : 1; | |
} else { | |
return (a[prop1] < b[prop1]) ? -1 : 1; | |
} | |
}); | |
return sort1; |
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
var el = function (element) { | |
if (element.charAt(0) === "#") { | |
// If passed an ID... | |
return document.querySelector(element); // ... returns single element | |
} | |
return document.querySelectorAll(element); // Otherwise, returns a nodelist | |
}; |
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
const { exec } = require("child_process"); | |
exec("ls -la", (error, stdout, stderr) => { | |
if (error) { | |
console.log(`error: ${error.message}`); | |
return; | |
} | |
if (stderr) { |