Skip to content

Instantly share code, notes, and snippets.

View yuezhu's full-sized avatar

Yue Zhu yuezhu

  • Boston, Massachusetts
View GitHub Profile
@yuezhu
yuezhu / gist:25e2e43c602a4aa2d1b897bbc47cb0cc
Last active March 22, 2022 11:52
Build Ceph radosgw using Centos 7 container
mkdir -p /root/build
docker run --name centos --hostname centos -it -v /root/build:/root/build centos:7 /bin/bash
# inside centos container
yum install -y epel-release
yum install -y git jq wget cmake3 make gcc-c++ rpm-build rpmdevtools
yum install -y centos-release-scl
yum install -y devtoolset-8
scl enable devtoolset-8 bash
cd /root/build
@yuezhu
yuezhu / gist:daa000f12c3e11fe97ced5495921d00b
Last active February 6, 2021 01:17
Generate Ceph 14.2.11 compile_commands.json on Mac Big Sur
brew install python nss leveldb oath-toolkit boost-python3
pip3 install -U cython sphinx
export PKG_CONFIG_PATH=$(brew list --verbose nss 2>&1 1>/dev/null | awk '{print $2}')/lib/pkgconfig:$(brew list --verbose openssl 2>&1 1>/dev/null | awk '{print $2}')/lib/pkgconfig
export PYTHON3_LIBRARIES=$(python3 -c "import distutils.sysconfig as sysconfig; print(sysconfig.get_config_var('LIBDIR'))")
export PYTHON3_INCLUDE_DIR=$(python3 -c "from distutils.sysconfig import get_python_inc; print(get_python_inc())")
export SNAPPY_ROOT_DIR=$(brew list --verbose snappy 2>&1 1>/dev/null | awk '{print $2}')
cmake -H. -BDebug -DCMAKE_BUILD_TYPE=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS=YES \
#!/bin/bash
set -ex
apt-get update
apt-get install -y \
apt-transport-https \
ca-certificates \
curl \
@yuezhu
yuezhu / gist:19676d06e871f99708ccb82805bda96d
Created June 12, 2020 16:22
Emacs auto update ELPA packages
(defconst package-no-https nil
"Use plain http when contacting ELPA repositories.")
(defconst package-upgrade-check-interval 7200
"Interval to perform ELPA packages upgrade check.")
(defconst package-upgrade-check-stamp
(expand-file-name "package-upgrade-check-stamp"
user-emacs-directory)
"Filename that store the timestamp that last ELPA packages
@yuezhu
yuezhu / ubuntu_t460s.org
Last active November 16, 2018 15:34
Ubuntu 18.04 on T460s

Ubuntu 18.04 on T460s

APT force IPv4

sudo sh -c 'cat > /etc/apt/apt.conf.d/99force-ipv4 <<EOF
Acquire::ForceIPv4 "true";
EOF'

Glibc prefer IPv4

@yuezhu
yuezhu / gist:47b15b4b8e944221861ccf7d7f5868f5
Created February 7, 2018 18:10
Generate self-signed certificate for HAProxy
# Generate a unique private key (KEY)
sudo openssl genrsa -out mydomain.key 2048
# Generating a Certificate Signing Request (CSR)
sudo openssl req -new -key mydomain.key -out mydomain.csr
# Creating a Self-Signed Certificate (CRT)
openssl x509 -req -days 365 -in mydomain.csr -signkey mydomain.key -out mydomain.crt
# Append KEY and CRT to mydomain.pem
@yuezhu
yuezhu / www.transmission.conf
Last active October 13, 2023 17:03
Enable HTTPS for Transmission on Synology
# Create nginx config /etc/nginx/conf.d/www.transmission.conf
# sudo synoservice --restart nginx
location /transmission {
if ($scheme = http) {
return 301 https://$http_host$request_uri;
}
auth_basic "Server Restricted";
auth_basic_user_file /etc/nginx/conf.d/.htpasswd;
allow 192.168.1.1;
allow 192.168.1.192/28;
@yuezhu
yuezhu / haproxy.cfg
Last active November 11, 2022 13:44
HAProxy config for HTTPS transmission web interface
global
maxconn 16384
log 127.0.0.1 len 8192 local0
log-send-hostname
chroot /var/lib/haproxy
stats socket /run/haproxy/admin.sock mode 660 level admin expose-fd listeners
stats timeout 30s
user haproxy
group haproxy
daemon
@yuezhu
yuezhu / git_server_via_ssh.sh
Last active February 8, 2018 20:50
Setup SSH GIT server
sudo useradd --create-home --skel /dev/null --home-dir /repo --shell /usr/bin/git-shell git
sudo chmod 750 /repo
sudo mkdir -p /repo/.ssh
sudo cp ~/.ssh/authorized_keys /repo/.ssh/ # Use current user's authorized_keys
sudo chown -R git:git /repo/.ssh/
sudo mkdir -p /repo/git-shell-commands
sudo sh -c "cat >/repo/git-shell-commands/no-interactive-login <<\EOF
#!/bin/sh
printf '%s\n' \"No interactive shell access is provided by this GIT server.\"
exit 128
@yuezhu
yuezhu / lenovo_outlet_scanner.py
Created January 14, 2018 21:34
Lenovo Outlet Scanner
import urllib
import re
import logging
import sys
import time
import webbrowser
import pprint
import argparse
import subprocess
import shlex