Skip to content

Instantly share code, notes, and snippets.

@tongphe
tongphe / bamboo_delete_disabled_branches.sh
Created March 8, 2018 09:00 — forked from sguillope/bamboo_delete_disabled_branches.sh
Script to delete all disabled branches of a Bamboo build plan.
#!/bin/bash -u
# Deletes all disabled branches of a Bamboo build plan
# -----------------------------------------------------------------------------
# Syntax:
# $0 {planKey}
# -----------------------------------------------------------------------------
# Purpose: Bamboo does not automatically delete plan branches when the
# corresponding branch in the repository gets deleted. Because Bamboo fails
# to pull from it, it disables the branch but keep it around forever.
# This script goes through all branches of a build plan and delete the ones
@tongphe
tongphe / wget.txt
Created May 21, 2018 07:16 — forked from suzannealdrich/wget.txt
wget spider cache warmer
wget --spider -o wget.log -e robots=off -r -l 5 -p -S --header="X-Bypass-Cache: 1" live-mysite.gotpantheon.com
# Options explained
# --spider: Crawl the site
# -o wget.log: Keep the log
# -e robots=off: Ignore robots.txt
# -r: specify recursive download
# -l 5: Depth to search. I.e 1 means 'crawl the homepages'.  2 means 'crawl the homepage and all pages it links to'...
# -p: get all images, etc. needed to display HTML page
# -S: print server response
#!/usr/bin/env python
# python tttt.py contacts.vcf > import_icloud.vcf
import vobject
import sys
phone_dict = {
'120': '70', '121': '79', '122': '77', '126': '76', '128': '78', # MOBI
'123': '83', '124': '84', '125': '85', '127': '81', '129': '82', # VINA
@tongphe
tongphe / ssh_auth_sock.md
Last active August 20, 2018 08:42 — forked from jvkersch/ssh_auth_sock.md
Updating SSH_AUTH_SOCK in an already established tmux session

I found this information somewhere on StackOverflow but I forgot exactly where. I'm paraphrasing what I learned here, for future reference.

SSH uses a Unix socket to communicate with other processes. The socket's path can be found by looking at the environment variable $SSH_AUTH_SOCK. When you re-connect to a tmux session that was started during a previous SSH session, this variable will contain the path of the previous SSH auth socket, and this will cause processes that try to connect to your authentication agent to fail. To fix this, we have to

  1. Create a symlink from the auth socket to a fixed path somewhere, so that we can refer to it later on, and not to modify the symlink if current is still alive. In ~/.ssh/rc, add
if [ ! -S ~/.ssh/ssh_auth_sock ] && [ -S "$SSH_AUTH_SOCK" ]; then
    ln -sf $SSH_AUTH_SOCK ~/.ssh/ssh_auth_sock
fi
@tongphe
tongphe / linuxsubsystem_autostart.md
Last active August 21, 2018 09:02
Linux subsystem autostart
  • 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"
@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]'
@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
#!/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
# 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>"

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