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

标签:#p

找到 12927 篇相关文章

AI 资讯

Title: How to Automate A4 Batch ID Card Printing in React (Without a Backend)

The Nightmare of HTML-to-PDF in React If you’ve ever built a School ERP, HR portal, or Event Management system, you’ve probably hit this exact wall: Your client needs to print 5,000 ID cards or badges. Usually, this forces frontend teams to do one of two terrible things: Pay for an expensive backend PDF generation API (which raises huge GDPR/privacy concerns because you have to send sensitive employee photos to a 3rd-party server). Force the non-technical HR team to manually type names into Canva, crop photos, and manually drag them onto an A4 grid (an 80-hour manual data entry nightmare). I got tired of rebuilding complex html2canvas and jsPDF calculators from scratch for every project. So, I decided to automate the entire pipeline natively in the browser. Enter @stratametriq/id-card-designer — an open-source, turnkey drag-and-drop ID card studio and A4 mathematical rendering engine for React. What it does out of the box: Instead of building a canvas from scratch, you install this NPM package in one line of code. It gives your end-users a complete visual dashboard directly inside your own application. Here is a 60-second video of how it looks running in a live production environment: 👉 https://youtu.be/l9aXWqRSFCM?si=nEIaaqsxypmzCflm The Core Features: Dynamic Handlebars Data Binding Your users can design a visual template and drop in tags like {{studentName}} or {{employeeId}}. Our engine automatically binds these variables to your live database array. No manual typing required. Scannable Barcodes & QR Codes We built native QR and Barcode generators directly into the canvas. You just pass the ID string, and the engine renders a scannable vector code instantly. The Magic Moment: Precision A4 Batch Matrix When your HR admin selects 500 employees and hits "Batch Print", the real magic happens. Our client-side mathematical matrix calculates exact millimeter dimensions—arranging exactly nine PVC cards perfectly on standard A4 cut-sheets, complete with professional 0.35

2026-07-27 原文 →
AI 资讯

React useDeepCompareEffect: Fix useEffect Object Dependencies (2026)

