Skip to content

Instantly share code, notes, and snippets.

@royz
royz / mongodb_backup.py
Created November 2, 2022 13:59 — forked from Lh4cKg/mongodb_backup.py
MongoDB Dump And Restore Database With Python PyMongo Driver
import bson
from pymongo import MongoClient
def dump(collections, conn, db_name, path):
"""
MongoDB Dump

Run this command from powershell (not from wsl)

docker run --name postgres -p 5432:5432 -e POSTGRES_PASSWORD=SECRET_PASSWORD_123 -v F:\DockerVolumes\postgres\data:/var/lib/postgresql/data:rw -d postgres

Installation

Using chocolaty choco install oh-my-posh

USing powershell Install-Module oh-my-posh -Scope CurrentUser

Using winget winget install JanDeDobbeleer.OhMyPosh -s winget


{
"final_space": true,
"console_title": true,
"console_title_style": "folder",
"blocks": [
{
"type": "prompt",
"alignment": "left",
"horizontal_offset": 0,
"vertical_offset": 1,
@royz
royz / logger.js
Last active February 11, 2022 15:58
A logger config using winston
const path = require('path')
const winston = require('winston')
const LOG_DIR = path.join(path.dirname(path.dirname(__filename)), 'logs')
const consoleLogFormat = winston.format.combine(
winston.format.timestamp({format: 'DD/MM/YYYY HH:mm:ss'}),
winston.format.colorize(),
winston.format.printf(({level, message, label, timestamp}) => {
return `${timestamp} ${label ? `[${label}] ` : ''}${level}: ${message}`;
@royz
royz / MongoDB.md
Last active April 24, 2024 20:20
MongoDB - install, enable authentication & remote access on Ubuntu 20.04

Install MongoDB 5.x

Source: MongoDB Docs

1. Import the public key used by the package management system

wget -qO - https://www.mongodb.org/static/pgp/server-5.0.asc | sudo apt-key add -

2. Create a list file for MongoDB

@royz
royz / ubuntu-sys-info.md
Created November 12, 2021 03:17
show sys info on ubuntu (like the one after startup)
. /etc/update-motd.d/50-landscape-sysinfo
setInterval(() => {
document.querySelectorAll(".circular.style-scope.yt-icon-button")[12].click();
document.querySelectorAll(".style-scope.ytd-menu-popup-renderer")[3].click();
}, 500);
@royz
royz / .bashrc
Last active April 8, 2022 19:09
#!/bin/bash
# enable color support of ls
if [ -x /usr/bin/dircolors ]; then
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
alias ls='ls --color=auto'
alias dir='dir --color=auto'
alias vdir='vdir --color=auto'
alias grep='grep --color=auto'
@royz
royz / install_mongodb.md
Created January 31, 2021 17:11
Install MongoDb on ec2 and configure authentication for remote access

Install MongoDb on ec2 and configure authentication for remote access

1. Install and start mongo service [official docs]

1.1 Import the public key used by the package management system

wget -qO - https://www.mongodb.org/static/pgp/server-4.4.asc | sudo apt-key add -