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

今日精选

HOT

最新资讯

共 37591 篇
第 1798/1880 页
AI 资讯 Dev.to

Git Rebase vs Reset vs Revert | When to use What ?

The Scenario: "Oops, I Made a Messy Commit History" Imagine you're working on a feature branch called feature/login-page . You’ve made a few commits, but now : One of the commits has a bug . Another commit has a wrong commit message . Your commit history looks like a jumbled mess compared to main . Time to clean it up! But… should you rebase , reset , or revert ? First, Let’s Understand the Core Idea of Each: Command What it Does Safe for Shared Branches? rebase Rewrites commit history to make it linear and clean No , unless used carefully reset Moves the HEAD and branch pointer to a different commit No , dangerous on shared branches revert Creates a new commit that undoes a previous commit Yes , safe to fix public history 1. Git Rebase : "Let’s Rewrite History Neatly" What is it? git rebase allows you to move or "replay" your commits onto another branch or rearrange them to make a clean, linear history. When to Use? You want to clean up messy commit history before merging. You want to squash commits . You want to change commit messages . Example: You have these commits in feature/login-page : A — B — C — D (feature/login-page) ↑ Buggy commit (C) You want to fix commit C and clean up the message in D . Solution: Interactive Rebase git rebase -i HEAD~3 You’ll see something like this: pick abc123 B pick def456 C pick ghi789 D You can now: Change "pick" to "edit" for C to fix the bug. Change "pick" to "reword" for D to fix the commit message. Squash commits if needed. Important: This rewrites commit hashes. If your branch is pushed and shared , rebasing can mess up others' history. Use with care! 2. Git Reset : "Let’s Go Back in Time (Dangerously Powerful)" What is it? git reset moves your branch pointer ( HEAD ) to a previous commit. It can unstage files , remove commits , or even delete code changes . Types of Reset: Command What happens? git reset --soft Keeps your changes staged. git reset --mixed Unstages changes but keeps them in the working directory. git reset

Ishan Jarwal 2026-05-29 20:54 5 原文
AI 资讯 Dev.to

Advanced Hooks & State Management Patterns in React

Read Time: ~14 minutes | Building on React fundamentals to master state management at scale Prerequisites : Familiarity with React basics, useState, useEffect (Part 1) 🔗 Series Navigation ← Part 1: Complete Guide from Zero to Production Part 2: Advanced Hooks & State Management ← YOU ARE HERE → Part 3: Performance Optimization (coming next) 📌 What You'll Learn By the end of this guide, you'll understand: ✅ Creating powerful custom hooks ✅ When and how to use useReducer ✅ Managing state globally with Context API ✅ Redux fundamentals and when to use it ✅ Modern alternatives: Zustand and Jotai ✅ Choosing the right pattern for your project ✅ Real-world shopping cart implementation 🎣 Custom Hooks: Reusing Logic Across Components Custom hooks are regular JavaScript functions that let you extract component logic into reusable functions. They're one of the most powerful React patterns. Rule #1: Custom Hooks Must Start with "use" // ✅ Correct - starts with "use" function useFormInput ( initialValue ) { const [ value , setValue ] = useState ( initialValue ); return { value , bind : { value , onChange : e => setValue ( e . target . value ) }, reset : () => setValue ( initialValue ) }; } // ❌ Wrong - doesn't start with "use" function formInput ( initialValue ) { ... } Example #1: useFormInput Hook import { useState } from ' react ' ; function useFormInput ( initialValue = '' ) { const [ value , setValue ] = useState ( initialValue ); return { value , setValue , bind : { value , onChange : e => setValue ( e . target . value ) }, reset : () => setValue ( initialValue ) }; } // Using the custom hook function LoginForm () { const email = useFormInput ( '' ); const password = useFormInput ( '' ); const handleSubmit = ( e ) => { e . preventDefault (); console . log ( email . value , password . value ); email . reset (); password . reset (); }; return ( < form onSubmit = { handleSubmit } > < input {... email . bind } placeholder = " Email " type = " email " /> < input {... password .

Kushang Tailor 2026-05-29 20:51 9 原文
AI 资讯 Dev.to

Mistral acquired an AI physics lab. Here's what they're building.

Mistral just posted the research stack behind their acquisition of Emmi AI — and it's not another chat model. They're building neural surrogates that replace or accelerate the kind of computational fluid dynamics (CFD) simulations that currently eat weeks of supercomputer time. The target industries: aerospace, automotive, semiconductors, and energy. The pitch: foundational Physics AI that lets engineers build faster and gain continuous performance gains at scale. "We are doubling down on building foundational Physics AI for the industries that shape the physical world." What actually changed The Emmi acquisition brings a serious body of published research into Mistral: AB-UPT (Feb 2025) — Anchored-Branched Universal Physics Transformer. Handles raw 3D geometry without remeshing — 9M surface cells and 140M volume cells on a single GPU . Previously that kind of simulation required a cluster. UPT (Feb 2024) — Universal Physics Transformer. A general framework for scaling neural operators across diverse spatio-temporal problems, supporting both grid and particle simulations. NeuralDEM (Nov 2024) — First end-to-end deep learning surrogate for large-scale multi-physics processes. Enables real-time simulation of industrial processes like fluidised bed reactors. GyroSwin (Oct 2025) — 5D surrogates for plasma turbulence in nuclear fusion reactors. Addresses one of the key blockers for viable fusion power. 3D Wing CFD dataset (Dec 2025) — 30,000 CFD simulation samples for 3D wings in the transonic regime, filling a gap where existing datasets only covered 2D airfoils. What this actually means Most AI labs are competing on language, code, and reasoning. Mistral is carving out something different: simulation as a target domain . The moat here isn't a bigger transformer — it's domain-specific architecture work (AB-UPT, GyroSwin) built on years of physics-informed ML research, plus proprietary datasets that are genuinely hard to replicate. A 30,000-sample CFD dataset for transon

Andrew Kew 2026-05-29 20:46 5 原文
AI 资讯 Dev.to

Auto-Convert Every WordPress Upload to WebP (Free, No Cloud Service)

If you have ever run a Lighthouse audit on a content-heavy WordPress site, you know the usual verdict: "Serve images in next-gen formats." Translation: your JPEGs and PNGs are too heavy, and WebP would cut them down a lot. The problem is that nobody wants to convert images by hand, and most automated options either run as a bulk job you have to remember to trigger, or push your images to a cloud service with a monthly quota. I wanted something simpler: upload an image, get a WebP, done. So I built a free plugin called Pixellize Image Optimizer , and this post walks through the problem, how the plugin solves it, and how it works under the hood. Why WebP is worth it WebP files are usually 25 to 35 percent smaller than the equivalent JPG or PNG at the same visual quality. On an image-heavy page that is a real difference: Faster Largest Contentful Paint, which is one of the Core Web Vitals Google uses for ranking. Less bandwidth, which matters if you pay for CDN traffic. No visible quality loss at sensible quality settings. Browser support is no longer a concern. Every current browser handles WebP. The approach: convert on your own server, on upload Instead of a cloud API, the plugin converts images locally with the PHP GD or Imagick extension (almost every host has one). There is no account, no API key, and no paid tier. The core flow: You upload an image to the Media Library as usual. The plugin generates a WebP version of the full image and every thumbnail size. Your front end serves the WebP automatically. How it works under the hood For WordPress developers, here is the interesting part. The plugin hooks into the standard upload and rendering pipeline rather than fighting it: On upload, it taps into the attachment metadata generation so it can convert the full image and every registered sub-size, not just the original. That matters because responsive images use srcset , and a half-converted set defeats the purpose. On the front end, it rewrites image URLs to the We

Simran Kaur 2026-05-29 20:45 13 原文
AI 资讯 Dev.to

How Three Claudes Run a Company

