Skip to main content

Posts

Showing posts from August, 2023

Can MATLAB timetables be imported into Python?

I am generating MAT files with timetable variables using Matlab 2021b. I have never used Python before and want to ensure these MAT files can be easily read into Python as well. Is importing timetable variables from MATLAB to Python possible? If not, can Python accept regular table variables? Thank you! I have not tried to import the data to Python as I have never used it. I was hoping a user would know the answer so that we can target our processing and formatting approach. source https://stackoverflow.com/questions/77018647/can-matlab-timetables-be-imported-into-python

ModuleNotFoundError: No module named pyjanitor despite pyjanitor being installed

I've confirmed the pyjanitor package is installed - it shows up in pip list and I get a confirmation if I try to reinstall with pip install pyjanitor . But then when I run import pyjanitor I get the error: No module named 'pyjanitor' What am I doing wrong? source https://stackoverflow.com/questions/77018639/modulenotfounderror-no-module-named-pyjanitor-despite-pyjanitor-being-installed

ET.fromstring gives ParseError

I am trying to parse an xml string and I want just the PackageReference Include attribute details and the Version of it. When I say ET.fromstring(xml) it gives error like xml.etree.ElementTree.ParseError: not well-formed (invalid token): line 284, column 84 . I verified if the xml is valid on multiple websites and there seems to be no issues with my xml and it is well formed. Please see my Edit below. import xml.etree.ElementTree as ET thisDict={} def parseXMLInCsProj(xml): tree = ET.fromstring(xml) for packageReference in tree.findall('.//PackageReference'): if packageReference is None: continue if 'Include' in packageReference: key=packageReference.get('Include') child_item=packageReference.find('.//Version').text thisDict[key]=child_item xmlstr=f'''<?xml version="1.0" encoding="utf-8"?> <packages> ...

win32com.client Outlook automation with permission error

Trying to download files from emails in Outlook, as I tried to save them the following error appeared (error code is translated may be different in English): An exception occurred: com_error (-2147352567, 'Exception.', (4096, 'Microsoft Outlook', 'Cannot save attachment. You do not have the proper permissions to perform this operation.', None, 0, -2147024891), None) File "C:\Users\jec\OneDrive - XP Investimentos\Financeiro\X - Teste\Automações\500000\Automation.py", line 17, in <module> pdf.SaveAsFile(str(pdf)) pywintypes.com_error: (-2147352567, 'Exception.', (4096, 'Microsoft Outlook', 'Unable to save attachment. You do not have the proper permissions to perform this operation.', None, 0, -2147024891), None) My code is: import win32com.client as client # python -m pip install --upgrade pywin32 import datetime as datetime import pandas as pd ## Connect in outlook outlook = client.Dispatch("Outlook.Applica...

VSCode: "Go to Symbol in Workspace" and "Go To Definition" only search in currently open tabs (JS)?

This seems to only affect my JS files. My PHP files work fine (with a PHP extension of course). When I do a symbol search (ie. Go to symbol in workspace ) or when I try to Go to Definition (or find usages), it will only look within the currently open tabs. This seems to defeat the purpose of these actions, where I want to search within my entire project. If I open the file containing the symbol/definition I am searching for in one tab, then search for that symbol/definition from a different file in another tab, it works just fine. If I close the tab containing the symbol/definition, it immediately stops working. I've tried disabling all of my extensions. The typescript.workspaceSymbols.scope setting does not affect the problem. I've tried restarting VSCode. I've made sure that the workspace is saved. This is a nearly fresh install of VSCode. Is this just how these features are supposed to work? Do I need to reload some sort of symbol database? Is there some setting or...

Fetched data is not updated after changes on next js ssr page

I've got this kind of situation. My application has two pages. The main one is used to show statistics about the user's account. And the user can go to the second one to change these statistics. Both of these pages are server side rendered. So when I go to the first page I see my statistics fetched from the database. I go to the second one and change the data. Then I go back. To go back I use component from "next/link". And here I am on the first page and I see the initial statistics. It seems like the page memoizing fetched data and doesn't update it when I go back. So what do I do to update the data every time the user goes to the statistics page? It's looks like there's no other option except to make it a client component and use useEffect(() => {}, []) hook. What do you think? Here's the statistics page: import Sidebar from "@/components/sidebar/component" import Header from "@/components/header/component" import Statistics...

Cannot Change backgound image using javascript though the image change is shown in console?

hello people i am trying to change background images on a interval of 3 seconds using javascript the code seem to be correct because the images can be seen changed in the console but not on the screen i see blank screen after 3 seconds. here is my react code import React, { useEffect, useState } from "react"; function Home() { let i = 0; // Start index from 0 useEffect(() => { const interval = setInterval(backgroundImages, 3000); return () => { clearInterval(interval); // Clean up the interval when the component unmounts }; }, []); function backgroundImages() { const imagearr = [ "rajwada.jpeg", "indore.jpeg", "females.jpeg", "mayor.jpg" ] console.log("Changing background image"); document.getElementById("main").style.backgroundImage = `url(${imagearr[i]})`; i++; if (i === imagearr.length) { i = 0; } } return ( ...

How to implement AES-CCM in Dart

I'm trying to migrate some JavaScript encryption code to a Dart equivalent but I cannot get the same result. The JavaScript code is using Stanford JavaScript Crypto Library and the Dart version is using AesGcm from Dart Cryptography 2.5.0 ( https://pub.dev/packages/cryptography ). The code in JS is result = sjcl.codec.hex.fromBits( sjcl.mode.ccm.encrypt( new sjcl.cipher.aes(sjcl.codec.hex.toBits("6dbe8f8c87d58e61c2ec29321f42e9ff")), // prf sjcl.codec.hex.toBits("00626c742e332e3132397649356b744455415443"), // plaintext sjcl.codec.hex.toBits("101112131415161718191A1B"), // iv sjcl.codec.hex.toBits("6465764944"), // adata 32)); The Dart I try to implement is final encrypted = await AesGcm.with256bits().encrypt( secretKey: SecretKey(utf8.encode("6dbe8f8c87d58e61c2ec29321f42e9ff")), // prf ? utf8.encode("00626c742e332e313239...

Why does the web code for the Snapchat Bitmoji Kit lead to a "Something Went Wrong Error"? [closed]

I am trying to implement the Snapchat Bitmoji Kit into a webpage using the Javascript implementation. Here is the code I am following: https://github.com/Bitmoji/BitmojiForDevelopers/blob/main/docs/vanilla-sticker-picker/index.html I am able to get into the login screen successfully. However, when I login I get a "Something Went Wrong Error." I setup the OAuth Keys and connected my Snapchat Developer Account. I am getting a 500 server error. It was also complaining about content security but I added those tags and it didn't fix anything. Is this happening to anyone else? Can someone please edit this code to get the Bitmoji sticker picker to appear? Appreciate all help thanks!! enter image description here I tried adding Content Security Policy tags to my header which was what the Console said to do. I was expecting that there was a browser security issue but I also got a 500 error so it might be a server issue. Via Active questions tagged javascript - Stack Overflow h...

How to make transform: scale work with transition and animation on hover?

I am trying to make hover scale work smoothly with animation scale. Hover works with #test but with .rotate I can't get it to work correctly. Also, why the hover scale doesn't work when the animation-fill-mode is forwards instead of none? https://codepen.io/yoholil/pen/qBLbYYm let flag = false; let test = document.querySelector("#test") test.addEventListener("click", function() { console.log(1); flag && test.classList.add("rotate"); !flag && test.classList.remove("rotate"); flag = !flag; }); #test { width: 200px; transition: 0.3s ease; animation: rotateRight 0.3s ease-in-out none; } #test:hover { transform: scale(1.2); } #test.rotate { transform: scaleX(-1); animation: rotateLeft 0.3s ease-in-out none; } @keyframes rotateRight { 0% { transform: scaleX(-1); } 100% { transform: scaleX(1); } } @keyframes rotateLeft { 0% { transform: scaleX(1); } 100% { transform: sc...

JavaScript: Key array does not store the value

I expect a list of all keys & values from the arrays to be displayed at the end. But the key array only remembers the key: value from the last for loop operation. let o = 0 let max while (true) { [dir, dirs, files] = dir_content(dir, dirs, files) for (let i = 0; i < files.length; i++) { let blocked_dir = true; for (let b = 0; b < blocked_dirs.length; b++) { if (files[i] == blocked_dirs[b]) { blocked_dir = false } else {} } if (blocked_dir) { tree.dir = files[i]; //Object.assign(tree, {dir: files[i]}); } } console.log(tree) break } Via Active questions tagged javascript - Stack Overflow https://ift.tt/REhruml

The size of tensor a (100) must match the size of tensor b (64) at non-singleton dimension 2"

I am trying to implement a simple linear network. The input tensor size is (B,3,64,64) My network is defined like this. tensorSize = x.size() input = tensorSize[0] * tensorSize[1] * tensorSize[2] self.linear_one = torch.nn.Linear(64, input) self.linear_two = torch.nn.Linear(input, 32) self.linear_output = torch.nn.Linear(32, 6) self.layer_in = self.linear_one(x) self.layer_in_two = self.linear_two(self.layer_in) self.layer_out = self.linear_output(self.layer_in_two) My output is size (B,3,64,6) but it needs to be (B,6) Why is my network not outputting the correct results? source https://stackoverflow.com/questions/76984392/the-size-of-tensor-a-100-must-match-the-size-of-tensor-b-64-at-non-singleton

Is there a way to create multiple separate GUIs in p5js without initialising too many global variables?

Context: I'm currently using p5gui and quicksettings to create GUIs, but I've been creating them by initialising global variables first and then creating them using "addGlobals()". With this method, I was able to create separate GUI panels on the same canvas but I'd rather minimize the use of global variables if possible. I have considered wrapping the GUI variables into an object like let params = {... } gui.addObject(params) but it turns out that doing this combines everything together and makes up one big GUI panel. Is there a way to create multiple separate GUIs with as few global variables as possible? Like a constructor of some sort. Via Active questions tagged javascript - Stack Overflow https://ift.tt/1Ds6lFM

How can I pass the inputs array of student answers to the controller?

I can't pass the inputs array of student answers to the controller with JavaScript. The big problem is if I use a form How can I receive the request values? Is it possible to send the student's answers in one array through the form? The Blade page is : @extends('layout.master') @section('css') @section('title','Teachers') <link href="../assets/js/DataTables/datatables.min.css" rel="stylesheet"> @endsection @section('content') <div class="container-xxl flex-grow-1 container-p-y"> <h4 class="fw-bold py-3 mb-4"><span class="text-muted fw-light"> /</span> ورقة إمتحان الطالب </h4> <hr class="my-1"/> @if($errors->any()) <div class="alert alert-danger"> <ul> @foreach($errors->all() as $error) ...

Retrieve numeric property name from object [duplicate]

I received the below json result and am trying to get the 2048 value. below is the JSON result. { "0": "https://media.elomilingerie.com/medias/110x154-pdp-thumb-ES801502-BLK-primary-Elomi-Swim-Tropical-Falls-Black-Underwire-Plunge-Bikini-Top.jpg?context=bWFzdGVyfHByb2R1Y3RJbWFnZXN8ODEzNXxpbWFnZS9qcGVnfGFHWmhMMmhtWmk4NU56STBOek14TlRVMU9EY3dMekV4TUhneE5UUmZjR1J3WDNSb2RXMWlYMFZUT0RBeE5UQXlYMEpNUzE5d2NtbHRZWEo1WDBWc2IyMXBMVk4zYVcwdFZISnZjR2xqWVd3dFJtRnNiSE10UW14aFkyc3RWVzVrWlhKM2FYSmxMVkJzZFc1blpTMUNhV3RwYm1rdFZHOXdMbXB3Wnd8MjZkNTRlMWY1YWM4OWY2MTNkNDYxM2Q5NDdkZDk4NjYwY2M5NWYzN2ZmZDYzNmI3MTc5NTlkMzM4YTg5NmI5Yg", "640": "https://media.elomilingerie.com/medias/480x672-pdp-mobile-ES801502-BLK-primary-Elomi-Swim-Tropical-Falls-Black-Underwire-Plunge-Bikini-Top.jpg?context=bWFzdGVyfHByb2R1Y3RJbWFnZXN8ODMxMDZ8aW1hZ2UvanBlZ3xhRGMyTDJoaE15ODVOekkwTnpNMU5ESXlORGswTHpRNE1IZzJOekpmY0dSd1gyMXZZbWxzWlY5RlV6Z3dNVFV3TWw5Q1RFdGZjSEpwYldGeWVWOUZiRzl0YVMxVGQybHRMVlJ5Yj...

d3 circle packing with a gap at the center

I am using the d3.js pack() method to pack the circles. But I want to leave an empty circle in the center like a gap, and then pack the circles around it. I tried using forceSimulation without luck. I want to achieve something like shown in the picture using pack(). Via Active questions tagged javascript - Stack Overflow https://ift.tt/GMLdkKE

How can I get started parsing binary files in JavaScript?

I have some binary files I'd like to be able to parse within the browser. I have found some python code that (I think) does exactly what I need but I don't understand python enough to interpret what I'm seeing. I have some sample files on my own code repository , and below is my attempt at parsing these files. You can drag files into the snippet window to parse that file const elBody = document.body; const dragClass = "drag-over"; const fReader = new FileReader(); fReader.onload = function (e) { const data = e.target.result; processFile(data); }; elBody.addEventListener("dragover", (dragEvent) => { dragEvent.preventDefault(); if (!elBody.classList.contains(dragClass)) { elBody.classList.add(dragClass); } }); elBody.addEventListener("dragleave", () => { elBody.classList.remove(dragClass); }); elBody.addEventListener("drop", (dropEvent) => { dropEvent.preventDefault(); elBody.classList.remove(drag...

What is wrong with my code,it is not working properly

this is the line of code i am using to show the blogdata wrt email but it is showing cannot GET /myblog app.get("/myblog/:e_mail", async (req, res) => { const requestedEmail = req.params.e_mail; try { const user = await User.findOne({ email: requestedEmail }); if (!user) { throw new Error("User not found"); } if (!user.selfBlog) { throw new Error("User does not have a self-blog post"); } const post = user.selfBlog; res.render("myblog", { title: post.title, content: post.content }); } catch (error) { console.error("Error fetching post:", error); res.status(404).render("error", { errorMessage: "Post not found!" }); } }); i tried to get the data in my db but got the error specified and it is my first time writing here so sorry for any mitake and as english is not my first language so sorry for any error in my english Thank you Via Active ...

Why is Framework7 is not working in my Cordova app?

I am developing a mobile app with Cordova and I have framework7 library in my template. Everything works smoothly on the Cordova browser platform. However, when I run it on the iOS platform, my menu links do not work. There is no console error output. My app.js : // Dom7 var $ = Dom7; // Init App var app = new Framework7({ root: '#app', theme: 'ios', routes: routes, view: { pushState: false, }, }); app.sheet.create({ el: '.my-sheet-swipe-to-close', swipeToClose: true, backdrop: true, }); var mainView = app.views.create('.view-main', { url: './index.html' }); My routes.js : "use strict"; var routes = [ { path: '/', Url: './index.html', }, { path: '/ads/', url: './ads.html', }, { ...

How can I identify chlorophyll and submerged aquatic plants in Google Earth Engine over a small pond?

var collection = ee.FeatureCollection([Sat_samp2]); Export.table.toDrive({ collection:collection , description:'lake' , folder:'ROI' , fileFormat:"SHP"}) Map.addLayer(ROI) Map.centerObject(ROI,16) var IMG = ee.ImageCollection("COPERNICUS/S2_SR") .filterBounds(ROI) .filterDate('2023-08-01', '2023-08-31') .sort('CLOUDY_PIXEL_PERCENTAGE', true) .first() .clip(ROI) var nir = IMG.select('B8'); // Near Infrared band var blue = IMG.select('B2'); // blue band var ndavi = blue.subtract(nir).divide(blue.add(nir)); var ndaviParams = {min: -1, max: 1, palette: ['blue', 'white', 'green']}; Map.addLayer(ndavi, ndaviParams, 'NDAVI'); var nir = IMG.select('B5'); // Near Infrared band var redEdge = IMG.select('B4'); // Red-edge band var ndci = nir.subtract(redEdge).divide...

Why does the console say "Cannot use import statement outside a module" when I import a class, which is a module? [duplicate]

So, I created two script files, one for export and one for import. Export // Mario's Test Studio const canvas = document.querySelector('canvas'); const c = canvas.getContext('2d'); canvas.width = innerWidth; canvas.height = innerHeight; export default class Mario { constructor() { this.height = 20; this.width = 20; this.position = { x: 0, y: canvas.height - this.height }; this.velocity = { x: 0 } this.shift = false; this.right = false; this.left = false; } draw() { addEventListener('keyup', ({keyCode}) => { switch (keyCode) { case 39: this.right = false; break; case 37: this.left = false; break; } switch (keyCode) { case 16: this.shift = false; ...

React does not recognize the `isActive` prop on a DOM element

I'm using an isActive property in React. It's not a native property but I would like to use it to make sense in my code logic. However, React is displaying this warning: StyledComponent.ts:159 styled-components: it looks like an unknown prop "isActive" is being sent through to the DOM, which will likely trigger a React console error. If you would like automatic filtering of unknown props, you can opt-into that behavior via <StyleSheetManager shouldForwardProp={...}> (connect an API like @emotion/is-prop-valid ) or consider using transient props( $ prefix for automatic filtering.) VM2196:1 Warning: React does not recognize the isActive prop on a DOM element. If you intentionally want it to appear in the DOM as a custom attribute, spell it as lowercase isactive instead. If you accidentally passed it from a parent component, remove it from the DOM element. const { StrictMode } = React; const { createRoot } = ReactDOM; const { ThemeProvider } = styled; ...

What is the difference between Number.isFinite() and Number.isInteger() in JavaScript?

I can't seem to find a difference in results when using Number.isFinite() and Number.isInteger() . I get that finite means not infinity, but Number.isInteger(Infinity) returns false too, so when do these two methods actually differ in their results? Comparing the outcomes for all these values and they produce the same results, so I'm stumped as to why both methods exist: [0, 1, -1, '1', Infinity, -Infinity, NaN, true, false, {}, null, undefined].forEach(val => { const string = typeof val === 'string' ? `"${val}"` : val === null ? `null` : typeof val === 'object' ? `{}` : val; console.log(`Number.isFinite(${string}): ${Number.isFinite(val)}`) console.log(`Number.isInteger(${string}): ${Number.isInteger(val)}`) }) Via Active questions tagged javascript - Stack Overflow https://ift.tt/exsVIwp

Backstage failing to start with Schema Error

I have been testing Backstage and all was going well till I did a yarn install this afternoon and now the whole thing has died on me :) Whenever I try to run yarn dev it errors out with [0] Loaded config from app-config.yaml [0] <i> [webpack-dev-server] Project is running at: [0] <i> [webpack-dev-server] Loopback: http://localhost:3000/, http://[::1]:3000/ [0] <i> [webpack-dev-server] Content not from webpack is served from '/Users/robertsa1/src/scratch/dev10/bleh/backstage/packages/app/public' directory [0] <i> [webpack-dev-server] 404s will fallback to '/index.html' [0] <i> [webpack-dev-middleware] wait until bundle finished: /catalog?filters%5Bkind%5D=component&filters%5Buser%5D=all [1] Backend failed to start up Error: Invalid configuration schema in ../../node_modules/@backstage/plugin-proxy-backend/config.d.ts, the following definitions are not supported: [1] [1] Partial<{[key:string]:string;Authorization:string;authoriza...

style.css not working while using flask python

When I try to run my app.py which starts a local url to run my html file the style.css does not work. It was working before i connected my script.js to it. clearing cache does not seem to work my files director location is like this: app.py(flask) templates --index.html static --script.js --style.css my html code is: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link rel="stylesheet" href=""> <title>Interactive Page</title> </head> <body> <div class="input-box"> <input type="text" id="user-input" placeholder="Enter your input..."> <button id="submit-button">Submit</button> </div> <div class="chat-box" id="chat-box"> <!...

How to access directory or file outside of root directory in React Native

I am working on project that involves creating a mobile app and website, so I decide to create same or shared screen (pages) for both my app and website. So I decided to go with this file structure. Monorepo App(React-Native) Web(Next.js) Screen (all screens will be here) now, I'm stuck at one problem: I can't access file outside of my root directory, that is my App directory how can I access files outside of root directory? I also change my metro.config.js file and babel.config.js file now they look like this: metro.config.js const {getDefaultConfig, mergeConfig} = require('@react-native/metro-config'); const path = require("path"); /** Metro configuration * https://facebook.github.io/metro/docs/configuration * * @type {import('metro-config').MetroConfig} */ const extraNodeModules = { shared: path.resolve(__dirname + "/../screen"), }; const watchFolders = [path.resolve(__dirname + "/../screen")]; const nodeModul...

get text to custom place in web page

I AM BEGINNER (JUST START). I AM CREATING THIS WEB PAGE TO PRACTICE HTML / CSS /JS. SO I'M FACING SOME TROUBLE HERE. I NEED TO GET THAT "CREATIVE WEB DESIGNER " TEXT UNDER TO THE HEADER . I TRIED DIFFERENT WAYS. BUT I COUDN'T DO THAT PROPERLY. class = "topic" THAT HOW I NAME IT (THE TEXT I MENTIONED) body { background-color: #D8D9DA; } .header h1 { color:rgb(13, 2, 0); font-family:"verdana", sans-serif ; padding-left: 30px; } .header { background-color: #FFF6E0; padding:30px; align-items: center; border-radius: 70px; display: flex; justify-content: space-between; } .social { list-style-type: none; display: inline; padding: 0px; margin-right: 10px; object-position: 10px; margin-top: 20px; } .navi{ list-style-type:none; padding: 8px 16px; font-family:"verdana", sans-serif ; font-size: 25px; display: block; width:20%; } .nav { list-style-type:none; padding: 8px 16px; f...

What is the design philosophy behind Promise.reject(reason) wrapping the reason with a Promise while Promise.resolve() not doing so?

So I was reading the article on MDN about Promises and got stuck here: Unlike Promise.resolve(), Promise.reject() always wraps reason in a new Promise object, even when reason is already a Promise. I'm just trying to understand what difference it makes in coding. What would happen if Reject doesn't wrap the reason with another Promise just as resolve does and how exactly this simplifies the usage. Appreciate some hypothetical examples. Via Active questions tagged javascript - Stack Overflow https://ift.tt/oQLAEKx

2D Coordinates of point defined as fractions of rectangular sides. Rectangular is not parallel to X, Y axes

I have a rectangular ABCD: (x1,y1)... (x4,y4). AB is not necessarily parallel to any of the axis. I need to find coordinates of a point inside of it, defined as portion of its sides: alpha *AB, alpha*CD . beta*BC, beta*DA. where alpha and beta are between 0 and 1. Is there as simple solution to it? source https://stackoverflow.com/questions/76894736/2d-coordinates-of-point-defined-as-fractions-of-rectangular-sides-rectangular-i

I can't get Python and tkinter to display a photo on a canvas [duplicate]

Update: The answer by acw1668 did allow me to display the image. Thank you. Searches for documentation for PhotoImage show it is hard to find. Online examples were easily misunderstood to indicate .jpg files were acceptable. Previous update: I edited the end of my explanation to show the suggested fix didn't work. I'm left wondering if people are avoiding the question because someone closed it, even though the recommended fix doesn't work or if I have a situation no one knows the answer to. Sorry, I'm new to Stack Overflow and I am unfamiliar how the site works. My original question begins here: I'm trying to make python/tkinter show a photo image on a canvas. All I get is the background color. I'm a retired programmer and now use python/tkinter to draw charts for my genealogy research and for whatever else catches my interest. This is the first time I've had trouble getting tkinter to do what I want. I've narrowed the chunk down to a main routin...

Difference between useState and props

I am new to React and I am trying to understand the difference between the following two approaches in a simple example where the button color is changed when there is a mouse hover event. First approach using props: function over(props) { props.target.style.backgroundColor = 'black'; }; function out(props){ props.target.style.backgroundColor = 'white'; }; return ( <div className="container"> <h1>{headingText}</h1> <input type="text" placeholder="What's your name?" /> <button onMouseOver={over} onMouseOut={out}>Submit</button> </div> ); Second approach using useState: const [isMouseOver, setMouseOver] = useState(false); function handleMouseOver() { setMouseOver(true); }; function handleMouseOut() { setMouseOver(false); }; return ( <div className="container"> <h1>{headingText}</h1>...

jest and babel config as ECMAScript module

i get the following error when running jest You appear to be using a native ECMAScript module configuration file, which is only supported when running Babel asynchronously. but "type": "module" is set in package.json and babel.config.js looks as follows // babel.config.js const config = { presets: [ "@babel/preset-env", ['@babel/preset-react', {runtime: "automatic"}] ], plugins: [ "@babel/plugin-proposal-class-properties" ], }; export default config; everything works when i rename babel.config.js to babel.config.cjs and change it to // babel.config.cjs module.exports = { presets: [ "@babel/preset-env", ['@babel/preset-react', {runtime: "automatic"}] ], plugins: [ "@babel/plugin-proposal-class-properties" ], }; but i do not want to convert babel babel.config.js to commonjs or to json. what am i doing wrong? how can i resolve the error? V...

How could I make my decryption program recognize which character the encrypted character belongs to, if each character could have 3 possible answers?

Heyo, I've had an assignment where I need to write an encryption program that gives each character three possible characters that it would turn into when encrypted. For example: a = [#, S, 2], b = [&, =, @] import string import random import json question = input("Would you like to Encrypt or Decrypt a string?\n") if question == "Encrypt": # We choose our random characters from encryptionList, and also create the dictionary from the same string using dict.fromkeys(). encryptionList = string.ascii_letters + string.digits + string.punctuation + " " dictionary1 = dict.fromkeys(encryptionList, ) dictionary2 = dict.fromkeys(encryptionList, ) # Adding the three random characters to our Dictionary by random, while loop checks whether each index is similar, and chooses another one if it is. for key in dictionary1: listOfLetters1 = list() listOfLetters2 = list() for i in range(3): listOfLette...

swapping two values using array destructuring is not working without semicolon(;)

let [x,y] = [10,20] [y,x] = [x,y] console.log(x,y) its not working as expected it gave me the error... Uncaught ReferenceError: Cannot access 'y' before initialization let [x,y] = [10,20];//using semicolon here [y,x] = [x,y] console.log(x,y) now its working please anyone can explain me why its working now..` Via Active questions tagged javascript - Stack Overflow https://ift.tt/YS51VwD

How do I create a jquery function so that a clicked button will scroll to the next date

I have a trigger button with a class of 'next'and I have coded a jquery function as follows: $(document).ready(function () { $(".next").click(function (e) { e.preventDefault(); console.log('got here'); var currentDate = new Date(); console.log(currentDate); var dateElements = $(".date"); var nextDateElement = null; dateElements.each(function () { var date = new Date($(this).text()); if (date > currentDate) { nextDateElement = $(this); return false; // Exit the loop } }); if (nextDateElement) { $('html, body').animate({ scrollTop: nextDateElement.offset().top }, 'slow'); } }); }); but I can't get it to work - or even display the console log. What might I be doing wrong? Via Active questions tagged javascript - Stack Overflow https:...

External Library in WebStorm as CSS with an http link

Does someone know how to load an External Library in WebStorm as CSS with an http link? It gives me the option to "Download Library" in the warning. <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/8.0.1/normalize.css"/> However, when I download it, the External Library loads as a .js and because it downloads it as .js, the warning still appears to me and the project doesn't index the library properly. I've tried repairing the IDE, or watching if I could rename it in some way, but nothing seems to fix it. Via Active questions tagged javascript - Stack Overflow https://ift.tt/itaAe3u

add screenshots with specific name to allure report

I'm learning webdriverIO and I have a question. Can we take screenshots with testcase's name and date? Now my screenshots name are something like this "e3e4c61d-88c2-4388-bc08-1247feea6d44-attachment.png". I use mocha framework and allure reporter. Maybe anyone know where I can see some docs or examples? Via Active questions tagged javascript - Stack Overflow https://ift.tt/itaAe3u

How to wait for a user click in a while loop?

I finished making a board game (Kamisado) in java with swing (JFrame). Now I am trying the same with client side javascrip/typescript (browser). The idea is something like this: while(!isGameOver(board)) { Player turn = getTurn(board); Move move = turn.getMove(board); tryMove(move, board); } I have a abstract class Player with abstract method getMove(Board board). So i can change the kind of player in the main function. Example: Player white = new PlayerAI(); Player black = new PlayerHuman(); PlayerHuman creates a View, in which the human user can click for moves, like this: class PlayerHuman extends Player { View view; PlayerHuman() { view = new View(); } getMove(Board board) { return view.getMove(board); } } class View { Move move; View { // add even listener which calls click } click(Move move) { this.move = move; synchronized (monitor) monitor.notify(); } ...

I am facing problem with Reflected XSS vulnerabilities in my router file please help me here

My Code :- router.post('/loadDetails', async (req, res) => { try { var resultData = await ltgService.postRequest(req.body, 'myconfig/loadAllSDetails'); res.send(resultData); } catch(error) { res.status(500).send(error.message); } }) Here i am getting vulnerability while passing input and output as The application's router.post embeds untrusted data in the generated output with send, at line 626 of routes\myConfigRouter.js . This untrusted data is embedded straight into the output without proper sanitization or encoding, enabling an attacker to inject malicious code into the output. The attacker would be able to alter the returned web page by simply providing modified data in the user input body, which is read by the router.post method at line 625 of routes\myConfigRouter.js . This input then flows through the code straight to the output web page, without sanitization. This can enable a Reflected Cross-Site Scripting (...

How to fix cursor issue with content editable attribute?

There is input field with content editable . Need to display block that contain img and none-displayable span with text. Snippet below did the task. But it has bug. And I can not change contenteditable because it belong external site and my code run in browser extension. Run snippet. Click end of line, press left arrow button a few times. Your cursor moving through images to text. It's okay. Now press right arrow button and try to arrived end of line. When cursor get there first image, cursor's selection disappears. Another words, we can move cursor from right to left, but fail from left to right. .editor { display: inline-block; width: 200px; } .hide { display: none; } <div class="editor" contenteditable="true">text <span contenteditable="false"><span class="hide"> DogePls </span><img alt="DogePls" src="https://cdn.betterttv.net/emote/55c7eb723d8fd22f20ac9cc1/1x.webp">...

Reduce redundant code by optimizing of appendRow() App script

I'm working on a project where I shall send data from my app to a google spreadsheet in 2 sheets through app script. I set up a paraphrase to secure the connection. Hkey I have a lot of data to send like computer1,brand1,cpu1,ram1,computer2,brand2,cpu2,ram2 until 20. my first version of the code comprise a lot of data like below: function doGet(e) { var ss = SpreadsheetApp.getActive(); var sheet1 = ss.getSheetByName("Sheet1"); var Sheet2 = ss.getSheetByName('Sheet2'); var Region = e.parameter.Region ; var Place = e.parameter.Place ; var Staff = e.parameter.Staff ; var computer1 = e.parameter.computer1; var brand1 = e.parameter.brand1; var cpu1 = e.parameter.cpu1; var ram1 = e.parameter.ram1; var computer2 = e.parameter.computer2; var brand2 = e.parameter.brand2; var cpu2 = e.parameter.cpu2; var ram2 = e.parameter.ram2; var Hkey = e.parameter.Hkey; if (Hkey == 'AB12xyz') { sheet1.appendRow(Region, Place, Staff, comp...

COCOEval get 0 result for AP and AR?

I am trying to do project in detecting keypoints from images. For the evaluation, I am using COCOeval to calculate the AP and AR. However, the evaluation dataset always get result 0 for all AP and AR. Is it normal for early stage of the training where the prediction still very bad? or There is something wrong with the code. Here the validation result example: [ { "category_id": 1, "center": [ 138.40066528320312, 120.2301254272461 ], "image_id": 100000, "scale": [ 1.2766542434692383, 1.2766542434692383 ], "score": 1.0, "keypoints": [ 369.5614013671875, 7.676669120788574, 1.0, 416.5087890625, 24.127635955810547, 1.0, 491.8260498046875, 31.30722427368164, 1.0, 335.75958251953125, 30.002338409423828, 1.0, 353.5982666015625, 60.155391693115234, 1.0, 472.4736328125, 41.874290466308594, 1.0, 210.8014373779297, 28.03527069091797, 1.0, 457.08782958984375, -108.73526000976562, 1.0, 543.10205078125, -105.9140396118164, 1.0, 343.3966674...

How to connect multiple search boxes to JavaScript and display its results [closed]

I am building a website, it based on past numbers of lottery results, now I’m stocked up at a place where I am going to search for some numbers in this table using JavaScript and the searched numbers will just change color or highlight. For the search box: there will 3 rows and in each row there will be 5 boxes because the results is 5 draw. Reason for the search is to make it easier to forecast or predict the next draw. The website image This is the code example \<div class=“row”\> \<div class=“column”\> \<table\> \<tr\> \<td\>24-54-70-89-60\</td\> \</tr\> \</table\> \</div\> \<div class=“column”\> \<table\> \<tr\> \<td\>52-76-51-72-54\</td\> \</tr\> \</table\> \</div\> \<div class=“column”\> \<table\> \<tr\> \<td\>11-7-9-31-15\</td\> \</tr\> \</table\> \</div\> \</div\> \<div class=“row”\> \<d...

how to exclude certain values for a string property in ajv schema?

name: { type: "string", minLength: 1, maxLength: 15, pattern: "^[^\\s].+[^\\s]$", // blocks leading and trailing white spaces errorMessage: "name", }, The above is the ajv schema for the name property. How do I further specify that certain values are not allowed. For example, "Hitler" and "Khan" are not allowed. Via Active questions tagged javascript - Stack Overflow https://ift.tt/yqjL4VK

How can I go about downloading a package in a lambda during runtime. I am trying to use the module geopandas which is too large for a layer

I am currently trying to pip install the package during runtime to a tmp folder but getting an error 'Importing the numpy C-extensions failed'. I have tried downloading the package from s3 during runtime and then get an error no module geopandas. I have already tried adding the pythonpath=/tmp env variable. I am trying to avoid using a docker container for this particular project. source https://stackoverflow.com/questions/76838608/how-can-i-go-about-downloading-a-package-in-a-lambda-during-runtime-i-am-trying