Remove Event Listener of Button

How do I remove the event listener, so the alert box will not be popped up anymore after Remove Listener to prevent it from triggering pop_up button is clicked? document.querySelector(‘#hihi-toggle’).addEventListener(‘click’, e => { alert(“I am Jim”) }); function remove_event_listener_button() { //document.querySelector(‘#hihi-toggle’).removeEventListener() } <button id=”hihi-toggle” data-enabled=”false”>Alert Box </button> <button onclick=”remove_event_listener_button()”>Remove Listener to prevent it from triggering… Read More Remove Event Listener of Button

How to parse each line separately with awk?

A multi-line variable LOG_BUF is set in a bash script parse.sh. Then the variable is parsed with awk, printing all rows containing pat: #!/bin/bash LOG_BUF=$(cat <<-END pat TEST_a pat TEST_b TEST_c pat TEST_d END ) echo ${LOG_BUF} | awk ‘BEGIN{}; /pat/{printf("%d %s", NR, $0); printf("\n")}; END{printf("\n")}’ The expected output is: $ ./parse.sh 1 mem TEST_a… Read More How to parse each line separately with awk?

Syntax error for lombok Generic class , builder pattern and custom setter

Following are the set of classes. import lombok.Builder; import lombok.Data; import java.util.Collection; import java.util.Collections; import java.util.List; @Data @Builder public class GenericClass<T> { //Omitted other attributes for brevity. private Class<T> elementClazz; @SuppressWarnings("rawtypes") private Class<? extends Collection> collectionClazz; private Collection<String> strings; /*BUILDER*/ public static class GenericClassBuilder { public GenericClassBuilder strings(Collection<String> strs) { if (strs == null) strs… Read More Syntax error for lombok Generic class , builder pattern and custom setter

why .then() is getting called twice in promises {javascript}

Problem: last 2 .then are getting called even while i am returning Promise.reject(). 1st .then() is printing undefined and 2nd .then() is also printing the output can someone please explain why? let p4 = new Promise((resolve,reject)=>{ resolve("p4 Resolved"); }); p4.then((val)=>{ console.log(val); return Promise.reject("20 Rejected"); } ) .catch((error)=>{console.log(error)}) .then((val)=>{console.log(val);return 290}) .then((val)=>{console.log("Last then : "+val);}) ; >Solution… Read More why .then() is getting called twice in promises {javascript}

Incorporating Untracked Changes Into a File With the same name in a Git repository

I have made a number of changes to an HTML file and it’s associated CSS file outside of the Git environment. Now I want to safely update the files that are being tracked inside of the Git repository. I am hoping to get some guidance for this aspect of Git before attempting anything. >Solution :… Read More Incorporating Untracked Changes Into a File With the same name in a Git repository

issue with mysql query 'where' priority

Im having issues with this mysql query, i need it to bring ONLY the files that have the condition WHERE st.class_id in (‘%s’) as principal, and the other conditions as secundary, tried changing the or’s to and’s with no luck, thanks in advance. $wpdb->get_results($wpdb->prepare("SELECT `st`.id,`st`.sub_name,`st`.stime,`st`.edate FROM {$_tables[‘subject’]} AS st WHERE `st`.class_id in (‘%s’) and (`stime`… Read More issue with mysql query 'where' priority

What is the proper way to delay a service worker update check?

I’d like to only have the service worker update check occur eg 5 mins into the app being used. Problem is that because it’s wrapped in window.addEventListener(‘load’, async () => { navigator.serviceWorker.register("/serviceWorker.js"); const registration = await navigator.serviceWorker.getRegistration(); it starts its checks at load time. To get around it I put the service worker init in… Read More What is the proper way to delay a service worker update check?