问:
Bootstrap Navigation Flex-Column issue with stacking ml-auto and mr-auto
I have a navigation layout that uses Bootstrap 4. I have done the best I can to make it look professional but I am struggling to make it look the way I want both on desktop and mobile layout (on mobile, mainly make the toggle button display on the right).

I am pretty well versed in these sort of things but I am busy with backend work and I guess flexbox isn't working the way I expect.

On desktop I am attempting to take the account link in the nav and have it be right aligned with the top navigation row, on mobile I would like the account link to be placed at the bottom of the collapsed navigation.

<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">

<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet" type="text/css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css">

<link href="https://exactestate.sfo2.digitaloceanspaces.com/static/fontawesome-pro/css/all.css" rel="stylesheet" type="text/css"/>

<link href="https://exactestate.sfo2.digitaloceanspaces.com/static/css/main_style.css" rel="stylesheet" type="text/css"/>
<link href="https://exactestate.sfo2.digitaloceanspaces.com/static/css/form_style.css" rel="stylesheet" type="text/css"/>
<link href="https://exactestate.sfo2.digitaloceanspaces.com/static/css/animation_css.css" rel="stylesheet" type="text/css"/>

    <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbar"
            aria-controls="navbarToggler" aria-expanded="false" aria-label="Toggle navigation">

    </button>

            ExactEstateManagement Software

                 Users

                 Register User

                 Users

                 Applications

                     New Application

                     Existing Applications

                     Management Processing

                     Compliance Processing

                     Application Dashboard and Preleasing

                 Properties

                     Properties

                     Units

                     Water Billing

                     Merchants

                 Prospects

                     Guest Cards

                     Appointments

                 Residents

                     Ledgers

                     Late Fee Declaration

                     Resident Search

                     Resident Extras

                     Enter Residents

                     Renewals
                {#                    #}
                {#                         Renewal Settings#}

                 Tasks

                     Create

                     View Completable Tasks

                     View Created Tasks

                 Reports

                     Reports

                 Documents

                      Upload Documents

                     Download Documents

                     Document Builder

                 Forms

                     View Forms

                     Create Form Declarations

                 Work Orders

                     Work Order Declaration

                     View Work Orders

                     Submit Work Order

                 Visitors

                 Enter
                    Visitor

                 Visitors

                 Account

Account

                     Edit Account Information

                     Logout

```

答:
EDIT : after OP made his expectations clear, I revamped the code and added media queries for the different positioning of the elements between mobile and desktop screens and I still kept the div wrapper for the whole menu and made it float-left.

Demo below :

<!DOCTYPE html>

    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">

<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet" type="text/css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css">

    <link href="https://exactestate.sfo2.digitaloceanspaces.com/static/fontawesome-pro/css/all.css" rel="stylesheet" type="text/css"/>

    <link href="https://exactestate.sfo2.digitaloceanspaces.com/static/css/main_style.css" rel="stylesheet" type="text/css"/>
    <link href="https://exactestate.sfo2.digitaloceanspaces.com/static/css/form_style.css" rel="stylesheet" type="text/css"/>
    <link href="https://exactestate.sfo2.digitaloceanspaces.com/static/css/animation_css.css" rel="stylesheet" type="text/css"/>

        <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbar"
                aria-controls="navbarToggler" aria-expanded="false" aria-label="Toggle navigation">

        </button>

                ExactEstateManagement Software

                         Users

                         Register User

                         Users

                         Applications

                             New Application

                             Existing Applications

                             Management Processing

                             Compliance Processing

                             Application Dashboard and Preleasing

                         Properties

                             Properties

                             Units

                             Water Billing

                             Merchants

                         Prospects

                             Guest Cards

                             Appointments

                         Residents

                             Ledgers

                             Late Fee Declaration

                             Resident Search

                             Resident Extras

                             Enter Residents

                             Renewals
                        {#                    #}
                        {#                         Renewal Settings#}

                         Tasks

                             Create

                             View Completable Tasks

                             View Created Tasks

                         Reports

                             Reports

                         Documents

                              Upload Documents

                             Download Documents

                             Document Builder

                         Forms

                             View Forms

                             Create Form Declarations

                         Work Orders

                             Work Order Declaration

                             View Work Orders

                             Submit Work Order

                         Visitors

                         Enter
                            Visitor

                         Visitors

                         Account

Account

                             Edit Account Information

                             Logout

© ViaTech Systems® 2019. All Rights Reserved.

```

Body:
EDIT : after OP made his expectations clear, I revamped the code and added media queries for the different positioning of the elements between mobile and desktop screens and I still kept the div wrapper for the whole menu and made it float-left.

Demo below :

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <!-- bootstrap, js, and jquery -->

<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet" type="text/css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css">

<!-- jquery -->
<script src="https://code.jquery.com/jquery-3.3.1.min.js"
        integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script>

<!-- js -->
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.bundle.min.js"></script>

    <!-- font awesome-->
    <link href="https://exactestate.sfo2.digitaloceanspaces.com/static/fontawesome-pro/css/all.css" rel="stylesheet" type="text/css"/>

    <!-- custom files -->
    <link href="https://exactestate.sfo2.digitaloceanspaces.com/static/css/main_style.css" rel="stylesheet" type="text/css"/>
    <link href="https://exactestate.sfo2.digitaloceanspaces.com/static/css/form_style.css" rel="stylesheet" type="text/css"/>
    <link href="https://exactestate.sfo2.digitaloceanspaces.com/static/css/animation_css.css" rel="stylesheet" type="text/css"/>
    <script src="https://exactestate.sfo2.digitaloceanspaces.com/static/js/local_timezone_cookie.js"></script>

</head>

    <style>
    .example{
        border: solid black;
    }
    </style>

<body>
<div class="main">
    <header>

      <style>
    #logo {
        vertical-align: middle;
        width: 50px;
    }

    .navbar-brand span {
        color: white;
        font-size: 2rem;
        line-height: 1.2;
        font-weight: 200;
        display: inline-block;
        vertical-align: middle;
        padding: 0 0 0 15px;
    }

    .navbar-brand b {
        display: block;
        font-size: 50%;
        line-height: 1;
    }

    @media (min-width: 992px) {
        #applicationsMenu {
            margin-left: 100px;
            margin-top: -50px;
        }
        #documentsMenu {
            margin-left: 100px;
        }
        #accountMenu {
            position: absolute !important;
            top: 5px;
            right: 10px;
        }
    }

</style>

<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
    <div class="navbar-toggler-right ml-auto">
        <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbar"
                aria-controls="navbarToggler" aria-expanded="false" aria-label="Toggle navigation">

            <span class="navbar-toggler-icon"></span>
        </button>
    </div>
    <div class="collapse navbar-collapse" id="navbar">
        <div class="float-left">
            <!-------------------------------------------------------------------------------------------------------no fle -->
            <a class="navbar-brand" href="#"><img id="logo" alt="Logo" src="https://exactestate.sfo2.digitaloceanspaces.com/static/images/logo_white.png">
                <span class="d-lg-none">ExactEstate<b>Management Software</b></span>
            </a>
            <ul id="applicationsMenu" class="navbar-nav">
                <!-------------------------------------------------------------------------------------------------------Users-->
                <li class="nav-item dropdown">
                    <a class="nav-link dropdown-toggle" href="#" role="button" data-toggle="dropdown">
                        <i class="fas fa-users" style="color:white;"></i> Users
                    </a>
                    <div class="dropdown-menu" aria-labelledby="navDropdown">
                        <a class="dropdown-item" href="{% url 'users_create' CLIENT.id %}"><i
                                class="far fa-user-plus"></i> Register User</a>
                        <div class="dropdown-divider"></div>
                        <a class="dropdown-item" href="{% url 'users_index' CLIENT.id %}"><i
                                class="fas fa-users"></i> Users</a>
                    </div>
                </li>
                <!-------------------------------------------------------------------------------------------------------Applications-->
                <li class="nav-item dropdown">
                    <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown">
                        <i class="fa fa-book" style="color:white;"></i> Applications
                    </a>
                    <div class="dropdown-menu" aria-labelledby="navbarDropdown">
                        <a class="dropdown-item" href="{% url 'applications_create' CLIENT.id %}">
                            <i class="fas fa-file-plus"></i> New Application</a>

                        <a class="dropdown-item" href="{% url 'applications_index' CLIENT.id %}">
                            <i class="fas fa-cabinet-filing"></i> Existing Applications</a>

                        <div class="dropdown-divider"></div>

                        <a class="dropdown-item"
                        href="{% url 'applications_processing_management' CLIENT.id %}">
                            <i class="far fa-ballot-check"></i> Management Processing</a>
                        <a class="dropdown-item"
                        href="{% url 'applications_processing_compliance' CLIENT.id %}">
                            <i class="fas fa-ballot-check"></i> Compliance Processing</a>

                        <div class="dropdown-divider"></div>

                        <a class="dropdown-item"
                        href="{% url 'applications_preleasing' CLIENT.id %}">
                            <i class="fa fa-book"></i> Application Dashboard and Preleasing</a>
                    </div>
                </li>
                <!-------------------------------------------------------------------------------------------------------Properties-->
                <li class="nav-item dropdown">
                    <a class="nav-link dropdown-toggle" href="#" role="button">
                        <i class="far fa-building" style="color:white;"></i> Properties
                    </a>
                    <div class="dropdown-menu" aria-labelledby="navDropdown">
                        <a class="dropdown-item" href="{% url 'properties_index' CLIENT.id %}">
                            <i class="far fa-building"></i> Properties</a>
                        <a class="dropdown-item" href="{% url 'properties_units_search' CLIENT.id %}">
                            <i class="fas fa-bed"></i> Units</a>
                        <a class="dropdown-item" href="{% url 'properties_water_billing_index' CLIENT.id %}">
                            <i class="far fa-tint"></i> Water Billing</a>

                        <a class="dropdown-item" href="{% url 'merchant_accounts_index' CLIENT.id %}">
                            <i class="far fa-usd-square"></i> Merchants</a>
                    </div>
                </li>
                <!-------------------------------------------------------------------------------------------------------Prospects-->
                <li class="nav-item dropdown">
                    <a class="nav-link dropdown-toggle" href="#" role="button" data-toggle="dropdown">
                        <i class="far fa-layer-plus" style="color:white;"></i> Prospects
                    </a>
                    <div class="dropdown-menu" aria-labelledby="navDropdown">
                        <a class="dropdown-item" href="{% url 'guest_cards_index' CLIENT.id %}">
                            <i class="fal fa-id-card-alt"></i> Guest Cards
                        </a>
                        <a class="dropdown-item" href="{% url 'appointments_index' CLIENT.id %}">
                            <i class="fal fa-phone"></i> Appointments
                        </a>

                    </div>
                </li>
                <!-------------------------------------------------------------------------------------------------------Residents-->
                <li class="nav-item dropdown">
                    <a class="nav-link dropdown-toggle" href="#" role="button" data-toggle="dropdown">
                        <i class="far fa-people-carry" style="color:white;"></i> Residents
                    </a>
                    <div class="dropdown-menu" aria-labelledby="navDropdown">
                        <a class="dropdown-item" href="{% url 'residents_ledgers_index' CLIENT.id %}">
                            <i class="far fa-file-invoice-dollar"></i> Ledgers</a>
                        <a class="dropdown-item" href="{% url 'residents_late_fees' CLIENT.id %}">
                            <i class="far fa-file-invoice-dollar"></i> Late Fee Declaration</a>
                        <div class="dropdown-divider"></div>
                        <a class="dropdown-item" href="{% url 'residents_index' CLIENT.id %}">
                            <i class="fas fa-search"></i> Resident Search</a>
                        <a class="dropdown-item" href="{% url 'residents_extras_index' CLIENT.id %}">
                            <i class="fas fa-plus-square"></i> Resident Extras</a>
                        <a class="dropdown-item" href="{% url 'residents_create' CLIENT.id %}">
                            <i class="fal fa-person-booth"></i> Enter Residents</a>

                        <div class="dropdown-divider"></div>

                        <a class="dropdown-item" href="{% url 'residents_renewals' CLIENT.id %}">
                            <i class="fal fa-calendar-plus"></i> Renewals</a>
                        {#                    <a class="dropdown-item" href="\23\residents\renewal_settings\">#}
                        {#                        <i class="fal fa-cog"></i> Renewal Settings</a>#}
                    </div>
                </li>
            <!-------------------------------------------------------------------------------------------------------Tasks-->
                <li class="nav-item dropdown">
                    <a class="nav-link dropdown-toggle" href="#" role="button" data-toggle="dropdown">
                        <i class="fas fa-tasks" style="{% if OPEN_TASKS %}color:red;{% else %}color:white;{% endif %}"></i>&nbsp;Tasks
                    </a>
                    <div class="dropdown-menu" aria-labelledby="navDropdown">
                        <a class="dropdown-item" href="{% url 'tasks_create' CLIENT.id %}">
                            <i class="far fa-plus"></i> Create </a>
                        <div class="dropdown-divider"></div>
                        <a class="dropdown-item" href="{% url 'tasks_list' CLIENT.id %}">
                            <i class="fal fa-eye" style="{% if OPEN_USER_TASKS %}color:red;{% endif %}"></i> View Completable Tasks
                        </a>
                        <a class="dropdown-item" href="{% url 'tasks_status' CLIENT.id %}">
                            <i class="fal fa-eye" style="{% if OPEN_SYSTEM_TASKS %}color:red;{% endif %}"></i> View Created Tasks
                        </a>
                    </div>
                </li>
            <!----------------------------------------------------------------------------------------------------Reports-->
                <li class="nav-item dropdown">
                    <a class="nav-link dropdown-toggle" href="#" role="button" data-toggle="dropdown">
                        <i class="fas fa-file-chart-line" style="color:white;"></i>&nbsp;Reports
                    </a>
                    <div class="dropdown-menu" aria-labelledby="navDropdown">
                        <a class="dropdown-item" href="{% url 'reports_index' CLIENT.id %}">
                            <i class="far fa-file-chart-line"></i> Reports
                        </a>
                    </div>
                </li>

            </ul>

            <ul id="documentsMenu" class="navbar-nav">
                <!------------------------------------------------------------------------------------------------------Documents-->
                <li class="nav-item dropdown">
                    <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown">
                        <i class="fas fa-folder-open" style="color:white;"></i> Documents
                    </a>
                    <div class="dropdown-menu" aria-labelledby="navbarDropdown">
                        <a class="dropdown-item" href="{% url 'documents_upload' CLIENT.id %}">
                            <i class="far fa-file-upload"> </i> Upload Documents </a>
                        <a class="dropdown-item" href="{% url 'documents_index' CLIENT.id %}">
                            <i class="far fa-file-download"></i> Download Documents </a>
                        <a class="dropdown-item" href="{% url 'documents_builder_index' CLIENT.id %}">
                            <i class="far fa-hard-hat"></i> Document Builder </a>
                    </div>
                </li>
                <!------------------------------------------------------------------------------------------------------Forms-->
                <li class="nav-item dropdown">
                    <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown">
                        <i class="fab fa-wpforms" style="color:white;"></i> Forms
                    </a>
                    <div class="dropdown-menu" aria-labelledby="navbarDropdown">
                        <a class="dropdown-item" href="{% url 'forms_index' CLIENT.id %}">
                            <i class="fab fa-wpforms"></i> View Forms</a>
                        <a class="dropdown-item" href="{% url 'forms_declarations_index' CLIENT.id %}">
                            <i class="fab fa-wpforms"></i> Create Form Declarations</a>
                    </div>
                </li>
            <!-------------------------------------------------------------------------------------------------------Work Orders-->
                <li class="nav-item dropdown">
                    <a class="nav-link dropdown-toggle" href="#" role="button" data-toggle="dropdown">
                        <i class="far fa-user-hard-hat" style="color:white;"></i> Work Orders
                    </a>
                    <div class="dropdown-menu" aria-labelledby="navDropdown">
                        <a class="dropdown-item" href="{% url 'work_orders_declarations' CLIENT.id %}">
                            <i class="fal fa-flag-checkered"></i> Work Order Declaration </a>
                        <a class="dropdown-item" href="{% url 'work_orders_index' CLIENT.id %}">
                            <i class="fal fa-eye"></i> View Work Orders
                        </a>
                        <a class="dropdown-item" href="{% url 'work_orders_submit' CLIENT.id %}">
                            <i class="fas fa-clipboard-list"></i> Submit Work Order
                        </a>
                    </div>
                </li>
                <!-------------------------------------------------------------------------------------------------------Visitors-->
                <li class="nav-item dropdown">
                    <a class="nav-link dropdown-toggle" href="#"
                    id="navbarDropdown" role="button"
                    data-toggle="dropdown" aria-haspopup="true"
                    aria-expanded="false">
                        <i class="fa fa-user-plus" style="color:white;"></i> Visitors
                    </a>
                    <div class="dropdown-menu" aria-labelledby="navbarDropdown">
                        <a class="dropdown-item" href="{% url 'visitors_enter' CLIENT.id %}"><i class="fas fa-user-plus"></i> Enter
                            Visitor</a>
                        <div class="dropdown-divider"></div>
                        <a class="dropdown-item" href="{% url 'visitors_index' CLIENT.id %}"><i class="fas fa-users"></i> Visitors</a>
                    </div>
                </li>

                <li id="accountMenu" class="nav-item dropdown">
                    <a class="nav-link dropdown-toggle" href="#"
                    role="button"
                    data-toggle="dropdown" aria-haspopup="true"
                    aria-expanded="false">
                        <i class="fas fa-user" style="color: white"></i> Account
                    </a>
                    <div class="dropdown-menu dropdown-menu-right" aria-labelledby="navDropdown">
                        <h4 style="text-align:center;">Account </h4>
                        <div class="dropdown-divider"></div>
                        <a class="dropdown-item" href="{% url 'update_account' CLIENT.id %}">
                            <i class="far fa-edit"></i> Edit Account Information</a>
                        <a class="dropdown-item" href="{% url 'login_logout' CLIENT.id %}">
                            <i class="far fa-sign-out-alt"></i> Logout</a>
                    </div>
                </li>
            </ul>
        </div>
    </div>
</nav>

    </header>

</div>
<footer>
    <div class="accent_color" style="height:5px;"></div>
    <div class="over_copyright" style="min-height: 25px;">
        <div class="container-fluid center">
            <div class="row">

    <div class="col-sm-6"><p class="in_footer_text" style="text-align: left;"></p></div>
<div class="col-sm-6"><p class="in_footer_text" style="text-align: right;"></p></div>

            </div>
        </div>
    </div>
    <p class="in_footer_text">&copy; ViaTech Systems&reg; 2019. All Rights Reserved.</p>
</footer>

</body>
</html>


来源: stackexchange

问:
R: How to colorize the diagonal panels in a pairs() plot?
The following code colorizes the panel backgrounds of a pairs plot in R. How can I colorize the diagonal panel (where the variable names are printed)? As you can see, I tried it but the variable names are not correctly aligned (for whatever reason).

```<code>count <- 0
mypanel <- function(x, y, ...){

   count <<- count+1
   bg <- if(count %in% c(1,4,9,12)) "#FDFF65" else "transparent"    ll <- par("usr")
   rect(ll[1], ll[3], ll[2], ll[4], col=bg)    points(x, y, cex=0.5)
}

mydiag.panel <- function(x, ...){

   ll <- par("usr")
   rect(ll[1], ll[3], ll[2], ll[4], col="#FDFF65") }

U <- matrix(runif(4*500), ncol=4)
pairs(U, panel=mypanel, diag.panel=mydiag.panel)
</code>```

答:
I was able to shade my diagonal without a complicated code:</p>

```<code>panel.diag <- function(x,...){
usr <- par("usr")
rect(usr[1],usr[3],usr[2],usr[4],col="pink")
}

pairs(U,upper.panel=panel.cor,lower.panel=panel.pts, diag.panel=panel.diag, label.pos=0.5)
</code>```

ContentLicense: CC BY-SA 3.0

Body:
The following code colorizes the panel backgrounds of a pairs plot in R. How can I colorize the diagonal panel (where the variable names are printed)? As you can see, I tried it but the variable names are not correctly aligned (for whatever reason).

count <- 0
mypanel <- function(x, y, ...){

   count <<- count+1
   bg <- if(count %in% c(1,4,9,12)) "#FDFF65" else "transparent"    ll <- par("usr")
   rect(ll[1], ll[3], ll[2], ll[4], col=bg)    points(x, y, cex=0.5)
}

mydiag.panel <- function(x, ...){

   ll <- par("usr")
   rect(ll[1], ll[3], ll[2], ll[4], col="#FDFF65") }

U <- matrix(runif(4*500), ncol=4)
pairs(U, panel=mypanel, diag.panel=mydiag.panel)

Body:
I was able to shade my diagonal without a complicated code:

panel.diag <- function(x,...){
usr <- par("usr")
rect(usr[1],usr[3],usr[2],usr[4],col="pink")
}

pairs(U,upper.panel=panel.cor,lower.panel=panel.pts, diag.panel=panel.diag, label.pos=0.5)

ContentLicense: CC BY-SA 4.0


问:
Maven ignoring variables in child pom
i been stuck with this for a while.
I am trying to automate the build and deploy (in nexus3) of several java modules and remove the need for manually set the module version in the projects pom.

My issue is that maven is ignoring the variables inside the pom files.

Parent pom:

```<code><properties>
  <revision>local</revision>
</properties>

<name>lib-cloud</name>
<groupId>com.company.lib</groupId>
<artifactId>lib-cloud</artifactId>
<version>${revision}</version>
<packaging>pom</packaging>
<modules>
    <module>lib-cloud-main</module>
</modules>
</code>```

and the child pom:

```<code><properties>
    <unrelatedVAR>2017.3.3</unrelatedVAR>
</properties>

<parent>
    <groupId>com.company.lib</groupId>
    <artifactId>lib-cloud</artifactId>
    <version>${revision}</version>
</parent>

<artifactId>lib-cloud-main</artifactId>
<name>lib-cloud-main</name>
</code>```

and then i build this with:

```<code>mvn -Drevision=3.1 clean package deploy
</code>```

This build the code just fine, create a lib-cloud-main/target/lib-cloud-main-3.1.jar

In side the jar, i can already see that
lib-cloud-main-3.1.jar/maven/com.company.lib/lib-cloud-main/pom.xml have

```<code><version>${revision}</version>
</code>```

As version, instead 3.1 as i would expected, but still this artifact manages to be saved in nexus.

If i try to use it, however, maven trow the error when trying to get the pom:

```<code>[ERROR] Failed to execute goal on project core-backend-api: Could not resolve dependencies for project com.company.core:core-backend-api:jar:local: Failed to collect dependencies at com.company.lib:lib-cloud-main:jar:3.1: Failed to read artifact descriptor for com.company.lib:lib-cloud-main:jar:3.1: Could not transfer artifact com.company.lib:lib-cloud:pom:${revision} from/to company-maven-public (http://mvn.company.local/repository/maven-public/): Failed to transfer file: http://mvn.company.local/repository/maven-public/com/company/lib/lib-cloud/$%7Brevision%7D/lib-cloud-$%7Brevision%7D.pom. Return code is: 400 , ReasonPhrase:Invalid repository path.
</code>```

I even tried to use

```<code>mvn release:update-versions -DdevelopmentVersion=3.1
</code>```

As a way to overwrite the poms with a static value before the build but this methos STILL fail to touch the  tag in any project children pom.

What i am doing wrong?

Apache Maven 3.5.4 (Red Hat 3.5.4-4) Maven home: /usr/share/maven Java
  version: 1.8.0_212, vendor: Oracle Corporation, runtime:
  /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.212.b04-0.fc29.x86_64/jre
  Default locale: pt_BR, platform encoding: UTF-8 OS name: "linux",
  version: "5.0.17-200.fc29.x86_64", arch: "amd64", family: "unix"

答:
You should use release plugin to do this.

mvn release:update-versions -DautoVersionSubmodules=true

Title: Maven ignoring variables in child pom

Body:
i been stuck with this for a while.
I am trying to automate the build and deploy (in nexus3) of several java modules and remove the need for manually set the module version in the projects pom.

My issue is that maven is ignoring the variables inside the pom files.

Parent pom:

<properties>
  <revision>local</revision>
</properties>

<name>lib-cloud</name>
<groupId>com.company.lib</groupId>
<artifactId>lib-cloud</artifactId>
<version>${revision}</version>
<packaging>pom</packaging>
<modules>
    <module>lib-cloud-main</module>
</modules>

and the child pom:

<properties>
    <unrelatedVAR>2017.3.3</unrelatedVAR>
</properties>

<parent>
    <groupId>com.company.lib</groupId>
    <artifactId>lib-cloud</artifactId>
    <version>${revision}</version>
</parent>

<artifactId>lib-cloud-main</artifactId>
<name>lib-cloud-main</name>

and then i build this with:

mvn -Drevision=3.1 clean package deploy

This build the code just fine, create a lib-cloud-main/target/lib-cloud-main-3.1.jar

In side the jar, i can already see that
lib-cloud-main-3.1.jar/maven/com.company.lib/lib-cloud-main/pom.xml have

<version>${revision}</version>

As version, instead 3.1 as i would expected, but still this artifact manages to be saved in nexus.

If i try to use it, however, maven trow the error when trying to get the pom:

[ERROR] Failed to execute goal on project core-backend-api: Could not resolve dependencies for project com.company.core:core-backend-api:jar:local: Failed to collect dependencies at com.company.lib:lib-cloud-main:jar:3.1: Failed to read artifact descriptor for com.company.lib:lib-cloud-main:jar:3.1: Could not transfer artifact com.company.lib:lib-cloud:pom:${revision} from/to company-maven-public (http://mvn.company.local/repository/maven-public/): Failed to transfer file: http://mvn.company.local/repository/maven-public/com/company/lib/lib-cloud/$%7Brevision%7D/lib-cloud-$%7Brevision%7D.pom. Return code is: 400 , ReasonPhrase:Invalid repository path.

I even tried to use

mvn release:update-versions -DdevelopmentVersion=3.1

As a way to overwrite the poms with a static value before the build but this methos STILL fail to touch the  tag in any project children pom.

What i am doing wrong?

Apache Maven 3.5.4 (Red Hat 3.5.4-4) Maven home: /usr/share/maven Java
  version: 1.8.0_212, vendor: Oracle Corporation, runtime:
  /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.212.b04-0.fc29.x86_64/jre
  Default locale: pt_BR, platform encoding: UTF-8 OS name: "linux",
  version: "5.0.17-200.fc29.x86_64", arch: "amd64", family: "unix"


问:
How to give different bg color to each  created using php function?
I've a table showing 7 days of week created using php function. How can i give different background color to each day in the table. I'm new to this, any and all help would be great.

```<code><?php
for($prev_days = 0 ; $prev_days<7;$prev_days++) {
    $curr_date = date('Y-m-d', strtotime(-$prev_days.' days'));
    $dayOfWeek = date("l",strtotime(strval($curr_date)));
    /*echo $dayOfWeek;*/
?>
    <td title="click here to see the files">
        <label>
            <a onclick="document.getElementById('id01').style.display='block'" class="clr">
                <?php echo substr(strval($dayOfWeek),0,3); ?>
            </a>
        </label>
    </td>
<?php
    }
?>

.CSSTableGenerator tr:first-child td{
background:-o-linear-gradient(bottom, #005fbf 5%, #003f7f 100%);
background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #005fbf), color-stop(1, #003f7f) );
background:-moz-linear-gradient( center top, #005fbf 5%, #003f7f 100% );
filter:progid:DXImageTransform.Microsoft.gradient(startColorstr="#005fbf", endColorstr="#003f7f");  background: -o-linear-gradient(top,#005fbf,003f7f);
background-color:#005fbf;
}
</code>```

This is the table created
: https://i.stack.imgur.com/nLnxP.png

答:
CSS Solution

Using nth terms:

td:nth-of-type(1) {
  background: red;
}
td:nth-of-type(2) {
  background: blue;
}
td:nth-of-type(3) {
  background: green;
}
td:nth-of-type(4) {
  background: yellow;
}
td:nth-of-type(5) {
  background: orange;
}
td:nth-of-type(6) {
  background: gray;
}
```

<p>... And so on</p>

<h2>PHP Solution</h2>

<p>First off, you'd want to create a method that returns a random HEX or something</p>

<p>Like so:</p>

<pre class="lang-php prettyprint-override"><code><?php
function random_color_part() {
    return str_pad( dechex( mt_rand( 0, 255 ) ), 2, '0', STR_PAD_LEFT);
}

function random_color() {
    return random_color_part() . random_color_part() . random_color_part();
}
?>
</code>```

Generating a random hex color code with PHP

Next, we need to use this like so:

<?php for($prev_days = 0 ; $prev_days<7;$prev_days++) {$curr_date = date('Y-m-d', strtotime(-$prev_days.' days'));$dayOfWeek = date("l",strtotime(strval($curr_date)));
/*echo $dayOfWeek;*/?>
 class="clr"><?php echo substr(strval($dayOfWeek),0,3); ?>
<?php}?>
```

So basically we're using PHP to output a dynamic style attribute to each TD.

Hopefully, this helped ya out, mate!

Title: How to give different bg color to each <td> created using php function?

Body:
I've a table showing 7 days of week created using php function. How can i give different background color to each day in the table. I'm new to this, any and all help would be great.

<?php
for($prev_days = 0 ; $prev_days<7;$prev_days++) {
    $curr_date = date('Y-m-d', strtotime(-$prev_days.' days'));
    $dayOfWeek = date("l",strtotime(strval($curr_date)));
    /*echo $dayOfWeek;*/
?>

                <?php echo substr(strval($dayOfWeek),0,3); ?>

<?php
    }
?>

.CSSTableGenerator tr:first-child td{
background:-o-linear-gradient(bottom, #005fbf 5%, #003f7f 100%);
background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #005fbf), color-stop(1, #003f7f) );
background:-moz-linear-gradient( center top, #005fbf 5%, #003f7f 100% );
filter:progid:DXImageTransform.Microsoft.gradient(startColorstr="#005fbf", endColorstr="#003f7f");  background: -o-linear-gradient(top,#005fbf,003f7f);
background-color:#005fbf;
}

This is the table created
: https://i.stack.imgur.com/nLnxP.png

Body:
CSS Solution

Using nth terms:

td:nth-of-type(1) {
  background: red;
}
td:nth-of-type(2) {
  background: blue;
}
td:nth-of-type(3) {
  background: green;
}
td:nth-of-type(4) {
  background: yellow;
}
td:nth-of-type(5) {
  background: orange;
}
td:nth-of-type(6) {
  background: gray;
}

... And so on

PHP Solution

First off, you'd want to create a method that returns a random HEX or something

Like so:

<?php
function random_color_part() {
    return str_pad( dechex( mt_rand( 0, 255 ) ), 2, '0', STR_PAD_LEFT);
}

function random_color() {
    return random_color_part() . random_color_part() . random_color_part();
}
?>

Generating a random hex color code with PHP

Next, we need to use this like so:

<?php for($prev_days = 0 ; $prev_days<7;$prev_days++) {$curr_date = date('Y-m-d', strtotime(-$prev_days.' days'));$dayOfWeek = date("l",strtotime(strval($curr_date)));
/*echo $dayOfWeek;*/?>
<td title="click here to see the files"><label><a onclick="document.getElementById('id01').style.display='block'" style=<?php echo "'" . random_color() . "'" ?> class="clr"><?php echo substr(strval($dayOfWeek),0,3); ?></a></label></td>
<?php}?>

So basically we're using PHP to output a dynamic style attribute to each TD.

Hopefully, this helped ya out, mate!


问:
Synchronize Data From Multiple Data Sources
Our team is trying to build a predictive maintenance system whose task is to look at a set of events and predict whether these events depict a set of known anomalies or not.

We are at the design phase and the current system design is as follows:

The events may occur on multiple sources of an IoT system (such as cloud platform, edge devices or any intermediate platforms)

The events are pushed by the data sources into a message queueing system (currently we have chosen Apache Kafka).

Each data source has its own queue (Kafka Topic).

From the queues, the data is consumed by multiple inference engines (which are actually neural networks).

Depending upon the feature set, an inference engine will subscribe to
multiple Kafka topics and stream data from those topics to continuously output the inference.

The overall architecture follows the single-responsibility principle meaning that every component will be separate from each other and run inside a separate Docker container.

Problem:

In order to classify a set of events as an anomaly, the events have to occur in the same time window. e.g. say there are three data sources pushing their respective events into Kafka topics, but due to some reason, the data is not synchronized.
So one of the inference engines pulls the latest entries from each of the kafka topics, but the corresponding events in the pulled data do not belong to the same time window (say 1 hour). That will result in invalid predictions due to out-of-sync data.

Question

We need to figure out how can we make sure that the data from all three sources are pushed in-order so that when an inference engine requests entries (say the last 100 entries) from multiple kakfa topics, the corresponding entries in each topic belong to the same time window?

答:
To handle this scenario, data sources must provide some mechanism for the consumer to realize that all relevant data has arrived. The simplest solution is to publish a batch from data source with a batch Id (Guid) of some form. Consumers can then wait until the next batch id shows up marking the end of the previous batch. This approach assumes sources will not skip a batch, otherwise they will get permanently mis-aligned. There is no algorithm to detect this but you might have some fields in the data that show discontinuity and allow you to realign the data.

A weaker version of this approach is to either just wait x-seconds and assume all sources succeed in this much time or look at some form of time stamps (logical or wall clock) to detect that a source has moved on to the next time window implicitly showing completion of the last window.


问:
what is the es6 fat arrow equivalent to a es5 function declaration
With ES5 I can declare either a function declaration or expression, depending on what I need.

```<code>function es5FunctionDeclaration() {
  return 'I am an es5 function declaration';
}

var es5FunctionExpression = function() {
  return 'I am an es5 function expression';
}
</code>```

With the ES6 fat arrow, it is common to create a function expression like this...

```<code>const es6FunctionExpression = () => {
  return 'I am an es6 function expression';
}
</code>```

But I haven't find a way to do a function declaration with a fat arrow, perhaps it is not possible.

```<code>// es6FunctionDeclarationWithFatArrow ??
</code>```

答:
The definition of an arrow function is here: http://www.ecma-international.org/ecma-262/6.0/#sec-arrow-function-definitions

```<code>ArrowFunction[In, Yield] :
    ArrowParameters[?Yield] [no LineTerminator here] => ConciseBody[?In]
ArrowParameters[Yield] :
    BindingIdentifier[?Yield] CoverParenthesizedExpressionAndArrowParameterList[?Yield]
ConciseBody[In] :
    [lookahead ≠ { ] AssignmentExpression[?In] { FunctionBody }
</code>```

What this means in English, is that an arrow function can only be declared like so args => {} and that's it. As you say, you can bind it to a variable with, for example, const func = args => {} or by passing it as an argument to another function, but there's no way. Indeed, passing an arrow function as an argument was one of the major reasons it was created (because of binding this). See lexical this (and the appendix)

As @MaheerAli has mentioned, arrow functions neatly avoids function hoisting which may be surprising behaviour.

ES6 does have some ways to declare functions in a shorter manner, such as within objects:

```<code>const obj = {
    func() {
        // ...
    }
}
</code>```

Body:
With ES5 I can declare either a function declaration or expression, depending on what I need.

function es5FunctionDeclaration() {
  return 'I am an es5 function declaration';
}

var es5FunctionExpression = function() {
  return 'I am an es5 function expression';
}

With the ES6 fat arrow, it is common to create a function expression like this...

const es6FunctionExpression = () => {
  return 'I am an es6 function expression';
}

But I haven't find a way to do a function declaration with a fat arrow, perhaps it is not possible.

// es6FunctionDeclarationWithFatArrow ??

Body:
The definition of an arrow function is here: http://www.ecma-international.org/ecma-262/6.0/#sec-arrow-function-definitions

ArrowFunction[In, Yield] :
    ArrowParameters[?Yield] [no LineTerminator here] => ConciseBody[?In]
ArrowParameters[Yield] :
    BindingIdentifier[?Yield] CoverParenthesizedExpressionAndArrowParameterList[?Yield]
ConciseBody[In] :
    [lookahead ≠ { ] AssignmentExpression[?In] { FunctionBody }

What this means in English, is that an arrow function can only be declared like so args => {} and that's it. As you say, you can bind it to a variable with, for example, const func = args => {} or by passing it as an argument to another function, but there's no way. Indeed, passing an arrow function as an argument was one of the major reasons it was created (because of binding this). See lexical this (and the appendix)

As @MaheerAli has mentioned, arrow functions neatly avoids function hoisting which may be surprising behaviour.

ES6 does have some ways to declare functions in a shorter manner, such as within objects:

const obj = {
    func() {
        // ...
    }
}


问:
Coping the value that does not exist
I was wondering if we copy a value that does not exist what will be the typeof copied value ?
Is it null or undefined ?

```<code>const args = [1]
console.log(...args.slice(1))
</code>```

Here is a concrete example

```<code>const compose = fns => (...args) =>
  fns.reduceRight((acc, fn) => fn(acc, ...args.slice(1)), args[0]);

const func3 = (x, y) => (y > 0 ? x + 3 : x - 3);

const func2 = x => x ** 2;

const func1 = x => x - 8;

const fnOne = compose([func1, func2, func3])('3', 1);
console.log(fnOne); // should be 1081

const fnTwo = compose([func1, func2, func3])('3', -1);
console.log(fnTwo); //should be -8
</code>```

答:
.slice always returns an array, never undefined. That array can be empty though.

If a function gets called with less arguments than parameters, the parameters will be undefined:

```<code>  const fn = (a, b) => console.log(a, b);

 fn(1) // a = 1, b = undefined
 // equals
 fn(...[1])  // a = 1, b = undefined
</code>```

Title: Coping the value that does not exist

Body:
I was wondering if we copy a value that does not exist what will be the typeof copied value ?
Is it null or undefined ?

const args = [1]
console.log(...args.slice(1))

Here is a concrete example

const compose = fns => (...args) =>
  fns.reduceRight((acc, fn) => fn(acc, ...args.slice(1)), args[0]);

const func3 = (x, y) => (y > 0 ? x + 3 : x - 3);

const func2 = x => x ** 2;

const func1 = x => x - 8;

const fnOne = compose([func1, func2, func3])('3', 1);
console.log(fnOne); // should be 1081

const fnTwo = compose([func1, func2, func3])('3', -1);
console.log(fnTwo); //should be -8

Body:
.slice always returns an array, never undefined. That array can be empty though.

If a function gets called with less arguments than parameters, the parameters will be undefined:

  const fn = (a, b) => console.log(a, b);

 fn(1) // a = 1, b = undefined
 // equals
 fn(...[1])  // a = 1, b = undefined


问:
Diagnostics.Process doesn't open PDF file using adobe reader
I'm having a problem while trying to open a PDF file using Process.Start().
The program runs the process as a background process but no adobe reader window show up. A solution i found was to use chrome.exe, but my client want to open on adobe-reader, as it's the default windows program.

(I have also trying without forcing "AcroRd32.exe" and passing the full path of "AcroRd32.exe". Same problem).

Anyone solved this?

My code:

```<code>var p = new Process
{
    StartInfo = new ProcessStartInfo(@"AcroRd32.exe", @"D:\Tests\81803130000326__.pdf")
};
p.Start();
</code>```

Background Processes:

I also have checked this question: Process.Start(/* path to pdf */) doesn't work with Adobe Reader on Windows 8

Edits

EDIT INFO: Forgot to say i'm running Windows 10 with Adobe Reader DC 2018.009.20044

EDIT 2: Found a "problem" of Adobe Reader DC. It mantains a level of security that doesn't let me run it as administrator (don't ask me why). Check this link for more information: https://forums.adobe.com/thread/1955530

Now I'll try to find a solution to run it without administrator privileges, or ask my client to uncheck the checkbox

Solution

So, I've found a solution for my problem. The Adobe Reader, since version 10.0, has a "Protected Mode" setting. I wrote a code to change that setting in the registry, so the user won't need to do that. Link: https://www.adobe.com/devnet-docs/acrobatetk/tools/AppSec/protectedmode.html

I hope it helps others in the future!

Solution Code:

```<code>var registroAdobe = Registry.LocalMachine.OpenSubKey(@"Software\Policies\Adobe\Acrobat Reader\DC\", true);
registroAdobe.SetValue("bProtectedMode", 0);
</code>```

This works for Acrobat Reader DC. You can run through "Software\Policies\Adobe\" Products and Versions if you need it.

答:
Actually, I found that this didn't work on my computer, but it led me to look deeper.
I found my solution to be:

```<code>var regAdobe = Registry.CurrentUser.OpenSubKey(@"Software\Adobe\Acrobat Reader\DC\Privileged", true);
regAdobe.SetValue("bProtectedMode", 0);
</code>```

Very similar, but ended up having to edit the user setting rather than the local machine's setting.

Cheers!

Body:
I'm having a problem while trying to open a PDF file using Process.Start().
The program runs the process as a background process but no adobe reader window show up. A solution i found was to use chrome.exe, but my client want to open on adobe-reader, as it's the default windows program.

(I have also trying without forcing "AcroRd32.exe" and passing the full path of "AcroRd32.exe". Same problem).

Anyone solved this?

My code:

var p = new Process
{
    StartInfo = new ProcessStartInfo(@"AcroRd32.exe", @"D:\Tests\81803130000326__.pdf")
};
p.Start();

Background Processes:

I also have checked this question: Process.Start(/* path to pdf */) doesn't work with Adobe Reader on Windows 8

Edits

EDIT INFO: Forgot to say i'm running Windows 10 with Adobe Reader DC 2018.009.20044

EDIT 2: Found a "problem" of Adobe Reader DC. It mantains a level of security that doesn't let me run it as administrator (don't ask me why). Check this link for more information: https://forums.adobe.com/thread/1955530

Now I'll try to find a solution to run it without administrator privileges, or ask my client to uncheck the checkbox

Solution

So, I've found a solution for my problem. The Adobe Reader, since version 10.0, has a "Protected Mode" setting. I wrote a code to change that setting in the registry, so the user won't need to do that. Link: https://www.adobe.com/devnet-docs/acrobatetk/tools/AppSec/protectedmode.html

I hope it helps others in the future!

Solution Code:

var registroAdobe = Registry.LocalMachine.OpenSubKey(@"Software\Policies\Adobe\Acrobat Reader\DC\", true);
registroAdobe.SetValue("bProtectedMode", 0);

This works for Acrobat Reader DC. You can run through "Software\Policies\Adobe\" Products and Versions if you need it.

Body:
Actually, I found that this didn't work on my computer, but it led me to look deeper.
I found my solution to be:

var regAdobe = Registry.CurrentUser.OpenSubKey(@"Software\Adobe\Acrobat Reader\DC\Privileged", true);
regAdobe.SetValue("bProtectedMode", 0);

Very similar, but ended up having to edit the user setting rather than the local machine's setting.

Cheers!


问:
Make hyperlink clickable when accessibility is on
I'm making application accessible using accessibility with Talk/Voice Over.

How to make links clickable with accessibility?

Using following methods for making Hyperlink clickable in TextView.

```<code>/**
 * This method creates the link and associates the ClickableSpan to it.
 * Once the ClickableSpan is clicked, it will call the
 * ClickableSpanListener.performAction
 */
public static void makeLinkClickable(
  final ClickableSpanListener clickableSpanListener,
  final SpannableStringBuilder strBuilder,
  final URLSpan span) {
final int start = strBuilder.getSpanStart(span);
final int end = strBuilder.getSpanEnd(span);
final int flags = strBuilder.getSpanFlags(span);

//get the String that is used as the link
final char[] characters = new char[end - start];
strBuilder.getChars(start, end, characters, 0);

  final ClickableSpan clickable = new ClickableSpan() {
    public void onClick(final View view) {
       clickableSpanListener.performAction(span.getURL(), new String(characters));
     }
   };
  strBuilder.setSpan(clickable, start, end, flags);
  strBuilder.removeSpan(span);
}

/**
 * This method takes in a String that contains at least one link defined by HTML <a></a> tags.
 * A link will be created in the String and added to the TextView.
 * The link will become clickable and the action (onClick) is defined by the
 * ClickableSpanListener.
 */
  public static void setTextViewHTML(
  final ClickableSpanListener clickableSpanListener,
  final TextView text,
  final String html) {
final CharSequence sequence = Html.fromHtml(html);
final SpannableStringBuilder strBuilder = new SpannableStringBuilder(sequence);
final URLSpan[] urls = strBuilder.getSpans(0, sequence.length(), URLSpan.class);
  for (final URLSpan span : urls) {
    makeLinkClickable(clickableSpanListener, strBuilder, span);
    }
   text.setText(strBuilder);
   text.setMovementMethod(LinkMovementMethod.getInstance());
 }

/**
 * This is the interface that should be implemented by classes to define the action
 * that will occur when a clickablespan is clicked
 */
 public interface ClickableSpanListener {
    void performAction(String url, String linkText);
 }

 setTextViewHTML(
    this,
    txtTermsPrivacy,
    getString(R.string.terms_condition_privacy_policy)
);
</code>```

Tried:

As mentioned in the google support for accessibility Google Support - Accessibility, I have tried using Linkify but it does not seem to work though.

答:
As mentioned in the Google Support page, the user will need to access the Local Context Menu via a TalkBack gesture (default gesture is Swipe up then right) to activate a TextView link.

In fact, any clickable span on a TextView widget may be activated through TalkBack using its context menu, even links that don't open a browser. Your implementation of performAction may show a Toast message, and the user will be able to activate through the context menu.

I tested it with TalkBack 7.3.0 in Android 8.1 with Linkify and android:autoLink="web". Both are working as expected.

```<code><TextView
    android:id="@+id/myTextView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:autoLink="web"
    android:text="This is a TextView with link to StackOverflow: http://www.stackoverflow.com, and to Android Documentation: https://developer.android.com." />
</code>```

Body:
I'm making application accessible using accessibility with Talk/Voice Over.

How to make links clickable with accessibility?

Using following methods for making Hyperlink clickable in TextView.

/**
 * This method creates the link and associates the ClickableSpan to it.
 * Once the ClickableSpan is clicked, it will call the
 * ClickableSpanListener.performAction
 */
public static void makeLinkClickable(
  final ClickableSpanListener clickableSpanListener,
  final SpannableStringBuilder strBuilder,
  final URLSpan span) {
final int start = strBuilder.getSpanStart(span);
final int end = strBuilder.getSpanEnd(span);
final int flags = strBuilder.getSpanFlags(span);

//get the String that is used as the link
final char[] characters = new char[end - start];
strBuilder.getChars(start, end, characters, 0);

  final ClickableSpan clickable = new ClickableSpan() {
    public void onClick(final View view) {
       clickableSpanListener.performAction(span.getURL(), new String(characters));
     }
   };
  strBuilder.setSpan(clickable, start, end, flags);
  strBuilder.removeSpan(span);
}

/**
 * This method takes in a String that contains at least one link defined by HTML  tags.
 * A link will be created in the String and added to the TextView.
 * The link will become clickable and the action (onClick) is defined by the
 * ClickableSpanListener.
 */
  public static void setTextViewHTML(
  final ClickableSpanListener clickableSpanListener,
  final TextView text,
  final String html) {
final CharSequence sequence = Html.fromHtml(html);
final SpannableStringBuilder strBuilder = new SpannableStringBuilder(sequence);
final URLSpan[] urls = strBuilder.getSpans(0, sequence.length(), URLSpan.class);
  for (final URLSpan span : urls) {
    makeLinkClickable(clickableSpanListener, strBuilder, span);
    }
   text.setText(strBuilder);
   text.setMovementMethod(LinkMovementMethod.getInstance());
 }

/**
 * This is the interface that should be implemented by classes to define the action
 * that will occur when a clickablespan is clicked
 */
 public interface ClickableSpanListener {
    void performAction(String url, String linkText);
 }

 setTextViewHTML(
    this,
    txtTermsPrivacy,
    getString(R.string.terms_condition_privacy_policy)
);

Tried:

As mentioned in the google support for accessibility Google Support - Accessibility, I have tried using Linkify but it does not seem to work though.

Body:
As mentioned in the Google Support page, the user will need to access the Local Context Menu via a TalkBack gesture (default gesture is Swipe up then right) to activate a TextView link.

In fact, any clickable span on a TextView widget may be activated through TalkBack using its context menu, even links that don't open a browser. Your implementation of performAction may show a Toast message, and the user will be able to activate through the context menu.

I tested it with TalkBack 7.3.0 in Android 8.1 with Linkify and android:autoLink="web". Both are working as expected.

<TextView
    android:id="@+id/myTextView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:autoLink="web"
    android:text="This is a TextView with link to StackOverflow: http://www.stackoverflow.com, and to Android Documentation: https://developer.android.com." />


问:
How to get json results prior to my custom schema in java/jackson?
I a coming to an problem where I am trying to result my json format properly. So, I got the first part of my custom schema, but I need some help to fix the second part which is the array list of hours,weekly, annual to list values as array and I am stuck to solve this issue. can anyone help me solve this. thanks!</p>

答:
You need to create list from steps and use writeObjectField method to serialise this list. Below you can find example implementation:

```<code>class JobSerializer extends StdSerializer<Salary> {

    public JobSerializer() {
        this(Salary.class);
    }

    public JobSerializer(Class<Salary> t) {
        super(t);
    }

    @Override
    public void serialize(Salary value, JsonGenerator jgen, SerializerProvider provider) throws IOException {
        jgen.writeStartObject();
        jgen.writeStringField("id", value.jobClassCd + value.payGrade + value.jobGroup);
        jgen.writeStringField("label", value.jobClassTitle + "( " + value.jobClassCd + value.payGrade + ") " + value.jobGroup);

        jgen.writeStringField("pay_grade_description_link", "payGrade");
        jgen.writeStringField("job_type", value.sectionToDisplay);
        jgen.writeStringField("mou", value.mou);
        jgen.writeStringField("mou_description", value.mouDescription);
        jgen.writeStringField("special_notes", value.specialNotes);
        jgen.writeStringField("salary_range_min_step_message", value.salaryRangeMinStepMessage);

        List<String> jobs = Arrays.asList(value.step1, value.step2, value.step3, value.step4, value.step5, value.step6, value.step7,
                value.step8, value.step9, value.step10, value.step11, value.step12, value.step13, value.step14,
                value.step15, value.step16, value.step17, value.step18, value.step19, value.step20);
        jgen.writeObjectField(value.rateType, jobs);

        jgen.writeEndObject();

    }
}
</code>```

Also, you can remove @JsonSerialize from all properties in Salary class. It is not required and can be confusing.

Body:
You need to create list from steps and use writeObjectField method to serialise this list. Below you can find example implementation:

class JobSerializer extends StdSerializer<Salary> {

    public JobSerializer() {
        this(Salary.class);
    }

    public JobSerializer(Class<Salary> t) {
        super(t);
    }

    @Override
    public void serialize(Salary value, JsonGenerator jgen, SerializerProvider provider) throws IOException {
        jgen.writeStartObject();
        jgen.writeStringField("id", value.jobClassCd + value.payGrade + value.jobGroup);
        jgen.writeStringField("label", value.jobClassTitle + "( " + value.jobClassCd + value.payGrade + ") " + value.jobGroup);

        jgen.writeStringField("pay_grade_description_link", "payGrade");
        jgen.writeStringField("job_type", value.sectionToDisplay);
        jgen.writeStringField("mou", value.mou);
        jgen.writeStringField("mou_description", value.mouDescription);
        jgen.writeStringField("special_notes", value.specialNotes);
        jgen.writeStringField("salary_range_min_step_message", value.salaryRangeMinStepMessage);

        List<String> jobs = Arrays.asList(value.step1, value.step2, value.step3, value.step4, value.step5, value.step6, value.step7,
                value.step8, value.step9, value.step10, value.step11, value.step12, value.step13, value.step14,
                value.step15, value.step16, value.step17, value.step18, value.step19, value.step20);
        jgen.writeObjectField(value.rateType, jobs);

        jgen.writeEndObject();

    }
}

Also, you can remove @JsonSerialize from all properties in Salary class. It is not required and can be confusing.


问:
Async to wait for a key in F#?
I would like to block async execution until the users presses any key in the console.

Here is what I have come up with:

```<code>let waitForAnyKey = async {
  do!
    new Task (fun () ->
      printfn "%s" "waiting for a key"
      Console.ReadKey () |> ignore
      printfn "%s" "got a key"
    )
    |> Async.AwaitTask
}
</code>```

Used like this:

```<code>async {
  printfn "%s" "Press any key... "
  do! waitForAnyKey
  printfn "%s" "You pressed a key. "
}
</code>```

However, the Task is never run.

How should I write this in F#?

Can I avoid creating a Task for this entirely?

答:
Without tasks, with Async.FromContinuations

open System

let waitForAnyKey =
    Async.FromContinuations (fun (cont, _, _) ->
        printfn "%s" "waiting for a key"
        cont (Console.ReadKey ())
        printfn "%s" "got a key"
    )

let test () =
    async {
        let! key = waitForAnyKey
        printfn "%O" key.Key
    }
    |> Async.RunSynchronously

test ()
```

Title: Async to wait for a key in F#?

Body:
I would like to block async execution until the users presses any key in the console.

Here is what I have come up with:

let waitForAnyKey = async {
  do!
    new Task (fun () ->
      printfn "%s" "waiting for a key"
      Console.ReadKey () |> ignore
      printfn "%s" "got a key"
    )
    |> Async.AwaitTask
}

Used like this:

async {
  printfn "%s" "Press any key... "
  do! waitForAnyKey
  printfn "%s" "You pressed a key. "
}

However, the Task is never run.

How should I write this in F#?

Can I avoid creating a Task for this entirely?


问:
Java `Iterator` to `Stream` which consumes the `Iterator` on terminal operation
Suppose you have a lazily-populated Iterator which you would like to convert to a Stream.  It can be assumed that the number of elements in the Iterator is finite.

It is possible to instruct the Iterator to skip elements (via a skip method on the implementation) to avoid unecessary element generation, but all elements of the Iterator must have been either skipped or generated once the Stream has had a terminal operation called on it.

I am aware of:

```<code>StreamSupport.stream(
        Spliterators.spliteratorUnknownSize(
                theIterator, Spliterator.ORDERED), false);
</code>```

for generating a Stream from an Iterator, however this does not provide a means to skip or ensure consumption of all elements.

Is there any basic Stream implementations which would allow for this via reasonably simple extension?

Delegation seems messy given the sheer number of methods of the Stream interface with no promise as to which will call which others as part of their internal implementation, and all the JDK implementations one could use as a starting point (at least in the JDK I'm using) are package-private and I assume there's good reason for that (e.g. they don't want me extending them...).

答:
Well I took a swing at doing this.  The idea was to create a TypeAdapter for Streams when reading through gson for json arrays, without having to convert every element:

https://github.com/BeUndead/gson-stream

From my quick round of testing it does everything I wanted it to, but there's almost certainly issues I didn't come across when quickly testing it.

Body:
Suppose you have a lazily-populated Iterator which you would like to convert to a Stream.  It can be assumed that the number of elements in the Iterator is finite.

It is possible to instruct the Iterator to skip elements (via a skip method on the implementation) to avoid unecessary element generation, but all elements of the Iterator must have been either skipped or generated once the Stream has had a terminal operation called on it.

I am aware of:

StreamSupport.stream(
        Spliterators.spliteratorUnknownSize(
                theIterator, Spliterator.ORDERED), false);

for generating a Stream from an Iterator, however this does not provide a means to skip or ensure consumption of all elements.

Is there any basic Stream implementations which would allow for this via reasonably simple extension?

Delegation seems messy given the sheer number of methods of the Stream interface with no promise as to which will call which others as part of their internal implementation, and all the JDK implementations one could use as a starting point (at least in the JDK I'm using) are package-private and I assume there's good reason for that (e.g. they don't want me extending them...).


问:
angular 2 - how to set <select> default selected option
My template is like this

```<code><select>
  <option>AM</option>
  <option>PM</option>
</select>
</code>```

How can I set option AM selected by default?

答:
```<code>        <select>
            <option [ngValue]="null">All</option>
            <option *ngFor="let oneItem of items" [ngValue]="oneItem.id">
               {{oneItem.description}}
            </option>
        </select>
</code>```

Simply add option to the list. This has worked for me in Angular 4.

Body:
My template is like this

<select>
  <option>AM</option>
  <option>PM</option>
</select>

How can I set option AM selected by default?

Body:
        <select>
            <option [ngValue]="null">All</option>
            <option *ngFor="let oneItem of items" [ngValue]="oneItem.id">
               {{oneItem.description}}
            </option>
        </select>

Simply add option to the list. This has worked for me in Angular 4.


问:
float point multiple and divident precision problem
I'm facing float point precision problem in my C++ code

given double d = 32.4;

```<code>d / 0.01 == 3240.0;
</code>```

gives true, while

```<code>d / 0.1 == 324.0
</code>```

gives false.

But if I multiple by 10 and 100 then the result are both true.

Since 32.4, 324 and 3240 can all be represented by 64bit double without any precision loss, so this result is quite confusing to me. (I'm not very familiar with multiplier and divident operation in float point)

In my use case, I will do some conversion among different scale, by simpliy multiplying or dividing something like 0.1, 0.01, 0.05. I mean, I don't require very high precision, my operands are usually less than 6 decimals, which can be represent in 64bit double without precision loss, so I want to get consistent result. I have a guess: should I always use multiplying instead of dividing in my use case?

答:
You seem to be mistaken about what values a floating point type can represent.

The value 32.4 cannot be represented exactly in any binary floating point format, nor can 0.1 or 0.01.  It looks like a repeating fractional number.  It's the same as the value 1/3, which also can't be exactly represented in decimal format i.e. 0.3333333333333....  So any arithmetic with these values will not be exact.

The best thing you can do in your case is change the division by a floating point value into a multiplication by an integer value, ex. / 0.1 --> * 10.  Even then the result won't be exact because the original value of 32.4 can't be represented exactly.  You'll need to round the result to an integer value to get something exact.

Body:
I'm facing float point precision problem in my C++ code

given double d = 32.4;

d / 0.01 == 3240.0;

gives true, while

d / 0.1 == 324.0

gives false.

But if I multiple by 10 and 100 then the result are both true.

Since 32.4, 324 and 3240 can all be represented by 64bit double without any precision loss, so this result is quite confusing to me. (I'm not very familiar with multiplier and divident operation in float point)

In my use case, I will do some conversion among different scale, by simpliy multiplying or dividing something like 0.1, 0.01, 0.05. I mean, I don't require very high precision, my operands are usually less than 6 decimals, which can be represent in 64bit double without precision loss, so I want to get consistent result. I have a guess: should I always use multiplying instead of dividing in my use case?


问:
Traefik create frontend rule in consul for docker backend
I actually use traefik with docker and everything works fine.
But now, i would like to create new frontend rule with my apps using consul as a KV store.

So i created some key:

```<code>/traefik/frontends/frontend1/backend    backend2
/traefik/frontends/frontend1/routes/test_1/rule Host:test.localhost
</code>```

And hope to see them in my traefik UI but nothing appeared.

Looking in logs, i can see

```<code>time="2018-04-26T19:31:06Z" level=debug msg="Configuration received from provider consul: {}"
time="2018-04-26T19:31:06Z" level=info msg="Skipping same configuration for provider consul"
</code>```

Connection with consul is okay and i saw some logs Cannot get key... so i created them to see if this was causing a bug

Have you an idea?

Thanks

答:
Are you missing a backend?  In my testing, the bare minimum to get it to appear in the UI is the following:

```<code>traefik/frontends/frontend-test/backend backend-test
traefik/backends/backend-test
</code>```

This is not enough however to have a working frontend/backend, but should get something in the UI.

Body:
I actually use traefik with docker and everything works fine.
But now, i would like to create new frontend rule with my apps using consul as a KV store.

So i created some key:

/traefik/frontends/frontend1/backend    backend2
/traefik/frontends/frontend1/routes/test_1/rule Host:test.localhost

And hope to see them in my traefik UI but nothing appeared.

Looking in logs, i can see

time="2018-04-26T19:31:06Z" level=debug msg="Configuration received from provider consul: {}"
time="2018-04-26T19:31:06Z" level=info msg="Skipping same configuration for provider consul"

Connection with consul is okay and i saw some logs Cannot get key... so i created them to see if this was causing a bug

Have you an idea?

Thanks

Body:
Are you missing a backend?  In my testing, the bare minimum to get it to appear in the UI is the following:

traefik/frontends/frontend-test/backend backend-test
traefik/backends/backend-test

This is not enough however to have a working frontend/backend, but should get something in the UI.


问:
React Router in Laravel
I'm trying to build a Laravel project using ReactJS. I've done show the data on table. However, when I add some links like Create, Edit, Delete... , it occurred some errors:

```<code>- Failed context type: The context `router` is marked as required in `Link`, but its value is `undefined`.
- Uncaught Error: You should not use `Link` outside a `Router`
</code>```

So:

I created RoutePath.js to create Routes only but i dont know how to import them into Example.js

When add page, edit page...is clicked, it redirects to blank page, not below the homepage. However, It seems that the add page will be below the homepage

Im new so please help me. Thank you. Here's my code:

Example.js

```<code>import React, { Component } from 'react';
import ReactDOM from 'react-dom';
import axios from 'axios';
import {Link} from "react-router-dom";
import CreatePost from './CreatePost';
import RoutePath from '../routes/RoutePath';

...

postRow(p){
        return (
            <tr key = {p.id}>
                <td>{p.title}</td>
                <td>{p.description}</td>
                <td><Link to='/edit'></Link></td>
                <td><Link to='/delete'></Link></td>
            </tr>
        )
    }

    render() {
        const posts = this.state.posts.map(post => this.postRow(post));
        return (
                <div>
                    <table border="1">
                        <thead>
                        <tr>
                            <th>Title</th>
                            <th>Description</th>
                            <th></th>
                            <th></th>
                        </tr>
                        </thead>
                        <tbody>
                        { posts }
                        </tbody>
                    </table>
                    <div>
                        <Link to='/add-post'>Add</Link>
                    </div>
                </div>

        );
    }
}
ReactDOM.render(
    <Example />
    , document.getElementById('homepage')
);
</code>```

RoutePath.js

```<code>import React, {Component} from 'react';
import { Route, BrowserRouter } from "react-router-dom";
import CreatePost from '../components/CreatePost';
import Example from '../components/Example';

export default class RoutePath extends Component{
    render(){
        return(
            <BrowserRouter>
                    <div>
                        <Route exact path='/' component={Example}/>
                        <Route path='/add-post' component={CreatePost}/>
                        <Route path='/edit' component={Edit}/>
                    </div>
            </BrowserRouter>
        )
    }
}
</code>```

答:
This works for me... My single view for my Single-Page-App is home.blade.php and I am using BrowserRouter in my App.js

```<code>Route::get('/', function () {
    return view('home');
});

Route::get('/{route}',function(){
    return view('home');
});
</code>```

This will allow you to go to http://localhost/ and get the homepage of the app or http://localhost/about-us and get the 'about-us' route.

This is a better method than using HashRouter which would look a little uglier: http://localhost/#/about-us

Title: React Router in Laravel

Body:
I'm trying to build a Laravel project using ReactJS. I've done show the data on table. However, when I add some links like Create, Edit, Delete... , it occurred some errors:

- Failed context type: The context `router` is marked as required in `Link`, but its value is `undefined`.
- Uncaught Error: You should not use `Link` outside a `Router`

So:

I created RoutePath.js to create Routes only but i dont know how to import them into Example.js

When add page, edit page...is clicked, it redirects to blank page, not below the homepage. However, It seems that the add page will be below the homepage

Im new so please help me. Thank you. Here's my code:

Example.js

import React, { Component } from 'react';
import ReactDOM from 'react-dom';
import axios from 'axios';
import {Link} from "react-router-dom";
import CreatePost from './CreatePost';
import RoutePath from '../routes/RoutePath';

...

postRow(p){
        return (

                {p.title}
                {p.description}
                <Link to='/edit'></Link>
                <Link to='/delete'></Link>

        )
    }

    render() {
        const posts = this.state.posts.map(post => this.postRow(post));
        return (

                            Title
                            Description

                        { posts }

                        <Link to='/add-post'>Add</Link>

        );
    }
}
ReactDOM.render(
    <Example />
    , document.getElementById('homepage')
);

RoutePath.js

import React, {Component} from 'react';
import { Route, BrowserRouter } from "react-router-dom";
import CreatePost from '../components/CreatePost';
import Example from '../components/Example';

export default class RoutePath extends Component{
    render(){
        return(
            <BrowserRouter>

                        <Route exact path='/' component={Example}/>
                        <Route path='/add-post' component={CreatePost}/>
                        <Route path='/edit' component={Edit}/>

            </BrowserRouter>
        )
    }
}

Body:
This works for me... My single view for my Single-Page-App is home.blade.php and I am using BrowserRouter in my App.js

Route::get('/', function () {
    return view('home');
});

Route::get('/{route}',function(){
    return view('home');
});

This will allow you to go to http://localhost/ and get the homepage of the app or http://localhost/about-us and get the 'about-us' route.

This is a better method than using HashRouter which would look a little uglier: http://localhost/#/about-us


问:
How to set multiple file entry and output in project with webpack?
How to set multiple file entry/output in project with webpack?

I follow http://webpack.github.io/docs/tutorials/getting-started/ success compile if only one file in one entry/output...

directory

```<code>app
webpack.config.js
./assets
././javascripts/Administrator/Article/Create/Base.js
././javascripts/Administrator/Article/Edit/Base.js
././javascripts/Account/Index/Base.js
././javascripts/Contact/Index/Base.js
...
</code>```

how to output like this?

```<code>././javascripts/Administrator/Article/Create/bundle.js
././javascripts/Administrator/Article/Edit/bundle.js
././javascripts/Account/Index/bundle.js
././javascripts/Contact/Index/bundle.js
</code>```

webpack.config.js

```<code>module.exports = {
  entry: {
    'AdministratorArticleCreate':['./assets/javascripts/Administrator/Article/Create/Base.js']
  },
  output: {
    path:
  }

    // if only one file
    // entry: "./assets/javascripts/Administrator/Article/Create/Base.js",
    // output: {
    //     // path: __dirname,
    //     path: "./assets/javascripts/Administrator/Article/Create/",
    //     filename: "bundle.js"
    // }
};
</code>```

答:
For my use case I actually needed to use different templates based on environment. To achieve this I passed in the NODE_ENV variable

```<code>module.exports = (env, argv) => {
  const ENVIRONMENT = env.NODE_ENV;
  let INDEX_HTML = 'index.html';
  if (ENVIRONMENT === 'staging') {
    INDEX_HTML = 'index-stg.html';
  }
</code>```

Then:

```<code>if (NODE_ENV === 'staging') {
   INDEX_HTML = 'index-stg.html';
}
</code>```

In the output:

```<code>output: {
      path: process.cwd() + '/build',
      filename: `[name].js`,
      chunkFilename: `[${HASH_MODE}].[name].js`
    },
</code>```

plugins:

```<code>new HtmlWebpackPlugin({
        inject: true,
        template: `app/${INDEX_HTML}`,
      }),
</code>```

Body:
How to set multiple file entry/output in project with webpack?

I follow http://webpack.github.io/docs/tutorials/getting-started/ success compile if only one file in one entry/output...

directory

app
webpack.config.js
./assets
././javascripts/Administrator/Article/Create/Base.js
././javascripts/Administrator/Article/Edit/Base.js
././javascripts/Account/Index/Base.js
././javascripts/Contact/Index/Base.js
...

how to output like this?

././javascripts/Administrator/Article/Create/bundle.js
././javascripts/Administrator/Article/Edit/bundle.js
././javascripts/Account/Index/bundle.js
././javascripts/Contact/Index/bundle.js

webpack.config.js

module.exports = {
  entry: {
    'AdministratorArticleCreate':['./assets/javascripts/Administrator/Article/Create/Base.js']
  },
  output: {
    path:
  }

    // if only one file
    // entry: "./assets/javascripts/Administrator/Article/Create/Base.js",
    // output: {
    //     // path: __dirname,
    //     path: "./assets/javascripts/Administrator/Article/Create/",
    //     filename: "bundle.js"
    // }
};

Body:
For my use case I actually needed to use different templates based on environment. To achieve this I passed in the NODE_ENV variable

module.exports = (env, argv) => {
  const ENVIRONMENT = env.NODE_ENV;
  let INDEX_HTML = 'index.html';
  if (ENVIRONMENT === 'staging') {
    INDEX_HTML = 'index-stg.html';
  }

Then:

if (NODE_ENV === 'staging') {
   INDEX_HTML = 'index-stg.html';
}

In the output:

output: {
      path: process.cwd() + '/build',
      filename: `[name].js`,
      chunkFilename: `[${HASH_MODE}].[name].js`
    },

plugins:

new HtmlWebpackPlugin({
        inject: true,
        template: `app/${INDEX_HTML}`,
      }),


问:
Make a simple get request in javascript
I am trying to do some simple webscraping in javascript to get the html code from either delish or tasty sites to store recipes.  one example would be this site: https://www.delish.com/cooking/recipe-ideas/a27469586/baked-zucchini-recipe/
However when I use fetch I am not able to get it to work.

I actually wrote the equivalent code in python that I want to be able to translate into javascript.  This is pasted here:

```<code>import requests
url = "https://www.delish.com/cooking/recipe-ideas/a27469586/baked-zucchini-recipe/"
r = requests.get(url)
text = str(r.content)
</code>```

I am able to get the javascript code to work when I use a different site.  For example this worked for me

```<code>fetch('https://api.github.com/users/maecapozzi')
   .then(res => console.log('response: ', res))
   .catch(console.error)
</code>```

but when trying for my site I got an error:

Access to fetch at 'https://www.delish.com/cooking/recipe-ideas/a27469586/baked-zucchini-recipe' from origin 'http://localhost:3000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
index.js:1375
TypeError: Failed to fetch

I am not sure what exactly this means as I am pretty new to all this, so any help at all would be greatly appreciated!

答:
"Cross-Origin Resource Sharing (CORS) is a mechanism that uses additional HTTP headers to tell a browser to let a web application running at one origin (domain) have permission to access selected resources from a server at a different origin. A web application executes a cross-origin HTTP request when it requests a resource that has a different origin (domain, protocol, and port) than its own origin.

An example of a cross-origin request: The frontend JavaScript code for a web application served from http://domain-a.com uses XMLHttpRequest to make a request for http://api.domain-b.com/data.json.

For security reasons, browsers restrict cross-origin HTTP requests initiated from within scripts. For example, XMLHttpRequest and the Fetch API follow the same-origin policy. This means that a web application using those APIs can only request HTTP resources from the same origin the application was loaded from, unless the response from the other origin includes the right CORS headers."

From: https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS

Basically server administrators implement CORS policies specifically to prevent what you're trying to do, which is access content from another site via code running on your site. Unless the server you want to access allows this kind of access, either via a non-restrictive CORS policy or a publicly accessible API like Github, then you won't be able to do what you're trying to do.

Title: Make a simple get request in javascript

Body:
I am trying to do some simple webscraping in javascript to get the html code from either delish or tasty sites to store recipes.  one example would be this site: https://www.delish.com/cooking/recipe-ideas/a27469586/baked-zucchini-recipe/
However when I use fetch I am not able to get it to work.

I actually wrote the equivalent code in python that I want to be able to translate into javascript.  This is pasted here:

import requests
url = "https://www.delish.com/cooking/recipe-ideas/a27469586/baked-zucchini-recipe/"
r = requests.get(url)
text = str(r.content)

I am able to get the javascript code to work when I use a different site.  For example this worked for me

fetch('https://api.github.com/users/maecapozzi')
   .then(res => console.log('response: ', res))
   .catch(console.error)

but when trying for my site I got an error:

Access to fetch at 'https://www.delish.com/cooking/recipe-ideas/a27469586/baked-zucchini-recipe' from origin 'http://localhost:3000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
index.js:1375
TypeError: Failed to fetch

I am not sure what exactly this means as I am pretty new to all this, so any help at all would be greatly appreciated!


问:
How to scale down pure CSS Component to fit parent Component?
I've built a pure css image, exported as a component in React. I'd like to scale down its size depending on the size of its parent.

I've attempted setting max sizes on the container className, object fit, and transform: scale. Either the pure css component disappears or doesn't change size. I can't figure out how to make it react responsively to its parent.

```<code>$shirt-color: #D2DADE;
$body-color: #F5EAD9;
$face-color: rgb(105, 97, 88);
$hair-color: rgb(177, 141, 107);
$background-color: #CCCCCC;

.body,
.head,
.neck-shadow,
.neck,
.ears,
.eyes,
.mouth,
.hair,
.glasses {
    position: relative;
}

.body {
    background: $shirt-color;
    border-radius: 100%;
    height: 50%; width: 55%;
    left: 23%; top: 75%;
    z-index: 1;
}

.container {
    object-fit: scale;
    margin: 1%;
    width: 25vw; height: 25vw;
    max-width: 250px; max-height: 250px;
    border-radius: 50%;
    background-color: $background-color;
    overflow: hidden;
    z-index: -20;
}

.ears {
    background: $body-color;
    border-radius: 50%;
    top: 10%; left: -10%;
    width: 22%; height: 20%;

    &::before {
        background: $body-color;
        border-radius: 50%;
        position: absolute;
        content: '';
        top: 0%; left: 450%;
        width: 100%; height: 100%;
    }
}

.mouth {
    border: 4px solid;
    border-radius: 100%;
    border-color: transparent transparent $face-color $face-color;
    top: -10%; left: 35%;
    width: 28%; height: 25%;
    transform: rotate(-45deg);
}

.eyes {
    border-radius: 100%;
    background: rgba(241, 150, 30, 0.5);
    top: 0%; left: 44%;
    width: 10%; height: 15%;

    &::before, &::after {
        position: absolute;
        content: '';
        background: $face-color;
        border-radius: 100%;
        width: 100%; height: 60%;
        top: -20%;
    }
    &::before {
        left: -200%;
    }
    &::after {
        left: 200%;
    }
}

.hair {
    background: $hair-color;
    border-top-left-radius: 75%;
    border-top-right-radius: 75%;
    top: -10%; left: 0%;
    width:105%; height: 40%;

    &::before, &::after {
        background: $hair-color;
        position: absolute;
        content: '';
    }
    &::before {
        border-top-left-radius: 30%;
        border-bottom-left-radius: 75%;
        top: 75%; left: -17%;
        width: 22%; height: 110%;
    }
    &::after {
        border-top-right-radius: 30%;
        border-bottom-right-radius: 75%;
        top: 75%; left: 92%;
        width: 15%; height: 100%;
    }
}

.hair .hair-content {
    &::before, &::after {
        background: $hair-color;
        border-radius: 100%;
        position: absolute;
        content: '';
        top: 40%;
    }
    &::before {
        border-bottom-right-radius: 60%;
        left: 30%;
        width: 30%; height: 75%;
    }
    &::after {
        border-bottom-right-radius: 75%;
        left: 50%;
        width: 45%; height: 100%;
    }
}

.head {
    background: $body-color;
    border-radius: 40px;
    left: 12%; top: -111%;
    width: 75%; height: 80%;
    z-index: 5;
  }

.neck {
    background: linear-gradient(rgb(179, 170, 157) 49%, $body-color 49%, $body-color );
    border-radius: 45%;
    border-color: #444 #444 #444 #444;
    left: 42%; top: -15%;
    width: 15%; height: 25%;
    z-index: 0;
}
</code>```

```<code>import React, { Component } from 'react';
import './Bradley.scss'

export default class Bradley extends Component {
    render() {
        return (
            <div>
                <div className = 'container' >
                    <div className = 'head'>
                        <div className = 'hair'>
                            <div className = 'hair-content'/>
                        </div>
                        <div className = 'ears'/>
                        <div className = 'eyes'/>
                        <div className = 'mouth'/>
                        <div className = 'neck'/>
                    </div>
                    <div className = 'body'/>
                </div>
            </div>
        )
    }
}
</code>```

And then I render it inside of a Jumbotron, for example. I've tried nesting it within other elements and a Container component.

```<code>import React from 'react';
import Bradley from './components/Bradley/Bradley'
import {Row, Col, Jumbotron, Container} from 'react-bootstrap'
import './App.css';

function App() {
  return (
    <div>
      <Jumbotron>
          <Bradley/>
      </Jumbotron>
    </div>
  );
}

export default App;
</code>```

The image stays the same size, and overflows from the container. Resizing the window does nothing.

EDIT: It now fits well, and I use % for all heights and widths, but it looks awful when I shrink the screen,

答: Change your dimension units to %, scale property will not work on hard coded dimensions, like 32px

Body:
I've built a pure css image, exported as a component in React. I'd like to scale down its size depending on the size of its parent.

I've attempted setting max sizes on the container className, object fit, and transform: scale. Either the pure css component disappears or doesn't change size. I can't figure out how to make it react responsively to its parent.

$shirt-color: #D2DADE;
$body-color: #F5EAD9;
$face-color: rgb(105, 97, 88);
$hair-color: rgb(177, 141, 107);
$background-color: #CCCCCC;

.body,
.head,
.neck-shadow,
.neck,
.ears,
.eyes,
.mouth,
.hair,
.glasses {
    position: relative;
}

.body {
    background: $shirt-color;
    border-radius: 100%;
    height: 50%; width: 55%;
    left: 23%; top: 75%;
    z-index: 1;
}

.container {
    object-fit: scale;
    margin: 1%;
    width: 25vw; height: 25vw;
    max-width: 250px; max-height: 250px;
    border-radius: 50%;
    background-color: $background-color;
    overflow: hidden;
    z-index: -20;
}

.ears {
    background: $body-color;
    border-radius: 50%;
    top: 10%; left: -10%;
    width: 22%; height: 20%;

    &::before {
        background: $body-color;
        border-radius: 50%;
        position: absolute;
        content: '';
        top: 0%; left: 450%;
        width: 100%; height: 100%;
    }
}

.mouth {
    border: 4px solid;
    border-radius: 100%;
    border-color: transparent transparent $face-color $face-color;
    top: -10%; left: 35%;
    width: 28%; height: 25%;
    transform: rotate(-45deg);
}

.eyes {
    border-radius: 100%;
    background: rgba(241, 150, 30, 0.5);
    top: 0%; left: 44%;
    width: 10%; height: 15%;

    &::before, &::after {
        position: absolute;
        content: '';
        background: $face-color;
        border-radius: 100%;
        width: 100%; height: 60%;
        top: -20%;
    }
    &::before {
        left: -200%;
    }
    &::after {
        left: 200%;
    }
}

.hair {
    background: $hair-color;
    border-top-left-radius: 75%;
    border-top-right-radius: 75%;
    top: -10%; left: 0%;
    width:105%; height: 40%;

    &::before, &::after {
        background: $hair-color;
        position: absolute;
        content: '';
    }
    &::before {
        border-top-left-radius: 30%;
        border-bottom-left-radius: 75%;
        top: 75%; left: -17%;
        width: 22%; height: 110%;
    }
    &::after {
        border-top-right-radius: 30%;
        border-bottom-right-radius: 75%;
        top: 75%; left: 92%;
        width: 15%; height: 100%;
    }
}

.hair .hair-content {
    &::before, &::after {
        background: $hair-color;
        border-radius: 100%;
        position: absolute;
        content: '';
        top: 40%;
    }
    &::before {
        border-bottom-right-radius: 60%;
        left: 30%;
        width: 30%; height: 75%;
    }
    &::after {
        border-bottom-right-radius: 75%;
        left: 50%;
        width: 45%; height: 100%;
    }
}

.head {
    background: $body-color;
    border-radius: 40px;
    left: 12%; top: -111%;
    width: 75%; height: 80%;
    z-index: 5;
  }

.neck {
    background: linear-gradient(rgb(179, 170, 157) 49%, $body-color 49%, $body-color );
    border-radius: 45%;
    border-color: #444 #444 #444 #444;
    left: 42%; top: -15%;
    width: 15%; height: 25%;
    z-index: 0;
}

import React, { Component } from 'react';
import './Bradley.scss'

export default class Bradley extends Component {
    render() {
        return (

        )
    }
}

And then I render it inside of a Jumbotron, for example. I've tried nesting it within other elements and a Container component.

import React from 'react';
import Bradley from './components/Bradley/Bradley'
import {Row, Col, Jumbotron, Container} from 'react-bootstrap'
import './App.css';

function App() {
  return (

      <Jumbotron>
          <Bradley/>
      </Jumbotron>

  );
}

export default App;

The image stays the same size, and overflows from the container. Resizing the window does nothing.

EDIT: It now fits well, and I use % for all heights and widths, but it looks awful when I shrink the screen,


问:
What does it mean to have a valid record when the record contains nothing, not even a single space
I was browsing the data for a particular column which looked like it had spaces because it did not say null

Upon trying to find what it was, I discovered the data does not have a single space but it is also not blank.

What is it then?  -- something between two single quotations '' which is not space.

Tried to run this query with no results:

```<code>select column1 from table1 where column1 like '% %'
-- Single space
</code>```

-> No records found

The second query I tried (see below) has no spaces mentioned. And that gave a result saying that there exist records which are like ->''

```<code>select column1 from table1 where column1 like '% %'

select column1 from table1 where column1= ''
</code>```

I am trying to understand what is that record and what does it mean to be nothing?

答:
Nullable Text fields be either NULL or a string of length 0, i.e. '' or a non-empty string, eg. 'abc'

'' is not the same as NULL.

I was taught in my databases course that NULL signifies that the value is unkown, and an identity value, such as an empty string, would mean that we know the value and it is nothing, but often developers and applications don't respect this distinction.

Body:
I was browsing the data for a particular column which looked like it had spaces because it did not say null

Upon trying to find what it was, I discovered the data does not have a single space but it is also not blank.

What is it then?  -- something between two single quotations '' which is not space.

Tried to run this query with no results:

select column1 from table1 where column1 like '% %'
-- Single space

-> No records found

The second query I tried (see below) has no spaces mentioned. And that gave a result saying that there exist records which are like ->''

select column1 from table1 where column1 like '% %'

select column1 from table1 where column1= ''

I am trying to understand what is that record and what does it mean to be nothing?


问:
Javascript params from string value
I want to set dynamic parameters for the TagEditor (or any other plugin that has parameters) plugin according to an array of paramaters in string (from php), I have a div in this way.

```<code><textarea class="tag-editor" type="text" name="xxxx" data-attributes-js="{placeholder:'1,2,3,4',other_para,:true,....}"></textarea>
</code>```

So in the JS I want to obtain those parameters and return them evaluated so that tagEditor works with those dynamic parameters.

```<code>var $input = $('.tag-editor');
$input.tagEditor( $input.attr("data-attributes-js") );
</code>```

but this does not work, how can I make this work this way?

答:
You may change few things here like:-

$(function(){

  const $input = $('.tag-editor');
  const jsString = $input.attr("data-attributes-js");
  const jsObj = JSON.parse(jsString);

  console.log(jsObj);;
})```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<textarea class="tag-editor" type="text" name="xxxx" data-attributes-js='{"placeholder":"1,2,3,4","other_para":true,"another_para":5}'></textarea></code>```

Title: Javascript params from string value

Body:
I want to set dynamic parameters for the TagEditor (or any other plugin that has parameters) plugin according to an array of paramaters in string (from php), I have a div in this way.

<textarea class="tag-editor" type="text" name="xxxx" data-attributes-js="{placeholder:'1,2,3,4',other_para,:true,....}"></textarea>

So in the JS I want to obtain those parameters and return them evaluated so that tagEditor works with those dynamic parameters.

var $input = $('.tag-editor');
$input.tagEditor( $input.attr("data-attributes-js") );

but this does not work, how can I make this work this way?

Body:
You may change few things here like:-

$(function(){

  const $input = $('.tag-editor');
  const jsString = $input.attr("data-attributes-js");
  const jsObj = JSON.parse(jsString);

  console.log(jsObj);;
})

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<textarea class="tag-editor" type="text" name="xxxx" data-attributes-js='{"placeholder":"1,2,3,4","other_para":true,"another_para":5}'></textarea>