Skip to content

Instantly share code, notes, and snippets.

@nguyenhoang2009
nguyenhoang2009 / Jenkinsfile.groovy
Created March 5, 2024 04:21 — forked from Faheetah/Jenkinsfile.groovy
Jenkinsfile idiosynchrasies with escaping and quotes
node {
echo 'Results included as an inline comment exactly how they are returned as of Jenkins 2.121, with $BUILD_NUMBER = 1'
echo 'No quotes, pipeline command in single quotes'
sh 'echo $BUILD_NUMBER' // 1
echo 'Double quotes are silently dropped'
sh 'echo "$BUILD_NUMBER"' // 1
echo 'Even escaped with a single backslash they are dropped'
sh 'echo \"$BUILD_NUMBER\"' // 1
echo 'Using two backslashes, the quotes are preserved'
sh 'echo \\"$BUILD_NUMBER\\"' // "1"
@nguyenhoang2009
nguyenhoang2009 / kubernetes-wordpress-installation.md
Last active January 11, 2024 03:58 — forked from p4tin/README.md
Wordpress Kubernetes Cluster

Kubernetes Wordpress installation

Use minikube to test with

  • on macos: ** brew cask install minikube ** minikube start

Start the cluster and scale:

  • kubectl create secret generic mysql-pass --from-literal=password=YOUR_PASSWORD
@nguyenhoang2009
nguyenhoang2009 / k8s-odoo.yaml
Created March 9, 2023 04:03 — forked from oivoodoo/odoo.yaml
k8s deploy for odoo
---
apiVersion: v1
kind: Service
metadata:
name: odoo-db
labels:
app: odoo-shop
spec:
ports:
- port: 5432
@nguyenhoang2009
nguyenhoang2009 / nginx_websocket.md
Created September 22, 2022 10:00 — forked from thanhpk/nginx_websocket.md
nginx websocket proxy pass

Set up nginx proxy to nodejs websocket


Tài liệu này trình bày hai cách cấu hình, https ở nginx -> wss nodejs hoặc từ https ở nginx -> ws ở nodejs

Để điều hướng request từ cổng 443 vào websocket server (demo bằng nodejs)

  • Yêu cầu, chạy nginx 1.4 trên ubuntu

From https to wss

  • nginx nghe cổng 443, toàn bộ request wss://domain.com/ws sẽ được chuyển về wss://127.0.0.1:2910
@nguyenhoang2009
nguyenhoang2009 / nginx-block-search-engine
Last active September 21, 2022 07:30 — forked from hans2103/server.badbots
NGINX to block bad bots. (add Twenga|TwengaBot if you want to exclude them too)
if ($http_user_agent ~* (360Spider|80legs.com|Abonti|AcoonBot|Acunetix|adbeat_bot|AddThis.com|adidxbot|ADmantX|AhrefsBot|AngloINFO|Antelope|Applebot|BaiduSpider|BeetleBot|billigerbot|binlar|bitlybot|BlackWidow|BLP_bbot|BoardReader|Bolt\ 0|BOT\ for\ JCE|Bot\ mailto\:craftbot@yahoo\.com|casper|CazoodleBot|CCBot|checkprivacy|ChinaClaw|chromeframe|Clerkbot|Cliqzbot|clshttp|CommonCrawler|comodo|CPython|crawler4j|Crawlera|CRAZYWEBCRAWLER|Curious|Curl|Custo|CWS_proxy|Default\ Browser\ 0|diavol|DigExt|Digincore|DIIbot|discobot|DISCo|DoCoMo|DotBot|Download\ Demon|DTS.Agent|EasouSpider|eCatch|ecxi|EirGrabber|Elmer|EmailCollector|EmailSiphon|EmailWolf|Exabot|ExaleadCloudView|ExpertSearchSpider|ExpertSearch|Express\ WebPictures|ExtractorPro|extract|EyeNetIE|Ezooms|F2S|FastSeek|feedfinder|FeedlyBot|FHscan|finbot|Flamingo_SearchEngine|FlappyBot|FlashGet|flicky|Flipboard|g00g1e|Genieo|genieo|GetRight|GetWeb\!|GigablastOpenSource|GozaikBot|Go\!Zilla|Go\-Ahead\-Got\-It|GrabNet|grab|Grafula|GrapeshotCrawler|GTB5|GT\:\:WWW|Guzz
@nguyenhoang2009
nguyenhoang2009 / kong-dns.md
Created October 10, 2021 19:18 — forked from montanaflynn/kong-dns.md
Example of using Kong with DNS

Kong

Kong is a powerful proxy built on nginx. By taking a request and passing it to an upstream server and then returning the result to the client Kong can perform his magic. To know which requests go to which service Kong looks for a Host header to match against. There's a few other ways Kong can match requests to services but for now that's the most basic route. Pun intended.

Start

Assuming everything has been installed and setup, such as dependencies and config files which can be found in the docs, it's time to turn Kong on. The first time Kong runs you'll see some Kong config values and initial migrations to the datastore.

kong start
@nguyenhoang2009
nguyenhoang2009 / script.sh
Created July 2, 2021 02:47 — forked from vielhuber/script.sh
PostgreSQL: Backup and restore export import pg_dump with password on command line #sql
# best practice: linux
nano ~/.pgpass
*:5432:*:username:password
chmod 0600 ~/.pgpass
# best practice: windows
edit %APPDATA%\postgresql\pgpass.conf
*:5432:*:username:password
# linux
@nguyenhoang2009
nguyenhoang2009 / export_db_structure.sh
Created July 2, 2021 02:47 — forked from dantheman213/export_db_structure.sh
Batch backup and export your Postgres or PostgreSQL table schemas and stored functions or procedures into individual *.sql files --the easy way!
#!/bin/sh
# AUTHOR
# DANIEL E. GILLESPIE (2016)
# https://github.com/dantheman213
# DESCRIPTION
# Export your app's table schemas and stored functions from a PostgreSQL
# database into individual *.sql files for easy management and source control.
@nguyenhoang2009
nguyenhoang2009 / slack.sh
Created June 25, 2021 18:29 — forked from andkirby/slack.sh
Shell/Bash script for sending slack messages.
#!/usr/bin/env bash
####################################################################################
# Slack Bash console script for sending messages.
####################################################################################
# Installation
# $ curl -s https://gist.github.com/andkirby/67a774513215d7ba06384186dd441d9e/raw --output /usr/bin/slack
# $ chmod +x /usr/bin/slack
####################################################################################
# USAGE
# Send message to slack channel/user