问:
border-radius circle isn't sliding to the middle of the screen
I am unable to get the top circle to move to the middle, the bottom 3 circles are fine, just needed to adjust the text and the placement of the icons centred in the circles. And at the same time, it would adjust to any screen size from tablet/mobile/laptop, I've been trying to edit it in the navigation/container with top/right % but it won't do a thing, How can I resolve this?

.container1 {
    max-width: 1000px;
    width: 100%;

}
.circle1 p {
    font-weight: bold;
    font-family: 'Lato';font-size: 28px;
}
.circle2 p{
    font-weight: bold;
    font-family: 'Lato';font-size: 28px;
}
.circle3 p {
    font-weight: bold;
    font-family: 'Lato';font-size: 28px;
}
.navigation  {
    position:relative;
    border: 2px solid rgb(211,211,211);
    width: 300px;
    border-radius: 100%;
    height: 300px;
    background: white;
}
.navigation ul {
    margin: 0;
    padding: 0;
    text-align: center;
    list-style-type: none;
}

.navigation li {
    font-weight: 100;
    letter-spacing: 2px;
    font-size: 35px;
    font-family: 'Roboto', sans-serif;
}

.circle1{
    margin: 0 auto;
    position: relative;
    border: 2px solid rgb(211,211,211);
    width: 210px;
    border-radius: 100%;
    height: 200px;
    background:rgb(211,211,211);

}
.circle2{
    margin: 0 auto;
    position: relative;
    border: 2px solid rgb(211,211,211);
    width: 210px;
    border-radius: 100%;
    height: 200px;
    background:rgb(211,211,211);
}

.circle3{
    margin: 0 auto;
    position: relative;
    border: 2px solid rgb(211,211,211);
    width: 210px;
    border-radius: 100%;
    height: 200px;
    background:rgb(211,211,211);
}

.border-circle li{
    list-style-type: none;
    text-decoration: none;
}
.border-circle{
    min-width: 1349px;
    width: 100%;
    top: 70%;
    display: flex;
}

.fa-10x{
    opacity: 0.3;
    font-size:7em !important;
    position: relative;
    text-decoration: none;
    color: inherit;
}

.fa-9x{
    position: relative;
    font-size:7em !important;
    opacity: 0.3;
    color: inherit;
    text-decoration: none;
}

.fa-8x{
    position: relative;
    font-size:7em !important;
    transform: translate(10rem, 10rem);
    opacity: 0.3;
    color: inherit;
    text-decoration: none;
}

a {
    color: inherit;
}

.circle {
  display: flex;
  justify-content: center;
  align-items: center;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><!DOCTYPE html>
<html>
    <jsp:include page="../head.html" />

     <body style="height: 130vh;">

        <!-- navigation bar -->
        <div class="container1">
            <nav class="navigation">
                <ul>
                    <li style="font-size:80px">Circle</li>
                    <li>in</li>
                </ul>
            </nav>
        </div>

        <div class="border-circle">
            <div class="circle1 circle">
                 <li><span class="fa fa-gamepad fa-9x"></span></li>
                <p> Circle1</p>
            </div>

            <div class="circle2 circle">
                 <li><span class= " fa fa-thumbs-up fa-10x"></span></li>
                <p> Circle2 </p>
            </div>

            <div class="circle3 circle">
                <li><span class="fa fa-gift fa-8x"></span></li>
                <p> Circle3 </p>
            </div>

        </div>

        <script src="https://code.jquery.com/jquery-3.4.1.slim.min.js" integrity="sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n" crossorigin="anonymous"></script>
        <script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
        <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js" integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" crossorigin="anonymous"></script>

    </body>
</html></code>```

答:
Try this solution.

key is:

```<code>    display: flex;
    justify-content: space-evenly;
    float: left;
    align-items: center;
</code>```

.container1 {
    max-width: 1000px;
    width: 100%;
    display: flex;
    justify-content: space-evenly;
    float: left;
    align-items: center;
}

.circle1 p {
    font-weight: bold;
    font-family: 'Lato';font-size: 28px;
}
.circle2 p{
    font-weight: bold;
    font-family: 'Lato';font-size: 28px;
}
.circle3 p {
    font-weight: bold;
    font-family: 'Lato';font-size: 28px;
}
.navigation  {
    position:relative;
    border: 2px solid rgb(211,211,211);
    width: 300px;
    border-radius: 100%;
    height: 300px;
    background: white;
    line-height: 300px;
}
.navigation ul {
    margin: 0;
    padding: 0;
    text-align: center;
    list-style-type: none;
}

.navigation li {
    font-weight: 100;
    letter-spacing: 2px;
    font-size: 35px;
    font-family: 'Roboto', sans-serif;
}

.circle1{
    margin: 0 auto;
    position: relative;
    border: 2px solid rgb(211,211,211);
    width: 210px;
    border-radius: 100%;
    height: 200px;
    background:rgb(211,211,211);

}
.circle2{
    margin: 0 auto;
    position: relative;
    border: 2px solid rgb(211,211,211);
    width: 210px;
    border-radius: 100%;
    height: 200px;
    background:rgb(211,211,211);
}

.circle3{
    margin: 0 auto;
    position: relative;
    border: 2px solid rgb(211,211,211);
    width: 210px;
    border-radius: 100%;
    height: 200px;
    background:rgb(211,211,211);
}

.border-circle li{
    list-style-type: none;
    text-decoration: none;
}
.border-circle{
    min-width: 1349px;
    width: 100%;
    top: 70%;
    display: flex;
}

.fa-10x{
    opacity: 0.3;
    font-size:7em !important;
    position: relative;
    text-decoration: none;
    color: inherit;
}

.fa-9x{
    position: relative;
    font-size:7em !important;
    opacity: 0.3;
    color: inherit;
    text-decoration: none;
}

.fa-8x{
    position: relative;
    font-size:7em !important;
    transform: translate(10rem, 10rem);
    opacity: 0.3;
    color: inherit;
    text-decoration: none;
}

a {
    color: inherit;
}

.circle {
  display: flex;
  justify-content: center;
  align-items: center;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><!DOCTYPE html>
<html>
    <jsp:include page="../head.html" />

     <body style="height: 130vh;">

        <!-- navigation bar -->
        <div class="container1">

              <nav class="navigation">
                <ul>
                    <li style="font-size:80px">Circle</li>
                    <li>in</li>
                </ul>
              </nav>

        </div>

        <div class="border-circle">
            <div class="circle1 circle">
                 <li><span class="fa fa-gamepad fa-9x"></span></li>
                <p> Circle1</p>
            </div>

            <div class="circle2 circle">
                 <li><span class= " fa fa-thumbs-up fa-10x"></span></li>
                <p> Circle2 </p>
            </div>

            <div class="circle3 circle">
                <li><span class="fa fa-gift fa-8x"></span></li>
                <p> Circle3 </p>
            </div>

        </div>

        <script src="https://code.jquery.com/jquery-3.4.1.slim.min.js" integrity="sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n" crossorigin="anonymous"></script>
        <script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
        <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js" integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" crossorigin="anonymous"></script>

    </body>
</html></code>```

Body:
I am unable to get the top circle to move to the middle, the bottom 3 circles are fine, just needed to adjust the text and the placement of the icons centred in the circles. And at the same time, it would adjust to any screen size from tablet/mobile/laptop, I've been trying to edit it in the navigation/container with top/right % but it won't do a thing, How can I resolve this?

.container1 {
    max-width: 1000px;
    width: 100%;

}
.circle1 p {
    font-weight: bold;
    font-family: 'Lato';font-size: 28px;
}
.circle2 p{
    font-weight: bold;
    font-family: 'Lato';font-size: 28px;
}
.circle3 p {
    font-weight: bold;
    font-family: 'Lato';font-size: 28px;
}
.navigation  {
    position:relative;
    border: 2px solid rgb(211,211,211);
    width: 300px;
    border-radius: 100%;
    height: 300px;
    background: white;
}
.navigation ul {
    margin: 0;
    padding: 0;
    text-align: center;
    list-style-type: none;
}

.navigation li {
    font-weight: 100;
    letter-spacing: 2px;
    font-size: 35px;
    font-family: 'Roboto', sans-serif;
}

.circle1{
    margin: 0 auto;
    position: relative;
    border: 2px solid rgb(211,211,211);
    width: 210px;
    border-radius: 100%;
    height: 200px;
    background:rgb(211,211,211);

}
.circle2{
    margin: 0 auto;
    position: relative;
    border: 2px solid rgb(211,211,211);
    width: 210px;
    border-radius: 100%;
    height: 200px;
    background:rgb(211,211,211);
}

.circle3{
    margin: 0 auto;
    position: relative;
    border: 2px solid rgb(211,211,211);
    width: 210px;
    border-radius: 100%;
    height: 200px;
    background:rgb(211,211,211);
}

.border-circle li{
    list-style-type: none;
    text-decoration: none;
}
.border-circle{
    min-width: 1349px;
    width: 100%;
    top: 70%;
    display: flex;
}

.fa-10x{
    opacity: 0.3;
    font-size:7em !important;
    position: relative;
    text-decoration: none;
    color: inherit;
}

.fa-9x{
    position: relative;
    font-size:7em !important;
    opacity: 0.3;
    color: inherit;
    text-decoration: none;
}

.fa-8x{
    position: relative;
    font-size:7em !important;
    transform: translate(10rem, 10rem);
    opacity: 0.3;
    color: inherit;
    text-decoration: none;
}

a {
    color: inherit;
}

.circle {
  display: flex;
  justify-content: center;
  align-items: center;
}

<!DOCTYPE html>

    <jsp:include page="../head.html" />

Circle

in

 Circle1

 Circle2

 Circle3

Body:
Try this solution.

key is:

    display: flex;
    justify-content: space-evenly;
    float: left;
    align-items: center;

.container1 {
    max-width: 1000px;
    width: 100%;
    display: flex;
    justify-content: space-evenly;
    float: left;
    align-items: center;
}

.circle1 p {
    font-weight: bold;
    font-family: 'Lato';font-size: 28px;
}
.circle2 p{
    font-weight: bold;
    font-family: 'Lato';font-size: 28px;
}
.circle3 p {
    font-weight: bold;
    font-family: 'Lato';font-size: 28px;
}
.navigation  {
    position:relative;
    border: 2px solid rgb(211,211,211);
    width: 300px;
    border-radius: 100%;
    height: 300px;
    background: white;
    line-height: 300px;
}
.navigation ul {
    margin: 0;
    padding: 0;
    text-align: center;
    list-style-type: none;
}

.navigation li {
    font-weight: 100;
    letter-spacing: 2px;
    font-size: 35px;
    font-family: 'Roboto', sans-serif;
}

.circle1{
    margin: 0 auto;
    position: relative;
    border: 2px solid rgb(211,211,211);
    width: 210px;
    border-radius: 100%;
    height: 200px;
    background:rgb(211,211,211);

}
.circle2{
    margin: 0 auto;
    position: relative;
    border: 2px solid rgb(211,211,211);
    width: 210px;
    border-radius: 100%;
    height: 200px;
    background:rgb(211,211,211);
}

.circle3{
    margin: 0 auto;
    position: relative;
    border: 2px solid rgb(211,211,211);
    width: 210px;
    border-radius: 100%;
    height: 200px;
    background:rgb(211,211,211);
}

.border-circle li{
    list-style-type: none;
    text-decoration: none;
}
.border-circle{
    min-width: 1349px;
    width: 100%;
    top: 70%;
    display: flex;
}

.fa-10x{
    opacity: 0.3;
    font-size:7em !important;
    position: relative;
    text-decoration: none;
    color: inherit;
}

.fa-9x{
    position: relative;
    font-size:7em !important;
    opacity: 0.3;
    color: inherit;
    text-decoration: none;
}

.fa-8x{
    position: relative;
    font-size:7em !important;
    transform: translate(10rem, 10rem);
    opacity: 0.3;
    color: inherit;
    text-decoration: none;
}

a {
    color: inherit;
}

.circle {
  display: flex;
  justify-content: center;
  align-items: center;
}

<!DOCTYPE html>
<html>
    <jsp:include page="../head.html" />

     <body style="height: 130vh;">

        <!-- navigation bar -->
        <div class="container1">

              <nav class="navigation">
                <ul>
                    <li style="font-size:80px">Circle</li>
                    <li>in</li>
                </ul>
              </nav>

        </div>

        <div class="border-circle">
            <div class="circle1 circle">
                <a href="#"> <li><span class="fa fa-gamepad fa-9x"></span></li> </a>
                <p> Circle1</p>
            </div>

            <div class="circle2 circle">
                <a href="#"> <li><span class= " fa fa-thumbs-up fa-10x"></span></li></a>
                <p> Circle2 </p>
            </div>

            <div class="circle3 circle">
                <a href="#"><li><span class="fa fa-gift fa-8x"></span></li></a>
                <p> Circle3 </p>
            </div>

        </div>

        <script src="https://code.jquery.com/jquery-3.4.1.slim.min.js" integrity="sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n" crossorigin="anonymous"></script>
        <script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
        <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js" integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" crossorigin="anonymous"></script>

    </body>
</html>


来源: stackexchange

问:
VUEX: Unexpected token, expected "," (axios)
I'm calling an weather API to display the weather data of user's current location using axios. But it's seems like there has a syntax error, but I coudn't find out where I coded wrong. Please help me.</p>

```<code>actions:{
         currentCity({commit}) {
            if (navigator.geolocation) {
                navigator.geolocation.getCurrentPosition(position => {
                axios
                .get(`${this.url_base}weather?&lat=${position.coords.latitude}&lon=${position.coords.longitude}&units=metric&APPID=${this.api_key}`)
                .then(res=>res.data)
                .then(weather=>{
                    commit('currentCity',weather)
                })
    }}}
},
</code>```

答:
use your IDE. You clearly don't open and close your braces and parentheses in the right order. If you click over a closing brace/parentheses in most editors (including even google chrome JS console which is what i used to find this) it will highlight the opening one making it very quick and easy to find your syntax errors...</p>

```<code>actions: {
    currentCity({commit})
    {
        if (navigator.geolocation) {
            navigator.geolocation.getCurrentPosition(position => {
                axios
                    .get(`${this.url_base}weather?&lat=${position.coords.latitude}&lon=${position.coords.longitude}&units=metric&APPID=${this.api_key}`)
                    .then(res => res.data)
                    .then(weather => {
                        commit('currentCity', weather)
                    })
            })
        }
    }
}
</code>```

ContentLicense: CC BY-SA 4.0

Body:
I'm calling an weather API to display the weather data of user's current location using axios. But it's seems like there has a syntax error, but I coudn't find out where I coded wrong. Please help me.

actions:{
         currentCity({commit}) {
            if (navigator.geolocation) {
                navigator.geolocation.getCurrentPosition(position => {
                axios
                .get(`${this.url_base}weather?&lat=${position.coords.latitude}&lon=${position.coords.longitude}&units=metric&APPID=${this.api_key}`)
                .then(res=>res.data)
                .then(weather=>{
                    commit('currentCity',weather)
                })
    }}}
},

Body:
use your IDE. You clearly don't open and close your braces and parentheses in the right order. If you click over a closing brace/parentheses in most editors (including even google chrome JS console which is what i used to find this) it will highlight the opening one making it very quick and easy to find your syntax errors...

actions: {
    currentCity({commit})
    {
        if (navigator.geolocation) {
            navigator.geolocation.getCurrentPosition(position => {
                axios
                    .get(`${this.url_base}weather?&lat=${position.coords.latitude}&lon=${position.coords.longitude}&units=metric&APPID=${this.api_key}`)
                    .then(res => res.data)
                    .then(weather => {
                        commit('currentCity', weather)
                    })
            })
        }
    }
}


问:
log4j with liferay and tomcat
I have a Liferay setup on the Tomcat6. I used Log4j initially for portlets/webapps by adding log4j.properties file in the classes folder and log4j.jar file in the web-inf/lib.

Now we have few quartz jobs which are available in the tomcat/lib folder and I want to enable log4j logging for these jobs as well.

For these quartz jobs I have copied same log4j.properties file in the tomcat/lib.

With the new configuration I keep getting the following error:

```<code>Could not instantiate appender named "JOBS"
A "org.apache.log4j.RollingFileAppender" is not assignable a "org.apache.log4j.Appender" variable.
The class "org.apache.log4j.Appender" was loaded by ...
</code>```

How to remove this error?

Is there any way I can keep a single log4j.properties file which can be used by both shared/lib as well as portlet/webapps.

答:
According to this post the problem is that you have configured your log4j twice.

My solution would be that you create the logger instance like this

private static Logger logger = Logger.getLogger(FooBar.class.getName());

and not to have log4j.properties under any lib or class folder but having it under a folder named resources.

AFAIK this should be a place where the both parts of your application may have access to.

ContentLicense: CC BY-SA 3.0

Title: log4j with liferay and tomcat

Body:
I have a Liferay setup on the Tomcat6. I used Log4j initially for portlets/webapps by adding log4j.properties file in the classes folder and log4j.jar file in the web-inf/lib.

Now we have few quartz jobs which are available in the tomcat/lib folder and I want to enable log4j logging for these jobs as well.

For these quartz jobs I have copied same log4j.properties file in the tomcat/lib.

With the new configuration I keep getting the following error:

Could not instantiate appender named "JOBS"
A "org.apache.log4j.RollingFileAppender" is not assignable a "org.apache.log4j.Appender" variable.
The class "org.apache.log4j.Appender" was loaded by ...

How to remove this error?

Is there any way I can keep a single log4j.properties file which can be used by both shared/lib as well as portlet/webapps.


问:
How to delete two groups of characters with regex?
I have this type of string:
First part: [[archive 726|The Archive]] is a great start

And I want to print:
First part: The Archive is a great start

Here is what I've come to far:

```<code>input.gsub!(/\[\[(.*?)\|/,"")
print input
> "First part: The Archive]] is a great start"
</code>```

How can I also match the ]]?

