Friday, 9 April 2021

To check the status of a FOR looping

You can try to use tqdm.tqdm

for file in tqdm.tqdm(files):

    print(file)



Friday, 26 March 2021

Wednesday, 24 March 2021

How to change docker image directory path?

ref: https://www.guguweb.com/2019/02/07/how-to-move-docker-data-directory-to-another-location-on-ubuntu/


If you want to move the docker data directory on another location you can follow the following simple steps.

1. Stop the docker daemon

sudo service docker stop

2. Add a configuration file to tell the docker daemon what is the location of the data directory

Using your preferred text editor add a file named daemon.json under the directory /etc/docker. The file should have this content:

sudo vi /etc/docker/daemon.json

{
    "data-root": "/home/ninja/docker/",
    "runtimes": {
        "nvidia": {
            "path": "nvidia-container-runtime",
            "runtimeArgs": []
        }
    }
}

of course you should customize the location “/path/to/your/docker” with the path you want to use for your new docker data directory.

3. Copy the current data directory to the new one

sudo rsync -aP /var/lib/docker/ /path/to/your/docker

4. Rename the old docker directory

sudo mv /var/lib/docker /var/lib/docker.old

This is just a sanity check to see that everything is ok and docker daemon will effectively use the new location for its data.

5. Restart the docker daemon

sudo service docker start

6. Test

If everything is ok you should see no differences in using your docker containers. When you are sure that the new directory is being used correctly by docker daemon you can delete the old data directory.

sudo rm -rf /var/lib/docker.old

Follow the previous steps to move docker data directory and you won’t risk any more to run out of space in your root partition, and you’ll happily use your docker containers for many years to come. 😉


How to mount the remote folder into a local folder?

sshfs -o big_writes user@192.168.1.123:/remote/folder/ /home/ninja/local/folder

Monday, 15 March 2021

How to sort file name according to numerical order in python?

 

import numpy as np
import glob
from natsort import natsorted

for file in natsorted(glob.glob("before_255/*")):
print(file)
 
---
 
before_255/0.npy
before_255/1.npy
before_255/2.npy
before_255/3.npy
before_255/4.npy
before_255/5.npy
before_255/6.npy
before_255/7.npy
before_255/8.npy
before_255/9.npy
before_255/10.npy
before_255/11.npy
before_255/12.npy
before_255/13.npy
before_255/14.npy
before_255/15.npy
before_255/16.npy
before_255/17.npy
before_255/18.npy
before_255/19.npy
before_255/20.npy 

How to compress video to mp4 using FFMPEG?

ffmpeg -i input.name -vcodec libx264 output.mp4

ffmpeg -i input.name -vcodec mpeg4 output.mp4

(these videos are playable by browser)


 ffmpeg -i input.mp4 -vcodec libx265 -crf 28 output.mp4

Tuesday, 9 March 2021