How to generate typings for CSS modules with Parcel?

I’m very new to Parcel. So this might seem like a dumb question to ask.

I have a project that uses typescript, react, less, parcel. And I need a way to generate typings since typescript is giving me the ‘Cannot find module ‘xxx‘ or its corresponding type declarations.’ error. I know I can create a global typing file for all modules ending with the extension .less, but that way I get errors ‘Property ‘xxx‘ does not exist on type ‘typeof import(“*.less”)” and no IntelliSense when editing.

I’m not sure if this is even supposed to be handled by Parcel, I found an extension for VSCode CSS Modules Typed which seems to do the trick, but there are a few plugins for parcel which promise to do the same thing but I can’t get them to work.

can i display my text file data in html form input field? if yes, please tell me how?

setup field:
My code takes input from enduser and stores that form data in one text file.

info field: here you can see form data(text file) which we stored before.

My Requirement is: want to show form data which we stored, on html form.

for ex: my text file contains: Device ID: SLSK10209849, this data has to show in html form input field

Totally, how to show text file form data in HTML form input fields

Here is my code:

<!DOCTYPE html>
<html>
<head>
<style>
.button {
  width: 100px;
  height: 30px;
  display: inline-block;
  background-color: #A9A9A9;
  margin: 0 10px 10px 0;
  color: #fff;
  text-align: center;
  line-height: 30px;
  cursor: pointer;
  border-radius: 15px;
}




.hide {
  display: none;
}
</style>
<div class="button" onclick="switch_div(1);">
 Setup
</div>
<div class="button" onclick="switch_div(2);">
 Info
</div>


<title>setup/info</title>





<div class="content hide" id="show_1">
<script language="Javascript" >
function download() {
  var filename = window.document.myform.docname.value;
  var name =  window.document.myform.name.value;
  var meterno =  window.document.myform.meterno.value;
  var volth=  window.document.myform.volth.value;
  var curth=  window.document.myform.curth.value;
  var sht=  window.document.myform.sht.value;
  var seasonal=  window.document.myform.seasonal.value;
  var mno=  window.document.myform.mno.value;
  var imno=  window.document.myform.imno.value;
  
  
  
  var pom = document.createElement('a');
  pom.setAttribute('href', 'data:text/plain;charset=utf-8,' + 
    "Device ID: " + encodeURIComponent(name) + "nn" +
    "Meter Number: " + encodeURIComponent(meterno) + "nn" +
    "Voltage Threshold: " + encodeURIComponent(volth) + "nn" +
    "Current Threshold: " + encodeURIComponent(curth) + "nn" +
    "Server Hit Time: " + encodeURIComponent(sht) + "nn" +
    "Seasonal: " + encodeURIComponent(seasonal) + "nn" +
    "Mobile No: " + encodeURIComponent(mno) + "nn" +
    "IMEI Number: " + encodeURIComponent(imno) + "nn" +

    encodeURIComponent("")); 

  pom.setAttribute('download', filename);

  pom.style.display = 'none';
  document.body.appendChild(pom);

  pom.click();

  document.body.removeChild(pom);
}
</script>
</head>
<body>
<form name="myform" method="post" >
  <label> File Name:</label>
  <input type="text" id="docname" value="name.txt" /><br/><br/>
  <label> Device ID:</label>
  <input type="text" id="name" /><br/><br/>
  <label> Meter Number:</label>
  <input type="text" id="meterno" /><br/><br/>
  <label> Voltage Threshold:</label>
  <input type="text" id="volth" /><br/><br/>
  <label> Current Threshold:</label>
  <input type="text" id="curth" /><br/><br/>
  <label> Server Hit Time:</label>
  <input type="text" id="sht" /><br/><br/>
  <label> Date:</label>
  <input type="date" id="seasonal"><br/><br/>
  <label> Mobile Number:</label>
  <input type="text" id="mno" /><br/><br/>
  <label> IMEI Number:</label>
  <input type="text" id="imno" /><br/><br/>
  
  
  
  
  
  <input id="download_btn" type="submit" class="btn" style="width: 125px" onClick="download();" />
  
</form>
</body>

</div><br/><br/><br/><br/>



<div class="content hide" id="show_2">

<body>
    <input type="file" name="inputfile"
            id="inputfile">
    <br>

    <pre id="output"></pre>
    
    <script type="text/javascript">
        document.getElementById('inputfile')
            .addEventListener('change', function() {
            
            var fr=new FileReader();
            fr.onload=function(){
                document.getElementById('output')
                        .textContent=fr.result;
            }
            
            fr.readAsText(this.files[0]);
        })
    </script>
</body>
</div>

<script>
function switch_div(show) {  
  document.getElementById("show_"+show).style.display = "block";
  document.getElementById("show_"+((show==1)?2:1)).style.display = "none";
} 
</script>




</html>

Barcode generation and scanning with Cypress

