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]'
#!/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>"
- 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'' }}'
@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