今日已更新 98 条资讯 | 累计 29551 条内容
关于我们

标签:#m

找到 8747 篇相关文章

AI 资讯

[Advanced Rust] 2.2. API Design Principles of Unsurprising Pt.2 - Implementing Clone, Default, PartialEq, PartialOrd, Hash, Eq…

Full title: [Advanced Rust] 2.2. API Design Principles of Unsurprising Pt.2 - Implementing Clone, Default, PartialEq, PartialOrd, Hash, Eq, and Ord 2.2.1. It Is Recommended to Implement the Clone Trait and the Default Trait Clone Trait The Clone trait in Rust allows an implementer to explicitly create a deep copy of itself through the clone method, as opposed to the by-value copy provided by the Copy trait. Example: #[derive(Debug, Clone)] struct Person { name : String , age : u32 , } impl Person { fn new ( name : String , age : u32 ) -> Self { Self { name , age } } } fn main () { let person1 = Person :: new ( "John" .to_owned (), 25 ); let person2 = person1 .clone (); println! ( "{:?}" , person1 ); println! ( "{:?}" , person2 ); } The Person struct implements the Clone trait In main , person2 clones the data from person1 because it implements Clone Output: Person { name: "John", age: 25 } Person { name: "John", age: 25 } Default Trait The Default trait in Rust allows a type to define a default value and return that default instance through the default() method. Example: #[derive(Default)] struct Point { x : i32 , y : i32 , } fn main () { let p = Point :: default (); println! ( "Point is at ({}, {})" , p .x , p .y ); } Output: Point is at (0, 0) 2.2.2. It Is Recommended to Implement the PartialEq , PartialOrd , Hash , Eq , and Ord Traits PartialEq Trait PartialEq provides support for the == and != operators, allowing custom types to participate in partial equality comparisons. Example: #[derive(Debug, PartialEq)] struct Point { x : i32 , y : i32 , } fn main () { let point1 : Point = Point { x : 1 , y : 2 }; let point2 : Point = Point { x : 1 , y : 2 }; let point3 : Point = Point { x : 3 , y : 4 }; println! ( "point1 == point2: {}" , point1 == point2 ); println! ( "point1 == point3: {}" , point1 == point3 ); } By implementing PartialEq , we can compare whether two structs are equal Output: point1 == point2: true point1 == point3: false PartialOrd , Eq , and Ord Trait

2026-08-03 原文 →
AI 资讯

When Your Homelab Grows Up: How SQLite Took Down My k3s Control Plane

Originally published at wostal.eu . TL;DR : My Hetzner k3s lab quietly became a platform. Dozens of operators with leader-election leases hammered the default datastore — SQLite via kine — until compaction entered a death-spiral: 1.36M rows, a 13.8 GB WAL that wouldn't checkpoint, CPU pinned at 99%, load average 79 on 8 cores. I stopped the bleeding by truncating the WAL, then migrated the control plane to embedded etcd (7.5 GB SQLite → 313 MB etcd, load 79 → 5). This is the full postmortem — and the lessons. This is a war story, not a tutorial. It's about the moment a homelab stops being a homelab and starts behaving like production — without ever announcing it. The cluster in question, homelab , is the Hetzner k3s setup I wrote about previously . It started small. It did not stay small. In this post I'll cover: How an overgrown lab broke the default datastore — the kine/SQLite compaction death-spiral The firefight — measuring instead of guessing, and the fix that actually worked The permanent fix — migrating the control plane to embedded etcd, and the honest caveats The meta-lesson — how to recognize when your lab has become a platform A diagnostic runbook — so next time it's minutes, not hours There's a companion piece to this incident. The CI pipeline that ran this etcd migration was itself freshly — and badly — migrated, and debugging it cost me hours over a single missing newline. I split that into its own post: I Let an AI Re-Platform My CI Pipeline. Here's What Broke. Context: it's "just a homelab" — except it isn't homelab began like any homelab: one k3s node on Hetzner, a few things to play with. The problem is that over months it quietly became a platform . A single master node ( cx43 , 8 vCPU / 16 GB, untainted, and also carrying Longhorn and workloads) now runs: ArgoCD, Kargo, Crossplane/Upbound, CloudNativePG, EMQX, Longhorn, trivy-operator, kubescape, Gatekeeper, Goldilocks/VPA, VictoriaMetrics, Loki, OpenTelemetry, Argo Workflows/Events/Rollouts, kga

