问:
Task hangs if terminal window doesn't lose focus
While debugging the problem, I minimized the code to the one below to understand why I have the problem. The program is a console application.

The code simply creates an instance of a third-party class and subscribes to an event that does nothing. When I run the code as is:

Line (9) is never executed unless the terminal window loses focus or I press the Enter key multiple times. It's like it's stuck on the line (8). If I replace the line (8) with any other method from ThridParty, such as obj.MethodX() I get the same problem.

If I delete line (8), then I won't have this problem.

If I remove Task.Run (line 5) and let the code on lines (7-9) run outside of Task.Run, then I won't have this problem.

If I uncomment lines 24-25 and 32-33 then I won't have this problem.

I looked at the ThirdParty constructor through dotPeek. It has a few lazy initializations (Lazy<>) of some pluggins and services. So it's likely that calling any obj.MethodX() initializes those plugins and services first. But I still don't understand why it matters if lines 7-9 and 22-34 run on separate threads. It seems as if one of them is starving.

```<code>1.  class MyService
2.  {
3.      public void Start()
4.      {
5.          Task.Run(() =>
6.          {
7.              var obj = new ThirdParty();
8.              obj.ItemChanged += (...) => {};
9.              Console.WriteLine("Instantiated ThirdParty");
10.          });
11.      }
12.  }

13. internal class Program
14. {
15.    static async Task Main(string[] args)
16.    {
17.        var service = new MyService();
18.        service.Start();
19.
20.        await Task.Run(() =>
21.        {
22.            while (true)
23.            {
24.                // if (Console.KeyAvailable)
25.                // {
26.                       var read = Console.ReadKey(true);
27.                       if (read.Key == ConsoleKey.X)
28.                       {
29.                           service.Stop();
30.                           return;
31.                        }
32.                // }
33.                // Thread.Sleep(100);
34.            }
35.       });
36.   }
37. }
</code>```

Body:
While debugging the problem, I minimized the code to the one below to understand why I have the problem. The program is a console application.

The code simply creates an instance of a third-party class and subscribes to an event that does nothing. When I run the code as is:

Line (9) is never executed unless the terminal window loses focus or I press the Enter key multiple times. It's like it's stuck on the line (8). If I replace the line (8) with any other method from ThridParty, such as obj.MethodX() I get the same problem.

If I delete line (8), then I won't have this problem.

If I remove Task.Run (line 5) and let the code on lines (7-9) run outside of Task.Run, then I won't have this problem.

If I uncomment lines 24-25 and 32-33 then I won't have this problem.

I looked at the ThirdParty constructor through dotPeek. It has a few lazy initializations (Lazy<>) of some pluggins and services. So it's likely that calling any obj.MethodX() initializes those plugins and services first. But I still don't understand why it matters if lines 7-9 and 22-34 run on separate threads. It seems as if one of them is starving.

1.  class MyService
2.  {
3.      public void Start()
4.      {
5.          Task.Run(() =>
6.          {
7.              var obj = new ThirdParty();
8.              obj.ItemChanged += (...) => {};
9.              Console.WriteLine("Instantiated ThirdParty");
10.          });
11.      }
12.  }

13. internal class Program
14. {
15.    static async Task Main(string[] args)
16.    {
17.        var service = new MyService();
18.        service.Start();
19.
20.        await Task.Run(() =>
21.        {
22.            while (true)
23.            {
24.                // if (Console.KeyAvailable)
25.                // {
26.                       var read = Console.ReadKey(true);
27.                       if (read.Key == ConsoleKey.X)
28.                       {
29.                           service.Stop();
30.                           return;
31.                        }
32.                // }
33.                // Thread.Sleep(100);
34.            }
35.       });
36.   }
37. }


来源: stackexchange

问:
How to Sorting/Searching IP Address in datatable Using Listjs Javascript
Im looking for a way to searching an IP Address in the table rows using Listjs

My datatable was not containt IP Address table i just added it manully perfectly like customer, phone, email, Etc

and it works fine but when i type dots between number example we have ip address 127.0.0.1 if search for 127. it say No Result Found but when i type 127 with no dot it give me the three number of the ip but after adding the dot to complete the ip address says No Result Found i need to searching for full ip address i searching alot in google for the solution i just cannot figure it as im not good in javascrite

listjs.init.js

var customerList, checkAll = document.getElementById("checkAll"),
    perPage = (checkAll && (checkAll.onclick = function() {
        var e = document.querySelectorAll('.form-check-all input[type="checkbox"]');
        1 == checkAll.checked ? Array.from(e).forEach(function(e) {
            e.checked = !0, e.closest("tr").classList.add("table-active")
        }) : Array.from(e).forEach(function(e) {
            e.checked = !1, e.closest("tr").classList.remove("table-active")
        })
    }), 8),
    editlist = !1,
    options = {
        valueNames: ["id", "customer_name", "ip_address", "email", "date", "phone", "status"],
        page: perPage,
        pagination: !0,
        plugins: [ListPagination({
            left: 2,
            right: 2
        })]
    };
document.getElementById("customerList") && (customerList = new List("customerList", options).on("updated", function(e) {
    0 == e.matchingItems.length ? document.getElementsByClassName("noresult")[0].style.display = "block" : document.getElementsByClassName("noresult")[0].style.display = "none";
    var t = 1 == e.i,
        a = e.i > e.matchingItems.length - e.page;
    document.querySelector(".pagination-prev.disabled") && document.querySelector(".pagination-prev.disabled").classList.remove("disabled"), document.querySelector(".pagination-next.disabled") && document.querySelector(".pagination-next.disabled").classList.remove("disabled"), t && document.querySelector(".pagination-prev").classList.add("disabled"), a && document.querySelector(".pagination-next").classList.add("disabled"), e.matchingItems.length <= perPage ? document.querySelector(".pagination-wrap").style.display = "none" : document.querySelector(".pagination-wrap").style.display = "flex", e.matchingItems.length == perPage && document.querySelector(".pagination.listjs-pagination").firstElementChild.children[0].click(), 0 < e.matchingItems.length ? document.getElementsByClassName("noresult")[0].style.display = "none" : document.getElementsByClassName("noresult")[0].style.display = "block"
}));
const xhttp = new XMLHttpRequest;
xhttp.onload = function() {
    var e = JSON.parse(this.responseText);
    Array.from(e).forEach(e => {
        customerList.add({
            id: '#VZ' + e.id + "",
            customer_name: e.customer_name,
            ip_address: e.ip_address,
            email: e.email,
            date: e.date,
            phone: e.phone,
            status: isStatus(e.status)
        }), customerList.sort("id", {
            order: "desc"
        }), refreshCallbacks()
    }), customerList.remove("id", '#VZ2101')
}, xhttp.open("GET", "assets/json/table-customer-list.json"), xhttp.send();
var isValue = (isCount = (new DOMParser).parseFromString(customerList.items.slice(-1)[0]._values.id, "text/html")).body.firstElementChild.innerHTML,
    idField = document.getElementById("id-field"),
    customerNameField = document.getElementById("customername-field"),
    ipField = document.getElementById("ipaddress-field"),
    emailField = document.getElementById("email-field"),
    dateField = document.getElementById("date-field"),
    phoneField = document.getElementById("phone-field"),
    statusField = document.getElementById("status-field"),
    addBtn = document.getElementById("add-btn"),
    editBtn = document.getElementById("edit-btn"),
    removeBtns = document.getElementsByClassName("remove-item-btn"),
    editBtns = document.getElementsByClassName("edit-item-btn");

function filterContact(e) {
    var t = e;
    customerList.filter(function(e) {
        e = (matchData = (new DOMParser).parseFromString(e.values().status, "text/html")).body.firstElementChild.innerHTML;
        return "All" == e || "All" == t || e == t
    }), customerList.update()
}