答:
You may use

```<code>input.gsub!(/\[\[[^\]\[]*\|(.*?)\]\]/, '\1')
</code>```

See the Rubular demo and a Ruby demo.

Details

\[\[  - a [[ substring

[^\]\[]* - any 0 or more chars other than [ and ], as many as possible (if there are multiple | chars inside [[...]], replace * with *? to match as few as possible)

\| - a | char

(.*?) - Group 1 (the group value is referred to with \1 from the replacement pattern, mind the single quotes around \1): any 0 or more chars other than line break chars, as few as possible

\]\] - a ]] substring.

Body:
I have this type of string:
First part: [[archive 726|The Archive]] is a great start

And I want to print:
First part: The Archive is a great start

Here is what I've come to far:

input.gsub!(/\[\[(.*?)\|/,"")
print input
> "First part: The Archive]] is a great start"

How can I also match the ]]?

Body:
You may use

input.gsub!(/\[\[[^\]\[]*\|(.*?)\]\]/, '\1')

See the Rubular demo and a Ruby demo.

Details

\[\[  - a [[ substring

[^\]\[]* - any 0 or more chars other than [ and ], as many as possible (if there are multiple | chars inside [[...]], replace * with *? to match as few as possible)

\| - a | char

(.*?) - Group 1 (the group value is referred to with \1 from the replacement pattern, mind the single quotes around \1): any 0 or more chars other than line break chars, as few as possible

\]\] - a ]] substring.


问:
Is `.` destination for the ADD/COPY dockerfile commands resolved with respect to WORKDIR?
Dockerfile ADD/COPY commands support the destination value to be a relative (to WORKDIR) path or an absolute path. Also, the source value is always the build context.

However, if the destination is specified as ., then is it resolved with respect to the WORKDIR (and does it default to the root (C:) if WORKDIR is not specified)?

答: Yes, your understanding is correct. . will consider the current directory as WORKDIR(if it's specified) and if not, then by default it will consider to /  or root directory as .


问:
Installing oracle database express edition error /u01/app/oracle/product/11.2.0/xe/bin/nls_lang.sh: No such file or directory
I am trying to install the oracle database express from here, but after adding the following lines to the ~/.bashrc:

```<code>export PYTHONPATH EDITOR
export ORACLE_HOME=/u01/app/oracle/product/11.2.0/xe
export ORACLE_SID=XE
export NLS_LANG=`$ORACLE_HOME/bin/nls_lang.sh`
export ORACLE_BASE=/u01/app/oracle
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$LD_LIBRARY_PATH
export PATH=$ORACLE_HOME/bin:$PATH
</code>```

and then running  ~/.profile I get this error:
bash: /u01/app/oracle/product/11.2.0/xe/bin/nls_lang.sh: No such file or directory

答:
Maybe it is because you are installing a newer version of the Oracle Express DB, I would check the version you downloaded, as the tutorial is a bit outdated and then just update everything along the way to reflect the changes.

First, make sure the version you have downloaded is different than the one in the tutorial.

You could also try to see if ORACLE_HOME exists by doing the following:

```<code>cd /u01/app/oracle/product/
</code>```

Then check the version folder to see if it is a different version.

The version available for download right now on Oracle's website is 18.4.0. If the folder is named 18.4.0, then the config should be the following:

```<code>export ORACLE_HOME=/u01/app/oracle/product/18.4.0/xe
export ORACLE_SID=XE
export NLS_LANG=`$ORACLE_HOME/bin/nls_lang.sh`
export ORACLE_BASE=/u01/app/oracle
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$LD_LIBRARY_PATH
export PATH=$ORACLE_HOME/bin:$PATH
</code>```

If that does not work, reinstall the whole thing again changing the version number to match the version you downloaded.

Body:
I am trying to install the oracle database express from here, but after adding the following lines to the ~/.bashrc:

export PYTHONPATH EDITOR
export ORACLE_HOME=/u01/app/oracle/product/11.2.0/xe
export ORACLE_SID=XE
export NLS_LANG=`$ORACLE_HOME/bin/nls_lang.sh`
export ORACLE_BASE=/u01/app/oracle
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$LD_LIBRARY_PATH
export PATH=$ORACLE_HOME/bin:$PATH

and then running  ~/.profile I get this error:
bash: /u01/app/oracle/product/11.2.0/xe/bin/nls_lang.sh: No such file or directory

Body:
Maybe it is because you are installing a newer version of the Oracle Express DB, I would check the version you downloaded, as the tutorial is a bit outdated and then just update everything along the way to reflect the changes.

First, make sure the version you have downloaded is different than the one in the tutorial.

You could also try to see if ORACLE_HOME exists by doing the following:

cd /u01/app/oracle/product/

Then check the version folder to see if it is a different version.

The version available for download right now on Oracle's website is 18.4.0. If the folder is named 18.4.0, then the config should be the following:

export ORACLE_HOME=/u01/app/oracle/product/18.4.0/xe
export ORACLE_SID=XE
export NLS_LANG=`$ORACLE_HOME/bin/nls_lang.sh`
export ORACLE_BASE=/u01/app/oracle
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$LD_LIBRARY_PATH
export PATH=$ORACLE_HOME/bin:$PATH

If that does not work, reinstall the whole thing again changing the version number to match the version you downloaded.


问:
get text from pdf and word with flutter dart
I want get all text from pdf or word file from user and I want do that from flutter application not from apis or backend.
is there any library in dart or flutter do that?</p>

答: I found one plugin maybe it's useful for you.</p>


问:
How to check the Recently executed TWS job stream
How can I check the TWS recently executed job stream

Is there any command to check when was jobstream/job last executed in last 365 days

答:
The best way is to query the JOB_HISTORY_V view on the database.

There are also historical reports from DWC that work with data from that view.


问:
Why is AWS Lambda function returning a different response value from backend?
BackEnd: I am using using AWS Lambda Project .NET Core C#

In the backend, I am returning code something like this:

```<code>var response = new APIGatewayProxyResponse
{
      StatusCode = (int)HttpStatusCode.OK,
      Body = Convert.ToBase64String(fooByteArray),
      IsBase64Encoded = true,
      Headers = new Dictionary<string, string> { { "Content-Type", 'application/pdf' }, { "Access-Control-Allow-Origin", "*" } },
};

return response;
</code>```

When I test in the Mock Lambda Test Tool, the value that it is returning is correct (I can literally copy paste the string in the front end and it will return the correct PDF values).

However, when I deploy this in AWS lambda, the response value changed (is lesser) and has some weird data in the PDF (for example, value is suppose to be $12.00, it now returns $12.000)

I tried everything, such as what I usually use:

```<code>Body = JsonConvert.SerializeObject(fooBytesWrappedInModelClass, new JsonSerializerSettings() { ReferenceLoopHandling = ReferenceLoopHandling.Ignore }),
</code>```

In the end, it always returns that weird $12.000. I don't want a hack fix on the front end to handle the extra zeroes as the PDF is a huge file and there may be other texts missing.

ADDITIONAL NOTES: I tried the following

Direct convert of byte array to Json serialize object

Converting byte
array into hex (lambda still has missing response values)

The problem is on Lambda itself (since the value there is already different) and not in Api Gateway yet

PDF byte array response has a range of 200K to 320K

Amount of response missing from 320K one was 12K characters

答:
Given that the problem surfaced as formatting issues, the root cause is most probably related to the culture within the AWS Lambda instance you are running.

This is a very common culprit when it comes to cloud deployment, as the emulation tools used on your machine use the machine's local culture which often differs from the cloud environment. There may also be cultural disparities between platforms based on their capaibilities, e.g. list separators differ between Windows and Unix for Russian.

One should always diagnose the outputs of their application within the given environment before continuing the investigation of either the environment or the application.

For large sets of data such as byte arrays, comparing individual bytes may be infeasible, but it may be worthwhile to produce hashes and see if those differ between the environments.

Body:
BackEnd: I am using using AWS Lambda Project .NET Core C#

In the backend, I am returning code something like this:

var response = new APIGatewayProxyResponse
{
      StatusCode = (int)HttpStatusCode.OK,
      Body = Convert.ToBase64String(fooByteArray),
      IsBase64Encoded = true,
      Headers = new Dictionary<string, string> { { "Content-Type", 'application/pdf' }, { "Access-Control-Allow-Origin", "*" } },
};

return response;

When I test in the Mock Lambda Test Tool, the value that it is returning is correct (I can literally copy paste the string in the front end and it will return the correct PDF values).

However, when I deploy this in AWS lambda, the response value changed (is lesser) and has some weird data in the PDF (for example, value is suppose to be $12.00, it now returns $12.000)

I tried everything, such as what I usually use:

Body = JsonConvert.SerializeObject(fooBytesWrappedInModelClass, new JsonSerializerSettings() { ReferenceLoopHandling = ReferenceLoopHandling.Ignore }),

In the end, it always returns that weird $12.000. I don't want a hack fix on the front end to handle the extra zeroes as the PDF is a huge file and there may be other texts missing.

ADDITIONAL NOTES: I tried the following

Direct convert of byte array to Json serialize object

Converting byte
array into hex (lambda still has missing response values)

The problem is on Lambda itself (since the value there is already different) and not in Api Gateway yet

PDF byte array response has a range of 200K to 320K

Amount of response missing from 320K one was 12K characters


问:
how to set an action button when creating an alarm clock using tkinter
I am trying my first project in python and wanted to create an alarm clock the ask the user to input the hour, minute and am or pm to set an alarm. I am having issues on how to set an action button so that when the user click on "set alarm", the alarm will be set.</p>

```<code>import datetime

import winsound

import tkinter as tk

filename = "old-fashioned-door-bell.wav"

window = tk.Tk()

window.title("Alarm Clock")

window.geometry("400x400")

window.configure(background="Brown")

def alarm_Clock():

    alarmHour = int(Entry1.get())

    alarmMinute = int(Entry2.get())

    amPm = str(Entry3.get())

    if (amPm == "pm"):

        alarmHour += 12

    while (1 == 1):

        if (alarmHour == datetime.datetime.now().hour and

            alarmMinute == datetime.datetime.now().minute):

            winsound.PlaySound(filename, winsound.SND_LOOP)

            break

def update_btn():

    alarmHour, alarmMinute, amPM = Entry1.get(), Entry2.get(), Entry3.get()

    if alarmHour.isdigit() and alarmMinute.isdigit() and amPM.isdigit():

       return alarm_Clock()

Prompts1 = tk.Label(text="Kels Alarm Clock", font=("Times New Roman", 40), bg="brown", fg="white")

Prompts1.grid(column=0, row=0)

Prompts2 = tk.Label(text="Please enter the time Alarm should ring!", font=("Times New Roman", 15),

bg="brown", fg="white")

Prompts2.grid(column=0, row=1, sticky="W")

Label1 = tk.Label(text="Enter Hour", bg="brown", fg="white", font="Garamond")

Label1.grid(column=0, row=2, sticky="W")

Label2 = tk.Label(text="Enter Minute", bg="brown", fg="white", font="Garamond")

Label2.grid(column=0, row=3, sticky="W")

Label3 = tk.Label(text="Am or Pm", bg="brown", fg="white", font="Garamond")

Label3.grid(column=0, row=4, sticky="W")

Entry1 = tk.Entry()

Entry1.grid(column=1, row=2)

Entry2 = tk.Entry()

Entry2.grid(column=1, row=3)

Entry3 = tk.Entry()

Entry3.grid(column=1, row=4)

Button1 = tk.Button(text="Set Alarm", command="update_btn")

Button1.grid(column=1, row=5)

window.mainloop()
</code>```

答:
Here is the full code</p>

```<code>import datetime
import winsound
import tkinter as tk

filename = "old-fashioned-door-bell.wav"

window = tk.Tk()

window.title("Alarm Clock")
window.geometry("400x400")
window.configure(background="Brown")
def alarm_Clock():
    alarmHour = int(Entry1.get())
    alarmMinute = int(Entry2.get())
    amPm = str(Entry3.get())

    if (amPm == "pm"):
        alarmHour += 12

    while (1 == 1):
        if (alarmHour == datetime.datetime.now().hour and
            alarmMinute == datetime.datetime.now().minute):
            winsound.PlaySound(filename, winsound.SND_LOOP)
            break

def update_btn():
    alarmHour, alarmMinute, amPM = Entry1.get(), Entry2.get(), Entry3.get()
    if alarmHour.isdigit() and alarmMinute.isdigit() and amPM.isdigit():
        return alarm_Clock()

Prompts1 = tk.Label(text="Kels Alarm Clock", font=("Times New Roman", 40), bg="brown",
fg="white")
Prompts1.grid(column=0, row=0)
Prompts2 = tk.Label(text="Please enter the time Alarm should ring!", font=("Times New
Roman", 15), bg="brown", fg="white")
Prompts2.grid(column=0, row=1, sticky="W")

Label1 = tk.Label(text="Enter Hour", bg="brown", fg="white", font="Garamond")
Label1.grid(column=0, row=2, sticky="W")
Label2 = tk.Label(text="Enter Minute", bg="brown", fg="white", font="Garamond")
Label2.grid(column=0, row=3, sticky="W")
Label3 = tk.Label(text="Am or Pm", bg="brown", fg="white", font="Garamond")
Label3.grid(column=0, row=4, sticky="W")

Entry1 = tk.Entry()
Entry1.grid(column=1, row=2)
Entry2 = tk.Entry()
Entry2.grid(column=1, row=3)
Entry3 = tk.Entry()
Entry3.grid(column=1, row=4)

Button1 = tk.Button(text="Set Alarm", command="update_btn")
Button1.grid(column=1, row=5)

window.mainloop()
</code>```

Body:
I am trying my first project in python and wanted to create an alarm clock the ask the user to input the hour, minute and am or pm to set an alarm. I am having issues on how to set an action button so that when the user click on "set alarm", the alarm will be set.

import datetime

import winsound

import tkinter as tk

filename = "old-fashioned-door-bell.wav"

window = tk.Tk()

window.title("Alarm Clock")

window.geometry("400x400")

window.configure(background="Brown")

def alarm_Clock():

    alarmHour = int(Entry1.get())

    alarmMinute = int(Entry2.get())

    amPm = str(Entry3.get())

    if (amPm == "pm"):

        alarmHour += 12

    while (1 == 1):

        if (alarmHour == datetime.datetime.now().hour and

            alarmMinute == datetime.datetime.now().minute):

            winsound.PlaySound(filename, winsound.SND_LOOP)

            break

def update_btn():

    alarmHour, alarmMinute, amPM = Entry1.get(), Entry2.get(), Entry3.get()

    if alarmHour.isdigit() and alarmMinute.isdigit() and amPM.isdigit():

       return alarm_Clock()

Prompts1 = tk.Label(text="Kels Alarm Clock", font=("Times New Roman", 40), bg="brown", fg="white")

Prompts1.grid(column=0, row=0)

Prompts2 = tk.Label(text="Please enter the time Alarm should ring!", font=("Times New Roman", 15),

bg="brown", fg="white")

Prompts2.grid(column=0, row=1, sticky="W")

Label1 = tk.Label(text="Enter Hour", bg="brown", fg="white", font="Garamond")

Label1.grid(column=0, row=2, sticky="W")

Label2 = tk.Label(text="Enter Minute", bg="brown", fg="white", font="Garamond")

Label2.grid(column=0, row=3, sticky="W")

Label3 = tk.Label(text="Am or Pm", bg="brown", fg="white", font="Garamond")

Label3.grid(column=0, row=4, sticky="W")

Entry1 = tk.Entry()

Entry1.grid(column=1, row=2)

Entry2 = tk.Entry()

Entry2.grid(column=1, row=3)

Entry3 = tk.Entry()

Entry3.grid(column=1, row=4)

Button1 = tk.Button(text="Set Alarm", command="update_btn")

Button1.grid(column=1, row=5)

window.mainloop()

Body:
Here is the full code

import datetime
import winsound
import tkinter as tk

filename = "old-fashioned-door-bell.wav"

window = tk.Tk()

window.title("Alarm Clock")
window.geometry("400x400")
window.configure(background="Brown")
def alarm_Clock():
    alarmHour = int(Entry1.get())
    alarmMinute = int(Entry2.get())
    amPm = str(Entry3.get())

    if (amPm == "pm"):
        alarmHour += 12

    while (1 == 1):
        if (alarmHour == datetime.datetime.now().hour and
            alarmMinute == datetime.datetime.now().minute):
            winsound.PlaySound(filename, winsound.SND_LOOP)
            break

def update_btn():
    alarmHour, alarmMinute, amPM = Entry1.get(), Entry2.get(), Entry3.get()
    if alarmHour.isdigit() and alarmMinute.isdigit() and amPM.isdigit():
        return alarm_Clock()

Prompts1 = tk.Label(text="Kels Alarm Clock", font=("Times New Roman", 40), bg="brown",
fg="white")
Prompts1.grid(column=0, row=0)
Prompts2 = tk.Label(text="Please enter the time Alarm should ring!", font=("Times New
Roman", 15), bg="brown", fg="white")
Prompts2.grid(column=0, row=1, sticky="W")

Label1 = tk.Label(text="Enter Hour", bg="brown", fg="white", font="Garamond")
Label1.grid(column=0, row=2, sticky="W")
Label2 = tk.Label(text="Enter Minute", bg="brown", fg="white", font="Garamond")
Label2.grid(column=0, row=3, sticky="W")
Label3 = tk.Label(text="Am or Pm", bg="brown", fg="white", font="Garamond")
Label3.grid(column=0, row=4, sticky="W")

Entry1 = tk.Entry()
Entry1.grid(column=1, row=2)
Entry2 = tk.Entry()
Entry2.grid(column=1, row=3)
Entry3 = tk.Entry()
Entry3.grid(column=1, row=4)

Button1 = tk.Button(text="Set Alarm", command="update_btn")
Button1.grid(column=1, row=5)

window.mainloop()


问:
How to extract correctly cased CharCode from WM_KeyUp or whereever
I'm trying to process WM_KeyUp messages to identify which alphanumeric key (if any) was pressed, in a case-sensitive manner.  In TApplicationEvents we have the OnMessage handler which in my project is assigned to

```<code>procedure TForm1.DoOnAppMessage(var Msg: tagMSG; var Handled: Boolean);
var
  CH : Char;
  [...]
begin
  Inc(MsgCount);

  case Msg.Message of
    WM_KeyUp : begin
      CH := Chr(Msg.WParam);
      // do something with CH
    end;

  end; { case ]
</code>```

That's fine, so far as it goes, except of course that I always get the upper case version of the letter.

So I evidently need to decode the Msg's LParam instead.  Googling around,
I've come across numerous examples of decoding the LParam, but none I can find deals
with what I would have thought would be the "simple" task of getting alphanumeric keys rendered
in the correct case. My q is, please could someone show me how to do that.

Please note:  I know I could get the correctly capitalised letters by handling the WM_Char
message but I can't use that in the real-life situation I'm trying to deal with (which is
actually inside a keyboard hook).

答:
I found a solution to this based on an earlier SO q&a, which involves setting up a low-level keyboard hook.  Initially when I tried this I got the same results as with the code posted in my q, namely that all the returned characters were lower-cased.

Interestingly, the thing which made the difference between no capitalisation and
correct capitalisation - which the code below does - was one of the 4 lines containing calls to GetKeyState, namely KeyState[VK_SHIFT] := GetKeyState(VK_SHIFT).  Without that,
the characters returned were all lower-case (unlike the ones from the code in my q,
which were all upper case);

```<code>type
  TOutProc = procedure(AString : String) of object;
var
  OutProc : TOutProc; // requires assignment to a suitable proc in the host application

type
  PKbdLlHookStruct = ^TKbdLlHookStruct;

  TKbdLlHookStruct = packed record
    vkCode: DWORD;
    scanCode: DWORD;
    flags: DWORD;
    time: DWORD;
    dwExtraInfo: DWORD;
  end;

const
  WH_KEYBOARD_LL   =   13;

var
  FKeyboardLayoutHandle: HKL;
  hhkLowLevelKybd:   HHOOK;

function LowLevelKeyBoardProc(nCode:   Integer;   awParam:   WPARAM;
  alParam:   LPARAM):   LRESULT;   stdcall;
const
  LLKHF_UP             =  $0080;
var
  act:   PKbdllHookStruct;
  CH : Char;
  S : String;
  KeyState : TKeyboardState;
  NewChar: array[0..1] of Char;
begin

  //  adapted from https://stackoverflow.com/q/1590983
  if (nCode = HC_ACTION) then begin
    case awParam  of
      WM_SYSKEYDOWN,
      WM_KEYUP,
      WM_SYSKEYUP: begin
        act := PKbdLlHookStruct(alParam);
        if awParam=WM_KEYUP then begin
          FillChar(NewChar,2,#0);
          GetKeyboardState(KeyState);
          //  Next four lines from https://stackoverflow.com/a/10480563
          KeyState[VK_CAPITAL] := GetKeyState(VK_CAPITAL);
          KeyState[VK_SHIFT] := GetKeyState(VK_SHIFT);
          KeyState[VK_CONTROL] := GetKeyState(VK_CONTROL);
          KeyState[VK_MENU] := GetKeyState(VK_MENU);

          if ToAsciiEx(act^.vkCode, act^.scanCode, KeyState, NewChar, 0, FKeyboardLayoutHandle) = 1 then
          CH := NewChar[0];
          if (CH in [#8, #10, #13]) Or (CH >= ' ') then begin
            S := CH;
            OutProc(S);
            GetClassName(GetForegroundWindow, @ClassBuffer, 100);
          end;
        end;
      end; { case }
    end;  { case }
  end;

  Result := CallNextHookEx(hhkLowLevelKybd, nCode, awParam, alParam);
end;
</code>```

Body:
I'm trying to process WM_KeyUp messages to identify which alphanumeric key (if any) was pressed, in a case-sensitive manner.  In TApplicationEvents we have the OnMessage handler which in my project is assigned to

procedure TForm1.DoOnAppMessage(var Msg: tagMSG; var Handled: Boolean);
var
  CH : Char;
  [...]
begin
  Inc(MsgCount);

  case Msg.Message of
    WM_KeyUp : begin
      CH := Chr(Msg.WParam);
      // do something with CH
    end;

  end; { case ]

That's fine, so far as it goes, except of course that I always get the upper case version of the letter.

So I evidently need to decode the Msg's LParam instead.  Googling around,
I've come across numerous examples of decoding the LParam, but none I can find deals
with what I would have thought would be the "simple" task of getting alphanumeric keys rendered
in the correct case. My q is, please could someone show me how to do that.

Please note:  I know I could get the correctly capitalised letters by handling the WM_Char
message but I can't use that in the real-life situation I'm trying to deal with (which is
actually inside a keyboard hook).

Body:
I found a solution to this based on an earlier SO q&a, which involves setting up a low-level keyboard hook.  Initially when I tried this I got the same results as with the code posted in my q, namely that all the returned characters were lower-cased.

Interestingly, the thing which made the difference between no capitalisation and
correct capitalisation - which the code below does - was one of the 4 lines containing calls to GetKeyState, namely KeyState[VK_SHIFT] := GetKeyState(VK_SHIFT).  Without that,
the characters returned were all lower-case (unlike the ones from the code in my q,
which were all upper case);

type
  TOutProc = procedure(AString : String) of object;
var
  OutProc : TOutProc; // requires assignment to a suitable proc in the host application

type
  PKbdLlHookStruct = ^TKbdLlHookStruct;

  TKbdLlHookStruct = packed record
    vkCode: DWORD;
    scanCode: DWORD;
    flags: DWORD;
    time: DWORD;
    dwExtraInfo: DWORD;
  end;

const
  WH_KEYBOARD_LL   =   13;

var
  FKeyboardLayoutHandle: HKL;
  hhkLowLevelKybd:   HHOOK;

function LowLevelKeyBoardProc(nCode:   Integer;   awParam:   WPARAM;
  alParam:   LPARAM):   LRESULT;   stdcall;
const
  LLKHF_UP             =  $0080;
var
  act:   PKbdllHookStruct;
  CH : Char;
  S : String;
  KeyState : TKeyboardState;
  NewChar: array[0..1] of Char;
begin

  //  adapted from https://stackoverflow.com/q/1590983
  if (nCode = HC_ACTION) then begin
    case awParam  of
      WM_SYSKEYDOWN,
      WM_KEYUP,
      WM_SYSKEYUP: begin
        act := PKbdLlHookStruct(alParam);
        if awParam=WM_KEYUP then begin
          FillChar(NewChar,2,#0);
          GetKeyboardState(KeyState);
          //  Next four lines from https://stackoverflow.com/a/10480563
          KeyState[VK_CAPITAL] := GetKeyState(VK_CAPITAL);
          KeyState[VK_SHIFT] := GetKeyState(VK_SHIFT);
          KeyState[VK_CONTROL] := GetKeyState(VK_CONTROL);
          KeyState[VK_MENU] := GetKeyState(VK_MENU);

          if ToAsciiEx(act^.vkCode, act^.scanCode, KeyState, NewChar, 0, FKeyboardLayoutHandle) = 1 then
          CH := NewChar[0];
          if (CH in [#8, #10, #13]) Or (CH >= ' ') then begin
            S := CH;
            OutProc(S);
            GetClassName(GetForegroundWindow, @ClassBuffer, 100);
          end;
        end;
      end; { case }
    end;  { case }
  end;

  Result := CallNextHookEx(hhkLowLevelKybd, nCode, awParam, alParam);
end;


问:
I just created a Python script. I am trying to run it on my windows computer. It does not work
I created a python script named "script.py":

```<code>variable=raw_input("what is your name: ")

print "welcome",variable
</code>```

Now I am trying to run it on my computer so that it prompts me with "What is your name" and then I can write my name, and then it greets me. How do I do this? I tried compiling the script in cmd using the command python script.py but nothing happens.

Edit:

I also changed the code so that it would be compatible with python 3.8(the version I downloaded)

答:
If you have installed a version of python later than 3 (3.6, 3.7, 3.8), then you have to use these input() and print() functions:

```<code>variable=input("what is your name: ")
print("welcome " + variable)
</code>```

The print function you used is for the previuos Python versions (2.7)

Body:
I created a python script named "script.py":

variable=raw_input("what is your name: ")

print "welcome",variable

Now I am trying to run it on my computer so that it prompts me with "What is your name" and then I can write my name, and then it greets me. How do I do this? I tried compiling the script in cmd using the command python script.py but nothing happens.

Edit:

I also changed the code so that it would be compatible with python 3.8(the version I downloaded)

Body:
If you have installed a version of python later than 3 (3.6, 3.7, 3.8), then you have to use these input() and print() functions:

variable=input("what is your name: ")
print("welcome " + variable)

The print function you used is for the previuos Python versions (2.7)


问:
How to clear ordering when using .first() in django
I have a query in database as follows. Whenever I try to do a .first() on the query, The equivalent query that gets run in the database is as follows

```<code>SELECT *  FROM “user" WHERE UPPER("user"."email"::text) = UPPER(%s) **ORDER BY** "registration_user"."id" ASC LIMIT 1
</code>```

I want to get rid of the order by clause as it interferes with indexes being applied correctly in the db and is also a costly operation. How can I refactor the code below?

```<code>users = User.objects.filter(email__iexact=email)
users.query.**clear_ordering**(True)
if users.count() > 0 :
    return users.first()
</code>```

答:
If no ordering is specified, that would mean that two calls with .first() can return a different element, and non-determinism often results in a lot of problems.

The ORDER BY pk is added by the .first() [Django-doc] call, so it is not part of your query at all. If the queryset has no ordering, then .first() will add an ordering by pk (primary key), as is described in the documentation:

first()

Returns the first object matched by the queryset, or None if there
  is no matching object. If the QuerySet has no ordering defined, then
  the queryset is automatically ordered by the primary key. This can
  affect aggregation results as described in Interaction with default
  ordering or order_by().

If you really do not want an ordering, you can subscript the queryset:

```<code>users = User.objects.filter(email__iexact=email)
if users.exists():
    return users<b>[0]</b></code>```

But that does not look like a very good idea. If no order is specified, then the database can return any record that matches the filtering condition, and it can thus return a different record each query.

Body:
I have a query in database as follows. Whenever I try to do a .first() on the query, The equivalent query that gets run in the database is as follows

SELECT *  FROM “user" WHERE UPPER("user"."email"::text) = UPPER(%s) **ORDER BY** "registration_user"."id" ASC LIMIT 1

I want to get rid of the order by clause as it interferes with indexes being applied correctly in the db and is also a costly operation. How can I refactor the code below?

users = User.objects.filter(email__iexact=email)
users.query.**clear_ordering**(True)
if users.count() > 0 :
    return users.first()

Body:
If no ordering is specified, that would mean that two calls with .first() can return a different element, and non-determinism often results in a lot of problems.

The ORDER BY pk is added by the .first() [Django-doc] call, so it is not part of your query at all. If the queryset has no ordering, then .first() will add an ordering by pk (primary key), as is described in the documentation:

first()

Returns the first object matched by the queryset, or None if there
  is no matching object. If the QuerySet has no ordering defined, then
  the queryset is automatically ordered by the primary key. This can
  affect aggregation results as described in Interaction with default
  ordering or order_by().

If you really do not want an ordering, you can subscript the queryset:

users = User.objects.filter(email__iexact=email)
if users.exists():
    return users[0]

But that does not look like a very good idea. If no order is specified, then the database can return any record that matches the filtering condition, and it can thus return a different record each query.


问:
MongoDB Atlas nested group LDAP
i'm getting a problem with mongodb atlas and nested group on active directory.

At the moment we don't have problem with user into a group:

GROUP -> USER1

If this user, for example, is nested inside other group:

GROUp -> GROUP1 -> USER1

we can connect on mongodb atlas with "user1" but it doesn't show anything, i mean collection or db which "group" has permission.

At the moment ldap query template on our mongo atlas portal is:

{USER}?memberOf?base

i think that it not work recursively and list only member of the group. I found on mongodb doc https://docs.mongodb.com/manual/tutorial/authenticate-nativeldap-activedirectory/#configure-ldap-query-template-for-authorization

this:

```<code>security:
  ldap:
    authz:
      queryTemplate:
        "DC=example,DC=com??sub?(&(objectClass=group)(member:1.2.840.113556.1.4.1941:={USER}))"
</code>```

so i think is possible to build a query that work recursively.

How i have to build the query to change the one of the image attached, to get user inside nested group?

Thanks

答:
You use exactly what they have in their documentation:

```<code>DC=example,DC=com??sub?(&(objectClass=group)(member:1.2.840.113556.1.4.1941:={USER}))
</code>```

Just change DC=example,DC=com to the distinguished name (DN) of your domain.

LDAP queries has several parts, each separated by a ?.

The search root. This is the DN where you want the search to start.

A list of attributes you want the search to return. This is why memberOf is specified in the default search.

The search depth. This can be one of:

Subtree (or "sub"), meaning that you want to search all levels in the directory below the search root.

One level. If the search root is an OU, for example, then using "one level" means you only want to search that one OU and not anything below it.

Base, meaning that the results can only include the search root itself.

The search query.

So in the default query:

```<code>{USER}?memberOf?base
</code>```

The search root is {USER}, the DN of the authenticated user. It returns only the memberOf attribute. And you only want to look at that one object (because of "base"). There is no search query.

In the new query:

```<code>DC=example,DC=com??sub?(&(objectClass=group)(member:1.2.840.113556.1.4.1941:={USER}))
</code>```

The search root is the root of the domain. There is no list of attributes. The search depth is "sub", meaning you want it to search the whole domain. Then the search query tells it to return all groups that have the authenticated user as a direct or nested member.

In both queries, you end up with a list of groups.

Title: MongoDB Atlas nested group LDAP

Body:
i'm getting a problem with mongodb atlas and nested group on active directory.

At the moment we don't have problem with user into a group:

GROUP -> USER1

If this user, for example, is nested inside other group:

GROUp -> GROUP1 -> USER1

we can connect on mongodb atlas with "user1" but it doesn't show anything, i mean collection or db which "group" has permission.

At the moment ldap query template on our mongo atlas portal is:

{USER}?memberOf?base

i think that it not work recursively and list only member of the group. I found on mongodb doc https://docs.mongodb.com/manual/tutorial/authenticate-nativeldap-activedirectory/#configure-ldap-query-template-for-authorization

this:

security:
  ldap:
    authz:
      queryTemplate:
        "DC=example,DC=com??sub?(&(objectClass=group)(member:1.2.840.113556.1.4.1941:={USER}))"

so i think is possible to build a query that work recursively.

How i have to build the query to change the one of the image attached, to get user inside nested group?

Thanks

Body:
You use exactly what they have in their documentation:

DC=example,DC=com??sub?(&(objectClass=group)(member:1.2.840.113556.1.4.1941:={USER}))

Just change DC=example,DC=com to the distinguished name (DN) of your domain.

LDAP queries has several parts, each separated by a ?.

The search root. This is the DN where you want the search to start.

A list of attributes you want the search to return. This is why memberOf is specified in the default search.

The search depth. This can be one of:

Subtree (or "sub"), meaning that you want to search all levels in the directory below the search root.

One level. If the search root is an OU, for example, then using "one level" means you only want to search that one OU and not anything below it.

Base, meaning that the results can only include the search root itself.

The search query.

So in the default query:

{USER}?memberOf?base

The search root is {USER}, the DN of the authenticated user. It returns only the memberOf attribute. And you only want to look at that one object (because of "base"). There is no search query.

In the new query:

DC=example,DC=com??sub?(&(objectClass=group)(member:1.2.840.113556.1.4.1941:={USER}))

The search root is the root of the domain. There is no list of attributes. The search depth is "sub", meaning you want it to search the whole domain. Then the search query tells it to return all groups that have the authenticated user as a direct or nested member.

In both queries, you end up with a list of groups.


问:
Healthvault Java API:Connection timed out: connect
I am trying to test Healthvault Java API with Maven and Jetty.

I am trying examples ui-sdk and ui-jaxb

i can login to the HV but once i login and revert back to my local server my local server display following error

```<code>WicketMessage: Can't instantiate page using constructor public com.microsoft.hsg.applications.weight.AuthenticationPage(org.apache.wicket.PageParameters)
and argument target = "[AppAuthSuccess]" wctoken = "[ASAAAAc0l5GS909AhtAG6llej2Ue+qDSLBETgLGSAuLKoLK+9lWhHNNH4w4W0/5jr78FH1ooBhTT4q8CAC/Ukjl6fO52Kq/ksk0t8RdN5WZQZNZW99THGoJLZntv7TRB6hY774q2hsj5yehy6FYERKDYVaUGpc3R5r+hb7seX8AvmildfDeB4iP4EOu3aEug5JTuWg==]"
actionqs = "[/]"Root cause:java.net.ConnectException: Connection timed out: connect     at java.net.PlainSocketImpl.socketConnect(Native Method)     at
java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:351)     at
java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:213)     at
java.net.PlainSocketImpl.connect(PlainSocketImpl.java:200)     at
java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
</code>```

Any one help me is this because of Proxy or Certificate ?

答: It is because connection is made to host and port, which is not actually listening.</p>

Body:
I am trying to test Healthvault Java API with Maven and Jetty.

I am trying examples ui-sdk and ui-jaxb

i can login to the HV but once i login and revert back to my local server my local server display following error

WicketMessage: Can't instantiate page using constructor public com.microsoft.hsg.applications.weight.AuthenticationPage(org.apache.wicket.PageParameters)
and argument target = "[AppAuthSuccess]" wctoken = "[ASAAAAc0l5GS909AhtAG6llej2Ue+qDSLBETgLGSAuLKoLK+9lWhHNNH4w4W0/5jr78FH1ooBhTT4q8CAC/Ukjl6fO52Kq/ksk0t8RdN5WZQZNZW99THGoJLZntv7TRB6hY774q2hsj5yehy6FYERKDYVaUGpc3R5r+hb7seX8AvmildfDeB4iP4EOu3aEug5JTuWg==]"
actionqs = "[/]"Root cause:java.net.ConnectException: Connection timed out: connect     at java.net.PlainSocketImpl.socketConnect(Native Method)     at
java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:351)     at
java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:213)     at
java.net.PlainSocketImpl.connect(PlainSocketImpl.java:200)     at
java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)

Any one help me is this because of Proxy or Certificate ?


问:
Revealing form fields after checkbox is checked django
Im trying to create a form in which, when a user checks the box, the form shows more values to input.

For example, I have the following

```<code>class ExampleForm(forms.Form):
    example_name = forms.charField(label='Name here')
    custom_message_check = forms.booleanField(required=False, initial=False)
    custom_message = forms.charField(label='Custom message here')
</code>```

Is it there a way to make custom_message field appear only when custom_message_check is activate? I read django docs and didnt find a widget for this, can this be done with django or do I need to create a custom html form?

EDIT: Forgot to clarify that the form rendering is being handled with django {{form.as_p}}

答:
In your template
do try</p>

```<code><p id="custom_message"></p>

var checkbox = document.getElementById("custom_message_check");
var custom_message= document.getElementById("custom_message");

checkbox.addEventListener( 'change', function() {
    if(this.checked) {
        custom_message.innerHtml = "{{ custom_message }}";
    } else {
        custom_message.innerHtml = "";
    }
});
</code>```

Body:
Im trying to create a form in which, when a user checks the box, the form shows more values to input.

For example, I have the following

class ExampleForm(forms.Form):
    example_name = forms.charField(label='Name here')
    custom_message_check = forms.booleanField(required=False, initial=False)
    custom_message = forms.charField(label='Custom message here')

Is it there a way to make custom_message field appear only when custom_message_check is activate? I read django docs and didnt find a widget for this, can this be done with django or do I need to create a custom html form?

EDIT: Forgot to clarify that the form rendering is being handled with django {{form.as_p}}

Body:
In your template
do try

<p id="custom_message"></p>

var checkbox = document.getElementById("custom_message_check");
var custom_message= document.getElementById("custom_message");

checkbox.addEventListener( 'change', function() {
    if(this.checked) {
        custom_message.innerHtml = "{{ custom_message }}";
    } else {
        custom_message.innerHtml = "";
    }
});


问:
How can setConsumerRebalanceListener get the calling ConsumerAwareRebalanceListener instance?
Maybe this is a naive question but it somhow stuck me there for some time. Please bear with me.

I have a class DataConsumer.java that implements ConsumerAwareRebalanceListener:

@Component
public class DataConsumer implements ConsumerAwareRebalanceListener {
    @Override
    public void onPartitionsAssigned(Consumer<?, ?> consumer, Collection<TopicPartition> partitions) {
        // seek offsets based on a given timestamp
    }
    @KafkaListener(topics = "dataTopic", containerFactory = "kafkaListenerContainerFactory")
    receive(ConsumerRecord payload) {}
}
```

<p>So in order for <code>onPartitionsAssigned</code> to work, i need to call <code>setConsumerRebalanceListener</code> in the <code>kafkaListenerContainerFactory</code> method which is defined in another class like this:</p>

<pre class="lang-java prettyprint-override"><code>@Bean
public ConcurrentKafkaListenerContainerFactory<String, ConsumerRecord> kafkaListenerContainerFactory() {
    ConcurrentKafkaListenerContainerFactory<String, ConsumerRecord> factory = new ConcurrentKafkaListenerContainerFactory();
    factory.getContainerProperties().setConsumerRebalanceListener(____________);
    // rest part omitted
}
</code>```

My question is about this ____________ part above. What shall i put there?

In my understanding, method kafkaListenerContainerFactory is called when we initialize the @KafkaListener container in DataConsumer class, so meaning there is already an existing DataConsumer instance to hold the @kafkaLister. How can i pass that already existing DataConsumer instance to setConsumerRebalanceListener function?

All the sample code snippets I can search out are like below:

setConsumerRebalanceListener(new ConsumerRebalanceListener() {
    //override the functions
})
```

But isn't this creating a new instance? If I put new DataConsumer() it will lose some status in the existing instance (e.g. the timestamp to seek offsets) so this can't work.

答:
You can declare DataConsumer as a @Bean (instead of using @Component) then you can inject your bean there.

However, this is the wrong mechanism to use in this case.

Implement ConsumerSeekAware instead - the container will automatically detect that your listener implements that and will call its onPartitionsAssigned.

See Seeking to a Specific Offset in the documentation.

Body:
Maybe this is a naive question but it somhow stuck me there for some time. Please bear with me.

I have a class DataConsumer.java that implements ConsumerAwareRebalanceListener:

@Component
public class DataConsumer implements ConsumerAwareRebalanceListener {
    @Override
    public void onPartitionsAssigned(Consumer<?, ?> consumer, Collection<TopicPartition> partitions) {
        // seek offsets based on a given timestamp
    }
    @KafkaListener(topics = "dataTopic", containerFactory = "kafkaListenerContainerFactory")
    receive(ConsumerRecord payload) {}
}

So in order for onPartitionsAssigned to work, i need to call setConsumerRebalanceListener in the kafkaListenerContainerFactory method which is defined in another class like this:

@Bean
public ConcurrentKafkaListenerContainerFactory<String, ConsumerRecord> kafkaListenerContainerFactory() {
    ConcurrentKafkaListenerContainerFactory<String, ConsumerRecord> factory = new ConcurrentKafkaListenerContainerFactory();
    factory.getContainerProperties().setConsumerRebalanceListener(____________);
    // rest part omitted
}

My question is about this ____________ part above. What shall i put there?

In my understanding, method kafkaListenerContainerFactory is called when we initialize the @KafkaListener container in DataConsumer class, so meaning there is already an existing DataConsumer instance to hold the @kafkaLister. How can i pass that already existing DataConsumer instance to setConsumerRebalanceListener function?

All the sample code snippets I can search out are like below:

setConsumerRebalanceListener(new ConsumerRebalanceListener() {
    //override the functions
})

But isn't this creating a new instance? If I put new DataConsumer() it will lose some status in the existing instance (e.g. the timestamp to seek offsets) so this can't work.


问:
How to use placeholders instead of labels in simple_form?
I want to use placeholders everywhere in my application instead of labels. I am using simple_form and Rails (3.2.14). How can I specify in simple_form config file to use placeholders instead of labels.

In Initializers there is a file simple_form.rb ie

```<code># Use this setup block to configure all options available in SimpleForm.
SimpleForm.setup do |config|
  # Wrappers are used by the form builder to generate a
  # complete input. You can remove any component from the
  # wrapper, change the order or even add your own to the
  # stack. The options given below are used to wrap the
  # whole input.
  config.wrappers :default, :class => :input, :hint_class => :field_with_hint, :error_class => :field_with_errors do |b|
    ## Extensions enabled by default
    # Any of these extensions can be disabled for a
    # given input by passing: `f.input EXTENSION_NAME => false`.
    # You can make any of these extensions optional by
    # renaming `b.use` to `b.optional`.

    # Determines whether to use HTML5 (:email, :url, ...)
    # and required attributes
    b.use :html5

    # Calculates placeholders automatically from I18n
    # You can also pass a string as f.input :placeholder => "Placeholder"
    b.use :placeholder

    ## Optional extensions
    # They are disabled unless you pass `f.input EXTENSION_NAME => :lookup`
    # to the input. If so, they will retrieve the values from the model
    # if any exists. If you want to enable the lookup for any of those
    # extensions by default, you can change `b.optional` to `b.use`.

    # Calculates maxlength from length validations for string inputs
    b.optional :maxlength

    # Calculates pattern from format validations for string inputs
    b.optional :pattern

    # Calculates min and max from length validations for numeric inputs
    b.optional :min_max

    # Calculates readonly automatically from readonly attributes
    b.optional :readonly

    ## Inputs
    b.use :label_input
    b.use :hint,  :wrap_with => { :tag => :span, :class => :hint }
    b.use :error, :wrap_with => { :tag => :span, :class => :error }
  end

  # The default wrapper to be used by the FormBuilder.
  config.default_wrapper = :default

  # Define the way to render check boxes / radio buttons with labels.
  # Defaults to :nested for bootstrap config.
  #   :inline => input + label
  #   :nested => label > input
  config.boolean_style = :nested

  # Default class for buttons
  config.button_class = 'btn'

  # Method used to tidy up errors. Specify any Rails Array method.
  # :first lists the first message for each field.
  # Use :to_sentence to list all errors for each field.
  # config.error_method = :first

  # Default tag used for error notification helper.
  config.error_notification_tag = :div

  # CSS class to add for error notification helper.
  config.error_notification_class = 'alert alert-error'

  # ID to add for error notification helper.
  # config.error_notification_id = nil

  # Series of attempts to detect a default label method for collection.
  # config.collection_label_methods = [ :to_label, :name, :title, :to_s ]

  # Series of attempts to detect a default value method for collection.
  # config.collection_value_methods = [ :id, :to_s ]

  # You can wrap a collection of radio/check boxes in a pre-defined tag, defaulting to none.
  # config.collection_wrapper_tag = nil

  # You can define the class to use on all collection wrappers. Defaulting to none.
  # config.collection_wrapper_class = nil

  # You can wrap each item in a collection of radio/check boxes with a tag,
  # defaulting to :span. Please note that when using :boolean_style = :nested,
  # SimpleForm will force this option to be a label.
  # config.item_wrapper_tag = :span

  # You can define a class to use in all item wrappers. Defaulting to none.
  # config.item_wrapper_class = nil

  # How the label text should be generated altogether with the required text.
  # config.label_text = lambda { |label, required| "#{required} #{label}" }

  # You can define the class to use on all labels. Default is nil.
  config.label_class = 'control-label'

  # You can define the class to use on all forms. Default is simple_form.
  # config.form_class = :simple_form

  # You can define which elements should obtain additional classes
  # config.generate_additional_classes_for = [:wrapper, :label, :input]

  # Whether attributes are required by default (or not). Default is true.
  # config.required_by_default = true

  # Tell browsers whether to use default HTML5 validations (novalidate option).
  # Default is enabled.
  config.browser_validations = false

  # Collection of methods to detect if a file type was given.
  # config.file_methods = [ :mounted_as, :file?, :public_filename ]

  # Custom mappings for input types. This should be a hash containing a regexp
  # to match as key, and the input type that will be used when the field name
  # matches the regexp as value.
  # config.input_mappings = { /count/ => :integer }

  # Custom wrappers for input types. This should be a hash containing an input
  # type as key and the wrapper that will be used for all inputs with specified type.
  # config.wrapper_mappings = { :string => :prepend }

  # Default priority for time_zone inputs.
  # config.time_zone_priority = nil

  # Default priority for country inputs.
  # config.country_priority = nil

  # Default size for text inputs.
  # config.default_input_size = 50

  # When false, do not use translations for labels.
  # config.translate_labels = true

  # Automatically discover new inputs in Rails' autoload path.
  # config.inputs_discovery = true

  # Cache SimpleForm inputs discovery
  # config.cache_discovery = !Rails.env.development?
end
</code>```

答:
Using placeholders instead of labels is bad practice, because it reduces the accessibility of the form to users of assistive technologies.

This doesn't mean that you can't achieve the visual effect that you're looking for: you can use the default behaviour of simple_form to create labels, and then style them with CSS to look like placeholders. Libraries like SkyLabels.js help create this visual effect without reducing accessibility.

As a general rule, pick HTML elements and attributes for their semantics rather than their default appearance.

Body:
I want to use placeholders everywhere in my application instead of labels. I am using simple_form and Rails (3.2.14). How can I specify in simple_form config file to use placeholders instead of labels.

In Initializers there is a file simple_form.rb ie

# Use this setup block to configure all options available in SimpleForm.
SimpleForm.setup do |config|
  # Wrappers are used by the form builder to generate a
  # complete input. You can remove any component from the
  # wrapper, change the order or even add your own to the
  # stack. The options given below are used to wrap the
  # whole input.
  config.wrappers :default, :class => :input, :hint_class => :field_with_hint, :error_class => :field_with_errors do |b|
    ## Extensions enabled by default
    # Any of these extensions can be disabled for a
    # given input by passing: `f.input EXTENSION_NAME => false`.
    # You can make any of these extensions optional by
    # renaming `b.use` to `b.optional`.

    # Determines whether to use HTML5 (:email, :url, ...)
    # and required attributes
    b.use :html5

    # Calculates placeholders automatically from I18n
    # You can also pass a string as f.input :placeholder => "Placeholder"
    b.use :placeholder

    ## Optional extensions
    # They are disabled unless you pass `f.input EXTENSION_NAME => :lookup`
    # to the input. If so, they will retrieve the values from the model
    # if any exists. If you want to enable the lookup for any of those
    # extensions by default, you can change `b.optional` to `b.use`.

    # Calculates maxlength from length validations for string inputs
    b.optional :maxlength

    # Calculates pattern from format validations for string inputs
    b.optional :pattern

    # Calculates min and max from length validations for numeric inputs
    b.optional :min_max

    # Calculates readonly automatically from readonly attributes
    b.optional :readonly

    ## Inputs
    b.use :label_input
    b.use :hint,  :wrap_with => { :tag => :span, :class => :hint }
    b.use :error, :wrap_with => { :tag => :span, :class => :error }
  end

  # The default wrapper to be used by the FormBuilder.
  config.default_wrapper = :default

  # Define the way to render check boxes / radio buttons with labels.
  # Defaults to :nested for bootstrap config.
  #   :inline => input + label
  #   :nested => label > input
  config.boolean_style = :nested

  # Default class for buttons
  config.button_class = 'btn'

  # Method used to tidy up errors. Specify any Rails Array method.
  # :first lists the first message for each field.
  # Use :to_sentence to list all errors for each field.
  # config.error_method = :first

  # Default tag used for error notification helper.
  config.error_notification_tag = :div

  # CSS class to add for error notification helper.
  config.error_notification_class = 'alert alert-error'

  # ID to add for error notification helper.
  # config.error_notification_id = nil

  # Series of attempts to detect a default label method for collection.
  # config.collection_label_methods = [ :to_label, :name, :title, :to_s ]

  # Series of attempts to detect a default value method for collection.
  # config.collection_value_methods = [ :id, :to_s ]

  # You can wrap a collection of radio/check boxes in a pre-defined tag, defaulting to none.
  # config.collection_wrapper_tag = nil

  # You can define the class to use on all collection wrappers. Defaulting to none.
  # config.collection_wrapper_class = nil

  # You can wrap each item in a collection of radio/check boxes with a tag,
  # defaulting to :span. Please note that when using :boolean_style = :nested,
  # SimpleForm will force this option to be a label.
  # config.item_wrapper_tag = :span

  # You can define a class to use in all item wrappers. Defaulting to none.
  # config.item_wrapper_class = nil

  # How the label text should be generated altogether with the required text.
  # config.label_text = lambda { |label, required| "#{required} #{label}" }

  # You can define the class to use on all labels. Default is nil.
  config.label_class = 'control-label'

  # You can define the class to use on all forms. Default is simple_form.
  # config.form_class = :simple_form

  # You can define which elements should obtain additional classes
  # config.generate_additional_classes_for = [:wrapper, :label, :input]

  # Whether attributes are required by default (or not). Default is true.
  # config.required_by_default = true

  # Tell browsers whether to use default HTML5 validations (novalidate option).
  # Default is enabled.
  config.browser_validations = false

  # Collection of methods to detect if a file type was given.
  # config.file_methods = [ :mounted_as, :file?, :public_filename ]

  # Custom mappings for input types. This should be a hash containing a regexp
  # to match as key, and the input type that will be used when the field name
  # matches the regexp as value.
  # config.input_mappings = { /count/ => :integer }

  # Custom wrappers for input types. This should be a hash containing an input
  # type as key and the wrapper that will be used for all inputs with specified type.
  # config.wrapper_mappings = { :string => :prepend }

  # Default priority for time_zone inputs.
  # config.time_zone_priority = nil

  # Default priority for country inputs.
  # config.country_priority = nil

  # Default size for text inputs.
  # config.default_input_size = 50

  # When false, do not use translations for labels.
  # config.translate_labels = true

  # Automatically discover new inputs in Rails' autoload path.
  # config.inputs_discovery = true

  # Cache SimpleForm inputs discovery
  # config.cache_discovery = !Rails.env.development?
end


问:
Determining if several data frames have the same column names in pandas
I have several df and would like to determine if they all have the same column names. I have seen several examples where this is done with two data frames but wanted some information on how to do this across multiple df-s.

For example if I have a list of df-s

```<code>dataframes = [df_1, df_2, df_3, df_4, df_5_1, df_5_2, df_6_1, df_6_2]
</code>```

I would like to possibly loop through each one to see if they all contain the same column names.

答:
Simply compare the column sets:

```<code>if all([set(dataframes[0].columns) == set(df.columns) for df in dataframes]):
    print('All have the same columns')
else:
    print('Some have different columns')
</code>```

A slightly easier variant of ALollz' neat answer (I would not be surprised though if his is faster).

Body:
I have several df and would like to determine if they all have the same column names. I have seen several examples where this is done with two data frames but wanted some information on how to do this across multiple df-s.

For example if I have a list of df-s

dataframes = [df_1, df_2, df_3, df_4, df_5_1, df_5_2, df_6_1, df_6_2]

I would like to possibly loop through each one to see if they all contain the same column names.

Body:
Simply compare the column sets:

if all([set(dataframes[0].columns) == set(df.columns) for df in dataframes]):
    print('All have the same columns')
else:
    print('Some have different columns')

A slightly easier variant of ALollz' neat answer (I would not be surprised though if his is faster).


问:
AWS adds metadata to file content when using uploadUrl
I'm using the next code to get upload instructuion with uploadUrl:

```<code>public UploadInstruction getUploadUrl() {
    final var objectKey = getObjectKey(generateUniqueFileKey());
    final var url = amazonS3.generatePresignedUrl(s3Properties.getBucket(), objectKey,
            calculateExpirationDate(s3Properties.getDownload().getUrlExpiration()), HttpMethod.PUT);
    return new UploadInstruction(url, getFileKey(objectKey));
}
</code>```

I get the URL via my api and use Postman to send PUT request. But when I'm using this URL to upload a file I found that AWS adds some metadata at the beginning of my file, like "Content-type: Application octets stream....". Is it a bug? How to avoid adding extra info to uploaded files with was upload URL?

UPDATED:
For example, I want to upload simple txt file with the next text:

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

When I uploaded to S3 via uploadUrl, after downloading I get a file with the next content:

```<code>----------------------------174475527638909501568708
Content-Disposition: form-data; name=""; filename="test.txt"
Content-Type: text/plain

test
----------------------------174475527638909501568708--
</code>```

Also, I changed the file name when generating uploadUrl. Also, when I uploaded zip archive I can't unpack it after downloading from s3 bucket. But all works when I uploading files via AWS CLI.

The address in PUT request is uploadUrl. My headers which postman added are next:

答:
I found some information here.
Usually when uploading files used form-data:

```<code>var fd = new FormData();
var file = document.getElementById('file')[0];
fd.append('file',file);
</code>```

It is necessary to use next:

```<code>var upload = document.getElementById('file');
var file = upload.files[0];
</code>```

Full code:

```<code><form method="put" action="" enctype="multipart/form-data" id="myform">

        <div >
            <input type="file" id="file" name="file" />
            <input type="button" class="button" value="Upload" id="but_upload">
        </div>
    </form>
</code>```

Ajax:

```<code>$(document).ready(function(){

    $("#but_upload").click(function(){

        var upload = document.getElementById('file');
var file = upload.files[0];

        $.ajax({
            url: '<uploadURL>',
            type: 'put',
            data: file,
            contentType: false,
            processData: false,
            success: function(response){
                if(response != 0){
                    alert('file uploaded');
                }else{
                    alert('file not uploaded');
                }
            },
        });
    });
});
</code>```

In Postman it is necessary to use binary instead form-data to attach a file:

Body:
I'm using the next code to get upload instructuion with uploadUrl:

public UploadInstruction getUploadUrl() {
    final var objectKey = getObjectKey(generateUniqueFileKey());
    final var url = amazonS3.generatePresignedUrl(s3Properties.getBucket(), objectKey,
            calculateExpirationDate(s3Properties.getDownload().getUrlExpiration()), HttpMethod.PUT);
    return new UploadInstruction(url, getFileKey(objectKey));
}

I get the URL via my api and use Postman to send PUT request. But when I'm using this URL to upload a file I found that AWS adds some metadata at the beginning of my file, like "Content-type: Application octets stream....". Is it a bug? How to avoid adding extra info to uploaded files with was upload URL?

UPDATED:
For example, I want to upload simple txt file with the next text:

test

When I uploaded to S3 via uploadUrl, after downloading I get a file with the next content:

----------------------------174475527638909501568708
Content-Disposition: form-data; name=""; filename="test.txt"
Content-Type: text/plain

test
----------------------------174475527638909501568708--

Also, I changed the file name when generating uploadUrl. Also, when I uploaded zip archive I can't unpack it after downloading from s3 bucket. But all works when I uploading files via AWS CLI.

The address in PUT request is uploadUrl. My headers which postman added are next:

Body:
I found some information here.
Usually when uploading files used form-data:

var fd = new FormData();
var file = document.getElementById('file')[0];
fd.append('file',file);

It is necessary to use next:

var upload = document.getElementById('file');
var file = upload.files[0];

Full code:

<form method="put" action="" enctype="multipart/form-data" id="myform">

        <div >
            <input type="file" id="file" name="file" />
            <input type="button" class="button" value="Upload" id="but_upload">
        </div>
    </form>

Ajax:

$(document).ready(function(){

    $("#but_upload").click(function(){

        var upload = document.getElementById('file');
var file = upload.files[0];

        $.ajax({
            url: '<uploadURL>',
            type: 'put',
            data: file,
            contentType: false,
            processData: false,
            success: function(response){
                if(response != 0){
                    alert('file uploaded');
                }else{
                    alert('file not uploaded');
                }
            },
        });
    });
});

In Postman it is necessary to use binary instead form-data to attach a file:


问:
C# IE11 selenium webdriver, No new window handles with new tab
Selenium Webdriver for Internet Explorer 11 is not creating a new window handle when my app opens a new tab.

The problem is similar to this , which was a problem with the window handles disappearing in a fraction of a second, but in my case a new window handle isn't even created in the first place.

I used the test code from that link to check for disappearing window handles, but it never created another window handle when a new tab was opened, so the test only displayed the first console output and never the second part.

I tried using:

```<code>driver.SwitchTo().Window(driver.WindowHandles.Last());
</code>```

but the Selenium Webdriver focus stays on the first tab, because I believe it isn't creating a new handle for the new tab.

Also, tried this:

```<code>driver.SwitchTo().Window(driver.WindowHandles[1]);
</code>```

and that results in an "out of range" exception and "Index was out of range. Must be non-negative and less than the size of the collection."

If I change the [1] to a [0], then obviously I do not get the exception because the focus is just set to the first tab.

Based on my testing with the test code in the link I provided and my own attempts, I believe that new window handles are not being created.

I tried resetting IE11 and then only changing the settings as described on Selenium's website including adding the registry key, which I used Helium's solution to that found here.

Also, I read some suggestions of adding the websites that I am opening to the Trusted sites list in IE, but still no go.

Any help is appreciated. Thanks.

答:
Hopefully this will help someone going forward...

I have been researching this after having the same issue and whatever I tried it did not resolve it!
In the  regedit I added the 'BF_Cache' -> 'iexplorer.exe', added '2500' set as '3' in the zones 0,2,3,4 (was already present in zone 1) & Set the 'protected mode' to enabled but no luck... My new window would open correctly through Selenium but when debugging I confirmed only one handle was available!

But... After I nearly gave up - I decided to run visual studio as an
  admin. And as if by Magic Selenium picked up that there was more
  than one window handle!

Body:
Selenium Webdriver for Internet Explorer 11 is not creating a new window handle when my app opens a new tab.

The problem is similar to this , which was a problem with the window handles disappearing in a fraction of a second, but in my case a new window handle isn't even created in the first place.

I used the test code from that link to check for disappearing window handles, but it never created another window handle when a new tab was opened, so the test only displayed the first console output and never the second part.

I tried using:

driver.SwitchTo().Window(driver.WindowHandles.Last());

but the Selenium Webdriver focus stays on the first tab, because I believe it isn't creating a new handle for the new tab.

Also, tried this:

driver.SwitchTo().Window(driver.WindowHandles[1]);

and that results in an "out of range" exception and "Index was out of range. Must be non-negative and less than the size of the collection."

If I change the [1] to a [0], then obviously I do not get the exception because the focus is just set to the first tab.

Based on my testing with the test code in the link I provided and my own attempts, I believe that new window handles are not being created.

I tried resetting IE11 and then only changing the settings as described on Selenium's website including adding the registry key, which I used Helium's solution to that found here.

Also, I read some suggestions of adding the websites that I am opening to the Trusted sites list in IE, but still no go.

Any help is appreciated. Thanks.


问:
How to install private github repository via npm in github actions workflow ci
I am trying to install npm dependencies within a github workflow ci by running npm install. However i get the following error:

```<code>npm ERR! Error while executing:
npm ERR! /usr/bin/git ls-remote -h -t ssh://git@github.com/private-org/private-repo.git
npm ERR!
npm ERR! Warning: Permanently added the RSA host key for IP address 'removed' to the list of known hosts.
npm ERR! git@github.com: Permission denied (publickey).
npm ERR! fatal: Could not read from remote repository.
</code>```

ci.yml

```<code>name: CI

on:
  push:
    branches: [master ]

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2
    - name: Use Node.js
      uses: actions/setup-node@v1
      with:
        node-version: '12.x'
    - run: node --version
    - run: npm install
</code>```

package.json

```<code>  ...
  "dependencies": {
    "some-pacakage": "git+ssh://git@github.com/private-org/private-repo.gitt",
  },
  ...
</code>```

This some-package is being installed via github by npm. The repo is within the same organization as which the workflow is running in. To solve this problem locally you setup ssh key on your github account tied to the organization.

But how can i solve this issue so that its able to install that package via github repo within the workfow ci where im not using my personal github account.

答:
The private repository is being installed via ssh. If you set an ssh key in the pipeline it will use that ssh key when attempting to install.

Fortunately there is a github action that allows us to do that https://github.com/webfactory/ssh-agent

Above npm install add the following:

```<code>  - uses: webfactory/ssh-agent@v0.2.0
  with:
    ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
</code>```

Setup / Pre-requisites

https://github.com/webfactory/ssh-agent#usage

Create an SSH key with sufficient access privileges. For security reasons, don't use your personal SSH key but set up a dedicated one
  for use in GitHub Actions. See below for a few hints if you are unsure
  about this step.

Make sure you don't have a passphrase set on the private key.

In your repository, go to the Settings > Secrets menu and create a new secret. In this example, we'll call it SSH_PRIVATE_KEY. Put the
  contents of the private SSH key file into the contents field. This key
  should start with -----BEGIN ... PRIVATE KEY-----, consist of many
  lines and ends with -----END ... PRIVATE KEY-----.

Body:
I am trying to install npm dependencies within a github workflow ci by running npm install. However i get the following error:

npm ERR! Error while executing:
npm ERR! /usr/bin/git ls-remote -h -t ssh://git@github.com/private-org/private-repo.git
npm ERR!
npm ERR! Warning: Permanently added the RSA host key for IP address 'removed' to the list of known hosts.
npm ERR! git@github.com: Permission denied (publickey).
npm ERR! fatal: Could not read from remote repository.

ci.yml

name: CI

on:
  push:
    branches: [master ]

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2
    - name: Use Node.js
      uses: actions/setup-node@v1
      with:
        node-version: '12.x'
    - run: node --version
    - run: npm install

package.json

  ...
  "dependencies": {
    "some-pacakage": "git+ssh://git@github.com/private-org/private-repo.gitt",
  },
  ...

This some-package is being installed via github by npm. The repo is within the same organization as which the workflow is running in. To solve this problem locally you setup ssh key on your github account tied to the organization.

But how can i solve this issue so that its able to install that package via github repo within the workfow ci where im not using my personal github account.

Body:
The private repository is being installed via ssh. If you set an ssh key in the pipeline it will use that ssh key when attempting to install.

Fortunately there is a github action that allows us to do that https://github.com/webfactory/ssh-agent

Above npm install add the following:

  - uses: webfactory/ssh-agent@v0.2.0
  with:
    ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}

Setup / Pre-requisites

https://github.com/webfactory/ssh-agent#usage

Create an SSH key with sufficient access privileges. For security reasons, don't use your personal SSH key but set up a dedicated one
  for use in GitHub Actions. See below for a few hints if you are unsure
  about this step.

Make sure you don't have a passphrase set on the private key.

In your repository, go to the Settings > Secrets menu and create a new secret. In this example, we'll call it SSH_PRIVATE_KEY. Put the
  contents of the private SSH key file into the contents field. This key
  should start with -----BEGIN ... PRIVATE KEY-----, consist of many
  lines and ends with -----END ... PRIVATE KEY-----.


问:
How to get the value of selected checkbox with specific name using jquery
i have this check box with different name but all the name start with checkUser

```<code><input type="checkbox" value="60176694447" name="checkUser52106">
<input type="checkbox" value="60176694448" name="checkUser52107">
<input type="checkbox" value="60176694449" name="checkUser52108">
</code>```

A quick google bring me this function from sitepoint

```<code>$(function(){
$('#btnClick').click(function(){
var val = [];
$(':checkbox:checked').each(function(i){
  val[i] = $(this).val();
});
});
});
</code>```

Right now i want to get all the value of selected checkbox with name start with checkUser. How to achieve this?

答:
Use a CSS3 type selector like this

```<code>$('input[name=~"checkUser"]:checked').each( function(idx) {
    val[idx] = $(this).val();
});
</code>```

Edit: oh, same exact answer as above :P

Body:
i have this check box with different name but all the name start with checkUser

<input type="checkbox" value="60176694447" name="checkUser52106">
<input type="checkbox" value="60176694448" name="checkUser52107">
<input type="checkbox" value="60176694449" name="checkUser52108">

A quick google bring me this function from sitepoint

$(function(){
$('#btnClick').click(function(){
var val = [];
$(':checkbox:checked').each(function(i){
  val[i] = $(this).val();
});
});
});

Right now i want to get all the value of selected checkbox with name start with checkUser. How to achieve this?

Body:
Use a CSS3 type selector like this

$('input[name=~"checkUser"]:checked').each( function(idx) {
    val[idx] = $(this).val();
});

Edit: oh, same exact answer as above :P