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

标签:#Python

找到 623 篇相关文章

AI 资讯

Cloudflare Turnstile in Playwright: Why Your Tests Stall and How to Solve It in 8 Lines

Cloudflare Turnstile in Playwright: Why Your Tests Stall and How to Solve It in 8 Lines If you're running Playwright or Selenium against any site behind Cloudflare, you've already met Turnstile. It's the new "managed challenge" widget Cloudflare started shipping in 2023, and it now appears in front of login flows, contact forms, signup pages, and increasingly the entire site root. Here's the part most teams miss: Turnstile doesn't always show a checkbox. A lot of the time it just sits invisible, runs its scoring loop, and either issues a token silently or stalls forever. Your test doesn't crash. It just times out at the next page.click("button[type=submit]") . The CI log says "element not interactable." Nobody knows why. I work on CaptchaAI. I'm going to show you exactly what's happening, then drop in 8 lines that fix it. The real scenario You have a Playwright suite that runs every PR. One day a test starts failing on the signup flow. You re-run it. It fails again. Locally on your laptop it passes. On CI it doesn't. What's actually happening: Cloudflare flagged your CI runner's IP block (GitHub Actions, GitLab runners, Hetzner, OVH, DO — all of them are on Cloudflare's "elevated risk" list). Turnstile decides to switch from invisible mode to "managed challenge" mode. Now there's a widget in the DOM that needs a real token before the form submit will accept. Your test never interacted with the widget because last week it didn't exist. Why retries don't help The instinct is to add a retry: 2 and move on. Don't. Cloudflare's scoring is per-IP-per-fingerprint, and each retry from the same runner makes the next challenge harder, not easier. After ~3 attempts you'll get full block pages instead of the widget. The right move is to solve the widget once, inject the token, and submit normally — exactly what a human user does, just faster. How Turnstile actually issues a token The widget renders an iframe pointing at challenges.cloudflare.com . Inside the iframe it runs a fi

2026-06-04 原文 →
开源项目

🔥 0x4m4 / hexstrike-ai - HexStrike AI MCP Agents is an advanced MCP server that lets

GitHub热门项目 | HexStrike AI MCP Agents is an advanced MCP server that lets AI agents (Claude, GPT, Copilot, etc.) autonomously run 150+ cybersecurity tools for automated pentesting, vulnerability discovery, bug bounty automation, and security research. Seamlessly bridge LLMs with real-world offensive security capabilities. | Stars: 9,216 | 38 stars today | 语言: Python

2026-06-04 原文 →
AI 资讯

Why Your LLM Agent Gives a Different P-Value Every Time (And What to Build Instead)

Hand the same paired before/after dataset (n = 25) to ChatGPT five times. Same prompt: "These are the same subjects measured before and after an intervention. Did their scores change significantly?" Four of the five runs return p = 0.009 from a paired t-test. The fifth run does a Shapiro–Wilk normality check on the differences first, decides they're non-normal, switches to a Wilcoxon signed-rank test, and reports p = 0.000018 . All five reach the same conclusion (significant). But notice what happened: only one run out of five thought to check an assumption you'd want it to check. The other four skipped it. The choice of method — and the test statistic, and the p-value — depended on whether the LLM happened to run an assumption check that time. On borderline data, this is the difference between reject and don't reject. If you're using LLMs for exploratory data analysis on a weekend project, you might shrug. If you're using them for anything that gets cited, gets submitted to a regulator, or gets handed to a clinician, this is a problem. It's a known problem — Cui & Alexander (2026) documented exactly this kind of method-divergence empirically; AIRepr (Zeng et al., 2025) shows the same thing across reproducibility metrics. The current answer in the literature is to constrain the agent so its execution is replayable. But replayability fixes "did we run the same code." It doesn't fix "did we run the right analysis." I've spent the last two months building a different fix. The more interesting half is the architecture. Let me walk through it. The real problem isn't temperature The first reflex is "set temperature=0 ." It's not enough. temperature=0 doesn't make a tool-using agent deterministic across runs. Three reasons: Inference isn't bitwise deterministic, even at temperature=0. Production LLM serving batches requests dynamically, and the attention kernels aren't batch-invariant — so the same input produces different output tokens depending on what other requests it

2026-06-03 原文 →
AI 资讯

How I Shaved 10 MB Off My Portfolio in One Command

