remove XML from SOAP responses

I am trying to deploy a non-wsdl php soapserver, the code as follows if very basic:

function notify($string) {
    return null;
 }
 
$server = new SoapServer(null,
            array('uri' => "http://localhost/"));

$server->addFunction("notify");
   $server->handle(); 

The above seems to work fine, the only problem is that the soap client requires a 200 OK and empty notifyResponse XML element. As you can see from the above, I tried a “return null” on the notify function but that still builds a “notifyResponse” element.

Unfortunately I cannot modify the client to accept anything different. I also tried removing the soapServer for tests and generated a http response with just a 200ok without any XML response and that was acceptable, unfortunately I cannot find a way to do this when soapServer is used.

The most simplified response I was able to generate is shown below, I achieved that by using:

return new SoapVar(”,XSD_ANYXML);

But this is still not accepted by the client as a good response, I either need to remove the whole XML layer or at least remove the “notifyResponse”

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
                   xmlns:ns1="http://localhost/"
                   xmlns:xsd="http://www.w3.org/2001/XMLSchema"
                   xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
                   SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
  <SOAP-ENV:Body><ns1:notifyResponse></ns1:notifyResponse></SOAP-ENV:Body>
</SOAP-ENV:Envelope>




AWS Kinesis library is not sending errors [closed]

I am using https://www.npmjs.com/package/@aws-sdk/client-kinesis to connect to aws kinesis. From time to time, I can see that in logs, there is a 400 error being logged on the line that I make client.send() post request. None of the followings worked to show me the reason behind that 400 error.

  • I tried wrapping client.send() in a try catch block, but no error is being captured!
  • using .then().catch(e => console.log(e)) didn’t work either
  • using .then(data => console.log(data), e => console.log(e)) didn’t capture it either

Is it a problem with the library that I am using for JS. Is there any other implementation to read kinesis data?

Selenium doesn’t detect specific item when not being active in the tab in the browser but works if I am active

I am trying to scrape from a very specific site that has two things that doesn’t work as expected: A) reject the cookie banner using reject button and B) enter a specific section to get a view about the profile views.

If I am active in the browser tab everything works as expected but if I am not the button for reject is found but the move_element(…).click().perform() doesnt’ reject the cookie banner and B) the section is not found.

Is this some bot-detection mechanism?

How to find the shortest path in a multigraph with dynamic edge costs based on bus line changes? [closed]

I’m working with a multigraph in JavaScript where each edge represents a bus route and includes both a weight (e.g., travel time or distance) and a busLine identifier.

I want to calculate the shortest path between two nodes, but with the following rule:

If a traveler switches bus lines from one edge to the next, a fixed penalty (e.g. +5) is added to the total cost.

Here is a simplified structure of my graph:
Example Visual Graph

const graph = {
  A: [
    { to: 'B', weight: 10, busLine: '2' },
    { to: 'B', weight: 10, busLine: '1' },
    { to: 'B', weight: 10, busLine: '3' },
  ],
  B: [
    { to: 'C', weight: 10, busLine: '1' },
    { to: 'D', weight: 10, busLine: '2' },
    { to: 'D', weight: 10, busLine: '3' },
    { to: 'D', weight: 10, busLine: '4' },
  ],
  C: [],
  D: [
    { to: 'E', weight: 10, busLine: '4' },
    { to: 'E', weight: 10, busLine: '3' },
  ],
};

For example:

A -> C [1, 1]

A -> D [2, 2] or [3, 3]

A -> E [2, 2, 4] or [3, 3, 4]

What I’m looking for:

  1. What is the best way to model or approach this problem?
  2. Is there a known algorithm (or variation of Dijkstra/A*) that supports dynamic edge costs based on previous edge metadata like busLine?
  3. Any recommended libraries or techniques to make this efficient on large graphs?
    Thanks in advance!

How can I restore a page to its initial state, if website state is saved to Local Storage?