React useDeepCompareEffect: Fix useEffect Object Dependencies (2026) You wire up a fetch. The endpoint takes a query object, so you pass it in the dependency array. The effect fires, sets state, the component re-renders, the query object is rebuilt — a brand-new object with identical contents — and the effect fires again. You have written an infinite loop, and React thinks it did exactly what you asked. function Results ({ term , page }: Props ) { const [ rows , setRows ] = useState ([]); const query = { term , page , sort : ' desc ' }; // new object, every render useEffect (() => { fetchRows ( query ). then ( setRows ); // setRows → re-render → new query → 🔁 }, [ query ]); } useDeepCompareEffect from @reactuses/core is a drop-in replacement for useEffect that compares dependencies by value instead of by reference. Same signature, same cleanup semantics — the effect just stops firing when nothing actually changed. Everything below is the real implementation, TypeScript-first, including the parts that cost you something. Why useEffect Can't See It React compares dependency arrays with Object.is , element by element. For primitives that's exactly what you want: 5 is 5 , 'desc' is 'desc' . For anything with an identity — objects, arrays, Date s, Map s, functions — it compares the reference , and a literal written inside a component body produces a fresh reference on every single render: Object . is ({ term : ' react ' }, { term : ' react ' }); // false — different objects So the dependency "changed" on every render, by React's definition. This isn't a bug in useEffect ; reference equality is the only comparison that's O(1), and React runs it on every render of every component. The cost of value comparison is real, and React declines to pay it on your behalf. Which leaves you paying it — one way or another. The Usual Workarounds, and Where They Fray Memoize the object. Correct, and the right answer when there's one dependency: const query = useMemo (() => ({ term , page

2026-07-27 原文 →
AI 资讯

The Evolution of AI, Explained in Stages

AI feels like it "suddenly" got smart in the last few years. It didn't. It's been evolving in distinct stages for over 70 years — each one building on the limits of the last. Here's the journey, broken down simply. Stage 1: Rule-Based AI (1950s-1980s) The earliest AI wasn't "intelligent" — it was a giant pile of if-else logic written by humans. How it worked: Programmers manually coded rules. "If symptom X and symptom Y, then diagnose Z." Chess engines, expert systems, early chatbots like ELIZA — all rule-based. The limit: These systems couldn't learn. Every scenario had to be explicitly programmed. Show it something outside its rules, and it broke. Stage 2: Machine Learning (1990s-2000s) Instead of hand-coding every rule, engineers started teaching systems to find patterns in data themselves. How it worked: Algorithms like decision trees, support vector machines, and linear regression learned relationships from labeled examples — spam vs. not spam, fraud vs. not fraud. The limit: These models needed carefully hand-engineered "features" (inputs) prepared by humans. They also struggled with messy, unstructured data like raw images or audio. Stage 3: Deep Learning (2010s) This is where things accelerated. Neural networks with many layers ("deep" networks) could learn features automatically from raw data, given enough compute and data. How it worked: Instead of a human deciding "look at edges, then shapes, then objects" in an image, the network learned that hierarchy itself. This powered breakthroughs in image recognition, speech-to-text, and translation. The limit: Deep learning was narrow. A model trained to recognize cats couldn't write an email. Each task needed its own model trained from scratch. Stage 4: Generative AI & LLMs (2018-Present) The current stage. Large Language Models like GPT and Claude are trained on massive amounts of text to predict "what comes next" — and in doing so, they pick up grammar, facts, reasoning patterns, and coding ability, all from o

2026-07-27 原文 →
AI 资讯

RockPlayer: Building a Modern Music Player with Angular, ASP.NET Core, Redis, and YouTube

Hello everyone! After publishing my Machine Learning with ML.NET series, I decided to turn the recommendation model into a complete application. In this new series, we build RockPlayer, a rock music player that combines modern software architecture, ASP.NET Core, Angular 22, Redis, and YouTube integration. Each article focuses on a different part of the project: 🎵 1. Introducing RockPlayer An overview of the project, its goals, and the overall architecture. https://devfullstack.net/blog/introducing-rockplayer 🔌 2. Adapters: Isolating the YouTube Provider Using the Adapter pattern to decouple the application from the YouTube integration. https://devfullstack.net/blog/adapters-isolating-the-youtube-provider ⚡ 3. No Database: Caching Lookups with Redis Using Redis to cache search results instead of storing external data in a database. https://devfullstack.net/blog/no-database-caching-lookups-with-redis 🅰️ 4. Angular 22 in Practice Applying modern Angular 22 features to build the user interface. https://devfullstack.net/blog/angular-22-in-practice 🚀 5. Building the RockPlayer API Building the API that orchestrates the application. https://devfullstack.net/blog/building-the-rockplayer-api ▶️ 6. The YouTube Adapter: Finding and Playing the Song Implementing the YouTube integration to search for and play songs. https://devfullstack.net/blog/the-youtube-adapter-finding-and-playing-the-song 🎧 7. RockPlayer in Angular 22: Onboarding Setting up the Angular application and organizing the project structure. https://devfullstack.net/blog/rockplayer-in-angular-22-onboarding 🎸 8. RockPlayer: Putting It All Together Bringing all the components together into a complete application. https://devfullstack.net/blog/rockplayer-putting-it-all-together I hope this series is useful for developers interested in software architecture, .NET, and Angular. See you there!

2026-07-27 原文 →
AI 资讯

What Judges Actually Score: Notes From a Year of Hackathon Judging

I judged three hackathons over about ten days this July: MLH x DigitalOcean "AI for Social Good" on July 11, the Sports World Cup Hackathon in San Francisco on July 17, and Aethera Hacks, an online event on Devpost, across July 19 to 21. I came in from the sports technology side, building athlete monetization tools, so I was usually the judge asking who pays for this rather than the judge asking what is your bundle size. That turned out to be a useful seat, because the questions that decide scores are mostly not technical ones. Here is the part builders rarely get told: a judge is scoring under a hard constraint. Some number of teams, a fixed window, and by the middle of the block the demos start blurring together. Judges are not evaluating your project against an ideal. They are ranking it against the six they just saw while trying to remember which one had the map. Everything below follows from that. The rubric is real, but it is not what separates teams Most events hand judges four or five categories with numbers next to them. Technical difficulty, originality, design, impact, something about use of a sponsor API. Those categories are real and I filled them in honestly. But they compress. Almost every team lands mid-range on most of them, and the spread that produces a winner comes from two or three things the rubric does not name directly. 1. Whether the demo ran This sounds too obvious to write down. It is the single largest score differentiator I saw. A working demo, live, on the judge's screen or the team's laptop, beats a more ambitious project shown as slides almost every time. Not because judges are impressed by working software as such, but because a live demo removes doubt, and doubt is what a judge is actually managing under time pressure. The practical version: cut scope until something end-to-end runs. One complete path through the product beats four half-built paths. If your architecture diagram has six boxes and two of them work, demo the two and de

2026-07-27 原文 →
AI 资讯

GitOps for AI Agents: Treating Tool Configs and Memory Like Production Infrastructure

GitOps for AI Agents: Treating Tool Configs and Memory Like Production Infrastructure Stop managing AI agent configurations as fragile scripts. Adopt GitOps principles for AI, treating your tool configs and memory as version-controlled, auditable infrastructure-as-code. Learn to implement mcp.jsonc, PR-reviewed workflows, and CI validation for reliable, reproducible AI. The Configuration Chaos in Modern AI Agents Today's AI agents are powerful orchestrators, not just chatbots. They connect to dozens of external tools, databases, and APIs via configurations that define their capabilities, permissions, and memory pathways. But this configuration—often scattered across JSON files, environment variables, or proprietary dashboards—becomes a critical vulnerability. A single typo in a tool's endpoint URL or an incorrect memory namespace can cause silent failures, security leaks, or non-reproducible agent behavior across development and production. Consider a common scenario: Your team updates an AI agent's access to a vector database for its long-term memory. The change is made directly in a production dashboard by an engineer. A week later, the agent starts hallucinating corrupted context. Reverting is guesswork because there's no change log, no PR review, and no record of the previous state. This is the classic "configuration drift" problem that plagued traditional infrastructure, and it's now crippling advanced AI systems. The Infrastructure-as-Code Paradigm for AI The solution lies in applying mature DevOps practices to AI management. We must stop treating AI configurations as special snowflakes and start treating them as infrastructure as code . This means storing all defining components—tool endpoints, authentication scopes, memory indexes, and even behavioral guardrails—in a version-controlled repository. The industry-standard format for this is emerging as mcp.jsonc , a JSONC (JSON with Comments) file that defines an agent's Model Context Protocol tools and memory

2026-07-27 原文 →
AI 资讯

Electricity Planning Engine, part 2: A Reader Comment Found a Real Gap in My Test Suite (and How I Fixed It)

I wrote about the Electricity Planning Engine a little while back, including a timezone bug that made a correct price look "not found" after a database round trip. A few days later, Alex Shev left this comment: Timezone bugs are brutal in planning engines because the result can look mathematically correct while being operationally wrong. Energy workflows especially need tests around boundaries, not just averages. That is a genuinely sharp way to put it, and it is not just a comment about the bug I already wrote about. It is a comment about how I test the project in general, and I did not like how well it applied once I went and checked. The part that stung a little "Looks mathematically correct while being operationally wrong" is exactly what the original timezone bug was. PriceSeries::priceAt() threw a clean "price not found" error, which is arguably the good version of that failure mode: loud, easy to catch, hard to ship. A quieter version of the same class of mistake, off by one hour instead of missing entirely, would not throw anything. It would just return a plan that looks completely reasonable and is wrong the entire time it runs. Alex's second point, boundaries over averages, is the one I actually had to go check rather than just agree with in the abstract. So I opened tests/Unit/Domain/Contract/PricingStrategyTest.php and looked at every hour used in every peak/off-peak assertion: new DateTimeImmutable ( '2026-07-18 14:00:00' ) // peak new DateTimeImmutable ( '2026-07-18 23:00:00' ) // off-peak new DateTimeImmutable ( '2026-07-18 05:00:00' ) // off-peak 14:00, 23:00, 05:00. Every single one comfortably inside its window. None of them anywhere near the actual transition. The off-peak slot in the config is 22:00 to 06:00 , and the comparison behind that lives in TimeSlot::contains() : // wraparound slot, e.g. 22:00 -> 06:00 return $minuteOfDay >= $this -> startMinuteOfDay || $minuteOfDay < $this -> endMinuteOfDay ; That >= versus < is exactly the kind of one-

2026-07-27 原文 →
AI 资讯

Building Dashboards People Actually Use

I've built dozens of dashboards. Most have been ignored. A few have been used constantly. The difference isn't the graphs. It's the design. The 3-second test A useful dashboard answers 'is everything OK?' in 3 seconds. Not 'let me scroll through 40 graphs to find out.' Big colored header at the top: green = healthy, yellow = watching, red = broken. That's the 3-second answer. Everything else is drill-down. The hierarchy rule Three layers, no more: Overview — one line per service, status color, key SLI Service detail — one dashboard per service, 6-12 graphs max Deep dive — triggered from service detail, domain-specific Anything beyond 3 layers is 'please get lost in my dashboard tree.' The on-call test Imagine you're on-call at 3 AM. You get paged for 'service X is slow.' Can you, in 30 seconds, use this dashboard to tell if the problem is the service itself, its database, its upstream dependency, or its downstream consumers? If yes, the dashboard works. If no, redesign. What to cut Graphs with no baseline (flat line or spiky forever — how do you know if it's bad?) Metrics you've never used in an actual incident Vanity metrics (total requests ever) Graphs where the y-axis is in units nobody understands The hidden metric The real measure of a dashboard's value: does the on-call engineer open it before or after the paging tool? If they open it first — it's their compass. If they open it only after being paged — it's a reference, not a dashboard. Aim for the first. Written by Dr. Samson Tanimawo BSc · MSc · MBA · PhD Founder & CEO, Nova AI Ops. https://novaaiops.com

