Switching between SQL Quarries

I know this is not the typical question that StackOverflow should handle but I need people’s ideas for this.

I’m currently learning PHP for web development and I’m working with SQL and a bit of data from my company (Confidential and I’m unable to show it). I have 2 different quarries currently written and I want to use a switch or a button (don’t know which is better) to switch between the 2 quarries in the back to display different data on the screen.

What are the best ways of doing this? I would be very appreciative if someone can give me a few code snippets on how to do this.

Thanks

Stop VSCode adding “endregion” autocompletion when pressing “enter” key

I am editing JSX code in .js files, and since two days (i don’t know why), each time I press ENTER key in VS Code to add a new empty line, then VS Code display this:

This is what VS code do

If I press ENTER again, then VS Code add “//#endregion” in my code.

But the point is, I don’t want this, I just want to jump a line, I don’t want VS Code to write this for me.

Do you know why VS Code has this behavior now, and how I can avoid VS Code doing this ?

Thank you very much

Is there a method to update a data object from vue when the database updates?

I’m making a web app that allows users to create an account and then join a room. Inside the room they can click a button and essentially allows them to pick who they are gonna give a gift to randomly. The problem I’m having is how do I update a data object from vue if the database updates for all users. What I mean is if a another user joined a room, the new user has the updated data object but all the other users who came before him will have the outdated data object. So what I’m essentially asking is how would vue update a data object if the database updates.

And by data object I mean something like this

data() {
 return {
  room: { name: "room", users: [] }
 }
}

Does the update() lifecycle hook do that? or computed()?
And before anyone answers, remember I need it to update to ALL the users that joined the room.

I’m using vue2 since I’m using vuetify

Must use import to load ES Module while updating angular

I ran into this problem while trying to upgrading from angular 6 to 8, whenever i try to ng serve or ng build i get the following error:

its been so fustrating, i’ve tried adding the “type”:”modules” to my package.json, trying renaming those files with the error to .cjs (then it doesnt even find the files because they are looking for the .js version)

i think the problem here is that the files with the error are inside node_modules?

i’ve tried deleting node_modules and doing NPM install but it was the same