I want to add a reset button to the website below, which will return the webpage to its initial state.

Reloading the web browser is not possible because the actions performed are stored in Local Storage.

I tried it via Gemeni but it gives the wrong answer. Can someone help me with this?

Thanks in advance.

<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
  body {
    margin: 0;
    background: #000000;
  }

  div.removable {
    color: #ffffff;
    font-size: 25px;
    font-family: Arial;
    padding: 12px 8px 12px 10px;
    cursor: pointer;
  }

  button {
    padding: 10px 15px;
    font-size: 16px;
    cursor: pointer;
    margin-top: 10px;
    position: fixed;
    top: 10px; /* Pas deze waarde aan om de verticale positie te bepalen */
    right: 10px; /* Pas deze waarde aan om de horizontale positie te bepalen */
    padding: 10px 15px;
    font-size: 16px;
    cursor: pointer;
    z-index: 1000; /* Zorg ervoor dat de knop boven andere elementen ligt */
  }
</style>
</head>
<body>
<div style="padding-top: 60px;"></div>
  <div class="removable" onclick="removeElement(this)">Task 1</div>
  <div class="removable" onclick="removeElement(this)">Task 2</div>
  <div class="removable" onclick="removeElement(this)">Task 3</div>

  <button id="undoButton" onclick="undoLastRemoval()" disabled>Undo</button>



  <script type="text/javascript">
    const removalHistory = []; // Array om verwijderde elementen en hun posities op te slaan
    const listContainer = document.body; // De container van de verwijderbare elementen

    // Functie om de huidige staat van de lijst op te slaan in Local Storage
    function saveListState() {
      const remainingItems = Array.from(document.querySelectorAll('.removable')).map(item => item.textContent);
      localStorage.setItem('todoListState', JSON.stringify(remainingItems));
    }

    // Functie om de opgeslagen staat van de lijst te laden
    function loadListState() {
      const savedState = localStorage.getItem('todoListState');
      if (savedState) {
        const items = JSON.parse(savedState);
        // Verwijder alle bestaande items
        document.querySelectorAll('.removable').forEach(item => item.remove());
        // Voeg de opgeslagen items opnieuw toe
        items.forEach(text => {
          const newDiv = document.createElement('div');
          newDiv.className = 'removable';
          newDiv.textContent = text;
          newDiv.onclick = function() { removeElement(this); };
          listContainer.insertBefore(newDiv, document.getElementById('undoButton'));
        });
        // Reset de undo geschiedenis omdat de pagina opnieuw is geladen
        removalHistory.length = 0;
        document.getElementById('undoButton').disabled = true;
      }
    }

    function removeElement(el) {
      removalHistory.push({
        element: el,
        previousSibling: el.previousElementSibling
      });
      el.remove();
      document.getElementById('undoButton').disabled = false;
      saveListState(); // Sla de staat op na een verwijdering
    }

    function undoLastRemoval() {
      if (removalHistory.length > 0) {
        const lastRemoval = removalHistory.pop(); // Haal de laatste verwijdering uit de geschiedenis
        const elementToRestore = lastRemoval.element;
        const previousSibling = lastRemoval.previousSibling;

        if (previousSibling) {
          previousSibling.insertAdjacentElement('afterend', elementToRestore);
        } else {
          listContainer.insertBefore(elementToRestore, listContainer.firstChild);
        }

        // Schakel de undo knop uit als er geen verwijderingen meer zijn om ongedaan te maken
        document.getElementById('undoButton').disabled = removalHistory.length === 0;
        saveListState(); // Sla de staat op na een undo
      }
    }

    // Laad de opgeslagen staat wanneer de pagina geladen is
    window.onload = loadListState;
  </script>
</body>
</html>

TypeError: The ‘data’ argument must be of type string or Buffer in Node.js crypto.update() for Password Reset

