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

标签:#r

找到 20173 篇相关文章

AI 资讯

Memory-Safe Media Preflight in Mobile Browsers

Client-side media preflight can improve an upload experience, but it can also crash the page before the network request begins. A twelve-megapixel JPEG may be only four megabytes on disk and tens of megabytes after decoding. Creating several full-size canvases at once is enough to exhaust memory on older phones. Preflight is policy, not editing Decide what the browser must prove before transfer. Useful checks include file count, compressed byte size, declared type, readable dimensions, and a conservative duration limit for video. Avoid mandatory re-encoding unless the product truly needs it. Every transformation adds CPU time, memory pressure, battery use, and another failure mode. Process one file at a time A file picker may return twenty items. Do not decode all of them to build previews. Maintain a queue with one active decode on constrained devices and at most two on stronger ones. for ( const file of files ) { const result = await inspect ( file ); renderResult ( result ); await yieldToMainThread (); } The UI can list filenames immediately while dimensions and thumbnails arrive progressively. Prefer metadata over full pixels Use createImageBitmap with resize hints when supported. It can decode away from the main rendering path and avoid a full-resolution canvas for a small preview. const bitmap = await createImageBitmap ( file , { resizeWidth : 640 , resizeQuality : ' medium ' }); Always close bitmaps after drawing. Revoke object URLs when the component unmounts. Small leaks become large when guests select and remove files repeatedly. Handle orientation and color carefully Modern browsers generally honor EXIF orientation when decoding, but behavior differs across APIs and older engines. Test portrait photographs from real iOS and Android devices. Do not strip metadata silently if the original is supposed to remain untouched; upload the source file and treat the preview as disposable UI. Color differences between the preview and exported original are usually les

2026-07-18 原文 →
AI 资讯

React Native Interview Handbook — Part 8 of 10: Code Output Challenges