require() of ES modules is not supported.
require() of W:sites****[email protected] from W:sites****CreditoConsumonode_modules@ngtoolswebpacksrcangular_compiler_plugin.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
Instead rename index.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from W:sites****[email protected].```



Digits being added instead of numbers [duplicate]

I am using Svelte and trying to make a game where when you click it will add a number, it works fine at first, but I make sure to save there data, for now im just storing it in localeStorage, now here is when the problem comes in. When I click the button now it will add a digit instead of adding just one to the number.

This is a bit of a weird question because it is oddly specific. I have looked up multiple things, and I cant seem to find this question has been asked before so I am now asking, Ive spent about 30 minutes researching, and nothing has came up.

What I think is happening is that the localeStorage is storing it as a string and not a number even though I have it in a :number to make sure that the variable will always be a number.

let clicks: number = 0;
  let cps: number = 0;
  let cpc: number = 1;
  let cm: number = 1.00;

  function handleClick() {
    const newClicks = cpc * cm;
    clicks += newClicks;
    window.localStorage.setItem('clicks', clicks);
  }

  window.addEventListener("load", function() {
    let sClicks = window.localStorage.getItem('clicks');
    clicks = sClicks;
}, false); 

this is inside of my <script> and in my html I have a simple <button on:click={handleClick}>{clicks}</button>

Im going to try to describe the problem a little more detail if you dont understand, when ever I click the button it will add one so it will go like this,
1, 2, 3, 4, 5, 6 now when I refresh the same number is there however when I click now it will go
61, 611, 6111, 61111, 611111 and so on. And it will still update the value in the localeStorage to be 6111 for example.

Thank you for any help.

connect online existing database with node js

I have a database an online link to the database and I want to connect it to node js and fetch data in my javascript project.
https://unplausible-trouble.000webhostapp.com/editor-4.8.1-mysql.php
And a Data in this database is related to this project.
https://visjs.github.io/vis-timeline/examples/timeline/other/groupsPerformance.html
I want to connect my project with the database which exists online.

Why does .join Method not work on my array?

I want to use JS to create a XML file, for thus I want to print my array that contains the snippets of my XML file without commas but .join() doesnt work

// creating of the XML snippets “<test” and “>”

let testArray = [];
var XML = new XMLWriter();
XML.BeginNode("test");
XML.EndNodeSingle();

// pushing into array and using .join()

testArray.push(XML.XML);

testArray = testArray.join(' ');

// trying to print array into a textarea

document.getElementById('xml').innerHTML = testArray;

// returns <test,>” but <test> is needed

Regex to validate comma separated string with special characters [closed]

I want a common regex to validate below comma separated strings.

input: 10.25.02.12:19092,10.25.02.12:29092,10.25.02.12:39092,10.25.02.12:49092 => should pass

input: at-sdf-dfds-in,at-dfd-in-32,at-wtn-df-df-dfd-in => should pass

input: localhost:19092,localhost:29092,localhost:39092,localhost:49092 => should pass

input: strg1,strg2,strg3 => should pass

input: localhost:19092, => should fail as comma at the end

Please help in this. Thanks in advance.

Loading CSV file to Neo4j using Docker not working

I have a problem while importing .csv file to Neo4j. My neo4j is on docker, when trying to import the csv using express, I get an error:
Neo4jError: Couldn't load the external resource at: file:/organizations.csv

I followed this: Neo4j LOAD CSV Error: unknown protocol: c, so I changed my neo4j.conf file, but it didn’t resolve my problem, I still get the error. The path is 100% fine, because my .js file is where the .csv file is.

LOAD CSV FROM 'file:///organizacje.csv' AS line
MERGE (o: Organization {organizationNr: toInteger(line[0]),name: line[1]})
RETURN o

What is wrong here?

Why does this function prompt twice?

I’ve written a bookmarklet for clicking a controllable amount of times on a HTML element (for clicker games, the like). However, when I run it, it prompts “How many times do you want to click?” twice.

To the best of my knowledge, the second prompt doesn’t do anything. Is there a way I can get rid of it?

Code:

javascript:
var clicked = false
document.onclick= function(event) {  
    if (!clicked) {
      var target= 'target' in event? event.target : event.srcElement;

      var clickamount= parseInt(prompt("Enter time to click "+target.id))-1;

      for (let i = 0; i < clickamount; i++) {
          target.click();
      }
      clicked = true
    }
    
};

Why does the smallest bubble size of this Highcharts jsFiddle example seem incorrect and how do I fix it?

I’m creating a bubble map and am having a problem with the smallest bubble sizes which are not behaving as I expect. After searching a bit in the documentation to understand the problem, I found this:
https://api.highcharts.com/highcharts/plotOptions.bubble.sizeBy

I don’t want to change the setting for ‘sizeBy’ from its default Area (that makes the most sense for my data) but there is helpful example alongside the API entry in JSFiddle:

https://jsfiddle.net/gh/get/library/pure/highcharts/highcharts/tree/master/samples/highcharts/plotoptions/bubble-sizeby/

Highcharts.chart(‘container’, {

chart: {
    type: 'bubble',
    plotBorderWidth: 1,
    zoomType: 'xy'
},

title: {
    text: 'Highcharts Bubbles Sizing'
},
subtitle: {
    text: 'Smallest and largest bubbles are equal, intermediate bubbles different.'
},

xAxis: {
    gridLineWidth: 1
},

yAxis: {
    startOnTick: false,
    endOnTick: false
},

series: [{
    data: [
        [1, 1, 1],
        [2, 2, 2],
        [3, 3, 3],
        [4, 4, 4],
        [5, 5, 5]
    ],
    sizeBy: 'area',
    name: 'Size by area'
}, {
    data: [
        [1, 1, 1],
        [2, 2, 2],
        [3, 3, 3],
        [4, 4, 4],
        [5, 5, 5]
    ],
    sizeBy: 'width',
    name: 'Size by width'
}]

});

Keeping in mind that I’m only nterested in showing by Area (the default), what I don’t understand about the example is why the first bubble (which has a z value of 1) is so small compared to the other bubbles. It’s area should be 0.5 times the area of the second bubble (which has a z value of 2). But it’s much much smaller (like 1/10 of the area). All of the other bubbles however seem to be proportionally correct — it’s really just that first bubble.

So my question is — why is the first bubble so small and is there a way to prevent this from happening so that all of the bubbles are proportionate according to area?

Many thanks in advance,

David