Skip to content

Instantly share code, notes, and snippets.

View geogdog's full-sized avatar

Greg Trahair geogdog

  • Monkeys with Buttons
  • Netherlands
View GitHub Profile
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: popeye
rules:
- apiGroups:
- ""
resources:
- configmaps
- deployments
#!/bin/bash
#
# Greg Trahair <greg@mwb.io>
SEMVER=$(git describe --tags --abbrev=0)
MAJOR=$(echo $SEMVER|cut -d. -f1)
MINOR=$(echo $SEMVER|cut -d. -f2)
MICRO=$(echo $SEMVER|cut -d. -f3)
case $1 in
@geogdog
geogdog / Makefile
Created December 19, 2018 10:25
Makefile Template
.DEFAULT_GOAL := help
SHELL := /bin/bash
##@ Helpers
cloc: ## Show Lines of Code analysis
@cloc --vcs git --quiet
help: ## Display this help
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
@geogdog
geogdog / _workon
Created December 19, 2018 09:28
ZSH Completion for virtualenvwrapper
#compdef _workon workon
# Drop this file in any directory in your $fpath variable
function _workon {
local line
virtualenvs=$(
command find $WORKON_HOME -maxdepth \
${VIRTUALENVWRAPPER_PROJECT_DEPTH:=5} \
@geogdog
geogdog / GPG and git on macOS.md
Created January 10, 2018 09:18 — forked from danieleggert/GPG and git on macOS.md
How to set up git to use the GPG Suite

GPG and git on macOS

Setup

No need for homebrew or anything like that. Works with https://www.git-tower.com and the command line.

  1. Install https://gpgtools.org -- I'd suggest to do a customized install and deselect GPGMail.
  2. Create or import a key -- see below for https://keybase.io
  3. Run gpg --list-secret-keys and look for sec, use the key ID for the next step
  4. Configure git to use GPG -- replace the key with the one from gpg --list-secret-keys
@geogdog
geogdog / bump_version.py
Created November 22, 2017 16:59
Simple script that bumps a semver version if you have a __version__ in your __init__.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import argparse
from mfaws import __version__
import os
parser = argparse.ArgumentParser()
parser.add_argument('-f', '--file', action='store',
help='Path to the file where the `__version__` \
variable is')
@geogdog
geogdog / argparse_subcommand_plugin.py
Last active October 18, 2017 16:21
A very simple subcommand plugin system for argparse
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import argparse
# Setup parser and subparser
parser = argparse.ArgumentParser()
subparsers = parser.add_subparsers(help="Subparser help")
class PluginBase(object):
@geogdog
geogdog / fibonacci.py
Last active September 26, 2017 10:08
Comparison of iterative and recursive fib function
#!/usr/bin/env python
# -*- coding: utf-8 -*-
def fib_r(n):
"""Recursive Fibonacci.
>>> fib_r(0)
0
@geogdog
geogdog / gitlab_checkout.py
Created May 18, 2017 11:50
Clone or Pull all Gitlab projects that you have access to
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Checkout all gitlab repos."""
from __future__ import print_function
try:
from urllib.request import urlopen, Request
except ImportError:
from urllib2 import urlopen, Request
import json
from getpass import getpass
def random_ascii_letters(length):
return ''.join([random.choice(string.ascii_letters) for _ in range(length)])