populating a table in SQL database(id:string, value: array of strings)

SELECT * FROM tableT WHERE

Please write code to populate tableT with id as a string, and array of strings as values, so the table would look like:

"Animals"   ["dogs","cats","rats"]
"Liquids"   ["water","tea","milk"]

The purpose of this is to see a certain id, get that Id from the database and display the corresponding array. So, f.e if the client types in “Animals”. The code would connect to database and retrivie the value ["dogs","cat","rats].

Retrieval code is also appreciated (in Javascript)

React State producing strange result on first state change

I am trying to create a basic square foot calculator using React State and am running into something I’ve not seen before. I’m sure it is something I’m not pervy to yet but would like to know if this is expected or not.

My goal here is when a user enters in a price I’d like to calculate that in real-time. So far, it is able to do this. HOWEVER, when I first load the page and enter in a set of numbers, for example, 5 in the width and 5 in the length – I get NaN printed to the console. Only after I enter a second number like 55 and 55, will it do the calculation and print it to the console.

I had suspected it has something to do with the initial state so instead of useState() I switched it to useState(0). Instead of producing NaN I get 0 printed to the console after each number I enter. Again, If I enter 55 and 55 it does the calculation. Why is this and how can I avoid this?

const PPSQ = 12;

const [width, setWidth] = useState()
const [length, setLength] = useState()

function calculate() {
    console.log((width * length) * PPSQ);
}

function getWidth(val) {
    setWidth(val.target.value)
    calculate()
}

function getLength(val) {
    setLength(val.target.value)
    calculate()
}

<input
className="form-control"
id="length"
name="length"
placeholder="Length"
type="number"
onChange={getLength}
autoComplete="off"
required
/>

<input
className="form-control"
id="width"
name="width"
placeholder="Width"
type="number"
onChange={getWidth}
autoComplete="off"
required
/>

“WebSocket connection to ‘wss://mydomain.com:8080/’ failed:” with no extra details

I am trying to host a websocket using node.js and it seems to host fine, but I cannot connect to it externally because I just get the error in the title. The : after failed suggests there should be extra details and similar questions here prove that, but I’m not getting anything after the colon making this very difficult to debug. I have tried in multiple browsers and I get the same error so it’s not my browser causing this. My best guess would be that my cerificates aren’t working, but they’re the same certificates I use for the rest of my websites and they work fine for them so not too sure.

This is my server-side (node.js) code:

const server = require('https').createServer({
    cert: fs.readFileSync('/etc/letsencrypt/live/mydomain.com/fullchain.pem'),
    key: fs.readFileSync('/etc/letsencrypt/live/mydomain.com/privkey.pem')
});

const websocket = new (require('ws').Server)({server});
websocket.on('connection', (client, request) => {
    console.log("New connection from "+request.socket.remoteAddress);
});

And my client-side (Javascript) code is just

new WebSocket("wss://mydomain.com:8080").onmessage = (event) => {
    console.log(event.data);
};

I have tried making my node.js server listen to port 8080 but that made no difference. I have also tried different URLs on the client side (such as without the protocol, without the port, using my ip) but as I would expect, those don’t work either.

Is passing an ampersand as a string character possible using the openFDA API?

I am using the openFDA NDC API. Searching and counting using the “manufacture_name.exact” field results in a status 400 bad request when passing the character “&” as part of the manufacturer name.

I have reviewed this question where an answer by Nag lists the supported characters and ampersand is not on that list.

I have tried using %26 as a replacement for & without success.

Is there a method to search with & inside the manufacturer name? If not, is there a reliable way to access the data which has & in the manufacturer’s name?

Dynamic Meta Tags via URL Variables

If you’re able to help with this problem, I’d appreciate it as I’m out of my depth.

I have a bunch of meta tags in a HTML header that need to map their content to variables in the URL. For example, if we have this URL:

http:example.com?bofn=Dave&boln=Nate&boem=Pat&botn=Taylor&bstn=Chris&lstn=Rami

We would want the meta tags in the header to read as this:

<meta name="bofn" content="Dave">
<meta name="boln" content="Nate">
<meta name="boem" content="Pat">
<meta name="botn" content="Taylor">
<meta name="bstn" content="Chris">
<meta name="lstn" content="Rami">

From what I’ve found online this would probably use javascript to function (URLSearchParams and/or location.search?) but I’ve no clue how to make it happen.

How to call map property on .getSource(‘my-data’).setData(this.props.heatMapDisplay);?

How do I call map on the line .getSource('my-data').setData(this.props.heatMapDisplay); it keeps me giving error(TypeError: Map.getSource is not a function.) Not sure what I am doing wrong.

class Map extends Component {
constructor(props) {
super(props);
this.state = {
  viewport: {
    latitude: 39.7392,
    longitude: -104.9903,
    width: "calc(100% - 350px)",
    height: "100vh",
    zoom: 10,
    
  },
  selectedRsu: null,
  selectedRsuCount: null
}


};



render() {
const { viewport, selectedRsu, selectedRsuCount } = this.state;
return (
  <div>
    <ReactMapGL
      {...viewport}
      mapboxApiAccessToken={process.env.REACT_APP_MAPBOX_TOKEN}
      mapStyle={mbStyle}
      onViewportChange={(viewport) => {
        this.setState({ viewport });
        Map.getSource('my-data').setData(this.props.heatMapDisplay);
        //how to call map properly
       
       
      }}
    > 
     <Source id="my-data" type="geojson" data={this.props.heatMapDisplay}>
     <Layer  {...layerStyle} />
          </Source>
    
    {

    }
      {this.props.rsuData?.map((rsu) => (
        <Marker
          key={rsu.id}
          latitude={rsu.geometry.coordinates[1]}
          longitude={rsu.geometry.coordinates[0]}
        >
          <button
            class="marker-btn"
            onClick={(e) => {
              e.preventDefault();
              this.setState({
                selectedRsu: rsu
              });
            }}
          ></button>
        </Marker>
      ))}

      {selectedRsu ? (
        <Popup
          latitude={selectedRsu.geometry.coordinates[1]}
          longitude={selectedRsu.geometry.coordinates[0]}
          onClose={() => {
            this.setState({
              selectedRsu: null,
              selectedRsuCount: null
            });
          }}
        >
          <div>
            <h2 class="popop-h2">{selectedRsu.properties.Ipv4Address}</h2>
            <p class="popop-p">Online Status: {selectedRsu.onlineStatus}</p>
            <p class="popop-p">
              Milepost: {selectedRsu.properties.Milepost}
            </p>
            <p class="popop-p">
              Serial Number:{" "}
              {selectedRsu.properties.SerialNumber
                ? selectedRsu.properties.SerialNumber
                : "Unknown"}
            </p>
            <p class="popop-p">BSM Counts: {selectedRsuCount}</p>
          </div>
        </Popup>
      ) : null}
    </ReactMapGL>
  </div>
 );
}
}

const layerStyle = {
id: 'GeoJsonMap-heat',
type: 'heatmap',
source: 'my-data',

paint: {
// increase weight as diameter breast height increases
'heatmap-weight': {
 property: 'count',
type: 'exponential',
stops: [
  [1, 0],
  [62, 1]
]
},
// increase intensity as zoom level increases
'heatmap-intensity': {
 stops: [
   [11, 1],
   [15, 3]
  ]
},
// assign color values be applied to points depending on their density
'heatmap-color': [
 'interpolate',
 ['linear'],
 ['heatmap-density'],
0,
'rgba(236,222,239,0)',
0.2,
'rgb(208,209,230)',
0.4,
'rgb(166,189,219)',
0.6,
'rgb(103,169,207)',
0.8,
'rgb(28,144,153)'
 ],
// increase radius as zoom increases
'heatmap-radius': {
 stops: [
  [11, 15],
  [15, 20]
 ]
},
// decrease opacity to transition into the circle layer
'heatmap-opacity': {
 default: 1,
  stops: [
   [14, 1],
   [15, 0]
  ]
 }
}
}



//call setData()
//figure out when to call above function

 export default Map;

can’t diasble autorefresh o the page

i have a form where user should make new inputs

now user can make new input BUT once only


index.html

<form id="MyForm">
            <input type="text" class="Line" id="Line0">
</form>

index.js

MyForm.addEventListener('submit', {
    handleEvent(event) {//make new line
        event.preventDefault();
        let myForm = document.getElementById("MyForm");
        myForm.insertAdjacentHTML("beforeend", "<input type='text' class='Line'id='line1'>")
    }
})

i have tried :

function new_line(index, event) {
    //change all indexes before this object
    let FormArray = Array.from(MyForm)
    MyForm.insertAdjacentHTML("beforeend", "<input type='text' class='Line' id='Line" + FormArray.length + " onsubmit='return new_line(" + FormArray.length + ")'>")
    event.preventDefault();
}

and

function new_line(index) {
    //change all indexes before this object
    let FormArray = Array.from(MyForm)
    MyForm.insertAdjacentHTML("beforeend", "<input type='text' class='Line' id='Line" + FormArray.length + " onsubmit='return new_line(" + FormArray.length + ")'>")
    return false;
}

but both of this functions update the page before i understand do they work or not

How to work with arrays sort, Iteration, methods

I have information about my products here and I want to find out how many copies of each product I have and that they show duplicate products and the number of duplicate products in the section.
(Item_number) are displayed.

const arrOfProducts = [
{
id: 1,
image: ‘/’,
nameProducts: ‘T’,
},
{
id: 2,
image: ‘/’,
nameProducts: ‘m’,
},
{
id: 1,
image: ‘/’,
nameProducts: ‘T’,
},
];

    <div className={styles.image_item_infiniti}>
      {arrOfProducts.map((item, index) => {
        return (
          <AboutShoppingComponent
            key={index}
            item_image={item.image}
            item_number={item.id}
            item_number_about_shopping_component={item.number}
          />
        );
      }, 0)}
    </div>

Why won’t an array pass with axios.post?

I’m trying to pass an array with ids to a backend in node.js. When console.log(Products) run before the axios.post(), the Products array has two ids in it. When I console.log(req.body.products) in my backend, the array is empty. How can I still access the array in my backend?

Frontend code

const Products = []

                        tempProd.forEach((item) => {
                            firebase.firestore().collection('products').where('name', '==', item.name).get().then((querySnapshot) => {
                                querySnapshot.forEach((doc) => {
                                    Products.push({
                                        price: doc.data().priceID,
                                    })
                                })
                            })
                        })

                        console.log(Products)

                            axios.post('https://Kvam-E-sport-API.olsendaniel04.repl.co/invoice', {
                                products: Products,
                                cus_id: response.data.medlem.id,
                            }).then((response) => {
                                console.log(response)
                            })

Backend code

app.post('/invoice', cors(), async (req, res) => {
      console.log(req.body)
      subscription = await stripe.subscriptions.create({
        collection_method: 'send_invoice',
        customer: req.body.cus_id,
        items: req.body.products,
        days_until_due: 14,
      })

    res.json({
      subscription: subscription
    })
  })

one icon file for whole application (Vuejs, Nuxt)

how can I create one icon file for my whole app? Currently I import into every *.vue file the icons and declare them afterwards like you can see in the following example.

<template>
  <div>
    <v-icon>
      {{mdiCheck}}
    </v-icon>
  </div>
</template>

<script>
import {
  mdiClose,
  mdiCheck
} from '@mdi/js'

export default {
    data: () => ({
        mdiClose: mdiClose,
        mdiCheck: mdiCheck
}),
</script>

I use Nuxt. I want to define the icons in one central file and use them in all my project without importing and declaring the icons in every single file. How can I do that?

traverse (iterate) each element of array in specific time?

I have an array which have 200 elements like -100 to 100. I want to traverse or iterate this whole array in a specific time duration. for example I want to traverse or iterate this array in 5 second or also in 1 minutes. it’s depend on user that , in how much time is define for traverse this whole array. How can i do it?

const array = [-100,-99,-98....0....98,99,100];

function traverseArr(){
....

}

trying to calculate specific cells of tables with javascript without the use of id’s

I am trying to calculate cell 2 and cell 3 of the table on every row in which the result will show in cell 4 and cell 4 will be multiplied by 1.96 in order to calculate cell 5

function Calculate()
{
    let calc = document.getElementById("tblCalc").querySelectorAll("tr");
    rows.cells [4] = rows[1,2,3,4,5].cells[3].value/1000*cells[2].value;
    rows.cells [5] = rows[1,2,3,4,5].cells[4].value*1.96;
    for (var i = 0 < calc.rows.cells; i++; )
    {
        
        document.getElementById("result1").value;
    document.getElementById("result2").value = document.getElementById("result1").value*1.96;
        
    }

here is 1 part of my html

        <table id="tblCalc">
        <tr>
            <th>Ingredient</th>
            <th>Prijs per kilo</th>
            <th>Nodig voor de 25cm pizza in gram</th>
            <th>25cm pizza</th>
            <th>35cm pizza</th>
        </tr>
        <tr>
            <td><input type="text"></td>
            <td><input type="number"></td>
            <td><input type="number"> </td>
            <td><input type="number" readonly></td>
            <td><input type="number" readonly></td>
        </tr>
        <tr>
            <td><input type="text" ></td>
            <td><input type="text"></td>
            <td><input type="text" ></td>
            <td><input type="text" readonly></td>
            <td><input type="text" readonly></td>
        </tr>

<input type="number" readonly id="result1">
    <br>
    <input type="number" readonly id="result2">
    <br>
    <button onclick="Calculate()">Calculate</button>

♨️Help.Microsoft.com ☎ (+1 (877 947-7788 ☎ Talk TO A PERson+| Phone Number …♨️

♨️Help.Microsoft.com ☎ (+1 (877 947-7788 ☎ Talk TO A PERson+| Phone Number …♨️
How does HELP.MICROSOFT.COM +1-877-947-7788 Support Number affect? As mentioned earlier they skipped 111 Help.microsoft.comis one of the most occuCOIN.BASEing help.microsoft.coms in MS OFFICE. So it means the business or user is at constant risk of Contact of HELP.MICROSOFT.COMSupport Number HELP.MICROSOFT.COMSupport Phone Number mostly occurs within the application system because of file damage. The file must be repaired by either restoration or by replacing it with an earlier saved backup copy of the stored data. HELP.MICROSOFT.COMTECHNICAL Support phone number – However, this is often HELP.MICROSOFT.COMCustomer Support phone number software within the end and that’s why
HELP.MICROSOFT.COM +1-877-947-7788 Software. Once the recovering process is complete, HELP.MICROSOFT.COMaccounting software will create a duplicate of that file. But if your application is open, you’d not find any backup created. This may produce two backup duplicates and also the latest one would be 12 hours old while another would be 24 hours old.

How can I make my custom review stars display required in angular form

I have a form for adding reviews, and added a custom star rating component. The ‘rating’ form value is required, so it won’t let you submit without selecting a rating, but there is no feedback. So I would like it to highlight the review star section if it has no value on submit as if it were an angular form field.

<div class="stars-wrapper" title="Rating: {{ form.get('rating').value }} out of 5 stars">
  <div class="star-button-wrapper" *ngFor="let i of [1,2,3,4,5]">
    <button class="star-button" type="button" (click)="setRating(i)" attr.aria-label="Set Rating to {{i}} stars" >
       <mat-icon class="full-star" *ngIf="form.get('rating').value >= i">star</mat-icon>
       <mat-icon class="empty-star" *ngIf="form.get('rating').value < i">star_border</mat-icon>
    </button>
  </div>
</div>```