I’m trying to automate a flow that requires scanning barcode. This was tested manually by using a 3rd party website to generate the barcode, and the actual scan barcode part was done on the site (using mobile browser and camera) I’m trying to automate. Since Cypress does not support multiple tabs or multiple browsers, I’m looking for alternate approaches to do so. The data that I can get is the UPC of the product, and the next step is to generate its barcode and scan it. How do we go about this using Cypress?
I know that there is a way to scan QR codes, but I haven’t been able to find much regarding generation and scanning of barcodes.

nuxtjs/composition-api – Module is undefined on composable file

I’m using @nuxtjs/composition-api in my Nuxt application with Vuetify. I have a composable file like this:

// composables/dialog.js
// https://www.npmjs.com/package/vuetify-dialog
import { useContext } from '@nuxtjs/composition-api'

export function useDialog () {
  const { $dialog } = useContext() // for some reason $dialog is undefined here
  const { message, error, info, warning, notify } = $dialog

  function showInfo (title, text) {
    return info({ title, text })
  }

  function messageSuccess (text) {
    return message.success(text)
  }

  // ... some other functions with message, error, info, warning

  return {
    $dialog,
    showInfo,
    messageSuccess,
    // ...
  }
}

The module $dialog is correctly registered in nuxt.config.js: $dialog docs

{
  modules: [
    // Simple usage
    'vuetify-dialog/nuxt',
    // ... other modules
  ]
}

When I access first a page that doesn’t use this composable and then navigate to another page that uses the composable, it works fine. However, if I directly open the page that uses the composable, it shows the error cannot destructure property 'message' of '$dialog' as it is undefined. It happens in production and local env.

Is there any limitation with composable files and @nuxtjs/composition-api ?

Github Issue

An API that returns details of retail stores in the United States and Canada

I’m trying to collate details of retail stores like Wallmart and Amazon. I need these details so i can visualize the data Tableau. The aim is for business owners to see these visualized data and make informed business decisions. So details like store name, location, MSA (Mertrpolitan Statistical Area), date store was opened and closed(if available).

While it is possible to get these data manually, it’s quite hectic and very difficult to come by.

Does anyone know any API I can use to solve this problem?

Lint file not found in WSL

I have the following structure in my project:

aibolit
├───apps
├───bin
│   ├───lint
...

lint is a bash script. But when I try to call it from the aibolit folder, I see the following error:
enter image description here

This is lint running script:

"lint": "npm run lint:js && npm run lint:css",
"lint:js": "bin/lint",
"lint:css": "npx stylelint "apps/**/*.scss"",

ls shows the bin folder and the lint file in it
enter image description here

how can I trace wheel event in html with javascript?

I have want to trace wheel – but page isn’t scroll becase my content is fit for page.
also I need to Know wheel rolling up or down ?

This is my code ,it just work when page is scrollable but (my page isn’t)

function myFunction() { // put this fun on a event of element.
    if (document.body.scrollTop > 50) 
     {
      console.log(document.body.scrollTop);
     } 
 }

I can’t access to chrome://version/ with chrome extention background.js

I have tryed to make a request from console:

var xmlhttp = new XMLHttpRequest();
xmlhttp.open("GET", "chrome://version");
xmlhttp.onreadystatechange = function()
{
    if ((xmlhttp.status == 200) && (xmlhttp.readyState == 4))
    {
        console.log(xmlhttp.responseText)
    }
};
xmlhttp.send();

This work perfectly on console, but when I try to execute it on background.js I have this error:

Not allowed to load local resource: chrome://version/

I have tryed to give permission in manifest.json but was unsuccessfull

Permission I have given to manifest:
fileSystem

If there is no way to get chrome version, how I can identificate a chrome user like profile path, whitout the profile is logged in google.

Vue-owel-carousel filter leaving empty space

I’m trying to build a product card carousel using vue-owl-carousel. One feature I would like this carousel to have is when a button is pressed, the matching tags will only appear in the carousel filtering out the others (as shown in image) [1]: https://i.stack.imgur.com/wkYds.png
The filter is working, however, the carousel will replace the filtered out cards with blank space as if the filtered out cards were still there. Any way to fix this?

** template **

<template>
<div >
  <button type="button" v-for="(c,i) in tags" :key="i" class="btn btn-outline-primary" @click="onClick(c)">{{c}}</button>

  <carousel :items="3" :margin="10" :nav="true">
    <div class="card" v-for="c in filterProducts" :key="c.name" style="width: 18rem;">
      <img :src="require('../assets/img/' + c.imgName + '.png')">
      <h5 class="card-title ps-2 pt-2">{{c.headline}}</h5>
      <div class="card-body">
        <p class="card-text">by {{c.text}}</p>
        <h6 class="card-text fw-bold fs-2">{{c.price}}</h6>
        <button  class="btn btn-outline-secondary rounded-pill">View Details</button>
      </div>
    </div>
  </carousel>