2026-08-03 原文 →
AI 资讯

Building Laravel NATS: A Modern, Production-Ready NATS Integration for Laravel

Building Laravel NATS: A Modern, Production-Ready NATS Integration for Laravel When building distributed systems, one of the biggest challenges is enabling services to communicate reliably without creating tight coupling. Laravel has excellent support for queues, events, broadcasting, and jobs, but when it comes to NATS , the ecosystem has been relatively limited. That's exactly why I built Laravel NATS . Instead of being just another wrapper around an existing PHP client, Laravel NATS aims to provide a Laravel-first developer experience while exposing the full power of NATS for modern event-driven architectures. In this article I'll explain: Why I built Laravel NATS Why you should consider NATS How Laravel NATS works Features that make it production ready Code examples Real-world use cases What makes this package different from existing solutions What is NATS? NATS is a lightweight, high-performance messaging system designed for cloud-native applications. Unlike traditional queues, NATS focuses on: Extremely low latency High throughput Simple publish/subscribe messaging Request/Reply APIs JetStream persistence Horizontal scalability Instead of applications calling each other directly: Order Service │ ▼ Notification Service Applications publish events: Order Service │ ▼ NATS Server │ │ ▼ ▼ Email Analytics Every service becomes independent. Why Laravel Needed a Better NATS Package Most existing packages expose the underlying PHP client almost directly. That means developers still have to understand: client lifecycle connections serialization subscriptions queue consumers JetStream APIs Laravel developers expect something different. We are used to APIs like: Cache :: put (); Queue :: push (); Event :: dispatch (); The goal of Laravel NATS was to make NATS feel just as natural. Installing Laravel NATS Installation is straightforward. composer require zaeem2396/laravel-nats php artisan vendor:publish --tag = nats-config Then configure your environment: NATS_HOST=127.0.0

2026-08-03 原文 →
AI 资讯

How to build an MCP server, step by step

Short answer To build an MCP server: install an official MCP SDK, declare your tools with typed inputs, optionally expose resources and prompts, run the server over stdio or HTTP, then connect an MCP client like Claude and test it. A minimal Python server is about ten lines; the work is in choosing what to expose and validating every input. This is the build . For what MCP is, its three primitives, and how it differs from an API, start with what is the Model Context Protocol — this page assumes that and goes straight to code. Prerequisites You need very little to get a server running locally: A language with an official SDK. Python and TypeScript are the most mature; the same protocol is also implemented for other languages. This guide uses the Python SDK (the secondary path most people search for), with notes on where the TypeScript SDK is equivalent. Python 3.10 or newer and uv (recommended) or pip to manage the environment. An MCP client to test against — Claude Desktop, or the MCP Inspector that ships with the SDK. You do not need cloud credentials to build or run the server itself. Conceptually a server exposes three things — tools (model-callable functions), resources (readable data), and prompts (reusable templates) . The steps below add them in that order. Exact SDK signatures evolve, so treat the snippets as the current shape and check the live docs before shipping. Which spec revision this builds against. The code here targets MCP revision 2025-11-25 — the revision the spec's versioning page still names as the current protocol version. Revision 2026-07-28 is published and reworks the wire format substantially. A server built against 2025-11-25 stays conformant today; what the new revision changes for a server author is set out below, so you can build now and plan the move. Step 1: scaffold the server Create a project, install the SDK, and write the smallest server that runs. With uv : uv init weather cd weather uv venv source .venv/bin/activate # Install t

2026-08-03 原文 →
AI 资讯

