西维蜀黍

【Network】反向 DNS 查询(Reverse DNS Lookup)

  ...


【Linux】信号(Signal)

信号(Signal)

Signals are a limited form of inter-process communication (IPC), typically used in Unix, Unix-like, and other POSIX-compliant operating systems. A signal is an asynchronous notification sent to a process or to a specific thread within the same process to notify it of an event. Signals originated in 1970s Bell Labs Unix and were later specified in the POSIX standard.

When a signal is sent, the operating system interrupts the target process’ normal flow of execution to deliver the signal. Execution can be interrupted during any non-atomic instruction. If the process has previously registered a signal handler, that routine is executed. Otherwise, the default signal handler is executed.

  ...


【Linux】命令 - cp

复制文件

# Copy a file to another location:
$ cp path/to/source_file.ext path/to/target_file.ext

# Copy a file into another directory, keeping the filename:
$ cp path/to/source_file.ext path/to/target_parent_directory
  ...


【IoT】Home Assistant 集成 Tuya(涂鸦) 设备

(depreciated) Install the old Tuya Home Assistant Integration

Adding Tuya to your Home Assistant instance can be done via the user interface, by taking the following steps:

After completing, the Tuya integration will be immediately available for use.

During configuration, be careful to select the country code and the platform corresponding to those used by you in the app. Once configuration flow is completed, the devices configured in your app will be automatically discovered.

Additionally, if your username or e-mail address isn’t accepted, please try using your phone number (minus the country code) as your username.

  ...


【IoT】安装 Home Assistant Core

Install on Raspberry Pi

# Install Software Properties Common
sudo apt install -y software-properties-common

# Add the Deadsnakes PPA
sudo add-apt-repository ppa:deadsnakes/ppa

sudo apt update; sudo apt install -y python3.12

# Update Python 3 to Point to the New Version
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.x 1
sudo update-alternatives --config python3

# verify
python3 --version

# homeassistant 2024.2.4 needs python3.12
sudo apt-get install python3.12-distutils
python3 -m pip install wheel
pip3 install homeassistant==2024.2.4

# 我出现了找不到该版本错误,2024.2.1 Requires-Python >=3.11.0
# 这时候需要升级 Python版本

ref

Install on Ubuntu

  ...


【NAS】DIY NAS

Background

RAID

  • RAID 0

    • File level writes, data duplicated on additional disks with no fault tolerance
  • RAID 1

    • Mirrored block level writes distributed across disks
  • RAID 5

    • 这个模式最少得3块以上的硬盘,属于RAID1 和 RAID0 之间,比如有4块硬盘组RIAD5,那么只会用一块硬盘进行保护,其它的空间可以叠加:
      • 空间大小:2+2+2+ 2 = 6T
    • 这个模式,可以最大的利用磁盘空间,也能保护磁盘,而且如果用SSD的话,硬盘速度也有叠加,不过缺点就是硬盘在损坏以后,换上新的硬盘后,重建数据的时间非常长,而重建过程中,如果再损坏一块硬盘,就全部玩完。
  • RAID 6

  • Block level writes distributed across disks, double distributed parity

  • RAID 10

  • 最多可以坏两个盘

    • RAID0和RAID1的结合,需要4个硬盘才行,先将2个硬盘进行RAID0,再将2个RAID0进行RAID1,可以保住数据安全的同时,提供硬盘速度。
  • RAID 6

    • 就是RAID5模式的加强版,用2个硬盘做冗余
  ...


【macOS】RTL8153 网卡驱动

查看 Type-C 网卡型号

  ...


【Design Pattern】Microservices - API Gateway / Backend for Frontend (BFF) Pattern

Context

Let’s imagine you are building an online store that uses the Microservice architecture pattern and that you are implementing the product details page. You need to develop multiple versions of the product details user interface:

  • HTML5/JavaScript-based UI for desktop and mobile browsers - HTML is generated by a server-side web application
  • Native Android and iPhone clients - these clients interact with the server via REST APIs

In addition, the online store must expose product details via a REST API for use by 3rd party applications.

A product details UI can display a lot of information about a product. For example, the Amazon.com details page for POJOs in Action displays:

  • Basic information about the book such as title, author, price, etc.
  • Your purchase history for the book
  • Availability
  • Buying options
  • Other items that are frequently bought with this book
  • Other items bought by customers who bought this book
  • Customer reviews
  • Sellers ranking

Since the online store uses the Microservice architecture pattern the product details data is spread over multiple services. For example,

  • Product Info Service - basic information about the product such as title, author
  • Pricing Service - product price
  • Order service - purchase history for product
  • Inventory service - product availability
  • Review service - customer reviews …

Consequently, the code that displays the product details needs to fetch information from all of these services.

  ...


【Engineering】Unix Philosophy

Unix philosophy

The Unix philosophy, originated by Ken Thompson, is a set of cultural norms and philosophical approaches to minimalist, modular software development. It is based on the experience of leading developers of the Unix operating system. Early Unix developers were important in bringing the concepts of modularity and reusability into software engineering practice, spawning a “software tools” movement. Over time, the leading developers of Unix (and programs that ran on it) established a set of cultural norms for developing software; these norms became as important and influential as the technology of Unix itself; this has been termed the “Unix philosophy.”

The Unix philosophy emphasizes building simple, short, clear, modular, and extensible code that can be easily maintained and repurposed by developers other than its creators. The Unix philosophy favors composability as opposed to monolithic design.

  ...


【Design Pattern】Microservices - Sidecar Pattern

Sidecar Pattern

Deploy components of an application into a separate process or container to provide isolation and encapsulation. This pattern can also enable applications to be composed of heterogeneous components and technologies.

This pattern is named Sidecar because it resembles a sidecar attached to a motorcycle. In the pattern, the sidecar is attached to a parent application and provides supporting features for the application. The sidecar also shares the same lifecycle as the parent application, being created and retired alongside the parent. The sidecar pattern is sometimes referred to as the sidekick pattern and is a decomposition pattern.

  ...