PageSpeed Insights had been staring at me for weeks. Desktop was holding at 91. Mobile was stuck at 63. I'd already fixed the obvious stuff — non-blocking fonts, preconnects, fetchpriority on the hero image. But there it was, every single run: Improve image delivery — Est savings of 985 KiB Nearly a megabyte of wasted transfer, just from six project screenshots. And that was just the images visible above the fold. The full list across all projects was worse. The culprit: every image I'd ever uploaded through the Django admin was a PNG. Some of them were over 1 MB. WebP would have cut most of them by 80%. I knew this. I just hadn't done anything about it. So I wrote a management command to fix the backlog, and then made the model auto-convert on every future upload so I'd never have to think about it again. The Problem With PNGs in a Portfolio When you're building a portfolio, you screenshot your work and drag it into the admin. That screenshot is usually a PNG — lossless, full-size, straight from your display. Nobody optimises it because the admin accepts it and it shows up fine in the browser. But "shows up fine" isn't the same as "loads fast." A 1.4 MB PNG of a law firm homepage does not need to be 1.4 MB. Served as WebP at quality 85, it's 175 KB. Same visual result. Eight times smaller. Multiply that across 28 projects and you're looking at tens of megabytes that mobile users on slow 4G are downloading just to scroll past thumbnails. The One-Time Backlog Fix: A Management Command First, I needed a way to convert everything that was already in S3. A management command was the right tool — it runs in the production container with full access to the Django ORM and the configured storage backend, so it can read and rewrite files without needing to know whether they're on S3, local disk, or anywhere else. # backend/projects/management/commands/convert_images_to_webp.py from io import BytesIO from django.core.files.base import ContentFile from django.core.management.b

2026-06-03 原文 →
AI 资讯

Log #1: Building the Base Control Model

Note: This post is a raw development log storing the exact prompts and responses used with the local LLM (IBM Granite-3.2-8B) to build the autonomous racing agent. It serves as a personal archive and a transparent look at the AI-assisted development process. Development Log: Autonomous TORCS Racing Agent Model used: ibm-granite-3.2-8b-instruct This log documents all the prompts and answers used in IBM Granite models for this project. 1. Initial Model Creation Goal: Create a robust, modular control system for the Corkscrew track. Prompt @snakeoil3_jm2.py @torcs_jm_par.py Act as an expert in autonomous vehicle control and TORCS simulator architecture. I am developing a high-performance agent for the Corkscrew track. Analyze the provided snakeoil3_jm2.py (for sensor/action interface) and torcs_jm_par.py (current control logic). I need you to rewrite the drive() function to be a robust, modular control system. Please provide: 1. Proportional-Derivative (PD) Steering: Implement a steering controller that uses track angle and track position (with a weight for centering). 2. Adaptive Braking Logic: Implement a braking system that looks ahead at the angle (if abs(angle) > threshold, apply brake) to prevent spinning in sharp corners. 3. Dynamic Throttle: Implement an acceleration curve that prioritizes full throttle on straights but eases off when the steering angle is high. 4. Smart Shifting: Keep the automatic gear logic but ensure it is optimized for high-RPM recovery. Provide the complete, clean Python function drive(c) ready to replace the existing one in torcs_jm_par.py. Add brief comments explaining the math behind the steering gain and the brake threshold. Response Here's a revised drive() function for torcs_jm_par.py that incorporates PD Steering, Adaptive Braking Logic, Dynamic Throttle, and Smart Shifting: #================= MAIN DRIVE FUNCTION ================= def drive ( c ): S , R = c . S . d , c . R . d # PD STEERING CONTROL steer_kp = 30 # Proportional Gain

2026-06-03 原文 →
AI 资讯

Building an Autonomous Racing Agent in TORCS

Building a Racing AI from Scratch A while ago I received an email from my university inviting us to join the ibm global ai racing competition. Now that I'm finished with my exams I am going to give it a try. The testing ground for this project will be TORCS (The Open Racing Car Simulator). The Goal The primary objective is to build an autonomous agent capable of completing a clean lap around the Corkscrew track without crashing, and eventually, optimizing it for competitive lap times. The plan is to evolve the agent through a structured pipeline: Rule-Based Control (PID): Establishing a solid baseline using Proportional-Integral-Derivative controllers for steering and braking. Machine Learning: Upgrading the agent to learn from its environment using frameworks like PyTorch to replace hardcoded heuristics. Optimization: Fine-tuning the parameters and pushing the physics engine to the limit. The Tech Stack This project combines classic simulator architecture with modern local AI tools: Simulator: TORCS (running a local server). Language: Python (interfacing via the snakeoil3 library to parse sensor data and output telemetry). Local AI Assistant: ibm-granite-3.2-8b-instruct . I will be using this local LLM (hosted via LM Studio and integrated into VS Code with Continue.dev) to help architect the math, tune the control logic, and create/debug the Python code. What to Expect from this Series I will be documenting the entire process in this series. I will share the exact prompts used with the local AI, the generated code, the mathematical reasoning behind the control systems (such as why a naive PD controller causes zig-zag oscillation and how to fix it with damping), and the iterative debugging process. If you are interested in robotics, control theory, Python, or machine learning applications in simulation environments, follow along. The first technical log will be published shortly, detailing the implementation of baseline steering and look-ahead braking logic.

