Exemple installation module depuis console python de qgis

import subprocess
subprocess.check_call(['pip', 'install', 'opencv-python', 'pytesseract', 'easyocr', 'pillow'])

Python Env Vars

# Common file for reusing ENV Vars
* `pip install dotenv`
* create `.env` file with variables defined:
  * `name=somevavlue`
```python
# config.py
import os
from dotenv import load_dotenv

class Config():
  API_URL = os.getenv(name)
  
# import from another file
from config import Config

name = Config.name
```

2402. Meeting Rooms III

You are given an integer n. There are n rooms numbered from 0 to n - 1. You are given a 2D integer array meetings where meetings[i] = [starti, endi] means that a meeting will be held during the half-closed time interval [starti, endi). All the values of starti are unique. Meetings are allocated to rooms in the following manner: Each meeting will take place in the unused room with the lowest number. If there are no available rooms, the meeting will be delayed until a room becomes free. The delayed meeting should have the same duration as the original meeting. When a room becomes unused, meetings that have an earlier original start time should be given the room. Return the number of the room that held the most meetings. If there are multiple rooms, return the room with the lowest number. A half-closed interval [a, b) is the interval between a and b including a and not including b.
/**
 * @param {number} n
 * @param {number[][]} meetings
 * @return {number}
 */