I am working on a password reset feature in a Node.js/Express application using Sequelize and the crypto module to hash passwords. When I send a POST request to my /reset-password endpoint, I get the following error:

Error in resetPassword: The “data” argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received undefined.

Here’s the relevant code for the resetPassword function:

import crypto from "crypto";
import { User } from "../models/user.js"; // Sequelize model
import { Op } from "sequelize";
import logger from "../utils/logger.js";

export const resetPassword = async (req, res) => {
  try {
    const { token, password } = req.body;

    // Find user by reset token
    const user = await User.findOne({
      where: {
        reset_token: token,
        reset_token_expires: { [Op.gt]: new Date() },
      },
    });

    if (!user) {
      return res.status(400).json({ message: "Invalid or expired reset token" });
    }

    // Hash new password
    const hashedPassword = crypto
      .createHash("sha256")
      .update(password)
      .digest("hex");

    // Update user password and clear reset token
    await user.update({
      password: hashedPassword,
      reset_token: null,
      reset_token_expires: null,
    });

    res.status(200).json({ message: "Password reset successful" });
  } catch (error) {
    logger.error("Error in resetPassword:", error);
    res.status(500).json({ message: "Error resetting password" });
  }
};

Additional info:
Node.js version: 18.x
Express version: 4.x
Sequelize version: 6.x

Code Completion Fails for Destructured Variables in WebStorm

WebStorm code completion does not work with destructured objects. See the example.

Successful type inference

Failed type inference

In the line

const { autoSkedDay, row } = currentHeader;

the IDE correctly infers that autoSkedDay: AutoSkedDay. However, in the subsequent line

const { endRow } = autoSkedDay;

the IDE incorrectly infers that autoSkedDay: any. In other words, it has forgotten what it used to know about the variable.

Has anyone had a similar issue and know how to fix it?

I tried not destructuring objects, and everything worked fine. For example, the following works:

const autoSkedDay = currentHeader.autoSkedDay;

In other words, this time the IDE recognizes that autoSkedDay: AutoSkedDay. However, when I abbreviate my code using object destructuring, type inference fails.

This issue happens all over the place in my code, despite extensive documentation (JSDoc) and it is very frustrating.

Problem with node.js: ReferenceError: window is not defined

ReferenceError: window is not defined
    at Object.<anonymous> (c:UsersLEDiSON BiZDesktoptestJavaScriptacceptUserInput.js:8:1)
    at Module._compile (node:internal/modules/cjs/loader:1554:14)
    at Object..js (node:internal/modules/cjs/loader:1706:10)
    at Module.load (node:internal/modules/cjs/loader:1289:32)
    at Function._load (node:internal/modules/cjs/loader:1108:12)
    at TracingChannel.traceSync (node:diagnostics_channel:322:14)
    at wrapModuleLoad (node:internal/modules/cjs/loader:220:24)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:170:5)
    at node:internal/main/run_main_module:36:49

I tried reviewing folders in the modules and diagnostic_channel but all was to no avail

Trying to hide auto-expanding menu bar on Zillow.com using tampermonkey

I’ve tried following several examples I found, but haven’t been able to get this to work.

The zillow menu in the map view with listings on the sidebar bar auto-expands on hover, which is annoying when I move my mouse too far accidentally past the search bar, and then have to move it away to make the expanded menu disappear.

I’m trying the following in my tampermonkey script, but it won’t work:

// ==UserScript==
// @name         Hide expanding menu bar
// @namespace    http://tampermonkey.net/
// @version      0.1
// @require      https://code.jquery.com/jquery-3.6.0.min.js
// @description  Hides zillow auto-expanding menu
// @author       mikmak
// @match        https://www.zillow.com/*
// @grant        GM_addStyle
// ==/UserScript==

const $ = window.$;
function hideStuff() {
  $('.data-zg-section="main"').removeClass('.data-zg-section="main"');
  $('.data-zg-section="main"').hide();
}

