Skip to content

Instantly share code, notes, and snippets.

import argparse
import multiprocessing
import signal
import subprocess
from pprint import pprint
globallock = multiprocessing.Lock()
class BatchSubprocess(object):
@thorsummoner
thorsummoner / doubly_linked_list.py
Created January 5, 2015 08:57
Python Double Linked List
# Original Source: http://ls.pwd.io/2014/08/singly-and-doubly-linked-lists-in-python/
class Node(object):
def __init__(self, data, prev, next):
self.data = data
self.prev = prev
self.next = next
@thorsummoner
thorsummoner / example.py
Created January 17, 2015 00:18
Overloading the modulo operator to calculate percent.
from percent import Percent
from pprint import pprint
def main():
pprint(
# Ten Percent
Percent(5) % 50
)
@thorsummoner
thorsummoner / pep8.txt
Created February 2, 2015 18:13
Budget.py Linting
Budget.py:6:1: E302 expected 2 blank lines, found 1
Budget.py:11:44: E712 comparison to False should be 'if cond is False:' or 'if not cond:'
Budget.py:14:1: W293 blank line contains whitespace
Budget.py:29:1: W293 blank line contains whitespace
Budget.py:41:12: E225 missing whitespace around operator
add_category_popover.py:4:1: E302 expected 2 blank lines, found 1
add_category_popover.py:14:59: E231 missing whitespace after ','
add_category_popover.py:21:1: W293 blank line contains whitespace
add_category_popover.py:24:40: W291 trailing whitespace
add_category_popover.py:25:40: W291 trailing whitespace
@thorsummoner
thorsummoner / metric.py
Created February 13, 2015 09:19
Metric Integers - Python
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import math
class MetricInt(int):
"""
Integer with metric string representation.
"""
incPrefixes = ['k', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y']
@thorsummoner
thorsummoner / autogen.sh.log
Created February 16, 2015 03:23
gthree autogen.sh
autoreconf: Entering directory `.'
autoreconf: configure.ac: not using Gettext
autoreconf: running: aclocal --force
aclocal: warning: couldn't open directory 'm4': No such file or directory
autoreconf: configure.ac: tracing
autoreconf: configure.ac: not using Libtool
autoreconf: running: /usr/bin/autoconf --force
configure.ac:7: error: possibly undefined macro: AC_DISABLE_STATIC
If this token and others are legitimate, please use m4_pattern_allow.
See the Autoconf documentation.
@thorsummoner
thorsummoner / .gitignore
Last active January 18, 2016 06:23
Pygtk3 window boilerplate
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
#!/usr/bin/env python
import argparse
import cairo
from gi.repository import Gtk
from gi.repository import Gdk
from gi.repository import GdkPixbuf
from gi.repository import GObject
@thorsummoner
thorsummoner / dblhelix
Last active August 29, 2015 14:21
Double helix ascii printer
#!/usr/bin/env python2
"""
Double Helix Text
"""
import argparse
import math
import sys
import time
@thorsummoner
thorsummoner / multiprocessing.py
Last active November 17, 2021 18:30
python multiprocessing example
#!/usr/bin/env python3
""" Example multiprocess based python file
"""
import multiprocessing
import argparse
import itertools
ARGP = argparse.ArgumentParser(