Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am thonixx on github.
  • I am thonixx (https://keybase.io/thonixx) on keybase.
  • I have a public key whose fingerprint is 7E0E 07A0 A16E FC84 257B 9F01 ED8D 4A44 9DDD 5DA4

To claim this, I am signing this object:

@thonixx
thonixx / convert-pfx-to-pem.sh
Last active August 29, 2015 14:14
PFX to PEM cert and key
# crt
openssl pkcs12 -in $file -out zertifikat.crt -clcerts -nokeys
# key
openssl pkcs12 -in $file -out schluessel.key -nocerts -nodes
# ca certs
openssl pkcs12 -in $file -out chain.crt-cacerts -nokeys
@thonixx
thonixx / remove-puppet-user.pp
Created March 24, 2015 11:44
Remove Puppet user which has running processes
define your_class::user (
$user = $name,
$ensure = 'present',
){
# only call when user gets removed
if $ensure == 'absent' {
exec {
"killing ${user}":
command => "pkill -9 -u ${user}",
@thonixx
thonixx / loop-function.sh
Last active December 21, 2015 16:38
Run any command in a while loop
# loop function
# run any command in a while loop with 1 second sleep
function loop() {
if [ -z "$1" ]
then
return
fi
cmd="$1"
@thonixx
thonixx / smtplogin.sh
Created August 25, 2013 15:51
Test SMTP login
# test smtp login
# scripted by github.com/thonixx
function smtplogin {
echo -n "Server: "
read server
echo ""
echo -n "Username: "
read user
@thonixx
thonixx / reverse.sh
Last active December 21, 2015 16:38
Do a reverse lookup easily
# ⣏⡉ ⡀⢀ ⣀⡀ ⡇ ⢀⣀ ⣀⡀ ⢀⣀ ⣰⡀ ⠄ ⢀⡀ ⣀⡀
# ⠧⠤ ⠜⠣ ⡧⠜ ⠣ ⠣⠼ ⠇⠸ ⠣⠼ ⠘⠤ ⠇ ⠣⠜ ⠇⠸
#
# Due to the complexity of parsing anothers output (and because everything
# is different on other linux versions) I decided to revamp the code.
#
# What's better:
# - multiple A record parsing (also with multiple PTR records now)
# - multiple PTR record parsing (now working w/o bugs)
# - better error handling based on empty result check
@thonixx
thonixx / maildelivery.sh
Created August 25, 2013 15:55
Test mail delivery (to check if e-mail account is configured on the remote server)
# test mail delivery
# scripted by github.com/thonixx
function maildelivery {
domain=$(echo "$1" | awk -F@ '{print $2}')
mailserver=$(dig mx $domain +short | awk {'print $2'} | head -n 1)
# test if something is in the output
if [ -z "$mailserver" ]
then
echo "There was no mailserver or no MX record. :("
@thonixx
thonixx / mailcheck.sh
Created August 25, 2013 15:57
Parse and print all sent mails
# function
# scroll below for the bash script
mailcheck () {
# abort if no argument
if [ -z "$1" ]
then
echo "I need a SASL user name"
return
fi
@thonixx
thonixx / kick.sh
Created August 25, 2013 15:59
kicks other users out of their sessions with a message would kick root which comes from a defined destination
# kick function
# kicks other users out of their sessions with a message
# would kick root which comes from a defined destination
function kick() {
if [ -z "$1" ]
then
echo "need user"
return
fi
@thonixx
thonixx / force-ruby-to-make-it-an-array.erb
Created July 19, 2016 11:36
Force Ruby to build an array of of an array-like string
<%
# define things
orig="item0"
orig='["item1", "item2"]'
orig=["item3", "item4"]
# force ruby to make it an array
if ! orig.respond_to?('each')
var=orig.gsub(/(^\[|\]$)/, "").gsub(/\"/, "").gsub(/\ */, "").split(",")