Skip to content

Instantly share code, notes, and snippets.

View RPDiep's full-sized avatar

Rene Diepstraten RPDiep

  • YourHosting B.V.
  • Middelburg, The Netherlands
View GitHub Profile
@RPDiep
RPDiep / outgoing_ipv6.sh
Created August 13, 2014 07:42
A script to label the secondary ipv6 addresses differently, thus making the first ipv6 the default for outgoing connections
#!/bin/bash
ETH=$(ip -6 r | awk '/^default/ {print $5}')
for IP in $(awk -F '=' '/IPV6ADDR_SECONDARIES/ {gsub("\"",""); gsub("/[0-9]*","/128"); print $2}' /etc/sysconfig/network-scripts/ifcfg-${ETH})
do
ip addrlabel add prefix ${IP} label 1001
done
@RPDiep
RPDiep / keybase.md
Created January 21, 2015 10:12
keybase.md

Keybase proof

I hereby claim:

  • I am RPDiep on github.
  • I am rpdiep (https://keybase.io/rpdiep) on keybase.
  • I have a public key whose fingerprint is 920D 7C11 15D7 5A39 6741 F096 9F01 AF83 773B 3208

To claim this, I am signing this object:

@RPDiep
RPDiep / README.md
Last active March 4, 2016 15:07
Ubuntu Kernel Cleanup

Ubuntu Kernel Cleanup

General

This script is used to remove old kernels cluttering /boot on Ubuntu systems. The following kernels are preserved:

  • The running kernel
  • The latest kernel from each major version
#!/bin/bash
max_apache_semaphores=20
cur_apache_semaphores=$(ipcs -s | grep -c apache)
apachectl=$(which apache2ctl apachectl 2>/dev/null)
[[ ${cur_apache_semaphores} -ge ${max_apache_semaphores} ]] && {
logger -t $(basename $0) "Cleaning up semaphores for apache"
ipcs -s | awk '/apache/ {print $2}' | xargs -n1 ipcrm -s
${apachectl} restart
@RPDiep
RPDiep / pingwrapper.py
Created October 12, 2016 11:02
A wrapper around ping which uses ping6 if the target has an AAAA record
#!/usr/bin/python3
import ipaddr
import os
import socket
import sys
if len(sys.argv) == 1:
print("""Usage: %s <hostname|ip>""" % sys.argv[0])
sys.exit(1)
@RPDiep
RPDiep / fizzbuzz.py
Last active December 2, 2017 12:34
FizzBuzz python oneliner
print('\n'.join([('Fizz' if i % 3 == 0 else '') + ('Buzz' if i % 5 == 0 else '') or str(i) for i in range(1,101)]))