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