Why Documentation Is Architecture

Most of the engineers consider documentation as an after-thought; a README on a finished system written in the final 20 minutes before a PR gets merged. That's the wrong way to do this relationship. Documentation is not a description of architecture. It is part of the architecture, and marking it as separate is the cause of so many rotting systems, which still pass all tests. The compiler doesn't care, your team does It could be a consistent codebase and yet it be undocumented garbage from the point of view of anybody who didn't write it. Only one sort of correctness is enforced by the compiler (or interpreter): does this code perform the operation that the instructions say it performs. It doesn't weigh in on why a specific table contains a deleted_at column, versus a hard delete, or why a service tries 3 times with exponential back-off, versus 5 times with a fixed interval. Those decisions include constraints that are not apparent in the diff, regulatory, historical, or performance. If these are only in the mind of the programmer who wrote them, the actual architecture is partially undocumented, and these constraints will be breached as soon as someone else messes with the code when it is under a tight deadline. Architecture is not only the shape of your services and schemas, it's the set of decisions and constraints that shape stayed within. Undocumented constraints are like walls that we don't see, or know about. They are walked through without anyone knowing they exist, and one of the assumed conditions is broken at a time. Documentation as a design artifact, not a report Good documentation should be done prior to and/or in the midst of implementation, not after. When writing a design doc that explicitly states the problem, the options you considered, the one you selected, and the tradeoffs you made, you are actually doing real design work, you are making mistakes in your thinking process that would only become apparent during production. There have been more ti

2026-08-02 原文 →
AI 资讯

The cache key that ignored the question

Two people asked a context compressor two completely different questions. It gave them the same answer. Not a similar answer — byte for byte the same 544 characters. Here's what that looked like: query="Fix the IntegrityError on commit" level=L0 -> 159 tok cache_hit=False query="Explain the tax rounding TODO in compute_tax" level=L3 -> 159 tok cache_hit=True identical output: yes (544 chars both) Different question. Different compression level. Same 544 characters, served from cache. Finding it I wasn't looking for this. I was auditing something else entirely — measuring how much meaning a context compressor loses, not how fast it runs. My harness feeds the same corpus through the compressor with different queries and checks which critical substrings survive: file paths, error types, line numbers, identifiers. I noticed two rows in my results table were identical. Same token count, same output. My first assumption was that my own harness had a bug — that I was passing the same query twice and hadn't noticed. So I changed the second query to something with no words in common with the first, and bumped the compression level from L0 to L3, which should change the output dramatically on its own. Same 544 characters. That was the moment it stopped being my bug. The cause One line: sid = content_hash(content) That sid was doing two jobs. It was the shadow ID — the handle used to refer to a stored document. And it was also the cache key. As a shadow ID it's correct: the same content should get the same handle. As a cache key it's wrong, because the output of compress() doesn't depend only on the content. It depends on the content and the query and the compression level. Two of those three inputs were simply not part of the key. So the first caller warmed the cache for a piece of content, and everyone who touched that same content afterwards got the first caller's answer — regardless of what they actually asked for. Why this is worse than a stale cache A stale cache gives y

2026-08-02 原文 →
AI 资讯

How to Prove Every Company Laptop Is Managed: An Endpoint Audit Evidence Checklist

A spreadsheet containing laptop serial numbers is not proof that every endpoint is managed. It proves only that someone created a spreadsheet. For an audit, customer security review, onboarding check, or incident investigation, the evidence needs to connect four facts: The organisation expects the device to exist. The device is assigned to an accountable owner or lifecycle state. A management or monitoring control is actively reporting from it. The reported evidence is recent enough to support the decision being made. A device can appear in an asset register while being absent from the management platform. It can also appear in the management platform while belonging to a former employee or reporting data that is months old. Control objective: Maintain a current, reconciled inventory of expected endpoints, managed endpoints, owners, security state, and unresolved exceptions. 1. Define what "managed" means before counting devices Teams often use the word managed without an operational definition. That creates false confidence. An endpoint should not count as managed merely because an agent was installed once. For a company-owned laptop, a practical definition normally requires all of the following. Criterion Minimum evidence Identity Hostname, serial number, hardware identifier, operating system, and management record can be tied to one device Ownership Named user, department, custodian, stock status, repair status, or retirement state Control Expected MDM, RMM, EDR, or other endpoint control is enrolled and associated with the correct organisation Freshness Last check-in and evidence timestamps fall within a documented threshold Posture Update, encryption, firewall, antimalware, restart, and other required states are known Accountability Deviations have a reason, owner, approval, target date, and review history A device that fails one criterion should not disappear from the report. It should remain visible as an exception. 2. Reconcile three sources of truth No sing

