PowerShell - Multiple Copy & Rename

# PowerShell - Multiple Copy & Rename Overall Structure - `run_copyfiles.bat` → (the simple batch file they double-click) - `copyfiles.ps1` → (the real PowerShell script) - `folderlist.txt` → (the list of folder names) ## PowerShell Script Notes Why use : `Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass` - Normally, Windows blocks running scripts for security. - This setting only lowers the security for this one PowerShell window (and resets when you close it). - It's safe for one-time or controlled use like this. Note: - it only changes settings for that one PowerShell window session. - It doesn’t change it permanently or for the whole computer. - **No admin rights** needed. ## Batch File Notes What it does: `%~dp0` means "same folder where the `.bat` file is." It launches PowerShell, skips security warnings, runs the script. `pause` keeps the window open at the end to see results.
# Define paths
$sourceRoot = "C:\temp\copyfiles_src"        # <-- Change this for real run
$localTarget = "C:\temp\copyfiles_dest"  # <-- Change this for real run

$listPath = "$PSScriptRoot\folderlist.txt"
$logFile = "$PSScriptRoot\copy_log.txt"

# Start a fresh log file
"Copy Process Started: $(Get-Date)" | Out-File -FilePath $logFile

# Ensure destination folder exists
if (-not (Test-Path $localTarget)) {
    New-Item -ItemType Directory -Path $localTarget | Out-Null
}

# Process each folder 

2444. Count Subarrays With Fixed Bounds

You are given an integer array nums and two integers minK and maxK. A fixed-bound subarray of nums is a subarray that satisfies the following conditions: The minimum value in the subarray is equal to minK. The maximum value in the subarray is equal to maxK. Return the number of fixed-bound subarrays. A subarray is a contiguous part of an array.
/**
 * @param {number[]} nums
 * @param {number} minK
 * @param {number} maxK
 * @return {number}
 */
var countSubarrays = function(nums, minK, maxK) {
    // Initialize variables to keep track of indices and result
    let minI = -1; // Index of the last occurrence of minK
    let maxI = -1; // Index of the last occurrence of maxK
    let ans = 0; // Total count of valid subarrays
    let leftBoundary = -1; // Left boundary of the current subarray

    // Iterate through the input array
    for

B2 Unit 13

offender vs perpetrator = same
rubbery vs burglary = 99% same, burglary nobody in building, robbery other people are inside building

informal gathering
chat about life
eat,drink and be merry
look into smth or investigate
make a profifit
Bedside manner
Daunting- scary, overwhelming
combat the crime
make a record 
record the crime
Potholes- holes in the road

async context manager

# async context manager

## __aenter__ & __aexit__

\_\_aenter\_\_ 是 Python 中异步上下文管理器(async context manager)的一个特殊方法。它是异步版本的 \_\_enter\_\_ 方法。当我们使用 async with 语句时,这个方法会被自动调用。

\_\_aexit\_\_ 方法,用于异步清理资源。

完整的调用流程:

```python
async with some_async_context() as context:
    # 在这里使用context
    # __aenter__在进入时被调用
    # __aexit__在退出时被调用
```

可以手动调用 \_\_aenter\_\_ 来手动管理生命周期。

add custom field to contact form 7 mail body

add_action('wpcf7_before_send_mail', function($contact_form) {
    $submission = WPCF7_Submission::get_instance();
    if (!$submission) return;

    $post_id = url_to_postid($submission->get_meta('url'));
    if (!$post_id) return;


    $pdf_url = get_field('pdf_file', $post_id);

    if ($pdf_url) {
        $mail = $contact_form->prop('mail');
        $mail['body'] = str_replace('[acf_pdf_url]', $pdf_url, $mail['body']);
        $contact_form->set_properties(['mail' => $mail]);
    }
});

ÉÈÀÇ

`À > alt-0192`

`É > alt-0201 / alt-144`

`È > alt-0200`

`Ç > alt-0199 / alt-128`

Majuscules sous Windows : ÉÈÀÇ

`À > alt-0192`

`É > alt-0201 / alt-144`

`È > alt-0200`

`Ç > alt-0199 / alt-128`

2845. Count of Interesting Subarrays

You are given a 0-indexed integer array nums, an integer modulo, and an integer k. Your task is to find the count of subarrays that are interesting. A subarray nums[l..r] is interesting if the following condition holds: Let cnt be the number of indices i in the range [l, r] such that nums[i] % modulo == k. Then, cnt % modulo == k. Return an integer denoting the count of interesting subarrays. Note: A subarray is a contiguous non-empty sequence of elements within an array.
/**
 * @param {number[]} nums
 * @param {number} modulo
 * @param {number} k
 * @return {number}
 */
var countInterestingSubarrays = function(nums, modulo, k) {
    let res = 0; // Stores the count of interesting subarrays
    let pre = 0; // Prefix sum tracking occurrences of nums[i] % mod === k
    let map = new Map([[0, 1]]); // Map to store frequencies of prefix sums modulo 'mod'

    for (let i = 0; i < nums.length; i++) {
        // Increment prefix sum when nums[i] % mod equals k (using i

react_factory_pattern

import { Suspense, lazy } from 'react';

const MyComponent = ({choiceType}) => {
  // Dynamically import the choice component based on choiceType (factory pattern)
  const Choice = lazy(() => {
    switch (choiceType) {
      case 'image':
        return import('./ChoiceImage.jsx');
      case 'default':
        return import('./Choice.jsx');
    }
  });
  
  return (
    <Suspense fallback={'Loading...'}>
      <Choice/>
    <Suspense/>
  );
}

// Could also abstract it to useChoiceFactory hook

rsync_full

rsync -aHvz --force --delete --sparse src dst

lv_create

lvcreate -l 100%FREE -n 

NPM auto-completion in bash

NPM provides autocompletion via the npm completion command. You can add it to your shell configuration
```sh
npm completion >> ~/.bashrc
source ~/.bashrc
```

Pip auto-completion in bash

Pip does not have native bash completion, but you can use tools like argcomplete to enable it
```sh
pip install argcomplete
activate-global-python-argcomplete
```

Twig-Template _headline.html.twig

{# templates/component/_headline.html.twig #}
{% use "@Contao/component/_headline.html.twig" %}

{% block headline_attributes -%}
    {% set headline = headline|merge({attributes: attrs().addClass('foobar').mergeWith(headline.attributes|default)}) %}
    {{ parent() }}
{%- endblock %}

Docker auto-completion in bash

Docker provides its own bash completion script. You can enable it by installing the bash-completion package and sourcing Docker's completion script
```sh
sudo apt install bash-completion
source /usr/share/bash-completion/completions/docker
```

Django auto-completion in bash

Django provides a built-in bash completion script. You can enable it by adding the following to your `.bashrc` or `.bash_profile`. The script uses the `DJANGO_AUTO_COMPLETE` environment variable to determine if it should provide completions.
```sh
_django_completion() {
    COMPREPLY=( $( COMP_WORDS="${COMP_WORDS[*]}" \
                   COMP_CWORD=$COMP_CWORD \
                   DJANGO_AUTO_COMPLETE=1 $1 ) )
}
complete -F _django_completion django-admin
complete -F _django_completion manage.py
```