function updateList() {
    var a = document.querySelector("input[name=status]:checked").value;
    data = userList.filter(function(e) {
        var t = !1;
        return "All" == a ? t = !0 : (t = e.values().sts == a, console.log(t, "statusFilter")), t
    }), userList.update()
}
refreshCallbacks(), document.getElementById("showModal") && (document.getElementById("showModal").addEventListener("show.bs.modal", function(e) {
    e.relatedTarget.classList.contains("edit-item-btn") ? (document.getElementById("exampleModalLabel").innerHTML = "Edit Customer", document.getElementById("showModal").querySelector(".modal-footer").style.display = "block", document.getElementById("add-btn").innerHTML = "Update") : e.relatedTarget.classList.contains("add-btn") ? (document.getElementById("exampleModalLabel").innerHTML = "Add Customer", document.getElementById("showModal").querySelector(".modal-footer").style.display = "block", document.getElementById("add-btn").innerHTML = "Add Customer") : (document.getElementById("exampleModalLabel").innerHTML = "List Customer", document.getElementById("showModal").querySelector(".modal-footer").style.display = "none")
}), ischeckboxcheck(), document.getElementById("showModal").addEventListener("hidden.bs.modal", function() {
    clearFields()
})), document.querySelector("#customerList").addEventListener("click", function() {
    ischeckboxcheck()
});
var table = document.getElementById("customerTable"),
    tr = table.getElementsByTagName("tr"),
    trlist = table.querySelectorAll(".list tr"),
    count = 11,
    forms = document.querySelectorAll(".tablelist-form"),
    statusVal = (Array.prototype.slice.call(forms).forEach(function(a) {
        a.addEventListener("submit", function(e) {
            var t;
            a.checkValidity() ? (e.preventDefault(), "" === customerNameField.value || "" === ipField.value || "" === emailField.value || "" === dateField.value || "" === phoneField.value || editlist ? "" !== customerNameField.value && "" !== emailField.value && "" !== dateField.value && "" !== phoneField.value && editlist && (t = customerList.get({
                id: idField.value
            }), Array.from(t).forEach(function(e) {
                (isid = (new DOMParser).parseFromString(e._values.id, "text/html")).body.firstElementChild.innerHTML == itemId && e.values({
                    id: '' + idField.value + "",
                    customer_name: customerNameField.value,
                    ip_address: ipField.value,
                    email: emailField.value,
                    date: dateField.value,
                    phone: phoneField.value,
                    status: isStatus(statusField.value)
                })
            }), document.getElementById("close-modal").click(), clearFields(), Swal.fire({
                position: "center",
                icon: "success",
                title: "Customer updated Successfully!",
                showConfirmButton: !1,
                timer: 2e3,
                showCloseButton: !0
            })) : (customerList.add({
                id: '#VZ' + count + "",
                customer_name: customerNameField.value,
                ip_address: ipField.value,
                email: emailField.value,
                date: dateField.value,
                phone: phoneField.value,
                status: isStatus(statusField.value)
            }), customerList.sort("id", {
                order: "desc"
            }), document.getElementById("close-modal").click(), refreshCallbacks(), clearFields(), filterContact("All"), count++, Swal.fire({
                position: "center",
                icon: "success",
                title: "Customer inserted successfully!",
                showConfirmButton: !1,
                timer: 2e3,
                showCloseButton: !0
            }))) : (e.preventDefault(), e.stopPropagation())
        }, !1)
    }), new Choices(statusField));

function isStatus(e) {
    switch (e) {
        case "Active":
            return '' + e + "";
        case "Block":
            return '' + e + ""
    }
}

function ischeckboxcheck() {
    Array.from(document.getElementsByName("checkAll")).forEach(function(e) {
        e.addEventListener("click", function(e) {
            e.target.checked ? e.target.closest("tr").classList.add("table-active") : e.target.closest("tr").classList.remove("table-active")
        })
    })
}

function refreshCallbacks() {
    removeBtns && Array.from(removeBtns).forEach(function(e) {
        e.addEventListener("click", function(e) {
            e.target.closest("tr").children[1].innerText, itemId = e.target.closest("tr").children[1].innerText;
            e = customerList.get({
                id: itemId
            });
            Array.from(e).forEach(function(e) {
                var t = (deleteid = (new DOMParser).parseFromString(e._values.id, "text/html")).body.firstElementChild;
                deleteid.body.firstElementChild.innerHTML == itemId && document.getElementById("delete-record").addEventListener("click", function() {
                    customerList.remove("id", t.outerHTML), document.getElementById("deleteRecordModal").click()
                })
            })
        })
    }), editBtns && Array.from(editBtns).forEach(function(e) {
        e.addEventListener("click", function(e) {
            e.target.closest("tr").children[1].innerText, itemId = e.target.closest("tr").children[1].innerText;
            e = customerList.get({
                id: itemId
            });
            Array.from(e).forEach(function(e) {
                var t = (isid = (new DOMParser).parseFromString(e._values.id, "text/html")).body.firstElementChild.innerHTML;
                t == itemId && (editlist = !0, idField.value = t, customerNameField.value = e._values.customer_name, ipield.value = e._values.ip_address, emailField.value = e._values.email, dateField.value = e._values.date, phoneField.value = e._values.phone, statusVal && statusVal.destroy(), statusVal = new Choices(statusField), t = (val = (new DOMParser).parseFromString(e._values.status, "text/html")).body.firstElementChild.innerHTML, statusVal.setChoiceByValue(t), flatpickr("#date-field", {
                    dateFormat: "d M, Y",
                    defaultDate: e._values.date
                }))
            })
        })
    })
}

function clearFields() {
    customerNameField.value = "", ipField.value = "", emailField.value = "", dateField.value = "", phoneField.value = ""
}

