the yjs newest insrt Item left was GC

I am using yjs https://github.com/yjs/yjs to implement a collaborate editor(v13.6.24), now I found the newest insert item did not append to the Doc. Then I tried to tracing the newest insert element
from source code and found that the element left side was a GC object. From the source code getMissing:

if (this.origin) {
      this.left = getItemCleanEnd(transaction, store, this.origin);
      this.origin = this.left.lastId;
    }

when the left was a GC object, the parent will set to null make the current insert item to GC:

if ((this.left && this.left.constructor === GC) || (this.right && this.right.constructor === GC)) {
      this.parent = null;
    } 

why the new insert Item left was GC? does anyone facing the similar issue? The new insert element should never append after a GC object.

How to make Typescript raise error on extraneous property? [duplicate]

In this example scenario, the developer made the mistake to name the field titleText instead of title.

interface ProductFoo {
  recommendationId?: string;
  title?: string; // Correct property name
  imageUrl?: string;
}

const products: ProductFoo[] = [];

// Correct object
const result: ProductFoo = {
  recommendationId: '1',
  title: 'Some Title', // Correct property name
  imageUrl: 'http://example.com/image.jpg',
};

products.push(result); // This will work fine

// Incorrect object (titleText does not exist on ProductFoo interface)
const wrongResult = {
  recommendationId: '1',
  titleText: 'Some Title', // TypeScript not giving error: 'Property 'titleText' does not exist on type 'ProductFoo'.'
  imageUrl: 'http://example.com/image.jpg',
};

products.push(wrongResult);

But typescript does not give any error here.

Why is this a Big Bug?

in subsequent code, we have
mustHaveTitleOrDeleteForever(product.title) // oops, deleted

I know I can just declare type of wrongResult: ProductFoo but is there way to keep the benefit of type inference ?

Undefined array key for every field

just to clarify I’m someone with absolutely no knowledge of PHP prior to this project.

i found this problem on my code and i cant solve i am trying to follow some youtube video and it same that the code is exactly like but still i cant fix it

this the error

Warning: Undefined array key “first_name” in C:xampphtdocsSocial mediaClasssignup_class.php on line 36

Warning: Undefined array key “first_name” in C:xampphtdocsSocial mediaClasssignup_class.php on line 39

Warning: Undefined array key “last_name” in C:xampphtdocsSocial mediaClasssignup_class.php on line 40

Warning: Undefined array key “gender” in C:xampphtdocsSocial mediaClasssignup_class.php on line 41

Warning: Undefined array key “email” in C:xampphtdocsSocial mediaClasssignup_class.php on line 42

Warning: Undefined array key “password” in C:xampphtdocsSocial mediaClasssignup_class.php on line 43

Fatal error: Uncaught Error: Call to undefined function create_userid() in C:xampphtdocsSocial mediaClasssignup_class.php:47 Stack trace: #0 C:xampphtdocsSocial mediaClasssignup_class.php(26): Signup->create_user(Array) #1 C:xampphtdocsSocial mediasign_up.php(12): Signup->evaluate(Array) #2 {main} thrown in C:xampphtdocsSocial mediaClasssignup_class.php on line 47

my code for that particular error

this is for the signup page

    <input name="first_name" type="text" style="width: 300px; height: 30px;   border-radius: 5px; margin-top: 40px; margin-left: 250px; padding-left: 10px" placeholder="First Name"><br>

    <input name="last_name" type="text" style="width: 300px; height: 30px; border-radius: 5px; margin-top: 20px; margin-left: 250px; padding-left: 10px;" placeholder="Last Name"><br>

Gender:

<option value="Male">Male</option>
<option value="Female">Female</option>

    <input name="email" type="text" style="width: 300px; height: 30px; border-radius: 5px; margin-top: 10px; margin-left: 250px; padding-left: 10px;" placeholder="Email"><br>

    <input name="password" type="password" style="width: 300px; height: 30px; border-radius: 5px; margin-top: 20px; margin-left: 250px; padding-left: 10px;" placeholder="enter Your Password"><br>

    <input name="pass2" type="password" style="width: 300px; height: 30px; border-radius: 5px; margin-top: 20px; margin-left: 250px; padding-left: 10px;" placeholder=" Reetyoe Password"><br>
    
    <input type="submit" style="width: 300px; height: 30px; border-radius: 5px; margin-top: 20px; margin-left: 250px; background-color: #4b5c77; color: white; cursor: pointer; border: none;" value="Sign up"><br>

and this is the class where the error is coming from

