- 博客(32)
- 资源 (5)
- 收藏
- 关注
原创 Python:kafka基本操作
pykafkahttps://pypi.org/project/pykafka/http://github.com/Parsely/pykafka/https://pykafka.readthedocs.io/kafka-pythonhttps://pypi.org/project/kafka-python/https://github.com/dpkp/kafka-pythonhttp://kafka-python.readthedocs.io/
2021-03-29 09:55:56 947
原创 Python:Redis发布订阅模式
发布消息# -*- coding: utf-8 -*-import redisredis_con = redis.Redis(host='127.0.0.1')redis_con.publish(channel='test', message='hi-1')订阅消息# -*- coding: utf-8 -*-import redisredis_con = redis.Redis(host='127.0.0.1')pubsub = redis_con.pubsub()pu
2021-03-26 11:59:57 1144
原创 Python:使用itsdangerous生成jwt签名
文档:https://github.com/pallets/itsdangerous安装pip install itsdangerous示例# -*- coding: utf-8 -*-from itsdangerous import TimedJSONWebSignatureSerializer# jwtauth_s = TimedJSONWebSignatureSerializer(secret_key="secret key", expires_in=6)token = auth
2021-03-24 17:37:30 1145
原创 笔记:JavaScript中的30个疑难杂症
JavaScript中的30个疑难杂症目录数据类型表达式运算符和分支结构内置对象JS DOMJS BOM函数对象面向对象typeof 和 instanceofJS数据类型:原始类型(基本类型)Undefined Null Boolean Number String引用类型(复杂类型)Object1、typeof检测返回对应数据类型console.log(typeof 123); // numberconsole.log(typeof true); // boolean
2021-03-23 22:49:25 2715 2
原创 Elasticsearch数组Array类型增加、删除
# 创建一条数据POST test_index/test_type/1{ "tags":["tag1", "tag2", "tag3"] }# 查看数据GET test_index/test_type/1# 给 _id=1 的tags增加一个 tag5POST test_index/test_type/1/_update{ "script" : { "source": "ctx._source.tags.add(params.tag)", "pa
2021-03-23 17:15:13 4762 2
原创 Python:Flask-ShortUrl短连接转换器
Flask-ShortUrl短连接转换器文档:https://github.com/lepture/flask-shorturl安装pip install Flask-ShortUrl代码示例# -*- coding: utf-8 -*-from flask import Flaskfrom flask_shorturl import ShortUrlapp = Flask(__name__)short = ShortUrl(app)# int转urlurl = short.
2021-03-23 15:18:23 1279
原创 Python:Flask-UUID 注册一个uuid的url转换器
Flask-UUID 注册一个uuid的url转换器文档:https://github.com/wbolster/flask-uuid安装pip install Flask-UUID代码示例# -*- coding: utf-8 -*-from uuid import UUIDfrom flask import Flaskfrom flask_uuid import FlaskUUIDapp = Flask(__name__)FlaskUUID(app)@app.route
2021-03-23 14:54:31 1365
原创 Python:Flask技术栈及Extensions扩展整理
扩展简介参考文章Flask-BasicAuth访问认证文章Flask-Cors跨域请求文章Flask-RestfulRestful接口文章Flask-WTF表单验证文章Flask-SQLAlchemy数据库扩展文章Flask-Migrate迁移数据库文章Flask-Mail发送邮件文章Flask-Cache缓存文章Flask-APScheduler管理定时任务文章livereload自动刷新页面...
2021-03-23 14:14:14 1508
原创 Python:多进程下实现单例
通过一个判断文件是否存在,判断实例是否存在# -*- coding: utf-8 -*-import atexitimport os@atexit.registerdef remove_lock_file(): if os.path.exists('file.lock'): os.remove('file.lock')def create_lock_file(): if not os.path.exists('file.lock'): w
2021-03-19 22:52:43 2325 1
原创 Python:标准库fcntl给打开的文件加锁
函数签名fcntl.flock(f.fileno(), operation) operation 的操作包括以下选项:变量名称简介fcntl.LOCK_EX排他锁其他进程没有读写访问权限fcntl.LOCK_SH共享锁所有进程都没有写权限(包括加锁进程),都有读权限fcntl.LOCK_NB非阻塞锁函数不能获得文件锁就立即返回,否则,等待获得文件锁fcntl.LOCK_UN解锁对加锁文件进行解锁LOCK_NB可以同LOCK_SH或LOCK
2021-03-19 22:43:54 1294 3
原创 Python:标准库atexit退出处理器
# -*- coding: utf-8 -*-import atexitdef close(): print('close')atexit.register(close)@atexit.registerdef close_file(): print('close_file')参考atexit — 退出处理器
2021-03-19 22:23:50 989
原创 Python:JS2PY执行js代码
Github: https://github.com/PiotrDabkowski/Js2Py安装pip install js2py示例# -*- coding: utf-8 -*-import js2pyjs2py.eval_js('console.log("Hi")')# 'Hi'add = js2py.eval_js('function add(a, b){return a + b}')print(add(1, 2))# 3
2021-03-18 18:30:02 1189 1
原创 vConsole:H5控制台调试工具
文档地址:(镜像): https://hub.fastgit.org/Tencent/vConsole/blob/dev/doc/tutorial_CN.md使用方式<script src="https://cdn.bootcss.com/vConsole/3.2.0/vconsole.min.js"></script><script>// init vConsolevar vConsole = new VConsole();console.log("H
2021-03-18 16:44:02 1116
原创 Mac Microsoft Updates Available-关闭Microsoft AutoUpdate弹框提示
方式一:终端修改其执行权限修改前是771cd /Library/Application\ Support/Microsoft/MAU2.0 && \sudo chmod 000 Microsoft\ AutoUpdate.app方式二:删除文件1、打开Finder2、前往文件夹 快捷键:command(⌘)+shift + G3、输入路径/Library/Application Support/Microsoft/4、打开文件夹MAU2.0 删除文件 Microsof
2021-03-18 16:07:30 1526
原创 Python/PHP/JS对象与json数据的转换key顺序问题
1、PHP关联数组与json数据转换前后key的顺序不变<?php// obj -> json$obj1 = [ 'name'=>'Tom', 'age'=> 23,];$obj2 = [ 'age'=> 23, 'name'=>'Tom',];print_r(json_encode($obj1));// {"name":"Tom","age":23}print_r(json_encode($obj2));
2021-03-17 17:08:06 1226
原创 github镜像加速方案整理
源地址https://raw.githubusercontent.com/mouday/gt-project/main/gt.sh加速地址https://raw.staticdn.net/mouday/gt-project/main/gt.shhttps://github3.mk-proxy.ml/-----https://raw.githubusercontent.com/mouday/gt-project/main/gt.shhttps://gh.api.99988866.xyz/https:
2021-03-16 18:07:34 3120
原创 Python:Hashids实现ID混淆
文档:https://hashids.org/Python实现: https://github.com/davidaurelio/hashids-python安装pip install hashids使用示例# -*- coding: utf-8 -*-from hashids import Hashidshashids = Hashids(salt='gu2kBqW38Zw=', min_length=8)# 编码trick_id = hashids.encode(119)pr
2021-03-16 18:06:21 926
原创 Cookiecutter通过项目模板创建项目
Cookiecutter是一个通过项目模板创建项目的命令行工具文档:https://cookiecutter.readthedocs.io/安装pip install cookiecutter使用示例$ cookiecutter https://github.com/candidtim/cookiecutter-flask-minimal.git参考Cookiecutter: 更好的项目模板工具:(1)简介及可用资源汇总Cookiecutter: 更好的项目模板工具:(2)安装及基础
2021-03-16 11:41:24 1179
原创 构建工具:Make和Makefile
Make:一个构建工具Makefile: 构建规则一个简单的例子功能是将b.txt 和 c.txt合并到新文件a.txt.├── Makefile # 构建规则├── b.txt└── c.txtMakefilea.txt: b.txt c.txt cat b.txt c.txt > a.txtb.txtb.txtc.txtc.txt执行$ makeMakefile格式<目标target> : <前置条件prerequisites&g
2021-03-16 11:04:43 1007
原创 Python:使用Flask-APScheduler管理定时任务
文档:https://github.com/viniciuschiele/flask-apscheduler安装pip install Flask-APScheduler示例from flask import Flaskfrom flask_apscheduler import APSchedulerclass Config(object): JOBS = [ { 'id': 'job1', 'func': '__m
2021-03-15 10:27:32 1972
原创 Python:Flask使用ThreadPoolExecutor执行异步任务
测试代码# -*- coding: utf-8 -*-import timefrom concurrent.futures import ThreadPoolExecutorfrom flask import Flask, requestexecutor = ThreadPoolExecutor()app = Flask(__name__)# 模拟耗时任务def run_job(name): time.sleep(5) print('run_job complet
2021-03-12 17:02:53 5155 4
原创 NodeJS:字符串和base64相互转换
nodejs不支持使用atob和btoa 进行字符串base64转换/** * string转为base64 */function stringToBase64(str) { return new Buffer.from(str).toString("base64");}/** * base64转字符串 */function base64ToString(b64) { return new Buffer.from(b64, "base64").toString();}示例
2021-03-11 18:20:48 3230
原创 笔记:Linux C语言编程基本原理与实践
C语言简介C语言的标准:ANSI CC语言的特点:简单快速高性能兼容性好功能强大易于学习C语言的应用:1、Linux嵌入式(小工具)(C语言小巧灵活、语法简单、适合做小工具)linux/unix系统就是由各种各样的小工具集成得来的。2、和硬件打交道的程序a、操作系统:苹果系统,安卓系统,windoowsb、ARM嵌入式、单片机、Arduino3、有高性能要求的应用程序著名的WEB服务器,NGINX=apache*10环境centos https://www.cent
2021-03-09 23:09:35 1689
原创 Python:pytest库进行代码测试
文档:https://docs.pytest.org/en/stable/安装pip install pytest测试文件 test_hello.py# -*- coding: utf-8 -*-import pytest# test_开头def test_hello(): print('hello')if __name__ == '__main__': # 命令行运行 $ pytest pytest.main(['-s', __file__])..
2021-03-09 11:29:10 1246 1
原创 Python:cator查询MySQL和SQLite数据库
现看一个直接使用mysql_connector_python查询数据库的示例from mysql.connector import Connectdb_config = { "database": "data", "username": "root", "password": "123456", "host": "127.0.0.1", "port": 3306, "charset": "utf8", "autocommit": True}
2021-03-05 17:24:11 964 1
原创 Python:number-parser解析数字字符串
文档:https://github.com/scrapinghub/number-parser安装pip install number-parserrequires Python 3.6+.# -*- coding: utf-8 -*-from number_parser import parse, parse_number, parse_ordinalprint(parse('two 3 三'))# 2 3 三print(parse_number('two'))# 2prin
2021-03-05 16:45:45 1201
原创 Python:price-parser解析价格字符串
文档:https://github.com/scrapinghub/price-parser安装pip install price-parserrequires Python 3.6+.# -*- coding: utf-8 -*-from price_parser import parse_priceprice = parse_price('23.1$')print(price)# Price(amount=Decimal('23.1'), currency='$')price
2021-03-05 16:37:08 1433
原创 Python:urllib解析查询参数parse_qsl、parse_qs
from urllib.parse import parse_qsl, parse_qsq = 'name=Tom&name=Jack&age=13&school=&home'print(parse_qsl(q))# [('name', 'Tom'), ('name', 'Jack'), ('age', '13')]print(parse_qs(q))# {'name': ['Tom', 'Jack'], 'age': ['13']}
2021-03-04 12:11:06 3878 1
原创 Linux:systemctl、service、chkconfig
systemctl 命令是系统服务管理器指令,它实际上将 service 和 chkconfig 这两个命令组合到一起。
2021-03-04 10:03:31 1099 1
原创 Python:jieba中文分词的使用笔记
文档:https://github.com/fxsjy/jieba安装pip install jieba分词cut/lcut(self, sentence, cut_all=False, HMM=True, use_paddle=False)# 参数:sentence 需要分词的字符串;cut_all 参数用来控制是否采用全模式;HMM 参数用来控制是否使用 HMM 模型;use_paddle 参数用来控制是否使用paddle模式下的分词模式切出了词典中没有
2021-03-02 18:31:41 1227
原创 Python:Peewee实践记录
文档:http://docs.peewee-orm.com/安装$ pip install peewee将已有数据表转为Model# 导出数据表为Model$ python -m pwiz -e mysql -H localhost -p 3306 -u root -P -o -i -t user data > user.py打印执行SQLimport logging# 打印日志logger = logging.getLogger('peewee')logger.addHa
2021-03-02 11:25:46 1355
原创 SQLite3命令行操作
SQLite3命令行操作# 启动$ sqlite3# 打开数据库>.open people.db# 格式化输出>.header on>.mode column>.timer on# 查看数据库文件>.database# 查看数据表 >.tablse# 查看表结构>.schema person# 查看数据>select * from person;参考https://www.runoob.com/sqlite
2021-03-02 11:02:32 1257
pyenv-2.3.90-full.tar.gz
2023-01-03
mybatis-generator-demo.zip
2020-07-26
CSS Tools: Reset CSS
2020-07-23
浏览器Header和cookie字符串形式转Json
2020-04-08
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人