Thursday 30 April 2020

How to change the current path in python?

import os, sys
BASEPATH = os.path.dirname(os.path.realpath(__file__))
sys.path.insert(0, BASEPATH)
os.chdir(BASEPATH)

Wednesday 29 April 2020

How to resize a batch of images in linux?

assign folder to current location:
FOLDER = $(pwd) 

convert all images using imagemagick and save into output folder:-
find ${FOLDER} -iname ‘*.png’ -exec convert \{} -verbose -resize 400x225\> output/\{} \;

How to tar with a password in ubuntu

tar with a password:
tar czvf - directory | gpg --symmetric --cipher-algo aes256 -o directory.tar.gz.gpg

untar with a password:
gpg -d directory.tar.gz.gpg | tar xzvf -

Thursday 23 April 2020

How to mount a windows shared folder into ubuntu?

sudo mount -t cifs -o username=ninja //192.168.1.xxx/ninja /mnt/ninja

where username and ip are the remote server / windows shared folder information

/mnt/ninja is the local / ubuntu location