Skip to content

Instantly share code, notes, and snippets.

@tolgahanakgun
Last active September 2, 2020 20:40
Show Gist options
  • Save tolgahanakgun/04f8fd8c55341e61cf73950be2e8066c to your computer and use it in GitHub Desktop.
Save tolgahanakgun/04f8fd8c55341e61cf73950be2e8066c to your computer and use it in GitHub Desktop.
some time saving tips
#Lists the binary files which runs with privileged rights
find / -perm -u=s -type f 2>/dev/null
# add the lines below to .bashrc file for autostarting the ssh-agent and adding all the private keys in msys2
eval `ssh-agent -s` 1>/dev/null
find ~/.ssh/ -type f -exec grep -l "PRIVATE" {} \; | xargs ssh-add >/dev/null 2>&1
# add the lines below to .bashrc file for auto setting the ssh-agent pid or run ssh-agent
if [[ "$(ps | grep ssh-agent | wc -l)" -eq "0" ]]; then
eval `ssh-agent -s` 1>/dev/null
ssh-add .ssh/id_ed25519 >/dev/null 2>&1
else
SSH_AGENT_PID=$(ps | grep ssh-agent | awk '{print $1}')
fi
# set upstream branch fetch only
git remote set-url --push upstream DISABLED
# delete remotely deleted branches
git remote prune origin
# download playlist from youtube as audio file with best quality with cover photo
# skips when encounters with a copyrighted video
# requires ffmpeg and AtomicParsley
youtube-dl -i -f bestaudio[ext=m4a] --embed-thumbnail --add-metadata -o "%(title)s.%(ext)s" "PLy6cHAjZSjBU6_o88-59l9NZLbbUi6IJX"
# flush iptables
iptables-save | awk '/^[*]/ { print $1 }
/^:[A-Z]+ [^-]/ { print $1 " ACCEPT" ; }
/COMMIT/ { print $0; }' | iptables-restore
# download a video parallel
youtube-dl --external-downloader aria2c --external-downloader-args "-c -j 3 -x 3 -s 3 -k 1M" "https://www.youtube.com/watch?v=dDzbfoRtqME"
-c -> continue
-j -> max-concurrent-downloads
-x -> max-connection-per-server
-s -> split
-k -> min split size
# fit docker ps printout to console
alias psdocker="docker ps -a | less -S"
alias lsdocker="docker container ls -l | less -S"
# add Logitech M546 keybinding in ubuntu with xbindkey
# all possible key combinations -> http://wiki.linuxquestions.org/wiki/XF86_keyboard_symbols
# create a file with default entries -> xbindkeys --defaults > ~/.xbindkeysrc
# add the lines to ~/.xbindkeysrc file
# install -> apt install xdotool xbindkeys
"xdotool key XF86Back"
b:6
"xdotool key XF86Forward"
b:7
"xdotool keydown XF86AudioLowerVolume"
b:8
"xdotool keyup XF86AudioLowerVolume"
b:8 + Release
"xdotool keydown XF86AudioRaiseVolume"
b:9
"xdotool keyup XF86AudioRaiseVolume"
b:9 + Release
# list only executables
alias lse="find . -maxdepth 1 -type f -executable"
# get ip address country with whois in bash
whois 8.8.8.8 |grep country -i -m 1 |cut -d ':' -f 2 |xargs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment