Skip to content

Instantly share code, notes, and snippets.

View CCH0124's full-sized avatar
I may be slow to respond.

CCHong CCH0124

I may be slow to respond.
View GitHub Profile
@CCH0124
CCH0124 / NGINX-CORS+CSP.conf
Created September 18, 2023 08:09 — forked from adrianorsouza/NGINX-CORS+CSP.conf
Nginx CORS and CSP configuration for wildcard origin domains
server {
...
add_header Content-Security-Policy "default-src 'none'";
add_header X-Content-Security-Policy "default-src 'none'";
add_header X-WebKit-CSP "default-src 'none'";
add_header "Access-Control-Allow-Headers" "X-Requested-With";
if ( $http_origin ~* (https?://(.+\.)?(domain1|domain2|domain3)\.(?:me|co|com)$) ) {
@CCH0124
CCH0124 / nginx.conf
Created September 18, 2023 07:58 — forked from Stanback/nginx.conf
Example Nginx configuration for adding cross-origin resource sharing (CORS) support to reverse proxied APIs
#
# CORS header support
#
# One way to use this is by placing it into a file called "cors_support"
# under your Nginx configuration directory and placing the following
# statement inside your **location** block(s):
#
# include cors_support;
#
# As of Nginx 1.7.5, add_header supports an "always" parameter which
@CCH0124
CCH0124 / vault-pki.sh
Created July 4, 2023 00:56 — forked from palimarium/vault-pki.sh
configuration-vault-pki
# Creating the root CA:
# First, enable the pki secrets engine at the pki path:
$ vault secrets enable pki
# Tune the pki secrets engine to issue certificates with a maximum time-to-live (TTL)
# of 87600 hours (10 years):
$ vault secrets tune -max-lease-ttl=87600h pki
@CCH0124
CCH0124 / mongo-docker-compose.yml
Created November 10, 2022 00:43 — forked from gbzarelli/mongo-docker-compose.yml
Initializing mongo db in docker-compose with init script
version: '3.8'
services:
# Database - Mongo DB
mongo:
image: mongo
environment:
MONGO_INITDB_ROOT_USERNAME: helpdev
MONGO_INITDB_ROOT_PASSWORD: 123456
# ONLY WORKS FROM INSIDE AZURE !!! (cloudstor can't mount CIFS v3 volumes - required when connecting over internet)
STORAGE_ACCOUNT=<account>
STORAGE_KEY=<key>
STORAGE_SHARE=<share>
# configure
docker plugin install --alias cloudstor:${STORAGE_ACCOUNT} --grant-all-permissions docker4x/cloudstor:18.06.1-ce-azure2 CLOUD_PLATFORM=AZURE AZURE_STORAGE_ACCOUNT_KEY="${STORAGE_KEY}" AZURE_STORAGE_ACCOUNT="${STORAGE_ACCOUNT}" AZURE_STORAGE_ENDPOINT="core.windows.net" DEBUG=1
# create
docker volume create --driver=cloudstor:${STORAGE_ACCOUNT} --opt=share=${STORAGE_SHARE} ${STORAGE_SHARE}
# test
docker run --rm -v ${STORAGE_SHARE}:/data --cap-add SYS_ADMIN --cap-add DAC_READ_SEARCH -it busybox
@CCH0124
CCH0124 / ObjectHeader32.txt
Created July 14, 2021 13:47 — forked from arturmkrtchyan/ObjectHeader32.txt
Java Object Header
|----------------------------------------------------------------------------------------|--------------------|
| Object Header (64 bits) | State |
|-------------------------------------------------------|--------------------------------|--------------------|
| Mark Word (32 bits) | Klass Word (32 bits) | |
|-------------------------------------------------------|--------------------------------|--------------------|
| identity_hashcode:25 | age:4 | biased_lock:1 | lock:2 | OOP to metadata object | Normal |
|-------------------------------------------------------|--------------------------------|--------------------|
| thread:23 | epoch:2 | age:4 | biased_lock:1 | lock:2 | OOP to metadata object | Biased |
|-------------------------------------------------------|--------------------------------|--------------------|
|
@CCH0124
CCH0124 / CleanArchitecture.md
Created December 28, 2018 14:35 — forked from ygrenzinger/CleanArchitecture.md
Summary of Clean Architecture by Robert C. Martin

Summary of book "Clean Architecture" by Robert C. Martin

Uncle Bob, the well known author of Clean Code, is coming back to us with a new book called Clean Architecture which wants to take a larger view on how to create software.

Even if Clean Code is one of the major book around OOP and code design (mainly by presenting the SOLID principles), I was not totally impressed by the book.

Clean Architecture leaves me with the same feeling, even if it's pushing the development world to do better, has some good stories and present robust principles to build software.

The book is build around 34 chapters organised in chapters.

@CCH0124
CCH0124 / nginxproxy.md
Created July 20, 2018 01:03 — forked from soheilhy/nginxproxy.md
How to proxy web apps using nginx?

Virtual Hosts on nginx (CSC309)

When hosting our web applications, we often have one public IP address (i.e., an IP address visible to the outside world) using which we want to host multiple web apps. For example, one may wants to host three different web apps respectively for example1.com, example2.com, and example1.com/images on the same machine using a single IP address.

How can we do that? Well, the good news is Internet browsers