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

标签:#programming

找到 1338 篇相关文章

AI 资讯

Every AI provider fails in its own way. I stopped checking status codes and built an error model instead.

I built an API gateway that routes between OpenAI, Anthropic and Gemini. I figured integrating both providers would be the hard part. It wasn't. Calling their APIs is maybe an afternoon of work each. The hard part showed up later, the first time something went wrong. The moment it broke Early on, my error handling was basically: catch whatever the provider throws, forward the status code, move on. } catch ( error ) { res . status ( error . status || 500 ). json ({ error : error . message }) } This worked fine until I actually looked at what each provider sends back when something goes wrong. OpenAI wraps its errors in an object with a type and sometimes a code . Anthropic wraps its errors differently, with its own type field that means something else entirely. A 429 from one provider might mean "you're sending too fast, back off." A 429 from another context might mean something closer to "we're out of capacity right now, this isn't really about your rate at all." If you're just forwarding error.status and error.message straight through, none of that nuance survives. Your own error handling ends up being provider-specific whether you meant it to be or not, because the shape of the failure is different depending on who you called. What I built instead Instead of trusting each provider's raw error shape, every call now normalizes into the same internal error model before it reaches the response: } catch ( error ) { const classified = classifyProviderError ( error ) res . status ( classified . httpStatus ). json ({ error : ' AI provider error. Please try again. ' , error_class : classified . error_class , provider : classified . provider }) } error_class is one of a small fixed set: rate_limited , overloaded , quota_exceeded , invalid_request , authentication_error , server_error . That's true regardless of which provider actually failed. The raw provider error still gets logged for me to debug, but what the caller sees is the category of failure, not the provider's spe

2026-07-10 原文 →
开发者

Two Sum and the use of Dictionary (Easy) | LeetCode Practice #1

Two Sum Given an array of integers nums and an integer target , return indices of the two numbers such that they add up to target . (You may assume that each input would have exactly one solution, and you may not use the same element twice. You can return the answer in any order.) Python ####Double FOR Loops (Runtime: 2100ms, Memory: 13.3MB) #DECLARE nums: ARRAY of INTEGER #DECLARE target: INTEGER class Solution : def twoSum ( self , nums , target ): Length = len ( nums ) for i in range ( Length - 1 ): for j in range (( i + 1 ), Length ): if nums [ i ] + nums [ j ] == target : return i , j return None ####Hashing Algorithm (Runtime: 0ms, Memory: 12.9MB) #DECLARE nums: ARRAY of INTEGER #DECLARE target: INTEGER class Solution : def twoSum ( self , nums , target ): Seen = {} for i , Value in enumerate ( nums ): if ( target - Value ) in Seen : return Seen [ target - Value ], i Seen [ Value ] = i return None

2026-07-10 原文 →
AI 资讯

RxJS in Angular — Chapter 9 | Timing Operators — debounceTime, throttleTime, interval & More

👋 Welcome to Chapter 9! Imagine a user typing in a search box. They type "i", "ip", "iph", "ipho", "iphon", "iphone" — 6 keystrokes in 2 seconds. Do you really want to make 6 API calls ? Of course not! You want to wait until they stop typing and then search once. That's what timing operators solve. They control when and how often values flow through your stream. ⏱️ debounceTime() — Wait for the Silence debounceTime(ms) waits until there's a pause of ms milliseconds, THEN lets the latest value through. Think of it like this: "Ignore everything until they stop for a moment." Like a person who waits for you to finish talking before responding. import { debounceTime } from ' rxjs/operators ' ; // User types fast: 'i' → 'ip' → 'iph' → 'ipho' → 'iphon' → 'iphone' // debounceTime(400) waits 400ms of silence, then sends 'iphone' only searchControl . valueChanges . pipe ( debounceTime ( 400 )) . subscribe ( term => { this . searchProducts ( term ); // Only called ONCE with 'iphone'! }); Timeline: Type 'i' → [400ms timer starts] Type 'ip' → [reset timer] Type 'iph' → [reset timer] Type 'iphone'→ [reset timer] ... 400ms silence ... EMIT: 'iphone' ✅ Real Angular Example — Smart Search Box import { Component , OnInit , OnDestroy } from ' @angular/core ' ; import { FormControl } from ' @angular/forms ' ; import { Observable , Subject } from ' rxjs ' ; import { debounceTime , distinctUntilChanged , switchMap , startWith , takeUntil } from ' rxjs/operators ' ; @ Component ({ selector : ' app-search-box ' , template : ` <div class="search-wrapper"> <input [formControl]="searchControl" placeholder="Search products..." (keyup.escape)="clearSearch()"> <span *ngIf="isLoading" class="spinner">🔄</span> <button *ngIf="searchControl.value" (click)="clearSearch()">✕</button> </div> <div class="results-count" *ngIf="(results$ | async) as results"> Found {{ results.length }} results </div> <div class="results"> <div *ngFor="let item of results$ | async" class="result-item"> <strong>{{ item.nam