public function create_user($data)
{ //calling the database class to save the data

    $firstname = $data["first_name"];
    $lastname = $data['last_name'];
    $gender = $data['gender'];
    $email = $data['email'];
    $password = $data['password'];

    //creating a url_adress for the user and the userid
   $url_adress = strtolower($firstname) . strtolower( $lastname);
   $userid = create_userid();



    $query= "insert into users
     (userid,first_name,last_name,gender,email,password,url_adress)
     values
     ('$userid', '$first_name','$last_name','$gender','$email','$password','$url_adress')";
    include_once("connect.php");

    return $query;
    /*
    $db = new Database();
    $db->save($query);
    */
}
private function create_userid()
{
    //creating a random number for the user id
    $length = rand(4,19);
    $number ="";
    for($i=0; $i<$length; $i++)
    {
        $rand_number = rand(0,9);
        $number .= $rand_number;
        return $number;
    }
}

Function “isAfter”

Write a function isAfter, which takes two dates as parameters, for checking if the first date is after the second date. It returns true if it is after and false if not.

Please note the function should be exported from the script.js file, as in the example below:

export function isAfter(date, dateToCompare) {
  // your code...
}

This function takes two parameters:
date – a Date object
dateToCompare – a Date object

The function should return true if the date is after dateToCompare.
It should return false if the date is before dateToCompare.
It should return false if any of the dates are invalid.

An example of using the function:

let date1 = new Date(2022, 22, 10);
let date2 = new Date(2022, 23, 10);

isAfter(date1, date2); // false
isAfter(date2, date1); // true
isAfter(date1, new Date(undefined)); // false

is there any way to run something only once in JavaScript?

I’m trying to put an audio into a code when it’s run, but since the browser I use doesn’t allow autoplay, I tried alternatively using a ‘button’ at the start to play the audio, but it keeps crashing. I don’t know how to create buttons so I’m using a rectangle and when mouse is pressed within the barrier of the rectangle, the variable to start the audio becomes true. This is my code:

if(starty = 380){ /*if it’s pressed at a specific time*/
  if(startx + startw > mouseX && mouseX > startx){
    if(starty + starth > mouseY && mouseY > starty) {
        if(mouseIsPressed){
          start = true;
        } 
  }
  }
}

if (start == true){
  startr = 0;
  song.play();
}

But I figured since the audio is played continuously while start = true, it happens too many times and crashes.

I tried adding a for loop to song.play() but it didn’t work 🙁

if (start == true){
  startr = 0;
  for (let i = 0; i < 2; i += 1) { /*hopefully this makes it run only once*/
    song.play();
  }
}

But it still crashes and I’m not sure what to do.
Also this is my first time asking a question so it might be a bit messy, sorry. Thank you!

How to style Google Maps PlaceAutocompleteElement to match existing form inputs?

I’m migrating from the legacy Google Places Autocomplete to the new PlaceAutocompleteElement in my Rails application. The new component is working functionally, but I can’t get it to match the styling of my existing form inputs.
Instead of enhancing my existing street address input field, the PlaceAutocompleteElement renders it as a completely separate input with Google’s default styling, creating an inconsistent UI.

Do you know how to remove the black border and change styles overall in https://developers.google.com/maps/documentation/javascript/examples/place-autocomplete-element#maps_place_autocomplete_element-javascript ?

I can’t find any example with styled widget. I found only for legacy places.

How to catch a JSON error preventing page load

After my computer has been idle for a while and I load a page, I sometimes get an error like

SyntaxError: JSON.parse: unexpected character at line 2 column 5 of the JSON data

and the page does not load

I can refresh the page and the error disappear and the site works as normal.

Until I figure out the source of the problem, is there any javascript or jQuery way to catch that error and force the page to reload?

(failed)net::ERR_CONNECTION_REFUSED found this issue in react I want to handle the error in react?

(failed)net::ERR_CONNECTION_REFUSED found this issue in react I want to handle the error in react ?

how to handle the request and throw the error in react

(failed)net::ERR_CONNECTION_REFUSED found this issue in react I want to handle the error in react ?

how to handle the request and throw the error in react
(failed)net::ERR_CONNECTION_REFUSED found this issue in react I want to handle the error in react ?

how to handle the request and throw the error in react

How do I fix these errors? When I submit my html page in The W3C Markup Validation it displays the errors but I couldn’t solve it [closed]

The errors are in this screenshot

I was checking where there was a closing tag but I can’t find any errors below is a screenshot of my html code.

Part 2 – half of the code
Part 1 – first part of the code

