uv - Python package manager

这篇文章深入介绍 uv 管理 Python 项目的使用 Features Python versions uv python install: 安装 Python 版本 uv python list: 查看可用的 Python 版本 uv python find: 查找安装的 Python 版本 uv python pin: 固定当前项目的 Python 版本 uv python uninstall: 卸载一个 Python 版本 Scripts uv run: 运行一个脚本 uv add --script: 为脚本添加一个依赖 uv remove --script: 移除一个依赖 Projects 使用 pyproject.toml 配置项目 uv init: 创建一个 Python 项目 uv add: 为项目添加依赖 uv remove: 删除项目依赖 uv sync: 同步环境下的依赖 uv lock: 为项目依赖创建一个锁文件 uv run: 在项目环境执行命令 uv tree: 查看项目依赖树 uv build: 将项目构建为分发归档文件 uv publish: 将项目发布到包索引 Tools 允许与安装工具 ...

September 22, 2025 · 11 min · 2131 words · Starslayerx

Morden Javascript Tutorial Chapter 2 - Fundamentals: 11~18

2.11 Logical operators There are four logical operators in JavaScript: || (ORA), && (AND), ! (NOT), ?? (Nullish Coalescing 空值合并). || OR result = a || b There are four logical combinations: alter( true || true ); // true alert( false || true ); // true alert( true || false ); // true alert( false || false ); // false If an operand is not a boolean it’s converted to be a boolean for the evaluation. if (1 || 0) { // works like (true || false) alter('truthy!'); } OR “||” finds the first truthy value result = value1 || value2 || value3 The OR || operator does the following: ...

September 21, 2025 · 22 min · 4603 words · Starslayerx

English for Programmers - 03

Unit 3. Discussing Code vocabulary - Modifiers When discussing code, modifiers can be extremely useful for making your feedback constructive and precise. modifiers: words that change the meaning of a sentence For example, a colleague asks: What do you think of the website? Response 1: It’s good When I click something it loads very quickly and I can navigate it easyily without any instructions. Response 2: It’s good! It’s very responsive and can be navigated intuitively. ...

September 20, 2025 · 2 min · 390 words · Starslayerx

Redis Bitmap

Bitmap 位图 Redis 的位图 bitmap 是由多个二进制位组成的数组, 数组中的每个二进制都有与之对应的偏移量(索引), 用户通过这些偏移量可以对位图中指定的一个或多个二进制位进行操作. Redis 为位图提供了一系列操作命令, 通过这些命令, 用户可以: 设置或获取索引位上的二进制值 统计位图中有多少个二进制位被设置成了1 查找位图中, 第一个被设置为指定值的二进制位, 并返回其偏移量 对一个或多个位图执行逻辑并、逻辑或、逻辑异或以及逻辑非运算 将指定类型的整数存储到位图中 SETBIT: 设置二进制位的值 SETBIT bitmap offset value 为位图指定偏移量上的二进制位设置值, 该命令会返回二进制位被设置之前的旧值作为结果. 当执行 SETBIT 时, 如果位图不存在, 或者位图当前的大小无法满足用户想要执行的设置操作, 那么 Redis 将对被设置的位图进行扩展, 使得位图可以满足用户的设置请求. 由于位图的扩展以字节为单位, 所以扩展后的位图包含的二进制数量可能会比用户要求的稍多一些. 且在扩展的同时, 会将未设置的二进制位初始化为 0. 与一些可以使用负数的 Redis 命令不同, SETBIT 命令只能使用正数偏移量, 尝试输入负数作为偏移量将引发一个错误 复杂度: O(1) GETBIT: 获取二进制位的值 GETBIT bitmap offset 与 SETBIT 命令一样, GETBIT 命令也只能接受正数作为偏移量. 对于偏移量超过位图索引的命令, GETBIT 命令将返回 0 作为结果. 复杂度: O(1) BITOCUNT: 统计被设置的二进制数量 BITCOUNT key 对于值为 10010100 的位图 bitmap001, 可以通过执行以下命令来统计有多少个二进制位被设置成了1: ...

September 19, 2025 · 5 min · 1009 words · Starslayerx

Redis HyperLogLog

