Posts

Showing posts from June, 2021

不要再用它来挖矿啦!

临时远程桌面环境?(不算是VPS) 更新日期:2021年6月22日 注意:请不要再用它来挖矿!!!! 注意:请不要再用它来挖矿!!!! 注意:请不要再用它来挖矿!!!! 且行且珍惜,不然就没有了,至于会不会封号目前还不知道。 Github Action GitHub Action 是 GitHub 于 2018 年 10 月推出的一个 CI\CD 服务,之前一直都是 Beta 版本,正式版于 2019 年 11 月正式推出。说白了就是你写了个自动化的脚本放到了Github的VM跑。 支持跑的操作系统 那么支持容器是什么操作系统呢? Virtual environment YAML workflow label Windows Server 2019 windows-latest or windows-2019 Windows Server 2016 windows-2016 Ubuntu 20.04 ubuntu-latest or ubuntu-20.04 Ubuntu 18.04 ubuntu-18.04 macOS Big Sur 11 macos-11 (仅供内部使用) macOS Catalina 10.15 macos-latest or macos-10.15 另外,VM支持了哪些软件可以参考 这篇文章 。 检查是否有管理员权限 那么问题来了,既然可以在他的VM上跑,VM会不会给管理员权限呢? name: DEMO on: workflow_dispatch jobs: build: runs-on: ubuntu-latest steps: - name: Run a whoami run: whoami - name: Run a ID run: id - name: Run a sudo run: sudo whoami 以下是 Ubuntu 的返回结果: > whoami > uid=1001(runner) gid=121(docker) groups=121(docker),4(adm),101(systemd-journ

SQLAlchemy 个人笔记

SQLAlchemy 个人笔记 by Mane, 修改日期:2021年6月18日 在开始之前 >>> import sqlalchemy >>> sqlalchemy.__version__ 检查版本号是否大于1.4 安装 mysqlclient 如果需要支援 Mysql 模块,就需要安装 mysqlclient sudo apt-get install libmysqlclient-dev python-dev pip3 install mysqlclient 依赖安装 pip3 install async-exit-stack async-generator Core VS ORM 传统比较底层的用法,缺点是很容易会有 SQL注入 和报错。 现代 Object 的写法,受到了 JDB or OOP 的启发,安全稳定,推荐使用。 Connect 和 Begin 的区别 提交数据的话,如果是 with engine.connect() as conn 则需要调用 Connection.commit() 才可以提交,但如果是 with engine.begin() as conn 那就不需要调用 Connection.commit() 就可以自动提交了 What’s “BEGIN (implicit)”? You might have noticed the log line “BEGIN (implicit)” at the start of a transaction block. “implicit” here means that SQLAlchemy did not actually send any command to the database; it just considers this to be the start of the DBAPI’s implicit transaction. You can register event hooks to intercept this event, for example. 参考官方文档 但是提交可以用 begin() ,查询就不可以用 begin() 了,因为没有和数据库连接也就不能够查询了。若要写入数

Fast API 个人笔记

Fast API 个人笔记 快速学习下近年现有的 Fast API 技术,仅供参考,By Mane。 更新日期:2021年6月17日 可选参数 使用 name: Optional[str] = None 指定 def say_hi(name: Optional[str] = None): if name is not None: print(f"Hey {name}!") else: print("Hello World") 路径函数 from fastapi import FastAPI app = FastAPI() @app.get("/items/{item_id}") async def read_item(item_id): return {"item_id": item_id} 如果是 item_id:int 就会自动变成了int类型 保存 Cookie / 读取 Cookie / 删除 Cookie from typing import Optional from fastapi import FastAPI from pydantic import BaseModel from starlette import responses # 一定要 import 这两个类 from fastapi import Cookie,Response app = FastAPI() @app.get("/mane/") # 这里要设置 Cookie(None) 不然就会被当作 输入参数 async def create_item(response:Response, testcookie:Optional[str] = Cookie(None)): # 设置 Cookie response.set_cookie("testcookie","acookie") # 获取 Cookie 要先声明 get_cookie = testcookie print(get_cookie)