Skip to content

Instantly share code, notes, and snippets.

@beli-sk
beli-sk / git-prompt.sh
Created August 2, 2021 21:11
git prompt on Gentoo
# /etc/bash/bashrc.d/git-prompt.sh
. /usr/share/git/git-prompt.sh
export GIT_PS1_SHOWDIRTYSTATE=1
if ${use_color} ; then
PS1=`echo "$PS1" | sed -r 's| \\\\\\$|\\\[\\\\033[01;31m\\\]$(__git_ps1)\\\[\\\\033[01;34m\\\] \\\\$|'`
else
PS1=`echo "$PS1" | sed -r 's| \\\\\\$|$(__git_ps1) \\\\$|'`
fi
@beli-sk
beli-sk / inputrc
Created January 9, 2020 08:45
Bash (or any readline prompt) vi-mode with tweaks
set editing-mode vi
set show-mode-in-prompt on
set vi-ins-mode-string "+"
set vi-cmd-mode-string ":"
$if mode=vi
set keymap vi-command
# these are for vi-command mode
Control-l: clear-screen
@beli-sk
beli-sk / kubens_bashrc.sh
Last active July 28, 2021 14:56
Bash: set default namespace for kubectl command
### kubens - set default namespace for kubectl command
function kubens {
if [[ -n "$1" ]] ; then
alias kubectl="kubectl -n $1"
export HELM_NAMESPACE="$1"
PS1=$( echo "$PS1" | sed -r 's/(.*)\(ns:[^)]*\)(.*)/\1\2/' )
PS1="(ns:$1)${PS1}"
else
unalias kubectl
@beli-sk
beli-sk / irexec.desktop
Last active April 5, 2019 19:14
LIRC Pulseaudio volume with Creative SB X-Fi Surround 5.1 Pro
[Desktop Entry]
Name=Irexec daemon
Comment=Handle IR command server
Exec=/usr/bin/irexec
Icon=applications-system
Terminal=false
Type=Application
Categories=AudioVideo;Application;X-Fedora-Extra
@beli-sk
beli-sk / kubetmp.sh
Last active February 25, 2019 13:43
Kubernetes: kubectl temporary environment per session
#!/bin/bash
# to be sourced by interactive shell or added to .bashrc
#
# kubectl temporary environment per session
# - any `kubectl config` changes (like use-context) go to temporary file
#
KUBETMPDIR=`mktemp -d`
[[ "$1" == "--merged" || "$1" == "-m" ]] && touch "${KUBETMPDIR}/kubeconfig" || cp "${HOME}/.kube/config" "${KUBETMPDIR}/kubeconfig"
eval "function kubetmp_cleanup {
rm -f ${KUBETMPDIR}/kubeconfig
@beli-sk
beli-sk / Disable gnome-keyring-ssh
Last active September 7, 2018 08:54
Disable Gnome Keyring SSH agent in (X)Ubuntu
# Disable Gnome Keyring SSH agent in Ubuntu
# To allow using ssh-agent from OpenSSH, mainly because
# gnome-keyring does not like EC-type SSH keys
# as regular user (for which to disable):
systemctl --user mask gnome-keyring-ssh.service
pam-auth-update
# and disable "GNOME Keyring Daemon..."
# which probably also disables automatic keyring unlocking on login
@beli-sk
beli-sk / plumbing.md
Last active February 16, 2024 04:07 — forked from schacon/plumbing.md
git plumbing cheat sheet

the plumbing commands

refs

  • update-ref

    • update a branch (or other reference) to point to a specific commit sha
  • symbolic-ref

    • update a reference (usually HEAD) to point to another reference (like a branch)
# show commit tree (possibly append --all for all branches)
git log --graph --oneline --decorate
# save previous as an alias and then just use 'git tree'
git config --global alias.tree "log --graph --oneline --decorate"
# restoring lost commit (e.g. after git reset --hard HEAD~1)
git fsck --lost-found
# or
git reflog
git merge <hash>
@beli-sk
beli-sk / apache-2.4_tls.conf
Last active December 4, 2015 15:57
HTTPS config
SSLCipherSuite ECDHE:DHE:HIGH:+SHA1:!MEDIUM:!LOW:!EXP:!aNULL:!eNULL:!PSK:!RC4
SSLHonorCipherOrder on
SSLProtocol all -SSLv3
<VirtualHost ...>
SSLEngine on
Header always set Strict-Transport-Security "max-age=15552000"
Header set Public-Key-Pins "pin-sha256=\"yiUxVRHwMNoXtZZS/RtgPr2bCNyc6L8IJrmTU80HSlA=\"; pin-sha256=\"XQIfp7PhqFyw93tHv86EhngOxSVVdZy0Dj1mFmI81PM=\"; max-age=15552000"
SSLUseStapling on
...
@beli-sk
beli-sk / bash_oneliners.sh
Last active July 18, 2017 14:38
Useful CLI one-liners (Linux)
# Number of open file descriptors per process (replace 'httpd' with process name)
lsof -p $( echo `ps -o pid= -C httpd` | tr ' ' ',' ) | awk '{ print $2 }' | uniq -c
# Show swap usage per process, >=1000 kB
cat /proc/*/status | egrep -B30 '^VmSwap:[[:space:]]+[[:digit:]]{4,}' | egrep '^Name|^Pid|^VmSwap'
# generate password
head -c12 /dev/urandom | base64 | tr '+/' '_-' | tr -d '='
# days to web server certificate expiry