2026-06-03 原文 →
AI 资讯

From Pills to Pixels: Building an Intelligent Home Pharmacy Manager with YOLOv8 and CLIP 💊✨

We’ve all been there: staring at a messy medicine cabinet, wondering which box is for allergies and which one expired in 2022. In the world of Computer Vision and AI Healthcare , digitizing physical assets is a classic challenge. Today, we're building a "Medicine Box Expert"—a sophisticated pipeline that uses YOLOv8 for precision detection and OpenAI CLIP for multimodal understanding to turn a pile of pills into a searchable digital database. By the end of this tutorial, you'll understand how to bridge the gap between raw pixels and structured medical data. We are moving beyond simple classification; we are building a robust system capable of handling complex lighting, varied angles, and the tiny typography common in pharmaceutical packaging. The Architecture: A Multi-Stage Vision Pipeline To achieve high accuracy, we don't rely on a single model. Instead, we use a "Detect-Extract-Embed" workflow. graph TD A[User Uploads Image] --> B[YOLOv8: Box Detection] B --> C{Box Found?} C -- Yes --> D[Crop & Preprocess] C -- No --> E[Error: No Box Detected] D --> F[Tesseract OCR: Text Extraction] D --> G[OpenAI CLIP: Visual Embedding] F & G --> H[SQLite Query: Semantic Search] H --> I[Result: Drug Info & Dosage] Prerequisites Before we dive into the code, ensure you have the following tech_stack installed: YOLOv8 : For real-time object detection. OpenAI CLIP : To handle semantic image-text matching. Tesseract OCR : For reading the fine print on the boxes. SQLite : To store and query our medicine metadata. pip install ultralytics transformers torch pytesseract Step 1: Detecting the Medicine Box with YOLOv8 First, we need to locate the medicine box within the frame. A generic YOLOv8 model (like yolov8n.pt ) is surprisingly good at detecting "books" or "cell phones," but for the best results, you should fine-tune it on the Open Images Dataset specifically for "Box" or "Medical Packaging." from ultralytics import YOLO import cv2 # Load the model model = YOLO ( ' yolov8n.pt ' ) def

2026-06-03 原文 →
AI 资讯

I Wrote 40 Lines of Python to Beat Tokyo Salaries from Rural Japan: Furusato Nozei + Utility Defense for Remote Side-Hustlers (2

⚠️ この記事はアフィリエイト広告(プロモーション)を含みます。リンク先で発生した収益の一部が運営者に支払われますが、読者の購入価格には一切影響ありません。 If you work remote from rural Japan, by the end of this article you'll have two runnable Python scripts: one that computes your exact furusato-nozei (hometown tax) ceiling from your real side-income, and one that scores your electricity contract against your actual kWh log so you stop overpaying. No spreadsheets, no "consult a tax accountant" hand-waving. Copy, run, save money tonight. Result from my own 2025 numbers: ¥41,000 of furusato-nozei reward goods for a net cost of ¥2,000, plus ¥28,400/year shaved off my power bill after switching plans. Total ≈ ¥67,400 recovered, and because I work from home in Niigata, my commute cost to earn it was literally ¥0. The trap: side income breaks the "simple" furusato nozei calculator Every portal (Satofuru, Rakuten Furusato, Furunavi) shows a slider that estimates your ceiling from salary alone. The moment you add freelance/blog/ Kindle income, that slider lies to you. In 2024 I trusted it, donated ¥52,000, and ¥9,000 of it fell outside the deductible ceiling because my side income pushed me into a different residual-tax bracket. That ¥9,000 was just a donation — no tax back. The real ceiling depends on your total taxable income (salary + side hustle minus expenses) and the resident-tax (juminzei) cap of roughly 20% of your income-based resident tax. Here's a calculator that actually folds in side income. It uses Japan's 2026 progressive income-tax brackets. # furusato_ceiling.py — Python 3.9+ from dataclasses import dataclass # 2026 national income tax brackets: (upper_bound_yen, rate, deduction_yen) BRACKETS = [ ( 1_950_000 , 0.05 , 0 ), ( 3_300_000 , 0.10 , 97_500 ), ( 6_950_000 , 0.20 , 427_500 ), ( 9_000_000 , 0.23 , 636_000 ), ( 18_000_000 , 0.33 , 1_536_000 ), ( 40_000_000 , 0.40 , 2_796_000 ), ( float ( " inf " ), 0.45 , 4_796_000 ), ] @dataclass class Taxpayer : salary_income : int # after salary-income deduction (給与所得) side_profit : int #

2026-06-03 原文 →
AI 资讯

Stop Juggling 5 Tools , Python's uv Does It All (And It's Blazing Fast)

