antd2 vue 升级到 antd3 时 table 报错处理
Warning: [ant-design-vue: Table] column.slots is deprecated. Please use v-slot:headerCell v-slot:bodyCell instead.
and3 table 即将废除 slots 写法
antd3 table 新写法
elasticsearch启动不起来,错误码78解决办法
ProblemYou want to run ElasticSearch using docker, but the container immediately stops again using this error message
elasticsearch exited with code 78
or
elasticsearch2 exited with code 78
Solution:If you look through the entire log message, you’ll find lines like
elasticsearch | [1]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
解决:
切换到root用户
执行命令:
1sysctl -w vm.max_map_count=262144
查看结果:
1sysctl -a|grep vm.max_map_count
显示:
vm.max_map_cou ...
git修改/添加/删除远程仓库
修改远程仓库地址1git remote set-url origin <remote-url>
仓库路径查询查询1git remote -v
添加远程仓库1git remote add origin <你的项目地址> //注:项目地址形式为:https://gitee.com/xxx/xxx.git或者 git@gitee.com:xxx/xxx.git
删除指定的远程仓库1git remote rm origin
判断一个字典类型的数据结构中是否存在某个键(包括子层级的键)-python
123456789101112131415161718192021222324252627def key_exists(d, key): # 如果键在当前字典的第一层,直接返回 True if key in d: return True # 递归检查所有子字典 for value in d.values(): if isinstance(value, dict): if key_exists(value, key): return True # 如果在所有层级都没有找到键,返回 False return False# 示例data = { "level1": { "level2": { "target_key": "value" } }, "anoth ...
python 实现倒排索引,建立简单的搜索引擎
如下,一个数据表docu_set中有三篇文章的,d1,d2,d3,如下
12345docu_set = { 'd1': 'i love shanghai', 'd2': 'i am from shanghai now i study in tongji university', 'd3': 'i am from lanzhou now i study in lanzhou university of science and technolgy',}
下面用这张表做一个简单的搜索引擎,采用倒排索引首先对所有文档做分词,得到文章的词向量集合
123456all_words = []for i in docu_set.values(): cut = i.split() all_words.extend(cut)set_all_words = set(all_words)print(set_all_words)
首先对 ...
python-判断字符串是数字
123456789101112131415161718def is_number(s): if s is None: return False try: float(s) return True except ValueError: pass try: import unicodedata unicodedata.numeric(s) return True except (TypeError, ValueError): pass return False
进程&线程&协程
一个程序至少有一个进程,一个进程至少有一个线程。一个线程可以有唯一一个事件循环,一个事件循环可以创建多个协程。注意:协程是用户态的线程,线程是内核态的线程。
apisix~按域名进行请求转发
路由route路由(Route)是请求的入口点,它定义了客户端请求与服务之间的匹配规则。路由可以与服务(Service)、上游(Upstream)关联,一个服务可对应一组路由,一个路由可以对应一个上游对象(一组后端服务节点),因此,每个匹配到路由的请求将被网关代理到路由绑定的上游服务中。
如果前端调用后端接口时,前缀都是/kpi/index时,那apisix就不知道应该选择哪个路由了,这时,我们需要为路由添加域名,,这个域名就是requestheader中的host,即前端调用apisix-gateway时的域名,这个域名是需要解析到apisix-gateway的。
上游upstream上游列表包含了已创建的上游服务(即后端服务),可以对上游服务的多个目标节点进行负载均衡和健康检查。
上游中指定了你要转发到的后端服务,可以是具体的节点IP+端口,也可以通过服务发现来指定,如kubernetes,nacos,dns等
路由中按域名转发的必要性首先,这里的域名是指gateway的域名,一般是前端网站有个域名,然后它在调用后端服务时,会使用apisix-gateway ...
python异步连接redis
异步编程用官方模块asyncio实现注意导入的库是redis.asyncio。需要在连接、设置、获取等使用redis的地方可等待。
123456789101112131415161718192021import asyncio async def async_singal(): from redis.asyncio import StrictRedis ip = "172.17.0.8" redis_conn = await StrictRedis( host=ip, port=6379, encoding="utf8", decode_responses=True, db=0, ) await redis_conn.set("name", "async singal") res = await redis_conn.get("name") print(res)asy ...
StopIteration 异常标志着协程的结束
在 asyncio 事件循环中,StopIteration 异常并不直接参与协程的调度。相反,其他机制和异常在协程调度和任务管理中起到了关键作用。
协程的停止和StopIteration
当协程通过 await 表达式暂停时,它会生成一个等待的对象(通常是 Future 对象)。在协程执行完成后,它会通过引发 StopIteration异常来返回其结果。这与普通的生成器类似,当生成器完成时也会引发 StopIteration。
在 asyncio 中,当一个任务(Task)运行一个协程时,如果遇到 StopIteration异常,这表示协程已经完成执行,任务将从事件循环中移除,并将结果存储在任务对象中 (Stack Overflow)。
其他异常的处理
asyncio 事件循环在处理协程时会捕获并处理其他类型的异常。当协程在 await 表达式或其他代码中引发异常时,这些异常会被传播回到调用者,或传递给asyncio 的异常处理机制 (Stack Overflow)。
调度机制
当协程遇到 await表达式时,它会暂停执行,并将控制权返回给事件循环。事件循环会管理这些暂停的任务,等 ...