Posts

Showing posts from May, 2022

git squash commits

 See  rebase - Squash my last X commits together using Git - Stack Overflow git rebase -i <after-this-commit> <after-this-commit>  is commit X+1 i.e. parent of the oldest commit you want to squash. This brings up the editor Choose "pick" on the second commit Choose "squash" on the subsequent commits

Imagemagick compress jpg

  magick flowchart.jpg -strip -interlace Plane -gaussian-blur 0.05 -quality 85% result.jpg See  image processing - Recommendation for compressing JPG files with ImageMagick - Stack Overflow

Batch file file read

  Batch file - read file into variable @echo OFF rem Has about 1024 character buffer limit rem See: https://stackoverflow.com/questions/3068929/how-to-read-file-contents-into-a-variable-in-a-batch-file echo Hello File > file.txt set /p ReadBack=<file.txt echo Text is %Readback% Outputs:  Text is: Hello File

Windows Batch

 Batch file: Enable delayed expansion From:  EnableDelayedExpansion - Windows CMD - SS64.com EnableDelayedExpansion Delayed Expansion will cause variables within a batch file to be expanded at execution time rather than at parse time , this option is turned on with the  SETLOCAL  EnableDelayedExpansion  command.

Getting absolute path of current script in Python

  Getting absolute path of current script in Python from pathlib import Path script_path = Path ( __file__ ) . resolve ( ) . parent print ( f"Script path is { script_path } " )