Remove an array from computed reverse method Vuejs

Good day, how to remove an array from a reverse method?

Here’s my code

const app = Vue.createApp({
    data() {
        return {
            app_title: 'Simple Checklist App',
            entered_task_value: '',
            list_of_tasks: [],
            is_priority: false,
        }
    },
    computed: {
        reverseItems() {
            return [...this.list_of_tasks].reverse();
        }
    },
    methods: {
        add_item() {
            this.list_of_tasks.push(
                {
                    id: this.list_of_tasks.length + 1,
                    data: this.entered_task_value,
                    priority: this.is_priority,
                }
            );
            this.entered_task_value = '';
            this.is_priority = '';
        },
        total_tasks() {
           return this.list_of_tasks.length;
        },
        remove_item(task_index) {
            return this.reverseItems.splice(task_index, 1);
        }
    },
});


app.mount('#app');

The remove_item method is not working and I am not sure how to properly call the property inside the computed

remove_item(task_index) {
            return this.reverseItems.splice(task_index, 1);
        }

This is the HTML

            <ul>
            <li
                v-for="(task, task_index) in reverseItems"
                class="item"
                :key="task.id"
                :class="{priority: task.priority}"
            >
            {{task.id}}
            {{task.data}}
             <button v-on:click="remove_item(task_index)">Remove</button>
            </li>
        </ul>

Thank you in Advance!

How to only allow author to use selection menu

I’ve seen that you can use message author, but my command is on a file called autovoice.js and my code that recieve the interaction from the selection menu is on the index :

client.on("interactionCreate", async interaction => {
        if (!interaction.isSelectMenu()) return;
        
        //Some code here

    });

I want to get the interaction author from the slash command and see if the interaction author from the selection menu is the same, any idea?

Map array of locales and change each locale to language name

Using Next.js, I’m getting the current locale and all available locales for a language selection menu:

const {cl, al} = useContext(LangContext);
// cl = "en-US"
// al = ["en-US", "de-DE"]

I wrote this function to return the full language name:

const clAlias = ()=> {
    if (cl === "en-US") { return "English" };
    if (cl === "de-DE") { return "Deutsch" };
}

Now I want to map al , but instead of having ["en-US", "de-DE"] I want to have ["English", "Deutsch"]. It not only looks better but also makes it easier for the user to select their language.
What would be the best way to do so?

How can i loop a loop in Javascript?

There’s an array arr with length N.
My query is that I want to run a loop N/2 times on an array but the condition is-

first the loop should run 1 time
like

for(let i=0;i<n/2;i++){
    anotherArr.push(arr[i])
}

then for 2 numbers , each pair from arr

for(let i=0;i<n/2;i++){
    for(let j=i+1;j<N/2;j++){
        anotherArr.push(arr[i]+arr[j])
}
}

then for 3 numbers each

for(let i=0;i<n/2;i++){
    for(let j=i+1;j<N/2;j++){
        for(let m=j+1;m<N/2;m++){
              anotherArr.push(arr[i]+arr[j]+arr[m])
}}
}

how can i run this loop N times without writing individual case separately.

Objects are not valid as a React child. found: object with keys {background, color}

i am trying to setting up darkMode button, but i got this error … Uncaught Error: Objects are not valid as a React child (found: object with keys {background, color}). If you meant to render a collection of children, use an array instead.

here is my data………………

my Contextjs component……

import { createContext, useReducer } from "react";
export const themeContext = createContext();


const initialState = {darkMode : true};

const themeReducer = (state, action) =>{

    switch(action.type){
        case'toggle':
        return {darkMode : !state.darkMode};
        default:
            return state;
    }
};

export const ThemeProvider = (props)=>{

    const [state, dispatch] = useReducer (themeReducer, initialState);
    return(
        <themeContext.Provider value={{state, dispatch}}>
           {props.children}
        </themeContext.Provider>
    );
};

my AppJs component…….

import Navbar from "./Components/Navbar/Navbar";
import "./App.css"
import { Intro } from "./Components/Intro/Intro";
import Services from "./Components/Services/Services";
import Experience from "./Components/Experience/Experience"
import Works from "./Components/Works/Works"
import Portfolio from "./Components/Portfolio/Portfolio"
import Testimonials from './Components/Testtimonials/Testimonials'
import Contact from "./Components/Contact/Contact"
import Footer from "./Components/Footer/Footer"
import {themeContext} from './Context'
import { useContext  } from "react";



function App() {

  const theme = useContext(themeContext);
  const darkMode = theme.state.darkMode;

  return (
    <div className="App">

      style={{ 
           background : darkMode? 'black' : '',
           color : darkMode? 'white' : ''
       }}
      
      <Navbar />
      <Intro />
      <Services />
      <Experience />
      <Works />
      <Portfolio/>
      <Testimonials/>
      <Contact />
      <Footer />
      
    </div>
  );
}

export default App;

and here is IndexJs……….

import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
import {ThemeProvider} from './Context';