Please help if you see any issues. I tried many options but I can’t seem to solve it.

below is the code

<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>FARM to TABLE</title>
    <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
    <link rel="preconnect" href="https://fonts.googleapis.com">
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
    <link href="https://fonts.googleapis.com/css2?family=Red+Hat+Display:ital,wght@0,300..900;1,300..900&family=Zilla+Slab:ital,wght@0,300;0,400;0,500;0,600;0,700;1,300;1,400;1,500;1,600;1,700&display=swap" rel="stylesheet">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/font/bootstrap-icons.min.css">
    <link rel="stylesheet" href="css/style.css">
</head>
  <body>
    <nav class="navbar navbar-expand-lg bg-custom">
        <div class="container-fluid">
          <a class="navbar-brand" href="index.html"><img src="images/brandlogo.svg" alt="FARM to TABLE" class="logo"></a>
          <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNavDropdown" aria-controls="navbarNavDropdown" aria-expanded="false" aria-label="Toggle navigation">
            <span class="navbar-toggler-icon"></span>
          </button>
          <div class="collapse navbar-collapse" id="navbarNavDropdown">
            <ul class="navbar-nav">
              <li class="nav-item">
                <a class="nav-link" href="index.html">Home</a>
              </li>
              <li class="nav-item">
                <a class="nav-link" href="about.html">About</a>
              </li>
              <li class="nav-item">
                <a class="nav-link" href="services.html">Services</a>
              </li>
              <li class="nav-item">
                <a class="nav-link" href="contact.html">Contact</a>
              </li>
            </ul>
          </div>
        </div>
      </nav>
    

      <div class="container text-center">
        <!-- Columns are always 50% wide, on mobile and desktop -->
        <div class="row">
          <div class="col-md-12"><img src="images/vegetables-basket-garden-produce-fresh.jpg" alt="vegetables in basket" class="img-fluid"></div>
          <h1 class="lh-1">At Farm to Table CSA in Elberta, Alabama, our mission is to nurture our community through USDA organic farming and the Community Supported Agriculture model. We pledge to promote sustainability by promoting local agriculture and providing the freshest produce directly to our customers.</h1>
          <div class="col-md-6"><img src="images/cucumber-tomatoes-vines-garden-green.jpg" alt="cucumber and tomatoes" class="img-fluid"></div>
          <div class="col-md-6"><img src="images/carrots-orange-garden-picked-fresh.png" alt="orange carrots" class="img-fluid"></div>
        </div>
      </div>

      <footer class="footer mt-3 py-3">
        <div class ="container text-center">
          <div class="row">
            <div class="col-lg-6">
              <h2>FARM to TABLE</h2>
              <p>230 Main Street <br>Elberta, Alabama 23567 <br>332-223-2323</p>
          </div>
          <div class="col-lg-6">
            <h2>Hours</h2>
            <p>Tuesday-Thursday 9am-7pm <br>Friday-Saturday 9am-5pm</p>
            <a href="https://www.facebook.com/yourpage" target="_blank" aria-label="Facebook"><i class="bi bi-facebook"></i></a>
            <a href="https://www.instagram.com/yourpage" target="_blank" aria-label="Instagram"><i class="bi bi-instagram"></i></a>
            <a href="https://www.youtube.com/yourpage" target="_blank" aria-label="YouTube"><i class="bi bi-youtube"></i></a>
          </div>
            <h3>&copy;2025, FARM to TABLE.</h3>
        </div>
        </div>
      </footer>
      
    <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" crossorigin="anonymous"></script>
  </body>
</html>

Attaching inner functions that use the same random number to related button click events js

I’m working on a game that will take a random object, and use that same random object for a series of questions/functions. I’m having trouble getting the next piece of code to run after clicking the “Begin” button. Most basically (and I know it’s still a lot sorry):

repo: https://github.com/ChristinaBohn/botany-game

const button = document.querySelector('#button')

const objects = [
  {
    id: 0,
    name: "Object",
    "first question": {
       "button text": "button text",
       "button function": "outerFunction.innerFunction2"
     },
    "second question": {
       "button text": "button text",
       "button function": "otherFunction"
     }
   }
]

const actions = [
  {
    name: "welcome",
    "button text": "button text",
    "button function": "outerFunction.innerFunction1"
  }
]

