Skip to content

Instantly share code, notes, and snippets.

@thorsummoner
thorsummoner / linux_diskstats.py
Last active April 7, 2022 20:25
munin diskmon plugin ported to python
#!/usr/bin/env python3
# ported from https://github.com/terrorobe/munin-plugins/blob/master/alumni/linux_diskstats
# GNP GPLv2
import glob
import re as regex
class diskmon(object):
"""docstring for diskmon"""
@thorsummoner
thorsummoner / numix.slack-theme
Created August 4, 2016 20:56
Numix based Slack theme.
#2d2d2d,#3E313C,#666666,#FFFFFF,#3E313C,#FFFFFF,#d64937,#D64937
{'ERROR': 128,
'FAST_FORWARD': 64,
'FORCED_UPDATE': 32,
'HEAD_UPTODATE': 4,
'NEW_HEAD': 2,
'NEW_TAG': 1,
'REJECTED': 16,
'TAG_UPDATE': 8,
'_flag_map': {' ': 64, '!': 128, '*': 0, '+': 32, '-': 8, '=': 4},
'flags': 4,
@thorsummoner
thorsummoner / hell_debuger.py
Created August 13, 2016 05:51
hell debugger
import inspect
depth = 0
def props(obj):
global depth
depth += 1
pr = {}
for name in dir(obj):
try:
value = getattr(obj, name)
@thorsummoner
thorsummoner / gist:61d08448f48ebe017f5cf7718ff667e8
Last active August 25, 2016 05:34
apt-fast with squid-dep-proxy over zeroconf/avahi/bonjore
# Given your quid-deb-proxy is using the hostname `apt` and has avahi-daemon installed
# Change /etc/apt-fast.conf to include `--async-dns=false --http-proxy=apt.local`
_DOWNLOADER='aria2c -c -j ${_MAXNUM} --async-dns=false --http-proxy=apt.local -i ${DLLIST} --connect-timeout=600 --timeout=600 -m0'
# Using aysnc-dns will hit this line in aria2c:
# https://github.com/aria2/aria2/blob/a1ce6d2e7f8824b1c1cd18d4e531d84ba58a07df/src/AbstractCommand.cc#L788
# Due to this behavor getting set:
# https://github.com/aria2/aria2/blob/a1ce6d2e7f8824b1c1cd18d4e531d84ba58a07df/src/AbstractCommand.cc#L788
#
@thorsummoner
thorsummoner / steamscript
Last active September 18, 2016 07:18
steamscript
#!/bin/bash
# steamcmd doesn't handle the shebang line, so lets remove it :\ Woo
# Use Tail to strip first line (print all lines starting at 2) of our input file
# Call steamcmd with automatic login and automatic exit
steamcmd +login ${STEAMLOGIN:-thorsummoner0} +runscript <(tail -n+2 $1) +exit
@thorsummoner
thorsummoner / logging.py
Last active September 29, 2016 17:14
logging snippet
#!/usr/bin/env python3
import logging
logging.basicConfig(level=logging.INFO)
logging.getLogger('urllib3').setLevel(logging.WARNING)
LOGGER = logging.getLogger(os.path.basename(__file__))
@thorsummoner
thorsummoner / python-sdl2-opengl.py
Last active October 12, 2022 10:53
Simple python app setting up SDL2 & OpenGL.
#!/usr/bin/env python
# The MIT License (MIT)
#
# Copyright (c) 2014 Richard Hawkins
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
#!/bin/sh
true | openssl s_client -connect outlook.com:443 | openssl x509 -noout -text | grep -B1 DNS:
@thorsummoner
thorsummoner / pythonic.md
Created October 21, 2016 22:22
How to be pythonic

To answer "getting a better understanding of python", I feel strongly that