Nota Rawak

nota segera sebagai rujukan

  1. Video Cutting with FFmpeg

    Run command as follows:-
    ffmpeg -i out.mp4 -ss 00:00:01 -t 00:01:00 out1.mp4
    -ss: The start time of the video
    -t: The time where the video should end
  2. Combining/Merging Pictures with [ImageMagick]

    • Left-to-Right:
      convert +append -background black image1.jpg image2.jpg output.jpg
    • Top-to-Bottom:
      convert -append -background black image1.jpg image2.jpg output.jpg
    • EXAMPLE of merging photos with borders and centered position:-
      convert +append -background black -border 1 -bordercolor white -gravity center image1.jpg image2.jpg output.jpg
  3. Convert A .txt File to PDF with Enscript & GhostScript

    1. First of all, convert a .txt file to .ps with [5] enscript by running the following command:-
      enscript -p output.ps input.txt
    2. And then convert the .ps file to .pdf with [6] GhostScript:-
      ps2pdf output.ps output.pdf
    Rujukan: How to convert a text file to PDF format on Linux
  4. Properly Disconnect & Reconnect to WiFi with wpa_supplicant

    This is somehow a primitive method for connecting to a wireless network but I just prefer doing it this way.
    • Connect to A Different Network

      To disconnect from current connection and connect to a different network, disconnect properly by:
      1. Setting the wireless device down first:
        sudo ip link set dev wlp2s0 down
      2. Releasing dhcpcd (otherwise, the initial DHCP client daemon lease will keep running in background. As such, we will encounter an error when connecting to a different network):
        sudo dhcpcd -k wlp2s0
      3. Totally kill the wpa_supplicant process (this step is important to prevent any issues later):
        sudo killall wpa_supplicant
      4. Setting the device up again:
        sudo ip link set dev wlp2s0 up
      5. Connecting to a different network by running wpa_supplicant command with the path to the new network config file:
        sudo wpa_supplicant -B -i wlp2s0 -c /etc/wpa_supplicant/wpa_supplicant.conf
      6. And lastly, restarting dhcpcd:
        sudo dhcpcd wlp2s0

      Provided below is an example of a valid wpa_supplicant.conf file:-

      ctrl_interface=/var/run/wpa_supplicant
      ctrl_interface_group=wheel
      update_config=1
      fast_reauth=1
      ap_scan=1
      
      network={
          ssid="MYSSID"
          psk=59e0d07fa4c7741797a4e394f38a5c321e3bed51d54ad5fcbd3f84bc7415d73d
      }
    • Reconnect to The Same Network

      If there is a need to disconnect from current connection and later we need to reconnect to the same network, just run the below commands:

      1. Disconnect:
        sudo ip link set dev wlp2s0 down
      2. Reconnect:
        sudo ip link set dev wlp2s0 up

      Since DHCP client daemon lease has been running in background and we are reconnecting to the same network, there is no need to release / restart dhcpcd.

    Rujukan: dhcpcd from archwiki

  5. Displaying Codes Behind A Symbol In Pygments

    The good thing about syntax highlighting with Pygments is that we do not have to use HTML Escape in order to display a character/symbol in our codes.
    However, I believe that there may be times when we need to present the code behind such character/symbol in our highlighted codes. So, here is the tip to have this purpose done:
    Let's say we need to have this '' character code shown in our highlighted codes. All we need to do is to replace the <&> symbol with its HTML escape which is <&amp;>. In this case, the code behind the symbol used in this example is <&#8984;>. So in our code writing, we should type it this way; <&amp;#8984;>.
  6. Vim, Vimtex and Zathura

    Related post: Vimtex and Zathura

    As I decided to have Vim back as the default editor, some things need to be done in order for synctex search to work.

    • open .tex file with the below command:-
      vim --servername VIM
    • OR place this line in .zshrc file:-
      alias vim="vim --servername VIM"
    • Also, to make it work when opening .tex files from ranger, add this line to the .config/ranger/rifle.conf file:-
      ext tex, has vim = vim --servername VIM "$@"

    Additional Notes

    The additional configuration above is not needed for gvim as it works out of the box.

    Rujukan: Synctex with Zathura (linux, easy)

  7. Multiple SSH Key Pairs Generation

    1. Jana kekunci SSH seperti contoh di bawah:-
      - untuk repositori
      git@github.com:saya/blog.git:
      ssh-keygen -f ~/.ssh/id_rsa.blog
      DAN
      - untuk repositori
      git@github.com:saya/saya.github.io.git (web):
      ssh-keygen -f ~/.ssh/id_rsa.web
    2. Daripada kekunci SSH yang telah dicipta di atas, buat satu fail konfigurasi yang disimpan sebagai ~/.ssh/config dan mengandungi butiran-butiran seperti berikut:-
      # account for the blog repo on github
      Host github.com-blog
          HostName github.com
          User saya
          IdentitiesOnly yes
          IdentityFile ~/.ssh/id_rsa.blog
      
      # account for the web repo on github
      Host github.com-web
          HostName github.com
          User saya
          IdentitiesOnly yes
          IdentityFile ~/.ssh/id_rsa.web
    3. Sunting parameter URL di bahagian [remote "origin"] yang terkandung di dalam fail tempatan .git/config, sebagai contoh daripada tetapan di atas:-
      url = git@github.com-blog:saya/blog.git
      url = git@github.com-web:saya/saya.github.io.git

      Beri perhatian kepada alias hos nama -blog dan -web yang ada pada fail ~/.ssh/config serta .git/config. Lihat juga pada bahagian IdentitiesOnly yes yang terkandung di dalam fail ~/.ssh/config. Baris ini adalah amat penting dalam memastikan bahawa SSH benar-benar menggunakan Fail Identiti seperti yang telah dinyatakan mengikut bahagian masing-masing.

    Kaedah ini juga berfungsi untuk GitLab.

    Rujukan: Using Multiple SSH Keys with Github

  8. Additional Config for Ranger Files

    • commands.py
      class empty(Command):
          """:empty
      
          Empties the trash directory ~/.Trash
              """
      
          def execute(self):
              self.fm.run("sudo rm -rf /home/raihan/.Trash/.*")
              self.fm.run("sudo rm -rf /home/raihan/.Trash/*")
    • rc.conf
      map DD shell mv -t /home/raihan/.Trash %s
    • rifle.conf
      #-------------------------------------------
      # Personal Settings
      #-------------------------------------------
      #ext mp4|mpeg|avi|flv,       has mpv,      X, flag f = mpv --fs -- "$@"
      ext mp4|mpeg|avi|flv,       has mpv,      X, flag f = mpv -- "$@"
      ext 7z|ace|ar|arc|bz2?|cab|cpio|cpt|deb|dgc|dmg|gz,  has 7z = 7z x -oarchives -- "$@"
      ext iso|jar|msi|pkg|rar|shar|tar|tgz|xar|xpi|xz|zip, has 7z = 7z x -oarchives -- "$@"
      #ext x?html?, has firefox,        X, flag f = firefox -- "$@"
      ext tex, has vim = vim --servername VIM "$@"
  9. Packages To Be Installed for Complete Function of Fcitx

    Fcitx packages that allow full function to applications such as Vim / NeoVim, LibreOffice and Chromium for different language inputs e.g. Japanese:-
  10. Completely Kill A Process/Program

    • To kill a process e.g. cmus, find out the pid number with the following command first:-
      pidof cmus
    • And then kill it by running the below command:-
      kill <the-pid-number-obtained-by-the-above-command>
  11. Grub2 Menuentry for Chainloading FreeBSD-UEFI

    menuentry 'FreeBSD 11.1' {
        insmod ufs2
        set root=(hd0,gpt10)
        chainloader /boot/boot1.efi
    }

    Rujukan: fighting with grub2

  12. Penukaran Penyusun untuk Latexmk

    Untuk penggunaan meluas bahasa asing lain seperti bahasa Arab, Jepun dan Korea dalam penghasilan dokumen dengan LaTeX, hamba tukarkan penyusun pdflatex kepada xelatex.

    Hamba tambahkan baris-baris di bawah ke dalam fail konfigurasi .vimrc.local (untuk ‘plugin’ vimtex):-

    let &rtp  = '~/.vim/bundle/vimtex,' . &rtp
    let &rtp .= ',~/.vim/bundle/vimtex/after'

    Dan kemudiannya hamba kemas kini fail-fail konfigurasi yang berikut:-

    • Fail .vimrc.local
      Baris <let g:vimtex_latexmk_options="-pdf -pdflatex='pdflatex -file-line-error -shell-escape -synctex=1'"> ditukarkan kepada:
      let g:vimtex_latexmk_options="-pdf -pdflatex='xelatex -file-line-error -synctex=1 -interaction=nonstopmode -shell-escape %S %O -verbose'"
    • Fail .latexmkrc
      Baris <$pdflatex = 'pdflatex -file-line-error -synctex=1 -interaction=nonstopmode -shell-escape %O %S';> digantikan kepada:
      $pdflatex = 'xelatex -file-line-error -synctex=1 -interaction=nonstopmode -shell-escape %S %O -verbose';

    Rujukan: latexmk compile fail with xelatex

  13. Perubahan Hari Kepada Kalendar Hijrah

    Ada masanya hari pada Kalendar Hijrah akan berubah kerana pengiraan dibuat berdasarkan kemunculan bulan atau dalam istilah Inggerisnya dipanggil 'lunar calendar'. Jadi akan ada keperluan untuk menyunting dua fail ini; satu untuk dipamerkan pada [i] conky dengan konfigurasi dalam bahasa python dan satu lagi untuk dipamerkan di weblog ini melalui [ii] skripjava.
    1. Suntingan pada fail hijri.py dari pakej ummalqura:-
      #id = mcjdn - UmalqurraArray.ummalqura_dat[index - 1] + 1   # komen baris asal
      id = mcjdn - UmalqurraArray.ummalqura_dat[index - 1] + 0    # tambah baris baru
    2. Suntingan pada fail moment-hijri.js:-
      //hd = mjdn - ummalqura.ummalquraData[i - 1] + 1    # komen baris asal
      hd = mjdn - ummalqura.ummalquraData[i - 1] + 0      # tambah baris baru
  14. Mengatasi Kegagalan Git Ketika Menambah Submodule

    Saya terima ralat ketika cuba menambah submodule public untuk git melalui baris perintah berikut, ie.:-
    git submodule add -b master git@github.com-web:saya/saya.github.io.git public
    Ralat yang diterima adalah:-
    Cloning into '$HOME/hugo/blog/public'...
    Enter passphrase for key '$HOME/.ssh/id_rsa.web': 
    warning: You appear to have cloned an empty repository.
    fatal: 'origin/master' is not a commit and a branch 'master' cannot be created from it
    Unable to checkout submodule 'public'

    Jadi saya berjaya selesaikan masalah ini melalui pembacaan di [halaman ini].

    Langkah-langkah yang perlu dibuat adalah:-

    1. Periksa sekiranya origin ada ditetapkan dengan menjalankan baris perintah seperti di bawah:-
      git remote -v
      Jika tiada apa-apa input yang keluar, tinggalkan langkah kedua dan teruskan dengan langkah ketiga diikuti langkah-langkah berikutnya.
      Jika mendapat keputusan seperti ini,
      origin	git@github.com-blog:saya/blog.git (fetch)
      origin	git@github.com-blog:saya/blog.git (push)
      teruskan dengan langkah kedua sehingga akhir.
    2. Singkirkan tetapan remote yang lama dengan baris perintah berikut:-
      git remote remove origin
    3. Kemudian bolehlah menambah remote yang betul dengan:-
      git remote add origin git@github.com-blog:saya/blog.git
    4. Dan akhir sekali, tambahkan submodule:-
      git submodule add -b master git@github.com-web:saya/saya.github.io.git public
      Maklum balas yang sepatutnya diterima adalah seperti ini:-
      Adding existing repo at 'public' to the index
  15. Tip Hosting dengan Netlify Melalui GitLab

    Netlify tidak mampu memproses git clone untuk memasang tema. Jalan terbaik untuk mengatasinya adalah dengan memadam subdirektori .git yang ada di dalam direktori tema ataupun dengan menambah git submodule.
  16. Menggabung Fail PDF dengan GhostScript

    Jalankan baris perintah seperti di bawah:-
    gs -dSAFER -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile=output.pdf *-laluan-ke-direktori-atau-fail-fail-PDF.pdf

    Rujukan: How to Use Ghostscript

  17. Nota Pendek

    1. nftables to replace iptables.

Kali terakhir halaman ini dikemaskini/disemak semula adalah pada .
Top