Skip to content

Instantly share code, notes, and snippets.

@farukcankaya
Last active June 14, 2022 19:15
Show Gist options
  • Save farukcankaya/8375df195f68dc1091519f554fcd43b5 to your computer and use it in GitHub Desktop.
Save farukcankaya/8375df195f68dc1091519f554fcd43b5 to your computer and use it in GitHub Desktop.
It is an alias to add your GPG signing key to the existing repository by automatically selecting the GPG key with the email configured in the Git.

Automatically activate GPG signing in a Git repository using alias

If you don't have a GPG signing key yet, generate a new GPG key using one of the resources below:

Creat agpg alias below,

alias agpg="GPG_EMAIL=$(git config user.email) && GPG_KEY=$(gpg --list-secret-keys --keyid-format LONG $GPG_EMAIL | awk '/sec/{print $2}' | cut -d'/' -f 2) && git config user.signingkey $GPG_KEY && git config commit.gpgsign true && printf '%s has been added to the repository associated with %s' $GPG_KEY $GPG_EMAIL"

Then, go into a repository where you want to activate GPG signing and run agpg command.

cd my-awesome-repository
➜ agpg
3AA5C34371567BD2 has been added to the repository associated with [email protected]

The alias lookups existing GPG keys in your machine and add the key associated with the email configured in the repository to Git.

Frequently Used Git Commands

Changing commit message

  • If you want to change the message of the last commit,
    • Run git commit --amend command
    • On the openning vim editor, press i key to switch to edit mode
    • Make your changes on the message then press ESC key to close edit mode
    • To conclude the change, press : and type wq then press Enter key.
    • Done! Your commit message should be updated. Also, the commit hash should be change but there will not be any changes on code.
  • If you want to change the message of a commit in between,
    • Run git rebase -i master command

Terminal Commands

Open files in Sublime Text Editor

  • Create an alias in local/bin:
    • sublime 3: ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" /usr/local/bin/sublime
    • sublime 2: ln -s /Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl /usr/local/bin/sublime
  • Add it to the path on ~/.bash_profile or ~/.zshrc or etc.: export PATH=/usr/local/bin:$PATH
  • Source your profile(~/.bash_profile or ~/.zshrc or etc.): source ~/.zshrc

Reduce Video Size with ffmpeg

ffmpeg -y -i 20210815_171028.mp4 -qmin 10 -qmax 40 -crf 30 -c:v libx264 -b:v 600k -c:a aac -ar 48000 -b:a 128k 20210815_171028_small.mp4

Split / Cut / Trim Video with the same quality

  • Slow but at good quality:ffmpeg -i 20210815_171028_small10.mp4 -ss 00:02:30 -to 00:05:09 -c:v libx264 -crf 30 20210815_171028_small10_2.mp4
  • Fast but sound at the beginning might be lost up to 4 second: ffmpeg -i 20210815_171028_small9.mp4 -ss 00:00:00 -to 00:02:30 -acodec copy -vcodec copy 20210815_171028_small9_1.mp4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment