问:
Sticky footer with flex-box and main body with overflow:auto breaks on non-webkit browsers
I have designed a web-page with a header and a sticky footer as follows:

/*
    Created on : Nov 16, 2017, 12:39:01 AM
    Author     : pantelis
*/
body, html {
    max-width: 960px;
    margin: auto;
    letter-spacing: normal;
    background-color: #173a61;
    font-family: sans-serif, Helvetica, Arial;
}

body.sticky {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;

    -webkit-box-orient: vertical;
    -webkit-box-direction: normal;
    -ms-flex-direction: column;
    flex-direction: column;

    height: 100vh;
}

/* classes */
p {
    margin: .5em 0;
}
a, a:visited, a:active, a:focus {
    text-decoration: none;
    color: #81afd2;
}
a:hover {
    color: darkblue;
}

/* general */
header, footer, section, div {
    -webkit-box-sizing: border-box;
    box-sizing: border-box;
    padding: .5em;
}

header, footer {
    background-color: #b8d0ea;
    text-align: center;
}

header h1, footer h1 {
    margin: .4em;
}

main {
    display:-webkit-box;
    display:-ms-flexbox;
    display:flex;
    -webkit-box-flex: 1;
    -ms-flex: 1;
    flex: 1;
    background-color: white;
}

/* movies */
#movies {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -ms-flex-wrap: wrap;
    flex-wrap: wrap;
    width: 50%;
    overflow:auto;
    border-right: thin solid silver;
}

figure {
    text-align: center;
    margin: .8em .8em;
    width: 90px;
}

img {
    width: 92px;
    border: none;
}

/* movie */
#movie {
    width: 50%;

    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;

    -webkit-box-orient: vertical;
    -webkit-box-direction: normal;
        -ms-flex-direction: column;
            flex-direction: column;
    padding: 0;
}

#movie img {
    float: right;
    width: 100%;
    max-width: 200px;
}
#header {
    font-size: 1.5em;
    border-bottom: thin solid silver;
}
#details {
    -webkit-box-flex: 1;
        -ms-flex: 1;
            flex: 1;
    overflow: auto;
}
#details p:first-of-type {
    font-weight: 600;
}
#footer {
    border-top: thin solid silver;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><body class="sticky">
        <header id="main-header">
            <h1>Test Flex</h1>
        </header>
        <main>
            <section id="movies">
            the movies<br>
            the movies<br>
            the movies<br>
            the movies<br>
            the movies<br>
            the movies<br>
            the movies<br>
            the movies<br>
            the movies<br>
            the movies<br>
            the movies<br>
            the movies<br>
            the movies<br>
            the movies<br>
            the movies<br>
            the movies<br>
            the movies<br>
            the movies<br>
            the movies<br>
            the movies<br>
            the movies<br>
            the movies<br>
            the movies<br>
            the movies<br>
            the movies<br>
            the movies<br>
            the movies<br>
            </section>
            <section id="movie">
                <div id="header">
                    The Title
                </div>
                <div id ="details">
                    The details<br>
                    The details<br>
                    The details<br>
                    The details<br>
                    The details<br>
                    The details<br>
                    The details<br>
                    The details<br>
                    The details<br>
                    The details<br>
                    The details<br>
                    The details<br>
                    The details<br>
                    The details<br>
                    The details<br>
                    The details<br>
                    The details<br>
                    The details<br>
                    The details<br>
                    The details<br>
                    The details<br>
                    The details<br>
                    The details<br>
                    The details<br>
                    The details<br>
                    The details<br>
                    The details<br>
                    The details<br>
                    The details<br>
                    The details<br>
                    The details<br>
                    The details<br>
                    The details<br>
                    The details<br>
                </div>
                <div id="footer">
                    The footer
                </div>
            </section>
        </main>
        <footer>
            The Footer ©
        </footer>
    </body></code>```

The footer is properly positioned at the bottom of the browser window using the following CSS:

```<code>body.sticky {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;

    -webkit-box-orient: vertical;
    -webkit-box-direction: normal;
    -ms-flex-direction: column;
    flex-direction: column;

    height: 100vh;
}
main {
    display:-webkit-box;
    display:-ms-flexbox;
    display:flex;

    -webkit-box-flex: 1;
        -ms-flex: 1;
                flex: 1;

}
</code>```

Two sections, each of 50% width, are contained in the main body. The first one contains many small items, so it is also a flex-box:

```<code>#movies {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -ms-flex-wrap: wrap;
        flex-wrap: wrap;

   width: 50%;
   overflow:auto;
}
</code>```

The other section contains details of the movie upon clicking each item in #movies.

When #movies is empty, or with few items, all browsers render the page properly. When it is loaded with many items,
Chrome and Safari and all other webkit browsers (Opera, Vivaldi) display the page as expected, i.e. the #movies item displays a scroll bar without any expansion and the footer remains in place at the bottom of the viewport, as shown here. (Note that scrollbars are not shown on a Mac.)

Firefox and Edge on the other hand do not render the page as expected: the main section is expanded all the way down along the y-axis in order to contain all the items in #movies, no scrollbar is shown. The footer goes down too, after the end of #movies.

The issue can be tested here. I would welcome any ideas that might help to remedy this behaviour.

答:
Flex item's has, in this case for column direction, a min-height that defaults to auto, which prevents it to become smaller than its content.

For Firefox and Edge, this needs to be set to 0 on the main, or else it will simply grow/overflow with its content.

```<code>main {
    display:-webkit-box;
    display:-ms-flexbox;
    display:flex;
    -webkit-box-flex: 1;
    -ms-flex: 1;
    flex: 1;
    background-color: white;
    min-height: 0;                        /*  added  */
}
</code>```

Stack snippet

/*
    Created on : Nov 16, 2017, 12:39:01 AM
    Author     : pantelis
*/
body, html {
    max-width: 960px;
    margin: auto;
    letter-spacing: normal;
    background-color: #173a61;
    font-family: sans-serif, Helvetica, Arial;
}

body.sticky {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;

    -webkit-box-orient: vertical;
    -webkit-box-direction: normal;
    -ms-flex-direction: column;
    flex-direction: column;

    height: 100vh;
}

/* classes */
p {
    margin: .5em 0;
}
a, a:visited, a:active, a:focus {
    text-decoration: none;
    color: #81afd2;
}
a:hover {
    color: darkblue;
}

/* general */
header, footer, section, div {
    -webkit-box-sizing: border-box;
    box-sizing: border-box;
    padding: .5em;
}

header, footer {
    background-color: #b8d0ea;
    text-align: center;
}

header h1, footer h1 {
    margin: .4em;
}

main {
    display:-webkit-box;
    display:-ms-flexbox;
    display:flex;
    -webkit-box-flex: 1;
    -ms-flex: 1;
    flex: 1;
    background-color: white;
    min-height: 0;                        /*  added  */
}

/* movies */
#movies {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -ms-flex-wrap: wrap;
    flex-wrap: wrap;
    width: 50%;
    overflow:auto;
    border-right: thin solid silver;
}

figure {
    text-align: center;
    margin: .8em .8em;
    width: 90px;
}

img {
    width: 92px;
    border: none;
}

/* movie */
#movie {
    width: 50%;

    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;

    -webkit-box-orient: vertical;
    -webkit-box-direction: normal;
        -ms-flex-direction: column;
            flex-direction: column;
    padding: 0;
}

#movie img {
    float: right;
    width: 100%;
    max-width: 200px;
}
#header {
    font-size: 1.5em;
    border-bottom: thin solid silver;
}
#details {
    -webkit-box-flex: 1;
        -ms-flex: 1;
            flex: 1;
    overflow: auto;
}
#details p:first-of-type {
    font-weight: 600;
}
#footer {
    border-top: thin solid silver;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code>    <body class="sticky">
        <header id="main-header">
            <h1>Test Flex</h1>
        </header>
        <main>
            <section id="movies">
            the movies<br>
            the movies<br>
            the movies<br>
            the movies<br>
            the movies<br>
            the movies<br>
            the movies<br>
            the movies<br>
            the movies<br>
            the movies<br>
            the movies<br>
            the movies<br>
            the movies<br>
            the movies<br>
            the movies<br>
            the movies<br>
            the movies<br>
            the movies<br>
            the movies<br>
            the movies<br>
            the movies<br>
            the movies<br>
            the movies<br>
            the movies<br>
            the movies<br>
            the movies<br>
            the movies<br>
            </section>
            <section id="movie">
                <div id="header">
                    The Title
                </div>
                <div id ="details">
                    The details<br>
                    The details<br>
                    The details<br>
                    The details<br>
                    The details<br>
                    The details<br>
                    The details<br>
                    The details<br>
                    The details<br>
                    The details<br>
                    The details<br>
                    The details<br>
                    The details<br>
                    The details<br>
                    The details<br>
                    The details<br>
                    The details<br>
                    The details<br>
                    The details<br>
                    The details<br>
                    The details<br>
                    The details<br>
                    The details<br>
                    The details<br>
                    The details<br>
                    The details<br>
                    The details<br>
                    The details<br>
                    The details<br>
                    The details<br>
                    The details<br>
                    The details<br>
                    The details<br>
                    The details<br>
                </div>
                <div id="footer">
                    The footer
                </div>
            </section>
        </main>
        <footer>
            The Footer ©
        </footer>
    </body></code>```

Body:
I have designed a web-page with a header and a sticky footer as follows:

/*
    Created on : Nov 16, 2017, 12:39:01 AM
    Author     : pantelis
*/
body, html {
    max-width: 960px;
    margin: auto;
    letter-spacing: normal;
    background-color: #173a61;
    font-family: sans-serif, Helvetica, Arial;
}

body.sticky {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;

    -webkit-box-orient: vertical;
    -webkit-box-direction: normal;
    -ms-flex-direction: column;
    flex-direction: column;

    height: 100vh;
}

/* classes */
p {
    margin: .5em 0;
}
a, a:visited, a:active, a:focus {
    text-decoration: none;
    color: #81afd2;
}
a:hover {
    color: darkblue;
}

/* general */
header, footer, section, div {
    -webkit-box-sizing: border-box;
    box-sizing: border-box;
    padding: .5em;
}

header, footer {
    background-color: #b8d0ea;
    text-align: center;
}

header h1, footer h1 {
    margin: .4em;
}

main {
    display:-webkit-box;
    display:-ms-flexbox;
    display:flex;
    -webkit-box-flex: 1;
    -ms-flex: 1;
    flex: 1;
    background-color: white;
}

/* movies */
#movies {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -ms-flex-wrap: wrap;
    flex-wrap: wrap;
    width: 50%;
    overflow:auto;
    border-right: thin solid silver;
}

figure {
    text-align: center;
    margin: .8em .8em;
    width: 90px;
}

img {
    width: 92px;
    border: none;
}

/* movie */
#movie {
    width: 50%;

    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;

    -webkit-box-orient: vertical;
    -webkit-box-direction: normal;
        -ms-flex-direction: column;
            flex-direction: column;
    padding: 0;
}

#movie img {
    float: right;
    width: 100%;
    max-width: 200px;
}
#header {
    font-size: 1.5em;
    border-bottom: thin solid silver;
}
#details {
    -webkit-box-flex: 1;
        -ms-flex: 1;
            flex: 1;
    overflow: auto;
}
#details p:first-of-type {
    font-weight: 600;
}
#footer {
    border-top: thin solid silver;
}

Test Flex

            the movies

            the movies

            the movies

            the movies

            the movies

            the movies

            the movies

            the movies

            the movies

            the movies

            the movies

            the movies

            the movies

            the movies

            the movies

            the movies

            the movies

            the movies

            the movies

            the movies

            the movies

            the movies

            the movies

            the movies

            the movies

            the movies

            the movies

                    The Title

                    The details

                    The details

                    The details

                    The details

                    The details

                    The details

                    The details

                    The details

                    The details

                    The details

                    The details

                    The details

                    The details

                    The details

                    The details

                    The details

                    The details

                    The details

                    The details

                    The details

                    The details

                    The details

                    The details

                    The details

                    The details

                    The details

                    The details

                    The details

                    The details

                    The details

                    The details

                    The details

                    The details

                    The details

                    The footer

            The Footer ©

The footer is properly positioned at the bottom of the browser window using the following CSS:

body.sticky {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;

    -webkit-box-orient: vertical;
    -webkit-box-direction: normal;
    -ms-flex-direction: column;
    flex-direction: column;

    height: 100vh;
}
main {
    display:-webkit-box;
    display:-ms-flexbox;
    display:flex;

    -webkit-box-flex: 1;
        -ms-flex: 1;
                flex: 1;

}

Two sections, each of 50% width, are contained in the main body. The first one contains many small items, so it is also a flex-box:

#movies {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -ms-flex-wrap: wrap;
        flex-wrap: wrap;

   width: 50%;
   overflow:auto;
}

The other section contains details of the movie upon clicking each item in #movies.

When #movies is empty, or with few items, all browsers render the page properly. When it is loaded with many items,
Chrome and Safari and all other webkit browsers (Opera, Vivaldi) display the page as expected, i.e. the #movies item displays a scroll bar without any expansion and the footer remains in place at the bottom of the viewport, as shown here. (Note that scrollbars are not shown on a Mac.)

Firefox and Edge on the other hand do not render the page as expected: the main section is expanded all the way down along the y-axis in order to contain all the items in #movies, no scrollbar is shown. The footer goes down too, after the end of #movies.

The issue can be tested here. I would welcome any ideas that might help to remedy this behaviour.

Body:
Flex item's has, in this case for column direction, a min-height that defaults to auto, which prevents it to become smaller than its content.

For Firefox and Edge, this needs to be set to 0 on the main, or else it will simply grow/overflow with its content.

main {
    display:-webkit-box;
    display:-ms-flexbox;
    display:flex;
    -webkit-box-flex: 1;
    -ms-flex: 1;
    flex: 1;
    background-color: white;
    min-height: 0;                        /*  added  */
}

Stack snippet

/*
    Created on : Nov 16, 2017, 12:39:01 AM
    Author     : pantelis
*/
body, html {
    max-width: 960px;
    margin: auto;
    letter-spacing: normal;
    background-color: #173a61;
    font-family: sans-serif, Helvetica, Arial;
}

body.sticky {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;

    -webkit-box-orient: vertical;
    -webkit-box-direction: normal;
    -ms-flex-direction: column;
    flex-direction: column;

    height: 100vh;
}

/* classes */
p {
    margin: .5em 0;
}
a, a:visited, a:active, a:focus {
    text-decoration: none;
    color: #81afd2;
}
a:hover {
    color: darkblue;
}

/* general */
header, footer, section, div {
    -webkit-box-sizing: border-box;
    box-sizing: border-box;
    padding: .5em;
}

header, footer {
    background-color: #b8d0ea;
    text-align: center;
}

header h1, footer h1 {
    margin: .4em;
}

main {
    display:-webkit-box;
    display:-ms-flexbox;
    display:flex;
    -webkit-box-flex: 1;
    -ms-flex: 1;
    flex: 1;
    background-color: white;
    min-height: 0;                        /*  added  */
}

/* movies */
#movies {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -ms-flex-wrap: wrap;
    flex-wrap: wrap;
    width: 50%;
    overflow:auto;
    border-right: thin solid silver;
}

figure {
    text-align: center;
    margin: .8em .8em;
    width: 90px;
}

img {
    width: 92px;
    border: none;
}

/* movie */
#movie {
    width: 50%;

    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;

    -webkit-box-orient: vertical;
    -webkit-box-direction: normal;
        -ms-flex-direction: column;
            flex-direction: column;
    padding: 0;
}

#movie img {
    float: right;
    width: 100%;
    max-width: 200px;
}
#header {
    font-size: 1.5em;
    border-bottom: thin solid silver;
}
#details {
    -webkit-box-flex: 1;
        -ms-flex: 1;
            flex: 1;
    overflow: auto;
}
#details p:first-of-type {
    font-weight: 600;
}
#footer {
    border-top: thin solid silver;
}

    <body class="sticky">
        <header id="main-header">
            <h1>Test Flex</h1>
        </header>
        <main>
            <section id="movies">
            the movies<br>
            the movies<br>
            the movies<br>
            the movies<br>
            the movies<br>
            the movies<br>
            the movies<br>
            the movies<br>
            the movies<br>
            the movies<br>
            the movies<br>
            the movies<br>
            the movies<br>
            the movies<br>
            the movies<br>
            the movies<br>
            the movies<br>
            the movies<br>
            the movies<br>
            the movies<br>
            the movies<br>
            the movies<br>
            the movies<br>
            the movies<br>
            the movies<br>
            the movies<br>
            the movies<br>
            </section>
            <section id="movie">
                <div id="header">
                    The Title
                </div>
                <div id ="details">
                    The details<br>
                    The details<br>
                    The details<br>
                    The details<br>
                    The details<br>
                    The details<br>
                    The details<br>
                    The details<br>
                    The details<br>
                    The details<br>
                    The details<br>
                    The details<br>
                    The details<br>
                    The details<br>
                    The details<br>
                    The details<br>
                    The details<br>
                    The details<br>
                    The details<br>
                    The details<br>
                    The details<br>
                    The details<br>
                    The details<br>
                    The details<br>
                    The details<br>
                    The details<br>
                    The details<br>
                    The details<br>
                    The details<br>
                    The details<br>
                    The details<br>
                    The details<br>
                    The details<br>
                    The details<br>
                </div>
                <div id="footer">
                    The footer
                </div>
            </section>
        </main>
        <footer>
            The Footer &copy;
        </footer>
    </body>


来源: stackexchange

问:
VBA stops running when value is written in a cell
I am organizing a dirty text in an organised table. And this code stops when the cell the marked line is completed. Can you help me to make it continuing the loop?</p>

```<code>Private Sub CommandButton1_Click()
    Dim sh As Worksheet
    Dim sh7 As Worksheet

    Dim CNAME As String

    Set sh = Worksheets("Sheet6")
    Set sh7 = Worksheets("Sheet7")
    lr = sh.Cells(Rows.Count, 1).End(xlUp).Row

    For n = 1 To lr
        If InStr(1, sh.Cells(n, 1), "CALL:") = 1 Then
            CNAME = sh.Cells(n, 7).Value
            Ci = sh.Cells(n + 1, 7).Value
            Cpd = sh.Cells(n + 1, 7).Value
        Else
            If InStr(1, sh.Cells(n, 1), "Topic:") = 1 Then
                T = sh.Cells(n, 2)
                Tpd = sh.Cells(n + 1, 2)
                Types = sh.Cells(n + 4, 2)
                DM = sh.Cells(n + 5, 2)
                D = sh.Cells(n + 5, 4)
                OD = sh.Cells(n + 6, 2)
                lr7 = sh7.Cells(Rows.Count, 1).End(xlUp).Row
                sh7.Cells(lr7 + 1, 1).Value = CNAME '********This is the last line it runs.
                sh7.Cells(lr7 + 1, 2).Value = Ci
                sh7.Cells(lr7 + 1, 3).Value = Cpd
                sh7.Cells(lr7 + 1, 4).Value = T
                sh7.Cells(lr7 + 1, 5).Value = Tpd
                sh7.Cells(lr7 + 1, 6).Value = Types
                sh7.Cells(lr7 + 1, 7).Value = DM
                sh7.Cells(lr7 + 1, 8).Value = D
                sh7.Cells(lr7 + 1, 9).Value = OD
            End If
        End If
    Next n
End Sub
</code>```

答:
You should get in the habit of defining all variables and supplying a default value.

EDIT:
It seems my original conclusion was incorrect. Upon further inspection I see what might be an issue in your code. Both times where you are trying to get the last row, you are using Rows.Count as a parameter.

Maybe change these

```<code>lr = sh.Cells(Rows.Count, 1).End(xlUp).Row
lr7 = sh7.Cells(Rows.Count, 1).End(xlUp).Row
</code>```

To this (note that I use the sheet variable in the first param)

```<code>lr = sh.Cells(sh.Rows.Count, 1).End(xlUp).Row
lr7 = sh7.Cells(sh7.Rows.Count, 1).End(xlUp).Row
</code>```

ContentLicense: CC BY-SA 3.0

Body:
I am organizing a dirty text in an organised table. And this code stops when the cell the marked line is completed. Can you help me to make it continuing the loop?

Private Sub CommandButton1_Click()
    Dim sh As Worksheet
    Dim sh7 As Worksheet

    Dim CNAME As String

    Set sh = Worksheets("Sheet6")
    Set sh7 = Worksheets("Sheet7")
    lr = sh.Cells(Rows.Count, 1).End(xlUp).Row

    For n = 1 To lr
        If InStr(1, sh.Cells(n, 1), "CALL:") = 1 Then
            CNAME = sh.Cells(n, 7).Value
            Ci = sh.Cells(n + 1, 7).Value
            Cpd = sh.Cells(n + 1, 7).Value
        Else
            If InStr(1, sh.Cells(n, 1), "Topic:") = 1 Then
                T = sh.Cells(n, 2)
                Tpd = sh.Cells(n + 1, 2)
                Types = sh.Cells(n + 4, 2)
                DM = sh.Cells(n + 5, 2)
                D = sh.Cells(n + 5, 4)
                OD = sh.Cells(n + 6, 2)
                lr7 = sh7.Cells(Rows.Count, 1).End(xlUp).Row
                sh7.Cells(lr7 + 1, 1).Value = CNAME '********This is the last line it runs.
                sh7.Cells(lr7 + 1, 2).Value = Ci
                sh7.Cells(lr7 + 1, 3).Value = Cpd
                sh7.Cells(lr7 + 1, 4).Value = T
                sh7.Cells(lr7 + 1, 5).Value = Tpd
                sh7.Cells(lr7 + 1, 6).Value = Types
                sh7.Cells(lr7 + 1, 7).Value = DM
                sh7.Cells(lr7 + 1, 8).Value = D
                sh7.Cells(lr7 + 1, 9).Value = OD
            End If
        End If
    Next n
End Sub

Body:
You should get in the habit of defining all variables and supplying a default value.

EDIT:
It seems my original conclusion was incorrect. Upon further inspection I see what might be an issue in your code. Both times where you are trying to get the last row, you are using Rows.Count as a parameter.

Maybe change these

lr = sh.Cells(Rows.Count, 1).End(xlUp).Row
lr7 = sh7.Cells(Rows.Count, 1).End(xlUp).Row

To this (note that I use the sheet variable in the first param)

lr = sh.Cells(sh.Rows.Count, 1).End(xlUp).Row
lr7 = sh7.Cells(sh7.Rows.Count, 1).End(xlUp).Row


问:
Spinnaker "Create Application" menu doesn't load
I'm quite new to the Spinnaker and have to ask for some help I guess. Does anyone knows why it could be that I can't create any Application and just keep seeing this screen.
My installation is through Halyard 1.5.0 and Ubuntu 14.04.
We don't use any cloud provider but I did configure Docker and Kubernetes part

And here is the error I see in the /var/log/spinnaker/echo/echo.log:

```<code>2017-11-16 13:52:29.901  INFO 13877 --- [ofit-/pipelines] c.n.s.echo.services.Front50Service       : java.net.SocketTimeoutException: timeout
at okio.Okio$3.newTimeoutException(Okio.java:207)
at okio.AsyncTimeout.exit(AsyncTimeout.java:261)
at okio.AsyncTimeout$2.read(AsyncTimeout.java:215)
at okio.RealBufferedSource.indexOf(RealBufferedSource.java:306)
at okio.RealBufferedSource.indexOf(RealBufferedSource.java:300)
at okio.RealBufferedSource.readUtf8LineStrict(RealBufferedSource.java:196)
at com.squareup.okhttp.internal.http.Http1xStream.readResponse(Http1xStream.java:186)
at com.squareup.okhttp.internal.http.Http1xStream.readResponseHeaders(Http1xStream.java:127)
at com.squareup.okhttp.internal.http.HttpEngine.readNetworkResponse(HttpEngine.java:739)
at com.squareup.okhttp.internal.http.HttpEngine.access$200(HttpEngine.java:87)
at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:724)
at com.squareup.okhttp.internal.http.HttpEngine.readResponse(HttpEngine.java:578)
at com.squareup.okhttp.Call.getResponse(Call.java:287)
at com.squareup.okhttp.Call$ApplicationInterceptorChain.proceed(Call.java:243)
at com.squareup.okhttp.Call.getResponseWithInterceptorChain(Call.java:205)
at com.squareup.okhttp.Call.execute(Call.java:80)
at retrofit.client.OkClient.execute(OkClient.java:53)
at retrofit.RestAdapter$RestHandler.invokeRequest(RestAdapter.java:326)
at retrofit.RestAdapter$RestHandler.access$100(RestAdapter.java:220)
at retrofit.RestAdapter$RestHandler$1.invoke(RestAdapter.java:265)
at retrofit.RxSupport$2.run(RxSupport.java:55)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at retrofit.Platform$Base$2$1.run(Platform.java:94)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.net.SocketException: Socket closed
at java.net.SocketInputStream.read(SocketInputStream.java:204)
at java.net.SocketInputStream.read(SocketInputStream.java:141)
at okio.Okio$2.read(Okio.java:139)
at okio.AsyncTimeout$2.read(AsyncTimeout.java:211)
... 24 more

2017-11-16 13:52:29.901  INFO 13877 --- [ofit-/pipelines] c.n.s.echo.services.Front50Service       : ---- END ERROR
</code>```

答:
I suspect you may be using redis as the persistent storage type(I ran into the same issue).

If this is the case, persistent storage using redis doesn't seem to be working properly out-of-the-box, and it is not supported. I would try using an S3 target, if available.

More info here on support for redis

To configure S3 using Halyard, use the following commands:

```<code>echo <SECRET_ACCESS_KEY> | hal config storage s3 edit --access-key-id <ACCESS_KEY_ID> --endpoint <S3_ENDPOINT> --bucket <BUCKET_NAME> --root-folder spinnaker --secret-access-key
hal config storage edit --type s3
hal deploy apply
</code>```

Body:
I'm quite new to the Spinnaker and have to ask for some help I guess. Does anyone knows why it could be that I can't create any Application and just keep seeing this screen.
My installation is through Halyard 1.5.0 and Ubuntu 14.04.
We don't use any cloud provider but I did configure Docker and Kubernetes part

And here is the error I see in the /var/log/spinnaker/echo/echo.log:

2017-11-16 13:52:29.901  INFO 13877 --- [ofit-/pipelines] c.n.s.echo.services.Front50Service       : java.net.SocketTimeoutException: timeout
at okio.Okio$3.newTimeoutException(Okio.java:207)
at okio.AsyncTimeout.exit(AsyncTimeout.java:261)
at okio.AsyncTimeout$2.read(AsyncTimeout.java:215)
at okio.RealBufferedSource.indexOf(RealBufferedSource.java:306)
at okio.RealBufferedSource.indexOf(RealBufferedSource.java:300)
at okio.RealBufferedSource.readUtf8LineStrict(RealBufferedSource.java:196)
at com.squareup.okhttp.internal.http.Http1xStream.readResponse(Http1xStream.java:186)
at com.squareup.okhttp.internal.http.Http1xStream.readResponseHeaders(Http1xStream.java:127)
at com.squareup.okhttp.internal.http.HttpEngine.readNetworkResponse(HttpEngine.java:739)
at com.squareup.okhttp.internal.http.HttpEngine.access$200(HttpEngine.java:87)
at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:724)
at com.squareup.okhttp.internal.http.HttpEngine.readResponse(HttpEngine.java:578)
at com.squareup.okhttp.Call.getResponse(Call.java:287)
at com.squareup.okhttp.Call$ApplicationInterceptorChain.proceed(Call.java:243)
at com.squareup.okhttp.Call.getResponseWithInterceptorChain(Call.java:205)
at com.squareup.okhttp.Call.execute(Call.java:80)
at retrofit.client.OkClient.execute(OkClient.java:53)
at retrofit.RestAdapter$RestHandler.invokeRequest(RestAdapter.java:326)
at retrofit.RestAdapter$RestHandler.access$100(RestAdapter.java:220)
at retrofit.RestAdapter$RestHandler$1.invoke(RestAdapter.java:265)
at retrofit.RxSupport$2.run(RxSupport.java:55)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at retrofit.Platform$Base$2$1.run(Platform.java:94)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.net.SocketException: Socket closed
at java.net.SocketInputStream.read(SocketInputStream.java:204)
at java.net.SocketInputStream.read(SocketInputStream.java:141)
at okio.Okio$2.read(Okio.java:139)
at okio.AsyncTimeout$2.read(AsyncTimeout.java:211)
... 24 more

2017-11-16 13:52:29.901  INFO 13877 --- [ofit-/pipelines] c.n.s.echo.services.Front50Service       : ---- END ERROR

Body:
I suspect you may be using redis as the persistent storage type(I ran into the same issue).

If this is the case, persistent storage using redis doesn't seem to be working properly out-of-the-box, and it is not supported. I would try using an S3 target, if available.

More info here on support for redis

To configure S3 using Halyard, use the following commands:

echo <SECRET_ACCESS_KEY> | hal config storage s3 edit --access-key-id <ACCESS_KEY_ID> --endpoint <S3_ENDPOINT> --bucket <BUCKET_NAME> --root-folder spinnaker --secret-access-key
hal config storage edit --type s3
hal deploy apply


问:
Initiating variables, of different types, in a way that I can iterate through them with a variable

'Declare variables for cell values attained from APR spreadsheet
    Dim orgSheetvalues(0) As String 'Project Title
    Dim orgSheetvalues(1) As String 'Circuit Tag
    Dim orgSheetvalues(2) As String 'District
    Dim orgSheetvalues(3) As String 'State
    Dim orgSheetvalues(4) As Date 'Date recieved
    Dim orgSheetvalues(5) As Currency  'Planned Capital Cost
    Dim orgSheetvalues(6) As Currency  'Actual Capital Cost
    Dim orgSheetvalues(7) As Date  'Capital work completed date
    Dim orgSheetvalues(8) As Currency  'Planned O&M Cost
    Dim orgSheetvalues(9) As Currency  'Actual O&M Cost
    Dim orgSheetvalues(10) As Date  'O&M work completed date
    Dim orgSheetvalues(11) As String 'RWP File Path
```

Clearly, this does not work.  Does anyone know of a way I can use the same variable name, for different variable types, in a way that can be iterated as the above would if it worked (eg. orgSheetvalue(iterating variable))?

答:
example</p>

```<code>Option Explicit

Sub aaa()

    Dim bbb(10) As Variant

    bbb(0) = "test 123"          ' string
    Set bbb(1) = Range("a1")     ' object
    bbb(2) = 98765               ' numeric

    Debug.Print bbb(0); vbTab; bbb(1).Interior.Color; vbTab; bbb(2)

End Sub
</code>```

Body:
'Declare variables for cell values attained from APR spreadsheet
    Dim orgSheetvalues(0) As String 'Project Title
    Dim orgSheetvalues(1) As String 'Circuit Tag
    Dim orgSheetvalues(2) As String 'District
    Dim orgSheetvalues(3) As String 'State
    Dim orgSheetvalues(4) As Date 'Date recieved
    Dim orgSheetvalues(5) As Currency  'Planned Capital Cost
    Dim orgSheetvalues(6) As Currency  'Actual Capital Cost
    Dim orgSheetvalues(7) As Date  'Capital work completed date
    Dim orgSheetvalues(8) As Currency  'Planned O&M Cost
    Dim orgSheetvalues(9) As Currency  'Actual O&M Cost
    Dim orgSheetvalues(10) As Date  'O&M work completed date
    Dim orgSheetvalues(11) As String 'RWP File Path

Clearly, this does not work.  Does anyone know of a way I can use the same variable name, for different variable types, in a way that can be iterated as the above would if it worked (eg. orgSheetvalue(iterating variable))?

Body:
example

Option Explicit

Sub aaa()

    Dim bbb(10) As Variant

    bbb(0) = "test 123"          ' string
    Set bbb(1) = Range("a1")     ' object
    bbb(2) = 98765               ' numeric

    Debug.Print bbb(0); vbTab; bbb(1).Interior.Color; vbTab; bbb(2)

End Sub


问:
How to get expiration_intent from Apple's subscriptions Server notifications?
According to the documentation in the below link, Apple subscriptions status server will send this field expiration_intent when users renew their subscription.

Apple's

This is the same as the Subscription Expiration Intent in the receipt.
Posted only if notification_type is RENEWAL or INTERACTIVE_RENEWAL.

https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/StoreKitGuide/Chapters/Subscriptions.html

I'm getting all the notifications on my production server and have checked all the logs for RENEWAL or INTERACTIVE_RENEWAL types but never been able to get the value for this field.

Any idea why this is happening? though I'm getting the rest of the fields with their values.

答:
This appears to be a bug, or a mistake in the documentation (one of many). I have only encountered this field when validating a receipt, where it will appear in the pending_renewal_info info (and only if auto_renew_status is 0).

Here is an OpenRadar I recommend duplicating: http://www.openradar.me/33937017


问:
Use grep to extract specific words from a string under conditions and print it to variable file names
I have a sample file like this:

r 2.1238 /NodeList/1/DeviceList/1/ ( type=0x806, source=00:00, destination=ff:ff) ns3::IPv4Header (source ipv4: 10.1.2.1 dest ipv4: 10.1.2.4)

+ 2.0076 /NodeList/0/DeviceList/1/ ( type=0x806, source=00:00, destination=ff:ff) ns3::ArpHeader (source ipv4: 10.1.2.1 dest ipv4: 10.1.2.4)

- 2.0077 /NodeList/1/DeviceList/1/ ( type=0x806, source=00:00, destination=ff:ff) ns3::IPv4Header (source ipv4: 10.1.2.1 dest ipv4: 10.1.2.4)

d 4.0042 /NodeList/2/DeviceList/1/ ( type=0x806, source=00:00, destination=ff:ff) ns3::IPv4Header (source ipv4: 10.1.2.1 dest ipv4: 10.1.2.4)

and so on.

The bold parts are the important fields. The first field can be '-', '+', 'r' or 'd'. The second field has a time stamp, in bold. Third field is to be the Node number, again in bold. The node number refers to the file to which the previous two fields is to be printed.

The restriction is that I want data from only those lines containing IPv4Header, eg. 1st, 3rd and 4th line in above sample.

So, I want my output to be like:

Node0.txt:
+ 2.0076

Node1.txt:
r 2.1238
- 2.0077

As you can see Node0 in line 2 is rejected as it does not contain IPv4Header. As we can see the number of output files being generated is equal to the number of nodes having IPv4Header.

Assume the number of lines and nodes to be multiple and variable for different files. Can someone please provide me with the necessary grep code?

答:
What you are actually looking for is sed. For example, using sed you could do the following:

```<code>$ sed -n '/IPv4Header/s/^\([+-rd]\)[ ]*\([0-9.]*\)[^0-9]*\([0-9]\).*$/Node\3.txt \1 \2/p' file
Node1.txt r 2.1238
Node1.txt - 2.0077
Node2.txt d 4.0042
</code>```

Where

sed -n  suppresses normal outoput,

/IPv4Header/  locate only lines containing IPv4Header

What following is the standard sed substitute s/match/replace/ where match uses capture groups \(stuff\) to save stuff for use in replace using backreferences where \1, \2... is replaced with stuff1, stuff2, etc..

^\([+-rd]\) save the first character if it is one of +-rd in capture group 1,

[ ]* skip any number of spaces,

\([0-9.]*\) save sequence of 0-9 and . in capture group 2,

[^0-9]* skip anything not a 0-9,

\([0-9]\) capture the next number in capture group 3,

.*$ skip remaining chars

/Node\3 \1 \2/ replace with the backreferences in the order shown

p print it.

Give it a try and let me know if it is doing what you need.

Body:
What you are actually looking for is sed. For example, using sed you could do the following:

$ sed -n '/IPv4Header/s/^\([+-rd]\)[ ]*\([0-9.]*\)[^0-9]*\([0-9]\).*$/Node\3.txt \1 \2/p' file
Node1.txt r 2.1238
Node1.txt - 2.0077
Node2.txt d 4.0042

Where

sed -n  suppresses normal outoput,

/IPv4Header/  locate only lines containing IPv4Header

What following is the standard sed substitute s/match/replace/ where match uses capture groups \(stuff\) to save stuff for use in replace using backreferences where \1, \2... is replaced with stuff1, stuff2, etc..

^\([+-rd]\) save the first character if it is one of +-rd in capture group 1,

[ ]* skip any number of spaces,

\([0-9.]*\) save sequence of 0-9 and . in capture group 2,

[^0-9]* skip anything not a 0-9,

\([0-9]\) capture the next number in capture group 3,

.*$ skip remaining chars

/Node\3 \1 \2/ replace with the backreferences in the order shown

p print it.

Give it a try and let me know if it is doing what you need.


问:
"static const" vs "#define" vs "enum"
Which one is better to use among the below statements in C?

```<code>static const int var = 5;
</code>```

or

```<code>#define var 5
</code>```

or

```<code>enum { var = 5 };
</code>```

答:
Another drawback of const in C is that you can't use the value in initializing another const.

```<code>static int const NUMBER_OF_FINGERS_PER_HAND = 5;
static int const NUMBER_OF_HANDS = 2;

// initializer element is not constant, this does not work.
static int const NUMBER_OF_FINGERS = NUMBER_OF_FINGERS_PER_HAND
                                     * NUMBER_OF_HANDS;
</code>```

Even this does not work with a const since the compiler does not see it as a constant:

```<code>static uint8_t const ARRAY_SIZE = 16;
static int8_t const lookup_table[ARRAY_SIZE] = {
    1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}; // ARRAY_SIZE not a constant!
</code>```

I'd be happy to use typed const in these cases, otherwise...

Title: "static const" vs "#define" vs "enum"

Body:
Which one is better to use among the below statements in C?

static const int var = 5;

or

#define var 5

or

enum { var = 5 };

Body:
Another drawback of const in C is that you can't use the value in initializing another const.

static int const NUMBER_OF_FINGERS_PER_HAND = 5;
static int const NUMBER_OF_HANDS = 2;

// initializer element is not constant, this does not work.
static int const NUMBER_OF_FINGERS = NUMBER_OF_FINGERS_PER_HAND
                                     * NUMBER_OF_HANDS;

Even this does not work with a const since the compiler does not see it as a constant:

static uint8_t const ARRAY_SIZE = 16;
static int8_t const lookup_table[ARRAY_SIZE] = {
    1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}; // ARRAY_SIZE not a constant!

I'd be happy to use typed const in these cases, otherwise...

ContentLicense: CC BY-SA 2.5


问:
Woocommerce coupon rounding issue
In our store we enter prices including tax. On frontend we hide decimals (In Sweden we don't really use decimals anymore in prices), but backend we keep them. This is why: https://krokedil.com/dont-display-prices-with-0-decimals-in-woocommerce/

We use the function from the link above to hide the decimals on frontend and have also added a function to round off coupons at front end.

```<code>/**
 * Trim zeros in price decimals
 **/
 add_filter( 'woocommerce_price_trim_zeros', '__return_true' );
function iconic_was_loop_position( $position ) {
    return 'woocommerce_after_shop_loop_item_title';
}

add_filter( 'iconic_was_loop_position', 'iconic_was_loop_position', 10, 1 );

