Skip to content

Instantly share code, notes, and snippets.

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[@]};
do
:
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
allow 66.249.0.0/16;
@tongphe
tongphe / sshd_config
Created May 4, 2020
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
trigger:
- platform: state
entity_id: persistent_notification.http_login
condition:
- condition: template
value_template: '{{ trigger.to_state.state != ''None'' }}'
View Obtain Xiaomi Token.md

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

View Cloud9 Dockerfile
# 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>"
View service init.d sample
#!/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 Jan 4, 2019
Nginx logging header and body Lua
View nginx_log_header_lua.md

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 Aug 28, 2018
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]'
@tongphe
tongphe / linuxsubsystem_autostart.md
Last active Aug 21, 2018
Linux subsystem autostart
View linuxsubsystem_autostart.md
  • Allow sudoer able to run services without password
  • Add a .bat file to Schedule Tasks
@echo off
bash.exe -c "sudo service ssh start"
bash.exe -c "sudo service crond start"