function useRandomIndex() {
  let randomIndex = Math.floor(Math.random() * 3);
  let currentObject = objects[randomIndex];

  function innerFunction1() {
    button.innerText = currentObject["first question"]["button text"][0]
    button.onclick = currentObject["first question"]["button function"][0]
  }

  function innerFunction2() {
    button.innerText = currentObject["second question"]["button text"][0]
    button.onclick = currentObject["second question"]["button function"][0]
  }

  button.onclick = useRandomIndex.innerFunction1
  return { innerFunction1, innerFunction2 }
};

const outerFunction = useRandomIndex();

function update(action) {
  button.innerText = action["button text"][0]
  button.innerText = action["button functions"][0]
}

function welcome() {
  update(actions[0])
}

functions['outerFunction.innerFunction1'] = outerFunction.innerFunction1;
functions['outerFunction.innerFunction2'] = outerFunction.innerFunction2;
functions['update'] = update;
functions['welcome'] = welcome;

welcome();
 

I’ve tried initializing the buttons inside the outerFunction and the game immediately jumps to the innerFunction1 step, but with the button initialized outside it gets stuck on the welcome page.

Any help is appreciated and I’m very new to this so please be gentle, don’t be afraid to overexplain -thanks!

Transform Origin with onMouseMove glitch

I’m trying to make this beam of light that follows mouse movement, typical of a light house basically. I’ve been able to get syntax, but the issue I have is that is that the code seems to break when carrying the cursor behind the light. I noticed that the issue is resolved when I change the transform origin to 50% 50%, but I still want the origin to be at 0 50% so it’s from a fixed point.

import { useRef } from "react";

const Lighthouse = () => {
  const lightBeamRef = useRef(null);
  function handleMouseMove(e) {
    const rect = lightBeamRef.current.getBoundingClientRect();
    const originX = rect.left + rect.width / 2;
    const originY = rect.top + rect.height / 2;

    const cursorX = e.clientX;
    const cursorY = e.clientY;

    const angle =
      (Math.atan2(cursorY - originY, cursorX - originX) * 180) / Math.PI + 1;

    lightBeamRef.current.style.transform = `rotate(${angle}deg)`;
    lightBeamRef.current.style.transformOrigin = "0% 50%"; 
  }

  return (
    <>
      <div
        className="light-rock bg-stone-700 w-screen h-screen justify-center items-center flex"
        onMouseMove={(e) => handleMouseMove(e)}
      >
        <div
          ref={lightBeamRef}
          className="light-beam bg-gray-200 w-50 rounded-full"
          style={{
            height: "100px",
            clipPath: "polygon(0 50%, 100% 0, 100% 100%)",
            transformOrigin: "0% 50%",
            background: "linear-gradient(45deg, #FA6900, #C02942)",
            transition: "transform 0.05s ease-out",
          }}
        ></div>
      </div>
    </>
  );
};

export default Lighthouse;

Hyperledger Fabric: Chaincode Registration Failed – “container exited with 0”

Problem Description

I am trying to deploy and invoke a chaincode on Hyperledger Fabric 2.4 using deployChaincode.sh. The chaincode installation and approval complete successfully, but when I try to invoke the chaincode using chaincodeInvokeInit, I get the following error:

Error: endorsement failure during invoke. response: status:500 message:"error in simulation: failed to execute transaction 83cdc94eeead01384f3eeabc101a71417645997f5d895e5be48dfa773b1900b3: could not launch chaincode residentManagement_1:13e03034c9144a182ea9a37c54a8b67d0df045cff62cccfafea937a01e8471ec: chaincode registration failed: container exited with 0"

Environment Details

Hyperledger Fabric Version: 2.4

Node.js Version: 16.20.2

Operating System: Ubuntu (running inside WSL)

Chaincode Language: JavaScript

What I Have Tried

Chaincode installation, approval, and commit all succeed.

Checked that all peers and orderers are running correctly.

Verified that the chaincode package ID matches the installed chaincode.

Chaincode Installation, Approval, and Commit Logs

Checked logs for possible issues but did not find any clear errors.

chaincode container logs

Issue with executeMethod OpenFile

I’m trying to open a template file from my custom plugin. I haven’t any errors and nothing happens. But by some reason result is undefined.
A size of uint8Array is exactly the same as the size of the file that I want to open.

const templateId = Asc.scope.step.data.template;

const template = await fetch(`http://localhost:3000/templates/${templateId}`);
const arrayBuffer = await template.arrayBuffer();
const uint8Array = new Uint8Array(arrayBuffer);

window.Asc.plugin.executeMethod('OpenFile', [uint8Array, ['id', `${templateId}.xlsx`]], function (result) {
  console.log('OpenFile.result', result);
});