This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from functools import wraps | |
from flask_restplus import Resource | |
HTTP_METHODS = ["get", "post", "delete", "put", "patch"] | |
class InjectableResource(Resource): | |
def hook_all_http_methods(self, pre_execution=None, post_execution=None, exception_handler=None): | |
for method in HTTP_METHODS: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Router, NavigationStart } from '@angular/router'; | |
import { filter, pairwise } from 'rxjs/operators'; | |
export function parseQuery(queryString: string) { | |
const query = {}; | |
const pairs = (queryString[0] === '?' ? queryString.substr(1) : queryString).split('&'); | |
for (let i = 0; i < pairs.length; i++) { | |
const pair = pairs[i].split('='); | |
query[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1] || ''); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# required vars: gcloud-api-key.json, $GCLOUD_PROJECT, $GCLOUD_ZONE, $CLUSTER_NAME, $SERVICE_NAME | |
gcloud auth activate-service-account --key-file gcloud-api-key.json | |
gcloud config set project $GCLOUD_PROJECT | |
gcloud config set compute/zone $GCLOUD_ZONE | |
lines=`gcloud container clusters list --filter NAME="$CLUSTER_NAME" | wc -l` | |
if [ $lines -eq 0 ] ; then echo "No deployed cluster for $CLUSTER_NAME" && exit 1 ; fi | |
gcloud container clusters get-credentials $CLUSTER_NAME | |
external_ip=$(kubectl get svc $SERVICE_NAME --template="{{range .status.loadBalancer.ingress}}{{.ip}}{{end}}") | |
echo "IP for cluster $CLUSTER_NAME is $external_ip" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM tiangolo/uwsgi-nginx:python3.7 | |
# or FROM tiangolo/uwsgi-nginx-flask:python3.7 | |
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf | |
COPY stop-supervisor.sh /etc/supervisor/stop-supervisor.sh | |
RUN chmod +x /etc/supervisor/stop-supervisor.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import gzip | |
import shutil | |
import logging | |
import os | |
from subprocess import Popen, PIPE, TimeoutExpired | |
SUCCESS_CODE = 0 | |
TIMEOUT_SECONDS = 600 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
from functools import wraps | |
from contextlib import ContextDecorator, AbstractContextManager | |
# Copied and changed from python3.6/contextlib.py | |
def safe_contextmanager(func): | |
@wraps(func) | |
def helper(*args, **kwds): |
NewerOlder