ReactDOM.render(
  <ThemeProvider> 
    <App />
  </ThemeProvider>,
  document.getElementById('root')
);


and error is:- Uncaught Error: Objects are not valid as a React child (found: object with keys {background, color}). If you meant to render a collection of children, use an array instead.

gridjs-vue can’t render HTML

I’m using gridjs-vue 4.0.0 with vue 2.0.
For some reason I can’t render a HTML in the content.
Here is my code:

    import Grid from 'gridjs-vue'
    export default {
        components: {
            Grid
        },
        mounted() {
            console.log(this.$gridjs); //this return 'undefined'
            },
        data () {
            return {
                cols: [ 
                      {
                        name: 'tester',
                        formatter: (cell) => {
                            return this.$gridjs.html(`<b>${cell}</b>`) //this line return error
                        }
                    }
                ],
            }
        },
    }

The log error is: Uncaught (in promise) TypeError: Cannot read properties of undefined (reading ‘html’)

Any suggestions? Thanks

Checkmarx: How to set a Checkmarx scan result as false positive/change status to not exploitable.?

In checkmarx scan results, some vulnerabilities are false positives.

Checkmarx is searching for variables with names like ‘password’, ‘credentials’, ‘Authentication’ etc.. and when it find some variable assigned with some values it warns with false scan result, pretending that the variable is storing sensitive informations.

Example: var.passphrase = this.passphrase;

As a result the scan result will have “Client_Privacy_Violation” vulnerability.

How can we remove those false negative vulnerabilities from scan execution.? So that it will not be shown in scan results.

Nuxt/Image – what is the difference in fit=”inside/outside”

As in the question topic, what is the difference between those keys, as per documentation

“inside: Preserving aspect ratio, resize the image to be as large as possible while ensuring its dimensions are less than or equal to both those specified.”

“outside: Preserving aspect ratio, resize the image to be as small as possible while ensuring its dimensions are greater than or equal to both those specified.”

How should I understand it? Lets say in reference to

“cover: (default) Preserving aspect ratio, ensure the image covers both provided dimensions by cropping/clipping to fit”

Which does not say that the image is resized, is it not than? And what is the use case for inside and outside?

Thanks

Should I import all images into JS file in RN

I have experience with React, but I am currently working on RN application and don’t have enough experience with RN. I am thinking should I import all the static images on the app startup.

I am thinking this because I don’t want to use images like;

<Image source={require('@/assets/icons/edit.png')} />

I want to create the Icon component and want to use it like this;

<Icon name="edit" />

I think it makes more sense to import the images at the beginning instead of importing them when the Icon component is called.

Is it bad for app performance to import all static images at app startup or is there no difference between importing images in screens and importing all at app startup?

Selenium python find and replace text

I’m trying to replace text within a string on Wagtail backend using Selenium and Python.
My strategy is:

  • Find the element that contains the text with contains(text()
  • Replace the string I need to replace (in this case some price)
  • substitute the old text with the new one
element = driver.find_element(By.XPATH,"//*[contains(text(), '17,30')]")
newprice= str(element.text).replace('17,30',"1000")
driver.execute_script("arguments[0].innerText =  ",newprice, element)

This is the error message I get

selenium.common.exceptions.JavascriptException: Message: javascript error: Unexpected identifier

The following code works but doesn’t do what I need. The element that contains “17,30” also contains other text. With the following code, the whole text will be substituted by “1000”.

element = driver.find_element(By.XPATH,"//*[contains(text(), '17,30')]")
driver.execute_script("arguments[0].innerText =  '1000'", element)

How can I enter an input values in Chrome browser console?

MyScenario– upon entering a value in frame counter and hit return key, the video should play at the mentioned interval.

How do i replicate this at browser console using JS selector? Below is the copied html of the input frame counter?

Note: I am a beginner to WebDev and stackoverflow. Kindly excuse if the question is not framed properly.

<div>
              <ap-timeline-time-input data-timeline-child="true" value="200"></ap-timeline-time-input>
              <!--?lit$5695349277$-->
            </div>
<ap-timeline-time-input data-timeline-child="true" value="200"></ap-timeline-time-input>
shadow-root (open)
<form class="time-input-edit hidden">
        <!-- input attribute "size" here is a fix for browser default width
        of the input element making the component width jumpy between edit
        and view mode -->
        <input size="1" value="200">
        <span class="error"><!--?lit$5695349277$--></span>
      </form>

What i tried using the below js path of the input field, i am able to enter the value which reflects in the field. However it video does not get jump to the frame to the new value. only if i click anywhere in the field it works as expected.

document.querySelector("body > app-root > app-qc-route > app-qc > div > app-workspace-outlet > app-workspace-split-layout > ap-split-pane > div:nth-child(2) > app-workspace-outlet > app-workspace-timeline-panel > div > div.timeline.mono-mix-padding-right > app-qc-timeline > app-timeline-base > ap-timeline-basic").shadowRoot.querySelector("ap-timeline > ap-timeline-row.alternate-background.timestamps.overflow-hack-right > span > div > ap-timeline-time-input").value="900"