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 / zhuang_bi.sh
Created November 5, 2015 10:19
给打开命令行终端增加duangdaungduang的特效, 这个逼装的我给满分
#!/bin/bash
# Usage: copy the code into .zshrc config file
# Find out current screen width and hight
_COLUMNS=$(tput cols)
# Set default message if ( input not provided
_MESSAGE=" FBI Warining "
# Calculate x and y coordinates so that we can display $MESSAGE
# centered in the screen
y=$(( ( $_COLUMNS - ${#_MESSAGE} ) / 2 ))
spaces=$(printf "%-${y}s" " ")
@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
# coding: utf-8
import types
class Task(object):
taskid = 0
def __init__(self, target):
Task.taskid += 1
self.tid = Task.taskid
#!/usr/bin/env python
# coding: utf8
import os
import sys
import calendar
import datetime
# 函数运行时间测试装饰器
import time
from functools import wraps

C++ source code snippets

Represent one byte

using Byte = std::uint8_t;

Represent a dynamic number of bytes

#include <vector>
// 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,
@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() {
@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 / 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 / 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