How can I split a 128-bit value into two 64-bit values [closed]

I’m trying to make a function that appends 2 longs into one and back again.

I used the (ac) + (ad) + (bc) + (bd) formula to combine the numbers.

I have searched for and wide (including this site) with no luck as to how to split the number into two.

I’m using PHP which as you know doesn’t have functions to convert floating point numbers into binary or hex.

I used unpack() with the “J*” setting. Each number returned is 8 bytes long.

I would like to be able to split it in the middle.

If anybody has any advice on how I can achieve this I will be forever thankful.

EDIT: I am trying to concat the two long strings into one (hash/ciphertext/aad) so I can do Polynomial multiplication so I can generate a hash for users with PHP versions less than 7.1.

PHP 7.1 and greater’s openssl_encypt() has support for the tags. The versions less than 7.1 don’t.

It’s been a pain due to PHP’s limitations regarding binary data. All implementations of GCM/CCM require data converted to a 128-bit number and the only number that can be 128-bits is a float number.

The implementations I found are too complex when all I want to do is find a way to get GCM/CCM working with PHP versions less than 7.1.

Additionally, you can’t even use openssl to encrypt GCM data if less than 7.1 because it does not provide a way to validate the tag.

PHP examples do NOT tell you this.

Hope this helps.

Send Elementor Form via Webhook to n8n with Hidden Email Field

I need help configuring an Elementor form to send data via webhook to n8n. I want to include two fields: the user’s email (automatically captured since they’ll be logged in) and a YouTube link manually entered by the user.

My goal is to hide the email field in the form and auto-fill it with the logged-in user’s data, as the form will only be available after login.

How can I set this up efficiently in Elementor and ensure the information is correctly sent to my n8n workflow?

How to add file to localhost from another computer

I have a XAMPP-hosted MySQL database on one computer, and I can access it on this computer using the other computer’s IP address. There’s a couple of php files that I can use to interact with the database, and they work fine on this computer. However, in the same directory as those php files (xampp/htdocs/demo/) I want to add another php file, but I want to build it on this computer. There’s tons of stuff out there on accessing localhost on another computer (which I can do no problem) but not much on modifying the localhost directory from another computer.

So, is either of these two things possible:

  1. Actually adding a php file to the localhost directory from this computer (ideal) OR

  2. Creating a php file on this computer (not on localhost) that can still access and modify my database.

?

Thanks! (and let me know if you need more information.)

WordPress suppressing script tags [duplicate]

How do i include a js file in wordpress with the base plan?

I tried inserting an html block but it does remove the script tags, how do i fix this?

I am unable to reach the html files i can only use the wizard editor from wp-admin as i have the basic plan on it.

See the imageenter image description here

Why is my async function not returning expected data in Node.js?

I’m working in Node.js and trying to fetch data from an API using async/await. Here’s a simplified version of my code:

async function fetchData() {
  const res = await fetch('https://api.example.com/data');
  const data = await res.json();
  return data;
}

const result = fetchData();
console.log(result); // Promise { <pending> }
  • I tried using await in different places.
  • I tried wrapping the call in another async function.
  • I expected console.log(result) to print the actual data from the API, not a Promise.

How can I fix this to get the actual result?

Trying to move the rectangle with arrow keys

Well, I’m trying to make a game wherein the rectangle would be able to move left and right. I’ve tried this eventListener but nothing is happening with the rectangle. It’s just there at the middle of my border even if I’m trying to press the arrow keys.

Here is the code:

<!DOCTYPE html>
<html>
    <head>
        <title> Ichi's Game </title>
        <link rel="stylesheet" href="/main.css">
    </head>

    <body>
        <h1> this is the game </h1>
        <canvas style="border-style:dashed" width="1000" height="500" id="game"></canvas>

        <script>
            const game = document.getElementById("game");
            const context = game.getContext("2d");

            const rectWidth = "50";
            const rectHeight = "50";
            const x = (game.width - rectWidth) / 2;
            const y = game.height - rectHeight;

            function drawRectangle() {
                context.clearRect(0, 0, game.width, game.height); //Clearing the canvas
                context.fillStyle = "blue"; 
                context.fillRect(x, y, rectWidth, rectHeight);
            }


            document.addEventListener("keydown", (event) => {
                const speed = 20;

                if(event.key === "ArrowLeft" && x > 0){
                    x -= speed;
                }
                if(event.key === "ArrowRight" && x + rectWidth < game.width) {
                    x += speed;
                }
                drawRectangle();
            })
            drawRectangle();


            
        </script>
    </body>

</html>

I’ve tried adding an up and down function but nothing happened also. I’ve also tried to change the speed but it didn’t do anything for the rectangle.

