Skip to content

Instantly share code, notes, and snippets.

@dirkakrid
dirkakrid / tree.md
Created October 29, 2016 15:38 — forked from hrldcpr/tree.md
one-line tree in python

One-line Tree in Python

Using Python's built-in defaultdict we can easily define a tree data structure:

def tree(): return defaultdict(tree)

That's it!

@dirkakrid
dirkakrid / mplog.py
Created October 28, 2016 05:39 — forked from myaut/mplog.py
Multiprocess grep in Python
from multiprocessing import Pool
from itertools import chain
import re
import sys
PROC_COUNT = 8
LINES_PER_PROC = 40
if len(sys.argv) != 3:
@dirkakrid
dirkakrid / processify.py
Created October 28, 2016 05:33 — forked from schlamar/processify.py
processify
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
@dirkakrid
dirkakrid / remconsole.py
Created October 28, 2016 05:31 — forked from schlamar/remconsole.py
Fork of `rfoo.utils.rconsole` to run with other RPC implementations.
"""
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()
@dirkakrid
dirkakrid / multilogging.py
Created October 27, 2016 06:08 — forked from Zaharid/multilogging.py
Proper way to manage logging for multiple processes.
# -*- coding: utf-8 -*-
"""
Created on Fri Jun 26 13:16:22 2015
@author: zah
"""
import multiprocessing
import logging
@dirkakrid
dirkakrid / Makefile
Created October 24, 2016 08:37 — forked from uggedal/Makefile
Void Linux qutebrowser docker container hack
# 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
@dirkakrid
dirkakrid / COPYING.txt
Created October 20, 2016 09:08 — forked from abulte/COPYING.txt
Build a custom Raspian image #2
# 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:
@dirkakrid
dirkakrid / samplerbox_maker.sh
Created October 20, 2016 09:02 — forked from josephernest/samplerbox_maker.sh
Script to make the SamplerBox ISO Image
#!/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
@dirkakrid
dirkakrid / pprint_defaulttict.py
Created October 20, 2016 08:20 — forked from JesseBuesking/pprint_defaulttict.py
Pretty prints a default dict in IPython
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')
@dirkakrid
dirkakrid / logging.yaml
Created October 20, 2016 07:30 — forked from JesseBuesking/logging.yaml
Testing MultiProcessingLog on both Windows 7 Enterprise and Ubuntu Developers Version 10.04_20121120.
---
version: 1
disable_existing_loggers: False
formatters:
simple:
format: "%(name)-20s%(levelname)-8s%(message)s"
handlers:
console:
class: logging.StreamHandler
level: DEBUG