Skip to content

Instantly share code, notes, and snippets.

@piihuynh
piihuynh / sane-caching.nginx.conf
Created December 6, 2021 15:29 — forked from philipstanislaus/sane-caching.nginx.conf
Sample Nginx config with sane caching settings for modern web development
# Sample Nginx config with sane caching settings for modern web development
#
# Motivation:
# Modern web development often happens with developer tools open, e. g. the Chrome Dev Tools.
# These tools automatically deactivate all sorts of caching for you, so you always have a fresh
# and juicy version of your assets available.
# At some point, however, you want to show your work to testers, your boss or your client.
# After you implemented and deployed their feedback, they reload the testing page – and report
# the exact same issues as before! What happened? Of course, they did not have developer tools
# open, and of course, they did not empty their caches before navigating to your site.
@piihuynh
piihuynh / parse_dotenv.bash
Created August 26, 2021 22:49 — forked from judy2k/parse_dotenv.bash
Parse a .env (dotenv) file directly using 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 / .gitlab-ci.yml
Created February 22, 2021 07:02 — forked from superjose/.gitlab-ci.yml
This is an example of a .gitlab-ci.yml that is required for Continuous Integration on GitLab projects.
# 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.
@piihuynh
piihuynh / docker-cleanup
Created August 8, 2020 11:47 — forked from wdullaer/docker-cleanup
Cleanup unused Docker images and containers
#!/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 July 27, 2020 15:42 — forked from tombigel/README.md
How to Change Open Files Limit on OS X and macOS Sierra (10.8 - 10.12)

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:

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;">
    ...
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
@piihuynh
piihuynh / manage.py
Created September 19, 2019 05:14 — forked from bennylope/LICENSE
Django manage.py file that loads environment variables from a .env file per Honcho/Foreman
#!/usr/bin/env python
import os
import sys
import re
def read_env():
"""Pulled from Honcho code with minor updates, reads local default
environment variables from a .env file located in the project root
directory.
@piihuynh
piihuynh / docker-wordpress.sh
Created May 14, 2019 08:17 — forked from tatemz/docker-wordpress.sh
A quick way to get a WordPress installation up and running with Docker
#!/bin/bash
mkdir wordpress-site && cd wordpress-site
touch docker-compose.yml
cat > docker-compose.yml <<EOL
version: "2"
services:
my-wpdb:
@piihuynh
piihuynh / docker_wordpress.md
Created May 14, 2019 08:09 — forked from bradtraversy/docker_wordpress.md
Docker Compose FIle For Wordpress, MySQL & phpmyadmin

Wordpress & Docker

This file will setup Wordpress, MySQL & PHPMyAdmin with a single command. Add the code below to a file called "docker-compose.yaml" and run the command

$ docker-compose up -d

# To Tear Down
$ docker-compose down --volumes