This is Part 8 of 10 , a bonus practice article with 70 code-output challenges . Each challenge asks you to predict the result before revealing the answer and reasoning. Complete series This Dev.to series has five core handbook articles plus five focused practice extras. Open the series page to move through the complete reading order: Part 1: JavaScript — core handbook, questions 1–120 Part 2: React — core handbook, questions 121–220 Part 3: React Native — core handbook, questions 221–420 Part 4: Performance & Architecture — core handbook, questions 421–560 Part 5: Senior & System Design — core handbook, questions 561–719 Part 6: Output-Based JavaScript Practice — bonus practice article Part 7: Coding Interview Practice — bonus practice article Part 8: Code Output Challenges — bonus practice article Part 9: Current React Native Interview Questions — new high-frequency practice article Part 10: Project & Production Interviews — senior project ownership and real-production practice How to use this challenge set Read the code, state the exact output or error, then explain the language rule. Do not run the snippet until you have committed to an answer. For React Native interviews, connect the JavaScript behavior to rendering, state updates, list handling, or the JavaScript thread when relevant. Skills tested Hoisting, scope, closures, and this Arrays, conditions, references, object behavior, and loose versus strict equality Promises, timers, async / await , and microtasks Common JavaScript patterns used in React and React Native interviews Code output challenges Challenge 1. Block-scoped counter Predict the exact output before opening the answer. let total = 0 ; for ( let i = 0 ; i < 3 ; i ++ ) { total += i ; } console . log ( total ); Answer and explanation Expected output: 3 Why: The loop adds 0, 1, and 2. Challenge 2. var callback loop Predict the exact output before opening the answer. for ( var i = 0 ; i < 3 ; i ++ ) { setTimeout (() => { console . log ( i ); }, 0

2026-07-18 原文 →
AI 资讯

The Robotics Tech Tree: the structured map I wish I had from LED to Physical AI

I was tired of buzzword-heavy AI projects and marginally impactful demos. Surely we can do something more inspiring with these LLMs than build another chatbot? For me, the answer is physical AI: the moment all those breakthroughs finally reach into the real world, in robots that see, move, and figure things out for themselves. I think it is the most exciting frontier in tech right now. It is also genuinely hard to break into, because it is not one field. It is about five of them stacked on top of each other: electronics, mechanics, programming, data, and AI. Eight months ago I started my own robotics journey from scratch, and I was completely overwhelmed. How do you get from blinking an LED to a humanoid that does your dishes? There are thousands of scattered tutorials out there, with no sense of what comes first, or what any of it is building toward. So I decided to build the map. Stealing the best idea from my favorite games: If you have ever played a factory-building or strategy game like Satisfactory or Civ Six, you know the feeling. You start with almost nothing, and you unlock new tech one satisfying step at a time. Those games are proof that we will happily spend hours mastering an intimidatingly complex system, as long as it is laid out as a clear tree of unlocks. So why not point that same instinct at learning something real? That is exactly what a tech tree is: a structured, visual path where each node is a skill and each connection is a prerequisite. You start at Curiosity on the far left and work your way right, through electronics, mechanics, code, data, and AI, all the way toward autonomous robots and humanoids. The idea is simple: turn gaming time into learning time. What the tree actually is Every node on the tree is a skill to learn, and the star-shaped nodes are hands-on projects where theory finally meets a soldering iron. Nodes are color-coded by discipline, so you can see at a glance whether you are in electronics, mechanics, programming, data s

2026-07-18 原文 →
开发者

Show HN: A zoomable timeline of 4M Wikipedia events

I'm building a journal app in Kotlin Multiplatform and for this purpose I have created a zoomable timeline interface. This is a side-project where I reuse the timeline interface to display 4 million events imported from Wikipedia / Wikidata, scored using PageRank. There is more information on the about page. If you're interested in the stack: I use Kotlin Multiplatform extensively, with Compose Multiplatform for the UI, communicates with the backend using Kotlinx-RPC and behind the hood a simple

2026-07-18 原文 →
AI 资讯

#05 – Python File Handling & Exceptions

Welcome to Day 5! Today we shift from volatile, temporary in-memory variables to persistent storage and application durability . You will learn how to interact safely with your operating system's file system, read/write structured industry data patterns, handle real-world operational crashes gracefully, and keep execution timelines documented using professional logging architectures. 💾 1. File Handling & pathlib 📄 Python's pathlib module treats file paths as smart object structures instead of plain text strings. This avoids bugs caused by differing slash directions across operating systems (Windows uses \ , while Mac/Linux use / ). Reading ( "r" ): Loads file contents into memory. Writing ( "w" ): Erases any existing file contents and writes a fresh payload from scratch. Appending ( "a" ): Targets the end of a file, adding fresh text without overwriting existing contents. 🌱 Easy Starter Example from pathlib import Path # Create a path reference pointing to a file in the current workspace directory file_path = Path ( " notes.txt " ) # Write text cleanly to a file space file_path . write_text ( " Hello from Day 5! " ) # Read data straight back into a string variable content = file_path . read_text () print ( content ) # Output: Hello from Day 5! 🏛️ Real-World Example: Multi-Platform System Telemetry Appender from pathlib import Path from datetime import datetime def log_system_status ( status_message : str ) -> None : # Resolve home folder pathways seamlessly across Windows, Mac, or Linux systems target_dir = Path . home () / " app_workspace " / " telemetry " # Create the directory chain automatically if it doesn't exist yet target_dir . mkdir ( parents = True , exist_ok = True ) log_file = target_dir / " runtime_events.log " timestamp = datetime . now (). isoformat () # Secure stream channel using Python's standard file-open context manager with open ( log_file , mode = " a " , encoding = " utf-8 " ) as file : file . write ( f " [ { timestamp } ] STATUS: { status_mes

2026-07-18 原文 →
AI 资讯

Resumable Browser Uploads for Crowded Event Networks

Event uploads fail differently from normal office uploads. A wedding guest may move between venue Wi-Fi and mobile data, lock the phone while a video is transferring, or close the browser as soon as the progress bar reaches 100%. Hundreds of devices can share one access point, and users rarely wait around to diagnose an error. The usual POST request plus optimistic success toast is not enough. A reliable browser flow needs a small protocol that distinguishes local preparation, network transfer, server acceptance, media processing, and final availability. This article describes a platform-neutral design for that protocol. The five states users actually experience Model each file as a durable state machine: selected -> preparing -> transferring -> accepted -> processing -> ready Add terminal or recoverable branches: preparing -> rejected_local transferring -> paused | retryable_error | expired accepted -> processing_error processing -> ready | processing_error The key distinction is between transferring and accepted . The browser may have sent every byte while the server has not yet committed the upload. Showing “done” at that boundary creates the most frustrating failure: the guest deletes the original, but the organizer never receives it. Give every file a client-generated identity Create an upload ID before the first network request. A UUID is sufficient when combined with the event identifier: const uploadId = crypto . randomUUID (); const uploadIntent = { uploadId , eventId , name : file . name , size : file . size , type : file . type , lastModified : file . lastModified , }; Send that identity when creating the server-side upload session. If the browser retries after a timeout, the server returns the existing session instead of creating a duplicate. This is idempotency at the workflow level. A guest can tap “retry” without having to understand whether the first request reached the server. Separate the control plane from file bytes Use a small JSON API for sessi

2026-07-18 原文 →
AI 资讯

React Native Interview Handbook — Part 7 of 10: Coding Interview Practice

This is Part 7 of 10 , a bonus practice article containing 75 coding interview questions drawn from the React Native Interview Handbook. It covers the implementation tasks commonly used in JavaScript and React Native rounds, from string and array problems to hooks, FlatList , asynchronous work, caching, retries, and native modules. Complete series This Dev.to series has five core handbook articles plus five focused practice extras. Open the series page to move through the complete reading order: Part 1: JavaScript — core handbook, questions 1–120 Part 2: React — core handbook, questions 121–220 Part 3: React Native — core handbook, questions 221–420 Part 4: Performance & Architecture — core handbook, questions 421–560 Part 5: Senior & System Design — core handbook, questions 561–719 Part 6: Output-Based JavaScript Practice — bonus practice article Part 7: Coding Interview Practice — bonus practice article Part 8: Code Output Challenges — bonus practice article Part 9: Current React Native Interview Questions — new high-frequency practice article Part 10: Project & Production Interviews — senior project ownership and real-production practice How to answer coding questions Before coding, clarify inputs, output, edge cases, platform constraints, time complexity, space complexity, cancellation, and test coverage. Start with a correct readable solution, then optimize only when the constraint justifies it. Topics covered Strings, arrays, maps, sets, recursion, and algorithmic complexity Debounce, throttle, memoization, deep cloning, and polyfills Custom hooks, API state, error boundaries, and React rendering FlatList pagination, pull to refresh, search, and offline retry Promises, timeouts, concurrency limits, and exponential backoff Caching, EventEmitter, Pub/Sub, LRU design, and native module boundaries Interview coding checklist Confirm assumptions before writing code. State time and space complexity. Handle empty input, invalid input, and duplicate values deliberately

2026-07-18 原文 →
AI 资讯

React Native Interview Handbook — Part 6 of 10: Output-Based JavaScript Practice

This is Part 6 of 10 , a bonus practice article containing 191 output-based JavaScript interview questions . It includes 111 questions drawn from the React Native Interview Handbook plus 80 additional questions on the JavaScript behavior interviewers commonly test in React Native rounds: hoisting, scope, closures, arrays, objects, functions, coercion, conditions, Promises, and the event loop. Complete series This Dev.to series has five core handbook articles plus five focused practice extras. Open the series page to move through the complete reading order: Part 1: JavaScript — core handbook, questions 1–120 Part 2: React — core handbook, questions 121–220 Part 3: React Native — core handbook, questions 221–420 Part 4: Performance & Architecture — core handbook, questions 421–560 Part 5: Senior & System Design — core handbook, questions 561–719 Part 6: Output-Based JavaScript Practice — bonus practice article Part 7: Coding Interview Practice — bonus practice article Part 8: Code Output Challenges — bonus practice article Part 9: Current React Native Interview Questions — new high-frequency practice article Part 10: Project & Production Interviews — senior project ownership and real-production practice How to use this guide Before opening an answer, state the exact output first. Then explain the rule that causes it: evaluation order, scope, coercion, reference identity, prototype lookup, or microtask scheduling. Run the snippet only after committing to an answer. Topics covered Hoisting, Temporal Dead Zone, var , let , const , and function declarations Scope, closures, this , arrow functions, call , apply , and bind Arrays, sparse arrays, map , reduce , sort , slice , splice , and mutation Objects, references, shallow copies, prototypes, getters, and property lookup Conditions, truthiness, equality, nullish coalescing, and type coercion Promises, async / await , microtasks, timers, and error recovery React and React Native rendering behavior, state updates, effects,

2026-07-18 原文 →
AI 资讯

Apple Music is getting a price hike

Apple Music is more expensive now. In the US, an individual plan now costs $11.99 per month, a $1 bump up from the previous $10.99 price. A family plan now costs $19.99 per month, up from $16.99, and a student plan costs $6.99 per month, up from $5.99. Apple, in a statement to Music Business […]

2026-07-18 原文 →