/**
* Round off decimals for coupons
**/
function filter_woocommerce_coupon_get_discount_amount( $discount,
$discounting_amount, $cart_item, $single, $instance ) {
    $discount = ceil( $discount );
    return $discount;
}
add_filter( 'woocommerce_coupon_get_discount_amount',
'filter_woocommerce_coupon_get_discount_amount', 10, 5 );
</code>```

This works well for both prices and percentage coupons/discounts.
However, say I have a coupon with a fixed cart amount of SEK400, when using it the amount instead changes to SEK402.
I guess this has to do with how woo applies the coupons combined with the rounding filter.

So my question is, is it possible to exclude the fixed cart coupons from the rounding function in some way?

答:
This can be done very easily using the WC_Coupon conditional method is_type(). In your hooked function filter_woocommerce_coupon_get_discount_amount() you will use last argument $instance that is the WC_Coupon Object in an if statement, this way:

```<code>add_filter( 'woocommerce_coupon_get_discount_amount', 'filter_woocommerce_coupon_get_discount_amount', 10, 5 );
function filter_woocommerce_coupon_get_discount_amount( $discount, $discounting_amount, $cart_item, $single, $instance ) {
    // Round the discount for all other coupon types than 'fixed_cart'
    if( ! $instance->is_type('fixed_cart') )
        $discount = ceil( $discount );

    return $discount;
}
</code>```

Code goes in function.php file of your active child theme (or theme) or also in any plugin file.

This should work…

Title: Woocommerce coupon rounding issue

Body:
In our store we enter prices including tax. On frontend we hide decimals (In Sweden we don't really use decimals anymore in prices), but backend we keep them. This is why: https://krokedil.com/dont-display-prices-with-0-decimals-in-woocommerce/

We use the function from the link above to hide the decimals on frontend and have also added a function to round off coupons at front end.

/**
 * Trim zeros in price decimals
 **/
 add_filter( 'woocommerce_price_trim_zeros', '__return_true' );
function iconic_was_loop_position( $position ) {
    return 'woocommerce_after_shop_loop_item_title';
}

add_filter( 'iconic_was_loop_position', 'iconic_was_loop_position', 10, 1 );

/**
* Round off decimals for coupons
**/
function filter_woocommerce_coupon_get_discount_amount( $discount,
$discounting_amount, $cart_item, $single, $instance ) {
    $discount = ceil( $discount );
    return $discount;
}
add_filter( 'woocommerce_coupon_get_discount_amount',
'filter_woocommerce_coupon_get_discount_amount', 10, 5 );

This works well for both prices and percentage coupons/discounts.
However, say I have a coupon with a fixed cart amount of SEK400, when using it the amount instead changes to SEK402.
I guess this has to do with how woo applies the coupons combined with the rounding filter.

So my question is, is it possible to exclude the fixed cart coupons from the rounding function in some way?

Body:
This can be done very easily using the WC_Coupon conditional method is_type(). In your hooked function filter_woocommerce_coupon_get_discount_amount() you will use last argument $instance that is the WC_Coupon Object in an if statement, this way:

add_filter( 'woocommerce_coupon_get_discount_amount', 'filter_woocommerce_coupon_get_discount_amount', 10, 5 );
function filter_woocommerce_coupon_get_discount_amount( $discount, $discounting_amount, $cart_item, $single, $instance ) {
    // Round the discount for all other coupon types than 'fixed_cart'
    if( ! $instance->is_type('fixed_cart') )
        $discount = ceil( $discount );

    return $discount;
}

Code goes in function.php file of your active child theme (or theme) or also in any plugin file.

This should work…


问:
How to solve AmbiguousColumn error in postgresql with ruby project
I would like to join two query result.
First one is

```<code>Gig.where(id:gigsInRadioIDS)
When I convert result to json I get this result
[{"id":1,"address":"test1"},{"id":2,"address":"test2"}
</code>```

Second is.

```<code>Slot.where(status:"available").where(Sequel.lit('("from" > ?) AND ("to" < ?)', fromdate, todate))
when I convert result to json I get this result
[{"id":15,"status":"available","gig_id":1}]
</code>```

What I want is to inner join to result
so I hope to get this result(I abbreviated some non related snippet)

```<code>[{"id":15,"status":"available","gig_id":1,"id":1,"address":"test1"}]
</code>```

What I have tried is

```<code>Gig.where(id:gigsInRadioIDS).as(:tb_gig).join(Slot.where(status:"available").where(Sequel.lit('("from" > ?) AND ("to" < ?)', fromdate, todate)), gig_id: :id)
</code>```

And I got this error

```<code>Sequel::DatabaseError - PG::AmbiguousColumn: ERROR:  column reference "id" is ambiguous
LINE 1: ...) AS "t1" ON ("t1"."gig_id" = "gigs"."id") WHERE ("id" IN (2...
</code>```

Thanks for reading this complex code.
Any news will be big help. Thanks.

答:
Your where(id:gigsInRadioIDS) translates into WHERE ("id" IN (...)), and since both gigs and slots have an "id" column, the database doesn't know which id you want.

You need to explicitly specify the table with where{{gigs[:id] => gigsInRadioIDS}}

Querying with Sequel

Body:
I would like to join two query result.
First one is

Gig.where(id:gigsInRadioIDS)
When I convert result to json I get this result
[{"id":1,"address":"test1"},{"id":2,"address":"test2"}

Second is.

Slot.where(status:"available").where(Sequel.lit('("from" > ?) AND ("to" < ?)', fromdate, todate))
when I convert result to json I get this result
[{"id":15,"status":"available","gig_id":1}]

What I want is to inner join to result
so I hope to get this result(I abbreviated some non related snippet)

[{"id":15,"status":"available","gig_id":1,"id":1,"address":"test1"}]

What I have tried is

Gig.where(id:gigsInRadioIDS).as(:tb_gig).join(Slot.where(status:"available").where(Sequel.lit('("from" > ?) AND ("to" < ?)', fromdate, todate)), gig_id: :id)

And I got this error

Sequel::DatabaseError - PG::AmbiguousColumn: ERROR:  column reference "id" is ambiguous
LINE 1: ...) AS "t1" ON ("t1"."gig_id" = "gigs"."id") WHERE ("id" IN (2...

Thanks for reading this complex code.
Any news will be big help. Thanks.


问:
PHP: How to sanitize uploaded filenames?
I have a PHP application.

I allow users to upload files to my web application.

Question:  What's the best way for me to sanitize the file names of the uploaded documents $_FILES["filename"]["tmp_name"] in PHP?

UPDATE:

Can I take an MD5 of the uploaded filename and use that as the newly assigned filename? If so, how do I do that in PHP?

答:
Ciao, this function also removes all the points and then I create the clean string with the extension.</p>

```<code>function sanitaze_upload_file($data)
{
    $imgName   = $data;
    $indexOFF  = strrpos($imgName, '.');
    $nameFile  = substr($imgName, 0,$indexOFF);
    $extension = substr($imgName, $indexOFF);
    $clean     = preg_replace("([^\w\s\d\-_~,;\[\]\(\)])", "",
    $nameFile);
    $NAMEFILE  = str_replace(' ', '', $clean).$extension;
    return $NAMEFILE;
}
</code>```

Body:
Ciao, this function also removes all the points and then I create the clean string with the extension.

function sanitaze_upload_file($data)
{
    $imgName   = $data;
    $indexOFF  = strrpos($imgName, '.');
    $nameFile  = substr($imgName, 0,$indexOFF);
    $extension = substr($imgName, $indexOFF);
    $clean     = preg_replace("([^\w\s\d\-_~,;\[\]\(\)])", "",
    $nameFile);
    $NAMEFILE  = str_replace(' ', '', $clean).$extension;
    return $NAMEFILE;
}


问:
Program won't store characters in 2d array in c
I am creating a program where I insert a number of sentences and the program outputs them in order. I have finished the program, but when I run it it seems like the characters I input into the array aren't displayed or stored correctly, getting as a result random letters instead of the full sentence. Here is the code of the program:

```<code>char ch;
int i,j,k;
int nothing = 0;
int count = 1;
char lines[5][256];
int length[256];

int main() {
    printf("Please insert up to a max of 5 lines of text (Press enter to go to next line and twice enter to stop the program):\n");
    i = 0;
    while (i<5){

        j = 0;
        ch = getche();

        if (ch == '\r'){
            if(i!= 0){
                break;
            }
            printf("You have not inserted anything, please insert a line:");
            i=-1;
        }

        if(ch != '\r'){
            lines[i][j]=ch;
            while (ch!='\r'){
                ch = getche();
                lines[i][j] = ch;
                j++;
            }
        }
        printf("\n");
        i++;
    }
    for (k=i ; k > 0; k--){
        printf("\tphrase %i :", count);
        for ( j =0 ; j <= length[k]; j++){
            printf("%c",lines[j][k]);
        }
        count++;
        printf("\n");
    }
    return 0;
}
</code>```

How can I get the characters to be stored and displayed correctly? Any help is appreciated, thank you!!

答:
There are numerous problems with your code.  I'll try and summarise here, and give you improved code.

Fist, some changes that I made to get this to compile on my system:

Changed getche() to getchar() (getche() does not appear to be available on Ubuntu).

I took out the section about re-entering a string, and just focused on the rest (since the logic there was slightly broken, and not relevant to your question).  It will still check for at least one line though, before it will continue.

I had to change the check for \r to \n.

I changed your length array to size 5, since you'll only have the lengths of maximum 5 strings (not 256).

Some problems in your code:

You never updated the length[] array in the main while loop, so the program never knew how many characters to print.

Arrays are zero indexed, so your final printing loops would have skipped characters.  I changed the for parameters to start at zero, and work up to k < i, since you update i after your last character in the previous loop.  The same with j.

Your reference to the array in the printing loop was the wrong way around (so you would've printed from random areas in memory).  Changed lines[j][k] to lines[k][j].

No need for a separate count variable - just use k.  Removed count.

The nothing variable does not get used - removed it.

#include <stdlib.h>
#include <stdio.h>

char ch;
int i,j,k;
char lines[5][256];
int length[5];

int main()
{
    printf("Please insert up to a max of 5 lines of text (Press enter to go to the next line and twice enter to stop the program):\n");
    i = 0;
    while (i<5)
    {
        j = 0;
        ch = getchar();

        if ((ch == '\n') && (j == 0) && (i > 0))
        {
            break;
        }

        if (ch != '\n')
        {
            while (ch != '\n')
            {
                lines[i][j] = ch;
                j++;
                ch = getchar();
            }
        }
        length[i] = j;
        printf("\n");
        i++;
    }
    for (k = 0; k < i; k++)
    {
        printf("\tPhrase %i : ", k);
        for (j = 0; j < length[k]; j++)
        {
            printf("%c", lines[k][j]);
        }
        printf("\n");
    }
    return 0;
}
```

Body:
I am creating a program where I insert a number of sentences and the program outputs them in order. I have finished the program, but when I run it it seems like the characters I input into the array aren't displayed or stored correctly, getting as a result random letters instead of the full sentence. Here is the code of the program:

char ch;
int i,j,k;
int nothing = 0;
int count = 1;
char lines[5][256];
int length[256];

int main() {
    printf("Please insert up to a max of 5 lines of text (Press enter to go to next line and twice enter to stop the program):\n");
    i = 0;
    while (i<5){

        j = 0;
        ch = getche();

        if (ch == '\r'){
            if(i!= 0){
                break;
            }
            printf("You have not inserted anything, please insert a line:");
            i=-1;
        }

        if(ch != '\r'){
            lines[i][j]=ch;
            while (ch!='\r'){
                ch = getche();
                lines[i][j] = ch;
                j++;
            }
        }
        printf("\n");
        i++;
    }
    for (k=i ; k > 0; k--){
        printf("\tphrase %i :", count);
        for ( j =0 ; j <= length[k]; j++){
            printf("%c",lines[j][k]);
        }
        count++;
        printf("\n");
    }
    return 0;
}

How can I get the characters to be stored and displayed correctly? Any help is appreciated, thank you!!


问:
JQuery not keyword
```<code>$("li a").click(function() {
    $(this).parent().css({ width: 160 });
    $("li").unbind('mouseenter mouseleave');
    $("#Container").css({ width: 200 }).animate({ width: 700 }, 1000);
});
</code>```

I wanna set width 120 for all li's except current(this).

Thanks

Title: JQuery not keyword

Body:
$("li a").click(function() {
    $(this).parent().css({ width: 160 });
    $("li").unbind('mouseenter mouseleave');
    $("#Container").css({ width: 200 }).animate({ width: 700 }, 1000);
});

I wanna set width 120 for all li's except current(this).

Thanks

Body: $(this).parent().siblings().css('width',120);


问:
Drupal 8 disable template (page & node) cache
I have tried several articles to disable the page and template cache in Drupal 8.  I am not using drush and find it very annoying I have to manually clear the cache after every change.

sites/default/default.services.yaml

List item

debug: true

cache: false

auto_reload: true

create sites/settings.php & sites/settings.local.php

$config['system.performance']['css']['preprocess'] = FALSE;

$config['system.performance']['js']['preprocess'] = FALSE;

$settings['cache']['bins']['render'] = 'cache.backend.null';

$settings['cache']['bins']['dynamic_page_cache'] = 'cache.backend.null';

$settings['cache']['bins']['page'] = 'cache.backend.null';

in development.services.yml add the following

```<code>    1. twig.config:
        debug: true
        auto_reload: true
        cache: false
</code>```

Rebuild the cache

http://yoursite/core/rebuild.php or drush cr

Disable cache in configuration -> performance

Be sure to disable dev tools cache

If I make an adjustment to page.html.twig nothing happens til I clear the cache, any other ideas would be great. This would be the latest version of Drupal 8

答:
With all the steps above I forgot to do one thing

Move the settings.local.php inside sites/default

Uncomment the following in settings.php

if (file_exists(DIR . '/settings.local.php')) {
  include DIR . '/settings.local.php';
}

Body:
I have tried several articles to disable the page and template cache in Drupal 8.  I am not using drush and find it very annoying I have to manually clear the cache after every change.

sites/default/default.services.yaml

List item

debug: true

cache: false

auto_reload: true

create sites/settings.php & sites/settings.local.php

$config['system.performance']['css']['preprocess'] = FALSE;

$config['system.performance']['js']['preprocess'] = FALSE;

$settings['cache']['bins']['render'] = 'cache.backend.null';

$settings['cache']['bins']['dynamic_page_cache'] = 'cache.backend.null';

$settings['cache']['bins']['page'] = 'cache.backend.null';

in development.services.yml add the following

    1. twig.config:
        debug: true
        auto_reload: true
        cache: false

Rebuild the cache

http://yoursite/core/rebuild.php or drush cr

Disable cache in configuration -> performance

Be sure to disable dev tools cache

If I make an adjustment to page.html.twig nothing happens til I clear the cache, any other ideas would be great. This would be the latest version of Drupal 8


问:
How to resolve "IndexError: string index out of range" error in python?
I use the following code to read data from a text file, and add some lines in between of some of the lines, but after running the code, before doing that, I get an error as mentioned bellow.

The data in the text file is converted from csv file and are comma separeted.

```<code>import os
import re
import time
from datetime import datetime

file_list = []
file_counter = 1
for filename in os.listdir(os.getcwd()):
    file_list.append(filename)

for filename in file_list:
    if(filename=='q.py'):   continue
    file = open(filename,"r").read().split('\n')
    file_to_write = "file" +str(file_counter) +".txt"
    file_w = open(file_to_write,"w")
    file_w.write(file[0])
    file_w.write("\n")
    number_of_lines = sum(1 for _ in file)
    lis = []
    for i in range(number_of_lines):
        lis.append(file[i])
    modified_time = []
    for i in range(number_of_lines):
        line = lis[i].split(' ')

        if(line[0]=='name' or line[0]==''):
            continue;
        temp1 = ""
        temp1+=line[2][0]
        temp1+=line[2][1]
        temp1+=line[2][2]
        temp1+=line[2][3]
        temp1+=line[2][4]
        temp1+=line[2][5]
        temp1+='0'
        temp1+='0'
        line[2] = temp1
        try:
            modified_time.append(line[0]+' '+line[1]+' '+line[2]+'
'+line[3]+' '+line[4]+' '+line[5])
        except:
            continue

    for i in range(len(modified_time)-1):
        line1 = modified_time[i].split(' ')
        if(line1[0]=='name' or line1[0]==''):
            continue;
        line2 = modified_time[i+1].split(' ')
        date1 = line1[1]
        date2 = line2[1]
        time1 = line1[2]
        time2 = line2[2]
        day1 = datetime.strptime(date1, '%Y/%m/%d').date()
        day2 = datetime.strptime(date2, '%Y/%m/%d').date()
        diff1 = (day2-day1).days*24*60

        format = '%H:%M:%S'
        startDateTime = datetime.strptime(time1, format)
        endDateTime = datetime.strptime(time2, format)

        diff2 = endDateTime-startDateTime
        diff2 = diff2.seconds/60

        diff =  diff1 + int(diff2)

        lis_written = line1[0] + ' ' + line1[1] + ' ' + line1[2] + ' ' +
line1[3] + ' ' + line1[4] + ' ' + line1[5] + '\n';
        file_w.write(lis_written)
        format = '%Y/%m/%d %H:%M:%S'
        time_counter = datetime.strptime(line1[1]+' '+line1[2], format)

        from datetime import timedelta

        for i in range(diff-1):
            time_counter = time_counter +timedelta(0,60)
            time_value = str(time_counter)
            time_value = time_value.split(' ')
            giventime = time_value[1]
            givendate = time_value[0]

            temp_str = ""
            temp_str+=givendate[0]
            temp_str+=givendate[1]
            temp_str+=givendate[2]
            temp_str+=givendate[3]
            temp_str+='/'
            temp_str+=givendate[5]
            temp_str+=givendate[6]
            temp_str+='/'
            temp_str+=givendate[8]
            temp_str+=givendate[9]

            lis_written = line1[0] + ' ' + temp_str + ' ' + giventime + ' ' +
str(-999) + ' ' + line1[4] + ' ' + line1[5] + '\n';
            file_w.write(lis_written)

    file_w.write(file[len(file)-1])
    file_w.write("\n")
    file_counter+=1
</code>```

This is the error I get at line 33:

```<code>Traceback (most recent call last):
  File "C:\Users\bxr5813\Desktop\time series\run\New folder\New folder\q.py",
line 33, in <module>
    temp1+=line[2][4]
IndexError: string index out of range
</code>```

The format of the input text file is as follows:

```<code>Value Date Time MilliSecond
919 04/15/16 19:41:02 700682752
551 04/15/16 19:46:51 014109952
717 04/15/16 19:49:48 333956864
2679 04/15/16 19:52:49 8053952
2890 04/15/16 19:55:43 73351552
2897 04/15/16 19:58:38 257767936
1790 04/15/16 21:39:14 13785728
2953 04/15/16 21:42:10 801841152
2516 04/15/16 21:45:04 467205376
2530 04/15/16 21:47:58 688858368
2951 04/15/16 21:51:02 6165952
2954 04/15/16 21:53:56 48836992
2537 04/15/16 21:56:52 105879296
2523 04/15/16 21:59:45 920951808
2536 04/15/16 22:02:49 103219968
2727 04/15/16 22:05:43 708147456
2554 04/15/16 22:11:48 323045888
2703 04/15/16 22:14:46 932627712
2958 04/15/16 22:17:40 574788352
2683 04/15/16 22:20:34 7734976
2542 04/15/16 22:23:29 353888512
2536 04/15/16 22:29:15 787323136
</code>```

答:
If you want to grab the last element on the 3rd line (index 2) it would be

temp1 += line[2][3]

Referencing line [x][4] implies you want the 5th column of a row that only has 4

Body:
I use the following code to read data from a text file, and add some lines in between of some of the lines, but after running the code, before doing that, I get an error as mentioned bellow.

The data in the text file is converted from csv file and are comma separeted.

import os
import re
import time
from datetime import datetime

file_list = []
file_counter = 1
for filename in os.listdir(os.getcwd()):
    file_list.append(filename)

for filename in file_list:
    if(filename=='q.py'):   continue
    file = open(filename,"r").read().split('\n')
    file_to_write = "file" +str(file_counter) +".txt"
    file_w = open(file_to_write,"w")
    file_w.write(file[0])
    file_w.write("\n")
    number_of_lines = sum(1 for _ in file)
    lis = []
    for i in range(number_of_lines):
        lis.append(file[i])
    modified_time = []
    for i in range(number_of_lines):
        line = lis[i].split(' ')

        if(line[0]=='name' or line[0]==''):
            continue;
        temp1 = ""
        temp1+=line[2][0]
        temp1+=line[2][1]
        temp1+=line[2][2]
        temp1+=line[2][3]
        temp1+=line[2][4]
        temp1+=line[2][5]
        temp1+='0'
        temp1+='0'
        line[2] = temp1
        try:
            modified_time.append(line[0]+' '+line[1]+' '+line[2]+'
'+line[3]+' '+line[4]+' '+line[5])
        except:
            continue

    for i in range(len(modified_time)-1):
        line1 = modified_time[i].split(' ')
        if(line1[0]=='name' or line1[0]==''):
            continue;
        line2 = modified_time[i+1].split(' ')
        date1 = line1[1]
        date2 = line2[1]
        time1 = line1[2]
        time2 = line2[2]
        day1 = datetime.strptime(date1, '%Y/%m/%d').date()
        day2 = datetime.strptime(date2, '%Y/%m/%d').date()
        diff1 = (day2-day1).days*24*60

        format = '%H:%M:%S'
        startDateTime = datetime.strptime(time1, format)
        endDateTime = datetime.strptime(time2, format)

        diff2 = endDateTime-startDateTime
        diff2 = diff2.seconds/60

        diff =  diff1 + int(diff2)

        lis_written = line1[0] + ' ' + line1[1] + ' ' + line1[2] + ' ' +
line1[3] + ' ' + line1[4] + ' ' + line1[5] + '\n';
        file_w.write(lis_written)
        format = '%Y/%m/%d %H:%M:%S'
        time_counter = datetime.strptime(line1[1]+' '+line1[2], format)

        from datetime import timedelta

        for i in range(diff-1):
            time_counter = time_counter +timedelta(0,60)
            time_value = str(time_counter)
            time_value = time_value.split(' ')
            giventime = time_value[1]
            givendate = time_value[0]

            temp_str = ""
            temp_str+=givendate[0]
            temp_str+=givendate[1]
            temp_str+=givendate[2]
            temp_str+=givendate[3]
            temp_str+='/'
            temp_str+=givendate[5]
            temp_str+=givendate[6]
            temp_str+='/'
            temp_str+=givendate[8]
            temp_str+=givendate[9]

            lis_written = line1[0] + ' ' + temp_str + ' ' + giventime + ' ' +
str(-999) + ' ' + line1[4] + ' ' + line1[5] + '\n';
            file_w.write(lis_written)

    file_w.write(file[len(file)-1])
    file_w.write("\n")
    file_counter+=1

This is the error I get at line 33:

Traceback (most recent call last):
  File "C:\Users\bxr5813\Desktop\time series\run\New folder\New folder\q.py",
line 33, in <module>
    temp1+=line[2][4]
IndexError: string index out of range

The format of the input text file is as follows:

Value Date Time MilliSecond
919 04/15/16 19:41:02 700682752
551 04/15/16 19:46:51 014109952
717 04/15/16 19:49:48 333956864
2679 04/15/16 19:52:49 8053952
2890 04/15/16 19:55:43 73351552
2897 04/15/16 19:58:38 257767936
1790 04/15/16 21:39:14 13785728
2953 04/15/16 21:42:10 801841152
2516 04/15/16 21:45:04 467205376
2530 04/15/16 21:47:58 688858368
2951 04/15/16 21:51:02 6165952
2954 04/15/16 21:53:56 48836992
2537 04/15/16 21:56:52 105879296
2523 04/15/16 21:59:45 920951808
2536 04/15/16 22:02:49 103219968
2727 04/15/16 22:05:43 708147456
2554 04/15/16 22:11:48 323045888
2703 04/15/16 22:14:46 932627712
2958 04/15/16 22:17:40 574788352
2683 04/15/16 22:20:34 7734976
2542 04/15/16 22:23:29 353888512
2536 04/15/16 22:29:15 787323136


问:
Run a list of String through a list of filters
I have List<String> and List<Filter>.

```<code>public interface Filter{
     List<String> filter(List<String> strToFilter);
}
</code>```

How can I pass the List<String> through the list of filters and use the output of one filter as an input to the other filter? I can do this using for-loop. I wanted to know how to achieve this using java 8 stream and lambda

答:
Reduce your transformations to a single one, and apply that to each element:</p>

```<code>List<String> filter(List<String> strToFilter) {
    List<Function<String, String>> transformations; // populate as you wish
    Function<String, String> reduction = transformations.stream().reduce(identity(), (a, b) -> a.andThen(b));
    return strToFilter.stream().map(reduction::apply).collect(toList());
}
</code>```

Body:
I have List<String> and List<Filter>.

public interface Filter{
     List<String> filter(List<String> strToFilter);
}

How can I pass the List<String> through the list of filters and use the output of one filter as an input to the other filter? I can do this using for-loop. I wanted to know how to achieve this using java 8 stream and lambda

Body:
Reduce your transformations to a single one, and apply that to each element:

List<String> filter(List<String> strToFilter) {
    List<Function<String, String>> transformations; // populate as you wish
    Function<String, String> reduction = transformations.stream().reduce(identity(), (a, b) -> a.andThen(b));
    return strToFilter.stream().map(reduction::apply).collect(toList());
}


问:
How can a Python module be imported from a URL?
As an experiment, I want to see how to import a Python module from a URL. The hypothetical goal here would be to import from a central location which keeps the modules up-to-date. How could this be done?

My attempt is as follows:

```<code>>>> import urllib
>>>
>>> def import_URL(URL):
...     exec urllib.urlopen(URL) in globals()
...
>>> import_URL("https://cdn.rawgit.com/wdbm/shijian/master/shijian.py")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<stdin>", line 2, in import_URL
TypeError: exec: arg 1 must be a string, file, or code object
</code>```

EDIT: Martijn Pieters identified a fix for the example code that results in the string representation of the remote module. The resulting code is as follows:

```<code>import urllib
def import_URL(URL):
    exec urllib.urlopen(URL).read() in globals()
</code>```

答:
Yes you can.

Just fetch the module with the url and once you have it store it as a string where you can run it using eval()

Using urllib and eval it can be done easily:

```<code>import urllib.request
a = urllib.request.urlopen(url)
eval(a.read())
</code>```

Do note that some modules (such as Pygame and Pydub) require runtimes and they could not be run using eval() because of the missing runtimes.

Good luck with your project, I hope I helped.

Body:
As an experiment, I want to see how to import a Python module from a URL. The hypothetical goal here would be to import from a central location which keeps the modules up-to-date. How could this be done?

My attempt is as follows:

>>> import urllib
>>>
>>> def import_URL(URL):
...     exec urllib.urlopen(URL) in globals()
...
>>> import_URL("https://cdn.rawgit.com/wdbm/shijian/master/shijian.py")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<stdin>", line 2, in import_URL
TypeError: exec: arg 1 must be a string, file, or code object

EDIT: Martijn Pieters identified a fix for the example code that results in the string representation of the remote module. The resulting code is as follows:

import urllib
def import_URL(URL):
    exec urllib.urlopen(URL).read() in globals()

Body:
Yes you can.

Just fetch the module with the url and once you have it store it as a string where you can run it using eval()

Using urllib and eval it can be done easily:

import urllib.request
a = urllib.request.urlopen(url)
eval(a.read())

Do note that some modules (such as Pygame and Pydub) require runtimes and they could not be run using eval() because of the missing runtimes.

Good luck with your project, I hope I helped.


问:
Using FORM.getPartsArray() in Lucee
Currently I'm working on a project to convert source code from ColdFusion to Lucee. I found an error occurs in Lucee, when using FORM.getPartArray(). Does Lucee have a similar function that can replace FORM.getPartArray()?

Example code:

```<code><cfset var fileExt = 'png'>
<cfset var tmpPartsArray = FORM.getPartsArray() />
<cfif IsDefined("tmpPartsArray")>
    <cfloop array="#tmpPartsArray#" index="local.tmpPart">
        <cfif local.tmpPart.isFile() AND local.tmpPart.getName() EQ arguments.formField>
            <cfset fileExt = ListLast(local.tmpPart.getFileName(), ".")>
        </cfif>
    </cfloop>
</cfif>
</code>```

答:
You could also try FORM.getFileItems(). That array seems to contain only file fields.

```<code><cfset Local.filesArray = FORM.getFileItems() />
<cfloop array="#Local.filesArray#" index="local.currFile">
    <cfset fileExt = ListLast(local.currFile.getName(), ".")>
</cfloop>
</code>```

What is the purpose of the original code? As the file was already uploaded to the server, you could also move it to a safe directory with <cffile action="upload"> and check cffile.serverFileExt instead.

Title: Using FORM.getPartsArray() in Lucee

Body:
Currently I'm working on a project to convert source code from ColdFusion to Lucee. I found an error occurs in Lucee, when using FORM.getPartArray(). Does Lucee have a similar function that can replace FORM.getPartArray()?

Example code:

<cfset var fileExt = 'png'>
<cfset var tmpPartsArray = FORM.getPartsArray() />
<cfif IsDefined("tmpPartsArray")>
    <cfloop array="#tmpPartsArray#" index="local.tmpPart">
        <cfif local.tmpPart.isFile() AND local.tmpPart.getName() EQ arguments.formField>
            <cfset fileExt = ListLast(local.tmpPart.getFileName(), ".")>
        </cfif>
    </cfloop>
</cfif>

Body:
You could also try FORM.getFileItems(). That array seems to contain only file fields.

<cfset Local.filesArray = FORM.getFileItems() />
<cfloop array="#Local.filesArray#" index="local.currFile">
    <cfset fileExt = ListLast(local.currFile.getName(), ".")>
</cfloop>

What is the purpose of the original code? As the file was already uploaded to the server, you could also move it to a safe directory with <cffile action="upload"> and check cffile.serverFileExt instead.


问:
Alpine container not able to resolve hostname
I have a StatefulSet Kubernetes deployment with 2 worker nodes. I was able to bring the containers up on those 2 nodes using a headless service hence the nodes have hostname as

abc-0.abc.default.svc.cluster.local

abc-1.abc.default.svc.cluster.local

The problem is that I am not able to ping abc-0 from abc-1 and in the opposite direction using the hostname. If I use IP addresses then everything works fine.

There were issues related the DNS resolution with Alpine Linux at some point(https://github.com/gliderlabs/docker-alpine/issues/8#issuecomment-172594887) but seems it was fixed in Alpine Linux 3.4.

What would be the good way to verify that the problem I am facing is not because of the Linux but instead some misconfiguration in Kube-DNS or something?

答: The problem was that the service I was running didn't get endpoints assigned to it. I am using v1.7.3 so resolved the problem by adding 'selector' on the headless service. Also, looks like this is no longer a problem in v1.8.3.</p>


问:
Azure B2C - Migrating users from SQL Database to B2C tenant
We are looking for any template or process available to migrate users that exist within an existing SQL Database into B2C users for their tenant. We also would need to validate the user's passwords prior to creation of these migrated users.

Is there any type of script/process you can suggest for completing such a B2C Tenant migration task.

答:
The Azure AD B2C team have published guidance for migration of identities at https://learn.microsoft.com/en-us/azure/active-directory-b2c/active-directory-b2c-user-migration.

If you don't have access to credentials in the current database (which I am hoping is true), then you might consider a "hybrid" migration, where:

During the migration period (e.g. a few days, weeks, or months) as users are signing themselves into or resetting passwords with the current identity provider, you create an Azure AD B2C identity for them with their current or new password.

At the end of the migration period, you create Azure AD B2C identities for all of the remaining users with a random password.

The key objective of this hybrid migration is to be friendly to users that are active during the migration period.


问:
Searching TrueVault always returns INVALID_SEARCH_QUERY
Dead simple search query only using required fields:

```<code>{ schema_id: 'xxxxxxxx-8b39-427a-8fb8-c764957fd9c6',
filter: { last_name: { type: 'not', value: 'Smith' } } }
</code>```

POSTing to https://api.truevault.com/v1/vaults/xxxxxxxx-15e3-442e-aa6f-xxxxxxxx/search

When POSTing, the POST call options look like this:

```<code>{
data: { search_option: 'xxxx base64 encoded JSON.stringify of the above xxxxxxx' },
headers: { Authorization: 'Basic xxx base64 encoded API KEY xxx' }
}
</code>```

Authorization is working. Result:

{ Error: failed [400] {     "error": {         "code":
  "SEARCH.INVALID_SEARCH_QUERY",         "message": "Invalid
  search_option.",         "type": "invalid_request_error"     },

  "result": "error",     "transaction_id":
  "9ad83046-1906-406c-87ab-963b904857c4" }

curl command for the same search query:

```<code>curl -d "{ search_option: 'eyJzY2hlbWFfaWQiOiJlOWVmYmE0NC04YjMwLTQyN2EtOGZiOC1jNzY0OTU3ZmMwZGUiLCJmaWx0ZXIiOnsibGFzdF9uYW1lIjp7InR5cGUiOiJ3aWxkY2FyZCIsInZhbHVlIjoiRnJhbnptZWllcioifX19' }"
-X POST
-H "Content-Type: application/json"
-H "Authorization: Basic xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx=="
https://api.truevault.com/v1/vaults/xxxxxxxx-15e3-442e-aa6f-4xxxxxxxxxx/search
</code>```

Same error:

```<code>{
    "error": {
        "code": "SEARCH.INVALID_SEARCH_QUERY",
        "message": "Invalid search_option.",
        "type": "invalid_request_error"
    },
    "result": "error",
    "transaction_id": "b5a51185-264f-4765-a1b8-6ae9e491aa39"
}
</code>```

答:
Alex,

I don't think your curl command is formatted the way TrueVault expects. This may also be your problem in your http library. The curl command I'd expect is:

```<code>curl https://api.truevault.com/v1/vaults/xyz/search \
 -XPOST \
 -H "Content..."
 -H "Auth..."
 -d "search_option=eyJ...."
</code>```

That is, the data payload is form-encoded (param1=value1&param2=value2) not JSON.

It looks like the docs for search were missing a sample curl, but you can see a similar curl for document create listed in the docs.

Body:
Dead simple search query only using required fields:

{ schema_id: 'xxxxxxxx-8b39-427a-8fb8-c764957fd9c6',
filter: { last_name: { type: 'not', value: 'Smith' } } }

POSTing to https://api.truevault.com/v1/vaults/xxxxxxxx-15e3-442e-aa6f-xxxxxxxx/search

When POSTing, the POST call options look like this:

{
data: { search_option: 'xxxx base64 encoded JSON.stringify of the above xxxxxxx' },
headers: { Authorization: 'Basic xxx base64 encoded API KEY xxx' }
}

Authorization is working. Result:

{ Error: failed [400] {     "error": {         "code":
  "SEARCH.INVALID_SEARCH_QUERY",         "message": "Invalid
  search_option.",         "type": "invalid_request_error"     },

  "result": "error",     "transaction_id":
  "9ad83046-1906-406c-87ab-963b904857c4" }

curl command for the same search query:

curl -d "{ search_option: 'eyJzY2hlbWFfaWQiOiJlOWVmYmE0NC04YjMwLTQyN2EtOGZiOC1jNzY0OTU3ZmMwZGUiLCJmaWx0ZXIiOnsibGFzdF9uYW1lIjp7InR5cGUiOiJ3aWxkY2FyZCIsInZhbHVlIjoiRnJhbnptZWllcioifX19' }"
-X POST
-H "Content-Type: application/json"
-H "Authorization: Basic xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx=="
https://api.truevault.com/v1/vaults/xxxxxxxx-15e3-442e-aa6f-4xxxxxxxxxx/search

Same error:

{
    "error": {
        "code": "SEARCH.INVALID_SEARCH_QUERY",
        "message": "Invalid search_option.",
        "type": "invalid_request_error"
    },
    "result": "error",
    "transaction_id": "b5a51185-264f-4765-a1b8-6ae9e491aa39"
}

Body:
Alex,

I don't think your curl command is formatted the way TrueVault expects. This may also be your problem in your http library. The curl command I'd expect is:

curl https://api.truevault.com/v1/vaults/xyz/search \
 -XPOST \
 -H "Content..."
 -H "Auth..."
 -d "search_option=eyJ...."

That is, the data payload is form-encoded (param1=value1&param2=value2) not JSON.

It looks like the docs for search were missing a sample curl, but you can see a similar curl for document create listed in the docs.


问:
App Crash while trying to share information through slack using UIActivityViewController
I am using an UIActivityViewController to show share options. The information I am trying to share consists of two pieces (a plain string and an url). The share is working through all the extensions like iMessages, Mail, Notes, Twitter, Facebook etc, but the app is crashing when I try to share through Slack. The weird thing is that the crash only happens if I am not debugging and it never crashes while debugging.

Code:

```<code>UIActivityViewController *activityVC = [[UIActivityViewController alloc] initWithActivityItems:@[title, self] applicationActivities:nil];
[self presentViewController:activityVC animated:YES completion:nil];

# UIActivityItemSource methods
- (id)activityViewControllerPlaceholderItem:(UIActivityViewController *)activityViewController {
    return url;
}

- (id)activityViewController:(UIActivityViewController *)activityViewController itemForActivityType:(NSString *)activityType {
    return url;
}

- (NSString*)activityViewController:(UIActivityViewController *)activityViewController subjectForActivityType:(NSString *)activityType {
    return title;
}

- (NSString *)activityViewController:(UIActivityViewController *)activityViewController dataTypeIdentifierForActivityType:(NSString *)activityType {
    return @"com.test.url";
}

- (UIImage *)activityViewController:(UIActivityViewController *)activityViewController thumbnailImageForActivityType:(NSString *)activityType suggestedSize:(CGSize)size {
    return image;
}
</code>```

I also noticed that this crash is happening on the Flipboard app and it's working fine on the Twitter app.

Did anyone run into this issue? If so can you please let me know what's the issue and how this can be fixed?

答: I've recently run into what sounds like the same issue. Sharing with Slack won't crash when you only have one item in the activityItems/initWithActivityItems array, but if you have more than that, it will crash. I don't know if you are experiencing that particular problem, but a workaround is to combine the url and text into one string object, if that will fit your use case. Seems like a problem with Slack that they need to address.</p>

Body:
I am using an UIActivityViewController to show share options. The information I am trying to share consists of two pieces (a plain string and an url). The share is working through all the extensions like iMessages, Mail, Notes, Twitter, Facebook etc, but the app is crashing when I try to share through Slack. The weird thing is that the crash only happens if I am not debugging and it never crashes while debugging.

Code:

UIActivityViewController *activityVC = [[UIActivityViewController alloc] initWithActivityItems:@[title, self] applicationActivities:nil];
[self presentViewController:activityVC animated:YES completion:nil];

# UIActivityItemSource methods
- (id)activityViewControllerPlaceholderItem:(UIActivityViewController *)activityViewController {
    return url;
}

- (id)activityViewController:(UIActivityViewController *)activityViewController itemForActivityType:(NSString *)activityType {
    return url;
}

- (NSString*)activityViewController:(UIActivityViewController *)activityViewController subjectForActivityType:(NSString *)activityType {
    return title;
}

- (NSString *)activityViewController:(UIActivityViewController *)activityViewController dataTypeIdentifierForActivityType:(NSString *)activityType {
    return @"com.test.url";
}

- (UIImage *)activityViewController:(UIActivityViewController *)activityViewController thumbnailImageForActivityType:(NSString *)activityType suggestedSize:(CGSize)size {
    return image;
}

I also noticed that this crash is happening on the Flipboard app and it's working fine on the Twitter app.

Did anyone run into this issue? If so can you please let me know what's the issue and how this can be fixed?


答:
Here's how you can chain a List<Filter> and apply them to a List<String> using streams:

```<code>List<String> strings = ...
List<Filter> filters = ...

strings = filters.stream()
        .reduce(s -> s, (a, b) -> s -> b.filter(a.filter(s)))
        .filter(strings);
</code>```

But as I mentioned in the comments, I think the cleanest solution is a simple for loop:

```<code>for (Filter filter : filters) {
    strings = filter.filter(strings);
}
</code>```

Title: Run a list of String through a list of filters

Body:
Here's how you can chain a List<Filter> and apply them to a List<String> using streams:

List<String> strings = ...
List<Filter> filters = ...

strings = filters.stream()
        .reduce(s -> s, (a, b) -> s -> b.filter(a.filter(s)))
        .filter(strings);

But as I mentioned in the comments, I think the cleanest solution is a simple for loop:

for (Filter filter : filters) {
    strings = filter.filter(strings);
}


问:
How to use Lynda.com in android development
my question is so simple:
I already have a lynda.com account, I got it to learn android development but since I started with the existing courses I am facing a problem which is I can't organize things, each course is from 1 hour to 3 hours maximum and they are not organized and not given difficulty level or so. It seems that each course speaks about one specified topic in android. so my question is if any one already have a lynda account and knows how things go in the site please tell me. the reason I want to complete android development learning at lynda in the very high quality the offer in the courses but I just don't know the path</p>

答: I haven't used Lynda.com much, but what I used to learn Android development was Udemy. The courses there are very good quality and offer several resources including a Q&A. I can link you the course that I took, if you'd like.</p>


问:
avro.schema.SchemaParseException: Unknown named schema 'record', known names: ['<namespace_name>.<name>']
I have a nested JSON structure as shown below. When I do avro.schema.Parse using python3 I get an error.

```<code>avro.schema.SchemaParseException: Unknown named schema 'record', known names:[data.info]
</code>```

{"namespace" : "data",
 "type": "record",
 "name": "info",
 "doc": "A  list  of strings.",
 "fields": [
    {"name": "DATE", "type": "string"},
    {"name": "file", "type": "string"},
    {"name": "info", "type": "record", "fields": [
            {"name": "START_DATE", "type": "string"},
            {"name": "END_DATE", "type": "string"},
            {"name": "other", "type": "array", "items":"string"}]}
          ]
        }```

答:
The problem was with the nested avro sctructure,
I could solve this by follwing Avro-nested schemas
Also using avro-json-validator could help to find the problem as soon as we write the .avsc files. A successful conversion to JSON tells that the avro.schema.Parse would work fine.I validated the next further updates I did to the .avsc file using this which worked fine.</p>

ContentLicense: CC BY-SA 4.0

Body:
I have a nested JSON structure as shown below. When I do avro.schema.Parse using python3 I get an error.

avro.schema.SchemaParseException: Unknown named schema 'record', known names:[data.info]

{"namespace" : "data",
 "type": "record",
 "name": "info",
 "doc": "A  list  of strings.",
 "fields": [
    {"name": "DATE", "type": "string"},
    {"name": "file", "type": "string"},
    {"name": "info", "type": "record", "fields": [
            {"name": "START_DATE", "type": "string"},
            {"name": "END_DATE", "type": "string"},
            {"name": "other", "type": "array", "items":"string"}]}
          ]
        }


问:
Angular - How to create a persistent/permanent "Add to Home screen" button in my web app, just like Google Contribute
How to create a persistent/permanent "Add to Home screen" button in my web app, just like Google Contribute? (see image below)

Background: It's an Angular v5 app with PWA service worker and manifest.json all setup. On landing in the app, a banner will pop-up inviting users to Add to Home Screen. It's all working good.

So how to have a button in my web app like Google Contribute (see image below)?

答:
position: sticky ?
add that button outside of your router so it remains there not depending on the view ? not sure exactly what you mean. if you try to describe it a little bit more I could help more.


问:
Convert XML to a data frame
I am looking to transfer data from a .php link into an R data frame, but am having trouble doing so.

Attempts thus far:

```<code>require(XML)
data <- xmlParse("http://www.mahdial-husseini.com/xmlthing.php ")
xml_data <- xmlToList(data)
</code>```

The error I am getting: Error: 1: failed to load HTTP resource

Additionally (and more conceptually), I don't quite understand the nature of the link. Is this XML data in a php file, and if so, when using R to gather data, do I treat it as XML or PHP? Thank you

答:
Or, possibly something readable:

```<code>library(xml2)
library(tidyverse)
</code>```

This will help make better column names:

```<code>mcga <- function(tbl) {
  x <- colnames(tbl)
  x <- tolower(x)
  x <- gsub("[[:punct:][:space:]]+", "_", x)
  x <- gsub("_+", "_", x)
  x <- gsub("(^_|_$)", "", x)
  x <- make.unique(x, sep = "_")
  colnames(tbl) <- x
  tbl
}
</code>```

This gets figured out automagically but it's nice to define it after it figures it out since it help with data consistency:

```<code>cols(
  .default = col_integer(),
  site = col_character(),
  aod_47 = col_double(),
  omi_aot = col_double(),
  omi_no2 = col_double(),
  fit = col_double(),
  lng = col_double(),
  lat = col_double()
) -> xdf_cols
</code>```

Now the work:

```<code>doc <- read_xml("http://www.mahdial-husseini.com/xmlthing.php")

xml_find_all(doc, ".//PPM1_0") %>%
  map_df(~{
    xml_attrs(.x) %>%
      as.list()
  }) %>%
  mcga() %>%
  type_convert(col_types = xdf_cols) -> xdf
</code>```

The type_convert() isn't fully necessary but it — with the column definitions — make for consistency in results.

And, the results:

```<code>xdf
## # A tibble: 8 x 21
##   sample        site month   day  year  hour      jd   doy pm25_hourly aod_47 omi_aot omi_no2      fit   res
##    <int>       <chr> <int> <int> <int> <int>   <int> <int>       <int>  <dbl>   <dbl>   <dbl>    <dbl> <int>
## 1      0      duluth     0     0     0     0       0     0           0  0.000   0.000   0.000  0.00000     0
## 2     19        <NA>    12     0  2004     5       0     0          30  0.000   0.000   0.000  0.00000     0
## 3   4545    Sarasota     4     0  2017     0       0     0           0  0.000   0.000   0.000  0.00000     0
## 4  11111     Atlanta    10     1  2004    13 2453280   275          23  0.379   0.148   0.274 16.01850    NA
## 5  11112  Birmingham    10     2  2008    14 2453281   276           0  0.000   0.000   0.000 19.19440     0
## 6  11113    Savannah    10     3  2004    13 2453282   277          15  0.181   0.133   0.127  9.00433    NA
## 7  11114   Fort Knox     6    20  2017    21       0   301          18  0.000   0.000   0.000  0.00000     0
## 8  63738 Fort Rucker     1     0  2015     0       0     0          40  0.000   0.000   0.000  0.00000     0
## # ... with 7 more variables: lng <dbl>, lat <dbl>, rel_humid <int>, altitude <int>, pressure <int>,
## #   signal_received <int>, temp_c <int>
</code>```

Full structure:

```<code>glimpse(xdf)
## Observations: 8
## Variables: 21
## $ sample          <int> 0, 19, 4545, 11111, 11112, 11113, 11114, 63738
## $ site            <chr> "duluth", NA, "Sarasota", "Atlanta", "Birmingham", "Savan...
## $ month           <int> 0, 12, 4, 10, 10, 10, 6, 1
## $ day             <int> 0, 0, 0, 1, 2, 3, 20, 0
## $ year            <int> 0, 2004, 2017, 2004, 2008, 2004, 2017, 2015
## $ hour            <int> 0, 5, 0, 13, 14, 13, 21, 0
## $ jd              <int> 0, 0, 0, 2453280, 2453281, 2453282, 0, 0
## $ doy             <int> 0, 0, 0, 275, 276, 277, 301, 0
## $ pm25_hourly     <int> 0, 30, 0, 23, 0, 15, 18, 40
## $ aod_47          <dbl> 0.000, 0.000, 0.000, 0.379, 0.000, 0.181, 0.000, 0.000
## $ omi_aot         <dbl> 0.000, 0.000, 0.000, 0.148, 0.000, 0.133, 0.000, 0.000
## $ omi_no2         <dbl> 0.000, 0.000, 0.000, 0.274, 0.000, 0.127, 0.000, 0.000
## $ fit             <dbl> 0.00000, 0.00000, 0.00000, 16.01850, 19.19440, 9.00433, 0...
## $ res             <int> 0, 0, 0, NA, 0, NA, 0, 0
## $ lng             <dbl> 84.1000, 63.6167, -82.5300, -84.7000, -86.8000, -81.1000,...
## $ lat             <dbl> 34.0000, 38.4161, 27.3300, 33.7500, 33.5200, 32.0800, 37....
## $ rel_humid       <int> 0, 0, 0, 0, 0, 0, 0, 0
## $ altitude        <int> 0, 0, 0, 0, 0, 0, 0, 0
## $ pressure        <int> 0, 0, 0, 0, 0, 0, 0, 0
## $ signal_received <int> 0, 0, 0, 0, 0, 0, 0, 0
## $ temp_c          <int> 0, 0, 0, 0, 0, 0, 0, 0
</code>```

Title: Convert XML to a data frame

Body:
I am looking to transfer data from a .php link into an R data frame, but am having trouble doing so.

Attempts thus far:

require(XML)
data <- xmlParse("http://www.mahdial-husseini.com/xmlthing.php ")
xml_data <- xmlToList(data)

The error I am getting: Error: 1: failed to load HTTP resource

Additionally (and more conceptually), I don't quite understand the nature of the link. Is this XML data in a php file, and if so, when using R to gather data, do I treat it as XML or PHP? Thank you

Body:
Or, possibly something readable:

library(xml2)
library(tidyverse)

This will help make better column names:

mcga <- function(tbl) {
  x <- colnames(tbl)
  x <- tolower(x)
  x <- gsub("[[:punct:][:space:]]+", "_", x)
  x <- gsub("_+", "_", x)
  x <- gsub("(^_|_$)", "", x)
  x <- make.unique(x, sep = "_")
  colnames(tbl) <- x
  tbl
}

This gets figured out automagically but it's nice to define it after it figures it out since it help with data consistency:

cols(
  .default = col_integer(),
  site = col_character(),
  aod_47 = col_double(),
  omi_aot = col_double(),
  omi_no2 = col_double(),
  fit = col_double(),
  lng = col_double(),
  lat = col_double()
) -> xdf_cols

Now the work:

doc <- read_xml("http://www.mahdial-husseini.com/xmlthing.php")

xml_find_all(doc, ".//PPM1_0") %>%
  map_df(~{
    xml_attrs(.x) %>%
      as.list()
  }) %>%
  mcga() %>%
  type_convert(col_types = xdf_cols) -> xdf

The type_convert() isn't fully necessary but it — with the column definitions — make for consistency in results.

And, the results:

xdf
## # A tibble: 8 x 21
##   sample        site month   day  year  hour      jd   doy pm25_hourly aod_47 omi_aot omi_no2      fit   res
##    <int>       <chr> <int> <int> <int> <int>   <int> <int>       <int>  <dbl>   <dbl>   <dbl>    <dbl> <int>
## 1      0      duluth     0     0     0     0       0     0           0  0.000   0.000   0.000  0.00000     0
## 2     19        <NA>    12     0  2004     5       0     0          30  0.000   0.000   0.000  0.00000     0
## 3   4545    Sarasota     4     0  2017     0       0     0           0  0.000   0.000   0.000  0.00000     0
## 4  11111     Atlanta    10     1  2004    13 2453280   275          23  0.379   0.148   0.274 16.01850    NA
## 5  11112  Birmingham    10     2  2008    14 2453281   276           0  0.000   0.000   0.000 19.19440     0
## 6  11113    Savannah    10     3  2004    13 2453282   277          15  0.181   0.133   0.127  9.00433    NA
## 7  11114   Fort Knox     6    20  2017    21       0   301          18  0.000   0.000   0.000  0.00000     0
## 8  63738 Fort Rucker     1     0  2015     0       0     0          40  0.000   0.000   0.000  0.00000     0
## # ... with 7 more variables: lng <dbl>, lat <dbl>, rel_humid <int>, altitude <int>, pressure <int>,
## #   signal_received <int>, temp_c <int>

Full structure:

glimpse(xdf)
## Observations: 8
## Variables: 21
## $ sample          <int> 0, 19, 4545, 11111, 11112, 11113, 11114, 63738
## $ site            <chr> "duluth", NA, "Sarasota", "Atlanta", "Birmingham", "Savan...
## $ month           <int> 0, 12, 4, 10, 10, 10, 6, 1
## $ day             <int> 0, 0, 0, 1, 2, 3, 20, 0
## $ year            <int> 0, 2004, 2017, 2004, 2008, 2004, 2017, 2015
## $ hour            <int> 0, 5, 0, 13, 14, 13, 21, 0
## $ jd              <int> 0, 0, 0, 2453280, 2453281, 2453282, 0, 0
## $ doy             <int> 0, 0, 0, 275, 276, 277, 301, 0
## $ pm25_hourly     <int> 0, 30, 0, 23, 0, 15, 18, 40
## $ aod_47          <dbl> 0.000, 0.000, 0.000, 0.379, 0.000, 0.181, 0.000, 0.000
## $ omi_aot         <dbl> 0.000, 0.000, 0.000, 0.148, 0.000, 0.133, 0.000, 0.000
## $ omi_no2         <dbl> 0.000, 0.000, 0.000, 0.274, 0.000, 0.127, 0.000, 0.000
## $ fit             <dbl> 0.00000, 0.00000, 0.00000, 16.01850, 19.19440, 9.00433, 0...
## $ res             <int> 0, 0, 0, NA, 0, NA, 0, 0
## $ lng             <dbl> 84.1000, 63.6167, -82.5300, -84.7000, -86.8000, -81.1000,...
## $ lat             <dbl> 34.0000, 38.4161, 27.3300, 33.7500, 33.5200, 32.0800, 37....
## $ rel_humid       <int> 0, 0, 0, 0, 0, 0, 0, 0
## $ altitude        <int> 0, 0, 0, 0, 0, 0, 0, 0
## $ pressure        <int> 0, 0, 0, 0, 0, 0, 0, 0
## $ signal_received <int> 0, 0, 0, 0, 0, 0, 0, 0
## $ temp_c          <int> 0, 0, 0, 0, 0, 0, 0, 0


问:
Find and extract a number from a string
I have a requirement to find and extract a number contained within a string.

For example, from these strings:

```<code>string test = "1 test"
string test1 = " 1 test"
string test2 = "test 99"
</code>```

How can I do this?

答:
use regular expression ...</p>

```<code>Regex re = new Regex(@"\d+");
Match m = re.Match("test 66");

if (m.Success)
{
    Console.WriteLine(string.Format("RegEx found " + m.Value + " at position " + m.Index.ToString()));
}
else
{
    Console.WriteLine("You didn't enter a string containing a number!");
}
</code>```

Title: Find and extract a number from a string

Body:
I have a requirement to find and extract a number contained within a string.

For example, from these strings:

string test = "1 test"
string test1 = " 1 test"
string test2 = "test 99"

How can I do this?

Body:
use regular expression ...

Regex re = new Regex(@"\d+");
Match m = re.Match("test 66");

if (m.Success)
{
    Console.WriteLine(string.Format("RegEx found " + m.Value + " at position " + m.Index.ToString()));
}
else
{
    Console.WriteLine("You didn't enter a string containing a number!");
}