</div>
</template>

JS

<script>
import carousel from "vue-owl-carousel"
export default {
  components:{carousel},
data(){
    return{
      tags:["business","blog","e-commerce"],

      cards:[{
        imgName: "homepage-design-hotjar",
        headline:"Business Template ",
        text:"Bozo",
        price: "$12.99"
      },
        {
          imgName: "homepage-design-qwilr",
          headline:"Fashion template",
          text:"Bozo",
          price: "$12.99",
          tag:"business"
        },
        {
          imgName: "homepage-design-usabilityhub",
          headline:"Game template",
          text:"Bozo",
          price: "$20.99",
          tag:"business",
        },
        {
          imgName: "skateboard",
          headline:"Game template",
          text:"Tony Hawk",
          price: "$100.99",
          tag:"blog"
        },
       {imgName: "skateboard",
         headline:"Game template",
         text:"Tony Hawk",
         price: "$100.99",
         tag:"blog"
       },

       {
         imgName: "skateboard",
         headline:"Game template",
         text:"Tony Hawk",
         price: "$100.99",
         tag:"e-commerce"
       },

      ],
      filterBy: "",
}

},
  computed:{
    filterProducts(){
if (this.filterBy === "") return this.cards;
else return this.cards.filter(c => c.tag === this.filterBy)
  }

},
methods: {
  onClick(tag) {
    this.filterBy = tag

  },

}
}
</script>

React Router v6 child route not rendering

With React Router v6 I want to render the callback page. Although I’m not able to get the output from the element prop in my screen. I’m only getting the output from out and always a blank screen or a 404 for the callback page. What am I missing with the new React Router?

const App: React.FC = () => (
  <>
    <GlobalStyle />
    <Suspense fallback={<Loading fullScreen />}>
      <Routes>
        <Route path="/" element={<PrivateRoute component={Home} />} />
        <Route path="/login" element={<PublicRoute component={Login} />} />
        <Route path="/auth/*" element={<p>auth</p>}>
          <Route path="callback" element={<p>callback</p>} />
        </Route>
      </Routes>
    </Suspense>
  </>
);
const App: React.FC = () => (
  <>
    <GlobalStyle />
    <Suspense fallback={<Loading fullScreen />}>
      <Routes>
        <Route path="/" element={<PrivateRoute component={Home} />} />
        <Route path="/login" element={<PublicRoute component={Login} />} />
        <Route path="/auth/callback" element={<p>callback</p>} />
      </Routes>
    </Suspense>
  </>
);

Also using an Outlet doesn’t seem to solve the problem..

const App: React.FC = () => (
  <>
    <GlobalStyle />
    <Suspense fallback={<Loading fullScreen />}>
      <Routes>
        <Route path="/" element={<PrivateRoute component={Home} />} />
        <Route path="/login" element={<PublicRoute component={Login} />} />
        <Route path="/auth/*" element={<><p>auth</p><Outlet /></>}>
          <Route path="callback" element={<p>callback</p>} />
        </Route>
      </Routes>
    </Suspense>
  </>
);

The BrowserRouter is in my Root component, which is rendering App.

Why is my DomDocument not working but it is in console [duplicate]

I made a simple project
html:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script src="script.js"></script>
    <canvas id="screwen">

    </canvas>
</body>
</html>

Javascript:

const GameWindow = document.getElementById('screwen')

But in console it saying GameWindow is null
console:

document.getElementById('screwen')
<canvas id=​"screwen">​ ​</canvas>​

const Hello = document.getElementById('screwen')
undefined
Hello
<canvas id=​"screwen">​ ​</canvas>​

GameWindow
null

Why is it like that?

I have these controllers that deletes a user, i want to implement DRY(Don’t repeat yourself) principle and make the res json message dynamic

I want to implement a DRY principle for my code below which deletes two different user and also i want to implement a dynamic response based on the details of the model provided to the find method

//This code here deletes the student
exports.deleteStudent = async (req, res) => {
    try {
        let ID = req.query.id
        let exactStudent = await Student.findById(ID)
        if (!exactStudent) {
            return res.status(400).json({ error: "Student with the specified ID not present" })
        }
        await Student.findByIdAndDelete(ID);
        res.status(200).json({ success: 'Student Deleted successfully ' })
    } catch (error) {
        throw error
    }
}

//the code here deletes the teachers

exports.deleteTeacher = async (req, res) => {
    try {
        let ID = req.query.id
        let exactTeacher = await Teacher.findById(ID)
        if (!exactTeacher) {
            return res.status(400).json({ error: "Teacher with the specified ID not present" })
        }
        await Teacher.findByIdAndDelete(ID);
        res.status(200).json({ error: 'Teacher Deleted successfully ' })
    } catch (error) {
        throw error
    }
}