Skip to main content

Posts

Showing posts from October, 2023

How do I compare my CSV to my config as I am iterating through each one?

Here is my code: import boto3 import pandas as pd import json s3 = boto3.resource('s3') my_bucket = s3.Bucket('bucket-name-here') def verify_unique_col(): with open(r'unique_columns.json', 'r') as f: config = json.load(f) for my_bucket_object in my_bucket.objects.filter(Prefix='decrypted/'): if my_bucket_object.key.endswith('.csv'): filename = my_bucket_object.key.split('/')[-1] for table in config['Unique_Column_Combination']['Table_Name']: unique_col_comb = config['Unique_Column_Combination']['Table_Name'][f'{table}'] df = pd.read_csv(f's3://path/to/{filename}', sep='|') df_unique = df.set_index(unique_col_comb.split(", ")).index.is_unique print(df_unique) verify_unique_col() I am trying to iterate through each CSV file in my bucket and read...

Huge differences between loss functions [closed]

I have a model on TensorFlow that has 2 inputs: some text data and a set of 3 numerical values. It outputs only one single float value. Here is its structure. num_input = keras.Input(shape= (30,3), name="nums") nmlstm = layers.LSTM(128, return_sequences=True)(num_input) nmdense1 = layers.Dense(128, activation='relu')(nmlstm) nmdense2 = layers.Dense(128, activation='relu')(nmdense1) nmdense3 = layers.Dense(128, activation='relu')(nmdense2) text_input = keras.Input(shape= (30, max_sequence_length), name="text") text_vec = layers.Embedding(vocab_size, mask_zero=True, output_dim=embedding_dim)(text_input) txtds1 = keras.layers.TimeDistributed(layers.LSTM(64, return_sequences=True))(text_vec) txtds2 = keras.layers.TimeDistributed(layers.LSTM(64, return_sequences=True))(txtds1) txtds3 = keras.layers.TimeDistributed(layers.LSTM(64, return_sequences=True))(txtds2) txrspd = layers.Reshape((30, 128))(txtds3) txdense = layers.Dense(128, activation=...

RangeError [BitFieldInvalid]: Invalid bitfield flag or number: Messages

I can’t figure how to solve this error, can someone help me in detail since I’m trying to make a bot? I’m sorry if I’m dumb.. Here is the message: ⠀ ⠀ ⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀ ⠀⠀⠀ ⠀⠀⠀ ⠀⠀⠀ ⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⠀ Via Active questions tagged javascript - Stack Overflow https://ift.tt/dOrgZMn

Will change of constructor's prototype influence the instantiated object?

If I have a function (constructor) with a defined prototype, let's say: function Student(name) { this.name = name; } Student.prototype.sayHello = function() { console.log(`Hello, my name is ${this.name}`); } And I instantiate and object using that function (from what I know it should set newly created object's property _prototype to the above prototype object in the moment of creation and set constructor property to Student function). const s1 = new Student('John'); s1.sayHello(); I am sure calling sayHello() would work, however, what if I change the Student 's prototype like this? Student.prototype.sayGoodbye = function() { console.log(`Goodbye, my name is ${this.name}`); } Should s1 be able to call sayGoodbye ? I've read that the _prototype should't change, so in that logic it should throw an error, however, trying it in Chrome's console panel and node.js project it worked and s1 could invoke sayGoodbye . Can someone help me underst...

What is the proper way to link a section on a page using locomotive scroll? [closed]

I have two section links on my page: home and about. Both of them do not work when you are below the respective sections. When the about link is clicked from the home section, it does scroll properly, but all of the content above is removed, other sections load in late and there is extra space at the bottom. This only goes back to normal when the home link is clicked. Actually, that is the only instance where the home link works. What am i doing wrong ? I will provide code to reproduce it if needed. Via Active questions tagged javascript - Stack Overflow https://ift.tt/HvpqlRn

Creating a Button with JavaScript

I'm currently learning JavaScript. I've been attempting to create a navbar button that opens the menu when clicked. After multiple attempts and changes to the code, I didn't solve the problem. HTML <nav class="nav"> <div class="logo">AdoptaPet</div> <button id="navBtn"><i class="bi bi-list abrirNav"></i></button> <ul id="abrirMenu" class="nav-links"> <i class="bi bi-x fecharNav"></i> <li><a href="">Home</a></li> <li><a href="">Sobre Nós</a></li> <li><a href="">Loja</a></li> <li><a href="">Cães para Adoção</a></li> <li><a href="">Detalhes do Cão</a...