function deleteMultiple() {
    ids_array = [];
    var e = document.getElementsByName("chk_child");
    if (Array.from(e).forEach(function(e) {
            1 == e.checked && (e = e.parentNode.parentNode.parentNode.querySelector(".id a").innerHTML, ids_array.push(e))
        }), "undefined" != typeof ids_array && 0 < ids_array.length) {
        if (!confirm("Are you sure you want to delete this?")) return !1;
        Array.from(ids_array).forEach(function(e) {
            customerList.remove("id", `${e}`)
        }), document.getElementById("checkAll").checked = !1
    } else Swal.fire({
        title: "Please select at least one checkbox",
        confirmButtonClass: "btn btn-info",
        buttonsStyling: !1,
        showCloseButton: !0
    })
}
document.querySelector(".pagination-next") && document.querySelector(".pagination-next").addEventListener("click", function() {
    document.querySelector(".pagination.listjs-pagination") && document.querySelector(".pagination.listjs-pagination").querySelector(".active") && document.querySelector(".pagination.listjs-pagination").querySelector(".active").nextElementSibling.children[0].click()
}), document.querySelector(".pagination-prev") && document.querySelector(".pagination-prev").addEventListener("click", function() {
    document.querySelector(".pagination.listjs-pagination") && document.querySelector(".pagination.listjs-pagination").querySelector(".active") && document.querySelector(".pagination.listjs-pagination").querySelector(".active").previousSibling.children[0].click()
});
var attroptions = {
        valueNames: ["name", "born", {
            data: ["id"]
        }, {
            attr: "src",
            name: "image"
        }, {
            attr: "href",
            name: "link"
        }, {
            attr: "data-timestamp",
            name: "timestamp"
        }]
    },
    attrList = new List("users", attroptions),
    existOptionsList = (attrList.add({
        name: "Leia",
        born: "1954",
        image: "assets/images/users/avatar-5.jpg",
        id: 5,
        timestamp: "67893"
    }), {
        valueNames: ["contact-name", "contact-message"]
    }),
    existList = new List("contact-existing-list", existOptionsList),
    fuzzySearchList = new List("fuzzysearch-list", {
        valueNames: ["name"]
    }),
    paginationList = new List("pagination-list", {
        valueNames: ["pagi-list"],
        page: 3,
        pagination: !0
    });```

ContentLicense: CC BY-SA 4.0

Body:
Im looking for a way to searching an IP Address in the table rows using Listjs

My datatable was not containt IP Address table i just added it manully perfectly like customer, phone, email, Etc

and it works fine but when i type dots between number example we have ip address 127.0.0.1 if search for 127. it say No Result Found but when i type 127 with no dot it give me the three number of the ip but after adding the dot to complete the ip address says No Result Found i need to searching for full ip address i searching alot in google for the solution i just cannot figure it as im not good in javascrite

listjs.init.js

var customerList, checkAll = document.getElementById("checkAll"),
    perPage = (checkAll && (checkAll.onclick = function() {
        var e = document.querySelectorAll('.form-check-all input[type="checkbox"]');
        1 == checkAll.checked ? Array.from(e).forEach(function(e) {
            e.checked = !0, e.closest("tr").classList.add("table-active")
        }) : Array.from(e).forEach(function(e) {
            e.checked = !1, e.closest("tr").classList.remove("table-active")
        })
    }), 8),
    editlist = !1,
    options = {
        valueNames: ["id", "customer_name", "ip_address", "email", "date", "phone", "status"],
        page: perPage,
        pagination: !0,
        plugins: [ListPagination({
            left: 2,
            right: 2
        })]
    };
document.getElementById("customerList") && (customerList = new List("customerList", options).on("updated", function(e) {
    0 == e.matchingItems.length ? document.getElementsByClassName("noresult")[0].style.display = "block" : document.getElementsByClassName("noresult")[0].style.display = "none";
    var t = 1 == e.i,
        a = e.i > e.matchingItems.length - e.page;
    document.querySelector(".pagination-prev.disabled") && document.querySelector(".pagination-prev.disabled").classList.remove("disabled"), document.querySelector(".pagination-next.disabled") && document.querySelector(".pagination-next.disabled").classList.remove("disabled"), t && document.querySelector(".pagination-prev").classList.add("disabled"), a && document.querySelector(".pagination-next").classList.add("disabled"), e.matchingItems.length <= perPage ? document.querySelector(".pagination-wrap").style.display = "none" : document.querySelector(".pagination-wrap").style.display = "flex", e.matchingItems.length == perPage && document.querySelector(".pagination.listjs-pagination").firstElementChild.children[0].click(), 0 < e.matchingItems.length ? document.getElementsByClassName("noresult")[0].style.display = "none" : document.getElementsByClassName("noresult")[0].style.display = "block"
}));
const xhttp = new XMLHttpRequest;
xhttp.onload = function() {
    var e = JSON.parse(this.responseText);
    Array.from(e).forEach(e => {
        customerList.add({
            id: '#VZ' + e.id + "",
            customer_name: e.customer_name,
            ip_address: e.ip_address,
            email: e.email,
            date: e.date,
            phone: e.phone,
            status: isStatus(e.status)
        }), customerList.sort("id", {
            order: "desc"
        }), refreshCallbacks()
    }), customerList.remove("id", '#VZ2101')
}, xhttp.open("GET", "assets/json/table-customer-list.json"), xhttp.send();
var isValue = (isCount = (new DOMParser).parseFromString(customerList.items.slice(-1)[0]._values.id, "text/html")).body.firstElementChild.innerHTML,
    idField = document.getElementById("id-field"),
    customerNameField = document.getElementById("customername-field"),
    ipField = document.getElementById("ipaddress-field"),
    emailField = document.getElementById("email-field"),
    dateField = document.getElementById("date-field"),
    phoneField = document.getElementById("phone-field"),
    statusField = document.getElementById("status-field"),
    addBtn = document.getElementById("add-btn"),
    editBtn = document.getElementById("edit-btn"),
    removeBtns = document.getElementsByClassName("remove-item-btn"),
    editBtns = document.getElementsByClassName("edit-item-btn");

function filterContact(e) {
    var t = e;
    customerList.filter(function(e) {
        e = (matchData = (new DOMParser).parseFromString(e.values().status, "text/html")).body.firstElementChild.innerHTML;
        return "All" == e || "All" == t || e == t
    }), customerList.update()
}

function updateList() {
    var a = document.querySelector("input[name=status]:checked").value;
    data = userList.filter(function(e) {
        var t = !1;
        return "All" == a ? t = !0 : (t = e.values().sts == a, console.log(t, "statusFilter")), t
    }), userList.update()
}
refreshCallbacks(), document.getElementById("showModal") && (document.getElementById("showModal").addEventListener("show.bs.modal", function(e) {
    e.relatedTarget.classList.contains("edit-item-btn") ? (document.getElementById("exampleModalLabel").innerHTML = "Edit Customer", document.getElementById("showModal").querySelector(".modal-footer").style.display = "block", document.getElementById("add-btn").innerHTML = "Update") : e.relatedTarget.classList.contains("add-btn") ? (document.getElementById("exampleModalLabel").innerHTML = "Add Customer", document.getElementById("showModal").querySelector(".modal-footer").style.display = "block", document.getElementById("add-btn").innerHTML = "Add Customer") : (document.getElementById("exampleModalLabel").innerHTML = "List Customer", document.getElementById("showModal").querySelector(".modal-footer").style.display = "none")
}), ischeckboxcheck(), document.getElementById("showModal").addEventListener("hidden.bs.modal", function() {
    clearFields()
})), document.querySelector("#customerList").addEventListener("click", function() {
    ischeckboxcheck()
});
var table = document.getElementById("customerTable"),
    tr = table.getElementsByTagName("tr"),
    trlist = table.querySelectorAll(".list tr"),
    count = 11,
    forms = document.querySelectorAll(".tablelist-form"),
    statusVal = (Array.prototype.slice.call(forms).forEach(function(a) {
        a.addEventListener("submit", function(e) {
            var t;
            a.checkValidity() ? (e.preventDefault(), "" === customerNameField.value || "" === ipField.value || "" === emailField.value || "" === dateField.value || "" === phoneField.value || editlist ? "" !== customerNameField.value && "" !== emailField.value && "" !== dateField.value && "" !== phoneField.value && editlist && (t = customerList.get({
                id: idField.value
            }), Array.from(t).forEach(function(e) {
                (isid = (new DOMParser).parseFromString(e._values.id, "text/html")).body.firstElementChild.innerHTML == itemId && e.values({
                    id: '' + idField.value + "",
                    customer_name: customerNameField.value,
                    ip_address: ipField.value,
                    email: emailField.value,
                    date: dateField.value,
                    phone: phoneField.value,
                    status: isStatus(statusField.value)
                })
            }), document.getElementById("close-modal").click(), clearFields(), Swal.fire({
                position: "center",
                icon: "success",
                title: "Customer updated Successfully!",
                showConfirmButton: !1,
                timer: 2e3,
                showCloseButton: !0
            })) : (customerList.add({
                id: '#VZ' + count + "",
                customer_name: customerNameField.value,
                ip_address: ipField.value,
                email: emailField.value,
                date: dateField.value,
                phone: phoneField.value,
                status: isStatus(statusField.value)
            }), customerList.sort("id", {
                order: "desc"
            }), document.getElementById("close-modal").click(), refreshCallbacks(), clearFields(), filterContact("All"), count++, Swal.fire({
                position: "center",
                icon: "success",
                title: "Customer inserted successfully!",
                showConfirmButton: !1,
                timer: 2e3,
                showCloseButton: !0
            }))) : (e.preventDefault(), e.stopPropagation())
        }, !1)
    }), new Choices(statusField));

function isStatus(e) {
    switch (e) {
        case "Active":
            return '' + e + "";
        case "Block":
            return '' + e + ""
    }
}

function ischeckboxcheck() {
    Array.from(document.getElementsByName("checkAll")).forEach(function(e) {
        e.addEventListener("click", function(e) {
            e.target.checked ? e.target.closest("tr").classList.add("table-active") : e.target.closest("tr").classList.remove("table-active")
        })
    })
}

function refreshCallbacks() {
    removeBtns && Array.from(removeBtns).forEach(function(e) {
        e.addEventListener("click", function(e) {
            e.target.closest("tr").children[1].innerText, itemId = e.target.closest("tr").children[1].innerText;
            e = customerList.get({
                id: itemId
            });
            Array.from(e).forEach(function(e) {
                var t = (deleteid = (new DOMParser).parseFromString(e._values.id, "text/html")).body.firstElementChild;
                deleteid.body.firstElementChild.innerHTML == itemId && document.getElementById("delete-record").addEventListener("click", function() {
                    customerList.remove("id", t.outerHTML), document.getElementById("deleteRecordModal").click()
                })
            })
        })
    }), editBtns && Array.from(editBtns).forEach(function(e) {
        e.addEventListener("click", function(e) {
            e.target.closest("tr").children[1].innerText, itemId = e.target.closest("tr").children[1].innerText;
            e = customerList.get({
                id: itemId
            });
            Array.from(e).forEach(function(e) {
                var t = (isid = (new DOMParser).parseFromString(e._values.id, "text/html")).body.firstElementChild.innerHTML;
                t == itemId && (editlist = !0, idField.value = t, customerNameField.value = e._values.customer_name, ipield.value = e._values.ip_address, emailField.value = e._values.email, dateField.value = e._values.date, phoneField.value = e._values.phone, statusVal && statusVal.destroy(), statusVal = new Choices(statusField), t = (val = (new DOMParser).parseFromString(e._values.status, "text/html")).body.firstElementChild.innerHTML, statusVal.setChoiceByValue(t), flatpickr("#date-field", {
                    dateFormat: "d M, Y",
                    defaultDate: e._values.date
                }))
            })
        })
    })
}

function clearFields() {
    customerNameField.value = "", ipField.value = "", emailField.value = "", dateField.value = "", phoneField.value = ""
}

function deleteMultiple() {
    ids_array = [];
    var e = document.getElementsByName("chk_child");
    if (Array.from(e).forEach(function(e) {
            1 == e.checked && (e = e.parentNode.parentNode.parentNode.querySelector(".id a").innerHTML, ids_array.push(e))
        }), "undefined" != typeof ids_array && 0 < ids_array.length) {
        if (!confirm("Are you sure you want to delete this?")) return !1;
        Array.from(ids_array).forEach(function(e) {
            customerList.remove("id", `<a href="javascript:void(0);" class="fw-medium link-primary">${e}</a>`)
        }), document.getElementById("checkAll").checked = !1
    } else Swal.fire({
        title: "Please select at least one checkbox",
        confirmButtonClass: "btn btn-info",
        buttonsStyling: !1,
        showCloseButton: !0
    })
}
document.querySelector(".pagination-next") && document.querySelector(".pagination-next").addEventListener("click", function() {
    document.querySelector(".pagination.listjs-pagination") && document.querySelector(".pagination.listjs-pagination").querySelector(".active") && document.querySelector(".pagination.listjs-pagination").querySelector(".active").nextElementSibling.children[0].click()
}), document.querySelector(".pagination-prev") && document.querySelector(".pagination-prev").addEventListener("click", function() {
    document.querySelector(".pagination.listjs-pagination") && document.querySelector(".pagination.listjs-pagination").querySelector(".active") && document.querySelector(".pagination.listjs-pagination").querySelector(".active").previousSibling.children[0].click()
});
var attroptions = {
        valueNames: ["name", "born", {
            data: ["id"]
        }, {
            attr: "src",
            name: "image"
        }, {
            attr: "href",
            name: "link"
        }, {
            attr: "data-timestamp",
            name: "timestamp"
        }]
    },
    attrList = new List("users", attroptions),
    existOptionsList = (attrList.add({
        name: "Leia",
        born: "1954",
        image: "assets/images/users/avatar-5.jpg",
        id: 5,
        timestamp: "67893"
    }), {
        valueNames: ["contact-name", "contact-message"]
    }),
    existList = new List("contact-existing-list", existOptionsList),
    fuzzySearchList = new List("fuzzysearch-list", {
        valueNames: ["name"]
    }),
    paginationList = new List("pagination-list", {
        valueNames: ["pagi-list"],
        page: 3,
        pagination: !0
    });


问:
I am looking for an algorithm to determine the relationship between two members of a family
This algorithm determines the relationship between two members of a family, it does so only at a basic level, including parents, siblings, children, cousins, half-siblings, and uncles.

It seems that I need to extend this functionality to fourth and fifth degree members, that is, fourth cousins and fifth cousins.

```<code>export interface Member {
  name: string
  father: string | null
  mother: string | null
}
const determinateDeepRelationship = (p1: string, p2: string, fam: Member[]) => {
  const getParents = (
    p?: Member['name'] | null,
    fam?: Member[]
  ): Member | null => {
    const found = fam?.find((member) => member.name === p)
    return found || null
  }
  const p1Parents = getParents(p1, fam)
  const p2Parents = getParents(p2, fam)

  // **************************************** Are brothers

  if (
    p1Parents?.father === p2Parents?.father &&
    p1Parents?.mother === p2Parents?.mother
  ) {
    return 'hermano/hermana'
  }
  // **************************************** Are father or mother
  if (
    p2Parents?.mother === p1Parents?.name ||
    p2Parents?.father === p1Parents?.name
  ) {
    return 'padre/madre'
  }

  // **************************************** Are father or soon
  if (p1Parents?.mother === p2 || p1Parents?.father === p2) {
    return 'hija/hijo'
  }

  // **************************************** Are step brother or step sister or soon

  if (
    p1Parents?.father === p2Parents?.father ||
    p1Parents?.mother === p2Parents?.mother
  ) {
    return 'stepBrother'
  }

  // ****************************************  Are uncle or ant

  const getGrandparents = (p: string): (string | null)[] => {
    const parents = getParents(p, fam)

    const grandparents = [
      getParents(parents?.father, fam)?.father || null,
      getParents(parents?.father, fam)?.mother || null,
      getParents(parents?.mother, fam)?.father || null,
      getParents(parents?.mother, fam)?.mother || null
    ]
    return grandparents
  }

  const p2Grandparents = getGrandparents(p2)
  const p1Grandparents = getGrandparents(p1)

  // p1 is uncle of p2
  console.log({ p1Grandparents, p2Grandparents, p2, p1, p1Parents })

  // ****************************************  Are cousins
  for (let i = 0; i < p1Grandparents.length; i++) {
    for (let j = 0; j < p2Grandparents.length; j++) {
      if (
        (p2Grandparents[i] && p1Grandparents.includes(p2Grandparents[i])) ||
        (p1Grandparents[j] && p2Grandparents.includes(p1Grandparents[j]))
      )
        return 'primos/primas'
    }
  }

  for (let j = 0; j < [p1Parents?.father, p1Parents?.mother].length; j++) {
    for (let i = 0; i < p2Grandparents.length; i++) {
      if (
        p1Parents?.father === p2Grandparents[i] ||
        p1Parents?.mother === p2Grandparents[i] ||
        p1Parents?.father === p2Grandparents[j] ||
        p1Parents?.mother === p2Grandparents[j]
      )
        return 'tia/tio'
    }
  }

  // ****************************************  Are nice or nephew
  for (let i = 0; i < p1Grandparents.length; i++) {
    for (let j = 0; j < [p2Parents?.father, p2Parents?.mother].length; j++) {
      if (
        p2Parents?.father === p1Grandparents[i] ||
        p2Parents?.mother === p1Grandparents[i] ||
        p2Parents?.father === p1Grandparents[j] ||
        p2Parents?.mother === p1Grandparents[j]
      )
        return 'sobrino/sobrina'
    }
  }

  return 'any'
}

