技术备忘录
工作中乃至生活中解决了一些或大或小,或简单或复杂的技术问题。 很多都因为没有好好的记录,所以之后需要再解决一遍。 特地记录在此,以便后续使用。
2025-10-15 Spark的时区设置
在使用一些Spark SQL函数的时候,会需要准确的设置时区,否则执行的结果就会有误差。
比如以UTC时区执行如下SQL:
spark.sql("select from_unixtime(1760362193,'yyyy-MM-dd HH:mm:ss') as dt").show()会得到:
+-------------------+
| dt|
+-------------------+
|2025-10-13 13:29:53|
+-------------------+但是如果是东京时区,则是:
+-------------------+
| dt|
+-------------------+
|2025-10-13 22:29:53|
+-------------------+获取时区设置:
设置时区(以东京为例):
批量杀线程
MySQL
创建用户并且授权读写Schema
MongoDB 权限配置
管理员权限配置
用户配置样例
删除用户
MongoDB 慢查询相关
查找当前大于10.0秒的、且最慢的一个查询的详情
统计大于10秒的慢查数量
一般统计大于5秒,15秒,30秒,60秒,300秒的慢查数量。
查询Running总时间
这个指标可以从侧面反应数据库的操作体验和压力。
杀死超时任务
Python Tricks
Lazy Evaluation
From the blog Python 延迟初始化(lazy property)
Comparing with the lazy, it more like cache the result, maybe can also simply replaced by lru_cache. We have to ensure the return value won't change while using it.
Example of Async wait
FFMPEG
Convert MP4 File to MP3 File
Replace -ab {bitrate} to -ac 2 -qscale:a 4 to use VBR
Convert to H264 mp4 file
Merge subtitle (srt) file and video
树莓派
RPI3 Ubuntu 摄像头
只能使用32位的系统
在
/boot/firmware/config.txt里增加start_x=1执行
sudo snap install picamera-streaming-demo以后重启系统打开 http://:8000/ 即可查看
参考资料:
RPI3 Wifi
Edit
/etc/netplan/xxxxxx.yaml:
Reference: How to setup the Raspberry Pi 3 onboard WiFi for Ubuntu Server 18.04 with netplan?
Encryption
SAML2 key/pem generator
K8S
创建一个管理员账户的配置文件
首先创建一个Service Account
获取账户详情 kubectl describe serviceaccount <Account Name>
随后获取secret的名字,格式一般是 <Account Name>-token-<随机字符串>
最后获取Token:
Java/Scala/Kotlin
Maven Settings
Mainly ~/.m2/settings.xml.
Glances
屏蔽多余的设备
在使用snap的时候经常会有一些奇怪的设备,包括loop{x}或者是/snap/之类的,这个时候只要在配置文件里加上
就可以屏蔽这些设备。
官方文档:
https://glances.readthedocs.io/en/latest/aoa/diskio.html
https://glances.readthedocs.io/en/latest/aoa/fs.html
配置文件的位置 https://glances.readthedocs.io/en/latest/config.html
Git
自动使用SSH代替HTTP
来源:https://www.digitalocean.com/community/tutorials/how-to-use-a-private-go-module-in-your-own-project
在~/.gitconfig加入这一段:
不仅可以用于导入私有的Go模块,还可以用于Brew安装的时候自动拉取Repo。
最后更新于
这有帮助吗?