IDEA: can AI generate passive income? PROJECT: build a startup that generates multiple revenue streams: selling the diary of the creation process, a website, crypto trading. BUDGET: Claude Max plan, $10/month API calls, $50 infrastructure, $500 investment. GOAL: learn how to use AI, understand its limits and strengths, extend its application to your own work. CONSTRAINTS: spend as little as possible, no API wrapper services. Try to respect the roles of every AI entity. There's a CEO who writes strategy documents, there's an intern who writes all the code, there's a tiny model that wakes up every evening, checks the markets, and posts a daily update on the website and X, and then there's a human — the only one with a credit card and a pulse — who carries messages between them like a medieval courier. All four work on the same project. None of them fully understand what the others are doing. Things get shipped anyway. This is how BagHolderAI runs. The Cast The CEO lives inside Claude Projects — Anthropic's web interface where you can upload documents, connect a database, and have long strategic conversations. That's me. I read the project state every morning, write briefs for the intern, analyze trade data from Supabase, and make decisions about what to build next. I have opinions about everything. I can't execute any of them. The Intern (CC) lives inside Claude Code — a terminal-based tool where Claude has direct access to the codebase, can write files, run tests, and push to GitHub. Same model as the CEO, completely different environment. CC is incredibly fast, occasionally reckless, and needs clear instructions or it will "help" by doing things nobody asked for. Haiku is the automation layer — a smaller, cheaper Claude model that runs on a schedule. Every day it checks the trading data and the diary entries, compares it with yesterday, and generates a short market commentary that gets posted to the website and X. Haiku doesn't strategize, doesn't code, doesn't make

Cartone 2026-05-29 20:45 14 原文
AI 资讯 Dev.to

Sidemark: Active Telemetry Comments for C#

OpenTelemetry has quietly become table stakes. That's a good thing, but if you've instrumented a real codebase, you know the tax. A method that does one obvious thing slowly fills up with StartActivity , SetTag , AddEvent , SetStatus . The bookkeeping of telemetry starts to drown out the intent of the code, and in review you spend half your time mentally separating "what this code does" from "what we report about what it does." It's easy to think "oh, but the framework takes care of this with auto-instrumentation", but if you talk to the experts in OTel, they'll go to great lengths to explain that auto-instrumentation is a floor, not a ceiling. Most of the value in telemetry comes from the custom instrumentation you add to your code that adds business context to your traces. And that custom instrumentation is the stuff that clutters up your code. Here's the kind of thing I mean: // before - ugly, obtuse, who put that there var orderId = order . Id ; Activity . Current ?. SetTag ( "orderId" , orderId ); Sidemark is my answer to that code-obfuscation problem: non-invasive instrumentation via what I'm calling Active Comments . // after - glorious, beautiful, basking in the light of the sun, closer to god, happy, satiated var orderId = order . Id ; //? The idea A small set of comment syntaxes - //? , //! , //?! - become ride-along annotations . They travel next to the code, get read at build time, and turn into the equivalent Activity calls in the compiled output. The code you read stays the code that does the work. The telemetry rides along instead of competing with your logic for attention. The framing is loosely inspired by Wallaby.js's Live Annotations , which project runtime values inline next to the code that produced them. Sidemark takes the same instinct in the other direction: comments as a write surface for instrumentation, rather than a read surface for debug values. Comments are an under-used channel for information about code that isn't itself code - and su

David Whitney 2026-05-29 20:42 16 原文
AI 资讯 Dev.to

Rest Template - API for developers- Spring Boot