Preparing for My Career Change into Software Development [closed]

I’m excited to share that I’m making a career shift into a field I’ve always been passionate about—the world of computers. Starting this Fall 2025, I’ll be studying Software Development.

This will be an entirely new path for me, but as someone who’s naturally creative and full of ideas, I believe I’ll truly enjoy this journey. I’d love to hear any advice you might have to help me prepare and hit the ground running this fall.

Thanks in advance!

How can I find a user-submitted audio file from an html page using python?

I am very new to programming in html and want to be able to access an audio file submitted by a user on the html page and use python in order to extract the audio information. I want the file given by the user, a variable value for frame rate which i will store in the html, and then to run the python file when it’s found it. I want to attach the python file to this html page as a script element.

I’ve already made the part that extracts the audio, i just need to know how to get the audio file and the variable value, and then run it.

Embedded links not clickable inside PDF for iOS devices

I have a SPFx React application where I am using the default window.print() functionality of browser to print the application pages when the user interacts with the Print Pages button.

Once the print window opens with the necessary pages, I save it as a pdf in my local folder. The pages contain embedded links(a tags with href) along with other content, but the links are not clickable in the PDFs only for iPad and iPhone, however the same links are clickable when the pdf is saved via desktop or any android device.

Any insights on this issue would be helpful. Thanks!!!

For the same html structure that is printed and saved as pdf, the links are clickable in desktop and android devices, but not in iOS devices when the application’s print functionality is done from iOS devices and the file is saved as a pdf.

The links should be clickable across all platforms.

Obsidian plugin: How to suppress editor actions (like Enter inserting newline) in custom input mode?

I’m writing an Obsidian plugin that activates a custom “find mode”. While in this mode, I listen to keydown events at the document level, and I want to capture keys like Enter, Escape, Backspace, and all character input without those keys triggering their default behavior in the editor. I call evt.preventDefault() and evt.stopPropagation() inside my handler. However, when I press Enter in find mode, the editor still inserts a newline, even though I call evt.preventDefault().

this.registerDomEvent(document, "keydown", (evt: KeyboardEvent) => {
            if (this.findMode) {
                if (evt.key === "Escape") {
                    this.exitFindMode();
                    evt.preventDefault();
                } else if (evt.key === "Enter") {
                    this.findAndHighlightInCurrentLine();
                    evt.preventDefault();
                    evt.stopPropagation();
                    evt.stopImmediatePropagation();
                } else if (evt.key === "Backspace") {
                    if (this.searchBuffer.length > 0) {
                        this.searchBuffer = this.searchBuffer.substring(
                            0,
                            this.searchBuffer.length - 1
                        );
                        this.updateStatusBar();
                    }
                    evt.preventDefault();
                } else if (
                    !evt.ctrlKey &&
                    !evt.altKey &&
                    !evt.metaKey &&
                    evt.key.length === 1
                ) {
                    this.searchBuffer += evt.key;
                    this.updateStatusBar();
                    evt.preventDefault();
                }
            }
        });

Jest.mock(‘fs’) breaks importing of xml2json package

