Skip to content

Instantly share code, notes, and snippets.

@ansiz
ansiz / check-restart.sh
Created May 5, 2020 06:30
checks specified process is running and restarts it
#!/bin/bash
date >> /tmp/trojan.log
echo "check trojan status" >> /tmp/trojan.log
@ansiz
ansiz / build.sh
Created January 20, 2019 16:27
Phabricator-CI-with-webhook
#!/bin/bash
# Prepare
export PATH=$PATH:/usr/local/phabricator/arcanist/bin
PHID=$1
DIFF_ID=$2
REVISION_ID=$3
TOKEN=YOUR_TOKEN_HERE
@ansiz
ansiz / enable_user_namespace.sh
Last active November 9, 2020 15:15
Enable user namespace on CentOS/Redhat 7 to support Docker namespace remap
#/bin/bash
grubby --args="namespace.unpriv_enable=1 user_namespace.enable=1" --update-kernel="$(grubby --default-kernel)"
echo "user.max_user_namespaces=15000" >> /etc/sysctl.conf
useradd hpc
usermod -u 666 hpc
groupmod -g 666 hpc
echo "hpc:666:1" > /etc/subuid
@ansiz
ansiz / install-tmux.sh
Last active November 4, 2018 09:40
Install tmux latest on CentOS
# ncurses and libevent
yum install ncurses libevent-devel -y
# tmux
git clone https://github.com/tmux/tmux.git
cd tmux
sh autogen.sh
./configure && make -j8
sudo make install
@ansiz
ansiz / gencert.sh
Created August 3, 2018 14:23
generate self-signed ssl certs
#!/bin/sh
# create self-signed server certificate:
read -p "Enter your domain [www.example.com]: " DOMAIN
echo "Create server key..."
openssl genrsa -des3 -out $DOMAIN.key 1024
@ansiz
ansiz / glider.conf
Last active July 13, 2018 22:43
make glider as a systemd service
listen=:1087
forward=socks5://127.0.0.1:1080
@ansiz
ansiz / go-shadowsocks-install.sh
Created May 31, 2018 16:25
go-shadowsocks-install.sh
#!/usr/bin/env bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
#=================================================================#
# System Required: CentOS, Debian, Ubuntu #
# Description: One click Install Shadowsocks-go server #
# Author: Teddysun <i@teddysun.com> #
# Thanks: @cyfdecyf <https://twitter.com/cyfdecyf> #
# Intro: https://teddysun.com/392.html #
#==================================================================
#!/bin/bash
# OpenVPN road warrior installer for Debian, Ubuntu and CentOS
# This script will work on Debian, Ubuntu, CentOS and probably other distros
# of the same families, although no support is offered for them. It isn't
# bulletproof but it will probably work if you simply want to setup a VPN on
# your Debian/Ubuntu/CentOS box. It has been designed to be as unobtrusive and
# universal as possible.
@ansiz
ansiz / URIParser.js
Last active April 17, 2018 01:11
JavaScript URI parser in regular expressions
function parseURI(url) {
var m = String(url).replace(/^\s+|\s+$/g, '').match(/^([^:\/?#]+:)?(\/\/(?:[^:@]*(?::[^:@]*)?@)?(([^:\/?#]*)(?::(\d*))?))?([^?#]*)(\?[^#]*)?(#[\s\S]*)?/);
// authority = '//' + user + ':' + pass '@' + hostname + ':' port
return (m ? {
href: m[0] || '',
protocol: m[1] || '',
authority: m[2] || '',
host: m[3] || '',
hostname: m[4] || '',
port: m[5] || '',