Skip to content

Latest commit

 

History

History
141 lines (106 loc) · 3.43 KB

mydoc.org

File metadata and controls

141 lines (106 loc) · 3.43 KB

My Documentation

Table Of Contents

Docker

Save and Load Image

docker save image:latest | bzip2 > myimage_latest.tar.bz2
docker load < myimage_latest.tar.bz2

MongoDB

Using version 5.0

Setup a mongodb docker container

docker pull mongodb:5.0
mkdir ~/mongodb
cp init-mongo.js ~/mongodb

Export From Docker

Export a database from a docker container to a flat file that can then be used to import in another docker container (basically transferring a database from on server to another)

docker exec <mongodb container> sh -c 'mongodump --authenticationDatabase admin -u <user> -p <password> --db <database> --archive' > db.dump

Import to Docker

Import a database that was exported from another docker container

docker exec -i <mongodb container> sh -c 'mongorestore --authenticationDatabase admin -u <user> -p <password> --db <database> --archive' < db.dump

Mongo Shell

To get to the mongo shell in a docker container. Assumption is the docker container is up and running

docker exec -it mongodb /bin/sh
mongo -u <user> <database>

URI

The URI needed to connect to the mongo database. The example below is for fish shell

set -x MONGODB_URI mongodb://<user>:<pass>@<host>:27017/<db_name>

Patch Files

Using diff to create create/apply patches

Creating a Patch

Create patch by running the following

diff -u OriginalFile UpdatedFile > PatchFile

Assume you have a directory with some files and subdirectories inside. You recursively copy its content to some new directory and do the necessary updates in it. To create a patch file containing the modifications you’ve made, run the following command:

diff -ruN OriginalDir UpdatedDir > PatchFile

Apply a Patch

Run the following to apply the patch

patch OriginalFile < PatchFile

For a directory, run this:

patch -p0 < PatchFile

Undo a Patch

To undo a patch, run the following

patch -R OriginalFile < PatchFile

To undo for a directory, run this:

patch -R -p0 OriginalFile < PatchFile

org-mode

Some shortcuts and keybindings that are out of the box from emacs for org-mode

Source code block

<s<tab>

Example code block

<e<tab>

Folding

shift+tab will cycle through folding/expanding everything

Tangle

Table of Contents

use :toc: