Skip to content

Instantly share code, notes, and snippets.

@dirkakrid
dirkakrid / prun
Created October 11, 2016 07:56 — forked from zhangchunlin/prun
prun, a little tool to run cmds parallel.
#! /usr/bin/env python
#coding=utf-8
import gevent
from gevent.subprocess import Popen, PIPE
import sys
def run(cmd,name="",index=1,color=True):
fc = 32 + index%5
if name:
@dirkakrid
dirkakrid / tcping.py
Created October 11, 2016 08:26 — forked from defnull/tcping.py
TCPing
def ping(server, port):
''' Check if a server accepts connections on a specific TCP port '''
try:
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((server, port))
s.close()
return True
except socket.error:
return False
@dirkakrid
dirkakrid / logger_example.py
Created October 11, 2016 08:26 — forked from zhangchunlin/logger_example.py
python snippet
import logging
logging.basicConfig(level=logging.INFO,
format='%(asctime)s %(levelname)s %(message)s',
datefmt='%Y-%m-%d %H:%M:%S')
log = logging.getLogger(__name__)
@dirkakrid
dirkakrid / test.py
Created October 11, 2016 08:30 — forked from crazed/test.py
sample using trigger with a custom loader
import sys
import logging
import xml.etree.ElementTree as ET
import re
import types
from uuid import uuid4
import cyclone.httpclient
import cyclone.jsonrpc
@dirkakrid
dirkakrid / example.py
Created October 20, 2016 05:07 — forked from schlamar/example.py
mplog: Python advanced multiprocessing logging.
import logging
import multiprocessing
import time
import mplog
FORMAT = '%(asctime)s - %(processName)s - %(levelname)s - %(message)s'
logging.basicConfig(level=logging.DEBUG, format=FORMAT)
existing_logger = logging.getLogger('x')
@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
@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 / 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 / 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 / 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