Create a regular expression to match big numbers

I get a response from the backend as text in which I have to find a match for numbers which is minimum 16 digits in length. Let's say I have data something like this: {"BIG_INT": 123456789012345675,"BIG_INT_ARRAY_SINGLE": [123456789012345676],"BIG_INT_ARRAY_MULTIPLE": [123456789012345661,12345678901234562,12345678901234563,12345678901234564],"STRING_BIG_INT_ARRAY": "[12345678901234567,12345678901234567, 12345678901234567,12345678901234567]","STRING_BIG_INT":"12345678901234567","BIG_INT_FLOATING_DECIMAL": 12345678901234567.76543210987654321} There are certain conditions where it should not match a number: If the number is enclosed within double quotes: ("STRING_BIG_INT":"12345678901234567" )` If the numbers are within string enclosed array: "STRING_BIG_INT_ARRAY":"[12345678901234567,12345678901234567]" If the number is fractional: "BIG_INT_FLOATING_D...

js and css are not applied to html as static files of nestjs backend solution on nginx server (localhost works correctly)

Hello dear dev community. i would appraciate your help with complex issue related to static content (html, css, js) and nginx configuration. I have backend solution with nestjs framework that returns to frontend some static content (html, css, js). When I launch it locally localhost works correctly. But after deploy to server with nginx configuration I faced with issue: css styles and js scripts are not applied to html. Could you please advise what would be the possible fixes of this issue. Via Active questions tagged javascript - Stack Overflow https://ift.tt/wQKps2r

Content Overflows Other Sections

I'm a beginner to all of this coding and simply trying to build my store's website from scratch. I've learned a lot in HTML codes so far, and have come across this tab content style that would benefit many of our pages. Unfortunately, I can't seem to find a way to get around the fact that the code doesn't build a frame around the entire content style that is submitted, so when I submit this code to the site and attempt to add a new section, the tab code overlaps the new section. It looks like the frame only goes around the text content, and stops when the <div class="tab"> starts. For reference: see the image attached of the code submitted to the webpage with the content overlapping on the new "TESTTEST1212" text section. Code Submitted with overlapping "test" section See HTML Tab Content Section Code Below: <!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width, ini...

Javascript filtering several options at the time

