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

标签:#dev

找到 2777 篇相关文章

AI 资讯

Architecting Block: Building a Custom Social Network, Theme Engine, and more

Pre: What is BlockSocial? BlockSocial is the ultimate social network for developers, bringing the energy of short-form video to the world of open source. Think of it as Facebook meets Instagram—a place to showcase your code, find inspiration, and build your developer brand through "Reels" and interactive dashboards. Github link: https://github.com/Hfs2024/BlockSocial 1. User Scenario & Workflow (The Fork System) The Setup User A : Publishes a post saying: "I love drinking Pepsi every day." User B : Is shy, but wants to tell their friend this is an unhealthy habit. User C : Is a malicious user who gossips. The Fork Mechanism User B creates a fork to discuss this post with User C via the POST /api/share endpoint. Data Copying : It copies the entire post contents except comments, likes, reports, and downloads. Chain Prevention : You can fork a forked post, but the system will fork the original source root, not the fork itself. Scope : It shares with only one user at a time to prevent unexpected group creation. Database Payload for Forks The following fields are appended to the document structure: { "share" : true , "shareId" : "post._id" , // The original post ID "sharedBy" : "req.currentUser.username" , // The user who shared or forked "shareTo" : "shareTo" , // The friend receiving the share "shareComment" : "comment || ''" // A quick comment on the post } Moderation & Enforcement Workflow If User C breaks trust and leaks the conversation, User B can report them via the POST /report/user endpoint. Verification : Administrators review interaction history to verify the violation. Account Termination : Bad users receive a permanent lifetime account ban. Data Scrubbing : All associated messages from the malicious user are removed. Blacklisting : The account is fully banned. The Blindspot : Face-to-face interactions remain outside system moderation boundaries 😅 2. Technical Implementation Details Dynamic Comment Identity Logic When a user submits a comment via POST /api/c

2026-06-19 原文 →
AI 资讯

Using a locked-down WordPress as the form backend for my static sites

Static sites are great: fast, cheap to host, almost nothing to attack. Then you add a contact form and hit the same wall everyone hits — a static site can't process a submission. You need a backend. The usual answers are a third-party service (Formspree, Netlify Forms, Basin) or a small server you now have to babysit. Both add a dependency you don't control, a recurring bill, and — the part that bugs me most — your submission data lives on someone else's infrastructure. There's a third option I've been running for a while: one WordPress install, zero public pages, used purely as a form endpoint. Every form from every static site I own hits it. I own all the data. And because it serves no public HTML, its attack surface is close to nothing. The architecture Three pieces, each doing one job: WordPress — the backend. Locked down so hard it doesn't behave like a normal WP site anymore. A form plugin — handles building, validation, storage, email, file uploads. (I use CraftForms because it exposes a clean craftforms/v1 REST namespace and can also serve the form HTML to an external page — more on that below.) Your static frontend — Cloudflare Pages / Netlify / wherever. It either fetch es the REST endpoint on submit, or drops in an embed snippet. WordPress never serves a public request. It only processes submissions. The part that matters: locking it down The biggest WordPress attack vector isn't your host — it's outdated plugins . So the first move is brutal minimalism: one plugin, no theme, no page builder, no public frontend. A WP install with one plugin and a blocked frontend has almost no CVE surface, because none of the usual stuff is installed. The rest is one must-use plugin. Drop this in wp-content/mu-plugins/ (no activation needed) and you've blocked the four standard entry points: <?php if ( ! defined ( 'ABSPATH' ) ) exit ; // 1. Restrict the REST API to your form namespace only. // Kills user enumeration (/wp/v2/users), route discovery, the usual REST exploits

2026-06-19 原文 →
AI 资讯

A Few Months Ago, Agentic Development Felt Overwhelming

