Skip to content

Instantly share code, notes, and snippets.

@gothma
gothma / secretsanta.py
Created June 2, 2016 20:24
Script to assign secret santas and notify them using smtp
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Import smtplib for the actual sending function
import smtplib
import getpass
from email.mime.text import MIMEText
from random import Random
# Names and mail adresses of people that a part of the Wichtel ceremony
@gothma
gothma / ShutdownHandler.py
Created November 22, 2015 10:24
Python logging: Trigger exit on critical error
from __future__ import print_function
import logging
import sys
class ShutdownHandler(logging.Handler):
def emit(self, record):
print(record.msg, file=sys.stderr)
logging.shutdown()
sys.exit(1)
@gothma
gothma / mail.py
Created July 30, 2015 13:08
TF Mail Check
#!/usr/bin/env python3
from imaplib import IMAP4_SSL
import getpass
s = IMAP4_SSL('imap.informatik.uni-freiburg.de', '993')
print(s.login(getpass.getuser(), getpass.getpass()))
s.logout()
@gothma
gothma / jsonConfig.py
Created February 12, 2015 13:39
Import json as native python class
#!/usr/bin/env python3
import json
class JSONConfig:
def __init__(self, dictionary):
for k, v in dictionary.items():
if type(v) is dict:
setattr(self, k, JSONConfig(v))
@gothma
gothma / md2cre.rb
Last active December 20, 2015 03:28 — forked from mxswd/md2cre.rb
#!/usr/bin/env ruby
# Invoke with `ruby md2cre.rb filename.md`
#
# Setup: `gem install redcarpet`
require 'rubygems'
require 'redcarpet'
class Creole < Redcarpet::Render::Base
def normal_text(text)