Skip to content

Instantly share code, notes, and snippets.

View biggers's full-sized avatar

Mark Biggers biggers

View GitHub Profile
@biggers
biggers / sshfs_ubuntu_fsys.sh
Created October 2, 2021 14:04
sshfs remote SSH mount script - MacOS client to Ubuntu
#!/bin/bash
# MacOS *specific*, 'sshfs' remote-mounts
# - tested on MacOS catalina; latest MacOS Fuse & sshfs
# - 10-02-2021 Sat
# NOTE:
# sudo mkdir -p /private/ssh # and do a 'chmod, chgrp'...
# drwxrwsr-x 5 root admin 160 Oct 2 08:32 /private/ssh/
# - install, MacOS FUSE, sshfs from https://osxfuse.github.io/
@biggers
biggers / git-fetchall.sh
Created May 21, 2020 15:10
Git, fetch all branches!
#!/bin/sh
# "git fetch all branches" -- to your local-repo
## to RUN-ME:
## git branch -r | sed -r -e 's:origin/::g' -e '/^\s+HEAD/d' | egrep -v gerrit/ > /tmp/foo
# ... gives you a chance, to change the "temp list of Branches to fetch"
## cat /tmp/foo ## hand-edit, if needed
@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 / bashrc.win.sh
Created December 27, 2018 14:32
"bootstrap" bashrc for a WSL (Windows 10) and Docker workflow
# /home/mabigger/.bashrc.win -*-sh-*-
# ---- References
# https://nickjanetakis.com/blog/setting-up-docker-for-windows-and-wsl-to-work-flawlessly
# https://sourceforge.net/projects/vcxsrv/
CEC=mabigger
sudo mount --bind /mnt/c /c
@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 / 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 / .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 / py_rotate_log_dict_config.py
Created December 19, 2017 19:23
Python3 rotating log-file configuration via "config.dictConfig"
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.
# CREATE USER 'example'@'localhost' IDENTIFIED BY 'example_password';
# GRANT ALL PRIVILEGES ON *.* TO 'example'@'localhost' IDENTIFIED BY 'example_password';
# CREATE DATABASE example;
import sys
import os
import time
from datetime import date, timedelta
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import Column, Integer, String, create_engine
from sqlalchemy.dialects.mysql import DATETIME, DATE
@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")