3488. Closest Equal Element Queries

You are given a circular array nums and an array queries. For each query i, you have to find the following: The minimum distance between the element at index queries[i] and any other index j in the circular array, where nums[j] == nums[queries[i]]. If no such index exists, the answer for that query should be -1. Return an array answer of the same size as queries, where answer[i] represents the result for query i.
/**
 * @param {number[]} nums
 * @param {number[]} queries
 * @return {number[]}
 */
var solveQueries = function(nums, queries) {
    const n = nums.length;
    const last = new Map();
    const dp = new Array(n).fill(n); // n = "no match yet"

    // Walk through array twice to simulate circular behavior
    for (let i = 0; i < 2 * n; i++) {
        const idx = i % n;
        const num = nums[idx];

        if (last.has(num)) {
            const prev = last.get(num);
            const dist = i 

Data Wrangling

Pandas support page: http://pandas.pydata.org/

Acess a specific column
  df["column"]
  
Drop missing values
  df.dropna(subset=["column"], axis=0, inplace = True)
  
Replave missing values
  df["missing_value"].replace(np.nan, new_value)
    ex.mean_of_table = df["loses"].mean()
      df["loses"].replace(np.nan, mean)

Identify types
  df.dtype()
  
Convert one dataframe to another type
  df.astype()
    ex. df["price"] = df["price"].astype("int")

Normailze datatypes
  Simple  feature scaling

2515. Shortest Distance to Target String in a Circular Array

You are given a 0-indexed circular string array words and a string target. A circular array means that the array's end connects to the array's beginning. Formally, the next element of words[i] is words[(i + 1) % n] and the previous element of words[i] is words[(i - 1 + n) % n], where n is the length of words. Starting from startIndex, you can move to either the next word or the previous word with 1 step at a time. Return the shortest distance needed to reach the string target. If the string target does not exist in words, return -1.
/**
 * @param {string[]} words
 * @param {string} target
 * @param {number} startIndex
 * @return {number}
 */
var closestTarget = function(words, target, startIndex) {
    const n = words.length;

    // We'll track the smallest circular distance found.
    // Start with Infinity so any real distance will be smaller.
    let best = Infinity;

    // Check every index in the array.
    for (let i = 0; i < n; i++) {

        // Only consider positions where the word matches the target.
        if

Prevent to commit on branches

- Create `.git/hooks/pre-commit` file - Then make it executable with `chmod +x .git/hooks/pre-commit`
#!/bin/bash
protected_branches="^(develop|main|master|production|staging)$"
current_branch=$(git symbolic-ref --short HEAD 2>/dev/null)

if [[ "$current_branch" =~ $protected_branches ]]; then
    echo "🚫 Direct commits to '$current_branch' are not allowed."
    echo "   Please switch to a feature branch:"
    echo "     git checkout -b feature/your-change"
    exit 1
fi
exit 0

JS - who adds inline styles

(function() {
    // Ищем inline-style с display:block и opacity:1!important
    // Допускаем пробелы, необязательные ; и любой дополнительный мусор вокруг
    const sniperRegex = /display\s*:\s*block\s*;[\s\S]*opacity\s*:\s*1\s*!important\s*;?|opacity\s*:\s*1\s*!important\s*;[\s\S]*display\s*:\s*block\s*;?/i;

    function logTrap(methodName, content, element) {
      console.debug('------------------------>>>> START <<<<------------------------');
      console.debug('----->>>> ', {
  

AWSでのwebアプリケーション構成パターン

# AWS Webアプリケーション インフラ構築パターン

## 目次

1. [パターン一覧](#パターン一覧)
2. [パターン1: EC2単体構成](#パターン1-ec2単体構成)
3. [パターン2: EC2 + RDS構成](#パターン2-ec2--rds構成)
4. [パターン3: ALB + Auto Scaling + RDS構成](#パターン3-alb--auto-scaling--rds構成)
5. [パターン4: ECS Fargate構成](#パターン4-ecs-fargate構成)
6. [パターン5: EKS構成](#パターン5-eks構成)
7. [パターン6: サーバーレス構成](#パターン6-サーバーレス構成)
8. [パターン7: 静的サイト + API構成](#パターン7-静的サイト--api構成)
9. [パターン8: Amplify構成](#パターン8-amplify構成)
10. [パターン9: マイクロサービス構成](#パターン9-マイクロサービス構成)
11. [パターン10: ハイブリッド構成](#パターン10-ハイブリッド構成)
12

wisper-clone

 can you help me create a tool simalar to wispr flow ,so i would like to have a wiget that will pop up or be opened
with a combiation of ketpresses(hotkeys), and the user clicks on a place on the page where they would like thier text
transcribed and then it happens as they are talking , if no place on the page is specified, then the transcription
needs to be saved to a place of the users choosing, default to documents. The coolish thing about wispr flow is that
ai will fix it on the fly so i

gsm mini test

#include <Arduino.h>

#define SIM800_RX 18
#define SIM800_TX 17

HardwareSerial simSerial(1);

String readResponse(unsigned long timeoutMs)
{
    String resp = "";
    unsigned long start = millis();

    while (millis() - start < timeoutMs)
    {
        while (simSerial.available())
            resp += (char)simSerial.read();
    }

    return resp;
}

void sendAT(const char *cmd, unsigned long waitMs = 1000)
{
    Serial.println("=================================");
  

fest12

void simTask(void *pvParameters)
{
    vTaskDelay(pdMS_TO_TICKS(6000));

    simSerial.begin(9600, SERIAL_8N1, SIM800_RX, SIM800_TX);
    vTaskDelay(pdMS_TO_TICKS(1000));

    simFlush();
    simSerial.println("AT");
    vTaskDelay(pdMS_TO_TICKS(300));
    simFlush();
    simSerial.println("ATE0");
    vTaskDelay(pdMS_TO_TICKS(300));

    simFlush();
    simSerial.println("AT+CPIN?");
    String cpinInit = simReadResponse(3000);
    Serial.println("[GSM] CPIN init: " + cpinInit)

pinecone

from pinecone import Pinecone, ServerlessSpec

pc = Pinecone(api_key="********-****-****-****-************")



index_name = "developer-quickstart-py"

if not pc.has_index(index_name):
    pc.create_index_for_model(
        name=index_name,
        cloud="aws",
        region="us-east-1",
        embed={
            "model":"llama-text-embed-v2",
            "field_map":{"text": "chunk_text"}
        }
    )

Disable USA Holidays for Gravity Forms Gravity Wiz Limit Dates.

Disable USA Holidays for Gravity Forms Gravity Wiz Limit Dates.
<?php
/**
 * Disable USA Holidays for Gravity Forms Gravity Wiz Limit Dates.
 *
 * @link https://gravitywiz.com/documentation/gravity-forms-limit-dates/
 * @link https://gist.github.com/cliffordp/38892bbfe30702d4623c9c13e17a1b09 This snippet.
 *
 * DOES NOT appear in the form editor's UI but DOES take effect when filling the form.
 * If you add your own Exception within form editor's UI, that will take precedence over these rules.
 *
 * TODO: ADD YOUR OWN FORM#s AND FIELD#s AT THE BOTTOM!
 */

i

1848. Minimum Distance to the Target Element

Given an integer array nums (0-indexed) and two integers target and start, find an index i such that nums[i] == target and abs(i - start) is minimized. Note that abs(x) is the absolute value of x. Return abs(i - start). It is guaranteed that target exists in nums.
/**
 * @param {number[]} nums
 * @param {number} target
 * @param {number} start
 * @return {number}
 */
var getMinDistance = function(nums, target, start) {
    // We'll track the smallest distance found so far.
    // Start with Infinity so any real distance will be smaller.
    let minDist = Infinity;

    // Scan through the entire array once.
    for (let i = 0; i < nums.length; i++) {

        // Only care about positions where nums[i] matches the target.
        if (nums[i] === target) {

WooCommerce > Set shipping to $0 if 'shipping class' items of "{shipping class}" are > $50

/**
 * PART 1: Split cart into separate shipping packages by class.
 * Each package shows as its own labeled shipping line at checkout.
 * 
 * Update the 3 slugs below to match your exact WooCommerce shipping class slugs
 * (WooCommerce > Settings > Shipping > Shipping Classes — use the "Slug" column).
 */
add_filter( 'woocommerce_cart_shipping_packages', 'split_cart_by_shipping_class' );
function split_cart_by_shipping_class( $packages ) {

    $cart = WC()->cart->get_cart();
    if 

webアプリケーション要件定義雛形

# `<システム名>` 要件定義書

| 項目 | 内容 |
|------|------|
| プロジェクト名 | `<記入>` |

## 用語集

> 記入ガイド: 本書中で使用する固有名詞・略語・業界用語を定義する。読み手が前提知識なしで読めることを目標とする。

| 用語 | 定義 |
|------|------|
| SPA | Single Page Application。初回ロード後はクライアントサイドで画面遷移を行う Web アプリケーション方式。 |
| SLA | Service Level Agreement。提供するサービス品質の合意指標(稼働率、応答時間 等)。 |

---

# 第1章 はじめに

## 1. 背景

> 記入ガイド: なぜ本システムが必要になったのかを記述する。現状の課題、ビジネス上の要求、外部環境の変化(法改正、技術革新、競合動向 等)を含める。
>
> 例: 当社では従来、経費精算を Excel テンプレートと紙の領収書による申請で運用してきた。リモートワークの定着により紙の物理回付が困難となり、申請者・承認者・経理部門のいずれ

botによる大量アクセス対策(インフラ)

# ボットによる大量アクセスに対するコスト調整の原則

## 1. レート制限(Rate Limiting)

### 1.1 制限単位

| 単位 | 説明 |
|------|------|
| IPアドレス | 送信元IPごとにリクエスト数を制限する |
| APIキー | 発行したキーごとにリクエスト数を制限する |
| ユーザーID | 認証済みユーザーごとにリクエスト数を制限する |
| セッション | セッションIDごとにリクエスト数を制限する |

### 1.2 アルゴリズム

| アルゴリズム | 動作 |
|--------------|------|
| Token Bucket | トークンを一定速度で補充し、リクエストごとにトークンを消費する。バースト許容。 |
| Leaky Bucket | リクエストをキューに格納し、一定速度で処理する。出力レートが一定。 |
| Fixed Window | 固定時間枠(例:1分間)内でリクエスト数をカウントする。境界でリセット。 |
| Sliding Window | 移動する時間枠内でリクエスト数をカウントする