A few months ago, I was overwhelmed by everything happening in AI. Every week there was a new coding assistant, a new workflow, or someone claiming they built an app in just a few hours. It felt like if you weren't keeping up, you'd be left behind. I tried almost everything. Cursor. ChatGPT. Claude Code. Lovable. At first, I kept switching between tools, hoping one of them would magically make me a better developer. It didn't. The biggest lesson I learned wasn't about choosing the best AI tool. It was learning how to work with AI. These days, I don't start by asking AI to write code. I start by explaining the problem. I describe the feature, the business requirements, the edge cases, and what I want the final result to look like. Sometimes I ask ChatGPT to help me plan the implementation first. Once everything is clear, I pass that plan to an agentic coding assistant and start building. That one change made a huge difference. I spend less time writing boilerplate and more time thinking about architecture, user experience, and solving the actual problem. AI still gets things wrong, so I review everything before it goes into production. But instead of writing every single line myself, I'm guiding the process. Looking back, the first few months were the hardest. Now it just feels normal. The tools will keep changing, but I think the real skill is learning how to communicate with AI and use it as part of your development process. That's something worth investing in.

2026-06-19 原文 →
AI 资讯

How to Access 50+ Chinese AI Models Through One API

How to Access 50+ Chinese AI Models Through One API The Chinese AI ecosystem exploded in 2025-2026. DeepSeek dropped training costs by an order of magnitude. Qwen 3 ships 19 variants from 0.6B to 235B parameters. GLM-5 competes head-to-head with GPT-5 at 3% of the price. There's Kylin, Yi-Lightning, Hunyuan-T1, MiniMax-M1, Step-2-16K, and 40+ more models from a dozen labs. The models are incredible. The fragmentation is not. Every lab has its own API. Different auth headers. Different response formats. Different streaming protocols. Different error codes. If you wanted to try 5 models from 5 Chinese labs last year, you'd need 5 SDKs and 5 billing dashboards. Nobody has time for that. This is exactly the problem AIWave was built to solve. One API Key. 50+ Models. Zero Code Changes. AIWave is a unified API gateway that aggregates 50+ Chinese AI models behind a single endpoint. It speaks the OpenAI API format, which means every existing tool, SDK, and codebase in your stack works without modification. Here's what that looks like in practice: from openai import OpenAI # Point to AIWave instead of OpenAI client = OpenAI ( base_url = " https://api.aiwave.live/v1 " , api_key = " sk-your-aiwave-key " ) # Use DeepSeek V4 Pro response = client . chat . completions . create ( model = " deepseek-v4-pro " , messages = [{ " role " : " user " , " content " : " Explain MoE architecture " }] ) # Switch to GLM-5 — change one string response = client . chat . completions . create ( model = " glm-5 " , messages = [{ " role " : " user " , " content " : " Explain MoE architecture " }] ) # Try Qwen 3 235B — same thing response = client . chat . completions . create ( model = " qwen3-235b " , messages = [{ " role " : " user " , " content " : " Explain MoE architecture " }] ) That's it. Whatever you're already using — the OpenAI Python SDK, LangChain, LlamaIndex, Vercel AI SDK, a custom fetch wrapper — continues to work. You change the base URL and the model name, and suddenly you have acce

2026-06-19 原文 →
开发者

TSRX: A Framework-Agnostic Alternative to JSX

TSRX is a TypeScript language extension developed by Dominic Gannaway, designed to build declarative user interfaces in a framework-agnostic manner. It compiles single .tsrx files to various runtime targets and supports scoped styles and declarative error handling. TSRX is currently in alpha and is open source under the MIT license. By Daniel Curtis

2026-06-19 原文 →
AI 资讯

Day 45 of Learning MERN Stack

Hello Dev Community! 👋 It is officially Day 45 of my non-stop run toward full-stack engineering! Yesterday, I learned how to serve static HTML pages using Express routing. Today, I took a major step toward building premium, clean, and minimalist UI/UX styles by installing and mastering Tailwind CSS via the Tailwind CLI ! Instead of writing massive, chaotic external CSS stylesheet files, today I shifted to the industry-standard utility-first workflow to speed up my design iterations. 🧠 Key Learnings From Day 45 (Tailwind CSS Architecture) Tailwind doesn't give you pre-built components; it gives you atomic utility classes that let you build completely custom, high-end layouts directly inside your HTML structure. Here is the engineering breakdown: 1. Tailwind CLI Installation & Initialization I learned how to integrate Tailwind from scratch using npm packages instead of lazy CDN links. Installed the tailwindcss compiler core ( npm install -D tailwindcss ). Initialized the configuration hub using npx tailwindcss init . 2. Crafting the Content Map inside tailwind.config.js Understood how Tailwind optimizes final file weights using tree-shaking. I configured the structural template paths so the compiler knows exactly which files to scan for dynamic styling classes: javascript /** @type {import('tailwindcss').Config} */ module.exports = { content: ["./public/**/*.{html,js}"], // Scanning static folders cleanly theme: { extend: {}, }, plugins: [], }

