Skip to content

Instantly share code, notes, and snippets.

tongphe / nginx.conf
Created December 13, 2022 09:02 — forked from Stanback/nginx.conf
Example Nginx configuration for adding cross-origin resource sharing (CORS) support to reverse proxied APIs
View nginx.conf
# 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
View kube-switch
#!/usr/bin/env bash
IFS=$'\n' clusters=($(kubectl config get-contexts --no-headers | awk '{print $2}'))
active_cluster=$(kubectl config current-context)
for i in ${!clusters[@]};
if [ "${clusters[$i]}" == $active_cluster ]; then
echo -e "\033[31m[*] \033[36m"${clusters[$i]}
View hassio_whitelist.conf
# Hassio nginx file location /usr/share/hassio/share/nginx_proxy/whitelist.conf:/share/nginx_proxy/whitelist.conf
# Nginx addon config
# customize:
# active: true
# default: nginx_proxy_default*.conf
# servers: nginx_proxy/*.conf
# Allow google assistant IPs
tongphe / sshd_config
Created May 4, 2020 15:22
Hass secure ssh server config
View sshd_config
Port 57749
PubkeyAuthentication yes
PasswordAuthentication no
PermitEmptyPasswords no
PermitRootLogin no
MaxAuthTries 5
ClientAliveInterval 900
ClientAliveCountMax 3
View hass_notify_bad_login.yaml
- id: notify_bad_login
alias: Send notification failed login attempt
initial_state: true
- platform: state
entity_id: persistent_notification.http_login
- condition: template
value_template: '{{ trigger.to_state.state != ''None'' }}'
View Obtain Xiaomi

Obtain Mi Home device token

Use any of these methods to obtain the device token for the supported miio devices.

Method 1 - Obtain device token for miio devices that hide their token after setup

Use one of these methods to obtain the device token for devices that hide their tokens after setup in the Mi Home App (like the Mi Robot Vacuum Cleaner with firmware 3.3.9_003077 or higher). This is usually the case for most Mi Home devices. The latest versions of the Mi Home smartphone app dont hold the token anymore so before you begin with any of these methods you will need to install an older version of the smartphone app. Version 5.0.19 works for sure with the 1st gen Vacuum Robot, for the 2nd gen (S50) you should try version 3.3.9_5.0.30. Android users can find older version of the app here.

Android users

Rooted Android Phones

View Cloud9 Dockerfile
# Cloud9 server
# A lot inspired by
# Notes:
# docker run -d --name cloud9 --user 1001:1001 -p -v /home/user/workspace/:/workspace tongphe/cloud9:v4 --auth user:password
FROM ubuntu
LABEL maintainer="Antoine GIRARD <>"
View service init.d sample
# Provides: <NAME>
# Required-Start: $local_fs $network $named $time $syslog
# Required-Stop: $local_fs $network $named $time $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Description: <DESCRIPTION>
tongphe /
Last active September 16, 2023 02:09
Nginx logging header and body Lua

Build dynamic modules

yum install gcc git luajit-devel pcre-devel lua-devel zlib-devel
git clone
git clone
tar xzvf nginx-1.12.2.tar.gz
cd nginx-1.12.2
export LUAJIT_LIB=/usr/lib64 export LUAJIT_INC=/usr/include/luajit-2.0
./configure --with-compat --add-dynamic-module=/root/ngx_devel_kit --add-dynamic-module=/root/lua-nginx-module
tongphe / .tmux.conf
Last active August 28, 2018 09:56
Tmux ssh-agent and vi mode
View .tmux.conf
set -g prefix F1
set -g base-index 1
set -g pane-base-index 1
set -g status-bg black
set -g status-fg white
set -g status-left-length 50
set -g status-right-length 150
set -g status-interval 5
set -g status-left '#[fg=cyan,bold]#(hostname)'
set -g status-right '#[default] #[fg=cyan,bold]%Y-%m-%d %H:%M:%S#[default]'