Skip to content

Instantly share code, notes, and snippets.

@piihuynh
piihuynh / portainer.yml
Last active Nov 25, 2021
Portainer-CE swarm mode with Traefik
View portainer.yml
version: '3.2'
services:
agent:
image: portainer/agent:2.9.2
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- /var/lib/docker/volumes:/var/lib/docker/volumes
environment:
AGENT_CLUSTER_ADDR: tasks.agent
@piihuynh
piihuynh / traefik-host.yml
Created Nov 25, 2021
Traefik v2.5 Swarm mode with "host" mode
View traefik-host.yml
version: '3.3'
services:
traefik:
# Use the latest Traefik image
image: traefik:v2.5
ports:
# Listen on port 80, default for HTTP, necessary to redirect to HTTPS
- target: 80
@piihuynh
piihuynh / parse_dotenv.bash
Created Aug 26, 2021 — forked from judy2k/parse_dotenv.bash
Parse a .env (dotenv) file directly using BASH
View parse_dotenv.bash
# Pass the env-vars to MYCOMMAND
eval $(egrep -v '^#' .env | xargs) MYCOMMAND
# … or ...
# Export the vars in .env into your shell:
export $(egrep -v '^#' .env | xargs)
@piihuynh
piihuynh / jspdf-import-fonts.js
Last active Feb 23, 2021
Import Japanese fonts functions for jsPDF
View jspdf-import-fonts.js
This file has been truncated, but you can view the full file.
function importFontNotoSansCJKjpRegular(jsPdfDoc) {
if (!jsPdfDoc) return;
@piihuynh
piihuynh / .gitlab-ci.yml
Created Feb 22, 2021 — forked from superjose/.gitlab-ci.yml
This is an example of a .gitlab-ci.yml that is required for Continuous Integration on GitLab projects.
View .gitlab-ci.yml
# Reference: https://www.exclamationlabs.com/blog/continuous-deployment-to-npm-using-gitlab-ci/
# GitLab uses docker in the background, so we need to specify the
# image versions. This is useful because we're freely to use
# multiple node versions to work with it. They come from the docker
# repo.
# Uses NodeJS V 9.4.0
image: node:9.4.0
# And to cache them as well.
View install_docker_docker-compose.sh
# Ask for the user password
# Script only works if sudo caches the password for a few minutes
sudo true
# =============================
# Install docker
# -----------------------------
# Option 1
# -----------------------------
# Install kernel extra's to enable docker aufs support
@piihuynh
piihuynh / docker-cleanup
Created Aug 8, 2020 — forked from wdullaer/docker-cleanup
Cleanup unused Docker images and containers
View docker-cleanup
#!/bin/sh
# Cleanup docker files: untagged containers and images.
#
# Use `docker-cleanup -n` for a dry run to see what would be deleted.
untagged_containers() {
# Print containers using untagged images: $1 is used with awk's print: 0=line, 1=column 1.
# NOTE: "[0-9a-f]{12}" does not work with GNU Awk 3.1.7 (RHEL6).
# Ref: https://github.com/blueyed/dotfiles/commit/a14f0b4b#commitcomment-6736470
docker ps -a | tail -n +2 | awk '$2 ~ "^[0-9a-f]+$" {print $'$1'}'
@piihuynh
piihuynh / README.md
Created Jul 27, 2020 — forked from tombigel/README.md
How to Change Open Files Limit on OS X and macOS Sierra (10.8 - 10.12)
View README.md

How to Change Open Files Limit on OS X and macOS

This text is the section about OS X Yosemite (which also works for macOS Sierra) from https://docs.basho.com/riak/kv/2.1.4/using/performance/open-files-limit/#mac-os-x

The last time i visited this link it was dead (403), so I cloned it here from the latest snapshot in Archive.org's Wayback Machine https://web.archive.org/web/20170523131633/https://docs.basho.com/riak/kv/2.1.4/using/performance/open-files-limit/

Mac OS X

To check the current limits on your Mac OS X system, run:

View disable-html-form-input-autocomplete-autofill.md

Disable HTML Form Input Autocomplete and Autofill

  1. Add autocomplete="off" onto <form> element;
  2. Add hidden <input> with autocomplete="false" as a first children element of the form.
<form autocomplete="off" method="post" action="">
    <input autocomplete="false" name="hidden" type="text" style="display:none;">
    ...
View Backup, restore postgres in docker container
Backup:
docker exec -t -u postgres your-db-container pg_dumpall -c > dump_`date +%d-%m-%Y"_"%H_%M_%S`.sql
Restore:
cat your_dump.sql | docker exec -i your-db-container psql -Upostgres