I am using react to create some page that requires a filtering menu. I have a dogs array which contain every dog information, and I am trying to filtering by its temperaments. every dog has at least three temperaments, and I have been trying to check if they have at least one of the temperaments submitted in the filter menu. But nothing seems to work. This the controling component. import {useEffect, useState} from "react"; import {useDispatch, useSelector} from "react-redux"; import {filteringDogs, getTemps, onSearchBreed, orderAscendingDogs, orderDescendingDogs} from "../store"; import styles from "./styles/SideBarComp.module.css"; import {useForm} from "../hooks"; export const SideBarComp = () => { const dispatch = useDispatch() const { dogs } = useSelector( state => state.dogs ) const { temps } = useSelector( state => state.temps ) useEffect(() => { dispatch(getTemps()) }, []) const { bree...

How can I get bookmarked hash links to work with a jQuery change function?

What's the simplest way with this jQuery change function to enable bookmarked hash links to work, i.e to be able to use example.com/#theme1 or example.com/#theme2 links? The jQuery #theme-selector changes the hash and shows/hides the relevant divs with the class, i.e. .theme1 or .theme2 , but when going to example.com/#theme1 from a bookmarked link, all divs are shown. In addition, if I refresh example.com/#theme1 , the hash remains #theme1 , but all divs are shown. Some other questions on SO deal with bookmarkable hashes, but they're many years old. And some libraries that appear useful are ten years old, too, like https://github.com/asual/jquery-address Unfortunately, running the snippet here won't show browser hash changes, nor will JSFiddle. Any ideas? jQuery(document).ready(function(jQuery){ jQuery("#theme-selector").change(function () { var urlhash = document.getElementById('theme-selector').value; ...

npm install takes forever when running docker-compose

I am working on a Next.js project with a PostgreSQL database running in a Docker container. My project's setup uses Docker Compose. However, when I run docker-compose up, it takes forever to execute the npm install command. Running npm install locally on my development machine finishes in less than a minute. In the attached log, you can see that when I run npm i with the log level set to verbose, it appears to hang with no progress after a certain point. [+] Building 3624.4s (7/8) => => transferring context: 34B 0.0s => [internal] load metadata for docker.io/library/node:latest 1.5s => [internal] load build context ...

Is this the valid json file format? I couldn't read it using json.parse unless I change it suffix from .json to .js [closed]

users.json const userContent = ` [{"id":1,"user":{"firstname":"Jacquette","lastname":"Marion","email":"jmarion0@nyu.edu","address":"207 Ryan Avenue","city":"Lubbock","state":"Texas","zip":"79491"},"portfolio":[{"symbol":"NKE","owned":483},{"symbol":"NKE","owned":512},{"symbol":"K","owned":562},{"symbol":"GE","owned":288},{"symbol":"PSX","owned":465},{"symbol":"FDX","owned":263},{"symbol":"AAPL","owned":688},{"symbol":"NFLX","owned":828},{"symbol":"NFLX","owned":-211},{"symbol":"APC","owned":994}]}, {"id":2,"u...

Issues faced when trying to render two PDF files

I am trying to code a program that will take in two files: a question paper and an answer paper. The two files should be rendered in the same window and have a vertical scroll bar that can be used. Below is my code: import tkinter as tk from tkinter import filedialog from tkinter import ttk from tkinter import * from PIL import Image, ImageTk import os from pdf2image import convert_from_path class PDFViewerApp: def __init__(self, root): self.root = root self.root.title("PDF Question Cropper") self.frame = ttk.Frame(self.root) self.frame.pack(fill="both", expand=True) self.question_file = None self.answer_file = None self.question_label = ttk.Label(self.frame, text="No question file selected.") self.question_label.pack() self.select_question_button = ttk.Button(self.frame, text="Select Question PDF", command=self.select_question_pdf) self.select_question_but...

Add and Remove items mutually between two categorized multi selection pull downs

Looking to have below kind of LHS & RHS drop down list. enter image description here I have two multi selectable pull down list LHS and RHS. Left side pull down is a super set and right one is a subset. The list is categorized too. User should be able to select whole category and add to right pull down list and similarly one should be able to remove whole category from RHS dropdown list too. If user is selecting only Item2 in Category3 and if Category3 is not present in RHS , the Item2 should be added to RHS along with its Category. How can we implement this using javascript or any Jquery libraries ? I tried to implement this using multi selection pull down list. But how to do the same with category too. I was not able to find a good one . Via Active questions tagged javascript - Stack Overflow https://ift.tt/QuL3tNT

Cupy CUDA: How to free/release device memory using cupy python?

In my original GPU code using cupy , I have multiple intermediate functions which do some computation and return the results. As a MWE , I have the code below in which foo() requires the variables gc_gpu and dgc_gpu to compute the final result. After computing the result, I want to release the device memory hold by the variables gc_gpu and dgc_gpu (just like we do in C++ CUDA by calling cudaFree(varName); ). I read the CUPY documentation and tried to use mempool.free_all_blocks() to release the memory. QUESTION: Even after using mempool.free_all_blocks() , the memory is not released (as I verify in the task manager). How can I free the device memory? import cupy as cp def foo(): gc_gpu = cp.zeros((51 * 51 * 8 * 101 * 101), dtype=cp.float64) dgc_gpu = cp.ones((51 * 51 * 8 * 101 * 101), dtype=cp.float64) result = gc_gpu + dgc_gpu # free memory mempool = cp.get_default_memory_pool() mempool.free_all_blocks() new_result = result * 2 return new...

TypeError: I am a bozo and can't debug this typeerror [closed]

I am receiving this error while running my code and can't seem to locate where the error is occurring and what to do about it. Also something to note is that the IDE I am using is not telling me where the error is occurring, just that it is occurring. "TypeError: cannot unpack non-iterable NoneType object" Here is my code: import random def roll_dice(): return random.randint(1, 6), random.randint(1, 6) def computer_turn(game_score, goal): turn_score = 0 while turn_score < goal: (d1, d2) = roll_dice() if d1 == 1 and d2 == 1: game_score = 0 turn_score = 0 break elif d1 == 1 or d2 == 1: turn_score = 0 break else: turn_score += d1 + d2 print(f"Computer rolled {d1}, {d2} Turn total {turn_score}") game_score += turn_score return game_score def human_turn(game_score): turn_score = 0 while True: d1, d2 = rol...

Getting a pipe reference into a task

I have two classes, Task1 and Task2. Task1 should read from a TCP/IP port and send up a pipe to Task2. Task2 should return the data to Task1 who echoes this to the client. This is just an experiment. Task2 will eventually process the data and send to another piece of hardware across a serial line. Task1 and Task2 should run on separate cores. I cannot see how to get the pipe reference into the tasks. It is not really necessary Task1 be different from the application. Just has to monitor a TCP/IP port and a pipe asynchronously. Task1 import asyncio import os from multiprocessing import Pipe import sys class Task1: def __init__(self, pipe): self.comm_pipe = pipe async def run(self, reader, writer): while True: data = await reader.read(100) if data: self.comm_pipe.send(data) else: break if self.comm_pipe.poll(): data_from_pipe = self.comm_pipe.recv() ...

AttributeError: type object 'RegisterUserView' has no attribute '_dataDict'

class RegisterUserView(WestwoodDogsView): def init (self, win): self.win = win self.regUser = tk.Toplevel() super(). init (self.regUser) self.regUser.title(C.REGTITLE) self.regUser.geometry("450x600") self.regUser.columnconfigure(0,weight=1) # the main title for our app, and its logo #amended titleFrame = tk.Frame(self.regUser) tk.Label(titleFrame, text=C.REGTITLE, font=("Verdana", 16), fg="blue", bg="yellow").grid(row=0,column=0) titleFrame.grid(row=1, column=0) # The details of the owner #amended userDetails = ttk.LabelFrame(self.regUser, text="New User Details") userDetails.grid(row=2) rowNum=0 self.userData = dict() for key, details in RegisterUserView._dataDict.items(): print(f"Key is:{key} Details are:{details}") if "text" in details: ttk.Label(userDetails, text=details["text"]).grid( row=rowNum, column=0, padx=5, pady=3,sticky=(tk.E)) ...

Nuxt 3/Vue 3 Reactivity issue, while rendering component in v-for loop

Hey community :) I have a reactivity issue (I think it is about reactivity). Description I have FileInput.vue component. With that component I upload files to project. When the new image is added, the new field is pushing to the form.allImages reactive array: @add="addImageField" addImageField function: const addImageField = (): void => { form.allImages.push({ filename: '' }); }; Reactive data: import type { Images } from '@/types/images.d'; interface Work { allImages: Images[]; } const form: Work = reactive({ allImages: [{ filename: '' }], }); Problem description When I add 2 images and then try to delete the first one using: const deleteImageField = (index: number): void => { form.allImages.splice(index, 1); }; the first block is removing correctly and the second comes up to its place (it is correct), but now the second image block need to be empty(with clear value to be able to add image to that). The value of the secon...

Iterating through child elements in puppeteer returns undefined

I'm a beginner with puppeteer and sorry if my question sounds dumb or I missed something. But when I try iterating through the parents node children elements and trying to get its innerText (that does exist) it returns undefined? let Atsiskaitymai = await page.$$("#slenkanti_dalis > table > tbody > tr") for (atsiskaitymas1 of Atsiskaitymai) { let s = await atsiskaitymas1.evaluate(x => Object.values(x.children)) for (let i of s) { console.log(i.innerText); } //returns undefined Thank you for anyone's help. Tried to do: i.evaluate(x => x.innertext) i.getAttribute('innerText') Via Active questions tagged javascript - Stack Overflow https://ift.tt/vnsRy1B

Error shown in console Crbug/1173575, non-JS module files deprecated. Website didn't load on my Internet but the same loaded on another internet

The webpage didn't load on my Wi-Fi/Internet but the same webpage loaded on another internet connection. Error shown in console Crbug/1173575, non-JS module files deprecated. I fixed it by removing all configured firewall settings and it worked for me. Does anyone know better why this problem occurs? Via Active questions tagged javascript - Stack Overflow https://ift.tt/vnsRy1B

How to build a collapsible side navbar without it sharing the same overall container as the main content?

I am trying to build an app that has a collapsible side navbar that I can use template inheritance with (jinja2) instead of rebuilding it for every page in the app. However I have not been able to figure out how to build the side navbar without it sharing the same overall div as the main content which then make it incapable of using template inheritance properly. Does anyone have any solutions? This is the code I have built in html. It works as is supposed to except the fact I cant use it in template inheritance. Any suggestions? <!-- #Left Sidebar ==================== --> <div id="main-wrap" class="wrapper"> <aside id="sidebar"> <!--content for sidebar--> <div class="h-100"> <div class="sidebar-logo"> <a href="">BusinessAssistant</a> </div> <ul class="sidebar-nav"> <li class="sidebar-header...

Extract number of Senders with Anomalous state

Given this document: const genDoc = () => { Senders: genSenders(), Anomalous: genAnomaly() }; I want to create an array mapped with Anomalous fields true and counting the number of Anomalous documents for each sender. So the output array would contain Senders with number of Anomalous 'true' states. const itemsFiltered = items.filter((i) => i.Anomalous === true); const senders = itemsFiltered.map( (i, idx) => i.Anomalous && { id: idx + 1, senderName: i.senders } ); Haven't been able to extract counts yet. Any ideas? Via Active questions tagged javascript - Stack Overflow https://ift.tt/OQG5vNC

How to create this scrolling "tab" animation

When I scroll into the section it feels like it slows down the scroll. And smoothly transitions into the next tab as you keep scrolling through the section. Then it releases when you go past the section. https://www.paypal.com/us/digital-wallet/fraud-detection scroll animation gif I've tried using scroll snap to create something similar but it's not really the same thing. Any push in the right direction would help. Thanks in advance. Via Active questions tagged javascript - Stack Overflow https://ift.tt/OQG5vNC

How to create a html table from array of objects in react?

I have to create an HTML table from an array of objects I receive from an API call. I am using react. Here is the relevant code return( </Container> {((demoLedgerEntries.length > 0) && <Table> <thead> <tr><td>Title demo</td><td>Title demo</td><td>Title demo</td></tr> </thead> <tbody> <tr><td>itemdemo1</td><td>itemdemo1</td><td>itemdemo1</td></tr> {demoLedgerEntries.forEach((item) => { return(<tr><td>{item.wagerAmount}</td> </tr>) }) } <tr><td>itemdemo2</td><td>itemdemo2</td><td>itemdemo2</td></tr> </tbody> </Table> ) } </Container> ) The demoLedgerEntries is an array of objects as foll...

Pasting a password to instagram [closed]

I need to paste the output from a random text generator to the instagram login. Is there a way to do that ? I haven't tried anything yet because I don't know how. Any help is appreciated. I need to do this automatically with a program, so far I've written this. import random import string account_name='aggelos_drm_' character_num=8 while signed_in==False: acc_password=''.join([random.choice(string.ascii_letters + string.digits + '!' + '@' + '#' + '$' + '%' + '^' + '&' + '*' + '(' + ')') for n in range(character_num)]) sign_in() while signed_in==True: print('Ο κωδικός είναι',acc_password) source https://stackoverflow.com/questions/77304397/pasting-a-password-to-instagram

I can post to my IIS server with c# but get a 405 error when posting to the same server with Javascript

I'm trying to post to the same server as my client on Windows 10. I can post from a c# program in the code behind but not to the same url using Javascript... which fails with a 405 Method Not Allowed error. The Javascript code looks like: var xHttp = new XMLHttpRequest(); xHttp.open("POST", url); xHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xHttp.onload = function () { top.idxDisplayMessage(this.responseText); }; xHttp.send(data); Same error with jQuery: function postHttpDoc(url, data) { // Data is in the proper object format here for jQuery var jqxhr = $j.post(url + '?' + data, function () { alert("success"); }) .done(function () { alert("second success"); }) .fail(function () { alert("error"); }) .always(function () { alert("finished"); }); } I've checked II...

i need solution of message content reading with discord bot

i made a discord bot with an discord id token, not bot. how can i see the contents of the message with this. if there are any other to read the message of the discord with the use of discord id and auto reply some specific messages in the server, please anyone help me with that. i already used 'on_message' function and it do not return the content of the message. is there any way to see the contents of the message with this?. i'm expenting a good solution or amy other method to read the contents of the message, i want to read the message and print on the console. source https://stackoverflow.com/questions/77298096/i-need-solution-of-message-content-reading-with-discord-bot

I scripted a code for finding GCD of 2 numbers and the method process is correct but in some special cases like 4 and 8 it doesn't work

I had scripted a code to find a gcd of 2 numbers by the book method of getting the factors, then the common factors and at last multiplying all common factors. It works too but there are some special cases for example 4 and 8. This is my source code Since it is for my practical examination I ought to get my own logic.. I tried to find GCD by the textbook method of finding the factors then the common factor and at last multiplying all the common factors and it seems to work too but gets stuck at few special cases like 4 and 8. source https://stackoverflow.com/questions/77297374/i-scripted-a-code-for-finding-gcd-of-2-numbers-and-the-method-process-is-correct

I am using Nginx to host my React application that makes calls to a Django application. Getting "Too many redirects" error when I visit the site

My React application is set up internally to make calls to my application built using Django Rest Framework. I am using both Gunicorn and Nginx, here is my Nginx config file. server { listen 80; server_name domain.com www.domain.com; return 301 https://$server_name$request_uri; } server { listen 443 ssl; server_name domain.com www.domain.com; ssl_certificate /etc/letsencrypt/live/domain.com/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/domain.com/privkey.pem; # Root directory of React build root /home/ubuntu/Project-Frontend/build; index index.html index.htm; location / { try_files $uri /index.html =404; } # Proxy requests to Django backend location /userapi/ { proxy_pass https://unix:/run/gunicorn.sock; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $host; proxy_redirect off; } } The Nginx server worked until I attempted to add...

Inconsistent average results for while loops

My program takes input from the user, counts the number of letters in the string, adds them to a variable and then divides the total of that variable by the number of words entered to get the average. I'm finding that I'm getting inconsistent results for my averages. What am I doing wrong? word_length_count = 0 count = 0 average = 0 word = input("Enter a word (press Enter to quit): ") count = count + 1 word_length_count = round(word_length_count + len(word)) average = len(word) while count == 1: word = input("Enter a word (press Enter to quit): ") if word == "": break else: while word != "": word = input("Enter a word (press Enter to quit): ") count = count + 1 word_length_count = round(word_length_count + len(word)) average = round(word_length_count / count) print("The average length of the words entered is", round(average)) source https...

Unable to resolve typescript error for redux createSlice

THis is my code: import { Conversation } from "@/types/conversation"; import { PayloadAction, createSlice } from "@reduxjs/toolkit"; const initialState: Conversation | null = null; export const conversationSlice = createSlice({ name: "conversation", initialState, reducers: { setConversation: ( // type error state: Conversation | null, action: PayloadAction<Conversation> ) => { state = action.payload; return state; }, }, }); // Action creators are generated for each case reducer function export const { setConversation } = conversationSlice.actions; export default conversationSlice.reducer; THis is the error I am receiving: Type '(state: Conversation | null, action: PayloadAction<Conversation>) => Conversation' is not assignable to type 'CaseReducer<null, { payload: any; type: string; }> | CaseReducerWithPrepare<null, PayloadAction<any, string, any, any>>'...

Is there any way to update a Power Automate variable inside a JS function?

I'm using the action "Run JavaScript function on web page" for extracting day & month from a website. The problem is that the value returned by JS function (stored to DateVar as a power automate var) is treated as [object Object] by Power Automate. Here is the JS code. var dynamicSelector = '[data-test="qc-wrapper"]'; function extractAndConcatenateDate() { // Find the elements by the dynamic selector var cardElement = document.querySelector(dynamicSelector); if (!cardElement) { return 'Element not found'; } // Find the elements by their class names or other attributes var dateElement = cardElement.querySelector('.sc-ABC1 .sc-XYZ1'); var monthElement = cardElement.querySelector('.sc-ABC2 .sc-XYZ2'); // Extract the text content from the elements var date = dateElement.textContent; var month = monthElement.textContent; // Return the concatenated date and month as a string return date + month; } ...

How do I select query in a button that has been iterated using handlebars?

Hello and thanks in advance, I iterated buttons in handlebars, but when I try to refer to them using Id I get no response. I assumed its because its an ID and IDs are unique, so creating multiple would break the code somehow but I tried with classes and it didnt work either. This is the iteration from the handlebars file <div class="timeline-wrapper"> <ul class="timeline"> <li data-date=""> <span class="title"></span> <div id="moment-dots" class="data show"> <h3 class="description"></h3> <small class="date"> </small> <p class="^details"> </p> <button id="get-history">What else happened on this day ?</button> </div> </li> and here is the event listener I ...

Trouble importing environment anaconda

I have a yml file that I'm trying to import via the Anaconda Navigator but having no luck. I don't get an error message, it just runs forever without actually ever importing the environment. I have administrator privileges on this pc, but it is a work pc. I was wondering if anyone had any suggestions for things I might try to get this to work? source https://stackoverflow.com/questions/77267903/trouble-importing-environment-anaconda

PayPal Integration Issue with Forbidden Error

I have an issue with PayPal payment integration. I want the payment to be integrated and I followed the instructions from: https://developer.paypal.com/docs/regional/mx/payment-selection-page/ My problem is that when I click on the payment button, I encounter a Forbidden error. I don't see any errors in the console either. Please guide me on this matter. My code: <div id="ppplus"> </div> <button type="submit" id="miniBrowserInitiateCheckout" class="btn btn-lg btn-primary btn-block" onclick="initiateCheckout(); return false;"> Checkout </button> <script src="https://www.paypalobjects.com/webstatic/ppplusdcc/ppplusdcc.min.js" type="text/javascript"></script> <script language="JavaScript"> function initiateCheckout() { var ppp = PAYPAL.apps.PPP({ "approvalUrl": "", "placeholder...

Looking for a js library or plugin that can help to create a feature same like ms word text effects has under text transform [closed]

I am looking for a js library or any plugin that can transform text over website same like Microsoft word does under "Text Effects" => "Text Transform" => Follow Path & Word Wrap. For reference please check below image. Via Active questions tagged javascript - Stack Overflow https://ift.tt/q5h8W2C

Currency exchange input field infinite loop

Im building an exhange rate calculator, which takes in 2 inputs, one for USD and other for MX, im using react and useForm hook, and 2 useffects, one for when the USD input changes and other for MX input, if MX changes then USD changes with the calculation MX / USD and vicecersa MX * USD, the problem is it starts an infinite loop because when one change the other one changes and then changes the other one and so on this is the code i have so far const { register, handleSubmit, watch, setValue, formState: { errors }, } = useForm<QuoterInputs>(); const usInput = watch('usInput'); const mxInput = watch('mxInput'); useEffect(() => { if (mxInput > 0) { const exchange = mxInput / parseFloat(exchangeRate); setValue('usInput', exchange, {}); } }, [exchangeRate, mxInput, setValue]); useEffect(() => { if (usInput > 0) { const exchange = usInput * parseFloat(exchangeRate); setValue(...

Activation of venv from script not working [duplicate]

I am trying to create and activate a virtual environment from a Python script. However I keep getting the following error: FileNotFoundError: [Errno 2] No such file or directory: 'source' I have tried, following different suggestions from past questions on this page: from subprocess import run run(["python", "-m", "venv", "venvIA"]) run(["source", "venvIA/bin/activate"]) How can I correctly activate the virtual environment from my script? I also tried replacing "source" for . and other tricks I found online. I am currently using Visual Studio code on a MacOS device but I am also planning on doing another similar code for Windows systems later, in case you know how to work with those too. source https://stackoverflow.com/questions/77251123/activation-of-venv-from-script-not-working

Running multiple instances of the same model on TorchServe

Pretty much what the title says, I have a single MAR file that I generated for my model. Is there a way that I can run multiple instances of that same model with TorchServe? I have tried duplicating the MAR file I got, but I got an error saying there is the same version of the model that is running already which means that the first file was loaded. I'm assuming I would have to regenerate the MAR file again with the same files. I'm trying to avoid that for storage reasons. source https://stackoverflow.com/questions/77251118/running-multiple-instances-of-the-same-model-on-torchserve

Why does my application only return the path when replacing the tag with

I use version: <div className="topnav"> <NavLink to="/" activeClassName="active" exact={true}> Home </NavLink> <NavLink to="/todo" activeClassName="active" exact={true}> Todo </NavLink> <NavLink to="/about" activeClassName="active"> About </NavLink> <a href="/">Home</a> </div> <BrowserRouter> <> <Navigation /> <img src={logo} className="App-logo" alt="logo" /> <Switch> <Route path="/" exact> <Home /> </Route> <Route path="/todo"> <TodoApp /> </Route> <Route path="/about"> <About /> </Route> </Switch> </> </BrowserRouter> With the above application, when I use the <a> tag it works fin...

Auto refreshing after changing in redux state

How to automatically refresh the page after, for example, deleting something from the data? So i won't have manually refresh page to see changes. I'm using axios and js-server for data manipulation, if you need this information. I have this code: import { connect } from "react-redux"; import { FetchUserList, RemoveUser } from "../Redux/Action"; import { useEffect } from "react"; import { Link } from "react-router-dom"; import { toast } from "react-toastify"; const UserListing = (props) => { useEffect(() => { props.loadUser(); }, []); const handleDelete = (code) => { if (window.confirm("Do you want to remove?")) { props.removeUser(code); props.loadUser(); toast.success("User removed successfully."); } }; return props.user.loading ? ( <div> <h2>Loading...</h2> </div> ) : props.user.errMessage ? ( <div> ...

Incorrect map route using here maps API

I am trying to route source and destination using HERE maps API but somehow when I try to route two cities which divided by sea, the map is showing the route which is passing through that sea but there is no bridge and route needs a go-around. How can I fix it? Sample code for routing: function calculateRouteFromAtoB(platform) { var origin=lat+','+long; console.log(origin); var router = platform.getRoutingService(null, 8), routeRequestParams = { routingMode: 'fast', transportMode: 'car', // origin: ''+origin+'', // Brandenburg Gate // destination: ''+''+document.querySelector(".myForm i input[name='dlat']").value+','+document.querySelector(".myForm input[name='dlong']").value+'', // Friedrichstraße Railway Station origin: '21.1702,72.8311', // Brandenburg Gate // destination: ''+document.querySelector(...

Image compressor not importing in nextjs

I am trying to compress an image but when i try to import image compress normally like this: import ImageCompressor from "image-compressor.js"; It gives error: Uncaught ReferenceError: window is not defined This is my code: const handleImage = async (e) => { const selectedFile = e.target.files[0]; if (selectedFile) { try { const compressedDataURL = await compressImage(selectedFile); console.log("Compressed dataURL: ", compressedDataURL); setImage(compressedDataURL); } catch (error) { console.error("Error compressing image:", error); } } }; //Compressing images function const compressImage = async (file) => { return new Promise((resolve, reject) => { new Im...

Can you help me with this problem please?

I tried to create a new proyect using yarn create expo-app My-Proyect, and then the terminal showed me the next error: ➤ YN0000: · Yarn 4.0.0-rc.52 ➤ YN0000: ┌ Resolution step ➤ YN0085: │ + create-expo-app@npm:2.1.1 ➤ YN0000: └ Completed ➤ YN0000: ┌ Fetch step ➤ YN0013: │ A package was added to the project (+ 1.17 MiB). ➤ YN0000: └ Completed ➤ YN0000: ┌ Link step ➤ YN0012: │ create-expo-app@npm:2.1.1 isn't supported by any available linker ➤ YN0000: └ Completed ➤ YN0000: · Failed with errors in 0s 50ms I tried unistalling the node and yarn dependeces and nothing happened, even if i change the folder direction it keeps throwing the same error. Via Active questions tagged javascript - Stack Overflow https://ift.tt/rPiZBUt

React styling with variable classname

I am making a chat app and the message has a classname of the current user's username. And I want if a user send a message to appear in blue while if the other one send one to appear in red. So I wanna do something like this: {currentUser.username} { background:red } Via Active questions tagged javascript - Stack Overflow https://ift.tt/rPiZBUt

Keycloak 21.1.2: java.lang.IllegalStateException: Could not find ScriptEngine for script

I am using quay.io/keycloak/keycloak:21.1.2 docker image with Java script adapters, I get below error when the Javascript adapters are executed in the authentication flow keycloak-1 keycloak 2023-09-26 11:19:33,012 WARN [org.keycloak.services] (executor-thread-5) KC-SERVICES0013: Failed authentication: java.lang.IllegalStateException: Could not find ScriptEngine for script: Script{id='null', realmId='master', name='role-based-authenticator', type='text/javascript', code='AuthenticationFlowError = Java.type("org.keycloak.authentication.AuthenticationFlowError"); But as per release notes at https://www.keycloak.org/docs/latest/release_notes/index.html#keycloak-21-1-0 version 21.1.0 onwards Nashorn javascript engine is available in Keycloak server by default, but for some reason this does not work. How can i fix this? Via Active questions tagged javascript - Stack Overflow https://ift.tt/xKvh1HG

Failed to load resource: the server responded with a status of 500 (Internal Server Error) while using react

frontend is running on port:3000 and backend was running on port:4000 . so I made the function, but still, my components are not visible. I created a file setupProxy.js const {createProxyMiddleware} = require('http-proxy-middleware'); module.exports = function (app) { app.use( '/api', createProxyMiddleware({ target: 'https://192.168.0.156:4000', changeOrigin: true, }), ); }; Via Active questions tagged javascript - Stack Overflow https://ift.tt/LBerM3a

Run and stop my_function() in thread_1 by pressing buttons in Beeware Toga app running in the main thread

I am trying to find a way to run and stop a function my_function() that should run continuously in thread_1 by pressing buttons in my Beeware Toga app that runs in the main thread with several buttons. The main issue is that when the my_function() is running it blocks the Toga GUI and cannot be stopped. I could not find a way to do it, and I run out of ideas. Any suggestion or hint would be much appreciated source https://stackoverflow.com/questions/77210346/run-and-stop-my-function-in-thread-1-by-pressing-buttons-in-beeware-toga-app-r