Skip to content

Instantly share code, notes, and snippets.

🏁
Working hard

Đặng Minh Dũng dungdm93

🏁
Working hard
Block or report user

Report or block dungdm93

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View circleci.yml
version: 2
jobs:
test:
docker:
- image: python:3.6-stretch
- image: tekodocker12/elasticsearch:7.1.1-icu
environment:
MYSQL_ROOT_PASSWORD: S3cret
steps:
@dungdm93
dungdm93 / flask-metrics.py
Created Oct 9, 2019
Prometheus apps monitoring
View flask-metrics.py
def register_telemetry(flask_app):
from prometheus_client import multiprocess
from prometheus_client.core import CollectorRegistry
from prometheus_flask_exporter import PrometheusMetrics
registry = CollectorRegistry()
multiprocess.MultiProcessCollector(registry, path=os.environ.get('prometheus_multiproc_dir', '/tmp'))
return PrometheusMetrics(
flask_app, group_by='url_rule', registry=registry,
static_labels={
View docker-compose.yml
version: '3.7'
services:
prometheus:
image: prom/prometheus:v2.12.0
network_mode: host
volumes:
- ./prometheus.yml:/etc/prometheus/prometheus.yml
grafana:
View semver-regex.md

Canonical regex

/^
(?'MAJOR'
    0|(?:[1-9]\d*)
)
\.
(?'MINOR'
    0|(?:[1-9]\d*)
View test.sh
count=1
while true; do
echo $((count++));
kubectl get pod -A > /dev/null;
sleep 1;
done;
@dungdm93
dungdm93 / 0-README.md
Last active Jul 7, 2019
Django serve staticfiles
View 0-README.md

Django Staticfiles

Django staticfiles is the most common problem you need to solve before putting your app on the production. In this tutorial, I and you will walk through the solution options, included.

  • runserver: Only in development environment.
  • gunicorn: Use gunicorn as your app server.
  • nginx: Put nginx web server in a front of your app server (gunicorn).
  • whitenoise: Let your django app self-serve static files.
@dungdm93
dungdm93 / bash-color.sh
Created Oct 23, 2018
Colorize terminal
View bash-color.sh
#!/bin/bash
##### Color table #####
# Black 0;30 Dark Gray 1;30
# Red 0;31 Light Red 1;31
# Green 0;32 Light Green 1;32
# Brown/Orange 0;33 Yellow 1;33
# Blue 0;34 Light Blue 1;34
# Purple 0;35 Light Purple 1;35
# Cyan 0;36 Light Cyan 1;36
@dungdm93
dungdm93 / jinja-cli.py
Last active Oct 18, 2018
Render Jinja template
View jinja-cli.py
import jinja2
loader = jinja2.FileSystemLoader(searchpath="./")
env = jinja2.Environment(loader=loader)
TEMPLATE_FILE = "template.j2"
template = env.get_template(TEMPLATE_FILE)
output = template.render()
print(f"[{output}]")
@dungdm93
dungdm93 / paas-gae.yml
Last active Dec 10, 2017
GitLab-CI: Deploy Scripts
View paas-gae.yml
deploy:paas-gae:
stage: deploy
image: google/cloud-sdk
before_script:
- echo "${GCLOUD_SERVICE_KEY}" > /tmp/.gsa.key
- gcloud auth activate-service-account --key-file /tmp/.gsa.key
- gcloud config set project "${PROJECT_NAME}" # TODO: change this
script:
- gcloud app deploy
environment:
@dungdm93
dungdm93 / android-gradle.yml
Last active Aug 10, 2019
GitLab-CI: Caching by package manager
View android-gradle.yml
variables:
ANDROID_COMPILE_SDK: "28"
test:unit:
image: circleci/android:api-${ANDROID_COMPILE_SDK}
cache:
key: gradle-cache
paths: [ .gradle ]
variables:
# GRADLE_OPTS: "-Dorg.gradle.daemon=false"
You can’t perform that action at this time.