全部文章
-
防止登录、注册和重置表单泄露账户是否存在
现有账户与不存在的账户得到的响应,只要有任何差别(消息文本、HTTP 状态、重定向、耗时),攻击者就能据此建立有效用户列表并发动攻击。返回相同的通用消息和状态,在两条路径上执行同样的工作,将可区分的信息放入电子邮件,并限制请求频率,避免残留差异被大规模采样。
-
SLIs for queues and batch jobs: age of the oldest message, freshness, coverage and last success
Request-driven services measure availability and latency; queues and batch jobs need different indicators: how old the oldest unprocessed item is, what proportion of data is fresher than a threshold, what proportion of scheduled runs completed within their window, and when the job last succeeded. This methodology derives them from the pipeline SLIs in the SRE workbook.
-
Checking a served TLS certificate chain and its expiry from the command line with openssl
openssl s_client with -servername and -showcerts prints the certificates a server actually sends, which the manual describes as not a verified chain; openssl x509 reads subject, issuer, SANs and the notAfter date of each one, and openssl verify -untrusted rebuilds the chain against a trust store. Check every hostname, and IPv4 and IPv6 separately.
-
Schema conventions for a new PostgreSQL database: names, identifiers, timestamps and text
Decide a handful of conventions before the first migration: lower-case snake_case names that never need quoting, one id strategy applied everywhere, timestamptz for every point in time with created_at on every table, text instead of varchar(n), and explicit NOT NULL and foreign keys; write them down so every later migration follows them.
-
When should a team split a monolith into services?
Open question: which observable signals (deployment coupling, team boundaries, scaling needs, incident patterns) have preceded successful extractions of services from a monolith, and which extractions were later reversed?
-
混合精度训练:自动类型转换、损失缩放与数值限制
混合精度为不同操作分配合适的浮点格式。自动类型转换和损失缩放解决不同问题;要确认性能收益,必须检查数值行为并在目标硬件上测量。
-
在进入智能体上下文之前,用决策模型筛查工具结果和检索片段
一种在智能体与输入之间放置快速类型化分类器的协议:在单次请求中评估每段检索内容或工具结果的相关性、矛盾和隐藏指令,在代码中丢弃或标记,并对照来源验证引用;同时将筛查视为仍可能被对抗性文本影响的过滤器。
-
使用 TypeVar、ParamSpec 和 PEP 695 语法编写泛型函数与装饰器
类型变量关联参数与返回值的类型;PEP 695 的方括号语法(def f[T](...))取代手工声明 TypeVar,上界与类型约束的语义不同,而 ParamSpec 让装饰器保留所包装函数的签名,不再将其抹去为 Callable[..., Any]。
-
Convert timestamps to UTC at the boundary
Reject ambiguous timestamps, convert aware instants to UTC and preserve the original timezone when local scheduling semantics matter.
-
A parcel delivery time log: order, dispatch, tracking and door timestamps on one row, with the carrier's scan and the observed arrival kept apart
A proposed record-only protocol for logging each parcel's timeline as timestamps in the RFC 3339 Internet Date/Time Format with UTC offsets, taken from the order confirmation, the dispatch notice, the carrier's tracking events and the household's own note of the arrival, with the carrier, service, delivery place and each attempt recorded; the carrier's delivered scan and the observed arrival are separate columns, and no carrier comparison or delivery-time claim is made.
-
Querying the systemd journal with journalctl: unit, boot, priority, time range and JSON output
journalctl can filter the systemd journal by unit, boot, priority and time range and emit machine-readable output, but only if the journal is configured to persist across reboots. This methodology covers precise queries, persistent storage, and the size caps in journald.conf.
-
JSON API 中的 null 与缺失字段
字段缺失、字段为 null 和字段值为空,是三种不同的表达,API 应说明自己区分哪些情况:RFC 7396 合并补丁用 null 表示移除,ProtoJSON 将 null 视为未设置且不输出它,Google 的 JSON 风格指南则建议省略空值或 null 属性,除非保留它们有语义上的理由。
-
将嵌入视为数据类型:固定长度向量、距离函数及向量列的要求
嵌入是由特定模型生成的固定长度浮点向量,只有在使用该模型训练所针对的距离度量、并与同一模型版本的向量放在一起时才有意义。存储时必须记录维度、模型标识符和距离度量;查询则意味着精确或近似的最近邻搜索。
-
二分查找陷阱:中点溢出与边界差一错误
二分查找很短,却出了名地容易写错:(low + high) / 2 会使固定位宽整数溢出,包含与不包含的边界容易混用,重复项又引出应返回哪个索引的问题。应使用库函数,或采用半开区间的单调谓词形式,并测试边界。
-
Verifying Stripe webhook signatures: Stripe-Signature, timestamp tolerance and secret rotation
Stripe sends a Stripe-Signature header shaped like t=<timestamp>,v1=<hex signature>, computed as HMAC-SHA256 over the string "{timestamp}.{raw body}" keyed with the whole whsec_ endpoint secret. Stripe's libraries reject signatures whose timestamp is more than five minutes (300 seconds) old by default, and while a rolled secret is kept alive (up to 24 hours) the header carries one v1 value per active secret.
-
Checking whether a database migration rehearsal represents the target state
Assess whether an isolated migration test exercised the schema and data conditions that matter for the intended deployment, rather than only proving the migration works on an empty database.
-
Writing shell scripts that fail safely
Use set -euo pipefail, quote every expansion, prefer [[ ]] and arrays, check tools with ShellCheck, and avoid parsing ls; a script that stops on the first error is easier to trust than one that continues.
-
Identifying an unknown Linux host before changing anything on it
Before an agent or operator changes configuration on a Linux machine it did not build, it should establish the distribution, kernel, virtualization or container status, init system, package manager and mandatory access control state — each with one cheap, non-destructive command.
-
CDN cache keys and purging: what identifies a cached object and how to invalidate it
A cache stores responses under a key built at minimum from method and target URI, extended by request headers named in Vary; CDNs add scheme, host and query string and let you customise the key at the cost of sharding. Purging by URL only hits objects whose key matches exactly, so tag responses (for example Fastly's Surrogate-Key header) to purge groups reliably.
-
Checkpointing a long agent task: progress files, idempotent steps and resumption
How an agent working through a multi-step task should record progress so that a crash, a context reset or a hand-over resumes at the last completed step without repeating side effects: a plan with numbered steps, a progress file updated after each step with evidence, idempotency keys for external writes, and a resumption procedure that verifies state before continuing.
机器可读: JSON