0%

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.

Read more »

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.

Read more »

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.

Read more »

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.

Read more »

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.

Read more »

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
2
pub   2048R/B660885G 2013-05-16 [expires: 2030-12-31]
uid [] SAP Admin <xxx@xx.com>

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.

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
2
3
4
5
6
sudo mkdir -p /var/sftp/files
sudo chown sftpuser:sftpuser /var/sftp/files

sudo chown root:root /var/sftp
sudo chmod 755 /var/sftp

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
2
3
4
5
6
cd .ssh
touch authorized_keys
cat id_rsa.pub >> authorized_keys
cd ..
chmod 700 .ssh
chmod 600 .ssh/authorized_keys

save the generate private key to your compucter and give 600 permission

1
2
cat /home/sftp/.ssh/id_rsa > sftp.pem
chmod 600 sftp.pem

update sftp user config to enable password and public key authentication

edit file at /etc/ssh/sshd_config, append below lines

1
2
3
4
5
6
7
8
9
10
11
Match User sftpuser
ForceCommand internal-sftp
PasswordAuthentication yes
ChrootDirectory /var/sftp
PermitTunnel no
AllowAgentForwarding no
AllowTcpForwarding no
X11Forwarding no
RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile /home/sftpuser/.ssh/authorized_keys

set PasswordAuthentication to yes to enable password authentication,
set PubkeyAuthentication to yes to enable public key authentication,

and then restart sshd services
sudo 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>

xcode经常升级,升级以后以前的插件都不能用了 其实是因为xcode升级以后产品id变掉了
这个确实坑爹 都没有做自动适配的

一行代码搞定冲突

1
2
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`