2026-06-19 原文 →
AI 资讯

What Does the Windows REFRESH button really do?

Hello, I'm Maneshwar. I'm building git-lrc, a Micro AI code reviewer that runs on every commit. It is free and source-available on Github. Star git-lrc to help devs discover the project. Do give it a try and share your feedback. I boot up my machine. The desktop loads. And before I open my editor, before I check Slack, before I do a single productive thing, I right-click an empty patch of desktop and hit Refresh . Then I do it again. And again. I am a person who can explain event loops and reason about cache invalidation, and yet here I am, mashing F5 on a static wallpaper like it owes me money. If you've never done this, congratulations, you're better than me. If you have ... welcome. You're among friends. First, let's kill the myth There's a folk belief that refreshing the desktop is a tiny act of system maintenance. A little spring cleaning. A gift to your hardworking CPU. It is not. Manually refreshing your desktop does not : free up RAM reduce CPU load clear some mysterious cache make your PC faster in any way, shape, or form All it does is tell Windows Explorer to redraw the current view . That's it. That's the whole feature. What's actually happening under the hood Here's the part that's actually interesting (we're devs, we live for the "actually"). Windows doesn't repaint your entire screen on every frame, that would be wildly wasteful. Instead it leans on a composition engine that, with help from your GPU when one's available, only redraws the regions that changed since the last frame. Already drawn elements get cached and reused. Icons, the taskbar, your wallpaper they're all mostly static, so mostly left alone. When something genuinely changes (you save a file, delete a folder, plug in a drive), the OS detects it and tells the composition engine: "hey, this little rectangle changed, repaint just that." The desktop refreshes itself, automatically, all day long, without you ever touching anything. So the manual Refresh button is really just a manual overrid

2026-06-19 原文 →
开发者

String Methods, Conditional Statements (if/elif/else), Loops (for, range())

🐍 Python for DevOps — Class 5 Notes Topic: String Methods, Conditional Statements ( if/elif/else ), Loops ( for , range() ) 📌 Key Concepts Overview Concept One-Line Definition String Methods Built-in functions to inspect and transform strings if / elif / else Execute code blocks based on conditions for loop Iterate over any iterable — string, list, range, dict range() Generate a sequence of numbers to loop over Nested if An if block inside another if block Nested for A for loop inside another for loop 🔤 Part 1 — String Methods (Continuation from Class 4) Checking String Case # islower() — True if ALL characters are lowercase ' devops ' . islower () # True ' Devops ' . islower () # False # isupper() — True if ALL characters are uppercase ' DEVOPS ' . isupper () # True ' Devops ' . isupper () # False # Practical: normalize before comparing env = input ( ' Enter environment: ' ) if env . lower () == ' production ' : print ( ' ⚠️ Deploying to PROD! ' ) Checking Digit / Numeric Strings Method Accepts Rejects DevOps Use isdecimal() 0-9 only decimals, superscripts Port validation isdigit() 0-9 + superscripts decimal points Version numbers isnumeric() 0-9 + superscripts + fractions decimal points Broadest check # Key difference — decimal point breaks all three ' 8080 ' . isdecimal () # True ' 8080 ' . isdigit () # True ' 8080 ' . isnumeric () # True ' 80.80 ' . isdecimal () # False — dot is not a digit ' 80.80 ' . isdigit () # False ' 80.80 ' . isnumeric () # False # DevOps use: validate user input before casting port_input = input ( ' Enter port: ' ) if port_input . isdecimal (): port = int ( port_input ) else : print ( ' ❌ Invalid port — must be a whole number ' ) replace() — Find and Replace in Strings # str.replace('old', 'new') ' Python ' . replace ( ' P ' , ' J ' ) # 'Jython' ' prod-server-01 ' . replace ( ' - ' , ' _ ' ) # 'prod_server_01' ' This is python class ' . replace ( ' i ' , ' a ' ) # 'Thas as python class' — ALL occurrences # DevOps: sanitize strings for us

2026-06-19 原文 →
AI 资讯

How email verification works: syntax, MX, and SMTP explained

"Email verification" sounds like one thing, but it's really a stack of checks of increasing depth and cost. Knowing what each layer actually proves helps you pick the right level instead of overpaying for verification you don't need. Layer 1: syntax The cheapest check: does the string look like a valid email address? A pragmatic regex catches obvious garbage ( asdf , a@@b , trailing spaces). It's instant and free, but weak on its own: nobody@asdf.asdf passes syntax and can't receive a single message. Layer 2: domain and MX records Next, does the domain actually accept mail? Every domain that receives email publishes MX (mail exchanger) records in DNS pointing to its mail servers. A quick DNS lookup tells you whether any exist. No MX (and no fallback A record) means the domain can't receive mail, so the address is undeliverable no matter how it's spelled. This single step removes a large class of fakes and dead domains. Layer 3: SMTP mailbox check The deepest level connects to the domain's mail server and begins the motions of sending a message to ask whether that specific mailbox exists, without actually delivering anything. It's the only layer that can hint a particular inbox is real, but it comes with real caveats: It's slow (a live connection per address). Many servers are "accept-all" and say yes to everything, so the answer is often meaningless. Lots of providers block or throttle these probes, and outbound port 25 is blocked on most modern hosting, so it's frequently unavailable anyway. SMTP checks matter most for cleaning old, cold lists, and far less for stopping junk at signup. The heuristics layer Alongside those, useful verification adds signal that has nothing to do with deliverability per se: Disposable detection: is it a throwaway provider? Role detection: is it info@ or admin@ rather than a person? Typo suggestions: "did you mean gmail.com?" for gmial.com . A deliverability score: one 0–100 number that rolls it all up so you can just threshold on it.

2026-06-19 原文 →
AI 资讯

Windows Platform Security and the Race to Secure AI Agents

In a new Windows Developer Blog post titled "Windows platform security for AI agents", Microsoft positions Windows as the trustworthy operating system for autonomous agents and introduces the Microsoft Execution Containers (MXC) SDK as the core of that strategy. The post argues that containment, identity and manageability must be built into the operating system. By Matt Saunders

2026-06-19 原文 →
AI 资讯

Why Taking Feedback Positively Can Transform Your Career as a Developer

Why Taking Feedback Positively Can Change Your Career As developers, engineers, designers, and professionals, we all want to improve. We spend countless hours learning new technologies, building projects, and gaining experience. Yet many people overlook one of the most powerful tools for growth: feedback. Unfortunately, feedback often feels personal. When someone points out mistakes in our code, resume, communication, or project, our first reaction is sometimes defensive. We feel offended, frustrated, or misunderstood. I've experienced this myself. But over time, I learned that the ability to accept feedback positively is one of the most valuable skills anyone can develop. Feedback Is Not an Attack One of the biggest misconceptions is believing that criticism is an attack on our abilities. When a senior engineer reviews your code and suggests improvements, they are not saying you're a bad developer. When a recruiter rejects your resume, they are not saying you're incapable. When users report problems in your open-source project, they are not trying to discourage you. Most of the time, people are simply showing you where improvements can be made. The sooner we separate our ego from our work, the faster we grow. Every Rejection Contains Information Many professionals view rejection as failure. I view it differently now. A rejection is data. If ten companies reject the same resume, the market is telling you something. If users consistently struggle with a feature, they're revealing a usability problem. If interviewers repeatedly point out the same weakness, they're highlighting a skill gap. The goal isn't to feel bad about the feedback. The goal is to learn from the information hidden inside it. Growth Begins Where Comfort Ends Positive feedback feels good. Constructive feedback creates growth. Nobody enjoys hearing that their architecture can be improved, their communication needs work, or their project has flaws. But those uncomfortable conversations often lead to th

2026-06-19 原文 →
AI 资讯

# Building an AI-Powered Carbon Footprint Awareness Platform with Flask, SQLite, and Groq (Llama 3.1)

🌿 Introduction As climate awareness grows, individuals are looking for actionable ways to reduce their personal carbon footprints. However, most carbon calculators are either too complex or offer generic, unhelpful advice. To solve this, I built CarbonWise —a production-ready Carbon Footprint Awareness Platform. It combines deterministic scientific carbon calculations with real-time, personalized AI reduction strategies using the Groq LLM API. Here is a technical deep-dive into how I built, secured, and optimized this application for the PromptWars: Virtual challenge. 🏗️ Architecture & System Design The application is designed to be lightweight, secure, and highly performant, avoiding heavy framework overhead. System Data Flow ┌──────────────────────────────────────────────────────────┐ │ User Browser │ └─────────────┬──────────────────────────────▲─────────────┘ │ HTTPS (POST / GET) │ Rendered HTML/CSS ┌─────────────▼──────────────────────────────┴─────────────┐ │ Flask App (app.py) │ └─────────────┬──────────────┬───────────────▲─────────────┘ │ │ │ ┌─────────────▼──────────┐ ┌─▼─────────────┐ │ │ SQLite DB (carbon.db) │ │Secure Session │ │ │ - Users & Logs │ │ Cookies │ │ │ - WAL Mode Enabled │ └───────────────┘ │ └────────────────────────┘ │ Structured JSON Insights ┌────────────────────────────────────────────┴─────────────┐ │ Groq API (Llama 3.1) │ │ - Model: llama-3.1-8b-instant │ └──────────────────────────────────────────────────────────┘ Backend : Flask (Python) handles routing, user session state, and database operations. Database : SQLite manages users and logs. We activated WAL (Write-Ahead Logging) mode to enable concurrent reads and writes. AI Engine : Connects to the Groq API using the ultra-fast Meta Llama 3.1 8B model ( llama-3.1-8b-instant ). Frontend : Rendered server-side with Jinja2 templates and styled with a custom dark-mode glassmorphism design system in Vanilla CSS. ⚙️ Feature Deep-Dive 1. Deterministic Carbon Calculations ( carbon_engine.p

2026-06-19 原文 →
AI 资讯

Exploring Lore: A Scalable Open Source Version Control System

What was released / announced Lore is an open source version control system designed with scalability in mind, allowing developers to efficiently manage large-scale projects. According to the official website, Lore aims to provide a more efficient and scalable alternative to traditional version control systems. This release is particularly exciting for developers and engineers working on complex projects that require robust version control. Why it matters As someone who works with large-scale AI infrastructure and cloud systems, I can attest to the importance of reliable version control. With Lore, developers can expect improved performance and reduced latency when managing massive codebases. This is especially crucial in environments where multiple teams collaborate on the same project, and version control becomes a bottleneck. I believe Lore has the potential to streamline development workflows and enhance overall productivity. How to use it To get started with Lore, you can begin by installing the command-line tool using the following command: pip install lore Once installed, you can initialize a new Lore repository using: lore init Lore also provides a REST API for integrating with other tools and services. For example, you can use the following Python code snippet to interact with the Lore API: import requests response = requests . get ( ' https://your-lore-instance.com/api/repo ' ) print ( response . json ()) You can explore more API endpoints and usage examples in the official Lore documentation. My take As an AI infrastructure engineer and DevOps architect, I'm excited about the potential of Lore to improve our development workflows. In my experience, traditional version control systems often struggle with large-scale projects, leading to performance issues and frustration. Lore's focus on scalability and performance could be a game-changer for teams working on complex AI and machine learning projects. I'm looking forward to exploring Lore further and integr

2026-06-19 原文 →
AI 资讯

I open-sourced the financial charting library we use in production

If you've ever tried to build a trading dashboard, a crypto portfolio tracker, or any financial app, you probably ran into the "charting problem" pretty quickly. The standard industry approach goes something like this: Embed a heavy <iframe> from a 3rd party provider. Realize it doesn't quite match your app's UI/theme. Struggle with limited postMessage APIs to push real-time data. Watch the UI lag when you try to render multiple charts on the same page. I got tired of fighting with iframe embeds and DOM-based SVG charts that couldn't handle thousands of real-time ticks. I needed something native, fast, and entirely under my control. So, I built one. And today, I'm fully open-sourcing the core engine. Meet Exeria Charts Exeria Charts is a source-available, high-performance financial charting library designed for self-hosted web applications. Instead of embedding external widgets, Exeria renders directly inside your application using a highly optimized Canvas architecture. Here’s a quick look at what it can do: https://exeria.dev The Tech Constraints (Why build another charting lib?) Building a financial chart isn't just about drawing boxes and lines. It’s about performance under pressure. When designing the architecture, we had a few strict requirements: Zero iframes: It had to be a native JavaScript/React module that lives in the main DOM tree, styled perfectly to match the host application. High-frequency updates: Crypto and forex markets move fast. The library needed to handle sub-millisecond tick updates without dropping frames or blocking the main UI thread. Unified runtime: I didn't want a separate library for line charts, another for candlesticks, and another for volume histograms. We needed one engine that could switch views instantly. How to use it We designed the API to be as straightforward as possible. Here is what a vanilla JS implementation looks like: import { createChart } from " @efixdata/exeria-chart " ; // 1. Grab your container const container = d

2026-06-19 原文 →
AI 资讯

How I Built an Adversarial AI Council in React (and Why It Argues With You)

A local-first, single-file SPA where multiple agents debate your decision and hand you a verdict. The problem: every AI I asked just agreed with me I almost named this project wrong. I'd picked a name that sounded powerful. I asked ChatGPT, and it loved it. I asked Claude, and it nodded along. Nobody warned me about the trademark conflict, the wrong search intent, or the SEO fight I'd pick with the BBC. That was the moment I realized the problem wasn't the name. It was the feedback loop. Most AI assistants are tuned to please, so they hide your blind spots instead of showing them. When you need to make a consequential decision, "sounds great" is the most expensive answer you can get. So I built the opposite: a council of AI agents that disagree on purpose. What NoFlattery does NoFlattery puts 2–4 agents in a room, gives them different reasoning biases, and makes them debate your decision. The output isn't another chat transcript. It's a Decision Record: a clear verdict, the reasoning behind it, the main risk, what would change the call, and a next step. Use it for product decisions, pricing, tech stack, hiring, or any call where one perspective isn't enough. Key product choices: Local-first: your chats and API keys stay in your browser. BYOK: bring your own OpenAI, Anthropic, OpenRouter, or Ollama key. One-time price: no subscription, no account, no data harvesting. The stack The whole app is a single-file SPA built with: React 19 + TypeScript Zustand for state Dexie over IndexedDB for local-first storage Vite + vite-plugin-singlefile for a single index.html deploy An OpenAI-compatible provider runtime so users can plug in their own keys Why single-file? Because the deploy becomes dead simple. One HTML file. No server for the data. No build orchestration. I can ship the app to Cloudflare Pages and forget about it. The turn engine: deterministic, not magical The heart of NoFlattery is a turn-based multi-agent engine. One user message triggers one round. Each agent sp

2026-06-19 原文 →
AI 资讯

Day 25 of 100 Days of ClickHouse: Mastering the ClickHouse HTTP API

ClickHouse HTTP API: A Complete Beginner's Guide Introduction When most people think about interacting with a database, they usually imagine connecting through a database client or application. However, ClickHouse also provides a simple and powerful HTTP API that allows you to query and manage your database using standard HTTP requests. The ClickHouse HTTP API provides a universal interface for communicating with your ClickHouse server. Since almost every programming language and automation tool supports HTTP, it becomes an excellent choice for integrations, monitoring, scripting, and lightweight applications. In this guide, you'll learn what the ClickHouse HTTP API is, why it's useful, and how to perform common database operations using simple HTTP requests. What Is the ClickHouse HTTP API? The ClickHouse HTTP API is a built-in interface that enables clients to communicate with a ClickHouse server using the HTTP protocol. Instead of connecting through the native TCP protocol, you simply send HTTP requests and receive responses in formats such as JSON, CSV, TSV, XML, or plain text. The HTTP interface is: Language agnostic Easy to integrate with web applications Firewall friendly Simple to test using tools like cURL, Postman, or a web browser Because of its simplicity, the HTTP API is widely used for automation, dashboards, data pipelines, and monitoring systems. Why Use the HTTP API? The ClickHouse HTTP API offers several advantages: No dedicated database driver is required. Works with virtually every programming language. Easy integration with REST-based applications. Supports multiple output formats. Ideal for automation and scripting. Perfect for cloud-native applications and microservices. Common Operations Using the HTTP API, you can: Execute SQL queries Insert data Create and modify tables Retrieve query results Export data in different formats Automate database operations Authentication Options ClickHouse supports multiple authentication methods when using th

2026-06-19 原文 →
AI 资讯

Putting a file in .gitignore does nothing if git already tracks it. I built a CLI to find the leftovers.

You added .env to .gitignore . You felt responsible. But three weeks later it's still in the repo, still pushed to GitHub, still in every clone — because adding a path to .gitignore does nothing to a file git already tracks. That's not a bug. It's documented behavior: .gitignore only stops untracked files from being added. Anything already committed keeps getting tracked, ignore rule or not. So the secrets, build artifacts, and 40 MB log files that were committed before someone wrote the rule just... stay. The fix is one command — git rm --cached — but only once someone notices . And nobody notices, because git status is clean and the file looks ignored. So I built gitslip : a zero-dependency CLI that finds every tracked file your own ignore rules say should be gone, and hands you the exact fix. $ npx gitslip 2 tracked files are ignored by your rules but still committed: config/secrets.env ↳ .gitignore:7 *.env logs/app.log ↳ .gitignore:2 *.log Fix — stop tracking them (keeps your local copy): git rm --cached -- config/secrets.env git rm --cached -- logs/app.log or let gitslip do it: gitslip --apply It tells you which rule caught each file ( .gitignore:7 *.env ), so there's no guessing. And --apply runs the git rm --cached for you — it only un-tracks, it never deletes your working copy. Why not just grep? You can grep your .gitignore patterns against git ls-files . But: A raw grep '\.env' can't tell a still-tracked leftover from a file that's correctly excluded, and it has no idea about !negation rules, build/ directory rules, nested .gitignore files, .git/info/exclude , or your global core.excludesFile . Reimplementing gitignore's matching semantics to get this right is exactly the kind of subtly-wrong code you don't want guarding your secrets. gitslip doesn't reimplement anything. It asks git. How it works (the fun part) Detection is a single git incantation: git ls-files -i -c --exclude-standard -c = tracked (cached), -i = ignored, --exclude-standard = use all the

2026-06-19 原文 →
AI 资讯

Structuring TypeScript: Interfaces, Type Aliases, Enums, and Object Types

Structuring TypeScript: Interfaces, Type Aliases, Enums, and Object Types You've learned TypeScript's primitive types and the basics of type inference here . Now it's time to model real-world data — users, orders, API responses, configuration objects. That's where interfaces, type aliases, and enums come in. These three features are what make TypeScript genuinely powerful for building applications. Let's dig in. Object Types: Describing the Shape of Data Before we get to interfaces, let's understand object types. When you want to describe the structure of an object, you define what properties it has and what types those properties are: // Inline object type annotation function displayUser ( user : { name : string ; age : number ; email : string }): void { console . log ( ` ${ user . name } ( ${ user . age } ) — ${ user . email } ` ); } This works, but it's messy to repeat everywhere. That's why we use type aliases and interfaces to name and reuse these shapes. Type Aliases: Naming a Type A type alias gives a name to any type — primitives, unions, objects, or combinations: // Alias for a primitive union type ID = string | number ; // Alias for an object shape type User = { id : ID ; name : string ; age : number ; email : string ; }; // Now use it anywhere const user : User = { id : 1 , name : " Ramesh " , age : 31 , email : " ramesh@example.com " , }; function getUser ( id : ID ): User { // ... fetch user logic } Type aliases are flexible — they can represent almost anything. Interfaces: Defining Object Contracts An interface is specifically designed to describe the shape of an object. Syntax is slightly different: interface User { id : number ; name : string ; age : number ; email : string ; } const user : User = { id : 1 , name : " Ramesh " , age : 31 , email : " ramesh@example.com " , }; Optional and Readonly Properties Properties can be marked as optional ( ? ) or read-only ( readonly ): interface UserProfile { readonly id : number ; // Can't be changed after cre

2026-06-19 原文 →