I’m getting the following error in one of my tests

 FAIL  src/__tests__/xml.spec.mjs
  ● Test suite failed to run

    Could not locate the bindings file. Tried:
     → node_modules/node-expat/lib/build/node_expat.node
     → node_modules/node-expat/lib/build/Debug/node_expat.node
     → node_modules/node-expat/lib/build/Release/node_expat.node
     → node_modules/node-expat/lib/out/Debug/node_expat.node
     → node_modules/node-expat/lib/Debug/node_expat.node
     → node_modules/node-expat/lib/out/Release/node_expat.node
     → node_modules/node-expat/lib/Release/node_expat.node
     → node_modules/node-expat/lib/build/default/node_expat.node
     → node_modules/node-expat/lib/compiled/18.17.1/darwin/arm64/node_expat.node
     → node_modules/node-expat/lib/addon-build/release/install-root/node_expat.node
     → node_modules/node-expat/lib/addon-build/debug/install-root/node_expat.node
     → node_modules/node-expat/lib/addon-build/default/install-root/node_expat.node
     → node_modules/node-expat/lib/lib/binding/node-v108-darwin-arm64/node_expat.node

      1 | import fs from 'fs';
    > 2 | import xml2json from 'xml2json';
        | ^
      3 |
      4 | export const read = (file) => {
      5 |   const xmlText = fs.readFileSync(file, 'utf8');

      at bindings (node_modules/bindings/bindings.js:126:9)
      at Object.<anonymous> (node_modules/node-expat/lib/node-expat.js:4:34)
      at Object.<anonymous> (node_modules/xml2json/lib/xml2json.js:1:115)
      at Object.<anonymous> (node_modules/xml2json/lib/index.js:3:18)
      at Object.<anonymous> (node_modules/xml2json/index.js:1:120)
      at Object.<anonymous> (src/xml.mjs:2:1)
      at Object.<anonymous> (src/__tests__/xml.spec.mjs:2:1)

The test file looks like:

import fs from 'fs';
import { read } from '../xml.mjs';

jest.mock('fs');

describe('read', () => {
  it('reads', () => {
    fs.readFileSync.mockReturnValue('<xml><tag>a</tag></xml>');
    expect(read('someFile')).toBe('{tag:a}');
  });
});

and the actual run looks like

import fs from 'fs';
import xml2json from 'xml2json';

export const read = (file) => {
  const xmlText = fs.readFileSync(file, 'utf8');
  return xml2json.toJson(xmlText);
};

I can’t see the cause of why this might be happening or how to fix it (easily). Any suggestions on what I can do to solve this issue?

Handling window.open() from a

What is the current recommended way to handle window.open() or a click on a link with target=_blank from inside a <webview>? I would like to capture the URL that a Document tried to open but prevent the default behaviour (where allowpopups is enabled).

It appears at some point there was a new-window event dispatched on the webview element, but have I understood correctly that this is deprecated?

WebContentsView is not an option for my use case.

sticky headers in virtualized list/table

i have virtualized list, in which i display elements in absolute position. And i want to display sticky headers (optionally) at left/top/right/bottom. It works almost correct but during scrolling there is delay between elements in headers and in table.

<div
      ref={scrollRef}
      style={{
        width,
        height,
        overflow: "auto",
        position: "relative",
        scrollBehavior: "smooth",
        willChange: "transform",
      }}
      onScroll={(e) => handleScroll(e)}
    >
      <StickyHeaders
        headers={headers}
        rowHeights={rowHeights}
        columnWidths={columnWidths}
        visibleRows={elementVisibilityRows.visible}
        visibleColumns={elementVisibilityCols.visible}
        height={height}
        width={width}
        scrollLeft={scrollLeft}
        scrollTop={scrollTop}
        scrollbarSize={scrollbarSize}
      />

      <div style={contentStyle}>
        {AbsoluteElementComponent ? (
          <AbsoluteElementComponent
            currentLeftOffset={scrollLeft}
            currentTopOffset={scrollTop}
            getElementLeftOffset={(index: number) => {
              const offset =
                typeof columnWidths === "number"
                  ? columnWidths * index
                  : elementVisibilityCols.sizesOffsetOfIndice[index];
              return offset;
            }}
            getElementTopOffset={(index: number) => {
              const offset =
                typeof rowHeights === "number"
                  ? rowHeights * index
                  : elementVisibilityRows.sizesOffsetOfIndice[index];
              return offset;
            }}
            offsetVersion={offsetVersion}
          />
        ) : null}
        {WrapperComponent ? (
          <WrapperComponent>
            <VirtualizedTableContent
              rowsOffsets={elementVisibilityRows.sizesOffsetOfIndice}
              columnsOffsets={elementVisibilityCols.sizesOffsetOfIndice}
              rowHeights={rowHeights}
              columnWidths={columnWidths}
              visibleRows={elementVisibilityRows.visible}
              visibleColumns={elementVisibilityCols.visible}
              CellComponent={CellComponent}
              additionalData={additionalData}
              offsetVersion={offsetVersion}
            />
          </WrapperComponent>
        ) : (
          <VirtualizedTableContent
            rowHeights={rowHeights}
            rowsOffsets={elementVisibilityRows.sizesOffsetOfIndice}
            columnWidths={columnWidths}
            columnsOffsets={elementVisibilityCols.sizesOffsetOfIndice}
            visibleRows={elementVisibilityRows.visible}
            visibleColumns={elementVisibilityCols.visible}
            CellComponent={CellComponent}
            additionalData={additionalData}
            offsetVersion={offsetVersion}
          />
        )}
      </div>
    </div>

Sticky Headers Component.

<div
      style={{
        position: "sticky",
        top: 0,
        left: 0,
        zIndex: 10,
        background: "white",
        display: "flex",
        flexDirection: "row",
        animation: "500ms ease-in-out 0s normal none 1 running fadeInDown"
      }}
      
    >
      <div style={{ position: "relative", height: "100%", width: "100%" }}>
        {headers.top ? (
          <TopHeaderSection
            header={headers.top}
            columnWidths={columnWidths}
            visibleColumns={visibleColumns}
            scrollLeft={scrollLeft}
            leftOffset={headers.left?.size ?? 0}
            headers={headers}
            rowHeights={rowHeights}
          />
        ) : null}

        etc
      </div>
    </div>

Top Header

<div
          style={{
            position: "absolute",
            top: 0,
            zIndex: 10,
            background: "white",
            display: "flex",
            flexDirection: "row",
            left: 0,
            
          }}
        >
          <div style={{ position: "relative", marginLeft: headers.left?.size }}>
            {Array.from(
              {
                length:
                  visibleColumns.lastVisible - visibleColumns.firstVisible + 1,
              },
              (_, colIdx) => {
                const columnIndex = visibleColumns.firstVisible + colIdx;
                const style = getHeaderStyle({
                  indexPosition: columnIndex,
                  direction: "top",
                  rowHeights,
                  columnWidths,
                  size,
                });
                style.left -= scrollLeft;
                return (
                  <header.component
                    key={`top-${columnIndex}`}
                    columnIndex={columnIndex}
                    style={style}
                  />
                );
              }
            )}
          </div>
        </div>
      ) : (
        <div
          style={{
            height: header.size,
            position: "absolute",
            top: 0,
            left: 0,
            right: 0,
          }}
        >
          <header.component
            position={{left: scrollLeft, top: 0}}
            visibleRows={{ firstVisible: 0, lastVisible: 0 }} // optional, no rows for top
            visibleColumns={visibleColumns}
          />
        </div>

i tried to use translate directly on sticky element, and effect is the same. Is it possible to achive what i want. And from where does delay comes from. As i read onScroll event happens before paint, so it seems like it would be possible to synchronize this elements, and you can synchronize two scrolls normally.

How to register a boolean type when compiling TypeScript bindings with Emscripten?

I have some Emscripten binding code (a self-contained, trivial example of which is shown below) that converts my C++ status_t return-value class into a boolean that JavaScript code can deal with efficiently. (i.e. a status_t representing an error condition is converted to JavaScript-false, while a status_t representing success is converted to JavaScript-true)

This works great when compiling the code to JavaScript, but when I try to compile the code to TypeScript (using emscripten’s --emit-tsd option, it errors out with the error Error: Missing primitive type to TS type for 'status_t'.

Is there some way to make this work when generating TypeScript bindings, in a way that is similar to how it works for JavaScript bindings, or am I just out of luck here?

// Works great to generate JavaScript bindings:
// emcc  -lembind -sEXPORTED_RUNTIME_METHODS=ccall,cwrap -sWASM_BIGINT -sMODULARIZE=1 -sEXPORT_ES6=1 -sEXPORT_NAME="CPPBindings" -sENVIRONMENT=web -lembind -std=c++17 typescript_status_t_binding_problem.cpp -o output_bindings.js

// Doesn't work to generate TypeScript bindings ("Error: Missing primitive type to TS type for 'status_t'")
// emcc  -lembind -sEXPORTED_RUNTIME_METHODS=ccall,cwrap -sWASM_BIGINT -sMODULARIZE=1 -sEXPORT_ES6=1 -sEXPORT_NAME="CPPBindings" -sENVIRONMENT=web -lembind -std=c++17 typescript_status_t_binding_problem.cpp --emit-tsd output_bindings.d.ts

#include <emscripten/bind.h>
#include <emscripten/wire.h>

using namespace emscripten;

class status_t
{
public:
   status_t() : _errStr(NULL) {/* empty */}
   status_t(const char * errStr) : _errStr(errStr) {/* empty */}

   bool IsOK()    const {return (_errStr == NULL);}
   bool IsError() const {return (_errStr != NULL);}

   const char * GetErrorString() const {return _errStr;}

private:
   const char * _errStr;
};

// Tell embind how to convert status_t <-> JavaScript bool
template <> struct internal::BindingType<status_t>
{
    using WireType = bool;
    static WireType toWireType(status_t s, rvp::default_tag)
    {
       if (s.IsOK()) return true;
                else return false;
    }
    static status_t fromWireType(WireType v) {return v ? status_t() : status_t("Error");}
};
EMSCRIPTEN_BINDINGS(status_t)
{
   internal::_embind_register_bool(internal::TypeID<status_t>::get(), "status_t", true, false);
}

class SomeExampleClass
{
public:
   SomeExampleClass() {/* empty */}

   status_t DoSomething() {return status_t();}
   status_t EpicFail() {return status_t("epic fail!");}
};

EMSCRIPTEN_BINDINGS(SomeExampleClass)
{
   class_<SomeExampleClass>("SomeExampleClass")
      .constructor<>()
      .function("DoSomething", &SomeExampleClass::DoSomething)
      .function("EpicFail",    &SomeExampleClass::EpicFail);
}