2026-07-27 原文 →
开发者

I'll be speaking at WordCamp US 2026 🎉

A few months ago, I submitted a talk proposal to WordCamp US without really knowing what to expect. Today, I'm happy to say that it was accepted, and I'll be speaking at one of the largest WordPress conferences in the world. WordCamp US has always been one of the events I've looked up to in the WordPress ecosystem. As someone who has spent over a decade building content platforms with WordPress, contributing to open source, and working with teams across different countries, having the opportunity to share my experience on that stage is something I don't take for granted. My session is: Stop Blaming WordPress: Building a Real Editorial Workflow Without Leaving the Ecosystem Throughout my time working with WordPress, I've noticed a recurring pattern. When editorial teams struggle to publish content efficiently, WordPress often gets the blame. But after working with organizations of different sizes, I've learned that the CMS is rarely the real problem. The real challenges are usually: disconnected editorial processes; unclear content ownership; missing approval workflows; inconsistent governance; too much reliance on manual work. In this session, I'll share practical strategies for building scalable editorial workflows while keeping WordPress at the center of the ecosystem. The goal isn't to introduce another platform, it's to make the existing one work better. Speaking at WordCamp US is especially meaningful because I've been part of the WordPress ecosystem for many years. Being able to give something back to this community is an opportunity I'm genuinely grateful for. If you'll be at WordCamp US 2026 in Phoenix, I'd love to connect. 🎟️ Get your ticket: https://us.wordcamp.org/2026/tickets/ 💸 Use my speaker discount: speaker-friend20 during checkout for a discount on your ticket. See you at WCUS! 🚀

