2025-07-29

Disable key repeating when using vi on Warp terminal

SYSTEM WIDE

$ defaults write -g ApplePressAndHoldEnabled -bool false


ONLY FOR WARP

$ defaults write dev.warp.Warp-Stable ApplePressAndHoldEnabled -bool false


 

2022-11-25

Convert UTF-8 nfd to nfc WHEN adding files into a folder on MacOS

1. when adding files into a folder
/usr/local/bin/convmv -f utf8 -t utf8 --nfc --notest -r /Users/dee/Downloads/
2. select a folder then convert
/usr/local/bin/convmv -f utf8 -t utf8 --nfc --notest -r "$1"

2021-07-01

Remove password from pdf file using ghostscript

Remove password from pdf file using ghostscript
$ gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sPDFPassword=PASSWORD -sOutputFile=OUTPUT.pdf -f ENCRYPTED.pdf
Install GhostScript on Mac
$ brew install ghostscript

2021-02-01

youtube-dl

List format for a video
$ youtube-dl -F 8Gpa_pdHrPE                        
List format for a playlist
$ youtube-dl -F PLBiQZMT3oSxW1RS1hn2jWBgswh0nlcgQZ\&index\=1
[youtube] 8Gpa_pdHrPE: Downloading webpage
[youtube] 8Gpa_pdHrPE: Downloading MPD manifest
[info] Available formats for 8Gpa_pdHrPE:
format code  extension  resolution note
139          m4a        audio only DASH audio   54k , m4a_dash container, mp4a.40.5@ 48k (22050Hz)
140          m4a        audio only DASH audio  134k , m4a_dash container, mp4a.40.2@128k (44100Hz)
251          webm       audio only DASH audio  136k , webm_dash container, opus @160k (48000Hz)
278          webm       256x144    DASH video   95k , webm_dash container, vp9, 30fps, video only
160          mp4        256x144    DASH video  108k , mp4_dash container, avc1.4d400b, 30fps, video only
242          webm       426x240    DASH video  220k , webm_dash container, vp9, 30fps, video only
133          mp4        426x240    DASH video  242k , mp4_dash container, avc1.4d400c, 30fps, video only
134          mp4        640x360    DASH video  274k , mp4_dash container, avc1.4d401e, 30fps, video only
243          webm       640x360    DASH video  405k , webm_dash container, vp9, 30fps, video only
244          webm       854x480    DASH video  752k , webm_dash container, vp9, 30fps, video only
135          mp4        854x480    DASH video 1155k , mp4_dash container, avc1.4d4014, 30fps, video only
247          webm       1280x720   DASH video 1505k , webm_dash container, vp9, 30fps, video only
137          mp4        1920x1080  DASH video 1831k , mp4_dash container, avc1.640028, 30fps, video only
136          mp4        1280x720   DASH video 2310k , mp4_dash container, avc1.4d4016, 30fps, video only
248          webm       1920x1080  DASH video 2646k , webm_dash container, vp9, 30fps, video only
18           mp4        640x360    360p  216k , avc1.42001E, 30fps, mp4a.40.2@ 96k (44100Hz), 123.62MiB
22           mp4        1280x720   720p  511k , avc1.64001F, 30fps, mp4a.40.2@192k (44100Hz) (best)
.bashrc or .zshrc
alias ytdl="youtube-dl --merge-output-format mp4 -f \"bestvideo+bestaudio[ext=m4a]/best\" -o \”%(title)s.%(ext)s\” --embed-thumbnail --add-metadata"
usage
$ ytdl 8Gpa_pdHrPE
$ ytdl PLBiQZMT3oSxW1RS1hn2jWBgswh0nlcgQZ\&index\=1

2020-09-28

Unicode normalization

NFD to NFC with convmv
 $ brew install convmv

 # Convert all files in a directory from NFD to NFC:
 $ convmv -f utf-8 -t utf-8 --nfc --notest .

 # Convert all files in a directory from NFC to NFD:
 $ convmv -f utf-8 -t utf-8 --nfd --notest .
NFD to NFC with iconv
 $ iconv -f UTF-8 -t UTF-8-MAC
NFD to NFC with rsync
 $ rsync --iconv=utf-8,utf-8-mac

2020-09-27

MP4 to GIF with FFMpeg

 $ ffmpeg -i INPUT.mp4 -f gif OUTPUT.gif
Additional options
 -ss 60.0 : skip 60 seconds
 -t 5 : for 5 seconds
 -r 12 : framerate 12fps
 -y : replace existing file
Example
 $ ffmpeg -i INPUT.mp4 -y -f gif -r 24 -ss 63.0 -t 2.5 OUTPUT.gif

2020-08-27

SSH with multiple private keys

Add privat keys
 $ ssh-add ~/.ssh/id_rsa_SERVER
Verify keys
 $ ssh-add -l
Test keys
 $ ssh -v URL_TO_HOST
Connect to server
 $ ssh HOSTNAME_OR_ALIAS

2020-05-27

Tensorflow Error : Failed to get convolution algorithm

Tensorflow Error
tensorflow.python.framework.errors_impl.UnknownError: Failed to get convolution algorithm. This is probably because cuDNN failed to initialize, so try looking to see if a warning log message was printed above.
Solution
  • shell
    export CUDA_VISIBLE_DEVICES=0
  • for tf 2
    import os
    
    os.environ['TF_FORCE_GPU_ALLOW_GROWTH'] = 'true'
  • for tensorflow-gpu v1.8
    from tensorflow.compat.v1 import ConfigProto
    from tensorflow.compat.v1 import InteractiveSession
    
    config = ConfigProto()
    config.gpu_options.allow_growth = True
    session = InteractiveSession(config=config)

2020-04-23

ISO to USB on Mac Mojave

  1. List devices
    $ diskutil list
    /dev/disk0 (internal, physical):
       #:                       TYPE NAME                    SIZE       IDENTIFIER
       0:      GUID_partition_scheme                        *251.0 GB   disk0
       1:                        EFI EFI                     314.6 MB   disk0s1
       2:                 Apple_APFS Container disk1         250.7 GB   disk0s2
    
    /dev/disk1 (synthesized):
       #:                       TYPE NAME                    SIZE       IDENTIFIER
       0:      APFS Container Scheme -                      +250.7 GB   disk1
                                     Physical Store disk0s2
       1:                APFS Volume Macintosh HD - Data     77.5 GB    disk1s1
       2:                APFS Volume Preboot                 82.0 MB    disk1s2
       3:                APFS Volume Recovery                528.1 MB   disk1s3
       4:                APFS Volume VM                      1.1 GB     disk1s4
       5:                APFS Volume Macintosh HD            11.1 GB    disk1s5
    
    /dev/disk2 (external, physical):
       #:                       TYPE NAME                    SIZE       IDENTIFIER
       0:     FDisk_partition_scheme                        *124.2 GB   disk2
       1:             Windows_FAT_32 CCCOMA_X64F             124.2 GB   disk2s1
    
  2. Unmount USB stick
    $ diskutil unmountDisk /dev/disk2
    Unmount of all volumes on disk2 was successful
    
  3. $ sudo dd if=kali-linux-2020.1b-installer-amd64.iso of=/dev/disk2 bs=1m
    Password:
    2075+1 records in
    2075+1 records out
    2176778240 bytes transferred in 656.146374 secs (3317519 bytes/sec)
    

2020-04-17