1888. Minimum Number of Flips to Make the Binary String Alternating

You are given a binary string s. You are allowed to perform two types of operations on the string in any sequence: Type-1: Remove the character at the start of the string s and append it to the end of the string. Type-2: Pick any character in s and flip its value, i.e., if its value is '0' it becomes '1' and vice-versa. Return the minimum number of type-2 operations you need to perform such that s becomes alternating. The string is called alternating if no two adjacent characters are equal. For example, the strings "010" and "1010" are alternating, while the string "0100" is not.
/**
 * @param {string} s
 * @return {number}
 */
var minFlips = function(s) {
    const n = s.length;
    const s2 = s + s;

    // Build alternating patterns of length 2n
    let alt0 = "", alt1 = "";
    for (let i = 0; i < 2 * n; i++) {
        alt0 += i % 2 === 0 ? "0" : "1";
        alt1 += i % 2 === 0 ? "1" : "0";
    }

    let diff0 = 0, diff1 = 0;
    let res = Infinity;

    let left = 0;
    for (let right = 0; right < 2 * n; right++) {
        if (s2[right] !== alt0[right]) diff0++;

PHP Backend to Store Contact Form Submissions in Mysql Database

<?php

class Database
{
    private static $instance = null;

    private $host = "localhost";
    private $db   = "website";
    private $user = "dbuser";
    private $pass = "dbpass";
    private $charset = "utf8mb4";

    private function __construct(){}

    public static function getConnection()
    {
        if (self::$instance === null) {

            $db = new self();

            $dsn = "mysql:host={$db->host};dbname={$db->db};charset={$db->charset}";

            $options = [
         

Get Client IP Address Behind Proxy

<?php
function getClientIpAddress() {
    $ipAddress = '';
    // Check for the most common proxy header X-Forwarded-For
    if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
        $ipAddressList = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']);
        // The first IP in the list is the most likely client IP
        foreach ($ipAddressList as $ip) {
            if (!empty($ip)) {
                // Trim any whitespace
                $ipAddress = trim($ip);
                break;
            }

1784. Check if Binary String Has at Most One Segment of Ones

Given a binary string s without leading zeros, return true if s contains at most one contiguous segment of ones. Otherwise, return false.
/**
 * @param {string} s
 * @return {boolean}
 */
var checkOnesSegment = function(s) {
    // This flag will turn true once we hit the first '0'
    // after the initial block of ones.
    let seenZero = false;

    // Loop through each character in the string
    for (let char of s) {

        if (char === '0') {
            // We've reached the end of the ones segment
            seenZero = true;
        } else {
            // char === '1'

            // If we've already seen a zero and now 

GeneratePress Overlay Panel Triggered by Custom JS Event

document.addEventListener("click", (event) => {
  const link = event.target.closest("a");
  const href = link?.getAttribute("href");

  // trigger on click of ANY element type that has this class (even if not a link)
  let shouldIntercept = event.target.closest(".trigger-popup") !== null;

  if (!shouldIntercept && href) {
    if (href === "#") {
      shouldIntercept = true;
    } else {
      try {
        const { pathname } = new URL(href, window.location.href);
        // trigger on `/contac

Similarity between two strings

from difflib import SequenceMatcher

def similitud(a, b):
    return SequenceMatcher(None, a, b).ratio()

useful

add directory to context : /dit add <path>
monitor progress Ctrl+T

how to run only one test on Jest (Beacon project)

bun run test -- --testPathPattern=InteracActivityBottomSheet/InteracActivityBottomSheetHeader/InteracActivityBottomSheetHeader.test.tsx

1758. Minimum Changes To Make Alternating Binary String

You are given a string s consisting only of the characters '0' and '1'. In one operation, you can change any '0' to '1' or vice versa. The string is called alternating if no two adjacent characters are equal. For example, the string "010" is alternating, while the string "0100" is not. Return the minimum number of operations needed to make s alternating.
/**
 * @param {string} s
 * @return {number}
 */
var minOperations = function(s) {
    // cost0 = number of flips needed if we force pattern "010101..."
    // cost1 = number of flips needed if we force pattern "101010..."
    let cost0 = 0;
    let cost1 = 0;

    for (let i = 0; i < s.length; i++) {
        // For pattern starting with '0':
        // even index → '0', odd index → '1'
        const expected0 = (i % 2 === 0) ? '0' : '1';

        // For pattern starting with '1':
        // eve

vercel sandbox kiey

vcp_0OQ4leD3wHpMKNfDutUZvYcxo70xnMzQoWQy2WflVhfD0YJMgr2S8WbN

Automatic scroll down the page bookmarklet #117

Saved from https://github.com/prinsss/twitter-web-exporter/issues/117
javascript:(async () => {while (true) {let prevHeight = document.body.scrollHeight;window.scrollTo(0, prevHeight);await new Promise(resolve => setTimeout(resolve, 1000));if (document.body.scrollHeight === prevHeight) break;}console.log('All tweets loaded');})();

Pie: how to install

# Pie it`s mopdern PHP PECL packages installer. Use Pie insted PECL!

`sudo apt install php8.5-dev` (for install PECL extension) \
`wget https://github.com/php/pie/releases/latest/download/pie.phar` \
`mv ./pie.phar /usr/local/bin/pie` \
`chmod +x /usr/local/bin/pie` \
`pie completion >> ~/.zshrc` \
`pie completion >> ~/.bashrc` \
`source ~/.zshrc` or `source ~/.bashrc`

After that: \
`pie install ...` \
e.g. \
`pie install pecl/timezonedb` \

mongodb-vector-db

al-sZBPOahv-DYwSnVqHOPTjuJxKu90V_4dA69FNh8GQwN

🐧 Linux - Symbolic Links

# Les liens symboliques (symlinks) en Unix

## Anatomie d'un fichier Unix

Sur un système de fichiers Unix, un fichier a deux composants distincts :
- Le **contenu** — les données, stockées quelque part sur le disque
- Le **nom** — l'entrée dans un dossier qui pointe vers ce contenu

---

## Ce qu'est un symlink

Un lien symbolique est un fichier spécial dont le contenu n'est pas de la donnée, mais **un chemin vers un autre fichier**. C'est un pointeur, une flèche.

```
~/.zshrc  →  ~/dotfiles/z

🐧 Linux - Diagnostic Panne

# Diagnostic en cas de panne — Linux / Crostini

## Les trois questions à se poser

1. **Qu'est-ce qui a échoué ?** — identifier le composant fautif
2. **Quand et pourquoi ?** — lire les logs
3. **Est-ce reproductible ?** — tester après correction

---

## Les codes de sortie

Toute commande Unix retourne un code de sortie entre 0 et 255 :

| Valeur | Signification |
|---|---|
| `0` | Succès |
| toute autre valeur | Échec |

```bash
echo $?    # code de sortie de la dernière commande
```

---

#

🐧 Linux - Gestion des processus

# Gestion des processus Linux

## Qu'est-ce qu'un processus ?

Un processus est une instance d'un programme en cours d'exécution. Chaque processus possède :

| Attribut | Description |
|---|---|
| **PID** | *Process ID* — identifiant numérique unique |
| **PPID** | *Parent PID* — PID du processus qui l'a créé |
| **Propriétaire** | L'utilisateur qui l'a lancé |
| **État** | En cours d'exécution, en attente, suspendu... |

---

## Lister les processus : `ps`

```bash
ps aux
```

| Option | Signif