The menu bar I am referring to is the “Buy Rent Sell Get a mortgage Find an agent” menu above the search box at the top left side.

connect file.cpp with requeriments from javascript [closed]

I’m trying to make an application. The frontend, through javascript, would request the user’s fingerprint and this would have to connect to the file.cpp that I use on the esp32s with the fingerprint reader and then send it to firebase. Is there a way I can apply this? I researched it, but I didn’t get satisfactory results.

Instructions for completing tasks and activities for GPU Network

Complete the tasks to qualify for potential GPU Network airdrops and rewards . Follow step-by-step instructions and track task updates and statuses to become one of the potential recipients of the GPU Network Airdrop.

Road to TGE Campign
Completed
GPU.NET has launched the Road to TGE campaign. We can perform tasks and earn GXP (points). These points will be converted into project tokens in the future. More points – more rewards.

  1. Go to the site and connect your wallet:

How can I filter an array of objects based on any value in JavaScript?

I have this array:

fullArray = [{color:'cars'},{make:'cars'},{weight:'people'},{height:'people'}]

I want this array;

justCars = [{color:'cars'},{make:'cars'}]

I have tried this code:

justCars = Object.fromEntries ( Object.entries ( fullArray.filter ( ([key,value]) => value === 'cars' ) );

The resulting array is empty.

How can I filter the array to keep those elements where the value = 'cars'?

Loading screen with message for every table fetching – Vue.js

At this point I’m just at a loss.

I’m a college student, this is for a school finals project.

I’m trying to make a loading screen where every step (fetching a table) has a message like “Fetching students…” then “Fetching administrators…” etc.

I’ve tried everything ChatGPT has told me to try, at this point it’s just making me try the same thing in a different style.

I’m not that knowledgeable about promises and DOMS and async/sync..
But here’s what I have learned so far about this, please correct me if I’m wrong:

  1. It does all the fetching parts before calculating the changes on the message at the end (or something like that), so it’s more like fetch – fetch – change message – change message, rather than change message – fetch – change message – fetch.
  2. That’s why you have to find a way to force Vue to re-render the DOM after changing the message, every time.

I’ve tried:

  • await this.$nextTick() between changing the message and fetching next table
  • await new Promise(r => requestAnimationFrame(r))
  • setTimeout() for changing message
  • setTimeout() for fetching table
  • any combination of these

But still, it’s not working as intended, what happens is either it goes blank then that’s it, or it flashes all the messages right at the end.

Here is the code (before I tried anything, to keep it simple):

          this.ShowAdminLogin = false;
          this.ShowAdminBoot = true;
          
          this.adminBootMessage = "Fetching admin controls...";
          await this.getAdminControls();
          
          this.adminBootMessage = "Fetching document requests...";
          await this.getAllRequest();
          await this.getAllRequestHistory();
          
          this.adminBootMessage = "Fetching admission forms...";
          await this.getAllAdmission();
          await this.getAllAdmissionHistory();
          
          this.adminBootMessage = "Fetching student users...";
          await this.getAllStudent();
          
          this.adminBootMessage = "Fetching administrators...";
          await this.getAllAdmin();
          
          this.adminBootMessage = "Fetching audit logs...";
          await this.getAllAuditLogAdmission();
          await this.getAllAuditLogRequest();
          
          this.login = true;
          this.loginMessage = data.message;
          this.adminDetails = data.data;
          this.verified = true;
          this.AdminID = data.data.admin_id;
          this.resetScreens();
          this.intervalUpdate();
          
          this.adminBootMessage = "Welcome, administrator!";
          this.loadingScreenTimeout();
          
          this.ShowAdminPanel = true;
          this.ShowDocumentRequests = true;

Can somebody just tell me how it should be so it works as intended? I just really need it to work asap. Thank you

NOTE: I’m using the CDN version of Vue

js circle inscribed in a rectangle

i was trying to make the image crop modal when you change your pfp in social midea sites
enter image description here

I have an absolutely positioned image with a circular crop area centered within it. you can currently drag the image, but I need to constrain this movement. The goal is to ensure the crop circle always remains fully inside the image boundaries. However, my current clamping code has errors, and the behavior varies unpredictably depending on the image dimensions, as shown in the attached image.

here is some of relevant part of my code

 const handleCropPreviewDrag = (e: React.MouseEvent<HTMLDivElement>) => {
    e.preventDefault();
    const img = pfpPreviewImageRef.current;
    if (!img) return;

    // Get the bounding rect of the image (after zoom/scale)
    const rect = img.getBoundingClientRect();
    // Store mouse offset inside the image
    dragOffsetRef.current = {
      x: e.clientX - rect.left,
      y: e.clientY - rect.top,
    };
    dragStartRef.current = {
      left: parseFloat(img.style.left) || 0,
      top: parseFloat(img.style.top) || 0,
    };

    const container = img.parentElement!;
    const containerRect = container.getBoundingClientRect();
    const cropSize = cropInducatorSize;
    const crop = cropIndicatorRef.current;

    function onMouseMove(ev: MouseEvent) {
      if (!img || !crop) return;
    
      // Get current image and container sizes
      const imgRect = img.getBoundingClientRect();
      const container = img.parentElement!;
      const containerRect = container.getBoundingClientRect();
      const cropSize = cropInducatorSize;
    
      let newLeft = dragStartRef.current.left + (ev.clientX - e.clientX);
      let newTop = dragStartRef.current.top + (ev.clientY - e.clientY);
    
      const minLeft = containerRect.width / 2 + cropSize / 2 - imgRect.width;
      const maxLeft = containerRect.width / 2 - cropSize / 2;
    
      newLeft = Math.min(maxLeft, Math.max(minLeft, newLeft));
    
      // Same for top
      const minTop = containerRect.height / 2 + cropSize / 2 - imgRect.height;
      const maxTop = containerRect.height / 2 - cropSize / 2;
    
      newTop = Math.min(maxTop, Math.max(minTop, newTop));
    
      img.style.left = `${newLeft}px`;
      img.style.top = `${newTop}px`;
    }

    function onMouseUp() {
      window.removeEventListener("mousemove", onMouseMove);
      window.removeEventListener("mouseup", onMouseUp);
    }

    window.addEventListener("mousemove", onMouseMove);
    window.addEventListener("mouseup", onMouseUp);
  }
<div  className="w-full relative max-h-[85%] flex flex-grow p-0 bg-black border border-border rounded-xl overflow-hidden">
                      
                      <Image
                        src={pendingPreviewUrl || user.image || "/user_placeholder.jpg"}
                        alt="Profile crop preview"
                        width={500}
                        height={500}
                        className="object-contain  rounded-xl w-fit top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 absolute select-none p-1 border border-border "
                        sizes="180px"
                        onLoad={()=>{
                          setImageTrueHeight(getContainedSize(pfpPreviewImageRef.current!)[1]!);
                          setImageTrueWidth(getContainedSize(pfpPreviewImageRef.current!)[0]!);
                        }}
                        style={{
                          maxHeight: "100%",
                          position: "absolute",
                        }}
                        ref={pfpPreviewImageRef}
                        onMouseDown={handleCropPreviewDrag}
                        onDragStart={e => e.preventDefault()}
                      >
                      </Image>
                      <div
                        ref={cropIndicatorRef}
                        className="crop-inducator absolute cursor-move -translate-x-1/2 -translate-y-1/2 bg-white/20 top-1/2 left-1/2 size-[200px] rounded-full outline outline-black border-2 border-white pointer-events-none"
                        style={{ width: cropInducatorSize, height: cropInducatorSize }}
                        
                      />
                      </div>

there is also a zoom slider and it affects the image by setting style.scale css property and i want to account for that too when calculating bounds