3443. Maximum Manhattan Distance After K Changes

You are given a string s consisting of the characters 'N', 'S', 'E', and 'W', where s[i] indicates movements in an infinite grid: 'N' : Move north by 1 unit. 'S' : Move south by 1 unit. 'E' : Move east by 1 unit. 'W' : Move west by 1 unit. Initially, you are at the origin (0, 0). You can change at most k characters to any of the four directions. Find the maximum Manhattan distance from the origin that can be achieved at any time while performing the movements in order. The Manhattan Distance between two cells (xi, yi) and (xj, yj) is |xi - xj| + |yi - yj|.
/**
 * Calculates the maximum Manhattan distance from the origin
 * that can be achieved while moving in a grid, with the option
 * to change up to 'k' directions.
 *
 * @param {string} s - String of movement directions: 'N', 'S', 'E', 'W'.
 * @param {number} k - Number of allowed direction changes.
 * @return {number} - Maximum distance from the origin at any point.
 */
var maxDistance = function(s, k) {
    let x = 0, y = 0;       // Current coordinates on the grid
    let maxDist = 0;        

/set-role/route.ts

import { NextResponse } from 'next/server'
import { createClient } from '@supabase/supabase-js'

const supabaseAdmin = createClient(
  process.env.NEXT_PUBLIC_SUPABASE_URL!,
  process.env.SUPABASE_SERVICE_ROLE_KEY! // ⚠️ Service role key uniquement côté serveur
)

export async function POST(req: Request) {
  try {
    const body = await req.json()
    const { userId, role, firstName, lastName } = body

    if (!userId || !role) {
      return NextResponse.json({ error: "userId et role sont requi

Allow to user choice between continue or stop an execution

# pause and allow the selection between continue or stop
while True:
    answer = input("Would you like to continue (C) or stop (S)? ").strip().lower()
    if answer == 'c':
        print("Continue...")
        break
    elif answer == 's':
        print("Stop.")
        exit()
    else:
        print("Not allowed answer.")

learning

kafka:
https://learn.conduktor.io/kafka/kafka-topics/

pretzel (python, api)
https://www.pretzellogix.net/2021/12/08/step-1-read-the-docs-and-use-postman-to-understand-the-rest-api/

Js starter file - ascend

<script>
    // make sure to import your icon CDN script first
    // Services icon swap (this is a quick way to replace system icons with FontAwesome icons
    jQuery('.products-services[about*="/tax-planning"] .thumbnail').empty().append('<i class="fa-solid fa-sharp icon-4x text-center fa-pie-chart"></i>');
  
    jQuery('.products-services[about*="/products-services/retirement-planning"] .thumbnail').empty().append('<i class="fa-solid fa-sharp icon-4x text-center fa-compass"></i>');
    
    

css starter file - ascend - June 2025

/* @import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,100..1000;1,9..40,100..1000&display=swap');

:root {
  --h1-font-family: "DM Sans", sans-serif;
  --h2-font-family: "DM Sans", sans-serif;
  --h3-font-family: "DM Sans", sans-serif;
  --h4-font-family: "DM Sans", sans-serif;
  --body-font-family: "DM Sans", sans-serif;
  --link-font-family: "DM Sans", sans-serif;
  --button-font-family: "DM Sans", sans-serif;
} */

h1, .h1, h2, .h2, h3, .h3, h4, .h4, h5, .h5,

FAQ Accordion and nested Accordions


    const handleAccordionToggle = (accordions) => {
        accordions.forEach((accordion) => {
            accordion.addEventListener("toggle", () => {
                if (accordion.open) {
                    accordions.forEach((otherAccordion) => {
                        if (otherAccordion !== accordion && otherAccordion.open) {
                            otherAccordion.open = false;
                        }
                    });
                }
            });
        });
    };

   

Wordpress admin bar - add small box for monitoring pageload, query and memory

/**
*************************************************************************
 * WORDPRESS - Show in the admin bar the main PHP template file, used template parts, PHP version, query count and page load time
*************************************************************************
*/
// Store the actual template being used
global $current_template_file;
add_filter('template_include', function($template) {
  global $current_template_file;
  $current_template_file = $template;
  return $

Escaping con kses

$example = get_field( 'example' ); 
echo wp_kses( $example, array(
  'b' => array(), 
  'br' => array(), 
  'strong' => array(), 
  'em' => array(),
  'h1' => array(),
  'h2' => array(),
  'h3' => array(),
  'h4' => array(),
  'h5' => array(),
  'h6' => array(),
  'p' => array(),
) );

COMAND CLI ANGULAR

COMANDI CLI ANGULAR:
ng add @angular/material

Script

`node ./sc.js`
const data = require('./snaphots.json');
const fs = require('fs');

const boo = data.map(({date, fundsExchanges, funds, notionalCcy, additionalFunds}) => {
  return {
    date,
    notionalCcy,
    fundsExchanges,
    additionalFunds,
    funds: funds.map(({ id, prices, createdAt, updatedAt, ltv, liqPx, ...other}) => {
      return {
        ...other,
        ltv: ltv || undefined,
        liqPx: liqPx || undefined,
        type: "manual",
        prices: prices.map(({id, createdA

WLAN Interfaces

Show status of all network interfaces
nmcli device status

MITM Proxy

Useful scripts around using MITM Proxy
mitmproxy --mode transparent --showhost --allow-hosts sessions.ggn.live:6125

Give header a custom styling based on character count

This is useful for when there is alot of menu items and it goes to a second line when the laptop screen is smaller.
header#top {
	@include respond-to(only-xl) {
		@for $i from 50 through 70 {
			@if $i >= 50 and $i <= 54 {
				&[data-carcount="#{$i}"] {
					nav.header-nav {
						--fontsize-main-menu-item: 1.4rem;
						--p-x-main-item: 1.4rem;

						form.search-form input[type="text"] {
							max-width: 20rem;
						}
					}

					.logo svg {
						width: 19rem;
					}
				}
			} @else if $i >= 55 and $i <= 59 {
				&[data-carcount="#{$i}"] {
					nav.header-nav {
						--fontsize-main-menu-item: 1.4rem;

Java Date/Time Methods

// timeDifference(t1:time, t2:time):time
// timeDifferenceAsString(t1:time, t2:time):string


public LocalTime timeDifference(LocalTime t1, LocalTime t2){
    long totalSeconds = ChronoUnit.SECONDS.between(t1, t2);
    
    long hours = totalSeconds / 3600;
    long minutes = (totalSeconds % 3600) / 60;
    long seconds = totalSeconds % 60;
    
    String td = String.format("%02d:%02d:%02d", 
            hours, minutes, seconds);
    return LocalTime.parse(td);
}

public String 

Api_learn_resources

pretzel logic website:
https://www.pretzellogix.net/2021/12/08/step-1-read-the-docs-and-use-postman-to-understand-the-rest-api/