Skip to content

Instantly share code, notes, and snippets.

#!/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 / .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
@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 / 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 / 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 / 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 / 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
import argparse
import multiprocessing
import signal
import subprocess
from pprint import pprint
globallock = multiprocessing.Lock()
class BatchSubprocess(object):
.git/objects/pack$ PACKFILE=pack-<...>.pack ; mv $PACKFILE $PACKFILE.repack; git unpack-objects -r < $PACKFILE.repack
@thorsummoner
thorsummoner / dhclient.conf
Last active July 6, 2021 01:33
How to request specific IP in /etc/dhcp/
# Configuration file for /sbin/dhclient, which is included in Debian's
# dhcp3-client package.
#
# This is a sample configuration file for dhclient. See dhclient.conf's
# man page for more information about the syntax of this file
# and a more comprehensive list of the parameters understood by
# dhclient.
#
# Normally, if the DHCP server provides reasonable information and does
# not leave anything out (like the domain name, for example), then