0x822a5b87的博客

到码头整点薯条吃

综述

本文是在学习python的过程中的一个简单的练手小项目,用于熟悉python内部的一些机制,全部的代码位于 tiny package manager

整体的逻辑是,当我们在编译一个 yarn 项目的过程中,我们会存在一个 package.json 文件,在文件中我们会声明项目的所有依赖。我们通过该依赖文件来进行一个包依赖分析,判断是否项目是否存在版本冲突,如果可以编译,则给出选择对应的版本。

例如:

---
title: dependencies
---
flowchart LR

jest("jest"):::pink

jest2("0.0.61"):::green
jest1("0.0.71"):::green

express-resource("express-resource-*"):::purple
underscore("underscore-*"):::purple
sji("sji-*"):::purple


express("express-*"):::purple
api-easy("api-easy-*"):::purple
mongoose("mongoose-*"):::purple

indirect01("indirect dependency ..."):::animate

jest --> jest1
jest --> jest2

jest1 --> express-resource --> indirect01
jest1 --> underscore --> indirect01
jest1 --> sji --> indirect01

jest2 --> express --> indirect01
jest2 --> api-easy --> indirect01
jest2 --> mongoose --> indirect01
jest2 --> express-resource

classDef pink 1,fill:#FFCCCC,stroke:#333, color: #fff, font-weight:bold;
classDef green fill: #696,color: #fff,font-weight: bold;
classDef purple fill:#969,stroke:#333, font-weight: bold;
classDef error fill:#bbf,stroke:#f66,stroke-width:2px,color:#fff,stroke-dasharray: 5 5
classDef coral fill:#f9f,stroke:#333,stroke-width:4px;
classDef animate stroke-dasharray: 9,5,stroke-dashoffset: 900,animation: dash 25s linear infinite;
阅读全文 »

插件逻辑

dify 的插件管理中,整个体系逻辑比较混乱,这里使用该文本记录一下 dify 的插件管理逻辑。

插件概述

一个插件以及插件对应的工具的组成部分如下图所示:

---
title: 插件
---
flowchart LR

plugin_id("plugin_id"):::green
organization1("organization"):::animate
plugin_name1("plugin_name"):::animate
slash1("/"):::error

plugin_id --> organization1 --> slash1 --> plugin_name1


plugin_unique_identifier("plugin_unique_identifier"):::green

organization2("organization"):::animate
slash2("/"):::error
symbol2(":"):::error
at2("@"):::error
plugin_name2("plugin_name"):::animate
version1("version"):::animate
checksum1("checksum"):::animate

plugin_unique_identifier --> organization2 --> slash2 --> plugin_name2 --> symbol2 --> version1 --> at2 --> checksum1

provider("full_provider"):::green

organization3("organization"):::animate
slash3_1("/"):::error
plugin_name3("plugin_name"):::animate
slash3_2("/"):::error
provider_name3("provider"):::animate

provider --> organization3 --> slash3_1 --> plugin_name3 --> slash3_2 --> provider_name3

classDef pink 1,fill:#FFCCCC,stroke:#333, color: #fff, font-weight:bold;
classDef green fill: #696,color: #fff,font-weight: bold;
classDef purple fill:#969,stroke:#333, font-weight: bold;
classDef error fill:#bbf,stroke:#f66,stroke-width:2px,color:#fff,stroke-dasharray: 5 5
classDef coral fill:#f9f,stroke:#333,stroke-width:4px;
classDef animate stroke-dasharray: 9,5,stroke-dashoffset: 900,animation: dash 25s linear infinite;
阅读全文 »

Conclusion of Linear Algebra For Everyone

REFERENCES

Glossary of Terms

terms descprition
Matrix A rectangular array of numbers, symbols, or expressions arranged in rows and columns.
Vector An ordered set of numbers, often represented as a column or row matrix.
Scalar A single number, as opposed to a vector or matrix.
Transpose A matrix operation that flips a matrix over its .
Determinant A scalar value that can be computed from a square matrix
Eigenvector A non-zero vector that only changes by a scalar factor when a linear transformation is applied to it.
Eigenvalue The scalar factor by which an eigenvector is scaled during a linear transformation.
Rank The dimension of the column space or row space of a matrix.
Dot Product The scalar product of two vectors, obtained by multiplying the corresponding components and summing the results.
Cross Product The vector product of two vectors in three-dimensional space, resulting in a vector that is to the original vectors
Orthogonal Two vectors are orthogonal if their dot product is zero
space Represents a collection of vectors with certain properties
Vector Space A vector space is a set of vectors along with operations of vector addition and scalar multiplication that satisfy certain properties.
Subspace A subspace is a subset of a vector space that is itself a vector space. It contains the zero vector, is closed under vector addition and scalar multiplication, and satisfies the other properties of a vector space.
Inner product space An inner product space is a vector space equipped with an inner product, which is a generalization of the dot product. The inner product defines a notion of angle and length in the space.
Normed Vector Space A normed vector space is a vector space equipped with a norm, which is a function that assigns a non-negative length to each vector and satisfies certain properties.
Hilbert Space A Hilbert space is a complete inner product space, meaning that it is a vector space equipped with an inner product that is also a complete metric space with respect to the norm induced by the inner product.
Upper Triangular Matrix A Upper Triangular Matrix is a matrix in which all the elements below the main diagonal are zero, and all the elements on or above the main diagonal can be zero or non-zero.
Lower Triangular Matrix A Lower Triangular Matrix is a matrix in which all the elements above the main diagonal (the diagonal from the top left to the bottom right) are zero, and all the elements on or below the main diagonal can be zero or non-zero.
Orthogonal Matrix
CR C stands for Column, R stands for Row
LU Lower tirangular and Upper triangular
QR QR decomposition as Gram-Schmidt orthogonalization Orthogonal Q and triangular R
阅读全文 »