2026-08-02 原文 →
AI 资讯

Microsoft Up 15%. Me? 100% Down.

hey there, so i wanted to share something with you. this is a bit personal but i have been watching the news this week and bruh... things are not going good. i am jobless right now, no other source of income, and day by day things are getting worse. and the worst part? AI is literally fuking every job in the software field. so when i saw this week's stock market drama, it hit me different. Microsoft popped. Meta tanked. Same AI boom. Two completely opposite reactions. and all i could think was... yeah, this is exactly my life right now. The Numbers, Bruh let me break it down real quick because this is wild: Microsoft jumped like 15% after beating expectations. Azure grew 43%. full year Azure revenue crossed $100 billion. insane. Meta dropped 8–9% after missing on guidance. their free cash flow collapsed 91% year-over-year to just $784 million. like... 91%?? gone. same AI boom. same crazy spending. and the market said "you're amazing" to one and "you're done" to the other. Why Microsoft Won Microsoft actually showed receipts. they didn't just talk about AI, they showed the money coming in. Azure is growing, Copilot is making real revenue, investors can literally see the line between billions spent and billions earned. lesson? Wall Street doesn't hate AI spending. it hates AI spending without proof. Why Meta Lost Meta's problem is that nobody can see where the money comes back. Zuckerberg talked about the "AI capacity dilemma" — how much compute to keep for yourself vs sell to others. but guidance missed, free cash flow went to hell, and the market was like... nah bro, i need answers. and honestly? i relate to that feeling more than i want to admit. putting everything into something and people still saying "not enough." The Bigger Picture this week is a preview of everything coming. companies are dumping hundreds of billions into data centers, chips, and models, all betting AI demand keeps exploding. the ones who can prove it pays off? they get rewarded. the ones who

2026-08-02 原文 →
AI 资讯

TypeScript Just Got 10x Faster by Not Being TypeScript

Table of Contents Introduction Putting the 10x Claim Into Perspective How Did We Get Here? This Was an Extensive Evaluation The Priority Was Compatibility Why Not Rust? Why Not C#? Why Go Fit the Existing Compiler A Port, Not a Simple Translation Where Does the Performance Come From? Native Execution Parallel Processing Memory Efficiency and Larger Projects The Benchmarks Memory Usage The JavaScript API Trade Off Is It Still TypeScript? The F1 Analogy Large Companies Helped Test TypeScript 7 Should You Upgrade? Final Thoughts Introduction At the end of March 2025, I published this article: Go-ing Beyond TypeScript: Microsoft Picks Go: How Will This Change the Landscape? Giorgi Kobaidze Giorgi Kobaidze Giorgi Kobaidze Follow Mar 31 '25 Go-ing Beyond TypeScript: Microsoft Picks Go: How Will This Change the Landscape? # microsoft # typescript # go # csharp 1 reaction 2 comments 12 min read At the time, Microsoft's decision to port the TypeScript compiler to Go sparked quite a bit of discussion and controversy. Many people questioned whether moving such a critical piece of the ecosystem away from TypeScript was the right choice. And boy, did Microsoft deliver what it promised: an order-of-magnitude performance improvement on some of the world's largest TypeScript codebases. The results are here, and the benchmarks speak for themselves. Putting the 10x Claim Into Perspective The phrase "10x faster" describes the scale of the improvement Microsoft has demonstrated. It does not guarantee that every codebase will become exactly ten times faster. The results depend on the size of the project, the work being performed, and the available hardware. Some projects might see a 5x improvement, while others could reach 8x, 10x, 12x, or potentially even more. No, this doesn't make every TypeScript developer a 10x developer , But it does mean that compiling a TypeScript project, loading it in an editor, and receiving diagnostics could become dramatically faster after moving to the nat

