Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)
That's it!
Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)
That's it!
from multiprocessing import Pool | |
from itertools import chain | |
import re | |
import sys | |
PROC_COUNT = 8 | |
LINES_PER_PROC = 40 | |
if len(sys.argv) != 3: |
import os | |
import sys | |
import traceback | |
from functools import wraps | |
from multiprocessing import Process, Queue | |
def processify(func): | |
'''Decorator to run a function as a process. | |
Be sure that every argument and the return value |
""" | |
remconsole.py | |
A Python console you can embed in a program and attach to remotely. | |
To spawn a Python console in a script do the following in any scope | |
of any module: | |
import remconsole | |
remconsole.spawn_server() |
# -*- coding: utf-8 -*- | |
""" | |
Created on Fri Jun 26 13:16:22 2015 | |
@author: zah | |
""" | |
import multiprocessing | |
import logging |
# make: | |
# Creates a Void Linux docker container with qutebrowser. | |
# make run: | |
# Runs qutebrowser in aforementioned container | |
REPO = http://muslrepo.voidlinux.eu/ | |
XBPS_INSTALL = usr/bin/xbps-install | |
ROOTFS = rootfs | |
PACKAGES = base-system-busybox | |
PACKAGES += dbus | |
PACKAGES += ca-certificates |
# originally copied from http://michael.gorven.za.net/blog/2012/10/22/building-raspbian-images-raspberry-pi | |
# Copyright (C) 2012 Michael Gorven <http://michael.gorven.za.net/> | |
# | |
# 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 | |
# furnished to do so, subject to the following conditions: |
#!/bin/bash -v | |
# CREATE A RASPBIAN JESSIE IMAGE FOR SAMPLERBOX | |
# 2016-08-31 | |
# | |
# USAGE: chmod 777 samplerbox_maker.sh ; nohup sudo ./samplerbox_maker.sh & | |
set -e | |
sudo apt-get update && sudo apt-get install -y cdebootstrap kpartx parted sshpass zip |
def pprint_defaultdict(): | |
from collections import defaultdict | |
import IPython | |
ip = get_ipython() | |
tf = ip.display_formatter.formatters['text/plain'] | |
def _print_default_dict(arg, p, cycle): | |
""" Pretty print a defaultdict. """ | |
def rec(obj, indent=0, level=0): | |
if isinstance(obj, defaultdict) or isinstance(obj, dict): | |
p.text('{\n') |
--- | |
version: 1 | |
disable_existing_loggers: False | |
formatters: | |
simple: | |
format: "%(name)-20s%(levelname)-8s%(message)s" | |
handlers: | |
console: | |
class: logging.StreamHandler | |
level: DEBUG |