This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://github.com/geektutu/7days-golang/tree/master/gee-cache/day6-single-flight/geecache/singleflight | |
package singleflight | |
import "sync" | |
// call is an in-flight or completed Do call | |
type call struct { | |
wg sync.WaitGroup | |
val interface{} | |
err error |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 前缀树路由 https://geektutu.com/post/gee-day3.html | |
type node struct { | |
pattern string // 待匹配路由,例如 /p/:lang | |
part string // 路由中的一部分,例如 :lang | |
children []*node // 子节点,例如 [doc, tutorial, intro] | |
isWild bool // 是否精确匹配,part 含有 : 或 * 时为true | |
} | |
// 第一个匹配成功的节点,用于插入 | |
func (n *node) matchChild(part string) *node { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// http middleware 实现 | |
type Context struct { | |
handlers []HandlerFunc | |
index int | |
} | |
func (c *Context) Next() { | |
c.index++ | |
s := len(c.handlers) | |
for ; c.index < s; c.index++ { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
msgbox("做我女朋友好吗") | |
msgbox("房产证上会写你名") | |
msgbox("保大") | |
msgbox("我妈会游泳") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
#-*- coding: UTF-8 -*- | |
import requests | |
import yaml | |
import os | |
import sys | |
import getopt | |
import shutil | |
import re |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$dir = ''; | |
foreach (scandir($dir) as $v) { | |
if ($v == '.' || $v == '..') { | |
continue; | |
} | |
if (is_dir($dir.'/'.$v)) { | |
foreach (scandir($dir.'/'.$v) as $vv) { | |
if ($v == '.' || $v == '..') { |