2026-07-27 原文 →
AI 资讯

Deploying to AWS Lightsail with a Docker image from ECR

Lightsail is a good home for a single small container: flat pricing, bandwidth included, and none of the VPC/security-group ceremony of EC2. The one rough edge is pulling a private image from Amazon ECR , because a standard Lightsail instance can't authenticate to ECR the way EC2 can. This post walks the whole path. The pipeline we're building: docker build ──push──> ECR (private repo) ──pull──> Lightsail instance ──run──> container What you'll need An AWS account and the AWS CLI installed locally. Docker installed locally (to build) and on the Lightsail box (to run). A Dockerfile that produces a runnable image. If you're deploying a Next.js app, a standalone output image works well. 1. Create the ECR repository ECR is a private Docker registry. Create one repository per image: aws ecr create-repository \ --repository-name project-name \ --region us-east-1 Note the repositoryUri in the output — it looks like: <account-id>.dkr.ecr.us-east-1.amazonaws.com/project-name You'll use that URI everywhere below. Export it to save typing: export ECR_URI = <account-id>.dkr.ecr.us-east-1.amazonaws.com/project-name export AWS_REGION = us-east-1 2. Build the image locally First, the Dockerfile . This is a multi-stage build for a Next.js app using output: "standalone" — the first stage installs dependencies and builds, the second copies only the traced runtime files into a slim image that runs as a non-root user: FROM node:24-alpine AS builder WORKDIR /app COPY package*.json ./ RUN npm ci COPY . . RUN npm run build FROM node:24-alpine WORKDIR /app ENV NODE_ENV=production ENV PORT=3000 ENV HOSTNAME=0.0.0.0 # Standalone output ships only the traced files needed to run the server. # public and .next/static are not included by default and must be copied in. # --chown makes the files writable by the non-root user so Next.js can write # its runtime cache to /app/.next/cache. COPY --from=builder --chown=node:node /app/public ./public COPY --from=builder --chown=node:node /app/.next/stand

