Skip to content

Instantly share code, notes, and snippets.

View durden's full-sized avatar

Luke Lee durden

View GitHub Profile
@durden
durden / export.py
Created October 16, 2012 19:59
Spotify Playlist Exporter
#!/usr/bin/env python
# NOTE: Idea for this script came from:
# spotify-export (https://github.com/jlund/spotify-export)
# To install/setup
# pip install -r requirements.txt
# python export.py <file>
@durden
durden / logger_size.py
Created November 15, 2017 10:15
Get size in KB of your logging infrastructure
import sys
import logging
def get_logger_memory_footprint():
"""
Get tuple of (logger names, size in KB)
"""
loggers = logging.Logger.manager.loggerDict
@durden
durden / mock.py
Created November 14, 2017 08:55
Simple mocking in Python
import contextlib
@contextlib.contextmanager
def mock_attr(object_, orig_attr_name, mock_attr):
"""
Temporarily mock object attribute for testing
This is similiar to the unittest.patch.object in Python 3.3 just much
simpler for our limited needs and use in Python 2.7.
@durden
durden / dump_stats.py
Created December 12, 2012 23:02
Dump Python pstats file to stdout sorted by cumulative stat
if __name__ == "__main__":
import sys
import pstats
stats = pstats.Stats(sys.argv[1])
stats.strip_dirs()
stats.sort_stats('cumulative')
stats.print_stats()
@durden
durden / references.md
Last active September 11, 2017 18:17
References for Python Science apps talk from Pycon 2013, PyTexas 2013, and PyArkansas 2012
@durden
durden / debug_signals.py
Created April 11, 2013 21:16
Attach to all available signals in decoratored class and print debug message each time one of the signals is emitted.
def debug_signals(cls):
"""
Attach to all available signals in decoratored class and print debug
message each time one of the signals is emitted.
"""
from PyQt4 import QtCore
def stripArgsFromSignature(signature):
"""
@durden
durden / bash_oop.sh
Created July 26, 2011 12:08
OOP in bash
#!/bin/bash
# ---------------------------------------------------------------------------
# OO support functions
# Kludged by Pim van Riezen <pi@madscience.nl>
# http://lab.madscience.nl/oo.sh.txt
# ---------------------------------------------------------------------------
DEFCLASS=""
CLASS=""
THIS=0
@durden
durden / css_edits.diff
Created June 27, 2016 08:05
CSS edits for markdown rendering
diff --git a/pskb_website/static/css/base.css b/pskb_website/static/css/base.css
index 519b677..30dfec1 100644
--- a/pskb_website/static/css/base.css
+++ b/pskb_website/static/css/base.css
@@ -588,7 +588,6 @@ a:hover.emphasize-dark {
}
#article pre, #article blockquote, #article form {
- margin-left: 21px;
word-wrap: break-word;