Canoe

Try to leave where you have been , No body was there to tell you it'll be a long way.


  • Home

  • Archives

  • Tags

  • c24's

  • Search

SSH Port Mapping

Posted on 2021-02-04 => 00:28:34
| Words count in article: 742

Scene

    • 正常来说在服务器部署了一个服务,要访问该服务得用该云服务器 ip + 端口
    • 然后去云服务器商设置开放端口,最后才能访问
    • 但是,我们只是想随手用一下而已,又懒得去开放端口
    • 这种时候可以用 SSH 端口映射

    • 我们想从公网去访问局域网内部的服务
    • 也可以利用 SSH 端口映射 把 云服务器的请求转发到 局域网内部设备里

    • 不同子网之间的访问
    • 内网穿透原理应该也是差不多
Read more »

Bitwarden On Docker

Posted on 2021-02-02 => 23:32:12
| Words count in article: 144

Docker

1
2
3
4
5
6
yum install docker
# ------
su root
systemctl enable docker
systemctl start docker
systemctl restart docker

Portainer

1
2
3
sudo docker pull portainer/portainer
sudo docker volume create portainer_data
sudo docker run -d -p 9000:9000 --name portainer --restart always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer

Bitwarden

1
2
docker pull bitwardenrs/server:latest
docker run -d --name bitwarden -v /var/run/bitwarden/:/data/ -p 80:9001 bitwardenrs/server:latest
Read more »

Python Dependency Separation

Posted on 2021-01-31 => 04:53:29
| Words count in article: 462

Scene

  • 由于每个项目之间的引入的依赖版本不同,并且有的依赖库还难以获取
  • 因此在开发时,需要把依赖给保存下来,并且指明依赖的版本

Solution

freeze

  • pip freeze > requirements.txt
  • 使用这个命令可以导出当前环境的所有依赖

pipreqs

  • pip install pipreqs
  • pipreqs ./ 切换到项目根目录下执行,导出当前目录所引用的依赖
  • pipreqs ./ --encoding==utf-8
  • pipreqs ./ --encoding==utf-8 --force

venv

  • 使用 python 的虚拟环境
    Read more »

Django Run

Posted on 2021-01-28 => 20:03:52
| Words count in article: 105

Other

Error: [WinError 10013] 以一种访问权限不允许的方式做了一个访问套接字的尝试。

1
2
3
Starting development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
Error: [WinError 10013] 以一种访问权限不允许的方式做了一个访问套接字的尝试。
  • 端口被占用,关闭被占用端口的程序
  • netstat -ano|findstr 8000
  • tasklist | findstr pid号
  • taskkill /pid pid号 /f

  • 或者改端口

Python get function from String

Posted on 2021-01-25 => 02:02:46
| Words count in article: 298

从变量中获取对象的函数并执行

  • 单纯的执行方法可以用 eval()、locals()、globals()

    1
    2
    3
    eval(func)() # func 为变量值
    locals()[func]()
    globals()[func]()
  • 而从对象中执行方法用 __getattribute__

    1
    chrome.__getattribute__(itemParser) # 对象.__getattribute__(变量值)
Read more »

MySQL Split String By Procedure

Posted on 2021-01-21 => 00:17:23
| Words count in article: 490

Scene

  • 有这样一个场景,需要把一个表中的某个字段内的字符串分割成列
roleCode users
4dc51344e6674c03ae0a176d3d0ae14e_20865 xb,guojinyu,jiangyuan,ly_bmcc,wwm,lck,wusuihua
4dc51344e6674c03ae0a176d3d0ae14e_20866 zlj,mashaomeng
4dc51344e6674c03ae0a176d3d0ae14e_20867 tianye2
4dc51344e6674c03ae0a176d3d0ae14e_20869 wangyinju,liu_yan
  • 就是把上面的表格拆分成下面的样子
roleCode users
4dc51344e6674c03ae0a176d3d0ae14e_20865 xb
4dc51344e6674c03ae0a176d3d0ae14e_20865 guojinyu
4dc51344e6674c03ae0a176d3d0ae14e_20865 jiangyuan
4dc51344e6674c03ae0a176d3d0ae14e_20865 ly_bmcc
4dc51344e6674c03ae0a176d3d0ae14e_20865 wwm
4dc51344e6674c03ae0a176d3d0ae14e_20865 lck
4dc51344e6674c03ae0a176d3d0ae14e_20865 wusuihua
4dc51344e6674c03ae0a176d3d0ae14e_20866 zlj
4dc51344e6674c03ae0a176d3d0ae14e_20866 mashaomeng
4dc51344e6674c03ae0a176d3d0ae14e_20867 tianye2
4dc51344e6674c03ae0a176d3d0ae14e_20869 wangyinju
4dc51344e6674c03ae0a176d3d0ae14e_20869 liu_yan
Read more »