2026-07-27 原文 →
AI 资讯

Talk to Your DNA: Building a Genomic RAG Pipeline with LlamaIndex and ClinVar

Have you ever looked at your raw DNA data from services like 23andMe or Ancestry.com and thought, "What on earth am I looking at?" Behind those megabytes of .txt or .vcf files lies the blueprint of you , but without a PhD in genetics, it's just a wall of "A, C, T, G." In this tutorial, we are going to bridge the gap between raw genomic noise and actionable insights. We’ll build an advanced Genomic RAG (Retrieval-Augmented Generation) pipeline. By the end, you'll have a system that takes raw SNP (Single Nucleotide Polymorphism) data, retrieves clinical significance from the ClinVar database, and generates an interactive risk guide using LlamaIndex and FAISS . If you are interested in Genomic Data Engineering , Bioinformatics with Python , or RAG (Retrieval-Augmented Generation) , this guide is for you. The Challenge: The "Needle in a Haystack" Problem A typical human genome has millions of variants. Most are harmless "junk" DNA, but some are "Pathogenic." Searching for these manually is impossible. We need a system that: Parses massive genomic files efficiently. Indexes trusted medical databases (ClinVar). Matches your specific variants against that knowledge base to provide context. The Architecture 🏗️ Here is how our data pipeline flows from raw pixels (well, raw base pairs) to structured insights: graph TD A[Raw SNP Data / VCF File] --> B(Pandas & Biopython Parser) B --> C{Filter High-Impact Variants} D[ClinVar Clinical Database] --> E(LlamaIndex Indexing) E --> F[FAISS Vector Store] C --> G[RAG Query Engine] F --> G G --> H[LLM: GPT-4o Synthesis] H --> I[Interactive Risk Report] Prerequisites 🛠️ To follow this advanced guide, you'll need: Tech Stack : Python 3.9+, Pandas, LlamaIndex, FAISS, and Biopython. Data : A sample VCF file (you can download public datasets from the 1000 Genomes Project) or your own exported 23andMe data. Step 1: Parsing the Genetic "Nonsense" First, we need to handle the raw data. 23andMe usually provides a tab-separated file. We use Panda

2026-07-27 原文 →
开发者

I don’t know what to do

I wanted to make a project for stardance hack club but I don’t know exactly what. I know a little bit of almost everything because im not decided what I want to really be good at yet. I know cpp pretty well, little bit of c#, some php, html, css, js. I also know basics of CAD, I like arduino, desktop apps and web apps. I don’t have any idea for anything that isn’t already there and is interesting. Pls help me submitted by /u/Blazej_kb [link] [留言]

2026-07-27 原文 →
AI 资讯

ChatGPT Work Raises Enterprise Questions on Automation, Governance and Rollout

OpenAI's ChatGPT Work materials have put a familiar enterprise question into sharper focus: how far can an AI assistant move from answering prompts to supporting coordinated, multi-step work? The supplied research identifies official OpenAI documentation covering capabilities, governance and enterprise rollout, but it does not establish a complete public feature list, pricing model or availability schedule. For prospective buyers, that makes disciplined evaluation more useful than assumptions about what the offering may eventually automate. The interest is understandable. A workplace AI product that can help teams turn requests into coordinated plans, reusable outputs or connected workflows could affect knowledge work well beyond individual chat sessions. But the available material does not substantiate specific claims about autonomous web or app generation, collaborative trip planning, or the exact scope of automation. Those scenarios should be treated as possible use cases to evaluate, not confirmed ChatGPT Work functionality. What the available ChatGPT Work materials establish The most reliable starting point is OpenAI's ChatGPT Work product page . According to the supplied research, OpenAI's official materials describe ChatGPT Work in the context of capabilities, governance and enterprise rollout . That framing matters because enterprise AI adoption is not solely a model-performance decision. It also involves how a tool fits existing systems, who can use it, what data it can access, and how organizations retain operational control. The research does not provide enough detail to verify particular integrations, permission settings, security certifications, pricing, regional availability or release dates. Enterprises should therefore avoid treating broad product positioning as a procurement specification. The practical question is whether the official documentation and commercial terms available at the time of evaluation answer the organization's specific requireme

