Python’s asyncio
library, along with the async
and await
keywords, has brought powerful concurrency capabilities to the language. It allows developers to write highly scalable I/O-bound applications. However, the asynchronous paradigm introduces new challenges and potential pitfalls that can trip up even experienced developers. This article highlights some of the most common traps and how to avoid them.
Practical Type Hinting in Python with MyPy
Python has always been a dynamically typed language, which is a key part of its flexibility and ease of use. However, for large and complex codebases, the lack of static type checking can lead to bugs that are hard to find. Since PEP 484, Python has official support for type hints, and tools like MyPy allow us to bring the benefits of static type checking to our Python projects.
Node.js Error Handling: A Practical Guide to Robust Applications
Building a robust Node.js application requires more than just writing functional code; it demands a solid error handling strategy. Unhandled errors can crash your server, leading to downtime and a poor user experience. This guide covers the essential patterns and best practices for handling errors effectively in your Node.js projects.
Getting Started with FastAPI for High-Performance APIs
When it comes to building APIs in Python, frameworks like Flask and Django have long been the go-to choices. However, a newer framework has rapidly gained popularity for its incredible performance and developer-friendly features: FastAPI. Built on top of Starlette and Pydantic, FastAPI makes it easy to create modern, fast, and well-documented APIs.
Mastering Python Virtual Environments: From venv to pip-tools
In the world of Python development, managing dependencies and project-specific environments is a foundational skill. It ensures that your projects are isolated, reproducible, and free from conflicts. For years, the standard has been venv
combined with a requirements.txt
file. In this post, we’ll revisit this classic approach and then explore how pip-tools
can significantly improve the workflow.
gpg unusable key
fix gpg unusable key
when we import gpg keys from backup, and try to use it for decript/encript, it will tell that the key is not usable,
we need to trust the keys first
use gpg --list-keys
to list all keys
the output would like this
1 | pub 2048R/B660885G 2013-05-16 [expires: 2030-12-31] |
we can get the keys id here B660885G
and then gpg>trust
If you’re sure about the authenticity of your key, select the trust level 5.
setup sftp account and two differences authentication logins
sftp is a way to use ftp on a linux server. it use the ssh account to connect the server, we can setup the sftp account and provide differences authentication
create sftp account without shell permission
1 | sudo adduser --shell /bin/false sftpuser |
then set the password for the user
1 | sudo passwd sftpuser |
create sftp directory for the user, and give the permission
/var/sftp/files here
1 | sudo mkdir -p /var/sftp/files |
create public key
we need to create the files in the user’s home directory, and generate the authentication keys
1 | mkdir /home/sftpuser/.ssh |
generate keys by ssh-keygen -t rsa
and point the file location to /home/sftpuser/.ssh/id_rsa
set authorized keys and permission
1 | cd .ssh |
save the generate private key to your compucter and give 600 permission
1 | cat /home/sftp/.ssh/id_rsa > sftp.pem |
update sftp user config to enable password and public key authentication
edit file at /etc/ssh/sshd_config, append below lines
1 | Match User sftpuser |
set PasswordAuthentication to yes to enable password authentication,
set PubkeyAuthentication to yes to enable public key authentication,
and then restart sshd servicessudo service sshd restart
test sftp connection by command line
password authentication
1 | sftp sftpuser@<server_host> |
public key authentication
1 | sftp -i sftp.pem sftpuser@<server_host> |
一个简单的漫画下载脚本
最近看暗杀教室实在是太麻烦了。手机app不更新 贴吧只有最新一话 网页在线看广告多得要死
简单的写了下 只针对暗杀教室这个漫画 不过其他漫画理论上也是可以的
地址在 https://github.com/ezioruan/Ansatsu-Kyoushitsu
解决xcode升级vim插件无法使用问题
xcode经常升级,升级以后以前的插件都不能用了 其实是因为xcode升级以后产品id变掉了
这个确实坑爹 都没有做自动适配的
一行代码搞定冲突
1 | find ~/Library/Application\ Support/Developer/Shared/Xcode/Plug-ins -name Info.plist -maxdepth 3 | xargs -I{} defaults write {} DVTPlugInCompatibilityUUIDs -array-add `defaults read /Applications/Xcode.app/Contents/Info.plist DVTPlugInCompatibilityUUID` |