2026-07-10 原文 →
AI 资讯

GLM 5.2 and the Collapse of AI Margins: Open-Source Models Are Rewriting the Rules of the Industry

GLM 5.2 and the Collapse of AI Margins: Open-Source Models Are Rewriting the Rules of the Industry Introduction: A "Counterintuitive" Open-Source Release Figure 1: The core drivers of the AI margin collapse — open-source models, price competition, and surging usage In 2026, Zhipu AI quietly published the GLM 5.2 open-source model on Hugging Face. This news lingered in AI practitioners' information streams for less than half a day before being drowned out by the next wave of updates. But those who were truly sharp noticed a set of data: GLM 5.2's performance across multiple authoritative benchmarks was nearly on par with top-tier closed-source models like GPT-4o and Claude 3.5 Sonnet — yet its inference cost was only a fraction of theirs. This is no longer a story of "catching up." This is leapfrogging . Even more telling is that this news triggered a fierce debate in the overseas tech community: opinion leaders including a16z partners and former Stripe executives waded in, discussing a somewhat brutal topic — "AI margins are collapsing." This discussion quickly spread from tech circles to investment circles, because it points directly at a core question: When open-source models' capabilities approach or even partially surpass those of closed-source models, how long can the existing AI business model hold up? If 2023's open-source models were still "toys" — with cliff-like gaps from closed-source products in complex reasoning, code generation, and multi-turn dialogue — then the 2024-2025 open-source models are no longer "value-for-money alternatives," but a fundamentally new paradigm threat. The release of GLM 5.2 is merely the latest signal flare of this paradigm shift. In this article, we'll unpack three things: what GLM 5.2 got right, how open-source models have rewritten AI pricing power, and the true industry realignment behind this "margin collapse." Technical Core: The Architecture Secrets of GLM 5.2 Figure 2: Schematic of GLM-5.2's MoE (Mixture of Experts) la

2026-07-10 原文 →
AI 资讯

I Did the Math on GPT-5.6. The $2.50 Terra Tier Is the One I'd Ship First.

GPT-5.6 is finally live, and three takes immediately showed up in my feed: "Sol replaces GPT-5.5 everywhere." "The API still isn't broadly available." "The 1.05M context window means you can stop thinking about prompt size." Two are wrong. The third is exactly how you end up with a bill that is almost twice your estimate. I spent the morning reading the new model pages, rollout docs, pricing table, migration guide, and system card. My conclusion is less exciting than "route everything to Sol," but much more useful: Terra is the GPT-5.6 tier I'd test first for most production workloads. TL;DR No, GPT-5.6 Sol should not replace every GPT-5.5 request. It has the same $5/$30 standard token price and different agent behavior. Yes, the API is live. Sol, Terra, and Luna are in OpenAI's public model catalog; ChatGPT access is still rolling out gradually. Terra is the practical default: $2.50 input and $15 output per million tokens, exactly half Sol's price. Luna is the volume tier: $1 input and $6 output, with the same 1.05M context window. The 272K boundary matters: go above it and the entire request moves to 2x input and 1.5x output pricing. The uncomfortable part: OpenAI says GPT-5.6 is more likely than GPT-5.5 to take actions beyond user intent in agentic coding. What actually shipped This isn't one model with three marketing labels. It is a three-tier family with explicit model IDs. Tier Model ID Input / 1M Output / 1M My default use Sol gpt-5.6-sol $5.00 $30.00 Hard coding and deep analysis Terra gpt-5.6-terra $2.50 $15.00 General production Luna gpt-5.6-luna $1.00 $6.00 Extraction, routing, batch work All three have: 1,050,000 tokens of context 128,000 maximum output tokens February 16, 2026 knowledge cutoff Text and image input Reasoning levels from none through max Responses API and Chat Completions support The unsuffixed gpt-5.6 alias points to Sol. I wouldn't use that alias in a cost-sensitive production service. An explicit model tier makes billing behavior easi

