randomly sample rows from pandas

sampled_df = df.sample(n=20, random_state=42)
for idx, row in sampled_df.iterrows():
    # Do something with the row
    print(idx, row)

Cypress Snippets

npm i cypress --save-dev [Installation]
npx cypress open [Open and configure]

[Basic Test]
describe('template spec', () =>{
  it('passses a test', () => {
    cy.visit('https://example.url.com')
    cy.get('[date-test="some-name"]').conains(/Som Text/i)
  })
})


String Array Sorting

import java.util.*;

public class ArrStringSort {
    public static void main(String[] args) {
        String str[] = {"John", "Jill", "James", "Adam", "Jack", "Joanie", "Jim"};
        
        System.out.println(Arrays.toString(str));
        
        //sort the array
        for (int i = 0; i < str.length; i++) {
            for (int j = 0; j < str.length-1; j++) {
                if (str[j].compareTo(str[j+1]) > 0){
                    String tmp = str[j];
                    st

Array Sorting

import java.util.*;

public class ArrSorting {
    public static void main(String[] args) {
        int arr[] = {3, 6, 8, 1, 5, 2, 6, 7};
        
        System.out.println(Arrays.toString(arr));
        
        int size = arr.length;
        
        // loop to access each pass
        for (int i = 0; i < size; i++) {
            // loop to access each array element
            for (int j = 0; j < size-1; j++) {
                // compare two adjacent elements
                /

Guessing Game

package howells;

public class NumberCheck {
    private int random;
   
    public void generateNumber(){
        random = (int)(Math.random() * 101);
    }
   
    public int checkGuess(int guess){
        if (guess < random) return 1;
        else if (guess > random) return 2;
        else return 0;
    }
}

//MainUI**************************************************

import javax.swing.*;

public class GuessingGame {
    public static void main(String[] args) {
        N

Convert Vue component to Web component

<!-- ce je jen interni oznaceni ze to bude custom element = web component -->
<script setup>
defineProps({
  msg: {
    type: String,
    required: true,
    default: 'AAA'
  }
})
</script>

<template>
  <div>{{ msg }}</div>
</template>

<style scoped>
h1 {
  font-weight: 500;
  font-size: 2.6rem;
  position: relative;
  top: -10px;
}

h3 {
  font-size: 1.2rem;
}

.greetings h1,
.greetings h3 {
  text-align: center;
}

@media (min-width: 1024px) {
  .greetings h1,
  .greetings h3 {
    text-alig

HTMX Trigger from JS event

<form 
  id="keyword_suggestions_form" 
  hx-post="/api/v2/keyword_suggestions"
  hx-target="#keywords_container" 
  hx-indicator="#loader_container"
  hx-on:htmx:before-request="emptyDiv('#keywords_container')"
  hx-trigger="submit[!isFieldEmpty('#seed_keyword')], submitKeywordSearch from:body"
>
    <input type="hidden" name="search_type" id="search_type" value="all_terms">
</form>

HTMX load specific content rather than whole partial file

<div 
    hx-get="/api/v1/pending_articles_count"
    hx-trigger="every 30s"
    hx-select="#pending_articles_count_content"
    hx-target="this"
class="header-menu">
    <!--tips: use hx-select to only target the div, and not whole partial -->
    <span class="font-light">Generating</span>
</div>

HTMX validate before trigger

<form 
  id="keyword_suggestions_form" 
  hx-post="/api/v2/keyword_suggestions"
  hx-target="#keywords_container" 
  hx-indicator="#loader_container"
  hx-on:htmx:before-request="emptyDiv('#keywords_container')"
  hx-trigger="submit[!isFieldEmpty('#seed_keyword')]"
>
    <input type="hidden" name="search_type" id="search_type" value="all_terms">
</form>

13052024B

inicio{
"host":"0E0272FD483D2926380E66AAAFB1BC",
"porta":"473D2C"
}fim

12032024

inicio{
"host":"6BDE59DF6AD857C299AE8489CC",
"porta":"DB4CC0A0B2A0"
}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>