问:
How use media-quires in CSS?
I'm making web-site , and i need make adaptive site. So i began use media-quires and got a trouble. When screen resolution has been changing  in example since 2560px to 1920px , some styles remain in site, however they hasn't written in code CSS, why ?

```<code>@media only screen and (max-width: 2560px ) {
    body {
        background-color: #344B56;
        color: white;
        font-family: Montserrat;
        margin: 0px;
        padding-top: 20px;
    }

    .container {
        margin: 0 auto;
    }

    .info {
        display: flex;
        justify-content: space-around;
        align-items: flex-start;
        padding-bottom: 5px;
    }

    .company {
        text-decoration: none;
        color: white;
        display: flex;
        flex-direction: column;
        justify-content: flex-start;
        align-items: flex-start;
        font-size: 30px;
        text-align: center;
    }

        .company p {
            margin: 0px;
        }

    .hours, .adress, .callback {
        display: flex;
        align-items: flex-start;
    }

    .logo {
        width: 50px;
        padding-top: 12px;
        padding-right: 10px;
    }

    .navbar {
        display: flex;
        justify-content: space-evenly;
        padding: 20px;
        border-top: 1px white solid;
        border-radius: 50px;
    }

    .completed {
        font-size: 20px;
        font-family: Montserrat;
        border-bottom: 2px skyblue solid;
        border-radius: 5px;
        margin: 0px;
        padding: 0px;
    }

    .navbar a {
        letter-spacing: -2px;
        color: white;
        font-size: 20px;
        font-family: Montserrat;
        text-decoration: none;
    }

        .navbar a:hover {
            color: skyblue;
        }

    .company_info {
        display: flex;
        justify-content: space-around;
        align-items: center;
        background-color: #323a42;
    }

    .company_text {
        display: flex;
        flex-direction: column;
        width: 500px;
        padding: 50px;
    }

    .infoCompany {
        background-image: url("./images/companyBack.jpeg");
        background-position: center center;
        background-size: cover;
        width: 100%;
        height: 600px;
    }

    .infoCompany__Text {
        display: flex;
        flex-direction: column;
        color: white;
        width: 100%;
        font-size: 26px;
    }

    .infoCompany__Text_Company {
        display: flex;
        margin-top: 100px;
        margin-left: 200px;
    }

    .Service {
        margin-top: 50px;
        margin-left: 200px;
        margin-right: 200px;
        color: white;
        font-size: 24px;
    }

    .Service__Products {
        display: flex;
        flex-wrap: wrap;
        justify-content: space-between;
        width: 100%;
    }

    .Service__Products_Product {
        display: flex;
        flex-direction: column;
        margin-top: 50px;
    }

        .Service__Products_Product:not(first-child) {
            margin-left: 150px;
        }

    .Product__img {
        width: 500px;
        height: 402px;
        border-top-left-radius: 30px;
        border-top-right-radius: 30px;
    }

    .Product__DownPartCard {
        display: flex;
    }

    .Product__LeftDivCard {
        width: 24px;
        height: 98px;
        background-color: #1A81AD;
    }

    .Product__NameCardDiv {
        width: 476px;
        height: 98px;
        background: white;
    }

    .Product__DownPartCard_Text {
        font-size: 18px;
        display: flex;
        color: black;
        padding-left: 15px;
        padding-top: 30px;
    }

    .Garant {
        color: white;
        margin-top: 100px;
        margin-left: 200px;
        margin-right: 200px;
        color: white;
        font-size: 24px;
    }

    .Garant__Garants {
        margin-top: 70px;
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
    }

    .Garant__Card {
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        text-align: center;
    }

    .Gatant__Card_Img {
        width: 150px;
        height: 150px;
    }

    .Gatant__Card_Text {
        font-size: 16px;
    }

    footer {
        margin-top: 70px;
        position: absolute;
        width: 100%;
        border-top: 1px white solid;
    }

    .invisible {
        opacity: 0;
    }
}

@media only screen and (max-width: 1920px ) {
    body {
        background-color: #344B56;
        color: white;
        font-family: Montserrat;
        margin: 0px;
        padding-top: 20px;
    }

    .container {
        margin: 0 auto;
    }

    .info {
        display: flex;
        justify-content: space-around;
        align-items: flex-start;
        padding-bottom: 5px;
    }

    .company {
        text-decoration: none;
        color: white;
        display: flex;
        flex-direction: column;
        justify-content: flex-start;
        align-items: flex-start;
        font-size: 30px;
        text-align: center;
    }

        .company p {
            margin: 0px;
        }

    .hours, .adress, .callback {
        display: flex;
        align-items: flex-start;
    }

    .logo {
        width: 50px;
        padding-top: 12px;
        padding-right: 10px;
    }

    .navbar {
        display: flex;
        justify-content: space-evenly;
        padding: 20px;
        border-top: 1px white solid;
        border-radius: 50px;
    }

    .completed {
        font-size: 20px;
        font-family: Montserrat;
        border-bottom: 2px skyblue solid;
        border-radius: 5px;
        margin: 0px;
        padding: 0px;
    }

    .navbar a {
        letter-spacing: -2px;
        color: white;
        font-size: 20px;
        font-family: Montserrat;
        text-decoration: none;
    }

        .navbar a:hover {
            color: skyblue;
        }

    .company_info {
        display: flex;
        justify-content: space-around;
        align-items: center;
        background-color: #323a42;
    }

    .company_text {
        display: flex;
        flex-direction: column;
        width: 500px;
        padding: 50px;
    }

    .infoCompany {
        background-image: url("./images/companyBack.jpeg");
        background-position: center center;
        background-size: cover;
        width: 100%;
        height: 600px;
    }

    .infoCompany__Text {
        display: flex;
        flex-direction: column;
        color: white;
        width: 100%;
        font-size: 26px;
    }

    .infoCompany__Text_Company {
        display: flex;
        margin-top: 100px;
        margin-left: 200px;
    }

    .Service {
        margin-top: 50px;
        margin-left: 200px;
        margin-right: 200px;
        color: white;
        font-size: 24px;
    }

    .Service__Products {
        display: flex;
        flex-wrap: wrap;
        justify-content: space-between;
        width: 100%;
    }

    .Service__Products_Product {
        display: flex;
        flex-direction: column;
        margin-top: 50px;
    }

    .Product__img {
        width: 400px;
        height: 302px;
        border-top-left-radius: 30px;
        border-top-right-radius: 30px;
    }

    .Product__DownPartCard {
        display: flex;
    }

    .Product__LeftDivCard {
        width: 12px;
        height: 98px;
        background-color: #1A81AD;
    }

    .Product__NameCardDiv {
        width: 388px;
        height: 98px;
        background: white;
    }

    .Product__DownPartCard_Text {
        font-size: 15px;
        display: flex;
        color: black;
        padding-left: 15px;
        padding-top: 30px;
    }

    .Garant {
        color: white;
        margin-top: 100px;
        margin-left: 200px;
        margin-right: 200px;
        color: white;
        font-size: 24px;
    }

    .Garant__Garants {
        margin-top: 70px;
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
    }

    .Garant__Card {
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        text-align: center;
    }

    .Gatant__Card_Img {
        width: 150px;
        height: 150px;
    }

    .Gatant__Card_Text {
        font-size: 16px;
    }

    footer {
        margin-top: 70px;
        position: absolute;
        width: 100%;
        border-top: 1px white solid;
    }

    .invisible {
        opacity: 0;
    }
}

@media only screen and (max-width: 1500px) {
    body {
        background-color: #344B56;
        color: white;
        font-family: Montserrat;
        margin: 0px;
        padding-top: 20px;
    }

    .container {
        margin: 0 auto;
    }

    .info {
        display: flex;
        justify-content: space-around;
        align-items: flex-start;
        padding-bottom: 5px;
    }

    .company {
        text-decoration: none;
        color: white;
        display: flex;
        flex-direction: column;
        justify-content: flex-start;
        align-items: flex-start;
        font-size: 30px;
        text-align: center;
    }

        .company p {
            margin: 0px;
        }

    .hours, .adress, .callback {
        display: flex;
        align-items: flex-start;
    }

    .logo {
        width: 50px;
        padding-top: 12px;
        padding-right: 10px;
    }

    .navbar {
        display: flex;
        justify-content: space-evenly;
        padding: 20px;
        border-top: 1px white solid;
        border-radius: 50px;
    }

    .completed {
        font-size: 20px;
        font-family: Montserrat;
        border-bottom: 2px skyblue solid;
        border-radius: 5px;
        margin: 0px;
        padding: 0px;
    }

    .navbar a {
        letter-spacing: -2px;
        color: white;
        font-size: 20px;
        font-family: Montserrat;
        text-decoration: none;
    }

        .navbar a:hover {
            color: skyblue;
        }

    .company_info {
        display: flex;
        justify-content: space-around;
        align-items: center;
        background-color: #323a42;
    }

    .company_text {
        display: flex;
        flex-direction: column;
        width: 500px;
        padding: 50px;
    }

    .infoCompany {
        background-image: url("./images/companyBack.jpeg");
        background-position: center center;
        background-size: cover;
        width: 100%;
        height: 600px;
    }

    .infoCompany__Text {
        display: flex;
        flex-direction: column;
        color: white;
        width: 100%;
        font-size: 26px;
    }

    .infoCompany__Text_Company {
        display: flex;
        margin-top: 100px;
        margin-left: 200px;
    }

    .Service {
        color: white;
        font-size: 24px;
        text-align: center;
    }

    .Service__Products {
        display: flex;
        flex-wrap: wrap;
    }

    .Service__Products_Product {
        width: 100%;
        display: flex;
        flex-direction: column;
        margin: 50px 0 0 0;
    }

    .Product__img {
        width: 400px;
        height: 302px;
        border-top-left-radius: 30px;
        border-top-right-radius: 30px;
    }

    .Product__downPartCard {
        display: flex;
    }

    .Product__leftDivCard {
        width: 12px;
        height: 98px;
        background-color: #1A81AD;
    }

    .Product__NameCardDiv {
        width: 388px;
        height: 98px;
        background: white;
    }

    .Product__DownPartCard_Text {
        font-size: 15px;
        display: flex;
        color: black;
        padding-left: 15px;
        padding-top: 30px;
    }

    .Garant {
        color: white;
        margin-top: 100px;
        margin-left: 200px;
        margin-right: 200px;
        color: white;
        font-size: 24px;
    }

    .Garant__Garants {
        margin-top: 70px;
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
    }

    .Garant__Card {
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        text-align: center;
    }

    .Gatant__Card_Img {
        width: 150px;
        height: 150px;
    }

    .Gatant__Card_Text {
        font-size: 16px;
    }

    footer {
        margin-top: 70px;
        position: absolute;
        width: 100%;
        border-top: 1px white solid;
    }

    .invisible {
        opacity: 0;
    }
}

</code>```

So "margin-left: 150px ;" from media 2560px  somehow using in 1920px, why ?

```<code>.Service__products_Product:not(first-child) {
    margin-left: 150px ;
}
</code>```

Title: How use media-quires in CSS?

Body:
I'm making web-site , and i need make adaptive site. So i began use media-quires and got a trouble. When screen resolution has been changing  in example since 2560px to 1920px , some styles remain in site, however they hasn't written in code CSS, why ?

@media only screen and (max-width: 2560px ) {
    body {
        background-color: #344B56;
        color: white;
        font-family: Montserrat;
        margin: 0px;
        padding-top: 20px;
    }

    .container {
        margin: 0 auto;
    }

    .info {
        display: flex;
        justify-content: space-around;
        align-items: flex-start;
        padding-bottom: 5px;
    }

    .company {
        text-decoration: none;
        color: white;
        display: flex;
        flex-direction: column;
        justify-content: flex-start;
        align-items: flex-start;
        font-size: 30px;
        text-align: center;
    }

        .company p {
            margin: 0px;
        }

    .hours, .adress, .callback {
        display: flex;
        align-items: flex-start;
    }

    .logo {
        width: 50px;
        padding-top: 12px;
        padding-right: 10px;
    }

    .navbar {
        display: flex;
        justify-content: space-evenly;
        padding: 20px;
        border-top: 1px white solid;
        border-radius: 50px;
    }

    .completed {
        font-size: 20px;
        font-family: Montserrat;
        border-bottom: 2px skyblue solid;
        border-radius: 5px;
        margin: 0px;
        padding: 0px;
    }

    .navbar a {
        letter-spacing: -2px;
        color: white;
        font-size: 20px;
        font-family: Montserrat;
        text-decoration: none;
    }

        .navbar a:hover {
            color: skyblue;
        }

    .company_info {
        display: flex;
        justify-content: space-around;
        align-items: center;
        background-color: #323a42;
    }

    .company_text {
        display: flex;
        flex-direction: column;
        width: 500px;
        padding: 50px;
    }

    .infoCompany {
        background-image: url("./images/companyBack.jpeg");
        background-position: center center;
        background-size: cover;
        width: 100%;
        height: 600px;
    }

    .infoCompany__Text {
        display: flex;
        flex-direction: column;
        color: white;
        width: 100%;
        font-size: 26px;
    }

    .infoCompany__Text_Company {
        display: flex;
        margin-top: 100px;
        margin-left: 200px;
    }

    .Service {
        margin-top: 50px;
        margin-left: 200px;
        margin-right: 200px;
        color: white;
        font-size: 24px;
    }

    .Service__Products {
        display: flex;
        flex-wrap: wrap;
        justify-content: space-between;
        width: 100%;
    }

    .Service__Products_Product {
        display: flex;
        flex-direction: column;
        margin-top: 50px;
    }

        .Service__Products_Product:not(first-child) {
            margin-left: 150px;
        }

    .Product__img {
        width: 500px;
        height: 402px;
        border-top-left-radius: 30px;
        border-top-right-radius: 30px;
    }

    .Product__DownPartCard {
        display: flex;
    }

    .Product__LeftDivCard {
        width: 24px;
        height: 98px;
        background-color: #1A81AD;
    }

    .Product__NameCardDiv {
        width: 476px;
        height: 98px;
        background: white;
    }

    .Product__DownPartCard_Text {
        font-size: 18px;
        display: flex;
        color: black;
        padding-left: 15px;
        padding-top: 30px;
    }

    .Garant {
        color: white;
        margin-top: 100px;
        margin-left: 200px;
        margin-right: 200px;
        color: white;
        font-size: 24px;
    }

    .Garant__Garants {
        margin-top: 70px;
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
    }

    .Garant__Card {
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        text-align: center;
    }

    .Gatant__Card_Img {
        width: 150px;
        height: 150px;
    }

    .Gatant__Card_Text {
        font-size: 16px;
    }

    footer {
        margin-top: 70px;
        position: absolute;
        width: 100%;
        border-top: 1px white solid;
    }

    .invisible {
        opacity: 0;
    }
}

@media only screen and (max-width: 1920px ) {
    body {
        background-color: #344B56;
        color: white;
        font-family: Montserrat;
        margin: 0px;
        padding-top: 20px;
    }

    .container {
        margin: 0 auto;
    }

    .info {
        display: flex;
        justify-content: space-around;
        align-items: flex-start;
        padding-bottom: 5px;
    }

    .company {
        text-decoration: none;
        color: white;
        display: flex;
        flex-direction: column;
        justify-content: flex-start;
        align-items: flex-start;
        font-size: 30px;
        text-align: center;
    }

        .company p {
            margin: 0px;
        }

    .hours, .adress, .callback {
        display: flex;
        align-items: flex-start;
    }

    .logo {
        width: 50px;
        padding-top: 12px;
        padding-right: 10px;
    }

    .navbar {
        display: flex;
        justify-content: space-evenly;
        padding: 20px;
        border-top: 1px white solid;
        border-radius: 50px;
    }

    .completed {
        font-size: 20px;
        font-family: Montserrat;
        border-bottom: 2px skyblue solid;
        border-radius: 5px;
        margin: 0px;
        padding: 0px;
    }

    .navbar a {
        letter-spacing: -2px;
        color: white;
        font-size: 20px;
        font-family: Montserrat;
        text-decoration: none;
    }

        .navbar a:hover {
            color: skyblue;
        }

    .company_info {
        display: flex;
        justify-content: space-around;
        align-items: center;
        background-color: #323a42;
    }

    .company_text {
        display: flex;
        flex-direction: column;
        width: 500px;
        padding: 50px;
    }

    .infoCompany {
        background-image: url("./images/companyBack.jpeg");
        background-position: center center;
        background-size: cover;
        width: 100%;
        height: 600px;
    }

    .infoCompany__Text {
        display: flex;
        flex-direction: column;
        color: white;
        width: 100%;
        font-size: 26px;
    }

    .infoCompany__Text_Company {
        display: flex;
        margin-top: 100px;
        margin-left: 200px;
    }

    .Service {
        margin-top: 50px;
        margin-left: 200px;
        margin-right: 200px;
        color: white;
        font-size: 24px;
    }

    .Service__Products {
        display: flex;
        flex-wrap: wrap;
        justify-content: space-between;
        width: 100%;
    }

    .Service__Products_Product {
        display: flex;
        flex-direction: column;
        margin-top: 50px;
    }

    .Product__img {
        width: 400px;
        height: 302px;
        border-top-left-radius: 30px;
        border-top-right-radius: 30px;
    }

    .Product__DownPartCard {
        display: flex;
    }

    .Product__LeftDivCard {
        width: 12px;
        height: 98px;
        background-color: #1A81AD;
    }

    .Product__NameCardDiv {
        width: 388px;
        height: 98px;
        background: white;
    }

    .Product__DownPartCard_Text {
        font-size: 15px;
        display: flex;
        color: black;
        padding-left: 15px;
        padding-top: 30px;
    }

    .Garant {
        color: white;
        margin-top: 100px;
        margin-left: 200px;
        margin-right: 200px;
        color: white;
        font-size: 24px;
    }

    .Garant__Garants {
        margin-top: 70px;
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
    }

    .Garant__Card {
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        text-align: center;
    }

    .Gatant__Card_Img {
        width: 150px;
        height: 150px;
    }

    .Gatant__Card_Text {
        font-size: 16px;
    }

    footer {
        margin-top: 70px;
        position: absolute;
        width: 100%;
        border-top: 1px white solid;
    }

    .invisible {
        opacity: 0;
    }
}

@media only screen and (max-width: 1500px) {
    body {
        background-color: #344B56;
        color: white;
        font-family: Montserrat;
        margin: 0px;
        padding-top: 20px;
    }

    .container {
        margin: 0 auto;
    }

    .info {
        display: flex;
        justify-content: space-around;
        align-items: flex-start;
        padding-bottom: 5px;
    }

    .company {
        text-decoration: none;
        color: white;
        display: flex;
        flex-direction: column;
        justify-content: flex-start;
        align-items: flex-start;
        font-size: 30px;
        text-align: center;
    }

        .company p {
            margin: 0px;
        }

    .hours, .adress, .callback {
        display: flex;
        align-items: flex-start;
    }

    .logo {
        width: 50px;
        padding-top: 12px;
        padding-right: 10px;
    }

    .navbar {
        display: flex;
        justify-content: space-evenly;
        padding: 20px;
        border-top: 1px white solid;
        border-radius: 50px;
    }

    .completed {
        font-size: 20px;
        font-family: Montserrat;
        border-bottom: 2px skyblue solid;
        border-radius: 5px;
        margin: 0px;
        padding: 0px;
    }

    .navbar a {
        letter-spacing: -2px;
        color: white;
        font-size: 20px;
        font-family: Montserrat;
        text-decoration: none;
    }

        .navbar a:hover {
            color: skyblue;
        }

    .company_info {
        display: flex;
        justify-content: space-around;
        align-items: center;
        background-color: #323a42;
    }

    .company_text {
        display: flex;
        flex-direction: column;
        width: 500px;
        padding: 50px;
    }

    .infoCompany {
        background-image: url("./images/companyBack.jpeg");
        background-position: center center;
        background-size: cover;
        width: 100%;
        height: 600px;
    }

    .infoCompany__Text {
        display: flex;
        flex-direction: column;
        color: white;
        width: 100%;
        font-size: 26px;
    }

    .infoCompany__Text_Company {
        display: flex;
        margin-top: 100px;
        margin-left: 200px;
    }

    .Service {
        color: white;
        font-size: 24px;
        text-align: center;
    }

    .Service__Products {
        display: flex;
        flex-wrap: wrap;
    }

    .Service__Products_Product {
        width: 100%;
        display: flex;
        flex-direction: column;
        margin: 50px 0 0 0;
    }

    .Product__img {
        width: 400px;
        height: 302px;
        border-top-left-radius: 30px;
        border-top-right-radius: 30px;
    }

    .Product__downPartCard {
        display: flex;
    }

    .Product__leftDivCard {
        width: 12px;
        height: 98px;
        background-color: #1A81AD;
    }

    .Product__NameCardDiv {
        width: 388px;
        height: 98px;
        background: white;
    }

    .Product__DownPartCard_Text {
        font-size: 15px;
        display: flex;
        color: black;
        padding-left: 15px;
        padding-top: 30px;
    }

    .Garant {
        color: white;
        margin-top: 100px;
        margin-left: 200px;
        margin-right: 200px;
        color: white;
        font-size: 24px;
    }

    .Garant__Garants {
        margin-top: 70px;
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
    }

    .Garant__Card {
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        text-align: center;
    }

    .Gatant__Card_Img {
        width: 150px;
        height: 150px;
    }

    .Gatant__Card_Text {
        font-size: 16px;
    }

    footer {
        margin-top: 70px;
        position: absolute;
        width: 100%;
        border-top: 1px white solid;
    }

    .invisible {
        opacity: 0;
    }
}

So "margin-left: 150px ;" from media 2560px  somehow using in 1920px, why ?

.Service__products_Product:not(first-child) {
    margin-left: 150px ;
}


来源: stackexchange

问:
Draw cross on a picture box and get center coordinates EMGU c#
I learn and now I am in a dilemma, silly, but for the newbie a dilemma, I have not been able to draw a line in the shape of a cross in my video window and that allows me to know the coordinates of the center of that cross.

I show you the current window
enter image description here

and then how I want it to look

enter image description here

I have searched in forums, youtube and more, but I can't find a simple example that will help me
It is an idea of what I need, thank you very much for your help and patience

this is my code. They will notice how inexperienced I am

```<code>using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using Emgu.CV;
using Emgu.CV.Structure;
using System.Runtime.InteropServices;
using System.Drawing.Imaging;

namespace Farmer_v._0._1._0
{
    public partial class Vision_artificial : Form

    {

        //COLOR PICKER
        [DllImport("user32.dll")]
        static extern bool GetCursorPos(ref Point lpPoint);

        [DllImport("gdi32.dll", CharSet = CharSet.Auto, SetLastError = true, ExactSpelling = true)]
        public static extern int BitBlt(IntPtr hDC, int x, int y, int nWidth, int nHeight, IntPtr hSrcDC, int xSrc, int ySrc, int dwRop);
        //COLOR PICKER

        Emgu.CV.Capture capWebcam = null;
        bool blnCapturingInProcess = false;
        Image<Bgr, Byte> imgOriginal;

        Image<Gray, Byte> imgProcesada;
        Mat frame = new Mat();

        //canny
        double umbral11 = 300;
        double umbral22= 300;
        //circulos
        double min_distancia = 4;
        double umbralCirculos1 = 1;
        double umbralCirculos2 = 1;
        int min_diametro = 10;
        int max_diametro = 400;
        int n_circulos = 0;
        //BGR
        int B1 = 0;
        int G1 = 0;
        int R1 = 175;
        int B2 = 100;
        int G2 = 100;
        int R2 = 256;

        public Vision_artificial()
        {
            InitializeComponent();

        }
        public Color GetColorAt(Point location)
        {
            using (Bitmap screenPixel = new Bitmap(1, 1, PixelFormat.Format32bppRgb))
            {
                using (Graphics gdest = Graphics.FromImage(screenPixel))
                {
                    using (Graphics gsrc = Graphics.FromHwnd(ibOriginal.Handle))
                    {
                        IntPtr hSrcDC = gsrc.GetHdc();
                        IntPtr hDC = gdest.GetHdc();
                        int retval = BitBlt(hDC, 0, 0, 1, 1, hSrcDC, location.X, location.Y, (int)CopyPixelOperation.SourceCopy);
                        gdest.ReleaseHdc();
                        gsrc.ReleaseHdc();

                    }
                }

                return screenPixel.GetPixel(0, 0);
            }
        }

        public void Draw(Cross2DF cross, IColor color, int thickness)
        {

        }

        private void Vision_artificial_Load(object sender, EventArgs e)
        {
            try
            {
                capWebcam = new Emgu.CV.Capture(1);  //asociar captura de objeto a la camara por defecto
            }
            catch (NullReferenceException except)    //si hay error
            {
                txtXYRadius.Text = except.Message;  //muestra error de objeto en el cuadro de texto
                return;
            }

            Application.Idle += processFrameAndUpdateGUI;
            blnCapturingInProcess = true;

            //camara.ImageGrabbed += Grabar;
            //camara.Start();

        }

        private void Vision_artificial_Closed(object sender, EventArgs e)
        {
            if (capWebcam != null)
            {
                capWebcam.Dispose();

            }
        }

        void processFrameAndUpdateGUI(object sender, EventArgs e)
        {

            imgOriginal = capWebcam.QueryFrame().ToImage<Bgr, Byte>();

            if (imgOriginal == null) return;
            imgProcesada = imgOriginal.InRange(new Bgr(B1, G1, R1),
                                            new Bgr(B2, G2, R2));
            imgProcesada = imgProcesada.SmoothGaussian(9);

            CircleF[] circles = imgProcesada.HoughCircles(new Gray(100),
                                                            new Gray(50),
                                                            2,
                                                            imgProcesada.Height / min_distancia,
                                                            min_diametro,
                                                            max_diametro)[0];

            foreach (CircleF circle in circles)
            {
                if (txtXYRadius.Text != "") txtXYRadius.AppendText(Environment.NewLine);
                txtXYRadius.AppendText("Objeto en posicion x=" + circle.Center.X.ToString().PadLeft(4) +
                                                       ", y =" + circle.Center.Y.ToString().PadLeft(4) +
                                           ", radius =" + circle.Radius.ToString("###.000").PadLeft(7));

                txtXYRadius.ScrollToCaret();
                n_circulos = circles.Length;
                geoX.Text = circle.Center.X.ToString();
                geoY.Text = circle.Center.Y.ToString();

                CvInvoke.Circle(imgOriginal,
                                new Point((int)circle.Center.X, (int)circle.Center.Y),
                                3,
                                new MCvScalar(0, 255, 0),
                                -1,
                                Emgu.CV.CvEnum.LineType.FourConnected,
                                0);

                imgOriginal.Draw(circle,
                                    new Bgr(Color.Red),
                                    3);

            }

            //Mat imagen2 = new Mat();
            //CvInvoke.Canny(imgOriginal.Clone(), imagen2, umbral11, umbral22);
            //ibCanny.Image = imagen2.Bitmap;
            ////circles = CvInvoke.HoughCircles(imagen2, HoughType.Gradient, 1.0, min_distancia, umbralCirculos1, umbralCirculos2, min_diametro, max_diametro);
            //

            //for (int i = 0; i < circles.Length; i++)
            //{

            //    CvInvoke.Circle(imagen2,
            //        Point.Round(circles[i].Center), (int)circles[i].Radius, new Bgr(Color.Red).MCvScalar, 2, LineType.EightConnected, 0);

            //}

            ibOriginal.Image = imgOriginal.ToBitmap();
            ibProcesada.Image = imgProcesada.ToBitmap();

        }

        //private void Grabar (object sender, EventArgs e)
        //{
        //    Mat imagen = new Mat();
        //    camara.Retrieve(imagen, 0);

        //        ibOriginal.Image = imagen.Bitmap;

        //    Mat imagen2 = new Mat();
        //    CvInvoke.Canny(imagen.Clone(), imagen2, umbral11, umbral22);
        //    ibProcesada.Image = imagen2.Bitmap;

        //    CircleF[] circulos = CvInvoke.HoughCircles(imagen2.Clone(), HoughType.Gradient, 1.0, min_distancia, umbralCirculos1, umbralCirculos2, min_diametro, max_diametro);
        //    n_circulos = circulos.Length;

        //    Mat imagen3 =imagen.Clone();

        //    for (int i = 0; i < circulos.Length; i++)
        //    {

        //        CvInvoke.Circle(imagen3,
        //            Point.Round(circulos[i].Center), (int)circulos[i].Radius, new Bgr(Color.Red).MCvScalar, 2, LineType.EightConnected, 0);

        //    }

        //    ibCanny.Image = imagen3.Bitmap;

        //}

        private void Arduino(object sender, EventArgs e)
        {

        }

        public Bitmap CannyEdge(Bitmap bmp)
        {
            Image<Gray, Byte> Cannybmp;
            Image<Gray, Byte> GrayBmp;
            Image<Bgr, Byte> orig = new Image<Bgr, Byte>(bmp);
            Image<Bgr, Byte> imgSmooth;
            Bitmap output;

            imgSmooth = orig.PyrUp();
            imgSmooth._SmoothGaussian(3);
            GrayBmp = imgSmooth.Convert<Gray, byte>();

            Gray grayCannyThreshold = new Gray(umbral11);
            Gray grayThreshLinking = new Gray(umbral22);

            Cannybmp = GrayBmp.Canny(grayCannyThreshold.Intensity, grayThreshLinking.Intensity);

                output = Cannybmp.ToBitmap();
            //int a = 5;
            return output;

        }

        private void pictureBox1_LoadCompleted(object sender, AsyncCompletedEventArgs e)
        {

        }

        private void pictureBox2_Click(object sender, EventArgs e)
        {

        }

        private void btnPausa_Click(object sender, EventArgs e)
        {
            if (blnCapturingInProcess == true)
            {
                Application.Idle -= processFrameAndUpdateGUI;
                blnCapturingInProcess = false;
                btnPausa.Text = "Capturar";
            }
            else
            {
                Application.Idle += processFrameAndUpdateGUI;
                blnCapturingInProcess = true;
                btnPausa.Text = "Pausa";
            }
        }

        private void ibCanny_Click(object sender, EventArgs e)
        {

        }

        private void pictureBox1_Click(object sender, EventArgs e)
        {

        }

        private void numericUpDown1_ValueChanged(object sender, EventArgs e)
        {
            umbral11 = (double)numericUpDown1.Value;
        }

        private void numericUpDown2_ValueChanged(object sender, EventArgs e)
        {
            umbral22 = (double)numericUpDown2.Value;
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            lbln_circulos.Text = n_circulos.ToString();
        }

        private void numericUpDown5_ValueChanged(object sender, EventArgs e)
        {
            umbralCirculos1 = (double)num_umbral_1.Value;
        }

        private void num_distanicia_minima_ValueChanged(object sender, EventArgs e)
        {
            min_distancia = (double)num_distancia_minima.Value;
        }

        private void num_umbral_2_ValueChanged(object sender, EventArgs e)
        {
            umbralCirculos2 = (double)num_umbral_2.Value;
        }

        private void num_diametro_minimo_ValueChanged(object sender, EventArgs e)
        {
            min_diametro = (int)num_diametro_minimo.Value;
        }

        private void num_diametro_maximo_ValueChanged(object sender, EventArgs e)
        {
            max_diametro = (int)num_diametro_maximo.Value;
        }

        private void boxB1_ValueChanged(object sender, EventArgs e)
        {
            B1 = (int)boxB1.Value;
        }

        private void boxG1_ValueChanged(object sender, EventArgs e)
        {
            G1 = (int)boxG1.Value;
        }

        private void boxR1_ValueChanged(object sender, EventArgs e)
        {
            R1 = (int)boxG1.Value;
        }

        private void boxB2_ValueChanged(object sender, EventArgs e)
        {
            B2 = (int)boxB2.Value;
        }

        private void boxG2_ValueChanged(object sender, EventArgs e)
        {
            G2 = (int)boxG2.Value;
        }

        private void boxR2_ValueChanged(object sender, EventArgs e)
        {
            R2 = (int)boxR2.Value;
        }

        private void button1_Click(object sender, EventArgs e)
        {

        }

        private void ibOriginal_MouseDown(object sender, MouseEventArgs e)
        {

        }

        private void ibOriginal_MouseMove(object sender, MouseEventArgs e)
        {
            panelColor.BackColor = GetColorAt(e.Location);

            //Bitmap pixelData = new Bitmap (ibOriginal.Image);
            //Color clr = pixelData.GetPixel(Cursor.Position.X - this.Left, Cursor.Position.Y - (this.Top +15));
            //lblB.Text = "RGBA(" + clr.R.ToString() + ", " + clr.G.ToString() + ", " + clr.B.ToString();

        }
    }
}

</code>```
```<code></code>```

ContentLicense: CC BY-SA 4.0

Body:
I learn and now I am in a dilemma, silly, but for the newbie a dilemma, I have not been able to draw a line in the shape of a cross in my video window and that allows me to know the coordinates of the center of that cross.

I show you the current window
enter image description here

and then how I want it to look

enter image description here

I have searched in forums, youtube and more, but I can't find a simple example that will help me
It is an idea of what I need, thank you very much for your help and patience

this is my code. They will notice how inexperienced I am

using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using Emgu.CV;
using Emgu.CV.Structure;
using System.Runtime.InteropServices;
using System.Drawing.Imaging;

namespace Farmer_v._0._1._0
{
    public partial class Vision_artificial : Form

    {

        //COLOR PICKER
        [DllImport("user32.dll")]
        static extern bool GetCursorPos(ref Point lpPoint);

        [DllImport("gdi32.dll", CharSet = CharSet.Auto, SetLastError = true, ExactSpelling = true)]
        public static extern int BitBlt(IntPtr hDC, int x, int y, int nWidth, int nHeight, IntPtr hSrcDC, int xSrc, int ySrc, int dwRop);
        //COLOR PICKER

        Emgu.CV.Capture capWebcam = null;
        bool blnCapturingInProcess = false;
        Image<Bgr, Byte> imgOriginal;

        Image<Gray, Byte> imgProcesada;
        Mat frame = new Mat();

        //canny
        double umbral11 = 300;
        double umbral22= 300;
        //circulos
        double min_distancia = 4;
        double umbralCirculos1 = 1;
        double umbralCirculos2 = 1;
        int min_diametro = 10;
        int max_diametro = 400;
        int n_circulos = 0;
        //BGR
        int B1 = 0;
        int G1 = 0;
        int R1 = 175;
        int B2 = 100;
        int G2 = 100;
        int R2 = 256;

        public Vision_artificial()
        {
            InitializeComponent();

        }
        public Color GetColorAt(Point location)
        {
            using (Bitmap screenPixel = new Bitmap(1, 1, PixelFormat.Format32bppRgb))
            {
                using (Graphics gdest = Graphics.FromImage(screenPixel))
                {
                    using (Graphics gsrc = Graphics.FromHwnd(ibOriginal.Handle))
                    {
                        IntPtr hSrcDC = gsrc.GetHdc();
                        IntPtr hDC = gdest.GetHdc();
                        int retval = BitBlt(hDC, 0, 0, 1, 1, hSrcDC, location.X, location.Y, (int)CopyPixelOperation.SourceCopy);
                        gdest.ReleaseHdc();
                        gsrc.ReleaseHdc();

                    }
                }

                return screenPixel.GetPixel(0, 0);
            }
        }

        public void Draw(Cross2DF cross, IColor color, int thickness)
        {

        }

        private void Vision_artificial_Load(object sender, EventArgs e)
        {
            try
            {
                capWebcam = new Emgu.CV.Capture(1);  //asociar captura de objeto a la camara por defecto
            }
            catch (NullReferenceException except)    //si hay error
            {
                txtXYRadius.Text = except.Message;  //muestra error de objeto en el cuadro de texto
                return;
            }

            Application.Idle += processFrameAndUpdateGUI;
            blnCapturingInProcess = true;

            //camara.ImageGrabbed += Grabar;
            //camara.Start();

        }

        private void Vision_artificial_Closed(object sender, EventArgs e)
        {
            if (capWebcam != null)
            {
                capWebcam.Dispose();

            }
        }

        void processFrameAndUpdateGUI(object sender, EventArgs e)
        {

            imgOriginal = capWebcam.QueryFrame().ToImage<Bgr, Byte>();

            if (imgOriginal == null) return;
            imgProcesada = imgOriginal.InRange(new Bgr(B1, G1, R1),
                                            new Bgr(B2, G2, R2));
            imgProcesada = imgProcesada.SmoothGaussian(9);

            CircleF[] circles = imgProcesada.HoughCircles(new Gray(100),
                                                            new Gray(50),
                                                            2,
                                                            imgProcesada.Height / min_distancia,
                                                            min_diametro,
                                                            max_diametro)[0];

            foreach (CircleF circle in circles)
            {
                if (txtXYRadius.Text != "") txtXYRadius.AppendText(Environment.NewLine);
                txtXYRadius.AppendText("Objeto en posicion x=" + circle.Center.X.ToString().PadLeft(4) +
                                                       ", y =" + circle.Center.Y.ToString().PadLeft(4) +
                                           ", radius =" + circle.Radius.ToString("###.000").PadLeft(7));

                txtXYRadius.ScrollToCaret();
                n_circulos = circles.Length;
                geoX.Text = circle.Center.X.ToString();
                geoY.Text = circle.Center.Y.ToString();

                CvInvoke.Circle(imgOriginal,
                                new Point((int)circle.Center.X, (int)circle.Center.Y),
                                3,
                                new MCvScalar(0, 255, 0),
                                -1,
                                Emgu.CV.CvEnum.LineType.FourConnected,
                                0);

                imgOriginal.Draw(circle,
                                    new Bgr(Color.Red),
                                    3);

            }

            //Mat imagen2 = new Mat();
            //CvInvoke.Canny(imgOriginal.Clone(), imagen2, umbral11, umbral22);
            //ibCanny.Image = imagen2.Bitmap;
            ////circles = CvInvoke.HoughCircles(imagen2, HoughType.Gradient, 1.0, min_distancia, umbralCirculos1, umbralCirculos2, min_diametro, max_diametro);
            //

            //for (int i = 0; i < circles.Length; i++)
            //{

            //    CvInvoke.Circle(imagen2,
            //        Point.Round(circles[i].Center), (int)circles[i].Radius, new Bgr(Color.Red).MCvScalar, 2, LineType.EightConnected, 0);

            //}

            ibOriginal.Image = imgOriginal.ToBitmap();
            ibProcesada.Image = imgProcesada.ToBitmap();

        }

        //private void Grabar (object sender, EventArgs e)
        //{
        //    Mat imagen = new Mat();
        //    camara.Retrieve(imagen, 0);

        //        ibOriginal.Image = imagen.Bitmap;

        //    Mat imagen2 = new Mat();
        //    CvInvoke.Canny(imagen.Clone(), imagen2, umbral11, umbral22);
        //    ibProcesada.Image = imagen2.Bitmap;

        //    CircleF[] circulos = CvInvoke.HoughCircles(imagen2.Clone(), HoughType.Gradient, 1.0, min_distancia, umbralCirculos1, umbralCirculos2, min_diametro, max_diametro);
        //    n_circulos = circulos.Length;

        //    Mat imagen3 =imagen.Clone();

        //    for (int i = 0; i < circulos.Length; i++)
        //    {

        //        CvInvoke.Circle(imagen3,
        //            Point.Round(circulos[i].Center), (int)circulos[i].Radius, new Bgr(Color.Red).MCvScalar, 2, LineType.EightConnected, 0);

        //    }

        //    ibCanny.Image = imagen3.Bitmap;

        //}

        private void Arduino(object sender, EventArgs e)
        {

        }

        public Bitmap CannyEdge(Bitmap bmp)
        {
            Image<Gray, Byte> Cannybmp;
            Image<Gray, Byte> GrayBmp;
            Image<Bgr, Byte> orig = new Image<Bgr, Byte>(bmp);
            Image<Bgr, Byte> imgSmooth;
            Bitmap output;

            imgSmooth = orig.PyrUp();
            imgSmooth._SmoothGaussian(3);
            GrayBmp = imgSmooth.Convert<Gray, byte>();

            Gray grayCannyThreshold = new Gray(umbral11);
            Gray grayThreshLinking = new Gray(umbral22);

            Cannybmp = GrayBmp.Canny(grayCannyThreshold.Intensity, grayThreshLinking.Intensity);

                output = Cannybmp.ToBitmap();
            //int a = 5;
            return output;

        }

        private void pictureBox1_LoadCompleted(object sender, AsyncCompletedEventArgs e)
        {

        }

        private void pictureBox2_Click(object sender, EventArgs e)
        {

        }

        private void btnPausa_Click(object sender, EventArgs e)
        {
            if (blnCapturingInProcess == true)
            {
                Application.Idle -= processFrameAndUpdateGUI;
                blnCapturingInProcess = false;
                btnPausa.Text = "Capturar";
            }
            else
            {
                Application.Idle += processFrameAndUpdateGUI;
                blnCapturingInProcess = true;
                btnPausa.Text = "Pausa";
            }
        }

        private void ibCanny_Click(object sender, EventArgs e)
        {

        }

        private void pictureBox1_Click(object sender, EventArgs e)
        {

        }

        private void numericUpDown1_ValueChanged(object sender, EventArgs e)
        {
            umbral11 = (double)numericUpDown1.Value;
        }

        private void numericUpDown2_ValueChanged(object sender, EventArgs e)
        {
            umbral22 = (double)numericUpDown2.Value;
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            lbln_circulos.Text = n_circulos.ToString();
        }

        private void numericUpDown5_ValueChanged(object sender, EventArgs e)
        {
            umbralCirculos1 = (double)num_umbral_1.Value;
        }

        private void num_distanicia_minima_ValueChanged(object sender, EventArgs e)
        {
            min_distancia = (double)num_distancia_minima.Value;
        }

        private void num_umbral_2_ValueChanged(object sender, EventArgs e)
        {
            umbralCirculos2 = (double)num_umbral_2.Value;
        }

        private void num_diametro_minimo_ValueChanged(object sender, EventArgs e)
        {
            min_diametro = (int)num_diametro_minimo.Value;
        }

        private void num_diametro_maximo_ValueChanged(object sender, EventArgs e)
        {
            max_diametro = (int)num_diametro_maximo.Value;
        }

        private void boxB1_ValueChanged(object sender, EventArgs e)
        {
            B1 = (int)boxB1.Value;
        }

        private void boxG1_ValueChanged(object sender, EventArgs e)
        {
            G1 = (int)boxG1.Value;
        }

        private void boxR1_ValueChanged(object sender, EventArgs e)
        {
            R1 = (int)boxG1.Value;
        }

        private void boxB2_ValueChanged(object sender, EventArgs e)
        {
            B2 = (int)boxB2.Value;
        }

        private void boxG2_ValueChanged(object sender, EventArgs e)
        {
            G2 = (int)boxG2.Value;
        }

        private void boxR2_ValueChanged(object sender, EventArgs e)
        {
            R2 = (int)boxR2.Value;
        }

        private void button1_Click(object sender, EventArgs e)
        {

        }

        private void ibOriginal_MouseDown(object sender, MouseEventArgs e)
        {

        }

        private void ibOriginal_MouseMove(object sender, MouseEventArgs e)
        {
            panelColor.BackColor = GetColorAt(e.Location);

            //Bitmap pixelData = new Bitmap (ibOriginal.Image);
            //Color clr = pixelData.GetPixel(Cursor.Position.X - this.Left, Cursor.Position.Y - (this.Top +15));
            //lblB.Text = "RGBA(" + clr.R.ToString() + ", " + clr.G.ToString() + ", " + clr.B.ToString();

        }
    }
}


问:
Proxy setting in package.json not working
I'm trying to successfully connect my backend Express app to my frontend React app but I'm having difficulty with the actual connection process and I think it's to do with the "proxy" pathway I'm using in my package.json file in my react app.

Express

```<code>const express = require('express')
const app = express()

let name = "Justin"

app.get('/', (req, res) => {
  res.send(name)
})

app.listen(40000, () => {
  console.log("Im Listening on port 40000")
})
</code>```

React

```<code>import './App.css';

function GetData() {
  fetch('/')
  .then((response) => response.text())
  .then(function (data) {
    console.log(data)
  }
  )};

function App() {
  return (

    <div className="App">
      <button onClick={GetData}>Get Data</button>
    </div>
  );
}

export default App;
</code>```

I've made sure to add the proxy route to the express server within my package.json file

```<code> "proxy": "http://localhost:40000",
</code>```

The only thing that happens when I click the button is a text representation of the react app html page source.

What I want to see is the name "justin" displayed in the console when I click the button.

Would love a quick solve

Body:
I'm trying to successfully connect my backend Express app to my frontend React app but I'm having difficulty with the actual connection process and I think it's to do with the "proxy" pathway I'm using in my package.json file in my react app.

Express

const express = require('express')
const app = express()

let name = "Justin"

app.get('/', (req, res) => {
  res.send(name)
})

app.listen(40000, () => {
  console.log("Im Listening on port 40000")
})

React

import './App.css';

function GetData() {
  fetch('/')
  .then((response) => response.text())
  .then(function (data) {
    console.log(data)
  }
  )};

function App() {
  return (

      <button onClick={GetData}>Get Data</button>

  );
}

export default App;

I've made sure to add the proxy route to the express server within my package.json file

 "proxy": "http://localhost:40000",

The only thing that happens when I click the button is a text representation of the react app html page source.

What I want to see is the name "justin" displayed in the console when I click the button.

Would love a quick solve


问:
How to check if mongoose array has particular element inside object or not?
Basically what i am trying to do is-

getting comments and foreach comment getting its commentVote

getting the commentVote, checking if votes array inside each commentVote contains postedBy property or not also inlucdes loggedin
user id inside postedBy property

my controller -

```<code>exports.getComments = (req, res) => {
  const { featureId } = req.params;
  Comment.find({ feature: featureId })
    .populate("postedBy", "_id username")
    .sort({ createdAt: -1 })
    .exec((err, comments) => {
      if (err) {
        return res.status(400).send({
          error: errorHandler(err),
        });
      }
      let commentsArray = comments;
      commentsArray.forEach((comment) => {
        CommentVote.findOne({ comment: comment._id }).exec(
          (err, commentvote) => {
            if (err) {
              return res.status(400).send({
                error: errorHandler(err),
              });
            }
            console.log("commentvote.votes", commentvote.votes.length);
            const votes = commentvote.votes;
           const test = commentvote.votes.includes("req.auth._id");
            console.log(test);
            });
          }
        );
      });
    });
};
</code>```

I am wondering if i can get true or false on console.log(test);
because based on that i will send response to that particular comment

That particular comment is liked or not!

Body:
Basically what i am trying to do is-

getting comments and foreach comment getting its commentVote

getting the commentVote, checking if votes array inside each commentVote contains postedBy property or not also inlucdes loggedin
user id inside postedBy property

my controller -

exports.getComments = (req, res) => {
  const { featureId } = req.params;
  Comment.find({ feature: featureId })
    .populate("postedBy", "_id username")
    .sort({ createdAt: -1 })
    .exec((err, comments) => {
      if (err) {
        return res.status(400).send({
          error: errorHandler(err),
        });
      }
      let commentsArray = comments;
      commentsArray.forEach((comment) => {
        CommentVote.findOne({ comment: comment._id }).exec(
          (err, commentvote) => {
            if (err) {
              return res.status(400).send({
                error: errorHandler(err),
              });
            }
            console.log("commentvote.votes", commentvote.votes.length);
            const votes = commentvote.votes;
           const test = commentvote.votes.includes("req.auth._id");
            console.log(test);
            });
          }
        );
      });
    });
};

I am wondering if i can get true or false on console.log(test);
because based on that i will send response to that particular comment

That particular comment is liked or not!


问:
How can i add a page in Pop-Up window in django website
I want my customers' login pages to open in a pop-up box or window in django website. How to do that?

The bootstrap template I downloaded has a pop-up video playback option that works well. So I tried editing the href to my login page URL, but when I click on the button it says:

127.0.0.1 refused to connect

But the same works when I right-click and open a new window.

Code for video playback:

```
<p><img src="https://i.stack.imgur.com/gmbmw.png" alt="Before" /></p>
<p>And here are the changes I've made. I changed just the <code>href</code>:</p>
<pre class="lang-html prettyprint-override"><code> <div class="col-lg-6 position-relative align-self-start order-lg-last order-first">
    <img src="{% static 'index_assets/img/about.jpg' %}" class="img-fluid" alt="">

</div>
</code>```

Body:
I want my customers' login pages to open in a pop-up box or window in django website. How to do that?

The bootstrap template I downloaded has a pop-up video playback option that works well. So I tried editing the href to my login page URL, but when I click on the button it says:

127.0.0.1 refused to connect

But the same works when I right-click and open a new window.

Code for video playback:

And here are the changes I've made. I changed just the href:


问:
I can not import something into my module (mjs-file)
I have here a Chrome Extension and can not import anything to my main (index.mjs) script into it.

index.mjs File:

```<code>import Browser from "webextension-polyfill";

const port = Browser.runtime.connect();
</code>```

index.html File:

```<code><!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div>
        <input id="input-el" type="text">
        <button id="submit-btn"> submit </button>
    </div>
    <div id="content-El"></div>

    <script src="index.mjs"></script>
</body>
</html>
</code>```

Error: Uncaught SyntaxError: Cannot use import statement outside a module [index.mjs:1]

I tried to a lot of things.

type="module" in my html

rename file ending to mjs & js

Body:
I have here a Chrome Extension and can not import anything to my main (index.mjs) script into it.

index.mjs File:

import Browser from "webextension-polyfill";

const port = Browser.runtime.connect();

index.html File:

<!DOCTYPE html>

    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>

        <input id="input-el" type="text">
        <button id="submit-btn"> submit </button>

Error: Uncaught SyntaxError: Cannot use import statement outside a module [index.mjs:1]

I tried to a lot of things.

type="module" in my html

rename file ending to mjs & js


问:
POST NSData to a Server
I am trying to POST the iPhone depth data to a Macbook using wifi (at-least 30 fps). I extracted depth CVPixelBuffer from ARSession followed by creating an NSMutableData.

My question is that how I can POST this message (NSMutableData) to a server? In the meantime, how can I GET the same message from the server in Python, preferably Flask, and convert the message to depth data for showing purposes?

I would really appreciate any help and thanks for your time.

```<code>func createDataFromPixelBuffer(pixelBuffer: CVPixelBuffer) -> Data {
    CVPixelBufferLockBaseAddress(pixelBuffer, [.readOnly])
    defer { CVPixelBufferUnlockBaseAddress(pixelBuffer, [.readOnly]) }

    let source = CVPixelBufferGetBaseAddress(pixelBuffer)
    let totalSize = CVPixelBufferGetDataSize(pixelBuffer)
    guard let rawFrame = malloc(totalSize) else {fatalError("failed to alloc " + String(totalSize))}
    memcpy(rawFrame, source, totalSize)

    return Data(bytesNoCopy: rawFrame, count: totalSize, deallocator: .free)
}

let data = createDataFromPixelBuffer(pixelBuffer: depth)
let messageData = NSMutableData()
messageData.append(data)
</code>```

Title: POST NSData to a Server

Body:
I am trying to POST the iPhone depth data to a Macbook using wifi (at-least 30 fps). I extracted depth CVPixelBuffer from ARSession followed by creating an NSMutableData.

My question is that how I can POST this message (NSMutableData) to a server? In the meantime, how can I GET the same message from the server in Python, preferably Flask, and convert the message to depth data for showing purposes?

I would really appreciate any help and thanks for your time.

func createDataFromPixelBuffer(pixelBuffer: CVPixelBuffer) -> Data {
    CVPixelBufferLockBaseAddress(pixelBuffer, [.readOnly])
    defer { CVPixelBufferUnlockBaseAddress(pixelBuffer, [.readOnly]) }

    let source = CVPixelBufferGetBaseAddress(pixelBuffer)
    let totalSize = CVPixelBufferGetDataSize(pixelBuffer)
    guard let rawFrame = malloc(totalSize) else {fatalError("failed to alloc " + String(totalSize))}
    memcpy(rawFrame, source, totalSize)

    return Data(bytesNoCopy: rawFrame, count: totalSize, deallocator: .free)
}

let data = createDataFromPixelBuffer(pixelBuffer: depth)
let messageData = NSMutableData()
messageData.append(data)


问:
In NetSuite Project field
In Quote I have field called project, according to the criteria if field is blank, it should show blank but, in my case, it shows undefined. How I resolve this problem. I am using that field to show project in PDF using suitelet.

Want a blank field instead of undefined.

Title: In NetSuite Project field


问:
Trying to read responseText to XMLRequest is just duplicating the body
So what's the deal?  I'm simply trying to read text from this file.  However, this code has the odd effect that, when I click the button, it seems to take the content of the page as the responseText, and will duplicate the button and paragraphs.  Yet as far as I can tell I am mimmicking the W3Schools example, yet it doesn't work.</p>
```<code><head></head>

<body>
<button onclick = "loadDoc()">Something to load?</button>
<p>Here's a paragraph</p>
<script>
    function loadDoc(){
    let xhttp = new XMLHttpRequest();

    xhttp.onload = function()
    {
    document.write(this.responseText);

    }

    xhttp.open("GET", "testText.txt");
    xhttp.send();
}
</script>

</body>
</code>```

Body:
So what's the deal?  I'm simply trying to read text from this file.  However, this code has the odd effect that, when I click the button, it seems to take the content of the page as the responseText, and will duplicate the button and paragraphs.  Yet as far as I can tell I am mimmicking the W3Schools example, yet it doesn't work.

<button onclick = "loadDoc()">Something to load?</button>

Here's a paragraph


问:
Use git diff to show only whitespace errors as defined in .gitattributes?
In .gitattributes I define what sorts of whitespaces should git diff treat as errors, for example:

*.xml whitespace=trailing-space,space-before-tab,indent-with-non-tab,tabwidth=2
```

The whitespace in this example option tells that git diff should treat specified kinds of whitespaces as errors for xml files.

When git diff is run against some xml file and finds those whitespace problems it will mark them with red background color, in the example bellow there are multiple whitespaces before tab as they are marked with red square for all the whitespaces:

What I want to achieve with git diff is to show me ONLY lines whitespace errors and no other code changes, is that possible and how?

Code changes which contain no whitespace errors should not be shown to reduce output only to whitespace errors.

Body:
In .gitattributes I define what sorts of whitespaces should git diff treat as errors, for example:

*.xml whitespace=trailing-space,space-before-tab,indent-with-non-tab,tabwidth=2

The whitespace in this example option tells that git diff should treat specified kinds of whitespaces as errors for xml files.

When git diff is run against some xml file and finds those whitespace problems it will mark them with red background color, in the example bellow there are multiple whitespaces before tab as they are marked with red square for all the whitespaces:

What I want to achieve with git diff is to show me ONLY lines whitespace errors and no other code changes, is that possible and how?

Code changes which contain no whitespace errors should not be shown to reduce output only to whitespace errors.


问:
I'm trying to get each array element in new line in PUG its not working
for example, I have this array:

```<code>const arr=['kiwi','orange','apple'];
console.log(arr.toString().split(',').join('\r\n'))
</code>```

it will give me each array element in new line in Javascript. but when I try to do this in PUG. I will get like this -

kiwi orange apple

but I want like this -

```<code>kiwi
orange
apple
</code>```

I know this question has been asked many times. but I tried with everything

```<code>('\n','\\n','<br>',<br/>', '```','\r\n'),
```

it didnt worked.

Body:
for example, I have this array:

const arr=['kiwi','orange','apple'];
console.log(arr.toString().split(',').join('\r\n'))

it will give me each array element in new line in Javascript. but when I try to do this in PUG. I will get like this -

kiwi orange apple

but I want like this -

kiwi
orange
apple

I know this question has been asked many times. but I tried with everything

('\n','\\n','
',
', '
','\r\n'),

it didnt worked.


问:
Creating generic JsonPatchMapper in Kotlin
I have been trying to create generic json patch mapper, which would:

take an targetBean and convert it to JsonNode

apply patch to it

convert patched JsonNode back to

Here is my attempt, but now I'm getting an error saying Cannot use 'T' as reified type parameter. Use a class instead.
This error occurs on line where I do return

...treeToValue(patched, T::class.java

Code:

```<code>import com.fasterxml.jackson.databind.JsonNode
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
import com.github.fge.jsonpatch.JsonPatch
import org.springframework.stereotype.Component
import java.util.function.BiFunction

@Component
class JsonPatchMapper<T>: BiFunction<T, JsonPatch, T> {

    private val objectMapper = jacksonObjectMapper()

    override fun apply(targetBean: T, patch: JsonPatch): T {
        val target = objectMapper.convertValue(targetBean, JsonNode::class.java)
        val patched = patch.apply(target)

        return objectMapper.treeToValue(patched, T::class.java)
    }
}
</code>```

Any help would be appreciated :)

Body:
I have been trying to create generic json patch mapper, which would:

take an targetBean and convert it to JsonNode

apply patch to it

convert patched JsonNode back to

Here is my attempt, but now I'm getting an error saying Cannot use 'T' as reified type parameter. Use a class instead.
This error occurs on line where I do return

...treeToValue(patched, T::class.java

Code:

import com.fasterxml.jackson.databind.JsonNode
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
import com.github.fge.jsonpatch.JsonPatch
import org.springframework.stereotype.Component
import java.util.function.BiFunction

@Component
class JsonPatchMapper<T>: BiFunction<T, JsonPatch, T> {

    private val objectMapper = jacksonObjectMapper()

    override fun apply(targetBean: T, patch: JsonPatch): T {
        val target = objectMapper.convertValue(targetBean, JsonNode::class.java)
        val patched = patch.apply(target)

        return objectMapper.treeToValue(patched, T::class.java)
    }
}

Any help would be appreciated :)


问:
Sort data in the vertical-stack in the victory stack
Is there any way, through which the data can be sorted in the vertical bar, in which the biggest value (y-axis) ends up at the bottom?

Here is my code

```<code>class App extends React.Component {

  render() {
    const getBarData = () => {
      return [1, 2,3,4].map((k) => {
        return [
          { x: 1, y: k*20 },
          { x: 2, y: k*30 },
          { x: 3, y: k*10 },
        ];
      });
    };

    return (
      <div>
        <VictoryChart domainPadding={{ x: 50 }} width={400} height={400}>
            <VictoryGroup offset={20} style={{ data: { width: 15 } }}>
              <VictoryStack colorScale={"red"}>
                {getBarData().map((data, index) => {
                  return <VictoryBar key={index} data={data}/>;
                })}
              </VictoryStack>
              <VictoryStack colorScale={"green"}>
                {getBarData().map((data, index) => {
                  return <VictoryBar key={index} data={data}/>;
                })}
              </VictoryStack>
              <VictoryStack colorScale={"blue"}>
                {getBarData().map((data, index) => {
                  return <VictoryBar key={index} data={data}/>;
                })}
              </VictoryStack>
            </VictoryGroup>
          </VictoryChart>
      </div>
    );
  }
}

ReactDOM.render(<App/>, mountNode);
</code>```

I have used the victory stack and victory group with the victory bar, but when I am using the sortKey and sortOrder inside the Victory bar, the graph is sorted horizontally not vertically.

Body:
Is there any way, through which the data can be sorted in the vertical bar, in which the biggest value (y-axis) ends up at the bottom?

Here is my code

class App extends React.Component {

  render() {
    const getBarData = () => {
      return [1, 2,3,4].map((k) => {
        return [
          { x: 1, y: k*20 },
          { x: 2, y: k*30 },
          { x: 3, y: k*10 },
        ];
      });
    };

    return (

        <VictoryChart domainPadding={{ x: 50 }} width={400} height={400}>
            <VictoryGroup offset={20} style={{ data: { width: 15 } }}>
              <VictoryStack colorScale={"red"}>
                {getBarData().map((data, index) => {
                  return <VictoryBar key={index} data={data}/>;
                })}
              </VictoryStack>
              <VictoryStack colorScale={"green"}>
                {getBarData().map((data, index) => {
                  return <VictoryBar key={index} data={data}/>;
                })}
              </VictoryStack>
              <VictoryStack colorScale={"blue"}>
                {getBarData().map((data, index) => {
                  return <VictoryBar key={index} data={data}/>;
                })}
              </VictoryStack>
            </VictoryGroup>
          </VictoryChart>

    );
  }
}

ReactDOM.render(<App/>, mountNode);

I have used the victory stack and victory group with the victory bar, but when I am using the sortKey and sortOrder inside the Victory bar, the graph is sorted horizontally not vertically.


问:
Api platform + mercure. How to modify a published entity when mercure service is not working
Well, I cannot figure out how to proceed if the mercure service (hub) is not working in the server. If this happens, I don't mind updates to subscribed clients, but I need the api to work as expected if mercure was not present. But if I switch off mercure hub and I try to make a put to a mercure tracked entity I'm getting a 500 error. How can this be avoided? In other words, how could I get the tracked entity work if, by any reason, hub is down?

I expected to have a setting or something like that in CaddyFile or api platform mercure bundle to avoid this.


问:
Resize Winform after adding Panels in C#
I have a following situation.

In my scenario, I have a borderless form, where a panel is docked on top , left and right. For this scenario I first wanted to drag the form using the top bar which I was able to after listening to the top panel mouse move event .

```<code>private void panel4_MouseMove(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                ReleaseCapture();
                SendMessage(Handle, WM_NCLBUTTONDOWN, HT_CAPTION, 0);
            }
        }
    }

public DetectionSegmentation()
        {
            InitializeComponent();

            this.DoubleBuffered = true;
            this.DoubleBuffered = true;
            this.SetStyle(ControlStyles.ResizeRedraw, true);

        }

    private const int
        HTLEFT = 10,
        HTRIGHT = 11,
        HTTOP = 12,
        HTTOPLEFT = 13,
        HTTOPRIGHT = 14,
        HTBOTTOM = 15,
        HTBOTTOMLEFT = 16,
        HTBOTTOMRIGHT = 17;

    const int _ = 10; // you can rename this variable if you like

    Rectangle Top { get { return new Rectangle(0, 0, this.ClientSize.Width, _); } }
    Rectangle Left { get { return new Rectangle(0, 0, _, this.ClientSize.Height); } }
    Rectangle Bottom { get { return new Rectangle(0, this.ClientSize.Height - _, this.ClientSize.Width, _); } }
    Rectangle Right { get { return new Rectangle(this.ClientSize.Width - _, 0, _, this.ClientSize.Height); } }

    Rectangle TopLeft { get { return new Rectangle(0, 0, _, _); } }
    Rectangle TopRight { get { return new Rectangle(this.ClientSize.Width - _, 0, _, _); } }
    Rectangle BottomLeft { get { return new Rectangle(0, this.ClientSize.Height - _, _, _); } }
    Rectangle BottomRight { get { return new Rectangle(this.ClientSize.Width - _, this.ClientSize.Height - _, _, _); } }

    protected override void WndProc(ref Message message)
    {
        base.WndProc(ref message);

        if (message.Msg == 0x84) // WM_NCHITTEST
        {
            var cursor = this.PointToClient(Cursor.Position);

            if (TopLeft.Contains(cursor)) message.Result = (IntPtr)HTTOPLEFT;
            else if (TopRight.Contains(cursor)) message.Result = (IntPtr)HTTOPRIGHT;
            else if (BottomLeft.Contains(cursor)) message.Result = (IntPtr)HTBOTTOMLEFT;
            else if (BottomRight.Contains(cursor)) message.Result = (IntPtr)HTBOTTOMRIGHT;

            else if (Top.Contains(cursor)) message.Result = (IntPtr)HTTOP;
            else if (Left.Contains(cursor)) message.Result = (IntPtr)HTLEFT;
            else if (Right.Contains(cursor)) message.Result = (IntPtr)HTRIGHT;
            else if (Bottom.Contains(cursor)) message.Result = (IntPtr)HTBOTTOM;
        }
    }
</code>```

Now I want to resize the form and for this I have added above lines of code, it was working well without the panels in the form but now after the panels have been added to the form, the resize code does not work. Moreover, I want to resize the form to a specific width and height of the form.

Body:
I have a following situation.

In my scenario, I have a borderless form, where a panel is docked on top , left and right. For this scenario I first wanted to drag the form using the top bar which I was able to after listening to the top panel mouse move event .

private void panel4_MouseMove(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                ReleaseCapture();
                SendMessage(Handle, WM_NCLBUTTONDOWN, HT_CAPTION, 0);
            }
        }
    }

public DetectionSegmentation()
        {
            InitializeComponent();

            this.DoubleBuffered = true;
            this.DoubleBuffered = true;
            this.SetStyle(ControlStyles.ResizeRedraw, true);

        }

    private const int
        HTLEFT = 10,
        HTRIGHT = 11,
        HTTOP = 12,
        HTTOPLEFT = 13,
        HTTOPRIGHT = 14,
        HTBOTTOM = 15,
        HTBOTTOMLEFT = 16,
        HTBOTTOMRIGHT = 17;

    const int _ = 10; // you can rename this variable if you like

    Rectangle Top { get { return new Rectangle(0, 0, this.ClientSize.Width, _); } }
    Rectangle Left { get { return new Rectangle(0, 0, _, this.ClientSize.Height); } }
    Rectangle Bottom { get { return new Rectangle(0, this.ClientSize.Height - _, this.ClientSize.Width, _); } }
    Rectangle Right { get { return new Rectangle(this.ClientSize.Width - _, 0, _, this.ClientSize.Height); } }

    Rectangle TopLeft { get { return new Rectangle(0, 0, _, _); } }
    Rectangle TopRight { get { return new Rectangle(this.ClientSize.Width - _, 0, _, _); } }
    Rectangle BottomLeft { get { return new Rectangle(0, this.ClientSize.Height - _, _, _); } }
    Rectangle BottomRight { get { return new Rectangle(this.ClientSize.Width - _, this.ClientSize.Height - _, _, _); } }

    protected override void WndProc(ref Message message)
    {
        base.WndProc(ref message);

        if (message.Msg == 0x84) // WM_NCHITTEST
        {
            var cursor = this.PointToClient(Cursor.Position);

            if (TopLeft.Contains(cursor)) message.Result = (IntPtr)HTTOPLEFT;
            else if (TopRight.Contains(cursor)) message.Result = (IntPtr)HTTOPRIGHT;
            else if (BottomLeft.Contains(cursor)) message.Result = (IntPtr)HTBOTTOMLEFT;
            else if (BottomRight.Contains(cursor)) message.Result = (IntPtr)HTBOTTOMRIGHT;

            else if (Top.Contains(cursor)) message.Result = (IntPtr)HTTOP;
            else if (Left.Contains(cursor)) message.Result = (IntPtr)HTLEFT;
            else if (Right.Contains(cursor)) message.Result = (IntPtr)HTRIGHT;
            else if (Bottom.Contains(cursor)) message.Result = (IntPtr)HTBOTTOM;
        }
    }

Now I want to resize the form and for this I have added above lines of code, it was working well without the panels in the form but now after the panels have been added to the form, the resize code does not work. Moreover, I want to resize the form to a specific width and height of the form.


问:
JQuery - How to change or set placeholder text to second select
Can someone help me with JQuery?

When I select the topic using first select, it always displays first item in category select. Would like to change that, so it displays only placeholder like ”Select one” etc

```<code><form><select id="topic">
  <option value="" disabled selected hidden>SELECT</option>
  <option value="category1">Category 1</option>
  <option value="category2">Category 2</option>
  <option value="category3">Category 3</option>
</select>

<select name="categories" id="categorySelector">
    <optgroup id="A" label="category1">
        <option value="" disabled selected hidden>SELECT</option>
        <option value="item1">item 1</option>
    </optgroup>
    <optgroup id="B" label="category2">
        <option value="" disabled selected hidden>SELECT</option>
        <option value="item2">item 2</option>
    </optgroup>
    <optgroup id="C" label="category3">
        <option value="" disabled selected hidden>SELECT</option>
        <option value="item3">item 3</option>
    </optgroup>
</select>
<button type="button" id="btn" onClick="addExcercise()">Add Exercise</button>
<form>

</code>```
```<code>$(function() {

    $('#btn').hide(); //hide submit button
    $('#categorySelector').hide();   //hide second selectBox
    var $optgroups = $('#categorySelector > optgroup');

    $("#topic").on("change",function(){

    var selectedVal = this.value;
    console.log(selectedVal);
        $('#categorySelector').html( $optgroups.filter('[label="'+selectedVal+'"]') );

        $('#categorySelector').attr('placeholder', 'select item'); //wont work
    $('#categorySelector').show();

    });

    $('#categorySelector').on('change', function() {
       $('#btn').show();
    });
});
</code>```

Some how categorySelector -select preselects first value from filtered optiongroup and ignores the hidden "SELECT" placeholder

Any clues how to get placeholder value "select" for categorySelect everytime these values are filtered

Somehow categorySelector -select pre-selects first value from filtered option-group and ignores the hidden "SELECT" placeholder

I also tried to add custom placeholder for  everytime the #topic onchange does the filtering.

```<code>$('#categorySelector').attr('placeholder', 'select item');
</code>```

Any clues how to get placeholder value "select" for categoryselector everytime these values are filtered

Body:
Can someone help me with JQuery?

When I select the topic using first select, it always displays first item in category select. Would like to change that, so it displays only placeholder like ”Select one” etc

<form><select id="topic">
  <option value="" disabled selected hidden>SELECT</option>
  <option value="category1">Category 1</option>
  <option value="category2">Category 2</option>
  <option value="category3">Category 3</option>
</select>

<select name="categories" id="categorySelector">
    <optgroup id="A" label="category1">
        <option value="" disabled selected hidden>SELECT</option>
        <option value="item1">item 1</option>
    </optgroup>
    <optgroup id="B" label="category2">
        <option value="" disabled selected hidden>SELECT</option>
        <option value="item2">item 2</option>
    </optgroup>
    <optgroup id="C" label="category3">
        <option value="" disabled selected hidden>SELECT</option>
        <option value="item3">item 3</option>
    </optgroup>
</select>
<button type="button" id="btn" onClick="addExcercise()">Add Exercise</button>
<form>

$(function() {

    $('#btn').hide(); //hide submit button
    $('#categorySelector').hide();   //hide second selectBox
    var $optgroups = $('#categorySelector > optgroup');

    $("#topic").on("change",function(){

    var selectedVal = this.value;
    console.log(selectedVal);
        $('#categorySelector').html( $optgroups.filter('[label="'+selectedVal+'"]') );

        $('#categorySelector').attr('placeholder', 'select item'); //wont work
    $('#categorySelector').show();

    });

    $('#categorySelector').on('change', function() {
       $('#btn').show();
    });
});

Some how categorySelector -select preselects first value from filtered optiongroup and ignores the hidden "SELECT" placeholder

Any clues how to get placeholder value "select" for categorySelect everytime these values are filtered

Somehow categorySelector -select pre-selects first value from filtered option-group and ignores the hidden "SELECT" placeholder

I also tried to add custom placeholder for  everytime the #topic onchange does the filtering.

$('#categorySelector').attr('placeholder', 'select item');

Any clues how to get placeholder value "select" for categoryselector everytime these values are filtered


问:
Running state machine on aiogram gives error: "AttributeError: 'NoneType' object has no attribute 'current_state'". Aiogram Python
I am writing a telegram bot and using the aiogram library. In parallel with the launch of the bot, I run the "check_time" function.
I have an async function "check_time" which in an infinite loop calls another async function "intermediary". The last function is checked, and if it = true, then another function is called. In this method, I already start the state machine. When starting the state machine, an error occurs:

```<code>File "E:\Profile\Desktop\Projects\Python\Productivity control\src\handlers\analysis.py", line 12, in check_time
     await intermediate()
   File "E:\Profile\Desktop\Projects\Python\Productivity control\src\handlers\analysis.py", line 29, in intermediary
     await asyncio.gather(*tasks)
   File "E:\Profile\Desktop\Projects\Python\Productivity control\src\handlers\analysis.py", line 35, in analysis
     await Days.value_of_day.set()
   File "C:\Users\serg\AppData\Local\Programs\Python\Python38-32\lib\site-packages\aiogram\dispatcher\filters\state.py", line 56, in set
     state = Dispatcher.get_current().current_state()
AttributeError: 'NoneType' object has no attribute 'current_state'
</code>```

Code:

```<code>async def check_time():
    while True:
        await asyncio.sleep(60)
        await intermediary()

async def intermediary():
    times = db.get_time_of_day()
    now = datetime.datetime.now()
    minute = str(now.minute)
    hour = str(now.hour)
    if len(str(now.minute)) == 1:
        minute = '0' + str(now.minute)
    if len(str(now.hour)) == 1:
        hour = '0' + str(hour)
    for time in times:
        if str(time[0]) == hour + minute:
            tasks = []
            tasks.append(asyncio.create_task(check_time()))
            tasks.append(asyncio.create_task(analysis(time[1])))
            await asyncio.gather(*tasks)
    print('all')

async def analysis(tg):
    await Days.value_of_day.set()
</code>```

State machine class code:

```<code>class Days(StatesGroup):
    value_of_day = State()
</code>```

db.py:

```<code>def get_time_of_day(self):
    with self.connection:
        time = self.cursor.execute(f"select time_of_day, tg_id from users").fetchall()
        return time
</code>```

What could be the problem? Please help, I can't do anything...

Body:
I am writing a telegram bot and using the aiogram library. In parallel with the launch of the bot, I run the "check_time" function.
I have an async function "check_time" which in an infinite loop calls another async function "intermediary". The last function is checked, and if it = true, then another function is called. In this method, I already start the state machine. When starting the state machine, an error occurs:

File "E:\Profile\Desktop\Projects\Python\Productivity control\src\handlers\analysis.py", line 12, in check_time
     await intermediate()
   File "E:\Profile\Desktop\Projects\Python\Productivity control\src\handlers\analysis.py", line 29, in intermediary
     await asyncio.gather(*tasks)
   File "E:\Profile\Desktop\Projects\Python\Productivity control\src\handlers\analysis.py", line 35, in analysis
     await Days.value_of_day.set()
   File "C:\Users\serg\AppData\Local\Programs\Python\Python38-32\lib\site-packages\aiogram\dispatcher\filters\state.py", line 56, in set
     state = Dispatcher.get_current().current_state()
AttributeError: 'NoneType' object has no attribute 'current_state'

Code:

async def check_time():
    while True:
        await asyncio.sleep(60)
        await intermediary()

async def intermediary():
    times = db.get_time_of_day()
    now = datetime.datetime.now()
    minute = str(now.minute)
    hour = str(now.hour)
    if len(str(now.minute)) == 1:
        minute = '0' + str(now.minute)
    if len(str(now.hour)) == 1:
        hour = '0' + str(hour)
    for time in times:
        if str(time[0]) == hour + minute:
            tasks = []
            tasks.append(asyncio.create_task(check_time()))
            tasks.append(asyncio.create_task(analysis(time[1])))
            await asyncio.gather(*tasks)
    print('all')

async def analysis(tg):
    await Days.value_of_day.set()

State machine class code:

class Days(StatesGroup):
    value_of_day = State()

db.py:

def get_time_of_day(self):
    with self.connection:
        time = self.cursor.execute(f"select time_of_day, tg_id from users").fetchall()
        return time

What could be the problem? Please help, I can't do anything...


问:
Andoid BLE createBond returns false on some devices?
Integrating with a BLE glucometer.  Pretty straightforward.  I'm following the BLE Spec.

Phone is a Motorola G32...will.  On various occasions I will get a createBond() call that returns false?

It's very random.  I'm trying to track it down with little success and looking for some guidance on what might trigger this to happen?

createBond() is an async call so it returns immediately and then I have a BroadcastReceiver listening for BT events.

here's some relevant code if anyone has any insight whatsoever.

```<code>            boolean tryToBond = getDevice().createBond();

        if (!tryToBond) {
            if (connectCtx != null) {
                connectCtx.error(getPluginResponseObject(failedToCreateBond, "Failed to initiate pairing.  createBond() return false")); // "Failed to initiate pairing.  createBond() return false");
            }

            return false;
        }
</code>```

Also here is the receiver.  Both are very simple...I'm leaning towards it being something simple and unrelated to the code but I can't figure out what.

Receiver code:

```<code>if (getDevice().getBondState() != BluetoothDevice.BOND_BONDED) { // YOU CAN IGNORE THIS LINE JUST SHOWING THAT WE ONLY REGISTER AND CALL CREATEBOND IF IT'S NOT ALREADY BONDED
        pairingBroadcastReceiver = new BroadcastReceiver() {
            @Override
            public void onReceive(Context context, Intent intent) {
                String action = intent.getAction();
                if (BluetoothDevice.ACTION_BOND_STATE_CHANGED.equals(action)){
                    aDevice = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
                    if (aDevice.getBondState() == BluetoothDevice.BOND_BONDED) {
                        //means device paired
                        Log.d("bt", "bonded");
                        pairingState = pairingStateEnum.success;
                    }
                    if (aDevice.getBondState() == BluetoothDevice.BOND_NONE){
                        Log.d("bt", "bonding failed");
                        pairingState = pairingStateEnum.failure;
                    }
                }
            }
        };
</code>```

Body:
Integrating with a BLE glucometer.  Pretty straightforward.  I'm following the BLE Spec.

Phone is a Motorola G32...will.  On various occasions I will get a createBond() call that returns false?

It's very random.  I'm trying to track it down with little success and looking for some guidance on what might trigger this to happen?

createBond() is an async call so it returns immediately and then I have a BroadcastReceiver listening for BT events.

here's some relevant code if anyone has any insight whatsoever.

            boolean tryToBond = getDevice().createBond();

        if (!tryToBond) {
            if (connectCtx != null) {
                connectCtx.error(getPluginResponseObject(failedToCreateBond, "Failed to initiate pairing.  createBond() return false")); // "Failed to initiate pairing.  createBond() return false");
            }

            return false;
        }

Also here is the receiver.  Both are very simple...I'm leaning towards it being something simple and unrelated to the code but I can't figure out what.

Receiver code:

if (getDevice().getBondState() != BluetoothDevice.BOND_BONDED) { // YOU CAN IGNORE THIS LINE JUST SHOWING THAT WE ONLY REGISTER AND CALL CREATEBOND IF IT'S NOT ALREADY BONDED
        pairingBroadcastReceiver = new BroadcastReceiver() {
            @Override
            public void onReceive(Context context, Intent intent) {
                String action = intent.getAction();
                if (BluetoothDevice.ACTION_BOND_STATE_CHANGED.equals(action)){
                    aDevice = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
                    if (aDevice.getBondState() == BluetoothDevice.BOND_BONDED) {
                        //means device paired
                        Log.d("bt", "bonded");
                        pairingState = pairingStateEnum.success;
                    }
                    if (aDevice.getBondState() == BluetoothDevice.BOND_NONE){
                        Log.d("bt", "bonding failed");
                        pairingState = pairingStateEnum.failure;
                    }
                }
            }
        };


问:
While connecting mongodb getting 'com.mongodb.MongoSecurityException: Failed to login Subject'
I am trying to connect mongodb enterprise instance in my project with the below statements, but i am getting an connection error. any solution would be appreciated here.

```<code>try (MongoClient client = MongoClients.create(URI)) {
     MongoIterable<String> dbNames = client.listDatabaseNames();
     dbNames.forEach(name -> System.out.println(name));
     client.close();
} catch (MongoException ex) {
     System.out.println("could not connect mongodb :" + ex);
}
</code>```

and the error i get

```<code>com.mongodb.MongoSecurityException: Failed to login Subject
    at com.mongodb.internal.connection.SaslAuthenticator.getSubject(SaslAuthenticator.java:202)
    at com.mongodb.internal.connection.SaslAuthenticator.doAsSubject(SaslAuthenticator.java:281)
    at com.mongodb.internal.connection.SaslAuthenticator.authenticate(SaslAuthenticator.java:59)
</code>```

BTW, i am using implementation 'org.mongodb:mongodb-driver-sync:4.8.1'

Body:
I am trying to connect mongodb enterprise instance in my project with the below statements, but i am getting an connection error. any solution would be appreciated here.

try (MongoClient client = MongoClients.create(URI)) {
     MongoIterable<String> dbNames = client.listDatabaseNames();
     dbNames.forEach(name -> System.out.println(name));
     client.close();
} catch (MongoException ex) {
     System.out.println("could not connect mongodb :" + ex);
}

and the error i get

com.mongodb.MongoSecurityException: Failed to login Subject
    at com.mongodb.internal.connection.SaslAuthenticator.getSubject(SaslAuthenticator.java:202)
    at com.mongodb.internal.connection.SaslAuthenticator.doAsSubject(SaslAuthenticator.java:281)
    at com.mongodb.internal.connection.SaslAuthenticator.authenticate(SaslAuthenticator.java:59)

BTW, i am using implementation 'org.mongodb:mongodb-driver-sync:4.8.1'


问:
Spark - size limit on filter predicates in getPartitionsByFilter()
By default Spark, when using external Hive metastore, will attempt to delegate partition pruning to HMS itself. For that, in HiveShim.getPartitionsByFilter() it will convert filters to the dialect understood by HMS, while skipping over unsupported predicates or those defined on non-partition columns:

```<code>  :
  override def getPartitionsByFilter(
      hive: Hive,
      table: Table,
      predicates: Seq[Expression]): Seq[Partition] = {

    // Hive getPartitionsByFilter() takes a string that represents partition
    // predicates like "str_key=\"value\" and int_key=1 ..."
      val filter = convertFilters(table, predicates)

      if (filter.isEmpty) {
        getAllPartitionsMethod.invoke(hive, table).asInstanceOf[JSet[Partition]]
      } else {
        logDebug(s"Hive metastore filter is '$filter'.")
        ...
  :
</code>```

My question: Is there any limitation on how long the string representing the predicates after conversion can be? Please note I'm not asking about JVM's physical limit (2GB), rather what Hive client and Hive metastore itself will support.

Body:
By default Spark, when using external Hive metastore, will attempt to delegate partition pruning to HMS itself. For that, in HiveShim.getPartitionsByFilter() it will convert filters to the dialect understood by HMS, while skipping over unsupported predicates or those defined on non-partition columns:

  :
  override def getPartitionsByFilter(
      hive: Hive,
      table: Table,
      predicates: Seq[Expression]): Seq[Partition] = {

    // Hive getPartitionsByFilter() takes a string that represents partition
    // predicates like "str_key=\"value\" and int_key=1 ..."
      val filter = convertFilters(table, predicates)

      if (filter.isEmpty) {
        getAllPartitionsMethod.invoke(hive, table).asInstanceOf[JSet[Partition]]
      } else {
        logDebug(s"Hive metastore filter is '$filter'.")
        ...
  :

My question: Is there any limitation on how long the string representing the predicates after conversion can be? Please note I'm not asking about JVM's physical limit (2GB), rather what Hive client and Hive metastore itself will support.


问:
NodeJS Zlib Decompress and Compress Pipe
I am trying to Decompress and then Compress a Resource received , here from node fetch.
As the script is brotly Compressed , i want to Decompress do some modification and Compress again but doing both DeCompress and Compress in pipe takes too long.

```<code>let fetch = require('node-fetch');
const {createBrotliCompress, createBrotliDecompress, brotliDecompress} = require('zlib');
(async () => {
    console.log('Checking compression');
    let url = 'https://www.youtube.com/s/desktop/25bf5aae/jsbin/desktop_polymer.vflset/desktop_polymer.js';
    let resp = await fetch(url, {
        method: "GET", headers: {
            "Accept-Encoding": "gzip, deflate, br"
        }, redirect: 'manual', response: 'stream', compress: false, credentials: true
    });
    let deComp = createBrotliDecompress({
        chunkSize: 16 * 1024
    });
    let comp = createBrotliCompress({
        chunkSize: 16 * 1024
    });
    // for await (const chunk of resp.body) {
    //     console.log(chunk.toString());
    // }
    // return;

    let i = 0;
    console.log('Status', resp.status);
    resp.body.pipe(deComp).pipe(comp);
    console.log('Pipe Start');
    deComp.on('data', function (data) {
        if (i++ === 0) {
            console.log(`DE-C Chunk ${i++}: ${data.length}`);
            // console.time('Got First Chunk');
            console.time('Decompression end');
        }
        console.log(`DE-C Chunk ${i++}: ${data.length}`);
    }).on("end", function () {
        console.timeEnd('Decompression end');
    }).on("error", function (e) {
        console.log(e)
    });

    let j = 0;
    comp.on('data', function (data) {
        if (j++ === 0) {
            console.log(`Chunk ${j++}: ${data.length}`);
            // console.time('Got First Chunk');
            console.time('Compression end');
        }
        console.log(`DC Chunk ${i++}: ${data.length}`);
    }).on("end", function () {
        console.timeEnd('Compression end');
    }).on("error", function (e) {
        console.log(e)
    });

})()
</code>```

Here the Entire Decompression and Compression takes 12 Sec , it should not take that much time

I am expecting it to be completed in less than 1.5 sec as the file Compressed is 1.6 MB and UnCompressed is 9.8 Mb

Body:
I am trying to Decompress and then Compress a Resource received , here from node fetch.
As the script is brotly Compressed , i want to Decompress do some modification and Compress again but doing both DeCompress and Compress in pipe takes too long.

let fetch = require('node-fetch');
const {createBrotliCompress, createBrotliDecompress, brotliDecompress} = require('zlib');
(async () => {
    console.log('Checking compression');
    let url = 'https://www.youtube.com/s/desktop/25bf5aae/jsbin/desktop_polymer.vflset/desktop_polymer.js';
    let resp = await fetch(url, {
        method: "GET", headers: {
            "Accept-Encoding": "gzip, deflate, br"
        }, redirect: 'manual', response: 'stream', compress: false, credentials: true
    });
    let deComp = createBrotliDecompress({
        chunkSize: 16 * 1024
    });
    let comp = createBrotliCompress({
        chunkSize: 16 * 1024
    });
    // for await (const chunk of resp.body) {
    //     console.log(chunk.toString());
    // }
    // return;

    let i = 0;
    console.log('Status', resp.status);
    resp.body.pipe(deComp).pipe(comp);
    console.log('Pipe Start');
    deComp.on('data', function (data) {
        if (i++ === 0) {
            console.log(`DE-C Chunk ${i++}: ${data.length}`);
            // console.time('Got First Chunk');
            console.time('Decompression end');
        }
        console.log(`DE-C Chunk ${i++}: ${data.length}`);
    }).on("end", function () {
        console.timeEnd('Decompression end');
    }).on("error", function (e) {
        console.log(e)
    });

    let j = 0;
    comp.on('data', function (data) {
        if (j++ === 0) {
            console.log(`Chunk ${j++}: ${data.length}`);
            // console.time('Got First Chunk');
            console.time('Compression end');
        }
        console.log(`DC Chunk ${i++}: ${data.length}`);
    }).on("end", function () {
        console.timeEnd('Compression end');
    }).on("error", function (e) {
        console.log(e)
    });

})()

Here the Entire Decompression and Compression takes 12 Sec , it should not take that much time

I am expecting it to be completed in less than 1.5 sec as the file Compressed is 1.6 MB and UnCompressed is 9.8 Mb


问:
How to open extension in selenium by the icon?
I add chrome extension in selenium through .trx file and now I need to open this extension on a page to activate it like this
check image, so not the full extension through link chrome-extension://, but just the little window and then press the buttons, how it can be possible?

```<code>from selenium import webdriver
from selenium.webdriver.chrome.options import Options

option = webdriver.ChromeOptions()
option.add_extension('extension.crx')
driver = webdriver.Chrome

driver.get('https://google.com/')
</code>```

Body:
I add chrome extension in selenium through .trx file and now I need to open this extension on a page to activate it like this
check image, so not the full extension through link chrome-extension://, but just the little window and then press the buttons, how it can be possible?

from selenium import webdriver
from selenium.webdriver.chrome.options import Options

option = webdriver.ChromeOptions()
option.add_extension('extension.crx')
driver = webdriver.Chrome

driver.get('https://google.com/')