var mostBooked = function(n, meetings) {
    // Initialize arrays to track the number of bookings and the end times of the last meetings for each room
    const count = new Array(n).fill(0);
    const roomEndTimes = new Array(n).fill(0);

    // Sort meetings by start time
    meetings.sort((a, b) => a[0] - b[0]);

    // Iterate through each meeting
    for (const [start, end] of meetings) {
        let assigned = 

Backup Full Database Script as Procedure

CREATE OR ALTER PROCEDURE [dbo].[usp_BackupDatabaseFull]
    @DbName SYSNAME,
    @BackupFolder NVARCHAR(255) = 'K:\SQLBackups\'  -- Default path; override if needed
AS
BEGIN
    SET NOCOUNT ON;

    DECLARE 
        @BackupFile NVARCHAR(500),
        @Timestamp NVARCHAR(50),
        @sql NVARCHAR(MAX);

    -- Check if database exists
    IF NOT EXISTS (SELECT 1 FROM sys.databases WHERE name = @DbName)
    BEGIN
        RAISERROR('Database [%s] does not exist.', 16, 1, @DbName);

JS - Pars Form Data

parsFormData() {
  return [...new FormData(this.form)].reduce((acc, [name, value]) => ({...acc, [name]: value}), {});
}

#parseFormData() {
  // Efficiently convert FormData to object
  return Object.fromEntries(new FormData(this.#form));
}

Reexport ES exports

// index.js
export * as MathUtils from "./math.js";
export * as StringUtils from "./string-utils.js";

// Usage:
// import { MathUtils, StringUtils } from './index.js';





// modules/index.js
export { default as Calculator } from "./calculator.js";
export { default as Logger } from "./logger.js";
export * from "./math.js";
export * from "./string-utils.js";
export { ApiClient as Client, HTTP_METHODS as Methods } from "./config.js";

ES6 dynamic import / export

// app.js

async function loadMathModule() {
  const mathModule = await import("./math.js");
  console.log(mathModule.add(5, 3));
}

// Or with .then()
import("./math.js")
  .then((mathModule) => {
      console.log(mathModule.PI);
  })
  .catch((error) => {
      console.error("Failed to load module:", error);
  });

[WP] 親と子孫のカテゴリを表示

<?php
# 親 & 子孫カテゴリを別途表示
// カレント機能は連携させて持たせる

// 現在のタームとその最上位の親を取得
$current_term = null;
$top_parent_id = 0;
if($_term_slug) {
    $current_term = get_term_by('slug', $_term_slug, $_post_type_slug.'category');
    if($current_term && !is_wp_error($current_term)) {
        // 最上位の親を見つける
        $temp_term = $current_term;
        while($temp_term->parent != 0) {
            $temp_term = get_term($temp_term->parent, $_post_type_slug.'category');
            if(is_wp_error($temp_term)) break;
      

charles使用技巧

# charles使用技巧
## 导出session
- **导出所有session:**`File` -> `Save session`
- **导出单个session:**选中单个session -> 右键`Export Session`

Merge Tailwind CSS classes efficiently

import { clsx, type ClassValue } from 'clsx';
import { twMerge } from 'tailwind-merge';

/**
 * Merge Tailwind CSS classes efficiently.
 *
 * @param inputs - Class values to merge.
 * @returns Merged class names.
 */
export function cn(...inputs: ClassValue[]): string {
  return twMerge(clsx(inputs));
}

Copia de Tabela Mysql

loteNfeUsuario_aux
notafiscaleletronica_aux
notafiscaleletronica_xml_aux
retencao_documento_aux
retencao_servico_aux


CREATE TABLE loteNfeUsuario_aux_2024 AS
SELECT *
  FROM loteNfeUsuario
 WHERE year(dataInsercao) = 2024;

 CREATE TABLE notafiscaleletronica_aux_2024 AS
SELECT *
  FROM notafiscaleletronica
 WHERE year(DataEmissao) = 2024;



 CREATE TABLE notafiscaleletronica_xml_aux_2024 AS
SELECT *
  FROM notafiscaleletronica_xml
 WHERE year(DataEmissao) = 2024


  CR

3440. Reschedule Meetings for Maximum Free Time II

You are given an integer eventTime denoting the duration of an event. You are also given two integer arrays startTime and endTime, each of length n. These represent the start and end times of n non-overlapping meetings that occur during the event between time t = 0 and time t = eventTime, where the ith meeting occurs during the time [startTime[i], endTime[i]]. You can reschedule at most one meeting by moving its start time while maintaining the same duration, such that the meetings remain non-overlapping, to maximize the longest continuous period of free time during the event. Return the maximum amount of free time possible after rearranging the meetings. Note that the meetings can not be rescheduled to a time outside the event and they should remain non-overlapping. Note: In this version, it is valid for the relative ordering of the meetings to change after rescheduling one meeting.
/**
 * @param {number} eventTime - Total event duration from t = 0 to t = eventTime
 * @param {number[]} startTime - Start times of n scheduled meetings
 * @param {number[]} endTime - End times of n scheduled meetings
 * @return {number} - Maximum continuous free time after rescheduling one meeting
 */
var maxFreeTime = function(eventTime, startTime, endTime) {
    const n = startTime.length;
    const timeline = [];

    // Step 1: Build an annotated timeline with schedules and gaps
    for (le

React State with Arrays

import React, { useState } from 'react';

function ArrayOperations() {
  const [items, setItems] = useState([]);

  return <div>...</div>;
}

✅ Add to End (push alternative):

setItems([...items, 'New Item']);

✅ Add to Beginning (unshift alternative):

setItems(['New Item', ...items]);

// Update an Item in the Array

const updateItem = (indexToUpdate, newValue) => {
  const updatedItems = items.map((item, index) =>
    index === indexToUpdate ? newValue : item
  );
  setItems(updatedItems);
};

Rendering components with props

const users = [
  { id: 1, name: 'Javier' },
  { id: 2, name: 'Maria' },
  { id: 3, name: 'Carlos' }
];

function User({ name }) {
  return <li>{name}</li>;
}

function UserList() {
  return (
    <ul>
      {users.map(user => (
        <User key={user.id} name={user.name} />
      ))}
    </ul>
  );
}

Maps

import React from 'react';

const fruits = ['Apple', 'Banana', 'Orange'];

function FruitList() {
  return (
    <ul>
      {fruits.map((fruit, index) => (
        <li key={index}>{fruit}</li>  // Always include a unique 'key'
      ))}
    </ul>
  );
}

export default FruitList;

Sharing State Between components

import { useState } from 'react';

export default function Accordion() {
  const [activeIndex, setActiveIndex] = useState(0);
  return (
    <>
      <h2>Almaty, Kazakhstan</h2>
      <Panel
        title="About"
        isActive={activeIndex === 0}
        onShow={() => setActiveIndex(0)}
      >
        With a population of about 2 million, Almaty is Kazakhstan's largest city. From 1929 to 1997, it was its capital city.
      </Panel>
      <Panel
        title="Etymology"
        isActive={ac