Skip to content

Instantly share code, notes, and snippets.

View zengxs's full-sized avatar

Xiangsong Zeng zengxs

  • Singapore/London
  • 07:16 (UTC +08:00)
View GitHub Profile
@zengxs
zengxs / mail_proxy.py
Last active June 8, 2019 01:48
A simple smtps, imaps proxy server
#!/usr/bin/env python3
# support python 3.5 or later, use python standard library only
import asyncio
import ssl
async def dial(client_conn, server_conn):
async def io_copy(reader, writer):
#!/bin/sh
sudo dd if=/dev/zero of=/swapfile bs=1M count=1024 # 1G
sudo chmod 0600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
echo /swapfile none swap sw 0 0 | sudo tee -a /etc/fstab
@zengxs
zengxs / PhabricatorSimplifiedChineseTranslation.php
Created March 9, 2020 16:10
Phabricator 简易中文翻译
<?php
// Phabricator 中文翻译
//
// 安装位置: {phabricator_root}/src/extension/PhabricatorSimplifiedChineseTranslation.php
//
// Ref: https://github.com/arielyang/phabricator_zh_Hans
final class PhabricatorSimplifiedChineseTranslation extends PhutilTranslation {
public function getLocaleCode() {
return 'zh_Hans';
@zengxs
zengxs / rainy-proxy.go
Last active March 19, 2020 06:42
a simple http-proxy program use goproxy, with basic auth
package main
import (
"log"
"net/http"
"github.com/elazarl/goproxy"
"github.com/elazarl/goproxy/ext/auth"
)
@zengxs
zengxs / info.php
Created April 12, 2020 06:13
`php_info` page with HTTP Basic Auth
<?php
$credentials = array(
'admin' => 'your_password',
);
$valid_users = array_keys($credentials);
$user = $_SERVER['PHP_AUTH_USER'];
$pass = $_SERVER['PHP_AUTH_PW'];
#!/usr/bin/env python3
###
# START pandocfilters.py
###
# Author: John MacFarlane <jgm@berkeley.edu>
# Copyright: (C) 2013 John MacFarlane
# License: BSD3
<?php
final class DiffusionReadmeView extends DiffusionView {
private $path;
private $content;
public function setPath($path) {
$this->path = $path;
return $this;
@zengxs
zengxs / test_socks5_to_tcp.py
Created November 5, 2019 12:51
Use python asyncio module to unwrap socks5 proxy socket
import asyncio
import logging
from asyncio import StreamReader, StreamWriter, StreamReaderProtocol
from typing import Optional
import socks
logging.basicConfig(level=logging.INFO)
@zengxs
zengxs / phabricator-configuration.md
Last active July 9, 2020 10:07
Phabricator configuration
apache ALL=(phd) SETENV: NOPASSWD: /usr/bin/git, /usr/bin/git-upload-pack, /usr/bin/git-receive-pack
git ALL=(phd) SETENV: NOPASSWD: /usr/bin/git, /usr/bin/git-upload-pack, /usr/bin/git-receive-pack

phd.service

# Systemd unit file for phd
[Unit]
Description=Phabricator Daemon
@zengxs
zengxs / README.md
Last active October 23, 2020 03:33
GitLab 安装配置流程

GitLab 安装配置流程

基于 CentOS 8.2 安装。其中,redis 和 postgresql 组件将由我们自己配置,而不使用 gitlab 的 docker 镜像中打包的版本。

gitlab 套件中的 nginx 将绑定到 127.0.0.1:8081 端口;gitlab 的 ssh 将绑定到 0.0.0.0:2222 端口。

注意需要关闭 CentOS 的 SELinux,SELinux 过于严苛的安全策略会给安装过程带来很多不必要的麻烦; 在系统安全方面,这里将启用 firewalld 防火墙,这种安全策略,对于仅安装了 gitlab 的服务器来说已经足够。

安装 Redis