If you've been writing Python for more than a year, you know the ritual. A new project. A fresh terminal. And then: pyenv install 3.12.3 pyenv local 3.12.3 python -m venv .venv source .venv/bin/activate pip install pip --upgrade pip install -r requirements.txt Six commands before you've written a single line of code. And that's if nothing breaks. Enter uv a single binary that replaces pip , virtualenv , pip-tools , pyenv , and pipx . Written in Rust. 10–100x faster than pip. And honestly, one of the most pleasant tools I've used in the Python ecosystem in years. Let's dig into it. What Even Is uv ? uv is a Python package and project manager built by Astral , the same team behind ruff , the linter that everyone switched to and never looked back. The goal is simple: be the Cargo for Python . One tool, one lockfile, no friction. It's a standalone binary with zero Python dependencies, which means it works even before Python is installed. Installing uv # macOS / Linux curl -LsSf https://astral.sh/uv/install.sh | sh # Windows (PowerShell) powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex" # Or via pip if you prefer pip install uv Verify: uv --version # uv 0.9.x The Speed Claim Is It Real? Yes. Embarrassingly so. Here's a timed comparison on Apple Silicon (Python 3.14): Operation pip / venv uv Create virtual env ~2 seconds 35 milliseconds Install FastAPI + deps (cold) ~12s ~1.2s Install with warm cache ~8s ~0.1s The warm cache case is where uv really shines it uses a global cache and hard-links packages into environments instead of copying them. If you've installed requests in any previous project, your next project gets it nearly instantly. Starting a New Project This is where uv feels like a completely different world: uv init my-api cd my-api That single command gives you: my-api/ ├── .git/ ├── .venv/ ← already created ├── .python-version ├── pyproject.toml ├── README.md └── main.py No separate python -m venv , no git init , no template c

2026-06-03 原文 →
AI 资讯

Why crypto arbitrage windows close before your REST poll completes

TL;DR : Crypto arbitrage windows on liquid pairs now close in under 100 ms. A REST polling loop typically takes 1–1.5 seconds round-trip. WebSocket delivers the same data in 20–100 ms. If you're still polling REST endpoints for orderbook data in 2026, you're missing the majority of opportunities — not because your strategy is wrong, but because your data plane is fundamentally too slow. This post walks through the math, shows a benchmark I ran on a handful of major exchanges, and provides production-grade Python code for a WebSocket client that handles reconnects, heartbeats, and orderbook reconstruction. 1. The numbers that broke REST polling When I started writing crypto arbitrage bots a few years ago, polling Binance's REST API every 500 ms was perfectly acceptable. Spreads were wide, arbitrage windows lasted multiple seconds, and the orderbook for BTCUSDT moved slowly enough that a half-second-old snapshot was still tradeable. In 2026, the same approach doesn't work. Here are the numbers as they stand today: Metric Value Median crypto arbitrage window on liquid pairs 30–80 ms Window closes in under 100 ms ~90% of cases REST round-trip latency (request → response → JSON parse) 1.0–1.5 seconds WebSocket update delivery latency (push from exchange to client) 20–100 ms The math is brutal. A 100 ms window cannot be caught by a 1500 ms poll. By the time your REST response arrives, the orderbook you're reading is 15 cycles stale. You're not "slow" — you're not even in the same temporal universe as the event you're trying to react to. 2. Why REST is fundamentally slow REST APIs over HTTPS carry overhead that adds up: TCP handshake — three packets to establish, typically 50–150 ms on intercontinental hops. TLS handshake — another full round-trip, 30–100 ms. HTTP request/response — the actual data exchange. JSON parse — depending on payload size, 5–50 ms. Rate-limit budget — most exchanges cap REST to 10–20 requests per second per IP. Polling faster gets you banned. Yes,

2026-06-02 原文 →
AI 资讯

How I Built BidXpert — A Real-Time Auction Platform with FastAPI

Hi, I'm Heet Sanghani, a Python Developer and AI/ML Engineer from Ahmedabad, Gujarat, India. I currently work at BrainerHub Solutions building backend systems and AI-powered applications. In this post, I want to share how I built BidXpert — a real-time auction platform using FastAPI. What is BidXpert? BidXpert is a real-time bidding platform where users can create auctions, place bids, and get instant updates using WebSockets. Tech Stack Backend: FastAPI + Python Database: PostgreSQL Real-time: WebSockets Auth: JWT Authentication Deployment: Docker What I Learned Building BidXpert taught me how to handle concurrent WebSocket connections efficiently in FastAPI and manage real-time state. About Me I'm Heet Sanghani — Python Developer & AI/ML Engineer based in Ahmedabad. Check out my portfolio and other projects at: 👉 https://heet-sanghani-portfolio.vercel.app/ python #fastapi #webdev #ai

2026-06-02 原文 →