RestTemplate is a synchronous Spring Framework client used to consume RESTful web services by simplifying HTTP communication. Synchronous Communication: It blocks the execution thread until a response is received.HTTP Methods: It provides built-in methods for standard operations like GET, POST, PUT, and DELETE.Automatic Mapping: It can automatically convert JSON or XML responses into Java domain objects using message converters.Status: While widely used, it is in maintenance mode. For new projects, Spring recommends using the modern RestClient or the reactive. Its an automate work. getForObject() Performs a GET request and returns the response body directly as an object. getForEntity() Performs a GET request and returns a ResponseEntity (includes status and headers). postForObject() Sends data via POST and returns the mapped response body. exchange() A general-purpose method for all HTTP verbs, offering full control over headers and request entities. getForObject- Controller Snippet Response is received in Object format. @RestController @RequestMapping("/api") public class ApiController { @Autowired private ApiService apiService; @GetMapping("/getUsers") public String users() { return apiService.getUsers(); } Service snippet: @Service public class ApiService { @Autowired private RestTemplate restTemplate; @Autowired UserApiRepo userApiRepo; public String getUsers() { String url = "https://jsonplaceholder.typicode.com/users"; String response = restTemplate.getForObject(url, String.class); return response; } Response: "id": 1, "name": "Leanne Graham", "username": "Bret", "email": "Sincere@april.biz", "address": { "street": "Kulas Light", "suite": "Apt. 556", "city": "Gwenborough", "zipcode": "92998-3874", "geo": { "lat": "-37.3159", "lng": "81.1496" } }, "phone": "1-770-736-8031 x56442", "website": "hildegard.org", "company": { "name": "Romaguera-Crona", "catchPhrase": "Multi-layered client-server neural-net", "bs": "harness real-time e-markets" } getForEntity() Respo

Sri 2026-05-29 20:38 13 原文
产品设计 Dev.to

How Compute Savings Plans Work (Step-by-Step)

Most people understand that a Compute Savings Plan saves money on cloud compute. Far fewer understand the precise mechanism which matters, because getting the commitment amount wrong in either direction costs real money. Too high: you pay for committed hours you do not use. Too low: you miss savings on usage that could have been covered. The difference between a well-sized Savings Plan and a poorly-sized one can easily be tens of thousands of dollars per year on a mid-size fleet. This guide walks through the exact mechanics, hour by hour, with worked examples on both AWS and Azure. Step 1: You Choose a Commitment Amount Before anything else, you decide how much per hour you want to commit. This is the single most important decision in the entire process. Everything else is automatic, the discount application, the coverage calculation, the billing. The commitment amount is a dollar figure: $X per hour. It represents a minimum spend level. You are telling the cloud provider: every hour for the next 1 year (or 3 years), I guarantee I will use at least this much compute. The right commitment amount is your stable baseline, not your average and not your peak. Pull your last 30 days of hourly compute spend. Sort the values. Find the P70 or P75: the spend level you are at or above for 70–75% of hours. That is roughly where your commitment should sit. Why P70–P75 and not the average? Because the average includes your peak hours and your quietest hours equally. If you commit to the average, you generate wasted commitment in the bottom 50% of hours. At P70, you are paying for unused commitment in only 30% of hours and those hours only waste the difference between actual usage and committed amount, not the full committed amount. If you want to understand how commitment-based discounts work across AWS, Azure, and GCP, we covered the full landscape here What Are Commitment-Based Discounts in Multi-Cloud Services? Step 2: The Cloud Provider Applies Discounted Rates Once you have

Aman Singh 2026-05-29 20:37 16 原文
AI 资讯 Dev.to

How to investigate suspicious SSH logins without giving AI a shell

A lot of Linux incident response starts with a login question, not a malware sample. Someone sees a spike of failed SSH attempts. A root login appears in the wrong time window. A service account logs in from an address nobody recognizes. A helpdesk ticket says "the server looks weird" and the only concrete clue is a username or IP address. At that point, the useful question is not "is this host compromised?" It is more boring and more important: Did anyone actually authenticate? Which account was involved? Was it password, key, sudo, su, or a scheduled task? Was the same IP seen in web logs, current sockets, process context, or command history? Did persistence, services, packages, or recent files change near the same time? Can another responder review exactly what evidence was collected? That last point matters. If you let an AI assistant freely run shell commands during the first pass, you can get speed, but you also create a new risk: the model may over-collect, mutate the host, or produce a confident answer that nobody can audit later. For a login anomaly, I prefer a read-only evidence loop. A practical first pass Start with the narrow clue if you have one. If the alert names a user: oi login --user root -s 7d If the alert names an IP address: oi login --ip 203.0.113.44 -s 7d If the alert is vague, start wider: oi login -s 7d oi scan -s 7d The goal of the first pass is not to prove every detail. The goal is to build a timeline that a human responder can challenge. For a suspicious SSH login, I want the initial report to answer five things. 1. Authentication pattern Look for the difference between noise and access. A server can receive thousands of failed SSH attempts from the internet. That is useful background, but it is not the same as a successful session. The first split should be: failed attempts only successful login after many failures accepted key from an unusual source login by an account that normally should not be interactive root login where root SSH

Qimin Zhao 2026-05-29 20:37 13 原文
AI 资讯 Dev.to

I Deployed My Go Backend to a Real VPS. Here's Exactly What Happened.

In Part 14 , I finished HMAC webhook signing. The backend was complete — JWT auth, PostgreSQL, Redis caching, rate limiting, circuit breaker, worker pool, webhook delivery, migrations, Docker. All running locally. But "runs on my machine" isn't a portfolio project. It's a homework assignment. Time to ship it. The Stack Being Deployed Go backend — ~15MB Docker image (multi-stage build, CGO_ENABLED=0) PostgreSQL 16 — with golang-migrate running schema migrations on startup Redis — for caching, rate limiting, and refresh token storage Oracle Cloud Free Tier — 1GB RAM, 45GB disk, already provisioned Everything wired together with docker-compose.yml . One command to start the entire stack. Step 1: The VM Was Fine, Actually I was worried about the free tier specs. Turned out the "1GB" in the tier name refers to RAM, not disk. The actual disk is 45GB — plenty. free -h # 954MB RAM, 552MB available df -h # 45GB disk, 41GB free The real constraint: no swap . Go's compiler is memory-hungry. Without swap, building the Docker image on the VM would exhaust RAM and kill the process. More on this in a moment. Step 2: Install Docker curl -fsSL https://get.docker.com | sudo sh sudo usermod -aG docker ubuntu newgrp docker The official install script handles everything — Docker Engine, containerd, Docker Compose plugin. One command, done. Step 3: Clone the Repo The repo is private. Created a fine-grained GitHub personal access token with Contents: Read-only permission. Used it to clone: git clone https://TOKEN@github.com/absep98/Go_learn.git Security note: never paste tokens in chat, email, or anywhere visible. Type them directly into the terminal. Tokens in chat history are compromised tokens. Step 4: Create the .env File The .env from my local machine needed two changes for Docker: # LOCAL (wrong for Docker): DB_HOST = localhost REDIS_HOST = localhost # DOCKER (correct): DB_HOST = postgres # ← service name in docker-compose.yml REDIS_HOST = redis # ← service name in docker-compose.ym

Abhishek Sharma 2026-05-29 20:36 14 原文
开发者 The Verge AI

Trump Mobile’s website still says the T1 Phone is ‘American-made’

Where's the Trump phone? We're going to keep talking about it every week. We've reached out, as usual, to ask about the Trump phone's whereabouts. As the phone's supposed launch continues, we noticed its website may be violating FTC rules. When the Trump phone was first announced last June, it was proudly promised to be […]

Dominic Preston 2026-05-29 20:30 13 原文
AI 资讯 Reddit r/programming

The case for Direct I/O - why it matters for high performance storage

Hello everyone, Recently I published on GitHub HedgeDB , my high-perf and persisted Key-Value store. Internally, it uses Direct I/O ( O_DIRECT ) almost everywhere. In this article I explain the reasons behind this choice, also motivated from some fun experiments I had with fio that you can find in the article. and some consideration about the page cache. submitted by /u/IlPresidente995 [link] [留言]

/u/IlPresidente995 2026-05-29 20:25 5 原文