2026-08-02 原文 →
AI 资讯

The plumbing behind newsletter apps: intake addresses, email-to-Atom, and what eight of them really cost

If you subscribe to more newsletters than you read, which tool fixes it depends entirely on which problem you actually have. Most roundups skip that step and just rank apps. Disclosure up front: we make one of the eight tools below. It's the last entry, it's new, and it has no track record — its section says so plainly. The other seven are real options and for most people one of them is the better pick. Every price and behaviour here was checked against the vendor's own site on 2 August 2026 . Where a vendor doesn't publish a price, this says that instead of guessing. The two problems people both call "too many newsletters" They aren't the same problem, and the tools split cleanly along the seam. Clutter. Newsletters are burying your real email. You'd read them, you just don't want them sitting next to your bank and your on-call alerts. The fix is routing: move them somewhere else. Volume. Twenty-five arrive a week and you have time for three. Moving them changes nothing — now you have twenty-five unread items in a nicer app. The fix is either condensing the pile or deciding what's in it. Almost every tool below solves exactly one of these. Buying a clutter tool for a volume problem is the standard way to end up paying a subscription and still having the same unread count. The plumbing, since you're the one wiring it up Four mechanics show up across all eight: Dedicated intake addresses. Readwise Reader, Meco, Readless and Digest each hand you an address on their domain (Meco's look like you@mecoinbox.com ). You subscribe with it and their infrastructure receives the mail — the cleanest integration point available: no OAuth scope on your mailbox, no IMAP polling, no shared credentials. Mailbox connection. Meco will alternatively connect Gmail or Outlook and pull your existing subscriptions across, setting the selected ones to skip your inbox (reversible at any time, per Meco's FAQ). Much faster than re-subscribing to 25 newsletters by hand. The cost is a read scope

2026-08-02 原文 →
AI 资讯

One keystroke to a project: building a tmux session launcher with fzf

I hit Ctrl-F more than any other key combination on this machine. It runs a shell function called fts — "find tmux session," which is not a good name but it's four years too late to change it. I press it, a fuzzy finder opens listing every project directory I have, I type a few characters, and I'm sitting in a tmux session for that project with the panes already laid out. If the session already existed, I'm back in it exactly where I left off. If what I typed doesn't exist yet, it offers to create it. Somebody watched me do this over a screen share recently and asked what was going on. So: here's the whole thing, the four tools it's built on, and a breakdown of every part that isn't obvious. What you'll end up with: One keystroke from anywhere to any project Fuzzy search across every repo you own, with a live directory tree preview Type a name that doesn't exist → it offers to scaffold and place it Never accidentally start a second tmux session for a project you already have open The same window/pane layout in every project, every time The problem it solves Before this, starting work looked like: cd ~/repo/work/some-project-i-half-remember-the-name-of tmux new-session -s some-project # split some panes, badly, slightly differently each time Three or four commands, one of which needed me to remember a path. None of it hard. All of it friction at exactly the wrong moment — the moment you've decided to start something, which is the moment you're most likely to get distracted instead. I'd also collected tmux sessions named 0 , 1 , 2 and some-project-2 , because I kept starting new ones instead of attaching to the one already running. So the goal wasn't really speed. It was making the right thing the automatic thing. Prerequisites Four tools plus zsh. All four are worth having on their own, and three of them are things you'll reach for daily once installed. Tool Version I'm on What it does here tmux 3.6a The terminal multiplexer. Holds the sessions, windows and panes. fz

2026-08-02 原文 →