Skip to content

Instantly share code, notes, and snippets.

View cloudfly's full-sized avatar
🎯
Focusing

chenyunfei cloudfly

🎯
Focusing
  • Hangzhou, China
View GitHub Profile
@cloudfly
cloudfly / my_config.vim
Last active March 16, 2020 03:10
vim 配置
" 首先安装 vim 配置框架 https://github.com/amix/vimrc.git
" 再安装 vim-go 插件 https://github.com/fatih/vim-go ,就是 clone 到 ~/.vim_runtime/my_plugins 下面
" 再安装 go 语言颜色主题 https://github.com/fatih/molokai 方法同上
set nu
map <tab> :tabnext<cr>
map <leader><tab> :tabprevious<cr>
map <leader>1 :tabfirst<cr>
#!/bin/bash
BASEDIR=/Users/chenyunfei/works
LEN=$(expr ${#BASEDIR} + 2)
cd $BASEDIR
function sync() {
while read -d "" event; do
echo $event | awk -v len="$LEN" '{print substr($0, len)}' | xargs -t -n1 -I{} rsync -avz {} chenyunfei@serverip::works/{}
@cloudfly
cloudfly / parser.go
Created April 12, 2018 02:32
command line string parser, parse it into string slice
func parseCommandLine(command string) ([]string, error) {
var args []string
state := "start"
current := ""
quote := "\""
escapeNext := true
for i := 0; i < len(command); i++ {
c := command[i]
if state == "quotes" {
@cloudfly
cloudfly / match.go
Last active January 20, 2021 02:27
字符串模糊匹配
func SimpleMatch(pattern, s string) bool {
i, j, star, match := 0, 0, -1, 0
for i < len(s) {
if j < len(pattern) && (s[i] == pattern[j] || pattern[j] == '?') {
i++
j++
} else if j < len(pattern) && pattern[j] == '*' {
match, star = i, j
j++
} else if star != -1 {
@cloudfly
cloudfly / tree.go
Created November 19, 2017 00:37
临时
package main
import (
"os"
"bufio"
"io"
"bytes"
"fmt"
"errors"
"strconv"
@cloudfly
cloudfly / _service.md
Created November 10, 2016 07:37 — forked from naholyr/_service.md
Sample /etc/init.d script

Sample service script for debianoids

Look at LSB init scripts for more information.

Usage

Copy to /etc/init.d:

# replace "$YOUR_SERVICE_NAME" with your service's name (whenever it's not enough obvious)
@cloudfly
cloudfly / proxy.go
Created July 7, 2016 07:41
sample http proxy
package proxy
import (
"github.com/mijia/sweb/log"
"io"
"net"
"net/http"
"strings"
"sync"
)
@cloudfly
cloudfly / elect.go
Last active July 7, 2016 07:41
elect a leader by using etcd
package elector
import (
etcdLibkv "github.com/docker/libkv"
"github.com/docker/libkv/store"
etcdStore "github.com/docker/libkv/store/etcd"
"github.com/mijia/sweb/log"
"strings"
"time"
)