Skip to content

Instantly share code, notes, and snippets.

View daydaygo's full-sized avatar
🎯
coder at work

dayday daydaygo

🎯
coder at work
View GitHub Profile
@daydaygo
daydaygo / singleflight.go
Created January 15, 2021 06:30
singleflight
// 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
@daydaygo
daydaygo / trie_router.go
Created January 15, 2021 04:38
trie router 前缀树路由
// 前缀树路由 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 {
@daydaygo
daydaygo / middleware.go
Created January 15, 2021 04:06
http middleware
// 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++ {
@daydaygo
daydaygo / girl.vbs
Last active January 15, 2021 04:03
msgbox("做我女朋友好吗")
msgbox("房产证上会写你名")
msgbox("保大")
msgbox("我妈会游泳")
@daydaygo
daydaygo / kongdl.py
Created June 10, 2020 09:09
kong: db -> dbless
#!/usr/bin/env python
#-*- coding: UTF-8 -*-
import requests
import yaml
import os
import sys
import getopt
import shutil
import re
<?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 == '..') {