ZSH completion of Kubectl supplied by minikube or microk8s
ZSH completion of Kubectl supplied by minikube or microk8s If you are using kubectl that is namespaced by minikube or microk8s and refer to kubectl using an alias then completion wont work by default.
This is because zsh expands the alias before attempting completion by default.
So instead of just sourcing the completion command and adding an alias you need to enable the complete_aliases option, so what you need to add to your .
Bootstrapping a Debian Lenny server with puppet from backports
Initial bootstrap make sure lsb-release is installed
aptitude install lsb-release add the backports key
/usr/bin/wget -O - http://backports.org/debian/archive.key | /usr/bin/apt-key add and repository source
cat > /etc/apt/sources.list <<EOF deb http://ftp.au.debian.org/debian lenny main contrib non-free deb-src http://ftp.au.debian.org/debian lenny main contrib non-free deb http://security.debian.org/ lenny/updates main contrib non-free deb-src http://security.debian.org/ lenny/updates main contrib non-free deb http://www.backports.org/debian lenny-backports main contrib non-free EOF do an update to get the backports packages in your package list
Getting the full fingerprint for a gpg key for apt sources in puppet
If you have ever seen the error
Warning: /Apt_key[Add key: 25E010CF from Apt::Source freeswitch]: The id should be a full fingerprint (40 characters), see README. And wondered how to get the full fingerprint, here’s how.
On a test box, import the key manually using the instructions from whoever the key is for, then on that machine run the command (as root)
apt-key adv –list-public-keys –with-fingerprint –with-colons That will list the keys currently installed.
Git Cheatsheet For Some Not So Common Activities
Post Receive Hook to Update The Checked Out Copy #!/bin/sh cd .. env -i git reset –hard Add a remote Note: There is no : between the host and the path
git remote add origin ssh://user@host/path/to/repo/.git Undo the last commit If you want the changes to stay in the working directory but just want to undo the actual commit.
git reset –soft HEAD^ If you want to get rid of the last change completely then to.
PostgreSQL tips
Get the size of a database SELECT pg_size_pretty(pg_database_size('somedatabase')) As fulldbsize; Get the size of a table (excluding the indexes) SELECT pg_size_pretty( pg_relation_size('your_table') ); Get size of a table (including the indexes) SELECT pg_size_pretty( pg_total_relation_size('your_table') ); Get the list of all databases including their sizes SELECT tablename,pg_size_pretty(pg_total_relation_size(tablename)) AS total_usage FROM pg_tables WHERE schemaname != 'pg_catalog' AND schemaname != 'information_schema' Get list of tables in information schema ‘database’ SELECT * FROM information_schema.tables; Get a list of all the db sizes for all the dbs on a server SELECT datname as "DB Name", pg_size_pretty(pg_database_size(datname)) AS "Full DB Size" FROM pg_catalog.
Re-encode video to save disk space
Quick and easy x264 example ffmpeg -i input.mp4 -c:v libx264 -crf 18 -preset slow -c:a copy output.mp4 Quick and easy x265 example ffmpeg -i input.mp4 -c:v libx265 -crf 18 -preset medium -c:a copy output.mp4 Change the resolution Add the argument -vf scale=1280:-1 to scale the width to 1280 and keep the height in proportion Whats the difference in presets ? x264 presets are more for adjusting the time taken to encode the video.
Using linux software raid
Get current raid status cat /proc/mdstat Replace a degraded disk in an array First work out which disk it is in the array (e.g. /dev/sda), then use lshw to get the serial number of the disk.
Now mark all the partitions on the disk as degraded
mdadm –manage /dev/md0 –fail /dev/sda1 mdadm –manage /dev/md0 –remove /dev/sda1 Now power down the machine and replace the failed drive using the serial number from lshw to identify it if necessary