2026-07-27 原文 →
AI 资讯

Following ROWIDs Through an Oracle Unique Index Update

I've always been amazed by how Oracle Database handles updates to a unique column—performing set-based operations that don't violate the unique constraint, yet when executed row by row, it temporarily permits duplicates. SQL > create table franck ( val int unique ); Table created . SQL > insert into franck values ( - 1 ) , ( 1 ) ; 2 rows created . SQL > select val from franck ; VAL ---------- - 1 1 SQL > update franck set val =- val ; 2 rows updated . SQL > select val from franck ; VAL ---------- 1 - 1 From a SQL perspective, this is expected behavior, but not all databases support it without raising an error: Db2 , SQL Server , and Oracle handle it without error. PostgreSQL raises ERROR: duplicate key value violates unique constraint "franck_val_key", DETAIL: Key (val)=(1) already exists. This works with a deferred constraint. MySQL or MariaDB raise Duplicate entry '1' for key 'franck.val' SQLite raises { "code": "SQLITE_CONSTRAINT_UNIQUE" } MongoDB raises E11000 duplicate key error collection: test.franck index: val_1 dup key: { val: 1 } db . franck . createIndex ({ val : 1 }, { unique : true }); db . franck . insertMany ([ { val : - 1 }, { val : 1 } ]); db . franck . updateMany ({},[ { $set : { val : { $multiply :[ " $val " , - 1 ]} } } ]); MongoServerError : Plan executor error during update :: caused by :: E11000 duplicate key error collection : test . franck index : val_1 dup key : { val : 1 } This is surprising because Oracle unique indexes store the indexed columns as the B-tree key and the ROWID as the associated data. Non-unique indexes add the ROWID to the physical key and are required for a deferrable unique constraint to allow temporary duplication before the end of the transaction. So how do non-deferrable unique indexes allow duplication during a single update statement? In this simple example, I would expect: The initial index entries are: (-1): row #1 and (1): row #2 Updating the first row deletes the first entry (-1): row #1 and adds one with (1):

2026-07-27 原文 →
AI 资讯

Vibe Coding Won't Kill Developers. It'll Kill the Middle.

When good cameras got cheap, everyone predicted the death of professional photography. The prediction landed wrong. The low end died outright: stock libraries, cheap portraits, mass-event coverage went to anyone with a phone and a free editing app. The high end did better than ever — editorial work, photojournalism with access nobody else had, an aesthetic you could not reproduce by buying the same gear. The damage landed in the middle. Small weddings, corporate headshots, real estate listings, the steady unglamorous bulk of the market: not extinction, compression. Prices fell, volume moved to cheaper substitutes, and the survivors climbed up or specialized out. That compression is the cleanest map I know for what AI-assisted coding is doing to software work. And this half I know from inside: two decades leading dev teams, and now building AI tooling for them. The comfortable half of the argument The reassuring version of this is everywhere right now: you were never paid to type, you were paid to think, so AI just frees you to do the valuable part. It's not wrong. It's just the half that's easy to hear. The other half is about the market, not about you. Judgment, architecture, knowing what breaks in maintenance, deciding what not to build — a model that writes plausible code on command doesn't commoditize any of that. I have watched weeks of confusion land on people who could not read what a capable model generated; the gap was never the tool, and better AI autocomplete does not close that gap. But "judgment beats typing" answers only a question about skill and dodges the question about market structure. AI doesn't replace developers as a class; it commoditizes a segment. The segment it hits first is the same one the camera hit: the middle. The junior-to-mid tier that lived on CRUD apps, simple integrations, brochure sites, the standard internal tool with a form and a table behind it. That work was always implementation against a known spec, and implementation again

2026-07-27 原文 →
AI 资讯

Next.js Middleware in 2026: Auth Guards, A/B Tests, and What Belongs at the Edge