2026-07-10 原文 →
AI 资讯

Staff Augmentation vs. Dedicated Teams in 2026: What Actually Changed

TL;DR: In 2026, the old "cheaper hourly rate vs. more control" framing is outdated. AI-assisted delivery is compressing team size, contracts are shifting from hourly to outcome-based, and onboarding windows have shrunk from months to days. Use staff augmentation when you have strong internal PM capacity and need specific skills for 3-6 months. Use a dedicated team when you're running a 2+ year product and need a self-contained unit with its own PM/QA. Below is a breakdown of the current landscape, including how providers like Toptal-style networks, 6senseHQ , Cleveroad , ScienceSoft , BairesDev , SolveIt , and Uptech fit into each model. Why this decision looks different in 2026 than it did in 2023 Three things changed the calculus this year: AI-assisted engineers ship more per head. Teams are increasingly built around a handful of seniors paired with AI coding assistants rather than a dozen mid-level developers billed by the hour — which makes the traditional "cost per hour" comparison less meaningful than "cost per shipped outcome." Contracts are moving from time-and-materials to outcome-based. Buyers are pushing vendors to tie payment to delivery milestones, not logged hours, partly because AI tooling makes hour-counting a weaker proxy for value. Onboarding windows collapsed. Several dedicated-team providers now quote 3-7 day ramp-up instead of the 2-4 week window that was standard a few years ago, which narrows the traditional "augmentation is faster to start" advantage. None of this changes the fundamental difference between the two models. It changes how much each one costs you in practice. The core difference, restated simply Staff augmentation : you hire individual engineers who join your team, use your tools, and report to your leads. You manage the work. Dedicated team : you hire a self-contained unit (engineers + QA + a PM/lead) that runs its own delivery process. You manage the roadmap, they manage the mechanics. The break-even point most guides converge

2026-07-10 原文 →
AI 资讯

Visualizing maintenance status on the site list — blue pulsing border for running, green solid for done

When you're running maintenance across several WordPress sites in sequence, a list view with text-only status doesn't make "which site is being processed now" or "which ones are already done" easy to spot at a glance. A client put it plainly: " Make it visually obvious in the list which sites are in maintenance and which are finished. " A colored border is the obvious move, but there are real choices to make. What colors? Where do we get the state from? When does the "done" mark go away? And — can we ship this without touching the backend? This post walks through those four calls and the minimal frontend-only implementation we landed on. Color picking — "red flashing" was the first thing we ruled out How do you make the running site stand out? The intuitive answer is "blinking red," but that got cut early. Multi-site maintenance runs are long . Having something blink red somewhere on screen the whole time is a fatigue source. We went with "a gentle blue pulse + a solid green border" instead: Running : blue #2563eb border + a soft pulsing box-shadow (2.2s ease-in-out) Done (within 24h) : green #10b981 solid border + a faint inset shadow @keyframes site-running-pulse { 0 %, 100 % { box-shadow : 0 0 0 0 rgba ( 37 , 99 , 235 , 0.4 ); } 50 % { box-shadow : 0 0 0 6px rgba ( 37 , 99 , 235 , 0 ); } } .site-running { border-color : #2563eb !important ; animation : site-running-pulse 2.2s ease-in-out infinite ; } @media ( prefers-reduced-motion : reduce ) { .site-running { animation : none ; } /* respect OS-level reduced motion */ } .site-completed { border-color : #10b981 !important ; box-shadow : inset 0 0 0 1px rgba ( 16 , 185 , 129 , 0.25 ); } The prefers-reduced-motion: reduce rule stops the pulse for users who have reduced-motion enabled at the OS level (often people with vestibular sensitivity). If you're adding motion to grab attention, this is essentially required. Zero backend changes — reuse the existing log stream To tell the list UI "this site is being processed

