Skip to content

Instantly share code, notes, and snippets.

Theo Baschak tbaschak

Block or report user

Report or block tbaschak

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@tbaschak
tbaschak / waitforping.sh
Created Sep 5, 2019
waits for a host to come up, then sends a notification
View waitforping.sh
#!/bin/bash
IP="1.1.1.1"
while [ "$RETURNCODE" != "0" ]; do
ping -c 1 $IP &> /dev/null
RETURNCODE=$? # ; echo $?
sleep 1
done
echo "Host $IP is up" | slackcat
@tbaschak
tbaschak / gen_mac.py
Created Oct 26, 2018
generates a mac address in the mikrotik bridge range
View gen_mac.py
#!/usr/bin/env python
# 00:00:5E:80:00:00 - 00:00:5E:FF:FF:FF
import random
from os.path import expanduser
def rand_mac():
return "%02x:%02x:%02x:%02x:%02x:%02x" % (
0, 0, 94,
@tbaschak
tbaschak / pdnsutil.bash_completion.d
Created Nov 29, 2017
my custom fork of pdnsutil.bash_completion.d included in pdns source
View pdnsutil.bash_completion.d
# simple & stupid implementation of bash completion for pdnsutil
#
# (C) 2016 Joerg Jungermann
#
# License: GPLv2
#
# put it into /etc/bash_completion.d/
#
# pdnsutil <TAB> - expands to known operations given as $1
# pdnsutil YOUNAMEIT <TAB> - completes to available zones, might be expensive with many (>10000) zones
@tbaschak
tbaschak / netbps.pl
Created Mar 2, 2017
Measures BPS coming out of tcpdump. Usage: `tcpdump -l -e -n ether broadcast | ./netbps`. Un-Modified from http://superuser.com/questions/356907/how-to-get-real-time-network-statistics-in-linux-with-kb-mb-bytes-format-and-for Raw
View netbps.pl
#!/usr/bin/perl
use strict;
use warnings;
use Time::HiRes;
my $reporting_interval = 5.0; # seconds
my $bytes_this_interval = 0;
my $start_time = [Time::HiRes::gettimeofday()];
STDOUT->autoflush(1);
@tbaschak
tbaschak / netpps.pl
Created Mar 1, 2017
Measures PPS coming out of tcpdump. Usage: `tcpdump -l -e -n ether broadcast | ./netpps`. Modified from http://superuser.com/questions/356907/how-to-get-real-time-network-statistics-in-linux-with-kb-mb-bytes-format-and-for
View netpps.pl
#!/usr/bin/perl
use strict;
use warnings;
use Time::HiRes;
my $reporting_interval = 5.0; # seconds
my $packets_this_interval = 0;
my $start_time = [Time::HiRes::gettimeofday()];
STDOUT->autoflush(1);
@tbaschak
tbaschak / my_imgurup.sh
Last active Jan 17, 2017 — forked from goodevilgenius/my_imgurup.sh
upload images to your imgur account from the command line
View my_imgurup.sh
#!/bin/bash
# To use, create ~/.myimgurup, and put in your client ID and secret
# E.g.:
# CLIENT_ID=80238f8092
# CLIENT_SECRET=239a482b034c820
#
# Next run `base /path/to/my_imgurup.sh auth` to get your PIN and access token
# Finally, `base /path/to/my_imgurup.sh up /path/to/image.png` to upload an image
@tbaschak
tbaschak / bgplg.h.communities.patch
Created Jan 8, 2017
adds show rib community command to openbsd bgplg
View bgplg.h.communities.patch
--- bgplg.h.orig 2017-01-08 00:54:08.000000000 -0600
+++ bgplg.h 2017-01-08 01:00:11.000000000 -0600
@@ -47,6 +47,8 @@
{ BGPCTL, "show", "ip", "bgp", "peer-as", NULL } }, \
{ "show ip bgp empty-as", 0, 0, NULL, \
{ BGPCTL, "show", "ip", "bgp", "empty-as", NULL } }, \
+ { "show rib community", 1, 1, "&lt;community&gt;", \
+ { BGPCTL, "show", "rib", "community", NULL } }, \
{ "show ip bgp summary", 0, 0, NULL, \
{ BGPCTL, "show", "ip", "bgp", "summary", NULL } }, \
@tbaschak
tbaschak / bgplgapi.patch
Created Jan 8, 2017
diff -u bgplg.c bgplgapi.c
View bgplgapi.patch
--- bgplg.c 2017-01-08 00:08:36.000000000 -0600
+++ bgplgapi.c 2017-01-08 00:18:27.000000000 -0600
@@ -2,6 +2,7 @@
/*
* Copyright (c) 2005, 2006 Reyk Floeter <reyk@openbsd.org>
+ * Copyright (c) 2017 Theodore Baschak <theodore@ciscodude.net>>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
View bgplgapi-Makefile
# $OpenBSD: Makefile,v 1.2 2014/12/23 19:32:16 pascal Exp $
.PATH: ${.CURDIR}/..
PROG= bgplgapi
SRCS= bgplgapi.c misc.c
CFLAGS+= -Wall
CFLAGS+= -Wstrict-prototypes -Wmissing-prototypes
CLFAGS+= -Wmissing-declarations -Wredundant-decls
CFLAGS+= -Wshadow -Wpointer-arith -Wcast-qual
@tbaschak
tbaschak / vm-backup.sh
Last active Jan 7, 2017
I use this script to backup my QEMU/KVM/libVirt virtual machines. The script requires KVM 2.1+ since it uses the live blockcommit mode. This means the data in the snapshot disk is rolled back into the original instead of the other way around. Script does NOT handle spaces in paths.
View vm-backup.sh
#!/bin/bash
#
BACKUPDEST="$1"
DOMAIN="$2"
MAXBACKUPS="$3"
if [ -z "$BACKUPDEST" -o -z "$DOMAIN" ]; then
echo "Usage: ./vm-backup <backup-folder> <domain> [max-backups]"
exit 1
You can’t perform that action at this time.