Headline: Next.js Middleware (middleware.ts at the project root) runs before every matched request — before cache, before rendering, before the route. That position makes it right for auth redirects, A/B cookie bucketing, and locale detection. Wrong for database queries and heavy imports. In 2026, Middleware on Vercel runs on Fluid Compute (standard Node.js), so the constraint is latency budget, not API availability. Key takeaways Middleware runs before every matched request — before cache, rendering, or route handler — the right layer for auth, locale, and A/B bucketing. Middleware can read requests, set cookies, redirect, rewrite, or return early — without the route running. DB queries and large packages add latency to every request. On Vercel in 2026, Middleware runs on Fluid Compute (standard Node.js). The constraint is latency: every added millisecond is paid on every matched request. Use matcher to scope Middleware to only the routes that need it; without it Middleware runs on every static asset request. Auth in Middleware = verifying a self-contained JWT without a DB call. Full session validation belongs in the route. I spent a long time only using Middleware for locale redirects. After shipping auth-protected routes and an A/B test, the full shape became clear. What is Next.js Middleware and where does it run? Middleware is exported from middleware.ts at the project root. It intercepts matched requests before route resolution, cache lookup, and Server Component execution. Returns one of four types: pass through ( NextResponse.next() ), redirect, rewrite (serve different content while keeping original URL in address bar), or a direct response. export function middleware ( request : NextRequest ) { return NextResponse . next (); } export const config = { matcher : [ ' /((?!_next/static|_next/image|favicon.ico).*) ' ], }; Without matcher , Middleware runs on every request including static files. On Vercel in 2026, Middleware runs on Fluid Compute — standard Nod

2026-07-27 原文 →
AI 资讯

The Distributed Systems Challenge of Post-Quantum Cryptography

Encrypted data stored in cloud archives today will outlive the mathematical algorithms guarding it. In enterprise architectures that handle long-term records, like construction risk logs or employee compliance platforms, data retention schedules often span twenty to thirty years. When building cloud pipelines that move this information across services, we depend heavily on asymmetric encryption, which is a security method using one public key to lock data and a separate private key to unlock it. Standard public-key algorithms rely on mathematical problems that are nearly impossible for classical computers to solve within a reasonable human timeframe. Quantum computing changes this equation entirely. Quantum computers leverage quantum mechanics, the physical rules governing subatomic particles, to perform calculations at speeds fundamentally unimaginable with traditional silicon processors. While powerful quantum systems are still in development, the security threat to distributed systems exists today. Hostile actors do not need to crack modern security algorithms in real time. Through a pattern known as Harvest Now, Decrypt Later, adversaries can capture and store encrypted network traffic right now. They simply wait until future quantum hardware becomes capable of running the formulas required to decrypt that stolen history. For software architects, preparing for post-quantum cryptography, which refers to new mathematical encryption algorithms designed to withstand quantum attacks, is far more than a simple library swap. It is a deep distributed systems migration challenge. The primary operational hurdle is payload size and computational overhead. Quantum-resistant algorithms require significantly larger digital keys and payload headers than the standards we rely on today. When cryptographic payloads expand, every component of a distributed platform feels the ripple effect. Message queues experience higher bandwidth demands. Database indexes inflate. Memory consump

2026-07-27 原文 →
AI 资讯

Your agent's instructions are promises nobody checks. I counted.

I didn't set out to build a developer tool. For a long time now I've been working with AI on everything in my life — daily conversations about my daughters, planning projects, ideas for ones that don't exist yet. The goal was always the same: ease my life, get more done, and break the barrier between human and AI — stop treating it as a search box, start treating it as a partner. Somewhere along the way, the partnership got serious. The workspace where my projects live grew an instruction system for AI coding agents — the files everyone is writing now: AGENTS.md , CLAUDE.md , a skills directory, rules for how agents should plan, log, and verify their work. Then I asked an uncomfortable question: is any of it actually followed? Not "do the agents seem to follow it." Could anyone tell , from the repository alone, whether an instruction was followed? For most of my rules, the answer was no. My own audit found that the two checks my instructions said must run before every commit were invoked by nothing — no CI, no hook, no scheduled task. The rule had been enforced, for its entire life, by whoever remembered. Replaying my last 200 commits, the index-freshness rule alone would have failed on 29 of 61 eligible commits — roughly half. My instructions were not rules. They were hopes with formatting. So I wondered whether everyone else's are too. I wrote a tool and measured. What I measured, and the two honest limits that come before the numbers I analysed eight public agent-instruction collections — 1,332 instruction units, 17,611 individual instructions — each at a pinned commit SHA, with the raw per-repo JSON published alongside the tool. An instruction counts as CHECKABLE if a reviewer could tell from the repo whether it happened: it's a tick-box, or contains a runnable command, or names a concrete file artifact, or refers to an exit code, a diff, an assertion. Everything else is CLAIMABLE — the only evidence it happened is the agent saying so. Two limits, before any num

2026-07-27 原文 →