Skip to content

Instantly share code, notes, and snippets.

View Andrew-liu's full-sized avatar

Andrew-liu Andrew-liu

View GitHub Profile
@Andrew-liu
Andrew-liu / install_bbr_on_centos.sh
Created December 2, 2017 11:11
一键配置Centos支持bbr内核
#!/usr/bin/env bash
#
# Auto install latest kernel for TCP BBR
#
# System Required: CentOS 6+, Debian7+, Ubuntu12+
#
# Copyright (C) 2016-2017 Teddysun <i@teddysun.com>
#
# URL: https://teddysun.com/489.html
#
@Andrew-liu
Andrew-liu / pyshell.py
Created September 27, 2017 04:13
python run shell command
#coding:utf-8
import subprocess
import time
from fabric.api import settings, run, env
def wait_process_end(process, timeout):
if timeout <= 0:
process.wait()
return 0
@Andrew-liu
Andrew-liu / logger.py
Last active October 21, 2017 08:09
A log tool for python with time rotating
# -*- coding: utf-8 -*-
#!/usr/bin/env python
# @Author: asyncliu
# @Date: 2017-08-12 10:32:58
# @Last Modified by: asyncliu
# @Last Modified time: 2017-10-20 17:40:41
# @Project: 日志工具类
import logging, sys
import logging.handlers
@Andrew-liu
Andrew-liu / install_shadowsocks_on_centos.sh
Last active June 3, 2021 10:20
CentOS下一键安装shadowsocks
# 一键安装shadowsocks
# wget --no-check-certificate -O shadowsocks.sh https://raw.githubusercontent.com/teddysun/shadowsocks_install/master/shadowsocks.sh && chmod +x shadowsocks.sh && ./shadowsocks.sh 2>&1 | tee shadowsocks.log
# 卸载方法
# ./shadowsocks.sh uninstall
# 配置文件路径
# /etc/shadowsocks.json
# 常用命令:
#启动:
# /etc/init.d/shadowsocks start
#停止:
@Andrew-liu
Andrew-liu / client.go
Created October 14, 2016 08:37 — forked from jordanorelli/client.go
rpc server example in go
package main
import (
"bufio"
"log"
"net/rpc"
"os"
)
func main() {
// sublime for mac settings
{
"always_show_minimap_viewport": true,
"bold_folder_labels": true,
"color_scheme": "Packages/Colorsublime - Themes/Cozy.tmTheme",
"create_window_at_startup": false,
"default_line_ending": "unix",
"ensure_newline_at_eof_on_save": true,
"font_face": "monaco",
"font_size": 16,

C++ source code snippets

Represent one byte

using Byte = std::uint8_t;

Represent a dynamic number of bytes

#include <vector>
#!/usr/bin/env python
# coding: utf8
import os
import sys
import calendar
import datetime
# 函数运行时间测试装饰器
import time
from functools import wraps
# coding: utf-8
import types
class Task(object):
taskid = 0
def __init__(self, target):
Task.taskid += 1
self.tid = Task.taskid
@Andrew-liu
Andrew-liu / tornado_cookie_secret_generator.py
Created November 10, 2015 04:00 — forked from didip/tornado_cookie_secret_generator.py
Generates secure cookie secret for Tornado Web Framework