export default determinateDeepRelationship

</code>```

This is the object that i use to test the algorimt

```<code>
const family = [
  { name: 'mat', father: 'mike', mother: null },
  { name: 'luz', father: null, mother: 'deb' },
  { name: 'sebas', father: 'mat', mother: 'luz' },
  { name: 'pilar', father: 'mat', mother: 'luz' },
  { name: 'juan', father: 'mat', mother: 'luz' },
  { name: 'lupe2', father: null, mother: null },
  { name: 'ana', father: 'sebas', mother: 'lupe' },
  { name: 'jose', father: 'sebas', mother: 'lupe' },
  { name: 'carlos', father: null, mother: null },
  { name: 'luis', father: 'carlos', mother: 'pilar' },
  { name: 'emma', father: 'carlos', mother: 'pilar' },
  { name: 'lulu', father: 'ed', mother: 'clau' },
  { name: 'lupe', father: 'juan', mother: 'lulu' },
  { name: 'pepe', father: 'juan', mother: 'lulu' },
  { name: 'tam', father: 'juan', mother: 'lulu' },
  { name: 'dan', father: 'carlos', mother: 'lulu' },
  { name: 'cam', father: 'carlos', mother: 'lulu' },
  { name: 'emi', father: 'jose', mother: 'lulu' },
  { name: 'max', father: 'ed', mother: 'ana' }
]

</code>```

Body:
This algorithm determines the relationship between two members of a family, it does so only at a basic level, including parents, siblings, children, cousins, half-siblings, and uncles.

It seems that I need to extend this functionality to fourth and fifth degree members, that is, fourth cousins and fifth cousins.

export interface Member {
  name: string
  father: string | null
  mother: string | null
}
const determinateDeepRelationship = (p1: string, p2: string, fam: Member[]) => {
  const getParents = (
    p?: Member['name'] | null,
    fam?: Member[]
  ): Member | null => {
    const found = fam?.find((member) => member.name === p)
    return found || null
  }
  const p1Parents = getParents(p1, fam)
  const p2Parents = getParents(p2, fam)

  // **************************************** Are brothers

  if (
    p1Parents?.father === p2Parents?.father &&
    p1Parents?.mother === p2Parents?.mother
  ) {
    return 'hermano/hermana'
  }
  // **************************************** Are father or mother
  if (
    p2Parents?.mother === p1Parents?.name ||
    p2Parents?.father === p1Parents?.name
  ) {
    return 'padre/madre'
  }

  // **************************************** Are father or soon
  if (p1Parents?.mother === p2 || p1Parents?.father === p2) {
    return 'hija/hijo'
  }

  // **************************************** Are step brother or step sister or soon

  if (
    p1Parents?.father === p2Parents?.father ||
    p1Parents?.mother === p2Parents?.mother
  ) {
    return 'stepBrother'
  }

  // ****************************************  Are uncle or ant

  const getGrandparents = (p: string): (string | null)[] => {
    const parents = getParents(p, fam)

    const grandparents = [
      getParents(parents?.father, fam)?.father || null,
      getParents(parents?.father, fam)?.mother || null,
      getParents(parents?.mother, fam)?.father || null,
      getParents(parents?.mother, fam)?.mother || null
    ]
    return grandparents
  }

  const p2Grandparents = getGrandparents(p2)
  const p1Grandparents = getGrandparents(p1)

  // p1 is uncle of p2
  console.log({ p1Grandparents, p2Grandparents, p2, p1, p1Parents })

  // ****************************************  Are cousins
  for (let i = 0; i < p1Grandparents.length; i++) {
    for (let j = 0; j < p2Grandparents.length; j++) {
      if (
        (p2Grandparents[i] && p1Grandparents.includes(p2Grandparents[i])) ||
        (p1Grandparents[j] && p2Grandparents.includes(p1Grandparents[j]))
      )
        return 'primos/primas'
    }
  }

  for (let j = 0; j < [p1Parents?.father, p1Parents?.mother].length; j++) {
    for (let i = 0; i < p2Grandparents.length; i++) {
      if (
        p1Parents?.father === p2Grandparents[i] ||
        p1Parents?.mother === p2Grandparents[i] ||
        p1Parents?.father === p2Grandparents[j] ||
        p1Parents?.mother === p2Grandparents[j]
      )
        return 'tia/tio'
    }
  }

  // ****************************************  Are nice or nephew
  for (let i = 0; i < p1Grandparents.length; i++) {
    for (let j = 0; j < [p2Parents?.father, p2Parents?.mother].length; j++) {
      if (
        p2Parents?.father === p1Grandparents[i] ||
        p2Parents?.mother === p1Grandparents[i] ||
        p2Parents?.father === p1Grandparents[j] ||
        p2Parents?.mother === p1Grandparents[j]
      )
        return 'sobrino/sobrina'
    }
  }

  return 'any'
}

export default determinateDeepRelationship

This is the object that i use to test the algorimt

const family = [
  { name: 'mat', father: 'mike', mother: null },
  { name: 'luz', father: null, mother: 'deb' },
  { name: 'sebas', father: 'mat', mother: 'luz' },
  { name: 'pilar', father: 'mat', mother: 'luz' },
  { name: 'juan', father: 'mat', mother: 'luz' },
  { name: 'lupe2', father: null, mother: null },
  { name: 'ana', father: 'sebas', mother: 'lupe' },
  { name: 'jose', father: 'sebas', mother: 'lupe' },
  { name: 'carlos', father: null, mother: null },
  { name: 'luis', father: 'carlos', mother: 'pilar' },
  { name: 'emma', father: 'carlos', mother: 'pilar' },
  { name: 'lulu', father: 'ed', mother: 'clau' },
  { name: 'lupe', father: 'juan', mother: 'lulu' },
  { name: 'pepe', father: 'juan', mother: 'lulu' },
  { name: 'tam', father: 'juan', mother: 'lulu' },
  { name: 'dan', father: 'carlos', mother: 'lulu' },
  { name: 'cam', father: 'carlos', mother: 'lulu' },
  { name: 'emi', father: 'jose', mother: 'lulu' },
  { name: 'max', father: 'ed', mother: 'ana' }
]


问:
DISCORD JS v14: Different reply after using the command a second time
I was wondering, is there a way to se a different Bot Reply if a SLASH-Command is sent a second time? For example, I want to make a Bot where you can use a command 4 times a day - each time with another reply like "Your first use", "Your second use", etc.

Different Reply After Using Second/More times


问:
I want to send a magnet using transmission-remote in window
You could start downloading remotely from linux to
http://localhost:9091/transmission/web/
using the command in

transmission-remote 9091-nid:password -a {magnet}.

I want to do this on Windows as well.

I used Python and now installed transmission and daemon for window and confirmed that it works on the web.
But I don't know how to send a magnet.


问:
Argument of type 'FooBar' is not assignable to parameter of type 'JSONObject'. Index signature is missing in type 'FooBar'
My goal is to create a type called JSONObject for any JSON like object. The best I found so far is:

```<code>interface JSONObject {
    [x: string]: JSONValue;
}

interface JSONArray extends Array<JSONValue> { }
type JSONValue =
    | string
    | number
    | boolean
    | JSONObject
    | JSONArray;
</code>```

To be used in low level function like this:

function saveJson(data: JSONObject) { ... }

Which works for most cases but this case, it does not work

```<code>export interface FooBar {
    foo: number,
    bar: number,
}
const data: FooBar = await fetchSomething();
saveJson(data);
</code>```

With the compile time error:

Argument of type 'FooBar' is not assignable to parameter of type
'JSONObject'.   Index signature is missing in type 'FooBar'.

My goal to remove the error without touching FooBar

Body:
My goal is to create a type called JSONObject for any JSON like object. The best I found so far is:

interface JSONObject {
    [x: string]: JSONValue;
}

interface JSONArray extends Array<JSONValue> { }
type JSONValue =
    | string
    | number
    | boolean
    | JSONObject
    | JSONArray;

To be used in low level function like this:

function saveJson(data: JSONObject) { ... }

Which works for most cases but this case, it does not work

export interface FooBar {
    foo: number,
    bar: number,
}
const data: FooBar = await fetchSomething();
saveJson(data);

With the compile time error:

Argument of type 'FooBar' is not assignable to parameter of type
'JSONObject'.   Index signature is missing in type 'FooBar'.

My goal to remove the error without touching FooBar


问:
SMB Direct Between WIN10 Enterprise and WIN 10 Pro
I want to configure SMB Direct using IWARP on my Computer.
I use Network Adapter T6225-CR both side, and i can find this Adapter on my device Manager.
And Server OS is Window 10 enterprise and Client Window 10 Pro.

When i type command Get-AdapterRDMA and Get-SmbClientNetworkInterface, RdmaCapable return true.
But, netstat -xan Command show Nothing on powerShell.
And share folder IO packet is not RDMA/DDP packet ON WireShark. It's just smb2 and isn't have IWARP Property and SMB Direct Property.
Do I have to use the server OS?

RDMA Communication using SMB Direct Between my ServerPC And ClientPC,
I Want to check RDMA Packet on WireShark and Performance Monitor


问:
Why can't I store the return value of a shell function by variable assignment?
```<code>function double {
    read -p "Enter the value: " value
    return $(($value * 2))
}

result=$(double)

echo "The new result is $result."
</code>```

When I run this piece of code the echo command doesn't print the computed value, but when I changed result=$(double) to double; result=$? it worked. Why can't I just assign the return value directly?

Body:
function double {
    read -p "Enter the value: " value
    return $(($value * 2))
}

result=$(double)

echo "The new result is $result."

When I run this piece of code the echo command doesn't print the computed value, but when I changed result=$(double) to double; result=$? it worked. Why can't I just assign the return value directly?


问:
VBA Solver Function to Loop Through Columns
I have a solver function that needs to be applied in 3 columns. I made the following VBA code in order to run the three solver functions with one VBA button.

```<code>Sub Solver1a()
    Dim c As Range
    Set c = ActiveSheet.Range("B11")
    Solver1b c
End Sub

Sub Solver1b(c As Range)
    Dim m  As Long

    For m = 1 To 3
        SolverReset

        SolverOk SetCell:=c.Address(), MaxMinVal:=3, ValueOf:=c.Offset(5, 0), _
                ByChange:=c.Offset(3, 0).Address(), Engine:=1, EngineDesc:="Simplex LP"

        SolverSolve True
        SolverSolve UserFinish:=True
        SolverFinish KeepFinal:=1

        Set c = c.Offset(0, 1)
    Next m
End Sub
</code>```

But it doesn't work when I run the code, it just says "Preparing Problem" in the lower left corner of the spreadsheet. I suppose it's loading but given that is solving three linear problems with no constraints I don't think it should take so long to solve.

Body:
I have a solver function that needs to be applied in 3 columns. I made the following VBA code in order to run the three solver functions with one VBA button.

Sub Solver1a()
    Dim c As Range
    Set c = ActiveSheet.Range("B11")
    Solver1b c
End Sub

Sub Solver1b(c As Range)
    Dim m  As Long

    For m = 1 To 3
        SolverReset

        SolverOk SetCell:=c.Address(), MaxMinVal:=3, ValueOf:=c.Offset(5, 0), _
                ByChange:=c.Offset(3, 0).Address(), Engine:=1, EngineDesc:="Simplex LP"

        SolverSolve True
        SolverSolve UserFinish:=True
        SolverFinish KeepFinal:=1

        Set c = c.Offset(0, 1)
    Next m
End Sub

But it doesn't work when I run the code, it just says "Preparing Problem" in the lower left corner of the spreadsheet. I suppose it's loading but given that is solving three linear problems with no constraints I don't think it should take so long to solve.


问:
How to display a circular image in place of an icon in React?
Please bear with me, I'm very new to React and very much in over my head.

```<code>              <VerticalTimelineElement
                className="timeline-element-custom"
                date="2222"
                iconStyle={{ background: 'rgb(1, 1, 1)', color: '#aaa' }}
                icon={<TimelineIcon iconClass="icon_name"/>}
              >
</code>```

In the above code segment, you can see where it has an icon selected to be displayed. Instead of icon, I want an image to be displayed. I removed iconStyle, and changed icon={(stuff)} to be img src = {image}. When I load the website, it does not show my image, but instead text that says "static image [imagename]" on white background. Any tips on how to edit this to use a custom image?

Here is the definition of verticaltimelineelement

```<code>
import * as React from "react";

export interface VerticalTimelineProps {
    animate?: boolean | undefined;
    children?: React.ReactNode;
    className?: string | undefined;
    layout?: '1-column' | '1-column-left' | '1-column-right' | '2-columns' | undefined;
    lineColor?: string | undefined;
}

export interface VerticalTimelineElementProps {
    children?: React.ReactNode;
    id?: string | undefined;
    className?: string | undefined;
    date?: string | undefined;
    dateClassName?: string | undefined;
    iconClassName?: string | undefined;
    iconOnClick?: (() => void) | undefined;
    iconStyle?: React.CSSProperties | undefined;
    icon?: React.ReactNode | undefined;
    intersectionObserverProps?: any;
    onTimelineElementClick?: (() => void) | undefined;
    position?: string | undefined;
    style?: React.CSSProperties | undefined;
    textClassName?: string | undefined;
    contentStyle?: React.CSSProperties | undefined;
    contentArrowStyle?: React.CSSProperties | undefined;
    visible?: boolean | undefined;
}

export class VerticalTimeline extends React.Component<VerticalTimelineProps> { }
export class VerticalTimelineElement extends React.Component<VerticalTimelineElementProps> { }
</code>```

Body:
Please bear with me, I'm very new to React and very much in over my head.

              <VerticalTimelineElement
                className="timeline-element-custom"
                date="2222"
                iconStyle={{ background: 'rgb(1, 1, 1)', color: '#aaa' }}
                icon={<TimelineIcon iconClass="icon_name"/>}
              >

In the above code segment, you can see where it has an icon selected to be displayed. Instead of icon, I want an image to be displayed. I removed iconStyle, and changed icon={(stuff)} to be img src = {image}. When I load the website, it does not show my image, but instead text that says "static image [imagename]" on white background. Any tips on how to edit this to use a custom image?

Here is the definition of verticaltimelineelement

import * as React from "react";

export interface VerticalTimelineProps {
    animate?: boolean | undefined;
    children?: React.ReactNode;
    className?: string | undefined;
    layout?: '1-column' | '1-column-left' | '1-column-right' | '2-columns' | undefined;
    lineColor?: string | undefined;
}

export interface VerticalTimelineElementProps {
    children?: React.ReactNode;
    id?: string | undefined;
    className?: string | undefined;
    date?: string | undefined;
    dateClassName?: string | undefined;
    iconClassName?: string | undefined;
    iconOnClick?: (() => void) | undefined;
    iconStyle?: React.CSSProperties | undefined;
    icon?: React.ReactNode | undefined;
    intersectionObserverProps?: any;
    onTimelineElementClick?: (() => void) | undefined;
    position?: string | undefined;
    style?: React.CSSProperties | undefined;
    textClassName?: string | undefined;
    contentStyle?: React.CSSProperties | undefined;
    contentArrowStyle?: React.CSSProperties | undefined;
    visible?: boolean | undefined;
}

export class VerticalTimeline extends React.Component<VerticalTimelineProps> { }
export class VerticalTimelineElement extends React.Component<VerticalTimelineElementProps> { }


问:
Apple script to change a colour of an SVG prompting a message in finder to include the new HEX code, copy it in the clipboard with the new color
I'm trying to do an apple script that can do the following:

I have an icon SVG called "bubble.svg" in a folder in a folder called "test" in the desktop.
Is it possible to create an apple script to change the hex colour of the icon so that when I will run the script it will prompt me a window to include the new HEX colour of the icon, and copy the svg with the new colour to the clipboard so that I can past it in application with the new colour?

I used the following code and get this error

```<code> on run
    set theHex to text returned of (display dialog "Enter the new HEX color for the icon:" default answer "#FFFFFF")
    set theFile to (choose file with prompt "Select the SVG file to modify:")
    set theFileContents to read file theFile
    set theFileContents to (do shell script "sed 's/#000000/" & theHex & "/g' < " & theFile)
    set theFile to open for access theFile with write permission
    write theFileContents to theFile starting at eof
    close access theFile
    set the clipboard to theHex
end run
</code>```

In can include the new colour and the select the file, but then I get the following error

```<code>ERROR error "sh: Macintosh: No such file or directory" number 1
</code>```

Can you help me?
Thank you!

I used the following

```<code>on run
    set theHex to text returned of (display dialog "Enter the new HEX color for the icon:" default answer "#FFFFFF")
    set theFile to (choose file with prompt "Select the SVG file to modify:")
    set theFileContents to read file theFile
    set theFileContents to (do shell script "sed 's/#000000/" & theHex & "/g' < " & theFile)
    set theFile to open for access theFile with write permission
    write theFileContents to theFile starting at eof
    close access theFile
    set the clipboard to theHex
end run
</code>```

Body:
I'm trying to do an apple script that can do the following:

I have an icon SVG called "bubble.svg" in a folder in a folder called "test" in the desktop.
Is it possible to create an apple script to change the hex colour of the icon so that when I will run the script it will prompt me a window to include the new HEX colour of the icon, and copy the svg with the new colour to the clipboard so that I can past it in application with the new colour?

I used the following code and get this error

 on run
    set theHex to text returned of (display dialog "Enter the new HEX color for the icon:" default answer "#FFFFFF")
    set theFile to (choose file with prompt "Select the SVG file to modify:")
    set theFileContents to read file theFile
    set theFileContents to (do shell script "sed 's/#000000/" & theHex & "/g' < " & theFile)
    set theFile to open for access theFile with write permission
    write theFileContents to theFile starting at eof
    close access theFile
    set the clipboard to theHex
end run

In can include the new colour and the select the file, but then I get the following error

ERROR error "sh: Macintosh: No such file or directory" number 1

Can you help me?
Thank you!

I used the following

on run
    set theHex to text returned of (display dialog "Enter the new HEX color for the icon:" default answer "#FFFFFF")
    set theFile to (choose file with prompt "Select the SVG file to modify:")
    set theFileContents to read file theFile
    set theFileContents to (do shell script "sed 's/#000000/" & theHex & "/g' < " & theFile)
    set theFile to open for access theFile with write permission
    write theFileContents to theFile starting at eof
    close access theFile
    set the clipboard to theHex
end run


问:
Most efficient way of calculating big terrain collision mesh
I'm using Unity Engine to make a space exploration game. I have to implement the collision system for the planet I made with quadsphere and quadtree LOD, I thought of two ways:

Generate a BIG mesh collider for the hole planet and keep the collision activated only for the face that the player is in (the planet has 6 faces). This works fine because the mesh is created only one time, but the game keeps a mesh collider bigger than needed in the scene.

Use the quadtree LOD and create a new mesh collider every second, but just for the high resolution terrain near the player. The mesh collider used in this option is way less bigger than the first option, but is updated every second.

Which way is more approachable? And there are more efficient methods than these two?


问:
React Native Axios re-fetch data if no data exist or network error
I have a React Native project. I need to fetch data. Some times the data I fetch my be empty. Is there a way to re-fetch after x amount of seconds if the data is not fetch or if there is a network error</p>
```<code>const [data, setData]= useState([])

useEffect(()=> {
    axios
    .get("https://finalspaceapi.com/api/v0/character/?limit=2")
    .then(function (response) {
        console.log(response);
        setData(response.data)
    })
    .catch(()=>{
       console.log("error re-fetch")
    })

},[])
</code>```

Body:
I have a React Native project. I need to fetch data. Some times the data I fetch my be empty. Is there a way to re-fetch after x amount of seconds if the data is not fetch or if there is a network error

const [data, setData]= useState([])

useEffect(()=> {
    axios
    .get("https://finalspaceapi.com/api/v0/character/?limit=2")
    .then(function (response) {
        console.log(response);
        setData(response.data)
    })
    .catch(()=>{
       console.log("error re-fetch")
    })

},[])


问:
Swift AVPlayer Video freeze
guys
I am making a project that plays video using Swift AVPlayer.
There is a problem that the video stops, or there is only sound but no video.
When a video URL is received and played through AVPlyer, the file extension is HLS (.m3u8)
Same issue with both AVPlayer and Safari. However, it plays normally in Chrome.

Is it a video file problem? Or is there something the app needs to handle?

This is the sample video URL I am using

https://demo.unified-streaming.com/k8s/features/stable/video/tears-of-steel/tears-of-steel.ism/.m3u8

https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8

http://d3rlna7iyyu8wu.cloudfront.net/skip_armstrong/skip_armstrong_stereo_subs.m3u8

self.playerItem = AVPlayerItem(url: URL(string: urlString)!)
        self.playerItem?.addObserver(self, forKeyPath: #keyPath(AVPlayerItem.status), options: [.initial, .new], context: &self.playerItemContext)
        self.playerItemObserver = true

if self.player == nil {
    self.player = AVPlayer(playerItem: self.playerItem)
    self.playerLayer = AVPlayerLayer(player: self.player)
    self.player?.play()
    return
}
```

I am using the above code to insert the url and play it.

Title: Swift AVPlayer Video freeze

Body:
guys
I am making a project that plays video using Swift AVPlayer.
There is a problem that the video stops, or there is only sound but no video.
When a video URL is received and played through AVPlyer, the file extension is HLS (.m3u8)
Same issue with both AVPlayer and Safari. However, it plays normally in Chrome.

Is it a video file problem? Or is there something the app needs to handle?

This is the sample video URL I am using

https://demo.unified-streaming.com/k8s/features/stable/video/tears-of-steel/tears-of-steel.ism/.m3u8

https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_fmp4/master.m3u8

http://d3rlna7iyyu8wu.cloudfront.net/skip_armstrong/skip_armstrong_stereo_subs.m3u8

self.playerItem = AVPlayerItem(url: URL(string: urlString)!)
        self.playerItem?.addObserver(self, forKeyPath: #keyPath(AVPlayerItem.status), options: [.initial, .new], context: &self.playerItemContext)
        self.playerItemObserver = true

if self.player == nil {
    self.player = AVPlayer(playerItem: self.playerItem)
    self.playerLayer = AVPlayerLayer(player: self.player)
    self.player?.play()
    return
}

I am using the above code to insert the url and play it.


问:
How to send message using Tibco RV to asynchronous way?
Currently, I make the Server to send the message using Tibco RV 8.5 version.

I used NetTransport to send the message.

However, I get request to send all message to async way.

So, I look through the document, but there's no way to send the message to asynchronous way in Tibco RV 8.5 version.

How can I send the message async way using Tibco RV?

I would appreciate it if you could let me know by reference or link.

Thanks in advance.

https://docs.tibco.com/pub/rendezvous/8.6.0/doc/pdf/TIB_rv_8.6.0_dotnet_reference.pdf?id=5

I look through the related document, but every SendRequest library send message in synchronous way.

If Tibco RV doesn't provide async method, I want to know how to send the message to async way.

Thanks in advance.


问:
How to use TigerGraph GSQL to associate data from one Vertex to another Vertex?
I am a beginner and trying to make several Vertex shown on the TigerGraph Insights Map Widget.

The Map widget displays vertex attributes as latitude and longitude, and I have shown the Location Vertex on the Map Widget successfully.

But the other Vertex cannot be shown on Map Widget due to no latitude and longitude data.

I have large CSV file of latitude and longitude for the “Location Vertex” and want to use GSQL to traverse these geolocation attributes to another Vertex, finally these Vertexes could be displayed on the map widget.

For example, my Vertex relations are shown in the pic.

Vertex & Edge

I want to find out whether there is a way to display the result of a GSQL that we would create in order to query the graph and associate dynamically the longitude and latitude data from a location to the corresponding action Vertex.

How can I use GSQL to associate these geolocation attributes from “Location Vertex” to “Action Vertex”?


问:
How to test AlertDialog using Mockk
I have a function inside my activity like this.

```<code>class MyActivity : AppCompatActivity() {
    ...
    fun functionUndertested() {
        AlertDialog.Builder(this, R.style.AppTheme)
            .setTitle("MyTitle")
            .create()
    }
}
</code>```

I want to test the functionUndertested() to verify whether .setTitle is successfully executed.

I am a new bee on the Mockk library, and I failed to find a similar example in the Mockk document. This issue has blocked me for some days.

I will be appreciated it if someone could tell me how to implement the test case.

Title: How to test AlertDialog using Mockk

Body:
I have a function inside my activity like this.

class MyActivity : AppCompatActivity() {
    ...
    fun functionUndertested() {
        AlertDialog.Builder(this, R.style.AppTheme)
            .setTitle("MyTitle")
            .create()
    }
}

I want to test the functionUndertested() to verify whether .setTitle is successfully executed.

I am a new bee on the Mockk library, and I failed to find a similar example in the Mockk document. This issue has blocked me for some days.

I will be appreciated it if someone could tell me how to implement the test case.


问:
How can I override ngb date picker custom footer template?
I'm using ng-bootstrap-datepicker and trying to apply footer template.
(refer this : https://ng-bootstrap.github.io/#/components/datepicker/examples#footertemplate)

(use version : "@ng-bootstrap/ng-bootstrap": "^6.0.2")

So can I override custom footer template for NgbDatepickerConfig?
NgbDatepickerConfig

If i cannot do this way, is there any way possible?

Please help!


问:
RemoteAction in Promise doesn't work at all. no request receiving - in visualforce page
I use jspdf lib and some kind of lib that converting dom element into image(dom-to-image), because jspdf setfont is not properly working. (Korean lang is not encoded or working in fonts)

First I convert DOM element into image, and I put that image into pdf by jspdf, after that I get the datauri from jspdf. I confirmed uri was properly made, but remote action is not working. only shows empty white page

-----javascript in visualforce page

```<code>    var quoteId = '{!Quote.Id}';

    function saveDOM() {
        if (domtoimage) {
            var node = document.getElementById('DomElement');
            var promises = [];

            promises.push(domtoimage.toPng(node, {quality : 1.0, bgcolor : '#fff', width : 950}));
            Promise.all(promises).then(function(results) {
                var dataUrl = results[0];

                if(quoteId, dataUrl) {
                    var attBody = dataUrl.split(',')[1];

                    return new Promise((resolve, reject) => {
                        window.jsPDF = window.jspdf.jsPDF;
                        window.html2canvas = html2canvas;

                        var doc = new jsPDF();
                        doc.addImage(attBody, 'PNG', 1, 10, 200, Math.floor(node.offsetHeight/4.7));

                        resolve(doc.output('datauri'));

                    }).then((result) => {
                        if(result){
                            var pdfBody = result.split(',')[1];

                            Visualforce.remoting.Manager.invokeAction(
                                '{!$RemoteAction.SaveAsPdfExtension.savePDF}',
                                pdfBody, quoteId,
                                function(result, event) {
                                    if(event.status && result) {
                                        alert('success!');
                                        window.location.href = '/' + quoteId;
                                    } else {
                                        alert('Something went wrong, please refresh the page.');
                                    }
                                }
                            );

                        }
                    })
                }
            }).catch(function (error) {
                console.error('oops, something went wrong!', error);
            });
        } else {
            alert('Something went wrong, please refresh the page.');
        }
    }
</code>```

-------------------apex controller

```<code>@RemoteAction
global static Boolean savePDF(String body, String parentId) {

    QuoteDocument qd = new QuoteDocument();

    qd.Document = EncodingUtil.base64Decode(body);
    qd.QuoteId = parentId;

    Database.SaveResult res = Database.insert(qd);

    return res.isSuccess();
}
</code>```

I don't know why requests are not received in controller.
if use jspdf.save() instead of output('datauri') and not request to the controller, it works properly.(download pdf document and it's perfect)
or pass the step that put image on pdf and just send image uri to controller, then it works properly too. (image is uploaded in attachment, and it's perfect too - when I change the apex code into making attachment)
but when it comes to combine these two steps together, controller never receives any requests.

please help

Body:
I use jspdf lib and some kind of lib that converting dom element into image(dom-to-image), because jspdf setfont is not properly working. (Korean lang is not encoded or working in fonts)

First I convert DOM element into image, and I put that image into pdf by jspdf, after that I get the datauri from jspdf. I confirmed uri was properly made, but remote action is not working. only shows empty white page

-----javascript in visualforce page

    var quoteId = '{!Quote.Id}';

    function saveDOM() {
        if (domtoimage) {
            var node = document.getElementById('DomElement');
            var promises = [];

            promises.push(domtoimage.toPng(node, {quality : 1.0, bgcolor : '#fff', width : 950}));
            Promise.all(promises).then(function(results) {
                var dataUrl = results[0];

                if(quoteId, dataUrl) {
                    var attBody = dataUrl.split(',')[1];

                    return new Promise((resolve, reject) => {
                        window.jsPDF = window.jspdf.jsPDF;
                        window.html2canvas = html2canvas;

                        var doc = new jsPDF();
                        doc.addImage(attBody, 'PNG', 1, 10, 200, Math.floor(node.offsetHeight/4.7));

                        resolve(doc.output('datauri'));

                    }).then((result) => {
                        if(result){
                            var pdfBody = result.split(',')[1];

                            Visualforce.remoting.Manager.invokeAction(
                                '{!$RemoteAction.SaveAsPdfExtension.savePDF}',
                                pdfBody, quoteId,
                                function(result, event) {
                                    if(event.status && result) {
                                        alert('success!');
                                        window.location.href = '/' + quoteId;
                                    } else {
                                        alert('Something went wrong, please refresh the page.');
                                    }
                                }
                            );

                        }
                    })
                }
            }).catch(function (error) {
                console.error('oops, something went wrong!', error);
            });
        } else {
            alert('Something went wrong, please refresh the page.');
        }
    }

-------------------apex controller

@RemoteAction
global static Boolean savePDF(String body, String parentId) {

    QuoteDocument qd = new QuoteDocument();

    qd.Document = EncodingUtil.base64Decode(body);
    qd.QuoteId = parentId;

    Database.SaveResult res = Database.insert(qd);

    return res.isSuccess();
}

I don't know why requests are not received in controller.
if use jspdf.save() instead of output('datauri') and not request to the controller, it works properly.(download pdf document and it's perfect)
or pass the step that put image on pdf and just send image uri to controller, then it works properly too. (image is uploaded in attachment, and it's perfect too - when I change the apex code into making attachment)
but when it comes to combine these two steps together, controller never receives any requests.

please help


问:
cocoapods's version is 1.11.3 and I want to downgrade with 1.11.2
terminal image

Now, cocoapods's version is 1.11.3 and I want to downgrade with 1.11.2

I used these code to downGrade xcode version.
sudo gem uninstall cocoapods
sudo gem install cocoapods -v 1.11.2

However, If I used this code, still cocoapods's version is 1.11.3
pod --version

I want to know what should I do now...

Now, cocoapods's version is 1.11.3 and I want to downgrade with 1.11.2 !
Please help me..