BOX-256

前言

最近在学习 RISC-V,但是指令太多,并且学习起来确实很无聊,所以找到了这个小游戏来学习一下汇编的思路。虽然不是真正的标准 RISC-V,但是可以作为学习路上的一个参考工具,下面是 BOX-256 的一些描述:

BOX-256 is a 8-bit fantasy computer, with 256 bytes of memory, 16 color 16x16 display. It is also a programming game, where the player tries to pass the graphics tests and optimize the code to perfection. The ultimate goal is to use as few CPU cycles or lines of code as possible, by employing multithreading and other optimization tricks.

此外,文档里提到了一些比较重要的细节这里也稍微列举一下:

阅读全文 »

game-log-sdk-go

经过两年多的测试,新版本的腾讯游戏日志服务(TencentGameLog,简称TGLog)的go语言版本SDK game-log-sdk-go 正式开源了,本服务支撑了腾讯互娱内部的PB级日志上报,支持了TCP/UDP日志上报,具体可以参考我们的文档。

最近因为开了两个 操作系统linkers 的新坑,一直在学习硬件和汇编相关的知识,所以这里找了一个简单的小游戏 MHRD(Micro Hard Rock Deluxe) 用来复习一些基础的CPU相关的知识,以下是官方的描述:

MHRD is a hardware design game, in which you design various hardware circuits in a hardware description language. The hardware circuits you design get more complex as you go until you create a fully functional CPU design.

语法

A design consists of the Inputs, Outputs, Parts and Wires section:

---
title: GRAMMER
---
flowchart LR

design("design"):::pink

subgraph grammer
    direction LR
    input_section("input_section"):::green
    output_section("output_section"):::green
    part_section("part_section"):::green
    wire_section("wire_section"):::green
end

design --> grammer

classDef pink 1,fill:#FFCCCC,stroke:#333;
classDef green fill: #696,color: #fff,font-weight: bold;
classDef purple fill:#969,stroke:#333;
classDef error fill:#bbf,stroke:#f66,stroke-width:2px,color:#fff,stroke-dasharray: 5 5
阅读全文 »

前言

在最近实现一个 简单的kv数据库 中又重新思考了一些问题。

当我第一次尝试了解数据库底层原理的时候,就从各个角度了解到了选择B+树而不是B树的很多理由,基本上无非是以下这些因素:

  • B+树支持范围查询。B+树非叶子节点不存储数据,并且成熟的B+树实现的叶子节点都会通过指针连接起来构成一个单独的链表;所以当我们进行范围查询的时候,只需要找到起始叶子节点之后遍历链表找到对应的结尾叶子节点即可。但是B树的非叶子节点也可以存储数据,所以无法实现;
  • 更适合磁盘存储:B+树的内部节点只存储键值的索引,而叶子节点存储实际的数据。这种设计使得每个节点的大小更小,可以容纳更多的键值对,减少了磁盘I/O的次数。另外,由于叶子节点之间通过链表连接,可以更好地利用磁盘预读取的特性,提高查询性能。
  • 更适合索引:数据库通常需要支持快速的索引查找,而B+树的结构更适合作为索引结构。B+树的内部节点只存储键值的索引,可以更好地利用内存空间,提高索引的效率。
  • 查询效率更稳定:B树的查询时间复杂度在1到树高之间,因为数据可能存储在根节点、内部节点或叶子节点,查询效率会因数据所在位置不同而波动。B+树的所有数据都存储在叶子节点,查询复杂度则稳定为树高,查询效率更加稳定。

当时觉得很有道理,然而随着水平和眼界的提升,却发现这里存在相当多的地方值得商榷:

阅读全文 »

早上逛 reddit rust 时偶然看到了 Ian Lance Taylor 介绍 linkers 的系列文章,觉得很有意思,决定开一个新坑来看看能不能自己实现一个简单的 linkers,目前找了一些资料,看起来工作量并不小。这里先做个简单的记录,参考的文章和书籍:

可能会涉及到的基础知识包括:

第一印象

一个最简单的链接过程

---
title: 一个简单的链接过程
---
flowchart LR

source1("source1"):::purple
of1("object_file1.o"):::purple

source2("source2"):::purple
of2("object_file2.o"):::purple

linkers("linkers"):::pink

executable("executable"):::green

source1 -->|gcc -o| of1
source2 -->|gcc -o| of2

of1 --> linkers
of2 --> linkers

linkers --> executable

classDef pink 1,fill:#FFCCCC,stroke:#333;
classDef green fill: #696,color: #fff,font-weight: bold;
classDef purple fill:#969,stroke:#333;
classDef error fill:#bbf,stroke:#f66,stroke-width:2px,color:#fff,stroke-dasharray: 5 5

链接过程可能涉及到的产物

阅读全文 »

test-fsm-arithmetic-operations

在之前 Programming Language Monkey 中,其实也实现了一版,但是当时只是简单的根据 Pratt Parsing 实现,并没有画出完整的状态机,所以在这里重新实现了一次,为了避免浪费太多的时间,这次将只会支持以下简单内容:

  • 支持 +, -, *, / 四则运算;
  • 支持 ()
  • 仅支持标准十进制格式的 number,不支持 0xFF 等其他形式的数字输入;
  • 仅支持 int64 类型,也就是说除法会导致会导致数据丢失,但是考虑到本来就是为了了解状态机而实现的玩具,这个完全是可以接受的;

前言

阅读全文 »
0%