Making a regexp to retrieve href/src of html tags

Im trying to get the href from links and src from script tags.
Since it’s my first time using regex, im isuing quite not enough understand on how groups, negation and conditional selection works.

This is what i’ve got so far

(/|./)((^([http|https]://))*.*?w+)([a-zA-Z]w+)(?=.(js|css|ts)b)(.*?w+)

Working in this cases:

<script src="./script.js"/>
<script src="/script.js"/>
<script src="/my/custom/dir/script.js"/>
<!--Theme same for links-->

Non functioning cases:

<script src="https://my.cdn.fav/script.js"/>
<script src="http://my.cdn.fav/script.js"/>

Or well it does consider the starting http and https but doesnt select them.
It’s this part that is doing something wrong (/|./)((^([http|https]://))

Issue with Fetch Request in a TypeScript react app

I am developing a react app and encountering an issue with a fetch request in my TypeScript file. The app is supposed to send a POST request to a Flask server running on localhost:5000. However, when I include the fetch request within a try-catch block inside a method of a class, the extension’s webpage fails to render any elements, and there are no errors logged in the console.

Here is the relevant code snippet, showing the location of the method within the class:



import fetch from 'node-fetch';

class InfoProvider implements Disposable {
  // Other class properties and methods...

  private async sendProofState(proofState: string) {
    try {
      const response = await fetch('http://localhost:5000/api/generate_tactics', {
        method: 'POST',
        headers: {
          'Content-Type': 'application/json'
        },
        body: JSON.stringify({ proof_state: proofState })
      });
      const data = await response.json();
      console.log("Response from Flask server:", data);
    } catch (error) {
      console.error("Error sending data to Flask server:", error);
    }
  }
//other methods
}

The issue seems to be specifically related to the fetch request, as commenting out this block allows the webpage to render correctly. I have confirmed that CORS is enabled on the server, and the server is running without issues.I even commented the line where the function is called and the issue persisted.

I need your advice to build a career as a Full-stack Ruby on Rails developer [closed]

What do you guys thing about becoming a Full-stack Ruby on Rails developer? Do Ruby on Rails worth it?

I need your advice, please?

Because I really like ruby on rails and I am thinking about specialize only in using it to build my career as a professional software engineer.

Please, give me you advice!

And where do you think I can start or do next, considering I have a little experience in Ruby and Ruby on Rails also.

I read a lot of article to make a choice.

HTML button not clickable despite adding onclick listener

I’ve created a “+” button to send text from an input field to my Firebase database. However, the result is not showing up in that database, and the “+” button is not clickable 🙁 Please take a look at my code below.

index.html:

<!doctype html>
<html>
    <head>
        <title>Reel Time</title>
        <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=Inter:wght@300&family=Ultra&display=swap" rel="stylesheet">
        <link rel="stylesheet" href="index.css">
    </head>
    <body>
        <div class="container">
            <h1>Reel Time</h1>
            <div class="field">
                <input type="text" id="input-field" placeholder="Pulp Fiction">
                <button id="add-button">+</button>
            </div>
        </div>
        <script src="functions.js" type="module"></script>
        <script src="index.js" type="module"></script>
    </body>
</html>

index.js:

import { initializeApp } from "https://www.gstatic.com/firebasejs/9.15.0/firebase-app.js"
import { getDatabase, ref, push } from "https://www.gstatic.com/firebasejs/9.15.0/firebase-database.js"

const appSettings = {
    databaseURL: "https://playground-91206-default-rtdb.asia-southeast1.firebasedatabase.app/"
}

const app = initializeApp(appSettings)
const database = getDatabase(app)
const moviesInDB = ref(database, "movies")

const inputFieldEl = document.getElementById("input-field")
const addButtonEl = document.getElementById("add-button")

addButtonEl.addEventListener("click", function() {
    let inputValue = inputFieldEl.value
    
    push(moviesInDB, inputValue)
    
    console.log(`${inputValue} added to database`)
})

functions.js:

export function add(a,b) {
   return a + b
}

Please advise 🙂

Getting a button to interact with an input to land in console

Using an html file i have created a and and I’m trying get the them to interact using a separate java script file.
I am using the console.log to check if my input is being received and pushed to the console by the button.

This is the body of the HTML file.

const myInput = document.getElementById("myInput");

function guess(myInput) {
  console.log(myInput);
}

myInput.addEventListener("click", document.getElementById("myInput"))
<h1 id="random">Random Number guesser</h1>
<h2>Guess a number below between 1 - 100.</h2>
<div>
  <button id="button" onclick="guess()">Guess!</button>
  <input id="myInput" type="text">
</div>`your text`
<script src="config.js"></script>

html2canvas , unable to output inner html and div as png

Basically i’m trying to output html to png using html2canvas. A button called Download PNG will trigger an action to capture all the elements inside div class e-con-inner. However the output png is blank and unable to print inner html elements and images. i’ve tried printing throuhg div class as well as css id. When the button was kept inside div e-con-inner it did however printed the button but no inner elements.

  <button onclick="downloadAllElementsAsPNG()">DOWNLOAD PNG</button>

<script src="https://cdnjs.cloudflare.com/ajax/libs/html2canvas/1.3.3/html2canvas.min.js"></script>
<script>
function downloadAllElementsAsPNG() {
  const eConInner = document.querySelector('.e-con-inner');
  const canvas = document.createElement('canvas');
  const context = canvas.getContext('2d');
  const scale = 2; // Increase this value for higher resolution

  canvas.width = eConInner.clientWidth * scale;
  canvas.height = eConInner.clientHeight * scale;

  const options = {
    scale: scale,
    canvas: canvas,
    logging: false,
    width: eConInner.clientWidth,
    height: eConInner.clientHeight,
    scrollY: -window.scrollY, // Capture entire content
  };

  html2canvas(eConInner, options).then((canvas) => {
    const link = document.createElement('a');
    link.href = canvas.toDataURL('image/png');
    link.download = 'e-con-inner.png';
    link.click();
  });
}
</script>

ERROR SyntaxError: Invalid RegExp: Invalid escape, js engine: hermes i am using marked to convert markdown to html

i want to convert markdown to html and none of the packages seems to be working. i am buidling an app in react native

i tried react-markdown, marked, react-native-htmlview none of them worked, ERROR TypeError: Cannot read property ‘marked’ of undefined

This error is located at:
in ArticlePage (created by SceneView)
in StaticContainer
in EnsureSingleNavigator (created by SceneView)
in SceneView (created by SceneView)
in RCTView (createdby

Package typescript

The current file is a CommonJS module whose imports will await produce ‘require’ calls; however, the referenced file is an ECMAScript module and cannot be imported with ‘require’. Consider writing a dynamic ‘import(“inquirer”)’ call instead. To convert this file to an ECMAScript module, change its file extension to ‘.mts’, or add the field `”type”: “module”” to ‘d:/IT Project/Simple-Calculator/package.json’.ts(1479)

module

Import inquirer run

req.body return ReadableStream in my route NextJS

I dont get it what is wrong of my code. I read and try other question like that but they didnt helped my

Is there any one who can help me ?

This is my route.js

import dbConnect from "@/lib/dbConnect";
import User from "@/models/User";
import { NextResponse, NextRequest } from "next/server";
import type { NextApiResponse, NextApiRequest } from "next";

export async function POST(req: NextApiRequest) {
  await dbConnect();
  let data = await req.body;
  console.log(data); //HERE ReadableStream { locked: false, state: 'readable', supportsBYOB: false } HERE

  try {
    const user = await new User(data);
    await user.save();

    return NextResponse.json({ user }, { status: 201 });
  } catch (error) {
    console.log("here 3");
    if (error instanceof Error) {
      return NextResponse.json(
        { error: error.message || "bilinmeyen bir hata" },
        { status: 500 }
      );
    } else {
      return NextResponse.json(
        { error: "bilinmeyen bir hata" },
        { status: 500 }
      );
    }
  }
}

This is my request;

try {
      const res = await fetch("http://localhost:3000/api/register", {
        method: "POST",
        headers: { "Content-Type": "application/json" },
        body: JSON.stringify(data),
      });

      const dataRes = await res.json();
      console.log("dataRes" + dataRes);
    } catch (error) {
      console.log(error);
    }

Why RecatJS do not update value when it changes

I`m learning React and I do not understand – why in first render React generate correctly value playerSymbol, but when It changes it is not re-render even when gameBoard changes. Code:

import { useState } from "react";

const initialGameBoard = [
 [null, null, null],
 [null, null, null],
 [null, null, null],
];

export default function GameBoard() {
  const [gameBoard, setGameBoard] = useState(initialGameBoard);

  function handleSelectedSqare(rowIndex, colIndex) {
    console.log("aaaa");
    setGameBoard((prevGameBoard) => {
      const updatedBoard = [
        ...prevGameBoard.map((innerArray) => [...innerArray]),
      ];
      console.log(updatedBoard);
      updatedBoard[rowIndex][colIndex] = "X";
      return updatedBoard;
    });
  }

  return (
    <ol id="game-board">
      {initialGameBoard.map((row, rowIndex) => (
        <li key={rowIndex}>
          <ol>
            {row.map((playerSymbol, colIndex) => (
              <li key={colIndex}>
                <button onClick={() => handleSelectedSqare(rowIndex, colIndex)}>
                  {playerSymbol}
                </button>
              </li>
            ))}
          </ol>
        </li>
      ))}
    </ol>
  );
}

Any idea guys?

nextjs 13, 14 App Directory language without i18n – internalization

Question: Is there a way to do multi-language without i18n since it’s a 2 pages website…

The context

The root layout has the language detection:

1- Using a context that record french if french or else is english.

<script async dangerouslySetInnerHTML={{ __html:(function () {
function setTheme(newTheme) {
window.__theme = newTheme;
window.__onThemeChange(newTheme);
}
// this will be overwritten in our React component
window.__onThemeChange = function () {};

              // this will be triggered by our React component
              window.__setPreferredTheme = function (newTheme) {
                setTheme(newTheme);
                try {
                  localStorage.setItem("lang", JSON.stringify(window.__theme));
                } catch (err) {}
              };

              // detect system theme and monitor for changes
              var darkQuery = navigator.languages ? navigator.languages[0] : (navigator.language || navigator.userLanguage)
              darkQuery = darkQuery.split('-')[0];

              var preferredTheme;
              // try to get saved theme
              try {
                preferredTheme = JSON.parse(localStorage.getItem("lang"));
              } catch (err) {}  
              // initialize preferredTheme
              setTheme(preferredTheme || darkQuery);
            })();`
          }}
        />

`

The goal is to use the contect “en” or “fr” to render the correct json caracter. At the moment I am stuck at the json part.

How to know the action sent to server by a button on a webpage? do you use a chrome addon for that?

how do you process to know the action sent to the server by this ‘Delete’ button on a webpage? do you use a special Chrome addon?


<div _ngcontent-geev-pwa-ssr-c1357586839="" class="modal-footer glob-font-body-bold">
  <button _ngcontent-geev-pwa-ssr-c1357586839="" type="button" class="modal-footer-cancel">Dismiss</button>
 ** <button _ngcontent-geev-pwa-ssr-c1357586839="" type="button" class="modal-footer-validate"> Delete </button>**
</div>

Screenshot

I have used Chrome built-in inspect tool, but this does not provide me any info about the action being actually requested to the web server, what else can I do to find it?

TypeError: Cannot read properties of undefined (reading ‘roles’) discord.js,, tried so much nothing worked [closed]

const Discord = require('discord.js');
      const client = new Discord.Client({
        intents: [
          Discord.GatewayIntentBits.Guilds,
          Discord.GatewayIntentBits.GuildMembers
        ]
      });
        // Get the guild (server) and role objects
        const guild = client.guilds.cache.get(`${js.guildId}`);
        const role = client.guild.roles.cache.find(role => role.name === `${roleName}`);

        // Get the member object
        const member = guild.members.cache.get(`${js.clientId}`);

        // Add the role to the member
        member.roles.add(role).catch(console.error);

this code give me this error, TypeError: Cannot read properties of undefined (reading ‘roles’).
What i can do?

i tried searching for answer but i didnt get anythibg

POST REQUEST BY NEXT JS 14

how to make POST REQUEST by next js 14 using axios or fetch but i prefer axios,
i try but alway show to me AxiosError: NewWorkError when try fetch show to me typeError: fetch faild

but it success with postman

i want sent request to http://localhost:3001/CreateUser

`
const POST = () => {

const PostRequest = async () => {
    try {
        const response await axios.post("http://localhost:3001/CreateUser", {
        nameOfUser: "mostafa",
        ageOfUser: 22,
        phoneNumber: 201003443454,
        EmailOfUser: "[email protected]",
      })
   } catch(error) {
       console.log(error.message);
   }
}

return <button onClick={() => PostRequest()}>POST</button>

}

export default POST;
`

i research in youtube and ask chat gpt and copilot and try by my self