之前曾介绍过使用 Redis 集和构建唯一计数器, 并将这个计数器用于计算网站的唯一房客 IP. 虽然使用集和实现唯一计数器可以实现该功能, 但这个方法有一个明显的缺陷: 随着被计数元素的不断增多, 唯一计数器占用的内存也会越来越大; 计数器越多, 他们的体积越大, 这一情况就会越严峻. 以计算唯一访客 IP 为例: 存储一个 IPv4 格式的 IP 地址最多需要 15 个字节 根据网站的规模不同, 每天出现的唯一 IP 可能会有数十万、数百万个 为了记录网站在不同时期的访客, 并进行相关的数据分析, 网站可能需要次序地记录每天的唯一访客 IP 数量 综上, 如果一个网站想要长时间记录访客 IP, 就必须创建多个唯一计数器. 如果访客比较多, 那么它创建的每个唯一计数器都将包含大量元素, 并因此占用相当一部分内存. 为了高效解决计算机唯一访客 IP 数量这类问题, 其中一种方法就是 HyperLogLog. HyperLogLog 简介 HyperLogLog 是一个专门为了计算集和的基数而创建的概率算法, 对于一个给定的集和, HyperLogLog 可以计算出这个集合的近似基数: 近似基数并非集和的实际基数, 它可能会比实际的基数大一点或者小一点, 但误差会在一个合理范围内. 因此, 那些不需要知道实际基数的程序就可以把这个近似基数当作集合的基数来使用. HyperLogLog 的优点在于计算近似基础所需的内存并不会因为集和的大小而改变, 无论集和包含元素有多少个, HyperLogLog 进行计算所需的内存总是固定的, 无论集和包含元素多少个, HyperLogLog 进行计算所需的内存总是固定的, 并且是非常少的. PFADD: 对集和元素进行计数 PFADD hyperloglog element [element ...] 根据给定元素是否已经进行过计数, PFADD 命令可能返回0, 也可能返回1: ...

September 18, 2025 · 3 min · 456 words · Starslayerx

Morden Javascript Tutorial Chapter 2 - Fundamentals: 06~10

2.6 Interaction: alert, prompt, confirm Will introduce alert, prompt and confirm in this chapter. alert It shows a message and waits for the user to press “OK”. alert("Hello"); prompt This function prompt accepts two arguments result = prompt(title, [default]); It shows a modal window with a text message, an input field for the visitor, and the buttons OK/Cancel. title: The text to show the visitor. default: An optional second parameter, the initial value for the input field. ...

September 17, 2025 · 15 min · 3118 words · Starslayerx

Morden Javascript Tutorial Chapter 2 - Fundamentals: 01~05

2.1 Hellow Wrold Firtly, let’s see how to attach a script to a webpage. For server-side environments (like Node.js), you can execute this script with a command like node my.js The “script” tag JavaScript programs can be inserted almost anywhere into an HTML docuemnt using the <script> tag <!DOCTYPE html> <html> <body> <p>Before this script...</p> <script> alert("Hello, World!"); </script> <p>...After the script...</p> </body> </html> The <script> tag contains JavaScript code which is automatically executed when the browser process the tag. ...

September 16, 2025 · 16 min · 3234 words · Starslayerx

Morden Javascript Tutorial Chapter 1 - An Introduction

An Introduction to JavaScript Let’s see what’s so special about JavaScript, what we can achieve with it, and what other technologies play well with it. Why is it call JavaScript? JavaScript initially called “Live Script”. But Java was popular at that time, so it was decided that positioning a new language as a “younger brother” of Java would help. But as it evolved, JavaScript became a fully independent language with its won specification called ECMAScript, and now it has no relation to Java at all. ...

September 15, 2025 · 3 min · 622 words · Starslayerx

English for Programmers - 02

Unit 2. Code Review & Testing this unit will cover: Differentiate between various testing strategies Write professional guidelines Sound more natural and smooth when asking questions Use colloquial language in speaking to give and accept feedback vocabulary - None Pharses 词汇: 名词短语 Testing 测试是软件开发中的重要短语, 用于检查软件是否达到特定的标准和用户需求. 使用这些名词语句来证明英语名词的专业性: None Desciption Example time box an allocated period of time for completing a task - allcate a 2-hour time box for regression testing stress test a method to assess a system’s performance under heavy loads - simulate 1000 users accessing the login page at the same time sanity check 健全性测试 a quick check to verify that something is as expected - are the units of the output value correct? ad hoc test 临时测试 a test performed without predefined test cases or plans - input unexpected characters into a search bar edge case a problem that only happens in extreme situations - upload an empty, 0-byte file 一些名词短语也可以当作动词使用: ...

September 12, 2025 · 4 min · 777 words · Starslayerx

English for Programmers - 01

Unit 1. Implementing Code This unit will cover: Use technical verbs to accurately define tasks and actoins Write commit messages in the corret Git format Confidently name the symbols used when writing code Understand vocabulary for syntax and programming rule vocaluary - action verbs 动词词汇 He optimised the queries to improve the response time. optimised: 提高 (improved) Can you implement the new feature we discussed yesterday? implement: 实现 (put int action) The team will integrate a third-party API to get real-time data. ...

September 11, 2025 · 3 min · 553 words · Starslayerx