13052024B

inicio{
"host":"3E32220D5FD653CC96A089F157DD48B5",
"porta":"473D2C"
}fim

12032024

inicio{
"host":"2B1E1612241E0A7FD877FD1C39",
"porta":"47C2BABA"
}fim

Start Tailwind

CLI command to start TW's CSS parser
npx tailwindcss -i ./src/input.css -o ./src/output.css --watch

2373. Largest Local Values in a Matrix

You are given an n x n integer matrix grid. Generate an integer matrix maxLocal of size (n - 2) x (n - 2) such that: maxLocal[i][j] is equal to the largest value of the 3 x 3 matrix in grid centered around row i + 1 and column j + 1. In other words, we want to find the largest value in every contiguous 3 x 3 matrix in grid. Return the generated matrix.
/**
 * @param {number[][]} grid
 * @return {number[][]}
 */
var largestLocal = function(grid) {
    // Get the size of the grid
    let n = grid.length;

    // Initialize the result matrix with size (n - 2) x (n - 2)
    let maxLocal = Array(n - 2).fill().map(() => Array(n - 2).fill(0));

    // Iterate over the grid, excluding the border
    for (let i = 1; i < n - 1; i++) {
        for (let j = 1; j < n - 1; j++) {
            // Initialize the max value as the smallest possible number
      

Docker Comandos basicos

Listar todos los contenedores activos

``` 
docker ps
```

Activar todos los contenedores de una carpeta

- Ir a la carpeta donde estan los contenedores

```
cd-docker
```
- Poner el comando

```
docker-compose up -d
```

Detener todos los contenedores

```
docker stop $(docker ps -q)
```

Advanced CASE WHEN THEN

-- https://towardsdev.com/sql-case-statement-with-code-examples-04f77dab8d5a

-- 1. Simple case
SELECT
    order_id,
    CASE customer_id
        WHEN 1 THEN 'Premium'
        WHEN 2 THEN 'Gold'
        WHEN 3 THEN 'Silver'
        ELSE 'Regular'
    END AS customer_type
FROM orders;


-- 2. Searched CASE Statement
SELECT
    order_id,
    CASE
        WHEN order_amount > 1000 THEN 'High'
        WHEN order_amount > 500 THEN 'Medium'
        ELSE 'Low'
    END AS order_priority
FROM orders;

-- 

タイトルに付随するサブタイトルのマークアップ

<hgroup>
  <h1>タイトル</h1>
  <p>サブタイトル</p>
</hgroup>

Composable return values - destruct - keep reactivity

// Composable
const useBurger = () => {
  const lettuce = ref(true);
  const ketchup = ref(true);
return {
  lettuce,
  ketchup,
}


// Component
setup() {
  // We can destructure but still keep our reactivity
  const { ketchup } = useBurger();
  watchEffect(() => console.log(ketchup.value));
  return {
    ketchup,
    removeKetchup: () => ketchup.value = false
  };
}



// If you don't want to destructure the values, you can always wrap it in reactive and it
// will be converted to a reactive 

857. Minimum Cost to Hire K Workers

There are n workers. You are given two integer arrays quality and wage where quality[i] is the quality of the ith worker and wage[i] is the minimum wage expectation for the ith worker. We want to hire exactly k workers to form a paid group. To hire a group of k workers, we must pay them according to the following rules: Every worker in the paid group must be paid at least their minimum wage expectation. In the group, each worker's pay must be directly proportional to their quality. This means if a worker’s quality is double that of another worker in the group, then they must be paid twice as much as the other worker. Given the integer k, return the least amount of money needed to form a paid group satisfying the above conditions. Answers within 10-5 of the actual answer will be accepted.
/**
 * @param {number[]} quality
 * @param {number[]} wage
 * @param {number} k
 * @return {number}
 */
var mincostToHireWorkers = function(quality, wage, k) {
    // Create an array of workers, where each worker is represented as an array of [quality, wage]
    let workers = [];
    for (let i = 0; i < quality.length; i++) {
        workers.push([quality[i], wage[i]]);
    }

    // Sort the workers array by wage to quality ratio in ascending order
    workers.sort((a, b) => (a[1] / a[0]) - (b[

Añadir slash al final de URLs en NEXTJS 14

Al poner **trailingSlash** como **true**, se añadira el slash al final de las URLs.

Archivo: next.config.mjs

```js
/** @type {import('next').NextConfig} */
const nextConfig = {
    trailingSlash: true,
};

export default nextConfig;
```

Baby wolf codes - advanced JS tips

// Destructure into multiple variables
const obj = { val: 1 };
const { val: a, val: b, val } = obj;

console.log(a); // -> 1
console.log(b); // -> 1
console.log(val); // ->



// Chaining catch in Promise
const somePromise = async () => Promise.reject('error');
somePromise()
    .then(e => {
        //
    })
    .catch(e => {
        throw new Error('error happened');
    })
    .catch(e => {
        console.log('hi ' + e); // hi Error
    });


// Multiple handlers for 

SQL Syntaxes for auto-increment for primary keys

Different SQL database management systems have their own mechanisms and syntax 
for automatically incrementing primary keys:

## 1. SQLite: Uses `AUTOINCREMENT` with `INTEGER PRIMARY KEY`
```sql
CREATE TABLE table_name (
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    ...
);
```

## 2. MySQL uses `AUTO_INCREMENT` with `INT`
```sql
CREATE TABLE table_name (
    id INT NOT NULL AUTO_INCREMENT,
    PRIMARY KEY (id),
    ...
);
```

## 3. PostgreSQL uses serial types like `SERIAL` for auto-incrementin

SQL-Constraints

Here's a sum up of relevant syntax examples of constraints, hierarchically classed.

# 1. `PRIMARY KEY`
## Basic Boilerplate
```sql
CREATE TABLE Employees (
    EmployeeID int NOT NULL,
    FirstName varchar(255),
    LastName varchar(255),
    Email varchar(255),
    HireDate date,
    PRIMARY KEY (EmployeeID)
);
```

## Composite Primary Key
A primary key can consist of more than one column. This is known as **composite
primary key**.

It is useful **when no single column uniquely identifies a

Install tailwind in a new project

# initial install
npm install -D tailwindcss

# create TW config file
npx tailwindcss init

# update TW config
/** @type {import('tailwindcss').Config} */
module.exports = {
  content: ["./src/**/*.{html,js}"],
  theme: {
    extend: {},
  },
  plugins: [],
}

# place in main css file
@tailwind base;
@tailwind components;
@tailwind utilities;

# start TW cli css service
npx tailwindcss -i ./src/`input`.css -o ./src/`output`.css --watch

# test
<!doctype html>
<html>
<head>
  <meta charset="UTF-8

786. K-th Smallest Prime Fraction

/**
 * @param {number[]} arr
 * @param {number} k
 * @return {number[]}
 */
// Define the function that takes an array and a number k as input
var kthSmallestPrimeFraction = function(arr, k) {
    // Initialize a new max priority queue
    let newarr  =  new MaxPriorityQueue();
    
    // Loop through each element in the array
    for(let i = 0; i < arr.length; i++){
        // For each element, loop through the rest of the array
        for(let j = i + 1; j < arr.length; j++){
            // E