Skip to content

Instantly share code, notes, and snippets.

luw2007 luw2007

Block or report user

Report or block luw2007

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@luw2007
luw2007 / trimspace.go
Created May 19, 2019
TrimSpace remove space, also in sentence. like: " a \t\r\n b " -> "a b"
View trimspace.go
package main
import (
"fmt"
"github.com/google/go-cmp/cmp"
)
func isSpace(b byte) bool {
switch b {
@luw2007
luw2007 / logger.go
Created Nov 17, 2018
Go logging for human
View logger.go
package log
import (
"bytes"
"path"
"time"
"github.com/gin-gonic/gin"
"github.com/lestrrat/go-file-rotatelogs"
"github.com/pkg/errors"
@luw2007
luw2007 / ae.c
Last active Aug 21, 2018
redis 事件处理和网络协议
View ae.c
#ifndef __AE_H__
#define __AE_H__
#include <time.h>
#define AE_OK 0
#define AE_ERR -1
#define AE_NONE 0 /* No events registered. */
#define AE_READABLE 1 /* Fire when descriptor is readable. */
View redis_proxy.py
"""
redis proxy
用来展示redis协议
"""
import asyncio
redis_addr = ('127.0.0.1', 6379)
proxy_addr = ('127.0.0.1', 6380)
View epoll.c
//http://www.it165.net/os/html/201308/5868.html
#include <sys/socket.h>
#include <sys/wait.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <sys/epoll.h>
#include <sys/sendfile.h>
#include <sys/stat.h>
#include <unistd.h>
#include <stdio.h>
@luw2007
luw2007 / tag
Created Aug 6, 2018
自动为git项目打版本号。保存为/usr/loca/bin/tag,chmod +x /usr/loca/bin/tag。 在git目录执行tag 即可
View tag
#!/bin/sh
# 版本号类似于 MAJOR.MINOR.PATCH 遵循 Semantic Versioning 2.0.0:
# MAJOR: 主版本号,不兼容的修改,如:底层重构、框架层变动
# MINOR:次版本号,向前兼容的修改,如:增加新功能、代码优化
# PATCH: 小版本号,修复bug
PREFIX=v
DEFAULT_VERSION=0.0.0
# 获取git版本号
@luw2007
luw2007 / four.go 
Last active Mar 14, 2019
google 面试题:输出连续的1、2、3、4到4个文件
View four.go 
package main
import (
"bytes"
"fmt"
"strconv"
)
const STEP, NUM = 4, 40
@luw2007
luw2007 / bit.go
Last active Nov 28, 2018
业务中经常需要对redis执行一组连续的 gitbit ,即 gitbits 。以下通过 getrange 方法来优化 getbits 的速度。redis 的 bit 并非按照自然顺序排序,所以需要计算。
View bit.go
package redis
import (
r "github.com/garyburd/redigo/redis"
)
type Pool struct {
r.Pool
}
@luw2007
luw2007 / docker-shadowsocks-go.md
Last active Apr 10, 2018
如何使用docker科学上网
View docker-shadowsocks-go.md

##问: 我怎么用docker 部署ss server

##答:

  1. 购买vps: 这个途径比较多。 网上一搜一大把。
  2. vps上安装docker: 方法很多, 比如ubuntu上可以使用sudo apt-get install docker.io 我采用的vps服务提供商提供的docker镜像。
  3. 使用docker 安装ss-server:
You can’t perform that action at this time.