This document provides guidelines for maintaining high-quality Python code. These rules MUST be followed by all AI coding agents and contributors.
All code you write MUST be fully optimized.
"Fully optimized" includes:
| const path = require('path'); | |
| const readline = require('readline'); | |
| const mongoose = require(path.resolve(__dirname, '..', 'api', 'node_modules', 'mongoose')); | |
| const { User } = require('@librechat/data-schemas').createModels(mongoose); | |
| const { SystemRoles } = require('librechat-data-provider'); | |
| require('module-alias')({ base: path.resolve(__dirname, '..', 'api') }); | |
| const connect = require('./connect'); | |
| const rl = readline.createInterface({ | |
| input: process.stdin, |
| function Get-RemoteDesktopVersions { | |
| [CmdletBinding()] | |
| param() | |
| try { | |
| # Use GitHub's API to get the directory listing | |
| $apiUrl = "https://api.github.com/repos/microsoft/winget-pkgs/contents/manifests/m/Microsoft/RemoteDesktopClient" | |
| # GitHub API requires a user agent | |
| $headers = @{ |
| using namespace System.Net.Sockets | |
| using namespace System.Net.Security | |
| using namespace System.Security.Cryptography.X509Certificates | |
| function ConvertFrom-X509Certificate { | |
| param( | |
| [Parameter(ValueFromPipeline)] | |
| [X509Certificate2]$Certificate | |
| ) |
| # Azure Policy: Tagging Based on Resource Group Name | |
| # Objective: | |
| # This policy aims to enforce tagging conventions based on the name of the resource group. If a resource group (or its contained resources) matches a specified naming pattern, a designated tag with a corresponding value will be applied. | |
| # | |
| # Parameters: | |
| # tagName: The name of the tag you want to apply. | |
| # tagValue: The value associated with the aforementioned tag. | |
| # rgNamePattern: A naming pattern that resource groups should match. For instance, if you want to target resource groups that start with "azurebatch", you'd use "azurebatch*". | |
| # applyToResources: A boolean parameter that dictates whether the tagging should be applied only to the resource group itself or also to the resources contained within the matching resource group. | |
| # |
| // The idea behind this is that you can do a terraform plan -out test.tfplan and then take the output that's printed | |
| // and copy/paste it into your code, then use these commands to clean it up so it's usable code. | |
| // In newer versions of Terraform you can do a terraform plan -generate-config to do this a different way, so check that out too. | |
| // Uses this exctension: https://marketplace.visualstudio.com/items?itemName=ArturoDent.find-and-transform&ssr=false#overview | |
| "findInCurrentFile": { | |
| "replaceHyphenPrefix": { | |
| "title": "Replace Terraform Plan output hyphen prefix...", // will appear in the Command Palette | |
| "find": "^(\\s+)- ", | |
| "replace": "$1", | |
| "isRegex": true, |
| Function New-AesKey { | |
| Param( | |
| [Int]$KeySize = 256, | |
| [Switch]$AsString | |
| ) | |
| $aesManaged = New-Object "System.Security.Cryptography.AesManaged" | |
| $aesManaged.KeySize = $KeySize | |
| $aesManaged.GenerateKey() | |
| If($AsString) { | |
| Return [System.Convert]::ToBase64String($aesManaged.Key) |
| #!/bin/bash | |
| # File: create_azure_vpn_client_cert.sh | |
| # Author: David Frazer | |
| # Date: 12/13/2022 | |
| # NOTE: This script expects a CA root cert and CA root key to exist at the following paths: | |
| # "${ORGNAME}_cacert.pem" | |
| # "${ORGNAME}_cakey.pem" | |
| # OPTIONAL: Set this to 1 to create a PFX for the user |
| Get-ChildItem 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkList\Profiles' | Select -Property * | %{ $Key = $_.PSChildName; $Name = $_.Name -Replace "HKEY_LOCAL_MACHINE","HKLM:"; $Category_Num = Get-ItemPropertyValue "$Name" -Name Category; If($Category_Num -eq 0){ $Category='Public' } ElseIf($Category_Num -eq 1){ $Category='Private' } ElseIf($Category_Num -eq 2){$Category = 'Domain'}; $ProfileName = Get-ItemPropertyValue "$Name" -Name ProfileName; ""|Select @{N='ProfileName';E={$ProfileName}},@{N="ProfileCategory";E={$Category} }} | Sort ProfileCategory |
| SELECT CASE cnt | |
| WHEN 2 THEN "TRUE" | |
| ELSE "FALSE" | |
| END "Vulnerable" | |
| FROM | |
| (SELECT name, | |
| start_type, | |
| COUNT(name) AS cnt | |
| FROM services | |
| WHERE name = 'NTDS' or (name = 'Spooler' and start_type <> 'DISABLED')) |