Skip to content

Instantly share code, notes, and snippets.

View biggers's full-sized avatar

Mark Biggers biggers

View GitHub Profile
@biggers
biggers / csvs_db_insert.py
Last active March 3, 2019 22:35
insert a set of CSVs (spreadsheets, "raw") into a MySQL DB - Python3 example (DB API; generators; PyMySQL)
import pymysql.cursors
import os
from attrdict import AttrDict
import sys
from datetime import datetime as dt
# Insert all /var/tmp/*/"CSV summary-reports" into MySQL - using Py DB-API
# NOTE: schema for the table must have been already created!
#
# INSTALL:
@biggers
biggers / linux_rescue_notes.rst
Last active November 15, 2018 02:05
Rescuing a Linux system
@biggers
biggers / peewee_pets_quickstart.py
Last active August 6, 2018 15:30
"pets" example from peewee "quickstart" / documentation
# Refs:
# (primary) http://peewee.readthedocs.io/en/latest/peewee/quickstart.html
# https://peewee.readthedocs.io/en/2.0.2/peewee/cookbook.html
from datetime import date
import peewee
from peewee import ( # noqa: F401
MySQLDatabase,
Model,
BooleanField,
@biggers
biggers / .bashrc.macos
Created January 9, 2018 03:50
.bashrc additions, for virtualenvwrapper and Python3 from Python.org
# 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
@biggers
biggers / torpeewee_ex01.py
Last active May 18, 2018 23:01
torpeewee -- fixed example from torpeewee/README.rst -- async peewee for Tornado
# -*- 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 / Dockerfile
Last active March 8, 2018 11:42
docker-compose build attempt for a Pyramid app
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 / tcpclient.py
Last active January 2, 2018 15:01
"continously-running" Tornado TCP client example -- sends to 'tornado/demos/tcpecho/server.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 / recipe-pyenv.sh
Created September 26, 2017 17:46
shell-recipe for pyenv install of Python 3.6.2 on CentOS / Redhat 6.7
# 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 / LinuxLVM.sh
Created September 1, 2017 13:50
simple Linux volume mgmt example / recipe(s) - LVM
-*-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 / csv_summary_to_sql.py
Created August 14, 2017 19:05
How-to use the PyMySQL module for Python3 DB-API, working simple example (need a SQL table created, first)
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