MySQL Sync to Mariadb

Posted on 2021-01-20 => 20:43:04
| Words count in article: 144

Unkown collation:’utf8mb4_0900_ai_ci’

  • 把 MySQL 数据同步到 Mariadb 出现排序规则不一致
  • MySQL 数据库默认字符集和排序规则
  • MySQL 转储的 SQL 文件默认DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
  • Mariadb 数据库默认字符集和排序规则
  • Mariadb 转储的 SQL 文件默认DEFAULT CHARSET=utf8mb4;

Solution

  • 在 Mariadb 中排序规则没有 utf8mb4_0900_ai_ci
  • 解决方法是 :转储 MySQL 数据,然后把 SQL 文件里的 COLLATE=utf8mb4_0900_ai_ci全部替换成 COLLATE=utf8mb4_general_ci 即可
    • 或者是把 SQL 文件里的 COLLATE=utf8mb4_0900_ai_ci 去掉
  • 总的来说就是把设置配成一致就可以了

Local-anywhere and CORS

Posted on 2021-01-20 => 01:36:34
| Words count in article: 96

Scene

  • 打开一个 html 加载了本地目录下的文件居然跨域了,原因在于本地文件的使用的是 file 协议
  • CORS 策略只支持这些协议:http、data、 chrome、chrome-extension 以及 https
  • 这样的话,可以直接转个协议就好了

Solution

  • 起个协议服务
  • npm i anywhere -g 安装 anywhere
  • anywhere -h 在文件目录启动服务

Reptiles and Raspberries

Posted on 2021-01-08 => 21:49:18
| Words count in article: 3.7k

分析接口数据结构

  • 找到数据的接口信息之后,请求获取数据并逐层分析数据结构
  • 然后提取需要的数据
  • 最后封装成方法
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    def get_tencent_virus_data():
    headers = {
    'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit'
    '/537.36 (KHTML, like Gecko) Chrome/53.0.2785.143 Safar'
    'i/537.36',
    }

    # https://news.qq.com/zt2020/page/feiyan.htm#/
    url = "https://view.inews.qq.com/g2/getOnsInfo?name=disease_h5"
    res = requests.get(url, headers=headers)
    res.encoding = "utf-8"
    getSource = json.loads(res.text)
    sourceData = json.loads(getSource["data"])

    lastUpdateTime = sourceData["lastUpdateTime"] # 最后更新时间
    chinaTotal = sourceData["chinaTotal"] # 总情况
    chinaAdd = sourceData["chinaAdd"] # 总确诊
    areaTree = sourceData["areaTree"] # 国家

    # 国家列表,中国
    name = areaTree[0]["name"] # 中国
    today = areaTree[0]["today"] # 今天新增确诊
    total = areaTree[0]["total"] # 今日总情况
    provinces = areaTree[0]["children"] # 34个省份

    # print(name)
    # print(today)
    # print(total)

    # 今日确诊,目前确诊,总确诊,总死亡数,总死亡概率,总康复数,总康复概率
    daily_data = [name, today["confirm"], total["nowConfirm"], total["confirm"], total["dead"], total["deadRate"],
    total["heal"], total["healRate"]]

    today_details = []
    for province in provinces:
    # print(province["name"]) # 省名
    # print(province["today"])
    # print(province["total"])
    province_name_ = province["name"]

    # 省所属城市
    for city in province["children"]:
    city_name_ = city["name"]
    city_today_confirm_ = city["today"]["confirm"] # 该城市今日确诊
    city_total_confirm_ = city["total"]["confirm"] # 该城市总确诊
    city_total_heal_ = city["total"]["heal"] # 该城市总康复
    city_total_heal_rate_ = city["total"]["healRate"] # 该城市总康复概率
    city_total_dead_ = city["total"]["dead"] # 该城市总死亡
    city_total_dead_rate_ = city["total"]["deadRate"] # 该城市总死亡概率
    today_details.append([lastUpdateTime, province_name_, city_name_, city_today_confirm_,
    city_total_confirm_, city_total_heal_, city_total_heal_rate_,
    city_total_dead_, city_total_dead_rate_
    ])

    return today_details, daily_data
Read more »

In Jupyter Notebook

Posted on 2020-12-30 => 22:29:11
| Words count in article: 341

Configure

  • pip install notebook
  • jupyter notebook 启动,工作空间是当前目录
  • jupyter notebook --generate-config 创建配置文件,指定工作空间的目录
  • c.NotebookApp.notebook_dir = r'F:\Code'打开配置文件找到这个配置并修改
    Read more »
1…456…9
0%
当前浏览器不支持canvas,请更换浏览器后再试
Orekiyuta

Orekiyuta

83 posts
68 tags
RSS
GitHub E-Mail
© 2024 Orekiyuta | Site words total count: 97.7k
京ICP备2021002172号-1