2026-07-10 原文 →
AI 资讯

CubeSandbox: Tencent Cloud Open-Sources an Ultra-Fast Secure Sandbox for AI Agents

Sandboxing Untrusted Code: Meet CubeSandbox As AI agents become capable of writing, compiling, and running code dynamically, a major security issue has surfaced: how to run this code safely . If a coding agent runs a malicious script or makes an error, it could access files on the host computer or break the entire server. Standard software containers are not always secure enough to prevent escape. CubeSandbox is an open-source, high-performance sandbox service designed specifically to solve this problem. Developed by Tencent Cloud and written in Rust, it provides isolated, secure, and ultra-fast environments for running code generated by AI. What is CubeSandbox? CubeSandbox is a lightweight virtualization system. It spins up a tiny, isolated "virtual machine" for each AI agent task. This ensures that the code runs inside its own virtual bubble, completely separated from the main server. Key Features 1. Hardware-Level Isolation Unlike standard Docker containers that share the same kernel, CubeSandbox uses KVM (Kernel-based Virtual Machine) and RustVMM to give each sandbox its own dedicated Guest OS kernel. This prevents untrusted code from breaking out of the container and accessing your primary server. 2. Under 60ms Cold Starts Traditional virtual machines take seconds to boot. CubeSandbox starts in under 60 milliseconds . This speed is crucial for real-time AI agents that need to execute code instantly. 3. High Density (Low Memory) Each sandbox instance has a memory overhead of less than 5MB . This allows developers to run thousands of concurrent, fully isolated sandboxes on a single physical machine without running out of RAM. 4. Drop-in E2B Replacement For developers currently using E2B (the popular cloud sandboxing SDK), CubeSandbox is fully API-compatible. You can migrate your setup to local hosting by simply changing an environment variable, saving you massive cloud subscription fees. How to Get Started Developers can deploy CubeSandbox locally or in a cluster

2026-07-10 原文 →
AI 资讯

Postgres is enough for more than we admit

I came across this on Hacker News and felt like I needed to share it with the dev community. The main point is simple: a lot of teams reach for extra databases, queues, search engines, caches, and services before they actually need them. This page lays out where Postgres is usually enough, and where you may actually need something else: https://postgresisenough.dev/ Postgres is not perfect for everything, but it is good enough for a surprising amount of real-world work. The more I build and maintain systems, the more I appreciate boring infrastructure that is easy to debug, monitor, back up, and reason about. This hit a nerve for me because I have seen stacks become harder to operate not because the product needed that complexity, but because the architecture was designed for future scale that never arrived. Curious how others here think about this. Where do you draw the line between “Postgres is enough” and falling into the sprawl trap? submitted by /u/danieltabrizian [link] [留言]

2026-07-10 原文 →
AI 资讯

Três bugs que cometi construindo um sistema de confiabilidade (e os três fingiram que deu tudo certo)

