Skip to content

Instantly share code, notes, and snippets.

@alipek
alipek / remove-disabled-snaps.sh
Created April 18, 2024 08:53
Remove old disabled snaps
#!/usr/bin/env bash
snap list --all | awk '/disabled/{print $1, $3}' | xargs -l bash -c 'sudo snap remove $0 --revision=$1'
@alipek
alipek / autossh.service
Created March 18, 2022 20:01 — forked from thomasfr/autossh.service
Systemd service for autossh
[Unit]
Description=Keeps a tunnel to 'remote.example.com' open
After=network.target
[Service]
User=autossh
# -p [PORT]
# -l [user]
# -M 0 --> no monitoring
# -N Just open the connection and do nothing (not interactive)
@alipek
alipek / bcm57765or57785fix
Created May 24, 2021 09:22 — forked from samgooi4189/bcm57765or57785fix
Fixing Broadcom Corporation BCM57765/57785 SDXC/MMC Card Reader
Follow the WORKAROUND:
1. Add a comand to /etc/rc.local, add the following line above "exit 0":
setpci -s 00:1c.2 0x50.B=0x41
2. Add the same comand to /etc/apm/resume.d/21aspm (which does not exist yet):
setpci -s 00:1c.2 0x50.B=0x41
3. Add the following to /etc/modprobe.d/sdhci.conf:
options sdhci debug_quirks2=4
4. Re-generate initrd:
sudo update-initramfs -u -k all
5. Reboot or reload sdhci module:
@alipek
alipek / kubectl-run-with-pvc.sh
Created December 2, 2020 09:17 — forked from yuanying/kubectl-run-with-pvc.sh
kubectl run with PVCs
#!/bin/bash
IMAGE="gcr.io/google-containers/ubuntu-slim:0.14"
COMMAND="/bin/bash"
SUFFIX=$(date +%s | shasum | base64 | fold -w 10 | head -1 | tr '[:upper:]' '[:lower:]')
usage_exit() {
echo "Usage: $0 [-c command] [-i image] PVC ..." 1>&2
exit 1
}

Context operations

Show all contexts

kubectl config get-contexts

Add new context

kubectl config set-context name-of-context --user=your-username --cluster=cluster-name --namespace=name-of-namespace
#!/bin/bash
if [ -z "${MYSQL_ROOT_PASSWORD}" ]; then
>&2 echo "Need root password to init privileges for database prefix"
fi
mysql -uroot -p$MYSQL_ROOT_PASSWORD <<EOF_GRANT
GRANT ALL PRIVILEGES ON \`${MYSQL_DATABASE}_%\`.* TO '${MYSQL_USER}'@'%';
EOF_GRANT
@alipek
alipek / getcomposer.sh
Created April 28, 2020 11:20 — forked from justb81/getcomposer.sh
get composer programmatically
#!/bin/sh
EXPECTED_SIGNATURE=$(curl -sS https://composer.github.io/installer.sig)
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
ACTUAL_SIGNATURE=$(php -r "echo hash_file('SHA384', 'composer-setup.php');")
if [ "$EXPECTED_SIGNATURE" != "$ACTUAL_SIGNATURE" ]
then
>&2 echo 'ERROR: Invalid installer signature'
rm composer-setup.php
@alipek
alipek / rotate_desktop.sh
Created May 20, 2019 13:18 — forked from mildmojo/rotate_desktop.sh
Script to rotate the screen and touch devices on modern Linux desktops. Great for convertible laptops.
#!/bin/bash
#
# rotate_desktop.sh
#
# Rotates modern Linux desktop screen and input devices to match. Handy for
# convertible notebooks. Call this script from panel launchers, keyboard
# shortcuts, or touch gesture bindings (xSwipe, touchegg, etc.).
#
# Using transformation matrix bits taken from:
# https://wiki.ubuntu.com/X/InputCoordinateTransformation
@alipek
alipek / clean-up-boot-partition-ubuntu.md
Created January 22, 2019 11:59 — forked from ipbastola/clean-up-boot-partition-ubuntu.md
Safest way to clean up boot partition - Ubuntu 14.04LTS-x64, Ubuntu 16.04LTS-x64

Safest way to clean up boot partition - Ubuntu 14.04LTS-x64, Ubuntu 16.04LTS-x64

Reference

Case I: if /boot is not 100% full and apt is working

1. Check the current kernel version

$ uname -r 

Delete all queue

rabbitmqctl list_queues | grep -v Listing | awk '{print $1}' | xargs -I '{}' rabbitmqadmin --user=$RABBITMQ_DEFAULT_USER --password=$RABBITMQ_DEFAULT_PASS delete queue 'name={}'