Skip to content

Instantly share code, notes, and snippets.

@tongphe
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
#
# 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
#!/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[@]};
do
:
if [ "${clusters[$i]}" == $active_cluster ]; then
echo -e "\033[31m[*] \033[36m"${clusters[$i]}
# 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
allow 66.249.0.0/16;
@tongphe
tongphe / sshd_config
Created May 4, 2020 15:22
Hass secure ssh server config
Port 57749
PubkeyAuthentication yes
PasswordAuthentication no
PermitEmptyPasswords no
PermitRootLogin no
MaxAuthTries 5
ClientAliveInterval 900
ClientAliveCountMax 3
- id: notify_bad_login
alias: Send notification failed login attempt
initial_state: true
trigger:
- platform: state
entity_id: persistent_notification.http_login
condition:
- condition: template
value_template: '{{ trigger.to_state.state != ''None'' }}'

https://github.com/Maxmudjon/com.xiaomi-miio/blob/master/docs/obtain_token.md

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

# Cloud9 server
# A lot inspired by https://hub.docker.com/r/gai00/cloud9/~/dockerfile/
# https://hub.docker.com/r/kdelfour/cloud9-docker/~/dockerfile/
#
# Notes:
# docker run -d --name cloud9 --user 1001:1001 -p 127.0.0.1:8282:8282 -v /home/user/workspace/:/workspace tongphe/cloud9:v4 --auth user:password
FROM ubuntu
LABEL maintainer="Antoine GIRARD <antoine.girard@sapk.fr>"
#!/bin/sh
### BEGIN INIT INFO
# 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>
### END INIT INFO
@tongphe
tongphe / nginx_log_header_lua.md
Last active February 9, 2024 03:06
Nginx logging header and body Lua

Build dynamic modules

yum install gcc git luajit-devel pcre-devel lua-devel zlib-devel
wget http://nginx.org/download/nginx-1.12.2.tar.gz
git clone https://github.com/openresty/lua-nginx-module.git
git clone https://github.com/simplresty/ngx_devel_kit.git
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
tongphe / .tmux.conf
Last active August 28, 2018 09:56
Tmux ssh-agent and vi mode
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]'