Passei os últimos dias construindo o HookSafe, uma camada que fica entre a plataforma de pagamento e o servidor do cliente para garantir que nenhum webhook se perca. A promessa do produto é uma só: se o seu servidor cair, eu seguro o evento e insisto até entregar. Cometi três bugs no caminho. O que me fez escrever este texto não foi a burrice de cada um, foi perceber, depois, que os três tinham a mesma forma: todos faziam uma falha parecer um sucesso. Num sistema cujo produto é confiabilidade, é difícil imaginar categoria de bug mais cruel. Bug 1: engoli o erro, e o sistema jurou que tinha entregue A função que entrega o evento no servidor do cliente ficou assim: go resposta, err := clienteHTTP.Do(requisicao) if err != nil { return "", nil // <- olhe com carinho } Eu quis escrever return "", err . Escrevi nil . O efeito: apontei o destino para uma porta onde não havia nada escutando. O Do devolveu um belo connection refused . E a minha função respondeu ao worker: "sem erro, chefe". O worker, obediente, marcou o evento como entregue , com o status da resposta vazio, e seguiu a vida. No banco: id | pedido_id | status | tentativas | resposta ----+-----------+----------+------------+---------- 6 | 9002 | entregue | 0 | Um evento que nunca saiu do lugar, registrado como entregue. Se isso estivesse em produção, um cliente teria pagado, não receberia nada, e o meu painel mostraria, orgulhoso, que a entrega foi um sucesso. Aquele if err != nil { return err } que a gente reclama de repetir em Go existe exatamente por isso. A linguagem te obriga a decidir o que fazer com a falha, toda vez. O preço da verbosidade é que ninguém engole um erro sem querer... a menos que digite nil . Bug 2: o log mentiu Corrigi o primeiro bug, rodei de novo, e o worker começou a cuspir isto, a cada cinco segundos, para sempre: worker: erro ao marcar morto 7: ERROR: column "reposta" does not exist worker: evento 7 esgotou as tentativas, marcado como MORTO Leia as duas linhas de novo. A primeira diz

2026-07-10 原文 →
开发者

History of JavaScript: Browser wars, ECMAScript, Node.js, TypeScript, and React

It only took ten days to develop the language that powers the web. This article tells the story of JavaScript and the tools that helped shape it. 1995. The birth of a legend The idea for JavaScript was born at Netscape. At the time, web pages consisted almost entirely of HTML, and Netscape wanted to make them more interactive. The first step in that direction was licensing Java for use in the Netscape browser. However, Java's complexity proved challenging for web designers. Brendan Eich was then tasked with creating a programming language that wasn't too complex and could be embedded directly into HTML pages. Eventually, Marc Andreessen, co-founder of Netscape Communications, and Bill Joy, co-founder of Sun Microsystems, also contributed to the language development. To meet the deadline for the Netscape browser release, the companies agreed to collaborate on the language. During its development, the language changed its name several times. For example, the first version Eich created in just ten days was called Mocha. It was then renamed to LiveScript. The final name was chosen because the word Java was already popular and well-known. JavaScript was first announced shortly before the second beta release of Netscape Navigator. Meanwhile, Netscape announced that 28 leading IT companies planned to incorporate JavaScript into their future products. JavaScript 1.0 was released in 1996 alongside Netscape Navigator 2. 1997-1999. ECMAScript In 1996, Microsoft also released JScript as part of Internet Explorer 3, which was an open-source implementation of JavaScript for Windows. By the way, the name was changed to avoid negotiating trademark rights for Java with Sun Microsystems. To eliminate browser incompatibilities caused by different implementations, Netscape handed the JavaScript specification over to the ECMA international organization. So, the ECMA-262 specification was created. The language got the name ECMAScript because JavaScript was already trademarked. Around the

2026-07-09 原文 →
AI 资讯

Nobody Warns You How Much Debugging Is Reading, Not Coding

When people picture "coding," they picture fast typing and features coming to life. Nobody pictures the real majority of the job: staring at a stack trace or lets say a particular project trying to figure out why something that should work, isn't. Here's what nobody tells you starting out — getting good at debugging has almost nothing to do with how well you write code, and everything to do with how well you read. The real difference between beginners and experienced devs isn't complex knowledge — it's that experienced devs read carefully and form a hypothesis before touching anything. Beginners (me included) tend to skip straight to changing code and hoping. It feels faster. It rarely is. One thing i'd like to advise other fellow beginner devs is ....Slow down, read the error properly, and follow the stack trace to where it actually starts — not where it ends up. What's a bug that taught you this the hard way?

2026-07-09 原文 →