Skip to content

Instantly share code, notes, and snippets.

Mark Biggers biggers

Block or report user

Report or block biggers

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@biggers
biggers / streamlogger.py
Last active Jun 30, 2017 — forked from pmuller/streamlogger.py
StreamLogger is a context handler which proxies an output stream to python's logging
View streamlogger.py
#!/usr/bin/env python3
#
# Port of "Fabric streamlogger" to Python3
# Credit (originally): https://gist.github.com/2376336.git
# pmuller - streamlogger.py
import sys
import logging
from io import StringIO
@biggers
biggers / async_threadpool_blocking_fn.py
Created Aug 10, 2017
async Python3 code using blocking-function
View async_threadpool_blocking_fn.py
from concurrent.futures import ThreadPoolExecutor, as_completed
import time
import random
TPOOL_SIZE = 8
def blocking(pid):
""" a non-deterministic "blocking" ? task
"""
@biggers
biggers / csv_summary_to_sql.py
Created Aug 14, 2017
How-to use the PyMySQL module for Python3 DB-API, working simple example (need a SQL table created, first)
View csv_summary_to_sql.py
import pymysql.cursors
import os
from attrdict import AttrDict
import sys
# Test a one-row Insert, Select for Capacity DB
# ... using Py DB-API
#
# Install:
# pip3 install PyMySQL attrdict
@biggers
biggers / LinuxLVM.sh
Created Sep 1, 2017
simple Linux volume mgmt example / recipe(s) - LVM
View LinuxLVM.sh
-*-sh-*-
Various bits, pieces, notes -- on using Linux Volume (Disk) Mgmt,
on various Linux distros
"A Debian Grimoire - LVM: Logical Volume Management, Version 2"
http://deb.riseup.net/storage/lvm2/
@biggers
biggers / recipe-pyenv.sh
Created Sep 26, 2017
shell-recipe for pyenv install of Python 3.6.2 on CentOS / Redhat 6.7
View recipe-pyenv.sh
# REF: https://github.com/pyenv/pyenv/blob/master/README.md
# ... building Python 3.6.2 on Bastion, "locally"
# yum install [Python3 build pre-reqs, on CentOS 6.7]
curl -L https://raw.githubusercontent.com/pyenv/pyenv-installer/master/bin/pyenv-installer | bash
tee -a $HOME/.bash_profile <<EOF
export PATH="\$HOME/.pyenv/bin:\$PATH"
eval "\$(pyenv init -)"
@biggers
biggers / py_rotate_log_dict_config.py
Created Dec 19, 2017
Python3 rotating log-file configuration via "config.dictConfig"
View py_rotate_log_dict_config.py
import sys
import logging
import logging.config
import random
import string
# "thank you" to folks on StackOverflow.com for various ideas,
# for this example. Works with Python3.
@biggers
biggers / tcpclient.py
Last active Jan 2, 2018
"continously-running" Tornado TCP client example -- sends to 'tornado/demos/tcpecho/server.py'
View tcpclient.py
import time
import logging
from tornado.options import options, define
from tornado import gen
from tornado.tcpclient import TCPClient
from tornado.iostream import StreamClosedError
from tornado.ioloop import IOLoop
define("host", default="127.0.0.1", help="TCP server host")
define("port", default=9888, help="TCP port to connect to")
@biggers
biggers / Dockerfile
Last active Mar 8, 2018
docker-compose build attempt for a Pyramid app
View Dockerfile
FROM phusion/baseimage:0.9.18
MAINTAINER biggers@utsl.com
ENV PYTHONUNBUFFERED 1
# ...put your own build instructions here...
RUN apt-get update --no-install-recommends && \
apt-get install -y --no-install-recommends \
@biggers
biggers / torpeewee_ex01.py
Last active May 18, 2018
torpeewee -- fixed example from torpeewee/README.rst -- async peewee for Tornado
View torpeewee_ex01.py
# -*- coding: utf-8 -*-
# REWORKED by biggers@utsl.com, from:
# 16/7/7
# create by: snower
import datetime
from tornado import gen
from tornado.ioloop import IOLoop
from torpeewee import (
Model,
@biggers
biggers / .bashrc.macos
Created Jan 9, 2018
.bashrc additions, for virtualenvwrapper and Python3 from Python.org
View .bashrc.macos
# you can omit the first (2) entries...
export PATH="$HOME/bin:/usr/local/bin:/usr/local/sbin:/usr/sbin::/sbin:/usr/bin:/bin"
export PATH=/Applications/Emacs.app/Contents/MacOS:$PATH
# 'virtualenvwrapper' support
export WORKON_HOME=$HOME/.virtualenvs
export VIRTUALENVWRAPPER_SCRIPT=/usr/local/bin/virtualenvwrapper.sh
source /usr/local/bin/virtualenvwrapper.sh
You can’t perform that action at this time.