- 博客(27)
- 资源 (1)
- 收藏
- 关注
原创 go-设计模式-解释器模式
go 设计模式 解释器模式package mainimport ( "fmt" "regexp" "strconv")type Address struct { City string}type User struct { Id int Name string Age int}func main() { var users = []*User{ {Id: 102, Name: "shenyi", Age: 20}, {Id: 103, Name: "sh
2021-10-23 11:34:53
168
原创 go 数组全排列组合实现
go实现全排列组合package mainimport "fmt"func demo(src []int) { for i := 0; i < len(src); i++ { first := src[i] temp := make([]int, 0) temp = append(temp, src[:i]...) temp = append(temp, src[i+1:]...) order([]int{first}, temp) }}func order(s
2021-08-30 13:13:38
1290
原创 es中对score 的过滤 min_score
排除_score小于min_score中指定的最小值的文档只返回 小于 min_score 值的指定 list。不是用post_filter 也不是用filter. 切记"sort":{ "_score":{ "order":"desc" } }, "min_score":80, "query":{ "function_score":{ "query":{
2021-05-17 19:59:56
4488
2
原创 排序查找有序字符串中的0
一个有规则的字符串 例如ioiioiiioiiiio 求指定_len 长度位置的 前面有多少个o出现下面是代码实现做了优化 时间复杂度简介O(1) 但是需要先做字符串规则处理剩下的不多少 自己看代码package mainimport "fmt"func main() { dd := "ioiioiiioiiiio" //原始序列 fmt.Println(len(dd)) _len := 6 //目标值长度值 m_p := make(map[int]int) sort_arr
2021-04-21 16:13:58
251
原创 数组目标值递归
问题:给你一个数组 arr,和一个整数 target。如果可以任意选择 arr 中的数字,能不能累加得到 target,返回 true 或者 false例如:输入 1,2,3,4,5,6 target 3输出 1递归的方法package mainimport "fmt"func process(arr []int, index int, sum int, aim int) int { if index == len(arr) { if sum == aim { return 1
2021-04-19 10:51:15
153
原创 最长子序列的长度
最长的连续子序列的长度package mainimport ( "fmt")func Max(x, y int) int { if x > y { return x } return y}func maxlzubList(arr []int) int { max_length := 1 lis := make([]int, len(arr)) lis[0] = 1 for i := 0; i < len(arr); i++ { for j := 0; j
2021-04-12 16:18:14
421
原创 数组中第n 大的元素 go排序版本
数组中第n 大的元素package mainimport "fmt"func findNMax(arr []int, n int) int { for j := 0; j < n; j++ { for i := len(arr) - 1; i > j; i-- { if arr[i] > arr[i-1] { //交换 arr[i-1], arr[i] = arr[i], arr[i-1] } } } fmt.Println(arr)
2021-04-12 14:57:17
163
原创 radix树实现-go
redix树实现gopackage mainimport "fmt"//radix Nodetype Node struct { Nodes []*Node Index string //节点数据 Path string //节点path}var root = NewRootNode("")func NewRootNode(s string) *Node { return &Node{ Nodes: make([]*Node, 0), Index: "",
2021-03-24 19:47:40
265
原创 学生成绩排行-sql
学生成绩排行建立表语句CREATE TABLE `student` ( `id` int(11) unsigned NOT NULL AUTO_INCREMENT, `name` varchar(20) DEFAULT NULL, `score` int(11) DEFAULT NULL, PRIMARY KEY (`id`)) ENGINE=InnoDB AUTO_INCREMENT=12 DEFAULT CHARSET=utf8;查询全部select * from stud
2021-03-19 14:33:57
1049
原创 go归并排序
go归并排序package mainimport "fmt"func split(res []int) []int { if len(res) < 2 { return res } i := len(res) / 2 left := split(res[:i]) right := split(res[i:]) return arrayMerge(left, right)}func arrayMerge(left []int, right []int) []int { r
2021-03-18 14:09:07
234
原创 给定一个包括 n 个整数的数组 nums 和 一个目标值 target
//给定一个包括 n 个整数的数组 nums 和 一个目标值 target。//找出 nums 中的三个整数,使得它们的和与 target 最接近。//返回这三个数的和。假定每组输入只存在唯一答案。package mainimport "fmt"//给定一个包括 n 个整数的数组 nums 和 一个目标值 target。//找出 nums 中的三个整数,使得它们的和与 target 最接近。//返回这三个数的和
2021-03-17 17:10:22
3694
原创 go 版 堆排序
堆排序package mainimport ( "fmt")func headSort(arr []int){ arrlen := len(arr) if arrlen <= 1 { return } for i:=0;i<arrlen;i++{ buildMinHead(arr[i:]) }}//构建最小堆//注意: 在二叉树中,若当前节点的下标为 i, 则其父节点的下标为 i/2,其左子节点的下标为 i*2,其右子节点的下标为i*2+1;//本代码是
2021-03-09 17:06:45
114
原创 2叉树 的前(先) 中,后 序便利
package mainimport "fmt"type TreeNode struct { Name string Left *TreeNode Right *TreeNode}func (t *TreeNode) AddLeftNode(value string) *TreeNode { t.Left = &TreeNode{Name: value} return t.Left}func (t *TreeNode) AddRightNode(value stri
2021-03-09 14:53:28
451
原创 单链表制定区域倒序时间复杂度O(n)
有序链表0,1,2,3,4,5,6倒序制定区域例如recover(0,1)特别注意在0 开始的时候 和大于结束节点的时候package mainimport ( "fmt")type Nextn interface { NextNode() *Node}type Node struct { Data string Next *Node}type List struct { HeadNode *Node Len int}func newList()
2021-03-08 18:31:14
230
原创 字符串序列-递归方式
package mainimport ( "fmt")func swap(start, end int, S []string) {S[start], S[end] = S[end], S[start]}func permutation(S []string, start, end int) { if start == end { fmt.Println(S) } else { for i := start; i < end; i++ { swap(start,
2021-03-02 13:32:39
146
原创 go-bloomfilter
go实现布隆过滤器加载静态资源生成动态资源 并加载适合前端部署,缓解前端眼里,分流控制源码https://github.com/272271975/gofloomfile欢迎star 谢谢
2020-11-30 10:17:03
127
原创 go 中间件 设计模式实现
中间件实现粗略版本var (PIPLC *PIPLContext)type Contion func() booltype ItemFn func(carry Contion, item Contion) Contion//PIPL 管道type PIPL struct {C *PIPLContextEntry func() bool}//PipleCMapRet 管...
2020-03-30 21:26:13
394
原创 php-qconf扩展安装
下载qconf zip文件地址:https://github.com/Qihoo360/QConfcurl -o qconf.zip https://codeload.github.com/Qihoo360/QConf/zip/masterunzip qconf.zipcd 目录mkdir build && cd buildcmake ..make &&a...
2019-10-08 16:03:11
993
原创 dockerfile for php5.6.37-alpine基础包
FROM php:5.6.37-fpm-alpine3.7RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories \&& apk update \&& apk add --no-cache libldap openldap-dev libmcrypt-de...
2019-09-30 09:35:12
1622
原创 新公司使用window电脑搭建docker做-v参数是问题
在window中使用git bash here 做bash 环境开发安装docker 这个不用说了 直接下载window docker hub 即可安装docker pull mysql:5.7docker pull mysql:5.7docker run -p 3306:3306 --name mymysql -v $PWD/conf:/etc/mysql/conf.d -v $PWD/...
2019-09-26 19:17:54
2212
原创 mysql 统计连续为正数出现的次数
select * from static_log;select name,count(count_nu) from (select `name`,count_nu, case when count_nu >0 then (@c := @c + 1) end as zz, case when count_nu < 0 then (@b + @c) end as cc from st...
2019-09-20 21:30:03
575
原创 php 多纬度数组递归排列组合
PHP版本 多纬度数组递归排列组合function digui2pailie($array = [],$link=[]){ if(is_array($array)){ foreach($array as $key=>$item){ if(is_array($item)){ digui2pailie($item,...
2019-09-18 10:53:04
227
原创 python接口测试一
python 动态添加测试case静态函数-加setattr 函数添加动态函数 根据参数。import unittestclass TestFkMath(unittest.TestCase): bar = 1 def test_one(self): self.assertEqual(1,1) def action(self,arg1): ...
2019-08-30 18:26:33
109
原创 nginx: [emerg] bind() to 0.0.0.0:80 failed (13: Permission denied)
在启动openresty 的时候提示 没有权限操作命令su - openresty -c “启动命令”提示 绑定端口失败 为什么呢因为 在sockt 1024 一下的时候需要root 权限 可以sudo 执行启动命令 当然也可以修改监听端口 大于1024 ,在生产环境还是要 sudo 启动 毕竟80端口是默认的...
2019-08-14 17:20:16
1312
原创 card控制显示函数类
<?php/** * card 卡片显示控制 */class DisplayService{ const DISPLAY_NONE = 'none';#隐藏 const DISPLAY_BLOCK = 'block';#显示 private $pipe_rst = []; private $return; public function...
2019-08-09 15:20:26
433
原创 控制显示类过滤原型
/** */class DisplayService{ const DISPLAY_NONE = 'none';#隐藏 const DISPLAY_BLOCK = 'block';#显示 public function parseFilterPipe($filter) { if(empty($filter) || !($filter_arr ...
2019-08-09 13:29:49
130
原创 laravel 中间件原理分析
@中间件堆实现实例代码废话不多说上代码a=array(function(a = array(function(a=array(function(p,$next){echo 1;$p++;next(next(next(p); },function(p,p,p,next){echo 2;$p++;next(next(next(p); },function(p,p,p,next){...
2019-03-22 16:21:09
300
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人