Skip to content

Instantly share code, notes, and snippets.

@eugrus
eugrus / Shift contents of every page in a PDF 1 cm to the right using pdflatex directly.sh
Last active July 26, 2023 23:16
Shift contents of every page in a PDF 1 cm to the right using pdflatex directly
pdflatex -jobname OUTPUT_PDF_FILE_NAME_WITHOUT_EXTENSION '\documentclass{article}\usepackage{pdfpages}\begin{document}\includepdf[pages=-,offset=1cm 0cm]{INPUT_PDF_FILE_NAME_WITH_EXTENSION.pdf}\end{document}'
@eugrus
eugrus / Shift contents of every page in a PDF 1 cm to the right using pdfjam.sh
Created February 18, 2023 01:30
Shift contents of every page in a PDF 1 cm to the right using pdfjam
pdfjam --offset '1cm 0 0 0' INPUT_PDF_FILE_NAME_WITH_EXTENSION.pdf -o OUTPUT_PDF_FILE_NAME_WITH_EXTENSION.pdf
@eugrus
eugrus / pdfmargins
Last active September 20, 2023 15:44
Add 1cm margins left and right to every page of a PDF using pdflatex directly
for INPUT_PDF_FILE in "$@"; do
if [ "$(file -b --mime-type "$INPUT_PDF_FILE")" == "application/pdf" ]; then
OUTPUT_PDF_FILE="${INPUT_PDF_FILE%.pdf}.margins"
pdflatex -jobname "$OUTPUT_PDF_FILE" "\documentclass{article}\usepackage{pdfpages}\begin{document}\includepdf[pages=-,trim=1cm 0cm 1cm 0cm]{$INPUT_PDF_FILE}\end{document}"
else
echo "Skipping non-PDF file: $INPUT_PDF_FILE"
fi
done
@eugrus
eugrus / Add 1cm margins left and right to every page of a PDF using pdfjam.sh
Created February 18, 2023 01:32
Add 1cm margins left and right to every page of a PDF using pdfjam
pdfjam --trim '1cm 0 1cm 0' INPUT_PDF_FILE_NAME_WITH_EXTENSION.pdf -o OUTPUT_PDF_FILE_NAME_WITH_EXTENSION.pdf
@eugrus
eugrus / rename files according to date and time of their last edit.ps1
Last active February 18, 2023 01:49
rename files according to date and time of their last edit in PowerShell
Get-ChildItem *.png | Rename-Item -newname {$_.LastWriteTime.toString("yyyy-MM-dd-HH-mm-ss") + ".png"}
@eugrus
eugrus / log your own public IP.sh
Created February 18, 2023 01:42
log your own public IP
while :; do date ; curl ifconfig.me ; printf "\n"; sleep 1; done |tee ~/iplog
@eugrus
eugrus / Keyb Layout Shortcuts.reg
Last active August 10, 2023 19:39
Workaround for the Windows bug rewriting the user's set up keyboard layout switching shortcuts. This hack rewrites the defaults. This one is set up as following: Ctrl+1 - German; Ctrl+2 - Russian; Ctrl+3 - US-English; Ctrl+4 - Canadian Int for French
Windows Registry Editor Version 5.00
[HKEY_USERS\.DEFAULT\Control Panel\Input Method\Hot Keys]
[HKEY_USERS\.DEFAULT\Control Panel\Input Method\Hot Keys\00000100]
"Virtual Key"=hex:33,00,00,00
"Key Modifiers"=hex:02,c0,00,00
"Target IME"=hex:09,04,09,04
[HKEY_USERS\.DEFAULT\Control Panel\Input Method\Hot Keys\00000101]
@eugrus
eugrus / Switch off the SMB cache.reg
Last active February 18, 2023 02:17
The off switch for the SMB cache in Windows
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\LanmanWorkstation\Parameters]
"DirectoryCacheLifetime"=dword:00000000
@eugrus
eugrus / extract audio from MKVs in the folder.cmd
Last active June 9, 2023 23:54
Extract audio from MKVs in the folder using ffmpeg
FOR /F "tokens=*" %G IN ('dir /b *.mkv') DO ffmpeg -i "%G" -acodec copy "%~nG.aac"
for file in *IMG_*; do mv -- "$file" "${file//IMG_/}"; done