### Go Fiber JWT Authentication Setup Source: https://context7_llms Guides through setting up a Go Fiber project with JWT authentication. Includes creating a project, installing dependencies, defining JWT middleware, creating a login handler to generate tokens, and registering these components with the Fiber app. ```bash mkdir go-fiber-jwt cd go-fiber-jwt go mod init go-fiber-jwt ``` ```bash go get github.com/gofiber/fiber/v2 go get github.com/gofiber/contrib/jwt ``` ```Go // jwt.go package main import ( jwtware "github.com/gofiber/contrib/jwt" "github.com/gofiber/fiber/v2" ) // Protected jwt 校验中间件 func Protected() fiber.Handler { return jwtware.New(jwtware.Config{ SigningKey: jwtware.SigningKey{Key: []byte("JWT密钥")}, ErrorHandler: jwtError, }) } // jwt 校验错误处理器 func jwtError(c *fiber.Ctx, _ error) error { return c.Status(fiber.StatusUnauthorized).SendString("缺少 JWT 或 JWT 格式错误") } ``` ```Go // login.go package main import ( "fmt" "github.com/gofiber/fiber/v2" "github.com/golang-jwt/jwt/v5" time "time" ) // LoginRequest 登录请求 type LoginRequest struct { Username string `json:"username"` Password string `json:"password"` } // Login 登录获取 token func Login(ctx *fiber.Ctx) error { var err error loginRequest := LoginRequest{} // 获取登录请求体 err = ctx.BodyParser(&loginRequest) if err != nil { return err } // TODO 检查用户名密码 // 生成 token 返回 jwts := jwt.New(jwt.SigningMethodHS256) claims := jwts.Claims.(jwt.MapClaims) claims["username"] = loginRequest.Username // 过期时间 claims["exp"] = time.Now().Add(time.Hour * 24).Unix() token, err := jwts.SignedString([]byte("JWT密钥")) if err != nil { return err } return ctx.SendString(token) } ``` ```Go // main.go package main import ( "github.com/gofiber/fiber/v2" "log" time "time" ) func main() { app := fiber.New() // 设置路由 app.Get("/login", Login) // 需要保护的路由添加中间件即可 app.Get("/hello", Protected(), func(ctx *fiber.Ctx) error { return ctx.SendString("hello") }) // 启动 log.Fatal(app.Listen(":8080")) } ``` -------------------------------- ### Guides Section Styling Source: https://spring.io/blog/2023/11/23/spring-boot-3-2-0-available-now Styles for the guides section, including hero elements, layout for guide links, and sticky positioning for navigation. Facilitates organized browsing of documentation. ```css .guides .hero-guides h1 { margin-bottom: .5rem; margin-top: 0 } .guides .hero-guides .image { left: 50px; position: absolute; top: 50px; width: 200px } .guides .hero-guides .content { height: 350px; margin: 0 auto; max-width: 1200px; padding: 90px 0 90px 300px; position: relative } .guides .hero-guides .links { bottom: -30px; left: 0; position: absolute; right: 0 } .guides .hero-guides .description { font-size: 1.2rem; margin-top: 0 } .guides .hero-guides .icon { color: #5c9f9f; margin-bottom: -20px } .guides .hero-guides a.box.is-special { border-top: 4px solid #6db33f; margin: 0 1rem; padding: 40px 0 } .guides .hero-guides a.box.is-special:hover .icon { color: #6db33f } .guides .b-checkbox.checkbox.is-small { font-size: .9rem } .guides .extra-0 { background: linear-gradient(90deg, #6db33f 50%, #80ea6e 0); height: 10px; overflow: hidden; position: sticky; position: -webkit-sticky; text-align: center; top: 0; z-index: 99 } .guides .search { margin: 0 auto; max-width: 500px; position: relative; text-align: right } .guides .search .input.is-special { margin-left: auto; padding-left: 50px } .guides .search .icon { height: 20px; left: 14px; position: absolute; top: 14px } .guides .search-sticky { background-color: #fff; position: sticky; position: -webkit-sticky; top: 10px; z-index: 9 } .guides .is-sticky { position: sticky; position: -webkit-sticky; top: 100px; z-index: 77 } .guides .columns-list, .guides .rows { margin: 0 -20px } .guides .columns-list article.column, .guides .rows article.column { padding-bottom: 0; padding-top: 0 } .guides .columns-list .tag, .guides .rows .tag { font-weight: 700 } .guides .columns-list a.guide-link, .guides .rows a.guide-link { color: #111; display: flex; flex-direction: column; height: 100%; min-height: 54px; padding: 20px; transition: all .2s } .guides .columns-list a.guide-link h2, .guides .rows a.guide-link h2 { color: #111; font-weight: 500 } .guides .columns-list a.guide-link:hover, .guides .rows a.guide-link:hover { border-color: #cbdbdb; box-shadow: 0 10px 20px 0 rgba(108, 135, 135, .2); text-decoration: none; top: -3px; transform: translateY(-3px) } .guides .columns-list a.guide-link .categories, .guides .rows a.guide-link .categories { margin-top: auto } .guides .cross-list { margin: 2rem -12px } .guides .cross-list a.box.is-special { border: 2px solid #ebf2f2; border-radius: 5px; height: 100% } .guides .cross-list a.box.is-special h2 { color: #086dc3 } .guides .cross-list a.box.is-special:hover { text-decoration: none } .guides.guides-category .extra img { height: 675px; position: absolute; right: -100px; top: -320px } .guide .tag-special:not(body).is-primary { background-color: #80ea6e; color: #111; font-weight: 700 } .guide .special-link { display: flex } .guide .logo-spring-sm { min-width: 20px; width: 20px } .guide .ascii-doc ul { list-style-type: disc } .guide .ascii-doc ol, .guide .ascii-doc ul { padding: .3rem 0 .3rem 40px } .guide .ascii-doc code, .guide .ascii-doc pre { background: #fff; border: 1px solid #e1e1e8; font-family: Monaco, monospace; font-size: 15px; overflow-x: auto; padding: 10px } .guide .ascii-doc code { white-space: nowrap } .guide .ascii-doc pre { margin: 1rem 0; position: relative } .guide .ascii-doc pre code { border: none; padding: 0; white-space: pre-w } ``` -------------------------------- ### FFmpeg Basic Usage and Full Example Source: https://context7_llms Explains the fundamental structure of FFmpeg commands and provides a comprehensive example demonstrating hardware acceleration (QSV), audio/video codec copying, quality presets, bitrate control, scaling, and stream removal. ```bash ### 基础用法 ffmpeg [全局参数] [输入文件参数] -i [输入文件] [输出文件参数] [输出文件] ### 完整示例 ffmpeg -y \ # 使用qsv硬件解码 -hwaccel qsv -hwaccel_output_format qsv -init_hw_device qsv=hw \ -i [input] \ # 音频编码器 # libx264 h264_nvenc h264_qsv libx265 hevc_qsv libvpx-vp9 vp9_qsv libaom-av1 -c:a copy \ # 视频编码器 -c:v copy \ # 质量 -preset slow\ # 码率 -minrate 964K -maxrate 3856K -bufsize 2000K \ # 720p -vf scale=720:-1 \ # 去除流 -an -vn \ [output] ``` -------------------------------- ### Scoop Installation and Configuration Source: https://context7_llms Instructions for installing and configuring the scoop package manager on Windows, including setting environment variables, execution policies, and proxy settings. ```powershell $env:SCOOP='D:\scoop' [Environment]::SetEnvironmentVariable('USERSCOOP', $env:SCOOP, 'User') $env:SCOOP_GLOBAL='D:\scoop' [Environment]::SetEnvironmentVariable('SCOOP_GLOBAL', $env:SCOOP_GLOBAL, 'Machine') ``` ```powershell Set-ExecutionPolicy RemoteSigned -Scope CurrentUser irm get.scoop.sh | iex ``` ```powershell scoop update ``` ```powershell scoop config proxy localhost:7891 ``` ```powershell scoop install aria2 scoop config aria2-warning-enabled false ``` -------------------------------- ### DOM Guides Source: https://developer.mozilla.org/zh-CN/docs/Web/API/crossOriginIsolated References to guides and tutorials for working with the Document Object Model (DOM) in web development. ```APIDOC DOM Guides: - DOM Overview: A general introduction to the Document Object Model. - Using the Document Object Model: Practical guidance on manipulating the DOM. - Attribute reflection: How attributes are reflected as DOM properties. - Traversing HTML tables with JavaScript and DOM interfaces: Techniques for navigating table structures. - Locating DOM elements using selectors: Methods for finding elements in the DOM. - Transforming with XSLT: Using XSLT to transform XML documents. - Examples of web and XML development using the DOM: Practical code examples. ``` -------------------------------- ### HTTP Interface Method Chaining Examples Source: https://docs.spring.io/spring-framework/reference/integration/rest-clients.html Provides examples of common method chaining patterns used when building HTTP requests with Spring's HTTP interfaces, illustrating how to specify HTTP methods, URIs, headers, and retrieve results. ```APIDOC method(HttpMethod) .uri(URI) .headers(Consumer) .body(Object) .retrieve() .toEntity(Class) - Builds and executes an HTTP request with specified method, URI, headers, and body. - retrieve() initiates the request execution. - toEntity(Class) specifies the expected response body type. method(HttpMethod) .uri(URI) .headers(Consumer) .body(Object) .retrieve() .toEntity(ParameterizedTypeReference) - Similar to the above, but uses ParameterizedTypeReference for generic response types. exchange(RequestEntity, ParameterizedTypeReference) - Executes a request using a pre-built RequestEntity and specifies the response type using ParameterizedTypeReference. execute(String, HttpMethod, RequestCallback, ResponseExtractor, Object…​) - A lower-level execution method allowing custom request callbacks and response extraction. method(HttpMethod) .uri(String, Object…​) .exchange(ExchangeFunction) - Builds a request with a URI template and parameters, then executes it via an ExchangeFunction. execute(String, HttpMethod, RequestCallback, ResponseExtractor, Map) - Another variant of execute, accepting parameters as a Map. method(HttpMethod) .uri(String, Map) .exchange(ExchangeFunction) - Builds a request with a URI template and parameters provided as a Map, executed via an ExchangeFunction. execute(URI, HttpMethod, RequestCallback, ResponseExtractor) - Executes a request with a URI object, HTTP method, custom callback, and response extractor. ``` -------------------------------- ### Gin Framework File Upload/Download with Minio Source: https://context7_llms Demonstrates server-side file upload and download using the Gin framework and Minio object storage. Includes setup for Minio client and Gin router. ```Shell go get github.com/gin-gonic/gin ``` ```Go package main import ( "context" "github.com/gin-gonic/gin" "log" "net/http" "github.com/minio/minio-go/v7" "github.com/minio/minio-go/v7/pkg/credentials" ) func main() { // 创建一个上下文,用于超时和取消等操作的处理,这里直接使用默认的实现 ctx := context.Background() // 创建 minio 客户端 endpoint := "127.0.1:9000" id := "admin" secret := "adminadmin" SessionToken := "" bucketName := "test" minioClient, err := minio.New(endpoint, &minio.Options{ Creds: credentials.NewStaticV4(id, secret, SessionToken), }) if err != nil { log.Fatalln(err) } // 创建 gin 路由 router := gin.Default() // 文件上传 router.POST("/upload", func(c *gin.Context) { // 读取文件 file, _ := c.FormFile("file") reader, _ := file.Open() defer func() { // 关闭流 _ = reader.Close() }() // 上传到 minio object, _ := minioClient.PutObject(ctx, bucketName, file.Filename, reader, file.Size, minio.PutObjectOptions{}) // 返回上传文件的信息 c.JSON(http.StatusOK, object) }) // 文件下载 router.GET("/file/:name", func(c *gin.Context) { name := c.Param("name") // 读取文件 object, _ := minioClient.GetObject(ctx, bucketName, name, minio.GetObjectOptions{}) defer func() { // 关闭流 _ = object.Close() }() // 返回文件 c.DataFromReader(http.StatusOK, -1, "application/stream", object, nil) }) // 监听 8080 _ = router.Run(":8080") } ``` -------------------------------- ### Fiber Framework File Upload/Download with Minio Source: https://context7_llms Demonstrates server-side file upload and download using the Fiber framework and Minio object storage. Includes setup for Minio client and Fiber app. ```Shell go get github.com/gofiber/fiber/v2 ``` ```Go package main import ( "context" "github.com/gofiber/fiber/v2" "github.com/gofiber/fiber/v2/utils" "github.com/minio/minio-go/v7" "github.com/minio/minio-go/v7/pkg/credentials" "log" ) func main() { // 创建一个上下文,用于超时和取消等操作的处理,这里直接使用默认的实现 ctx := context.Background() // 创建 minio 客户端 endpoint := "127.0.1:9000" id := "admin" secret := "adminadmin" SessionToken := "" bucketName := "test" minioClient, err := minio.New(endpoint, &minio.Options{ Creds: credentials.NewStaticV4(id, secret, SessionToken), }) if err != nil { log.Fatalln(err) } // 创建 fiber 路由 app := fiber.New() // 文件上传 app.Post("/upload", func(c *fiber.Ctx) error { // 读取文件 file, err := c.FormFile("file") if err != nil { return err } reader, err := file.Open() if err != nil { return err } defer func() { // 关闭流 _ = reader.Close() }() // 上传到 minio filename := utils.UUID() contentType := file.Header["Content-Type"][0] object, err := minioClient.PutObject(ctx, bucketName, filename, reader, file.Size, minio.PutObjectOptions{ ContentType: contentType, }) if err != nil { return err } // 返回上传文件的信息 return c.JSON(object) }) // 文件下载 app.Get("/file/:name", func(c *fiber.Ctx) error { name := c.Params("name", "") // 读取文件 object, err := minioClient.GetObject(ctx, bucketName, name, minio.GetObjectOptions{}) if err != nil { return err } // 返回文件 return c.SendStream(object) }) // 监听 8080 log.Fatal(app.Listen(":8080")) } ``` -------------------------------- ### Scoop Basic Usage Commands Source: https://context7_llms Essential scoop commands for managing software, including updating, listing, searching, installing, and cleaning up packages and cache. ```shell scoop update ``` ```shell scoop list ``` ```shell scoop search ``` ```shell scoop install / ``` ```shell scoop install openjdk17 python go nodejs-lts ``` ```shell scoop status ``` ```shell scoop update or scoop update * ``` ```shell scoop cache rm * ``` ```shell scoop cleanup or scoop cleanup * ``` ```shell scoop help ``` -------------------------------- ### JavaScript Currying Function Example Source: https://context7_llms Illustrates the concept of currying in JavaScript, where a function that takes multiple arguments is transformed into a sequence of functions, each taking a single argument. This example shows how to curry a function and use it for partial application and delayed execution. ```javascript // 柯里化函数 function curry(fn) { return function curried(...args) { if (args.length >= fn.length) { return fn(...args) } else { return function (...nextArgs) { return curried(...args, ...nextArgs) } } } } // 原始函数 function add(a, b, c) { return a + b + c } // 柯里化后的函数 const curriedAdd = curry(add) console.log(curriedAdd(1)(2)(3)) // 输出 6 console.log(curriedAdd(1, 2)(3)) // 输出 6 console.log(curriedAdd(1)(2, 3)) // 输出 6 ``` -------------------------------- ### Spring Dependency Injection and Configuration Source: https://docs.spring.io/spring-framework/reference/integration/rest-clients.html Comprehensive guide to Dependency Injection (DI) in Spring, including detailed configuration, various injection methods, and advanced autowiring techniques. ```APIDOC Spring Dependency Injection and Configuration: Dependencies and Configuration in Detail - Elaborates on how to configure dependencies between beans, including constructor injection and setter injection. Dependency Injection - Explains the core principles of Dependency Injection and its implementation within the Spring Framework. Using `depends-on` - Describes the use of the `depends-on` attribute to explicitly control the initialization order of beans. Lazy-initialized Beans - Details how to configure beans for lazy initialization, deferring their instantiation until they are first requested. Autowiring Collaborators - Explains Spring's autowiring capabilities, allowing the container to resolve dependencies automatically based on type, name, or constructor. Method Injection - Covers the concept of method injection, where a container-managed bean can obtain lookups for other container-managed beans through abstract methods. ``` -------------------------------- ### JavaScript Proxy Get Example Source: https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Proxy Demonstrates the use of the 'get' trap in a JavaScript Proxy. This example sets a default value of 37 for any property that does not exist on the target object. ```javascript const handler = { get: function (obj, prop) { return prop in obj ? obj[prop] : 37; }, }; const p = new Proxy({}, handler); p.a = 1; p.b = undefined; console.log(p.a, p.b); // 1, undefined console.log("c" in p, p.c); // false, 37 ``` -------------------------------- ### Caddy Site Configuration Examples Source: https://context7_llms Demonstrates Caddy site configurations for different domains, including redirection to a www subdomain and routing API requests or serving static files for a single-page application. It imports the common configuration block. ```caddy # 站点配置 example.org { # 重定向到www redir https://www.example.org{uri} import COMMON_CONFIG } blog.example.org { # 重定向到www redir https://www.example.org{uri} import COMMON_CONFIG } www.example.org { root * /home/user/blog/dist route { # handle_path 去除前缀,handle 保留 handle_path /api/* { # 反向代理 reverse_proxy localhost:8080 } # 单页面应用 try_files {path}.html {path} / file_server } import COMMON_CONFIG } ``` -------------------------------- ### Proxy get handler example Source: https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Proxy Demonstrates the `get` handler of the Proxy object. It returns a default value (37) when a property is not found in the target object, showcasing property access interception. ```js const handler = { get: function (obj, prop) { return prop in obj ? obj[prop] : 37; }, }; const p = new Proxy({}, handler); p.a = 1; p.b = undefined; console.log(p.a, p.b); // 1, undefined console.log("c" in p, p.c); // false, 37 ``` -------------------------------- ### FFmpeg Video Screenshotting (Interval) Source: https://context7_llms Provides a command to capture frames from a video at specified intervals. This example extracts one frame per second starting from 1 minute and 24 seconds into the video. ```bash ### 截图(从 1:24 开始,每秒一张) ffmpeg -y -i input.mp4 -ss 00:01:24 -t 00:00:01 output_%3d.jpg ``` -------------------------------- ### Custom Setter and Getter for Archiving Source: https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperty Shows how to implement custom getter and setter functions for a property. This example creates an 'Archiver' object where setting the 'temperature' property logs the value and archives it, while getting it returns the current temperature. ```js function Archiver() { let temperature = null; const archive = []; Object.defineProperty(this, "temperature", { get() { console.log("get!"); return temperature; }, set(value) { temperature = value; archive.push({ val: temperature }); }, }); this.getArchive = () => archive; } const arc = new Archiver(); arc.temperature; // 'get!' arc.temperature = 11; arc.temperature = 13; arc.getArchive(); // [{ val: 11 }, { val: 13 }] ``` -------------------------------- ### Spring RestClient Usage Source: https://context7_llms An example of using Spring's RestClient, introduced in Spring 6.1, for making non-reactive HTTP requests. It demonstrates creating a RestClient instance and performing a GET request to fetch repository data from GitHub. ```APIDOC RestClient Usage: RestClient.create() - Creates a new RestClient instance with default configuration. restClient.get() - Initiates a GET request. .uri("https://api.github.com/users/{username}/repos", "blyrin") - Specifies the URI for the request, allowing path variables. - Parameters: - uri: The target URL string, potentially with placeholders. - varargs: Values to substitute into the URI placeholders. .accept(MediaType.APPLICATION_JSON) - Sets the Accept header to request JSON responses. - Parameters: - mediaType: The desired media type (e.g., MediaType.APPLICATION_JSON). .acceptCharset(StandardCharsets.UTF_8) - Sets the Accept-Charset header to specify the preferred character encoding. - Parameters: - charset: The desired character set (e.g., StandardCharsets.UTF_8). .retrieve() - Executes the request and prepares for response processing. .toEntity(Object.class) - Retrieves the response body and maps it to a specified entity type (Object.class in this case). - Returns: A ResponseEntity containing the status code, headers, and the body. Related Methods: - post(), put(), delete(), etc. for other HTTP methods. - .body(...) to set the request body. - .exchangeToMono(...) or .exchangeToFlux(...) for reactive processing (if applicable). - .onStatus(...) for custom error handling based on status codes. ``` -------------------------------- ### Minio Go SDK Basic Operations Source: https://context7_llms Demonstrates essential operations using the Minio Go SDK, including client initialization, uploading files, downloading files, and deleting files from Minio storage. ```bash go get github.com/minio/minio-go/v7 ``` ```Go package main import ( "context" "log" "github.com/minio/minio-go/v7" "github.com/minio/minio-go/v7/pkg/credentials" ) func main() { // 创建一个上下文,用于超时和取消等操作的处理,这里直接使用默认的实现 ctx := context.Background() // 创建 minio 客户端 endpoint := "127.0.1:9000" id := "admin" secret := "adminadmin" SessionToken := "" minioClient, err := minio.New(endpoint, &minio.Options{ Creds: credentials.NewStaticV4(id, secret, SessionToken), }) if err != nil { log.Fatalln(err) } // ... // 上传本地文件 bucketName := "test" objectName := "123.jpg" filePath := "test.jpg" info, err := minioClient.FPutObject(ctx, bucketName, objectName, filePath, minio.PutObjectOptions{}) if err != nil { log.Fatalln(err) } // 输出上传文件信息 log.Printf("上传完成\n%#v", info) // 下载文件到本地 // bucketName := "test" // objectName := "123.jpg" // filePath := "456.jpg" err = minioClient.FGetObject(ctx, bucketName, objectName, filePath, minio.GetObjectOptions{}) if err != nil { log.Fatalln(err) } // 删除文件 // bucketName := "test" // objectName := "123.jpg" err = minioClient.RemoveObject(ctx, bucketName, objectName, minio.RemoveObjectOptions{}) } ``` -------------------------------- ### FFmpeg Create Video from Audio and Image Source: https://context7_llms Explains how to create a video file by combining an audio track with a static image. The image is looped, and the video duration is determined by the audio file's length. ```bash ### 音频添加图片输出视频 ffmpeg \ -loop 1 \ -i cover.jpg -i input.mp3 \ -c:v libx264 -c:a aac -b:a 192k -shortest \ output.mp4 ``` -------------------------------- ### JavaScript Proxy for docCookies Source: https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Proxy This example creates a JavaScript Proxy to wrap a `docCookies` object, intercepting fundamental operations like getting, setting, and deleting properties. It enhances the cookie management interface by defining custom behavior for these operations. ```javascript /* The docCookies object is assumed to be obtained from: https://reference.codeproject.com/dom/document/cookie/simple_document.cookie_framework */ const docCookies = new Proxy(docCookies, { get(target, key) { return target[key] ?? target.getItem(key) ?? undefined; }, set(target, key, value) { if (key in target) { return false; } return target.setItem(key, value); }, deleteProperty(target, key) { if (!(key in target)) { return false; } return target.removeItem(key); }, ownKeys(target) { return target.keys(); }, has(target, key) { return key in target || target.hasItem(key); }, defineProperty(target, key, descriptor) { if (descriptor && "value" in descriptor) { target.setItem(key, descriptor.value); } return target; }, getOwnPropertyDescriptor(target, key) { const value = target.getItem(key); return value ? { value, writable: true, enumerable: true, configurable: false, } : undefined; }, }); /* Cookie Testing */ console.log((docCookies.myCookie1 = "First value")); console.log(docCookies.getItem("myCookie1")); docCookies.setItem("myCookie1", "Changed value"); console.log(docCookies.myCookie1); ``` -------------------------------- ### Value Correction and Attached Properties with Proxy Source: https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Proxy Illustrates using Proxy's 'get' and 'set' traps for value correction and managing attached properties. This example ensures data is stored in the correct format (array) and provides access to a computed property ('latestBrowser'). ```javascript let products = new Proxy( { browsers: ["Internet Explorer", "Netscape"], }, { get: function (obj, prop) { // Attach a property if (prop === "latestBrowser") { return obj.browsers[obj.browsers.length - 1]; } // Default behavior is to return the property value return obj[prop]; }, set: function (obj, prop, value) { // Attach a property if (prop === "latestBrowser") { obj.browsers.push(value); return; } // If not an array, convert it if (typeof value === "string") { value = [value]; } // Default behavior is to save the property value obj[prop] = value; // Indicate success return true; }, }, ); console.log(products.browsers); // ['Internet Explorer', 'Netscape'] products.browsers = "Firefox"; // Handles string input console.log(products.browsers); // ['Firefox'] products.latestBrowser = "Chrome"; console.log(products.browsers); // ['Firefox', 'Chrome'] console.log(products.latestBrowser); // 'Chrome' ``` -------------------------------- ### Disk and PE Tools Source: https://context7_llms Recommendation for Ventoy, a tool for creating bootable USB drives from ISO files. ```APIDOC Ventoy: Description: An open-source tool to create a bootable USB drive from ISO, WIM, IMG, VHD(x), EFI files. Features: - Boot from 2000+ ISO files directly without extraction. - Supports Legacy BIOS and UEFI. - Supports Secure Boot. - Supports most types of ISO files. - Plugin and Theme support. Installation: - Download the Ventoy package for your OS. - Run the Ventoy2Disk.exe application. - Select the target USB drive and click 'Install'. Usage: - After installation, copy your ISO files to the Ventoy USB drive. - Boot from the USB drive, and Ventoy will present a menu of the ISO files. Source: (Implied from context, typically https://www.ventoy.net/) ``` -------------------------------- ### FFmpeg Information Commands Source: https://context7_llms Shows how to list all supported encoders and container formats (file extensions) that FFmpeg can handle. This is useful for understanding FFmpeg's capabilities. ```bash ### 查看支持的编码器 ffmpeg -encoders ### 查看支持的容器格式(后缀名) ffmpeg -formats ``` -------------------------------- ### System Information and Optimization Tools Source: https://context7_llms Recommendations for various Windows utility tools focused on system information, optimization, and management, with download sources. ```APIDOC AIDA64: Description: Comprehensive system information and diagnostic tool. Download: https://www.aida64.com/downloads Autoruns: Description: Displays information about what programs are configured to run during system startup or login. Download: https://learn.microsoft.com/zh-cn/sysinternals/downloads/autoruns Defender Control: Description: Tool to completely disable or enable Windows Defender Antivirus. Download: Search on sordum.org Windows Update Blocker: Description: Utility to block or unblock Windows updates. Download: Search on sordum.org DXVA Checker: Description: Checks supported video codecs and DXVA decoding capabilities. Download: https://bluesky-soft.com/en/DXVAChecker.html NatTypeTester: Description: Checks the NAT type of the current network connection. Source: https://github.com/HMBSbige/NatTypeTester noMeiryoUI: Description: Utility for changing system fonts. Source: https://github.com/Tatsu-syo/noMeiryoUI Optimizer: Description: A collection of optimization tools for Windows. Source: https://github.com/hellzerg/optimizer Process Explorer: Description: Advanced task manager for Windows, showing detailed process information. Download: https://learn.microsoft.com/zh-cn/sysinternals/downloads/process-explorer PowerSettingsExplorer: Description: Tool for adjusting power configuration settings, including core priority. Download: Contact author (link not provided in source) RunAsDate: Description: Utility to run a program with a specific date and time. Download: https://www.nirsoft.net/utils/run_as_date.html Windows11Manager: Description: A suite of optimization and management tools for Windows. Download: https://www.yamicsoft.com/cn/index.html CompactGUI: Description: Graphical tool for managing Windows Compact OS features. Source: https://github.com/IridiumIO/CompactGUI ContextMenuManager: Description: Tool for managing entries in the Windows context menu (right-click menu). Source: https://github.com/BluePointLilac/ContextMenuManager InSpectre: Description: Tool to enable or disable microcode patches for Spectre vulnerabilities. Download: https://www.grc.com/inspectre.htm Malware Patch (MWP): Description: Software patcher, potentially for security or functionality. Source: https://github.com/the1812/Malware-Patch TCPOptimizer: Description: Network optimization tool for tuning TCP/IP parameters. Download: https://www.speedguide.net/downloads.php ``` -------------------------------- ### 彻底关闭 Hyper-V 和相关虚拟化服务 (Powershell) Source: https://context7_llms 通过 PowerShell 命令禁用 Windows 的 Hyper-V 虚拟化平台及其相关服务,以提升系统性能。此操作会影响 WSL2、Docker Desktop 等依赖 Hyper-V 的软件。需要管理员权限执行。 ```powershell # 关闭 Hyper-V 虚拟化层 Disable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V-Hypervisor bcdedit /set hypervisorlaunchtype off # 关闭内存完整性 (在“设备安全性”中设置) # 关闭 Device Guard (通过注册表修改) # HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\DeviceGuard # EnableVirtualizationBasedSecurity = 0 # RequirePlatformSecurityFeatures = 0 ``` -------------------------------- ### Widevine CDM Installation Structure Source: https://context7_llms This entry details the file structure and placement for installing the Widevine Content Decryption Module (CDM) into ungoogled-chromium to enable DRM playback for protected content. ```text WidevineCdm (如果不存在则新建) ├── LICENSE.txt ├── manifest.json │ ├── _platform_specific ├── win_x64 (这个文件夹名需要根据你实际下载的决定) ├── widevinecdm.dll ├── widevinecdm.dll.lib ├── widevinecdm.dll.sig ``` -------------------------------- ### 禁用基于虚拟化的安全性 (VBS) Source: https://context7_llms 通过删除注册表项和修改 bcdedit 设置来禁用基于虚拟化的安全性。需要管理员权限执行。 ```text HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\DeviceGuard - EnableVirtualizationBasedSecurity - RequirePlatformSecurityFeatures ``` ```cmd bcdedit /set {0cb3b571-2f2e-4343-a879-d86a476d7215} loadoptionsDISABLE-LSA-ISO,DISABLE-VBS bcdedit /set vsmlaunchtype off ``` -------------------------------- ### RestTemplate getForEntity to RestClient get with URI Source: https://docs.spring.io/spring-framework/reference/integration/rest-clients.html Maps RestTemplate's getForEntity with a URI object to RestClient's equivalent using get(), uri(), retrieve(), and toEntity(). This covers retrieving the response entity. ```APIDOC RestTemplate: getForEntity(URI url, Class responseType) - Retrieves an entity by making a GET request to the specified URI. - Parameters: - url: The URI to retrieve the entity from. - responseType: The class of the response body. - Returns: The response entity. RestClient: get() .uri(URI uri) .retrieve() .toEntity(Class responseType) - Retrieves an entity by making a GET request. - Parameters: - uri: The URI to retrieve the entity from. - Returns: The response entity. ``` -------------------------------- ### 解决“无法打开此 'ms-gamingoverlay' 链接”弹窗 (Regedit) Source: https://context7_llms 通过修改注册表禁用 Windows Game DVR 功能来解决打开游戏时出现的“无法打开此 'ms-gamingoverlay' 链接”弹窗问题。需要修改 `GameDVR` 和 `GameConfigStore` 下的键值。 ```text 1. 打开运行(Win+R),并输入 `regedit` 命令,按确定或回车 2. 定位如下位置: ```text HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\GameDVR ``` 找到`AppCaptureEnabled`这个键值,把值改为 0 3. 定位如下位置: ```text HKEY_CURRENT_USER\System\GameConfigStore ``` 找到 `GameDVR_Enabled` 这个键值,把值改为 0 ``` -------------------------------- ### RestTemplate getForEntity to RestClient get Source: https://docs.spring.io/spring-framework/reference/integration/rest-clients.html Maps RestTemplate's getForEntity with String URI and varargs to RestClient's equivalent using get(), uri(), retrieve(), and toEntity(). This covers retrieving the response entity. ```APIDOC RestTemplate: getForEntity(String url, Class responseType, Object... uriVariables) - Retrieves an entity by making a GET request to the specified URL. - Parameters: - url: The URL to retrieve the entity from. - responseType: The class of the response body. - uriVariables: Variables to substitute in the URL. - Returns: The response entity. RestClient: get() .uri(String url, Object... uriVariables) .retrieve() .toEntity(Class responseType) - Retrieves an entity by making a GET request. - Parameters: - url: The URL to retrieve the entity from. - uriVariables: Variables to substitute in the URL. - Returns: The response entity. ``` -------------------------------- ### RestTemplate getForObject to RestClient get with URI Source: https://docs.spring.io/spring-framework/reference/integration/rest-clients.html Maps RestTemplate's getForObject with a URI object to RestClient's equivalent using get(), uri(), retrieve(), and body(). This covers retrieving an object from a URL. ```APIDOC RestTemplate: getForObject(URI url, Class responseType) - Retrieves an object by making a GET request to the specified URI. - Parameters: - url: The URI to retrieve the object from. - responseType: The class of the object to return. - Returns: The response body as an object of the specified type. RestClient: get() .uri(URI uri) .retrieve() .body(Class responseType) - Retrieves an object by making a GET request. - Parameters: - uri: The URI to retrieve the object from. - Returns: The response body as an object of the specified type. ``` -------------------------------- ### Logback Configuration for Console and File Output Source: https://context7_llms This configuration sets up logback for console output with color rendering and file output for DEBUG, INFO, and WARN levels. It includes rolling policies based on size and time, with specified history and size caps for archived logs. ```xml logback debug ${CONSOLE_LOG_PATTERN} UTF-8 ${log.path}/debug.log %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n UTF-8 ${log.path}/debug-%d{yyyy-MM-dd}.%i.log 100MB 60 20GB debug ACCEPT DENY ${log.path}/info.log %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n UTF-8 ${log.path}/info-%d{yyyy-MM-dd}.%i.log 100MB 60 20GB info ACCEPT DENY ${log.path}/warn.log %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n UTF-8 ``` -------------------------------- ### RestTemplate getForObject to RestClient get Source: https://docs.spring.io/spring-framework/reference/integration/rest-clients.html Maps RestTemplate's getForObject with String URI and varargs to RestClient's equivalent using get(), uri(), retrieve(), and body(). This covers retrieving an object from a URL. ```APIDOC RestTemplate: getForObject(String url, Class responseType, Object... uriVariables) - Retrieves an object by making a GET request to the specified URL. - Parameters: - url: The URL to retrieve the object from. - responseType: The class of the object to return. - uriVariables: Variables to substitute in the URL. - Returns: The response body as an object of the specified type. RestClient: get() .uri(String url, Object... uriVariables) .retrieve() .body(Class responseType) - Retrieves an object by making a GET request. - Parameters: - url: The URL to retrieve the object from. - uriVariables: Variables to substitute in the URL. - Returns: The response body as an object of the specified type. ``` -------------------------------- ### 使用 HTML Meta 标签防止搜索引擎索引 Source: https://context7_llms 通过在 HTML 的 `` 部分添加 `` 标签,指示搜索引擎不要索引此页面内容,也不要跟踪页面上的链接。这是一种基本的 SEO 控制方法。 ```html ``` -------------------------------- ### RestTemplate getForEntity to RestClient get with Map Source: https://docs.spring.io/spring-framework/reference/integration/rest-clients.html Maps RestTemplate's getForEntity with String URI and Map for variables to RestClient's equivalent using get(), uri(), retrieve(), and toEntity(). This covers retrieving the response entity. ```APIDOC RestTemplate: getForEntity(String url, Class responseType, Map uriVariables) - Retrieves an entity by making a GET request to the specified URL. - Parameters: - url: The URL to retrieve the entity from. - responseType: The class of the response body. - uriVariables: A Map of variables to substitute in the URL. - Returns: The response entity. RestClient: get() .uri(String url, Map uriVariables) .retrieve() .toEntity(Class responseType) - Retrieves an entity by making a GET request. - Parameters: - url: The URL to retrieve the entity from. - uriVariables: A Map of variables to substitute in the URL. - Returns: The response entity. ``` -------------------------------- ### RestTemplate getForObject to RestClient get with Map Source: https://docs.spring.io/spring-framework/reference/integration/rest-clients.html Maps RestTemplate's getForObject with String URI and Map for variables to RestClient's equivalent using get(), uri(), retrieve(), and body(). This covers retrieving an object from a URL. ```APIDOC RestTemplate: getForObject(String url, Class responseType, Map uriVariables) - Retrieves an object by making a GET request to the specified URL. - Parameters: - url: The URL to retrieve the object from. - responseType: The class of the object to return. - uriVariables: A Map of variables to substitute in the URL. - Returns: The response body as an object of the specified type. RestClient: get() .uri(String url, Map uriVariables) .retrieve() .body(Class responseType) - Retrieves an object by making a GET request. - Parameters: - url: The URL to retrieve the object from. - uriVariables: A Map of variables to substitute in the URL. - Returns: The response body as an object of the specified type. ```