Skip to content

Instantly share code, notes, and snippets.

View stemid's full-sized avatar

Stefan Midjich stemid

View GitHub Profile
@stemid
stemid / sex.c
Last active January 13, 2024 11:49
/*sex.c*/
/* Original author unknown. Presumably this is public domain by now.
* If you are the original author or know the original author, please
* contact <freebsd@spatula.net>
*
* Orphan code cleaned up a bit by Nick Johnson <freebsd@spatula.net>
* Completely rewrote how word wrapping works and added -w flag.
*/
@stemid
stemid / brew.py
Created July 24, 2012 14:07
Homebrew module for ansible
#!/usr/bin/python -tt
# (c) 2012, Stefan Midjich
# Written by Stefan Midjich <swehack@gmail.com>
#
# This module was written for Ansible.
# It doesn't support all of Homebrew yet.
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
@stemid
stemid / colout_df.py
Last active December 18, 2015 05:39
Dwarf Fortress gamelog Colout theme for Solarized terminals.
# Colout Dwarf Fortress theme for Solarized terminals
# First install colout, go to https://github.com/nojhan/colout
#
# mkdir ~/.colout
# cp colout_df.py ~/.colout/
# tail -0f df/gamelog.txt | colout -T ~/.colout -t df
#
# I just started this for my own sake, please do add your own colors, regexes and stuff.
# By Stefan Midjich
# Example: sudo tail -F /var/log/maillog|grep -E '(stat=|CLEAN|Blocked SPAM)'|colout -T ~/.colout -t maillog
# By Stefan Midjich
def theme():
bright_black = '#002b36'
black = '#073642'
bright_green = '#586e75'
bright_yellow = '#657b83'
bright_blue = '#839496'
bright_cyan = '#93a1a1'
@stemid
stemid / days_in_month.py
Last active August 29, 2015 14:10
calculates days of each month with a simple formula thought up by Curtis McEnroe
#!/usr/bin/env python
# http://cmcenroe.me/2014/12/05/days-in-month-formula.html
from __future__ import print_function
from argparse import ArgumentParser
import math
parser = ArgumentParser()
parser.add_argument(
@stemid
stemid / gnuplot.gnu
Last active August 29, 2015 14:20
Gnuplot script to plot TIMING-SA values from amavis maillogs
#!/usr/bin/env gnuplot
# Extract the values into a csv, I tend to save only hour:minutes:seconds and the milliseconds using awk
# Example: grep TIMING-SA /var/log/maillog | awk '{printf "%s,%s\n", $3, $11}'
#
# Then set the csv filename in envrionment before running script.
# export GNUPLOT_NAME=sa_timing.csv
# ./gnuplot.gnu
reset
@stemid
stemid / password.go
Last active September 4, 2020 08:26
Create encrypted versions of passwords in go
// build: go build password.go
// run: ./password -password='clear text'
// use HISTCONTROL=ignoreboth and indent commands with one space to avoid
// saving passwords in your shell history.
package main
import (
"os"
"fmt"
@stemid
stemid / tsm.pm
Created May 27, 2015 13:45
Simple TSM perl interface made by an old co-worker
#!/usr/bin/perl -w
# Oskar Liljeblad 2008-10-17
package TSM;
use strict;
use Encode;
$TSM::dsmadmc = 'dsmadmc';
$TSM::username = 'admin';
@stemid
stemid / pyvmomi_example1.py
Last active November 29, 2017 07:02
pyVmomi template script that demonstrates traversing objects from vcenter.
#!/usr/bin/env python
# This is sort of a template script for most operations that might have to
# recursively traverse the vcenter objects looking for something.
#
# by Stefan Midjich <swehack@gmail.com>
#
# See comments further down in the code to understand more.
# It's important to know the object structure of your vcenter so look into
# your own MOB first. It's found at https://10.11.12.13/mob on your vcenter
# server.
@stemid
stemid / sshfp.bash
Last active September 16, 2015 10:59
sshfp to generate SSHFP records for ecdsa.
#!/bin/bash
# {{ ansible_managed }}
#
# rewritten from http://blog.chr.istoph.de/dns-sshfp-record-fuer-alle-algorithmen-gleichzeitig-erstellen/
#
# Create SSHFP records from public keys, supports ecdsa too.
# Stefan.Midjich@cygate.se added support for alternate config dirs. 2015-11-16
domain="$1"
config_dir="${2:-/etc/ssh}"