Monday, August 07, 2023

VIM underlining a title

 

HOW TO MAKE A CAPTION?

----------------------


(instead of keep tapping '-' to reach the desired length,

 one easy(?) way to achieve the same as above:

 go to the line)


0v$gU        # caption to uppercase

yyp          # duplicate the line

v$r-         # replace the line
ESC



(if same length not care, simply

80i- {escape}

Labels:

Monday, May 15, 2023

Recover from git reset --hard

 Okay, it was a stupid mistake in the morning before coffee, I hard reset my clone to a wrong repo.

So, not just my current branch, but everything is gone, including my other branches of projects working in parallel.

Learnt from experience, don't try any thing more or might be messing things up even worse, searched online.

Thank the author of Git, there is a command, showing all actions(?) I did.

    git reflog                            

Hard reset to the previous hash recovered my not yet pushed branches.

Now, that maybe something I should keep in mind with.

Labels:

Friday, January 13, 2023

ubuntu to mount windows network shared folder

 sudo mount -t cifs -o username=me@here.com //wonderland/path/to/peter ~/mnt/pan

Labels: , ,

Sunday, September 18, 2022

git bare clone - list files / read files howto

 # list files

git ls-tree --full-tree --name-only HEAD

# if utf

git config core.quotepath off


# read files

git show master:path/to/file


# revert bare clone

git config --local --bool core.bare false


# revert single branch on shallow clone

git remote set-branches origin '*'

git fetch --depth 1 -v






Labels:

Thursday, August 25, 2022

ImageMagick bash command - animated GIF <=> JPG/PNG

Accidentally or intentionally converted animated GIF to a bunch of JPGs or PNGs, by:

$ convert  anime.gif  anime.jpg

# above command output a bunch of files:

anime-0.jpg anime-12.jpg anime-16.jpg anime-2.jpg anime-23.jpg anime-5.jpg anime-9.jpg

anime-1.jpg anime-13.jpg anime-17.jpg anime-20.jpg anime-24.jpg anime-6.jpg anime.gif

anime-10.jpg anime-14.jpg anime-18.jpg anime-21.jpg anime-3.jpg anime-7.jpg

anime-11.jpg anime-15.jpg anime-19.jpg anime-22.jpg anime-4.jpg anime-8.jpg

# Note that files are sorted as 0, 1, 10, 11, 12, ... 19, 2, 20, 21, ...

# so, to convert it back, it is NOT as easy as

convert  *.jpg  out.gif

# above gave jerky animation due to wrong sequence of images

# we need:

convert `ls *.jpg | sort --version-sort` out.gif 

# as expected, version sort gives 1, 2, 3, ... 10, 11, 12, ... 19, 20, 21, ...  

# more control, for example:

convert -delay 10 -loop 0 `ls *.jpg | sort --version-sort` out10.gif

delay is 10 * 10ms     ie.  1/10 sec per frame

loop 0 meaning no repeat



Labels: , , ,

Tuesday, March 29, 2022

HOWTO force monitor resolution on mxlinux

After recent upgrade, MX Linux could no longer detect my Viewsonic 22 inch monitor.

Due to unknown, the system therefore set the display to a very primitive resolution - VGA 1024x768 (4:3).

According to the monitor spec (from google), natively it should support 1680x1050 (16:10).



run command:

$ cvt 1680 1050

# 1680x1050 59.95 Hz (CVT 1.76MA) hsync: 65.29 kHz; pclk: 146.25 MHz

Modeline "1680x1050_60.00"  146.25  1680 1784 1960 2240  1050 1053 1059 1089 -hsync +vsync



Add the native mode to display port 0, which is how I connect my monitor:

xrandr --newmode "1680x1050_60.00"  146.25  1680 1784 1960 2240  1050 1053 1059 1089 -hsync +vsync

xrandr

xrandr --addmode DisplayPort-0 1680x1050_60.00



If want to config it every time log in, append the following to .profile


xrandr --newmode "1680x1050_60.00"  146.25  1680 1784 1960 2240  1050 1053 1059 1089 -hsync +vsync

xrandr --addmode DisplayPort-0 1680x1050_60.00

#xrandr --output DisplayPort-0 --off --output DVI-0 --mode 2048x1536_60.00 --pos 0x0 --rotate normal --output HDMI-0 --off

xrandr --output DisplayPort-0 --mode 1680x1050_60.00 --pos 0x0 --rotate normal


Labels: , ,

Tuesday, March 22, 2022

How to ssh pipe copy files from remote to local compressed

ssh  john@192.168.1.49  "cd ~/Documents && tar -cf - assignments/ | gzip -9"  >  assignments.tar.gz


# syntax explanation

ssh    username@remoteIP     "command string"


Labels: , , ,

macOS howto format usb drive to dos compatible, max 4GB

 diskutil eraseDisk FAT32 MY_DISK1 /dev/disk2

Labels: , ,