Skip to content

Instantly share code, notes, and snippets.

@meganlkm
meganlkm / pypi.sh
Created November 10, 2017 16:06
upload packages to pypi
#!/usr/bin/env bash
## =======================================================================
## ~/.pypirc
## -----------------------------------------------------------------------
# [distutils] # this tells distutils what package indexes you can push to
# index-servers =
# pypi
# pypitest
@meganlkm
meganlkm / mezzanine.Dockerfile
Last active December 15, 2017 21:21
simple django/mezzanine example
# Build it:
# docker build -t mezzanine-dev .
# Run it:
# docker run -it --rm -p '8000:8000' mezzanine-dev
# then go to http://localhost:8000/admin/
# username: admin
# password: default
FROM python
@meganlkm
meganlkm / catp
Last active January 25, 2018 00:22
catp: The cat command with syntax highlighting.
#!/usr/bin/env bash
## Install #######################################
# pip install Pygments pygments-markdown-lexer
# cp catp ~/.catp
# echo "source .catp" >> .bash_profile
## Usage #########################################
# > catp filename.foo
##################################################
"""
example sls:
merge_reactor_config:
module.run:
- name: conf_manip.merge
- origin: /etc/salt/master.d/reactor.conf
- source: /srv/salt/mystate/files/reactor.conf
"""
import filecmp
@meganlkm
meganlkm / allsalt-dev-setup.sh
Created January 21, 2018 21:46
setup a salt-master and some minions for salt development and testing
#!/usr/bin/env bash
# clone the minions branch of the allsalt repo
git clone -b minions git@github.com:intuitivetechnologygroup/allsalt.git
# build the containers
cd allsalt
make build-debian
make build-centos-minion
make build-ubuntu-minion
@meganlkm
meganlkm / app.py
Created May 22, 2018 15:09
download a rendered template as a StringIO object in a Flask app
from StringIO import StringIO
from flask import Flask, render_template, send_file
app = Flask(__name__)
@app.route('/bootstrap')
def bootstrap():
str_io = StringIO()
#!/usr/local/bin/bash
if [ -f /etc/os-release ]; then
# freedesktop.org and systemd
. /etc/os-release
OS=$NAME
VER=$VERSION_ID
elif type lsb_release >/dev/null 2>&1; then
# linuxbase.org
OS=$(lsb_release -si)
@meganlkm
meganlkm / thread-queue-1.py
Created May 19, 2020 18:33
Thread/Queue Example
import random
import time
from queue import Queue
from threading import Thread
WORKERS = 2
class Worker(Thread):
import time
from queue import Queue
from threading import Thread
def threaded(f, daemon=False):
def wrapped_f(q, *args, **kwargs):
"""this function calls the decorated function and puts the
result in a queue"""
import queue
from threading import Thread
class Worker(Thread):
def __init__(self, q, other_arg, *args, **kwargs):
self.q = q
self.other_arg = other_arg
super().__init__(*args, **kwargs)