Skip to content

Instantly share code, notes, and snippets.

@wimvds
wimvds / gist:8f5bf05dea6c708573cb1c894896b2db
Last active March 3, 2021 15:54
Extend a VM disk using fdisk
Extend the disk using fdisk (after the disk image itself has been extended):
fdisk -u /dev/sda
- Use the option p to print the partition table (you will need the start position later)
- Delete the partition with option d
- Add a new partition with option n
- Create a primary partition with P and give this the partition number 1
- For the first sector, use the start position from step 2
- Use the defaultvalue for the last sector
- Check your changes by printing the partition table again
@wimvds
wimvds / kubernetes-snippets.md
Last active January 27, 2020 09:30
Kubernetes snippets

Kubernetes snippets

Remove all replicasets without pods on ready state

kubectl get replicasets --all-namespaces -o json | jq '.items[] | select(.status.readyReplicas<1) | "kubectl delete replicasets \(.metadata.name) -n \(.metadata.namespace)"' | xargs -n 1 bash -c
@wimvds
wimvds / list-cron.sh
Last active January 13, 2017 12:35
List all cronjobs for all users (as root)
#!/bin/bash
# System-wide crontab file and cron job directory. Change these for your system.
CRONTAB='/etc/crontab'
CRONDIR='/etc/cron.d'
# Single tab character. Annoyingly necessary.
tab=$(echo -en "\t")
# Given a stream of crontab lines, exclude non-cron job lines, replace
@wimvds
wimvds / mysql
Created December 14, 2016 09:31
Run mysql command in (currently running) mariadb docker container
#!/bin/bash
if [ -t 0 ]; then
# Terminal input (keyboard) - interactive
docker exec -it mariadb mysql $@
else
# File or pipe input - non-interactive
docker exec -i mariadb mysql $@
fi
@wimvds
wimvds / remove-dupe.sh
Created November 24, 2016 08:18
Remove an mp3 duplicate (m4a with same name exists in the same folder)
#!/bin/bash
# Usage:
# find ~/Music -name '*.m4a' -exec ~/bin/remove-dupe.sh {} \;
M4A_FILE=$1
MP3_FILE="${M4A_FILE%.*}.mp3"
if [ -f "$MP3_FILE" ]; then
rm -rf "$MP3_FILE"
echo "Removed $MP3_FILE"
fi
@wimvds
wimvds / mqttclient.php
Created November 7, 2016 22:11
Onion Omega MQTT publisher client
<?php
class MqttClient
{
private $server;
private $port;
private $user;
private $password;
public function __construct($server, $port = 1883, $user = '', $password = '')
@wimvds
wimvds / rtttl_player.ino
Created November 5, 2016 14:49
play_RTTTL function to play ringtones on ESP8266 (Adafruit Feather Huzzah) with Arduino
// Based on https://github.com/granadaxronos/120-SONG_NOKIA_RTTTL_RINGTONE_PLAYER_FOR_ARDUINO_UNO
#define OCTAVE_OFFSET 0
#define isdigit(n) (n >= '0' && n <= '9')
int tone_pin = 4; // You can assing any digital output pin for speaker output!
void play_RTTTL(char* p){
byte default_dur = 4;
@wimvds
wimvds / gist:c65455c0b3d1c3182cdc4acc18446bcb
Created October 27, 2016 11:29
What to do if /boot reaches 100%
List all old kernels that can be removed (Debian) :
dpkg -l linux-{image,headers}-* | awk '/^ii/{print $2}' | egrep '[0-9]+\.[0-9]+\.[0-9]+' | grep -v $(uname -r)
Remove them using dpkg --purge :
ie. dpkg --purge linux-headers-3.13.0-86 linux-headers-3.13.0-86-generic linux-image-3.13.0-86-generic linux-image-extra-3.13.0-86-generic
Afterwards run apt-get autoremove (if needed preceded by apt-get -f install).
@wimvds
wimvds / ImperialMarch.ino
Last active October 17, 2016 20:06 — forked from octosteve/ImperialMarch.ino
Imperial march played on an Arduino with a Piezo Element
int speakerPin = 9;
int length = 46;
String notes[] = {"G4","G4", "G4", "D#4/Eb4", "A#4/Bb4", "G4", "D#4/Eb4","A#4/Bb4", "G4", "D5", "D5", "D5", "D#5/Eb5", "A#4/Bb4", "F#4/Gb4", "D#4/Eb4","A#4/Bb4", "G4", "G5","G4","G4","G5","F#5/Gb5", "F5","E5","D#5/Eb5","E5", "rest", "G4", "rest","C#5/Db5","C5","B4","A#4/Bb4","A4","A#4/Bb4", "rest", "D#4/Eb4", "rest", "F#4/Gb4", "D#4/Eb4","A#4/Bb4", "G4" ,"D#4/Eb4","A#4/Bb4", "G4"};
int beats[] = { 8, 8, 8, 6, 2, 8, 6 , 2 ,16 , 8, 8, 8, 6, 2, 8, 6, 2, 16,8,6,2,8,6,2,2, 2, 2,6,2,2,8,6,2,2,2,2,6,2,2,9,6,2,8,6,2,16 };
int tempo = 50;
void playTone(int tone, int duration) {
for (long i = 0; i < duration * 1000L; i += tone * 2) {
digitalWrite(speakerPin, HIGH);
delayMicroseconds(tone);

Keybase proof

I hereby claim:

  • I am wimvds on github.
  • I am wimvds (https://keybase.io/wimvds) on keybase.
  • I have a public key is ASD19plOvA6jRlJ5vT9FADGueBzOy7Y8LLSL_K-u4fhs-Ao

To claim this, I am signing this object: