Is It Possible To Construct V8 In Mixed Precision

When you do mixed precision calculations, you can adopt intermediate calculating result for a 2(or3)-time mixed precision at the same time. If it has a logic graph like this, can you adopt a JavaScript v8 data management into multiple intermediate mixed-precision calculations,hence making much more calculating power than before?

There are direct connect, turnaround reconnect and turnaround connect at the same time. Are these logic fulfill the requirement of making a v8 just like how JavaScript v8 did for making more calculating power?

What does it mean when there are two character classes next to each other in a regular expression?

I am trying to figure out a solution I found to an algorithm problem (this is one of the correct solutions for the problem on Codewars), but it uses a regular expression I’m not sure the meaning of.

The problem specified to match only words, including those with apostrophes at the beginning, middle, or end of the word, so I think that’s what this regex is supposed to do. I’m just unsure of what the two sets of square brackets next to each other here are supposed to be doing:

Here it is: /([A-Za-z][A-Za-z']*)/g

I am new to regular expressions, but I think I get the general gist of this one. I just have never seen the square bracket sets used like this before and couldn’t find other examples of this (instead of [[]]).

I tried to figure this out by putting in regexr.com, removing different parts of the entire expression to see what matches change, but it was even more confusing. Maybe it’s made up by that person and not a conventional use of character classes, but I still am not sure what it’s trying to do because in regexr, /([A-Za-z']*)/g seems to work just fine.

Edit:
Sorry, I also thought of another question looking at this, what is the purpose of the parentheses here? Taking them off in regexr gave me the same result, I think.

Second edit:
I noticed now that on regexr.com there is a “WARNING” button that said “The expression can return empty matches, and may match infinitely in some use cases” when I put in /([A-Za-z']*)/g. I’m not sure what this means at all.

On highlight an external file page load seems to fail

Trying to highlight an external file main.cpp with highlight.js I put together the following:

<!DOCTYPE html>
<html>
<head>

    <link rel="stylesheet" 
          href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/default.min.css">

    <title>My Node.js Server</title>
</head>
<body>
    <h1>Hello from Node.js!</h1>

    <pre><code class="cpp" id="codeContainer">int x = 5;</code></pre>

    <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js"></script>
<!-- and it's easy to individually load additional languages -->
<!-- <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/languages/cpp.min.js"></script> -->

<script>hljs.initHighlightingOnLoad();</script>

<script>
    document.write("casdca");
</script>

    <script>
        fetch('main.cpp')
            .then(response => response.text())
            .then(text => {
                const codeContainer = document.getElementById('codeContainer');
                codeContainer.textContent = text; 
                hljs.highlightElement(codeContainer);
            });
        hljs.initHighlightingOnLoad();
    </script>

</body>
</html>

However it seems page loading is failing, since I see the actual index.html source code in the browser.

Comment on codeContainer.textContent = text; and following lines depending on it cause the page to load, but not presenting main.cpp obviously.

All this is being loaded by

node node.js

which is

const http = require('http');
const fs = require('fs');
const path = require('path');

const server = http.createServer((req, res) => {
    fs.readFile(path.join(__dirname, 'index.html'), (err, data) => {
        if (err) {
            res.writeHead(500);
            res.end("Error loading the page");
        } else {
            res.writeHead(200, { 'Content-Type': 'text/html' });
            res.end(data);
        }
    });
});

const PORT = 3000;
server.listen(PORT, () => {
    console.log(`Server running at http://localhost:${PORT}/`);
});

Wondering what I’m missing. Appreciate if one can give me some directions.

Using .each() in Object Literal Pattern with this

I’m currently learning about the Object Literal pattern and I’m struggling with using this especially in my use case with .each().

This is what I have.

var myObject = {
  
    el: {
      divs: document.querySelectorAll(".mydiv")
    },
 
    init: function() {
      this.allDivs();
    },
   
    allDivs: function() {
      this.el.divs.each(this.backGround);
    },
        
    backGround: function() {
      this.css("background", "red");
    }
};
 
myObject.init();

I want to change the background to red for each div with the class .mydiv. I see that I’m using this wrong and maybe also .each() but I’m not sure what I’m looking for here and would appreciate any help.

How can i display the number of rows, in Javascript, using a div with contenteditable=”true” instead of a textarea? Rows are not counted

I’m having trouble switching from using a <textarea> to a div with contenteditable=”true”. I created a vertical column in which all the numbers of the rows corresponding to a text editor are counted. Previously the row numbers were connected to a <textarea>, so I was able to correctly get what I wanted (e.g. like this code).

enter image description here

MY PROBLEM. Now, for several technical reasons, i had to give up the <textarea> and use a new div with contenteditable=”true”, then i removed the <textarea>, but using partly almost the same code. The problem now is that, since i no longer have <textarea>, i can’t count the rows of the new div with contenteditable. My Javascript code was set to run on a <textarea>. Now i would like to modify it to make the same code work even on a div.

Currently (with the snippet code) I get this:

enter image description here


MY ATTEMPTS AT A SOLUTION

I think my Javascript code (which uses 2 different ways) is good enough and maybe just needs a few changes, but i can’t link it with new div. Now i would like to modify it to make the same code work even on a div, so i changed the query selector from textarea to .hilite-editor, converting the query selector to to grab:

BEFORE: const textarea = document.querySelector("textarea");

NOW: textarea = document.querySelector(".hilite-editor")

Considering that textarea is a form field and div is an html element, i modified it so that i don’t access its contents via value, but by accessing it with Html

BEFORE: const num = textarea.value.split("n").length;

NOW: const num = textarea.innerHTML.split("n").length;

I also tried replacing textarea.value.substring with textarea.innerHTML.substring.

But despite these changes, it still doesn’t work.Sorry, I’m new to Javascript and still learning. How can I display the line numbers of the div (and no longer of the textarea)? I would like to get this:

enter image description here

Complete code

const textarea = document.querySelector("textarea");
const numbers = document.querySelector(".numbers");

//VIEW DIRECTLY (WITHOUT PRESSING A BUTTON)
function updateLineNumbers() {
  const num = textarea.value.split("n").length;
  numbers.innerHTML = Array(num).fill("<span></span>").join("");
}

// Update line numbers when the page loads
updateLineNumbers();

// Update line numbers when the textarea content changes
textarea.addEventListener("input", updateLineNumbers);

/////////////////////////////////////////////////////////////////

// WHEN I PRESS KEY
textarea.addEventListener("keydown", (event) => {
  if (event.key === "Tab") {
    const start = textarea.selectionStart;
    const end = textarea.selectionEnd;

    textarea.value =
      textarea.value.substring(0, start) +
      "t" +
      textarea.value.substring(end);

    event.preventDefault();
  }
});
/* EDITOR CODE */
/* Scrollbars */
::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}

::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.1);
  border-radius: 0px;
}

::-webkit-scrollbar-thumb {
  background-color: rgba(255, 255, 255, 0.3);
  border-radius: 1rem;
}


.hilite {
position: relative;
background: #1e1e1e;
height: 120px;
overflow: auto;
width: 100%;
height: 100%;
}

.hilite-colors code,
.hilite-editor {
padding: 1rem !important;
top: 0;
left: 0;
right: 0;
bottom: 0;
white-space: pre-wrap;
font: 13px/1.4 monospace;
width: 100%;
background: transparent;
border: 0;
outline: 0;
}

/* THE OVERLAYING CONTENTEDITABLE WITH TRANSPARENT TEXT */
.hilite-editor {
display: inline-block;
position: relative;
color: white;
caret-color: hsl( 50, 75%, 70%); /* But keep caret visible */
width: 100%;
}
.hilite-editor:focus {
outline: transparent;
}
.hilite-editor::selection {
background: hsla(0, 100%, 75%, 0.2);
}

/* THE UNDERLAYING DIV WITH HIGHLIGHT COLORS */
.hilite-colors {
position: absolute;
user-select: none;
width: 100%;
}


/* COUNT NUMBER ROW */
.editor {
  display: inline-grid;
  grid-template-columns: 3em auto;
  gap: 10px;
  line-height: 21px;
  border-radius: 2px;
  overflow-y: auto;
  width: 100%;
}

.editor>* {
  padding-top: 10px;
  padding-bottom: 10px;
}

.numbers {
  text-align: right;
  background: #333;
  /* padding-right: 20px; */
  width: 35px;
  height: 200px;
  /* margin-right: 71px; */
}

.numbers span {
  counter-increment: linenumber;
}

.numbers span::before {
  content: counter(linenumber);
  display: block;
  color: #888;
}


/* Tabs */
.content {
    display: none;
    padding: 0;

}

.content--active {
    display: flex;
  height: 200px;
  width: 800px;
}

h1 {
    margin-bottom: 0.5em;
    font-weight: 700;
}

p {
    font-weight: 300;
}
              <div class="content content--active">


                <div class="numbers">
                  <span></span>
                </div>  

                <div class="hilite">
 
                  <pre class="hilite-colors"><code class="language-html"></code></pre>
                  <div
                    data-lang="html"
                    class="hilite-editor"
                    contenteditable="true"
                    spellcheck="false"
                    autocorrect="off"
                    autocapitalize="off"
                    >TEST 1
TEST 2
TEST 3
</div>
                </div>  
              </div>

How to convert ready-made paid Themeforest HTML template to NextJS app router compatible

Does anyone knows effective way to make HTML template (which has bunch of 3rd party js files and css files) compatible with new NextJS 14 App rounter?

I seen all tutorials, blogs and what not but all are for old page directory no one has mentioned for new app router.

I have added all css files using import in root layout.js and added all js files in page.js using <Script src="/app/js/xyz.js"/>

But still when i open the page in browser it shows hydration ui error in console log.

Note: I also changed p tag to div tag where there are more than one element inside p tag

I had converted the simple plain HTML to JSX using online html to jsx tool.

I put all the required files ( external css files and js files ) in the public folder and imported the css in the root layout.js file AND using nextjs’s Script tag i added all the required js files for example: <Script src = “/public/js/owl.music.player.js”

I was expecting that the HTML template now will be working with NextJS as well but sadly when i open the browser it shows only loading gif and bunch of console errors regarding jQuery and mainly an error of “Hydration ui”

How to maintain login authentication in vue3 + vuex + firebase?

Currently, the login is working fine, but when I refresh, the user information changes to null and then the user information is retrieved again. How do I solve this?
Please note that I do not want to use loading.

I retrieve user information from userStore like this.

const userStore = {
...
  actions: {
    initAuth({ commit }: any) {
      return new Promise((resolve) => {
        onAuthStateChanged(auth, (user) => {
          commit('setUser', user);

          resolve(user);
        });
      });
    },
  },
...
}

App.vue

const route = useRoute();
const store = useStore();
const user = ref(null);

onMounted(async () => {
  watchEffect(() => {
    const newUser = store.getters['userStore/getUser'];
    user.value = newUser;

    console.log(user.value);
  });

  if (user.value === null) {
    const storedUser = JSON.parse(localStorage.getItem('user') as any);

    if (storedUser) {
      user.value = storedUser;
    }
  }

  await store.dispatch('userStore/initAuth');
});

How do I fix it?

Issue in rendering .js file in springboot application

I am creating a springboot application. In templates folder I am keeping html files and in static folder I am keeping javascript files. But html files are not able to render javascript files. Please help me with correct files structure of both the files in springboot application also if I need to add anything in pom.xml or in application.properties file then please tell me.

I have created a registration form and put it inside the templates folder of springboot application. I have one app.js file inside the static folder of spring boot application which is helping in using an api to render the country, state and city as a dropdown list. When I am writing that script code directly inside the html file then it is working fine but when I am trying to import app.js file then it is not working.

Como usar o puppeteer e o angular juntos com o Electron? [closed]

Estou tentando fazer um projeto electron junto com o angular e o whatsapp-web.js, onde eu consiga abrir em uma view do electron um template angular junto com o a lib whatsapp-web.js que usa puppeteer. Procurando vi que a própria comunidade do whatsapp-web.js ja tinha conseguindo ultilizar essa lib com o electron, mas quero tentar encaixar isso com um projeto angular, onde o electron executasse minha build do meu projeto angular que é o index.html, e a lib wwebjs-electron executaria o puppeteer, em uma view junto com o tamplate angular, alguém consegue me ajudar?

const { app, BrowserWindow, BrowserView } = require('electron');
const puppeteer = require('puppeteer-core');
const pie = require('puppeteer-in-electron');
const { Client } = require('wwebjs-electron');

//minha variavel para abrir a janela do electron
let mainWindow;

//minha view
let view;

//inicializa a o lib 'puppeteer-in-electron'
async function initializePuppeteer() {
await pie.initialize(app);
}

async function createWindow() {

await initializePuppeteer();

await app.whenReady();

// cria minha janela
mainWindow = new BrowserWindow({
width: 1400,
height: 800,
webPreferences: {
nodeIntegration: true
}
});

//Cria minha view e insere na janela
view = new BrowserView();
mainWindow.setBrowserView(view);

//executa a lib wwebjs-electron
pie.connect(app, puppeteer).then((mainWindow) => {

    const client = new Client(mainWindow, view);
    
    client.on('ready', () => {
        console.log('Client is ready!');
    });
    
    client.on('message', msg => {
        if (msg.body == '!ping') {
            msg.reply('pong');
        }
    });
    
    client.initialize();

});

//carrega o arquivo index.html na minha janela
mainWindow.loadFile('dist/project-teste/index.html');

}

app.on('activate', () => {
if (BrowserWindow.getAllWindows().length === 0) {
createWindow();
}
});

createWindow();

MongoDB match all documents with $in if query is null

I have a query in MongoDB like so

collection.find(
    {$and:[
        {origin:{ $in: countries }}, {brand: {$in: brands}}
    ]}
).toArray();

If both the arrays countries and brands have some values, the query will correctly return documents that have both the specified country and brand. However, if one of these arrays is empty, the query will no longer work. How can I fix this? I want my users to be able to search only by country or only by brand, not always by both. I also have other parameters which should be searchable independently or combined with other parameters. How can I construct a query that will give me the desired output?

Failed to load main.js script from index.html leaves a blank site until refresh

The problem is described on the example of Vite / Rollup bundler + Vue app but it perfectly applies to any other modern web stack.

Vite adds a hash to each js chunk, asset, and as well as to the main.js file. It does this in order to let the client know that the file has been changed and it needs to download the new one. I then have a handler in my Vue app router that in case of an error loading dynamic module it will refresh the page and thus find out the new hashes & new files. The problem is if a hash of the main.js file is being changed the website doesn’t get to load the Vue router and doesn’t pass through this error handler. It gets stuck in a blank index.html document until a manual refresh of a website. Did anyone consider adding an error handler to the

<script type="module" src="/src/main.hash1.js"></script>

in the HTML file? My idea is:

<script type="module" src="/src/main.hash1.js" onerror="onMainScriptLoadingError"></script>

and inside of onMainScriptLoadingError putting a
window.location.reload();
depending on some value stored in localStorage. On one hand to reload the page and download the new index.html with new main.hash2.js to be able to load the new assets. On the other hand to avoid the infinite refresh loop (variable in localStorage with the date of the last forced refresh or something similar).

The only ‘solution’ I found on the internet is leaving the old main.hash1.js historic files but I don’t want to end up with 1000 main.js files on the server. I don’t want either to relate the CI/CD build to the previous build. Want to keep it separated & independent.

Any ideas? Does it all make sense? Why isn’t it considered in the official documentation of any bundler?

Unable to get innerhtml with JS

I have used visual basic and selenium to automate some tasks at work for a few years now and have very little experience with js. Right now, i am creating a browser extension for edge to copy some specific fields on the webpage and then paste those values onto another webpage. I can scrape these values using vba and selenium, but get no values using js.

This vba code does work to get the attribute I need.

Set elem = D.FindElementByCss("#MainContent_grdClassValues > tbody > tr:nth-child(2) > td:nth-child(2)")
   
txtstr = elem.Attribute("innerHTML")
        
MsgBox "" & txtstr & ""

This is the js code i tried and the extension debugger tells me it cannot read properties of null (reading ‘innerHTML’)

document.getElementById(‘copybtn’).addEventListener(‘click’, function (){
  let val = document.querySelector(#MainContent_grdClassValues > tbody > tr:nth-child(2) > td:nth-child(2)”).innerHTML();
  alert(val);
});

JS – WebAuthn – Support for uvm extension?

I’ve been wanting to detect whether a user uses a PIN instead of biometrics on my website that utilizes Webauthn, or even disable PIN altogether. I’ve read that this can only be done using the uvm extension. I’ve implemented it like this in the publicKeyCredentialCreationOptions, but I was not able to get it to work:

extensions: { uvm: true },

Why is this? Is it because no browsers/authenticators support the uvm extension? I thought at least Chrome and Edge supported it. And if not, why? Are there any workarounds to detect/disable PIN in webauthn?