Skip to content

Instantly share code, notes, and snippets.

View michaelconnor00's full-sized avatar

Mike Connor michaelconnor00

View GitHub Profile
@michaelconnor00
michaelconnor00 / get_all_service_ports.sh
Last active February 3, 2018 23:19
Docker inspect formatting
docker service inspect \
-f='{{range $ports := .Endpoint.Ports}}Service ID: {{$.ID}}, Image: {{$.Spec.TaskTemplate.ContainerSpec.Image}}Ports: {{json $ports}}{{end}}' \
$(docker service ls -q)
# Less Verbose
docker service inspect -f='{{range $ports := .Endpoint.Ports}}{{json $ports}}{{end}}' $(docker service ls -q)
@michaelconnor00
michaelconnor00 / convert-geojson-to-wkt.py
Created June 20, 2017 18:54 — forked from drmalex07/convert-geojson-to-wkt.py
Convert GeoJSON to/from WKT in Python. #python #geojson #geometry
import json
import geojson
from shapely.geometry import shape
o = {
"coordinates": [[[23.314208, 37.768469], [24.039306, 37.768469], [24.039306, 38.214372], [23.314208, 38.214372], [23.314208, 37.768469]]],
"type": "Polygon"
}
s = json.dumps(o)
@michaelconnor00
michaelconnor00 / put_archive.py
Last active July 14, 2024 22:05 — forked from zbyte64/sample.py
Docker Python put_archive example
import tarfile
import time
import json
from io import BytesIO
import docker
src_code = """
if __name__ == "__main__":
print('Hello World, From Alpine!!!!!!!!!')
"""
@michaelconnor00
michaelconnor00 / inspect.py
Created August 29, 2016 18:45
Python Inspect
# Inspect the modules in the package and loop through them.
members = inspect.getmembers(sys.modules[package_name], inspect.ismodule)
for name, data in members:
if name == 'models.py':
data.MyClass.run_function()
@michaelconnor00
michaelconnor00 / memd
Created August 29, 2016 18:44
Memcached basics.
Telnet to your server:
telnet 127.0.0.1 11211
List the items, to get the slab ids:
stats items
STAT items:3:number 1
STAT items:3:age 498
STAT items:22:number 1
@michaelconnor00
michaelconnor00 / tables.md
Created August 29, 2016 18:43
Various Markdown Helpers
Tables Are Cool
col 1 is left-aligned $1600
col 2 is centered $12
col 3 is right-aligned $1
docker run --rm -it -v "$GOPATH":/gopath -v "$(pwd)":/app -e "GOPATH=/gopath" -w /app golang:1.4.2 sh -c 'CGO_ENABLED=0 go build -a --installsuffix cgo --ldflags="-s" -o hello'
@michaelconnor00
michaelconnor00 / p3_venv
Created August 17, 2016 20:07
How to create a python 3 virtualenv
# Assuming Python 3 is installed
mkvirtualenv --python=python3_path myenv
# Typical paths: /usr/local/bin/python3 or python
@michaelconnor00
michaelconnor00 / pip_install.py
Last active June 21, 2016 17:14
Pip install a package for development
pip install --editable .
same as
python setup.py develop
@michaelconnor00
michaelconnor00 / reqs.py
Created April 7, 2016 23:21
A snippet for reading install_requires from requirements.txt
req_exclusions = ['setuptools', 'pytest']
def get_requirements():
reqs = []
with open('requirements.txt', 'r') as f:
for line in f:
add = True
for req in req_exclusions:
if req in line: