Skip to content

Instantly share code, notes, and snippets.

View aprxi's full-sized avatar

Anthony Potappel aprxi

  • The Netherlands
View GitHub Profile
@aprxi
aprxi / Makefile-twine-upload
Last active September 27, 2019 20:28
Makefile-twine-upload
.PHONY: upload
upload:
$(RUN_DOCK) "twine upload ~/$(MODULE_NAME)/dist/$(MODULE_NAME)-$(MODULE_VERSION)*"
@aprxi
aprxi / Setuppy-variables
Last active September 27, 2019 20:26
Setuppy-variables
import os
import re
import setuptools
envstring = lambda var: os.environ.get(var) or ""
try:
with open("README.md", "r") as fh:
long_description = fh.read()
except:
@aprxi
aprxi / Profile-variables
Created September 26, 2019 21:09
Profile-variables
# export vars to environment
if [ -s ~/${MODULE_NAME}/variables ]; then
set -a
. ~/${MODULE_NAME}/variables
set +a
fi
@aprxi
aprxi / Makefike-makepip
Created September 26, 2019 15:15
Makefile-makepip
.PHONY: module
module:
@# ensure there is a symlink from MODULE_NAME to module directory
@# then run regular setup.py to build the module
$(RUN_DOCK) "cd ~/$(MODULE_NAME) \
&& find ./ -type l -maxdepth 1 |xargs rm -f \
&& ln -sf module "$(MODULE_NAME)" \
&& python3 setup.py sdist"
.PHONY: pylint
@aprxi
aprxi / Makefile-fork
Last active September 27, 2019 20:27
Makefile-fork
.PHONY: fork
FILES = \
module files Makefile Dockerfile docker-compose.yml setup.py MANIFEST.in variables .gitignore .pylintrc
DEST ?= $(dest)
fork:
ifeq ($(DEST),)
@echo 'MISSING "dest=" PARAMETER'
@echo 'RUN: make fork dest=$${DIRECTORY}'
else
@# copy when either directory does not exist, or is empty
@aprxi
aprxi / PyShipper-variables
Created September 26, 2019 14:00
PyShipper-variables
NAME=${YOUR_MODULE_NAME}
VERSION=${VERSION_OF_YOUR_MODULE}
AUTHOR="${YOUR_NAME_OR_ALIAS}"
AUTHOR_EMAIL="${YOUR_EMAIL_ACCOUNT}"
DESCRIPTION="${WHAT_YOUR_MODULE_DOES}"
URL="${GIT_REPOSITORY_URL}"
@aprxi
aprxi / Makefile-readvar
Last active September 26, 2019 14:23
Makefile-readvar
# Retrieve a variable from a file in to Makefile
# Strips off any quotes as well, \47 represents a strong-quote
MODULE_NAME = \
$(shell awk -F= '/^NAME\ ?=/{gsub(/\47|"/, "", $$NF);print $$NF;exit}' variables)
@aprxi
aprxi / autocommit.vimrc
Last active April 6, 2019 15:39
vimrc-autocommit
" command W !git diff-index --quiet HEAD || git commit -am auto
" autocmd BufWritePost * call AutoCommit()
command W call AutoCommit()
function! AutoCommit()
execute ':w'
call system('git rev-parse --git-dir > /dev/null 2>&1')
if v:shell_error
return
endif
let message = '__auto_update__:' . expand('%:.')
@aprxi
aprxi / Dockerfile
Last active March 25, 2021 06:26
Dockerfile_20190214
FROM alpine as base
RUN apk update \
&& apk add --no-cache \
bash
FROM scratch as user
COPY --from=base . .
ARG HOST_UID=${HOST_UID:-4000}
@aprxi
aprxi / docker-compose.yml
Last active March 25, 2021 06:25
docker-compose.yml_20190214
version: '3.4'
services:
main:
# Makefile fills PROJECT_NAME to current directory name.
# add UID to allow multiple users run this in parallel
container_name: ${PROJECT_NAME}_${HOST_UID:-4000}
hostname: ${PROJECT_NAME}
# These variables are passed into the container.
environment:
- UID=${HOST_UID:-4000}