TDLib编译错误

今天编译TDLib,出现了以下错误: td/tdutils/td/utils/crypto.cpp:899:25: error: too few arguments to function ‘int EVP_MAC_init(EVP_MAC_CTX*, const unsigned char*, size_t, const OSSL_PARAM*)’ 899 | res = EVP_MAC_init(ctx); | ^ In file included from /home/soda/td/tdutils/td/utils/crypto.cpp:28: /usr/local/include/openssl/evp.h:1179:5: note: declared here 1179 | int EVP_MAC_init(EVP_MAC_CTX *ctx, const unsigned char *key, size_t keylen, | ^~~~~~~~~~~~ 应该是我安装的OpenSSL版本太新导致的(编译安装)。 搜索得到EVP_MAC_init的文档,里面提到: int EVP_MAC_init(EVP_MAC_CTX *ctx, const unsigned char *key, size_t keylen, const OSSL_PARAM params[]); If key is NULL, the key must be set via params either as part of this call or separately using EVP_MAC_CTX_set_params(). ...

May 2, 2021

一个项目的fix

最近研究知识图谱,看到了两篇知识图谱的文章[1][2],里面提到了一个项目,本人下载下来后,遇到了一些错误,在此把fix的过程分享一下。 先看README 第一步就是pyltp库安装不上,上网搜索得知,LTP库已经支持python了,只需要pip install ltp即可。 然后安装neo4j,选择对应的平台下载,解压后运行bin/neo4j console。此时终端显示: 2021-04-28 12:48:56.162+0000 INFO Starting... 2021-04-28 12:48:58.117+0000 INFO ======== Neo4j 4.1.8 ======== 2021-04-28 12:48:59.236+0000 INFO Performing postInitialization step for component 'security-users' with version 2 and status CURRENT 2021-04-28 12:48:59.236+0000 INFO Updating the initial password in component 'security-users' 2021-04-28 12:48:59.721+0000 INFO Bolt enabled on localhost:7687. 2021-04-28 12:49:00.579+0000 INFO Remote interface available at http://localhost:7474/ 2021-04-28 12:49:00.580+0000 INFO Started. 然后访问http://localhost:7474/,使用默认用户名neo4j密码neo4j登录,然后修改密码。填入config.py中。 然后执行python .\neo_db\creat_graph.py,出现ImportError,在IDE中发现这一行标灰没什么用 from py2neo import Graph, Node, Relationship,NodeSelector 删掉这一行就可以运行了。 由于把依赖从pyltp改为了ltp,涉及到的代码均要修改。首先是KGQA/ltp.py,修改后的代码如下。 # -*- coding: utf-8 -*- from ltp import LTP def cut_words(words): ltp = LTP() seg, hidden = ltp.seg([words]) pos = ltp.pos(hidden) return seg, pos def get_target_array(words): arr = [] seg, pos = cut_words(words) for k in zip(seg[0], pos[0]): if k[1] in ('nh', 'n'): arr.append(k[0]) return arr 其他均为一些小的修改,具体可以查看Git Repo。

April 28, 2021

tampermonkey验证码识别

首先安装tesseract。 参考: Installation tessdoc/Home 编译安装方法 参考:Compiling-GitInstallation 通过pip安装pytesseract 后台: #!/usr/bin/env python # ocr backend import asyncio import websockets import base64 from io import BytesIO from PIL import Image import pytesseract async def get_ocr(websocket, _): while True: # base64 encoded img file data = await websocket.recv() seq = 'base64,' pos = data.find(seq) + len(seq) x = base64.b64decode(data[pos:]) # img file img = Image.open(BytesIO(x)) # result a = pytesseract.image_to_string(img) out = a.strip().replace(" ", "") print(out) await websocket.send(out) start_server = websockets.serve(get_ocr, "127.0.0.1", 5678) asyncio.get_event_loop().run_until_complete(start_server) asyncio.get_event_loop().run_forever() 参考: ...

April 24, 2021

ctrl+z导致powershell中docker命令行意外退出

最近经常使用 pwsh(PowerShell Core)连接 docker 访问 PostgreSQL 数据库,当我编辑命令的时候,可以使用 Ctrl+左右方向键进行左右词间的跳转,或者使用 alt+backspace 进行以词为单位的删除。 I frequently use pwsh to access docker-based postgresql database recently. It supports Ctrl+left/right edit on the command line. Use alt+backspace can delete words. 然而,当我多删了一个词的时候,长时间使用文本编辑器的习惯使我按下了 ctrl+z,希望进行恢复。这时,意外发生了:docker 命令行退出,返回到了 pwsh prompt。 But, When I acceidently press more backspace, I want to use “ctrl+z” to recover. An incident happens: docker command exited! 我尝试进行了一些搜索: I tried some searches: ctrl+z terminate docker terminal suspend and recover in powershell docker windows “ctrl z” 得到了一些相关的内容: ...

November 19, 2020

psql常用命令

命令 Command 作用 Action \h [NAME] help on syntax of SQL commands, * for all commands \d[S+] list tables, views, and sequences \d[S+] NAME describe table, view, sequence, or index \l[+] [PATTERN] list databases \echo [-n] [STRING] write string to standard output (-n for no newline) \i FILE execute commands from file \cd [DIR] change the current working directory \c[onnect] connect to new database \conninfo display information about current connection \q quit psql

November 15, 2020