1.Cassandra介绍
Apache Cassandra是最流行的分布式宽表数据库,具有SQL的入口,最初由Facebook开发,后续贡献给Apache。参考:认识Cassandra
当我们开发的系统想要使用第三方账号系统(比如微信,微博,facebook)进行登录的时候,就需要使用第三方平台的登录能力,下面是各第三方平台的对接文档
关于oauth和oauth2.0:理解OAuth 2.0
https://developers.weixin.qq.com/doc/oplatform/Website_App/WeChat_Login/Wechat_Login.html
https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/login.html
web端
app移动端,可以使用refresh token
https://open.weibo.com/wiki/%E6%8E%88%E6%9D%83%E6%9C%BA%E5%88%B6
https://openhome.bilibili.com/doc/4/eaf0e2b5-bde9-b9a0-9be1-019bb455701c
在使用Goland开发go项目的时候,突然有一次遇到有些包下面的类无法被引用的情况,排查下来发现是这些包下面的config.go文件无法被正常识别成go代码文件
从而导致下面无法引用其他包中的所有config.go文件中的类
kratos无法正常引用
gorm的gen无法正常引用
解决方法是去File Type下面的File type auto-detected by file content下面将config.go配置删除,就可以解决这个问题
1 | func main() { |
配置arg
输出
1 | Hello World |
注意arg[0]是go程序的运行目录
golang内置的标准库flag,可以用来读取配置文件的路径
1 | func main() { |
配置
输出
1 | ./configs |
如果找不到-conf配置的话,才会输出 ./
1 | go get github.com/BurntSushi/toml@latest |
参考:https://github.com/BurntSushi/toml
config.toml配置
1 | Age = 25 |
读取配置
1 | type Config struct { |
输出
1 | {25 [Cauchy Plato] 3.14 [6 28 496 8128] 1987-07-05 05:45:00 +0000 UTC} |
1 | go get github.com/koding/multiconfig |
参考:https://github.com/koding/multiconfig
读取配置
1 | func main() { |
输出
1 | &{Age:25 Cats:[Cauchy Plato] Pi:3.14 Perfection:[6 28 496 8128] DOB:1987-07-05 05:45:00 +0000 UTC} |
安装viper
1 | go get github.com/spf13/viper |
在config目录下添加viper.go文件
1 | package config |
配置文件
1 | db: |
读取配置
1 | func main() { |
官方镜像仓库selenium/standalone-chrome,只支持amd64
拉取镜像
1 | docker pull selenium/standalone-chrome:120.0 |
启动
1 | docker run -d -p 4444:4444 -p 15900:5900 selenium/standalone-chrome:120.0 |
其他参数
1 | docker run -d -p 4444:4444 -p 15900:5900 -e SE_NODE_MAX_SESSIONS=5 --shm-size=2g selenium/standalone-chrome:120.0 |
参考:https://hub.docker.com/r/selenium/standalone-chrome
访问 localhost:4444/ui 可以查看selenium的运行状态
可以使用mac自带的屏幕共享功能连接pod的vnc
输入 vnc://localhost:15900,默认密码是secret
界面
ubuntu/debian换源
1 | sudo -s |
安装pip3
1 | apt-get install python3-pip |
安装selenium和webdriver-manager
1 | pip3 install selenium |
查看chrome和driver version
1 | root@ced974ac3394:/# google-chrome --version |
1.不启用chrome gui
1 | root@ced974ac3394:/# python3 |
参考:https://github.com/password123456/setup-selenium-with-chrome-driver-on-ubuntu_debian
2.启用chrome gui
1 | root@fce0fc2def31:/# python3 |
此时vnc界面会弹出浏览器
1 | >>> driver.get("https://python.org") |
打开了python的网页
如果语言cloudflare的人机校验,可以尝试使用 undetected_chromedriver 这个包来代替selenium的webdriver
安装 undetected_chromedriver
1 | pip3 install undetected_chromedriver |
替换seleniuim的web driver
1 | import undetected_chromedriver as uc |
参考:https://github.com/ultrafunkamsterdam/undetected-chromedriver
由于selenium/standalone-chrome镜像只支持amd64架构,如果是M1芯片的话,需要使用支持arm64架构的镜像 seleniarm/standalone-chromium
拉取镜像
1 | docker pull seleniarm/standalone-chromium:120.0 |
启动,需要指定运行平台是linux/arm64
1 | docker run -d -p 4444:4444 -p 15900:5900 -e SE_NODE_MAX_SESSIONS=5 --shm-size=2g --platform linux/arm64 selenium/standalone-chrome:120.0 |
运行selenium
seleniarm/standalone-chromium镜像中的浏览器是chromium,和chrome浏览器一些区别,需要指定webdriver的路径为/usr/bin/chromedriver
1 | root@fce0fc2def31:/# python3 |
如果使用m1芯片想 undetected_chromedriver 来绕过cloudflare的人机校验的话
1 | import undetected_chromedriver as uc |
默认的下载路径在/root/Downloads
yaml配置
1 | port: 7890 |
如果使用yt-dlp音源需要额外安装
拔掉USB线, 重新连上HDMI, 加电, 系统开机就是新的安卓系统了
使用的系统是20180123-S905L-R3300L-V12C-root-qlzy
参考:R3300L运行CoreELEC, EmuELEC和Armbia
双系统不用把armbian系统刷进emmc,需要在安卓系统中安装Reboot to LibreELEC的apk来启动TF卡系统,装上TF卡就自动进行armbian系统
参考:魔百盒R3300L、CM101H以及中兴ZX10 B860AV1.2刷armbian跑甜糖
使用的系统版本是Armbian_20.10_Arm-64_buster_current_5.9.0.img
1 | cp /etc/apt/sources.list /etc/apt/sources.list.bak |
换成清华源
1 | deb https://mirrors.tuna.tsinghua.edu.cn/debian buster main contrib non-free |
然后
1 | apt-get update |
如果遇到NO_PUBKEY的报错
1 | Err:4 https://mirrors.tuna.tsinghua.edu.cn/debian buster-backports InRelease |
执行下面命令
1 | sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys XXXXXXX |
1 | armbian-config |
1 | root@arm-64:~# docker -v |
假设armbian的ip是192.168.0.xx
创建network
1 | docker network create -d macvlan --subnet=192.168.0.0/24 --gateway=192.168.0.1 -o parent=eth0 macnet |
启动pod,其中192.168.0.11是openwrt后面会使用的ip
1 | docker run \ |
打开网卡混杂模式
1 | sudo ip link set eth0 promisc on |
将pod中/etc/config/network的192.168.0.1或者修改成192.168.0.11
1 | docker exec unifreq-openwrt-aarch64 sed -e "s/192.168.0.1/192.168.0.11/" -i /etc/config/network |
重启pod
1 | docker restart unifreq-openwrt-aarch64 |
参考:M401a系列:armbian下docker安装openwrt做旁路由
登录192.168.0.11访问openwrt的管理页面,注意是http的浏览器访问的时候需要接受风险,默认账号密码是root和password
这时候openwrt需要进行一些设置
网络 => 接口 => LAN => DHCP 服务器 => 基本设置
操作: 勾选忽略此接口
网络 => 接口 => LAN => DHCP 服务器 => IPv6 设置
操作: 禁用 路由通告服务
, DHCPv6 服务
, NDP 代理
网络 => 接口 => LAN => 一般设置 => 基本设置
操作:
IPv4 网关
改为 192.168.0.1
IPv4 广播
改为 192.168.0.255
使用自定义的 DNS 服务器
改为 114.114.114.114
这时候pod中就可以访问外网了
其中192.168.0.116是armbian机器的ip,192.168.0.11是openwrt的ip
1 | root@arm-64:~# ip addr add 192.168.0.116 dev mynet |
参考:N1 通过 Docker 安装 Openwrt 为旁路由
注意需要把软路由接到主路器上
如果不想修改主路由的DNS地址,那么可以通过修改手机的路由器地址到openwrt的ip地址+修改DNS地址到openwrt的ip地址的方式
参考:软路由(operwrt)通过ss Plus+ kx上网教程
当我们开发的系统想要使用第三方账号系统(比如微信,微博,facebook)进行登录的时候,就需要使用第三方平台的登录能力,下面是各第三方平台的对接文档
关于oauth和oauth2.0:理解OAuth 2.0
https://developers.weixin.qq.com/doc/oplatform/Website_App/WeChat_Login/Wechat_Login.html
https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/login.html
web端
app移动端,可以使用refresh token
https://open.weibo.com/wiki/%E6%8E%88%E6%9D%83%E6%9C%BA%E5%88%B6
https://openhome.bilibili.com/doc/4/eaf0e2b5-bde9-b9a0-9be1-019bb455701c
多表连接查询
1 | # 返回的是两张表的乘积 |