问:
Z-index applied to footer doesn't work

.wrap {
  background-color: #393939;
  height: inherit;
}

/*-----------------------header---------------------------------------------------------*/

.header-inner {
  background-color: #393939;
  width: 100%;
  height: 70px;
  /* [disabled]display: flex; */
  position: fixed;
  top: 0;
}

.pclogo {
  display: none;
}

.tabletlogo {
  display: none;
}

.line {
  display: none;
}

a .mobilelogo {
  width: 215px;
  height: auto;
  margin-top: 10px;
  display: block;
  margin-right: auto;
  margin-left: auto;
  cursor: pointer;
}

/*doesn't show the navigation bar*/

.navbar {
  display: none
}

/*---------------------hamburger-----------------------*/

.hamburger {
  display: block;
  position: absolute;
  top: 10px;
  right: 3.3%;
  cursor: pointer;
  float: right;
  z-index: 4/*important!!! humburger menu comes on the top of side menu*/
}

.bar1,
.bar2,
.bar3 {
  width: 26px;
  height: 3px;
  /* Original 5px*/
  margin: 8px 0;
  /* Original 6px*/
  transition: 0.6s;
  background-color: white;
  border-radius: 3px;
}

/* Rotate first bar */

.change .bar1 {
  -webkit-transform: translate(0px, 5.5px) rotate(-45deg);
  /*move →0px ↓5.5px(hight of bar/2+margin/2) and lotate ↺45°*/
  transform: translate(0px, 5.5px) rotate(-45deg);
  background-color: rgba(207, 207, 207, 1.00);
}

/* Fade out the second bar */

/*.change .bar2 {
   opacity: 0;
  }*/

/* Rotate last bar */

.change .bar3 {
  -webkit-transform: translate(0px, -5.5px) rotate(45deg);
  transform: translate(0px, -5.5px) rotate(45deg);
  background-color: rgba(207, 207, 207, 1.00);
}

/*---dropdown menu---*/

.dropdown {
  height: 100%;
  width: 0;
  position: fixed;
  z-index: 3;
  /*important!!! humburger menu comes on the top of side menu*/
  top: 0;
  right: 0;
  background-color: #393939;
  overflow-x: hidden;
  transition: 0.5s;
  padding-top: 60px;
  text-align: center;
}

.dropdown a {
  display: none;
  transition: 0.4s;
}

/*---dropdown menu withdraw---*/

.change.dropdown {
  height: 100%;
  width: 50%;
  position: fixed;
  z-index: 3;
  top: 0;
  right: 0;
  background-color: rgba(69, 69, 69, 0.90);
  /*Color Transparency of side menu*/
  overflow-x: hidden;
  transition: 0.6s;
  padding: 68px 0 0 0;
  /* control the space above "Home"*/
  text-align: center;
}

/*---dropdown menu effect---*/

.change.dropdown a {
  padding: 10px 5px;
  font-family: 'Kozuka Gothic Pr6N';
  font-size: 18px;
  text-decoration: none;
  color: white;
  display: block;
  transition: 0.3s;
  border-bottom: rgba(163, 161, 161, 0.77);
}

.dropdown a::before {
  -webkit-transition-duration: 0.3s;
  /* Safari */
  transition-duration: 0.3s;
  content: attr(data-hover);
  /*The attr() property inserts a specified attribute's value before or after the selected element(s).*/
}

.dropdown a:hover {
  border-left: 2px solid rgba(255, 255, 255, 0.70);
  border-right: 2px solid rgba(255, 255, 255, 0.70);
  -webkit-transform: scale(0.9);
  -moz-transform: scale(0.9);
  transform: scale(0.9);
  color: rgba(255, 255, 255, 0.70);
}

/*---------------------hamburger---------------------------*/

/*---------------------------------------------header----------------------------------------------*/

/*----------------------------------------------Main----------------------------------------------*/

.main-inner {
  min-height: 100%;
  height: auto !important;
  /*Cause footer to stick to bottom in IE 6*/
  height: 100%;
  vertical-align: bottom;
  padding-top: 70px;
  /*-------important!!!!!-------*/
}

.slideimage-container img {
  height: inherit;
  width: 100%;
  /* [disabled]padding-top: 90px; */
  /* [disabled]padding-bottom: 70px; */
  object-fit: cover;
  object-position: center;
  overflow: hidden;
}

/*----------update list-----------*/

.update-container {
  padding: 5px;
  width: 100%;
}

.update-container table {
  margin: 0 auto;
}

.update-container table tr {
  color: white;
  font-size: 10px;
  font-family: 'Kozuka Gothic Pr6N';
  text-align: left;
  font-weight: thin;
  padding: 5px 10px;
  vertical-align: top;
}

/*----------------------------------------------Main----------------------------------------------*/

/*----------------------------------------------Footer----------------------------------------------*/

.footer-inner {
  width: 100%;
  /* [disabled]padding-top: 15px; */
  /*space between Main and Footer*/
  height: 28px;
  bottom: 0;
  position: fixed;
  background-color: #393939;
  z-index: 1;
}

.line-footer {
  display: none;
  /* [disabled]width: 100%; */
  /* [disabled]height: 1px; */
  /* [disabled]border-bottom: 1px solid white; */
  /* [disabled]margin-bottom: 15px; */
  /* [disabled]position: absolute; */
}

.copyright {
  width: 100%;
  float: right;
  font-family: 'Kozuka Gothic Pr6N';
  color: #ffffff;
  font-size: 0.5px;
  bottom: 0px;
  padding: 10px 5px 0 0;
  /* [disabled]margin-right: 5px; */
  text-align: right;
  /* [disabled]position: absolute; */
}

/*----------------------------------------------Footer----------------------------------------------*/```
<pre class="snippet-code-html lang-html prettyprint-override"><code><body oncontextmenu="return false">

  <div class="wrap">
    <!-- to define the maximum width -->

    <!-- Header -->
    <header>
      <div class="container">
        <div class="header-inner">
          <!-- Header Flex (logo and navbar) -->

          <!-- Hamburger -->

          <div class="hamburger" onclick="myFunction(this)">
            <div class="bar1"></div>
            <!-- <div class="bar2"></div> -->
            <div class="bar3"></div>
          </div>

          <div id="myDIV" class="dropdown" role="navigation">
            Home
            News
            Concept
            Profile
            Works
            Contact
          </div>

          <!-- x is used to change hamburger menu, y is used to change side menu width -->
          <script>
            function myFunction(x) {
              x.classList.toggle("change");

              var y = document.getElementById("myDIV");
              y.classList.toggle("change");
            }
          </script>

          <!-- Hamburger -->

          <ul class="navbar" role="navigation">
            <li>Home</li>
            <li>News</li>
            <li>Concept</li>
            <li>Profile</li>
            <li>Works</li>
            <li>Contact</li>
          </ul>

          <div class="line"></div>
        </div>
      </div>

    </header>

    <!-- Main Content -->
    <main>
      <div class="container">
        <div class="main-inner">
        </div>
      </div>

      <div class="container">
        <div class="update-container">
        </div>
      </div>

    </main>
    <!-- End Main Content -->

    <!-- Footer -->
    <footer>
      <div class="container">
        <div class="footer-inner">
          <div class="line-footer"></div>
          <div class="copyright">
            Copyright © 小野寺康都市設計事務所. All rights reserved.
          </div>
        </div>
      </div>
    </footer>
    <!-- End Footer -->
  </div>
</body></code>```

z-index

show the footer on top of main contents under the side menu

```<code>.dropdown `{height: 100%;width: 0;position: fixed;z-index: 3;/*important!!! humburger menu comes on the top of side menu*/top: 0;right: 0;background-color: #393939;overflow-x: hidden;transition: 0.5s;padding-top: 60px;text-align: center;}`

.hamburger `{display: block;position: absolute;top: 10px;right: 3.3%;cursor: pointer;float: right;z-index: 4/*important!!! humburger menu comes on the top of side menu*/}`

.footer-inner `{width: 100%;/* [disabled]padding-top: 15px; *//*space between Main and Footer*/height: 28px;bottom: 0;position: fixed;background-color: #393939;z-index: 1;}`
</code>```

Footer(z-index:1) should be showed under the side menu(z-index:3) and hamburger(z-index:4).

If I changed z-index of footer to -1, it gets the desired result, but then footer comes behind the main contents...

I want to keep footer on top of main contents under the side menu.

答: Try adding z-index:2 to your .header-inner class and see if you get the desired result.

Title: Z-index applied to footer doesn't work

Body:
.wrap {
  background-color: #393939;
  height: inherit;
}

/*-----------------------header---------------------------------------------------------*/

.header-inner {
  background-color: #393939;
  width: 100%;
  height: 70px;
  /* [disabled]display: flex; */
  position: fixed;
  top: 0;
}

.pclogo {
  display: none;
}

.tabletlogo {
  display: none;
}

.line {
  display: none;
}

a .mobilelogo {
  width: 215px;
  height: auto;
  margin-top: 10px;
  display: block;
  margin-right: auto;
  margin-left: auto;
  cursor: pointer;
}

/*doesn't show the navigation bar*/

.navbar {
  display: none
}

/*---------------------hamburger-----------------------*/

.hamburger {
  display: block;
  position: absolute;
  top: 10px;
  right: 3.3%;
  cursor: pointer;
  float: right;
  z-index: 4/*important!!! humburger menu comes on the top of side menu*/
}

.bar1,
.bar2,
.bar3 {
  width: 26px;
  height: 3px;
  /* Original 5px*/
  margin: 8px 0;
  /* Original 6px*/
  transition: 0.6s;
  background-color: white;
  border-radius: 3px;
}

/* Rotate first bar */

.change .bar1 {
  -webkit-transform: translate(0px, 5.5px) rotate(-45deg);
  /*move →0px ↓5.5px(hight of bar/2+margin/2) and lotate ↺45°*/
  transform: translate(0px, 5.5px) rotate(-45deg);
  background-color: rgba(207, 207, 207, 1.00);
}

/* Fade out the second bar */

/*.change .bar2 {
   opacity: 0;
  }*/

/* Rotate last bar */

.change .bar3 {
  -webkit-transform: translate(0px, -5.5px) rotate(45deg);
  transform: translate(0px, -5.5px) rotate(45deg);
  background-color: rgba(207, 207, 207, 1.00);
}

/*---dropdown menu---*/

.dropdown {
  height: 100%;
  width: 0;
  position: fixed;
  z-index: 3;
  /*important!!! humburger menu comes on the top of side menu*/
  top: 0;
  right: 0;
  background-color: #393939;
  overflow-x: hidden;
  transition: 0.5s;
  padding-top: 60px;
  text-align: center;
}

.dropdown a {
  display: none;
  transition: 0.4s;
}

/*---dropdown menu withdraw---*/

.change.dropdown {
  height: 100%;
  width: 50%;
  position: fixed;
  z-index: 3;
  top: 0;
  right: 0;
  background-color: rgba(69, 69, 69, 0.90);
  /*Color Transparency of side menu*/
  overflow-x: hidden;
  transition: 0.6s;
  padding: 68px 0 0 0;
  /* control the space above "Home"*/
  text-align: center;
}

/*---dropdown menu effect---*/

.change.dropdown a {
  padding: 10px 5px;
  font-family: 'Kozuka Gothic Pr6N';
  font-size: 18px;
  text-decoration: none;
  color: white;
  display: block;
  transition: 0.3s;
  border-bottom: rgba(163, 161, 161, 0.77);
}

.dropdown a::before {
  -webkit-transition-duration: 0.3s;
  /* Safari */
  transition-duration: 0.3s;
  content: attr(data-hover);
  /*The attr() property inserts a specified attribute's value before or after the selected element(s).*/
}

.dropdown a:hover {
  border-left: 2px solid rgba(255, 255, 255, 0.70);
  border-right: 2px solid rgba(255, 255, 255, 0.70);
  -webkit-transform: scale(0.9);
  -moz-transform: scale(0.9);
  transform: scale(0.9);
  color: rgba(255, 255, 255, 0.70);
}

/*---------------------hamburger---------------------------*/

/*---------------------------------------------header----------------------------------------------*/

/*----------------------------------------------Main----------------------------------------------*/

.main-inner {
  min-height: 100%;
  height: auto !important;
  /*Cause footer to stick to bottom in IE 6*/
  height: 100%;
  vertical-align: bottom;
  padding-top: 70px;
  /*-------important!!!!!-------*/
}

.slideimage-container img {
  height: inherit;
  width: 100%;
  /* [disabled]padding-top: 90px; */
  /* [disabled]padding-bottom: 70px; */
  object-fit: cover;
  object-position: center;
  overflow: hidden;
}

/*----------update list-----------*/

.update-container {
  padding: 5px;
  width: 100%;
}

.update-container table {
  margin: 0 auto;
}

.update-container table tr {
  color: white;
  font-size: 10px;
  font-family: 'Kozuka Gothic Pr6N';
  text-align: left;
  font-weight: thin;
  padding: 5px 10px;
  vertical-align: top;
}

/*----------------------------------------------Main----------------------------------------------*/

/*----------------------------------------------Footer----------------------------------------------*/

.footer-inner {
  width: 100%;
  /* [disabled]padding-top: 15px; */
  /*space between Main and Footer*/
  height: 28px;
  bottom: 0;
  position: fixed;
  background-color: #393939;
  z-index: 1;
}

.line-footer {
  display: none;
  /* [disabled]width: 100%; */
  /* [disabled]height: 1px; */
  /* [disabled]border-bottom: 1px solid white; */
  /* [disabled]margin-bottom: 15px; */
  /* [disabled]position: absolute; */
}

.copyright {
  width: 100%;
  float: right;
  font-family: 'Kozuka Gothic Pr6N';
  color: #ffffff;
  font-size: 0.5px;
  bottom: 0px;
  padding: 10px 5px 0 0;
  /* [disabled]margin-right: 5px; */
  text-align: right;
  /* [disabled]position: absolute; */
}

/*----------------------------------------------Footer----------------------------------------------*/

            Home
            News
            Concept
            Profile
            Works
            Contact

Home

News

Concept

Profile

Works

Contact

            Copyright © 小野寺康都市設計事務所. All rights reserved.

z-index

show the footer on top of main contents under the side menu

.dropdown `{height: 100%;width: 0;position: fixed;z-index: 3;/*important!!! humburger menu comes on the top of side menu*/top: 0;right: 0;background-color: #393939;overflow-x: hidden;transition: 0.5s;padding-top: 60px;text-align: center;}`

.hamburger `{display: block;position: absolute;top: 10px;right: 3.3%;cursor: pointer;float: right;z-index: 4/*important!!! humburger menu comes on the top of side menu*/}`

.footer-inner `{width: 100%;/* [disabled]padding-top: 15px; *//*space between Main and Footer*/height: 28px;bottom: 0;position: fixed;background-color: #393939;z-index: 1;}`

Footer(z-index:1) should be showed under the side menu(z-index:3) and hamburger(z-index:4).

If I changed z-index of footer to -1, it gets the desired result, but then footer comes behind the main contents...

I want to keep footer on top of main contents under the side menu.


来源: stackexchange

问:
Implementing Oauth Server with Authorization Code grant
A bit naive question. I am implementing OAuth server 2.0 with grant type = Authorization code grant. Here's what I have done

1) Created 2 endpoints as /login and /token

2) Created a login page with html as

```<code><html>
     <form action=\"/login\" method=\"post\">

     <div class=\"textcontainer\">
          <label><b>Sign in</b></label>
     </div>
     <div class=\"emailcontainer\">
          <input type=\"text\" placeholder=\"Enter email\"
           name=\"uname\" required>
     </div>

     <div class=\"passwordcontainer\">
          <input type=\"text\" placeholder=\"Enter Password\"
             name=\"psw\" required>
     </div>

     <div class=\"signincontainer\">
           <button type=\"submit\">Sign in</button>
           <input type=\"checkbox\" checked=\"checked\"> Remember me
     </div>

     <div class=\"container\" style=\"background-color:#f1f1f1\">
        <span class=\"psw\">Forgot <a href=\"#\">password?</a></span>
     </div>
   </form>
</code>```

3) The above page will be displayed when client sends

GET
  /login?client_id=CLIENT_ID&redirect_uri=REDIRECT_URI&state=STATE_STRING&scope=REQUESTED_SCOPES&response_type=code

4) I will save the state and redirect URI and the html page is displayed.

5) When user enters email and password and clicks submit button, then a POST will be issued to my server as POST /login and I will fetch the email and password from the request and verify.

Now the problem is I am not able to figure out a way to know if this POST has come from the same client who has called the previous GET.

Is there any way/html trick I can do to resend the state again in my submit button post? Is saving client IP the only way?

I understand the POST /token so that part is clear.

Thanks
Sammy

答:
You can generate a unique identifier (GUID) on the server, before sending the form.
Then put it into the form inside a hidden input :

```<code><form>
    ... your code

    <input type="hidden" value= "<%= <your identifier> %>">
</form>
</code>```

Then this unique value will be returned to you in the POST.

the way you insert the identifier depends on your programming language, I used C# an the above example.

ContentLicense: CC BY-SA 3.0

Body:
A bit naive question. I am implementing OAuth server 2.0 with grant type = Authorization code grant. Here's what I have done

1) Created 2 endpoints as /login and /token

2) Created a login page with html as

     <form action=\"/login\" method=\"post\">

          Sign in

          <input type=\"text\" placeholder=\"Enter email\"
           name=\"uname\" required>

          <input type=\"text\" placeholder=\"Enter Password\"
             name=\"psw\" required>

           <button type=\"submit\">Sign in</button>
           <input type=\"checkbox\" checked=\"checked\"> Remember me

        Forgot password?

   </form>

3) The above page will be displayed when client sends

GET
  /login?client_id=CLIENT_ID&redirect_uri=REDIRECT_URI&state=STATE_STRING&scope=REQUESTED_SCOPES&response_type=code

4) I will save the state and redirect URI and the html page is displayed.

5) When user enters email and password and clicks submit button, then a POST will be issued to my server as POST /login and I will fetch the email and password from the request and verify.

Now the problem is I am not able to figure out a way to know if this POST has come from the same client who has called the previous GET.

Is there any way/html trick I can do to resend the state again in my submit button post? Is saving client IP the only way?

I understand the POST /token so that part is clear.

Thanks
Sammy

Body:
You can generate a unique identifier (GUID) on the server, before sending the form.
Then put it into the form inside a hidden input :

<form>
    ... your code

    <input type="hidden" value= "<%= <your identifier> %>">
</form>

Then this unique value will be returned to you in the POST.

the way you insert the identifier depends on your programming language, I used C# an the above example.


答:
z-index can be tricky because it is relative to the containing z-index. A z-index is calculated for any object that is positioned (meaning relative, absolute, fixed, or sticky).

Because .header-inner is fixed, it has a calculated z-index of 0. Now, because z-index is relative to the containing z-index, your .inner-footer's z-index is relative to z-index 0, so any z-index that is nested in .header-inner will not be able to be placed on top of a block that is on top of .header-inner unless you change .header-inner's z-index to a greater value.

This ultimately means that your .inner-footer's z-index of 1 is competing vs. a z-index of 0, so it will always be placed on top unless you change the competing z-index to a value greater than 1 (change it to 2).

To make it clearer that .hamburger and .change.dropdown have nested z-index values, you can change these to 2 and 1, respectively, and they will have the same effect as they do now.

See the modified code:

.wrap {
  background-color: #393939;
  height: inherit;
}

/*-----------------------header---------------------------------------------------------*/

.header-inner {
  background-color: #393939;
  width: 100%;
  height: 70px;
  /* [disabled]display: flex; */
  position: fixed;
  z-index: 2; /* to place this on top of footer */
  top: 0;
}

.pclogo {
  display: none;
}

.tabletlogo {
  display: none;
}

.line {
  display: none;
}

a .mobilelogo {
  width: 215px;
  height: auto;
  margin-top: 10px;
  display: block;
  margin-right: auto;
  margin-left: auto;
  cursor: pointer;
}

/*doesn't show the navigation bar*/

.navbar {
  display: none
}

/*---------------------hamburger-----------------------*/

.hamburger {
  display: block;
  position: absolute;
  top: 10px;
  right: 3.3%;
  cursor: pointer;
  float: right;
  z-index: 2 /*important!!! humburger menu comes on the top of side menu*/
}

.bar1,
.bar2,
.bar3 {
  width: 26px;
  height: 3px;
  /* Original 5px*/
  margin: 8px 0;
  /* Original 6px*/
  transition: 0.6s;
  background-color: white;
  border-radius: 3px;
}

/* Rotate first bar */

.change .bar1 {
  -webkit-transform: translate(0px, 5.5px) rotate(-45deg);
  /*move →0px ↓5.5px(hight of bar/2+margin/2) and lotate ↺45°*/
  transform: translate(0px, 5.5px) rotate(-45deg);
  background-color: rgba(207, 207, 207, 1.00);
}

/* Fade out the second bar */

/*.change .bar2 {
   opacity: 0;
  }*/

/* Rotate last bar */

.change .bar3 {
  -webkit-transform: translate(0px, -5.5px) rotate(45deg);
  transform: translate(0px, -5.5px) rotate(45deg);
  background-color: rgba(207, 207, 207, 1.00);
}

/*---dropdown menu---*/

.dropdown {
  height: 100%;
  width: 0;
  position: fixed;
  z-index: 3;
  /*important!!! humburger menu comes on the top of side menu*/
  top: 0;
  right: 0;
  background-color: #393939;
  overflow-x: hidden;
  transition: 0.5s;
  padding-top: 60px;
  text-align: center;
}

.dropdown a {
  display: none;
  transition: 0.4s;
}

/*---dropdown menu withdraw---*/

.change.dropdown {
  height: 100%;
  width: 50%;
  position: fixed;
  z-index: 1; /* below hamburger */
  top: 0;
  right: 0;
  background-color: rgba(69, 69, 69, 0.90);
  /*Color Transparency of side menu*/
  overflow-x: hidden;
  transition: 0.6s;
  padding: 68px 0 0 0;
  /* control the space above "Home"*/
  text-align: center;
}

/*---dropdown menu effect---*/

.change.dropdown a {
  padding: 10px 5px;
  font-family: 'Kozuka Gothic Pr6N';
  font-size: 18px;
  text-decoration: none;
  color: white;
  display: block;
  transition: 0.3s;
  border-bottom: rgba(163, 161, 161, 0.77);
}

.dropdown a::before {
  -webkit-transition-duration: 0.3s;
  /* Safari */
  transition-duration: 0.3s;
  content: attr(data-hover);
  /*The attr() property inserts a specified attribute's value before or after the selected element(s).*/
}

.dropdown a:hover {
  border-left: 2px solid rgba(255, 255, 255, 0.70);
  border-right: 2px solid rgba(255, 255, 255, 0.70);
  -webkit-transform: scale(0.9);
  -moz-transform: scale(0.9);
  transform: scale(0.9);
  color: rgba(255, 255, 255, 0.70);
}

/*---------------------hamburger---------------------------*/

/*---------------------------------------------header----------------------------------------------*/

/*----------------------------------------------Main----------------------------------------------*/

.main-inner {
  min-height: 100%;
  height: auto !important;
  /*Cause footer to stick to bottom in IE 6*/
  height: 100%;
  vertical-align: bottom;
  padding-top: 70px;
  /*-------important!!!!!-------*/
}

.slideimage-container img {
  height: inherit;
  width: 100%;
  /* [disabled]padding-top: 90px; */
  /* [disabled]padding-bottom: 70px; */
  object-fit: cover;
  object-position: center;
  overflow: hidden;
}

/*----------update list-----------*/

.update-container {
  padding: 5px;
  width: 100%;
}

.update-container table {
  margin: 0 auto;
}

.update-container table tr {
  color: white;
  font-size: 10px;
  font-family: 'Kozuka Gothic Pr6N';
  text-align: left;
  font-weight: thin;
  padding: 5px 10px;
  vertical-align: top;
}

/*----------------------------------------------Main----------------------------------------------*/

/*----------------------------------------------Footer----------------------------------------------*/

.footer-inner {
  width: 100%;
  /* [disabled]padding-top: 15px; */
  /*space between Main and Footer*/
  height: 28px;
  bottom: 0;
  position: fixed;
  background-color: #393939;
  z-index: 1;
}

.line-footer {
  display: none;
  /* [disabled]width: 100%; */
  /* [disabled]height: 1px; */
  /* [disabled]border-bottom: 1px solid white; */
  /* [disabled]margin-bottom: 15px; */
  /* [disabled]position: absolute; */
}

.copyright {
  width: 100%;
  float: right;
  font-family: 'Kozuka Gothic Pr6N';
  color: #ffffff;
  font-size: 0.5px;
  bottom: 0px;
  padding: 10px 5px 0 0;
  /* [disabled]margin-right: 5px; */
  text-align: right;
  /* [disabled]position: absolute; */
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><body oncontextmenu="return false">

  <div class="wrap">
    <!-- to define the maximum width -->

    <!-- Header -->
    <header>
      <div class="container">
        <div class="header-inner">
          <!-- Header Flex (logo and navbar) -->

          <!-- Hamburger -->

          <div class="hamburger" onclick="myFunction(this)">
            <div class="bar1"></div>
            <!-- <div class="bar2"></div> -->
            <div class="bar3"></div>
          </div>

          <div id="myDIV" class="dropdown" role="navigation">
            Home
            News
            Concept
            Profile
            Works
            Contact
          </div>

          <!-- x is used to change hamburger menu, y is used to change side menu width -->
          <script>
            function myFunction(x) {
              x.classList.toggle("change");

              var y = document.getElementById("myDIV");
              y.classList.toggle("change");
            }
          </script>

          <!-- Hamburger -->

          <ul class="navbar" role="navigation">
            <li>Home</li>
            <li>News</li>
            <li>Concept</li>
            <li>Profile</li>
            <li>Works</li>
            <li>Contact</li>
          </ul>

          <div class="line"></div>
        </div>
      </div>

    </header>

    <!-- Main Content -->
    <main>
      <div class="container">
        <div class="main-inner">
        </div>
      </div>

      <div class="container">
        <div class="update-container">
        </div>
      </div>

    </main>
    <!-- End Main Content -->

    <!-- Footer -->
    <footer>
      <div class="container">
        <div class="footer-inner">
          <div class="line-footer"></div>
          <div class="copyright">
            Copyright © 小野寺康都市設計事務所. All rights reserved.
          </div>
        </div>
      </div>
    </footer>
    <!-- End Footer -->
  </div>
</body></code>```

Title: Z-index applied to footer doesn't work

Body:
z-index can be tricky because it is relative to the containing z-index. A z-index is calculated for any object that is positioned (meaning relative, absolute, fixed, or sticky).

Because .header-inner is fixed, it has a calculated z-index of 0. Now, because z-index is relative to the containing z-index, your .inner-footer's z-index is relative to z-index 0, so any z-index that is nested in .header-inner will not be able to be placed on top of a block that is on top of .header-inner unless you change .header-inner's z-index to a greater value.

This ultimately means that your .inner-footer's z-index of 1 is competing vs. a z-index of 0, so it will always be placed on top unless you change the competing z-index to a value greater than 1 (change it to 2).

To make it clearer that .hamburger and .change.dropdown have nested z-index values, you can change these to 2 and 1, respectively, and they will have the same effect as they do now.

See the modified code:

.wrap {
  background-color: #393939;
  height: inherit;
}

/*-----------------------header---------------------------------------------------------*/

.header-inner {
  background-color: #393939;
  width: 100%;
  height: 70px;
  /* [disabled]display: flex; */
  position: fixed;
  z-index: 2; /* to place this on top of footer */
  top: 0;
}

.pclogo {
  display: none;
}

.tabletlogo {
  display: none;
}

.line {
  display: none;
}

a .mobilelogo {
  width: 215px;
  height: auto;
  margin-top: 10px;
  display: block;
  margin-right: auto;
  margin-left: auto;
  cursor: pointer;
}

/*doesn't show the navigation bar*/

.navbar {
  display: none
}

/*---------------------hamburger-----------------------*/

.hamburger {
  display: block;
  position: absolute;
  top: 10px;
  right: 3.3%;
  cursor: pointer;
  float: right;
  z-index: 2 /*important!!! humburger menu comes on the top of side menu*/
}

.bar1,
.bar2,
.bar3 {
  width: 26px;
  height: 3px;
  /* Original 5px*/
  margin: 8px 0;
  /* Original 6px*/
  transition: 0.6s;
  background-color: white;
  border-radius: 3px;
}

/* Rotate first bar */

.change .bar1 {
  -webkit-transform: translate(0px, 5.5px) rotate(-45deg);
  /*move →0px ↓5.5px(hight of bar/2+margin/2) and lotate ↺45°*/
  transform: translate(0px, 5.5px) rotate(-45deg);
  background-color: rgba(207, 207, 207, 1.00);
}

/* Fade out the second bar */

/*.change .bar2 {
   opacity: 0;
  }*/

/* Rotate last bar */

.change .bar3 {
  -webkit-transform: translate(0px, -5.5px) rotate(45deg);
  transform: translate(0px, -5.5px) rotate(45deg);
  background-color: rgba(207, 207, 207, 1.00);
}

/*---dropdown menu---*/

.dropdown {
  height: 100%;
  width: 0;
  position: fixed;
  z-index: 3;
  /*important!!! humburger menu comes on the top of side menu*/
  top: 0;
  right: 0;
  background-color: #393939;
  overflow-x: hidden;
  transition: 0.5s;
  padding-top: 60px;
  text-align: center;
}

.dropdown a {
  display: none;
  transition: 0.4s;
}

/*---dropdown menu withdraw---*/

.change.dropdown {
  height: 100%;
  width: 50%;
  position: fixed;
  z-index: 1; /* below hamburger */
  top: 0;
  right: 0;
  background-color: rgba(69, 69, 69, 0.90);
  /*Color Transparency of side menu*/
  overflow-x: hidden;
  transition: 0.6s;
  padding: 68px 0 0 0;
  /* control the space above "Home"*/
  text-align: center;
}

/*---dropdown menu effect---*/

.change.dropdown a {
  padding: 10px 5px;
  font-family: 'Kozuka Gothic Pr6N';
  font-size: 18px;
  text-decoration: none;
  color: white;
  display: block;
  transition: 0.3s;
  border-bottom: rgba(163, 161, 161, 0.77);
}

.dropdown a::before {
  -webkit-transition-duration: 0.3s;
  /* Safari */
  transition-duration: 0.3s;
  content: attr(data-hover);
  /*The attr() property inserts a specified attribute's value before or after the selected element(s).*/
}

.dropdown a:hover {
  border-left: 2px solid rgba(255, 255, 255, 0.70);
  border-right: 2px solid rgba(255, 255, 255, 0.70);
  -webkit-transform: scale(0.9);
  -moz-transform: scale(0.9);
  transform: scale(0.9);
  color: rgba(255, 255, 255, 0.70);
}

/*---------------------hamburger---------------------------*/

/*---------------------------------------------header----------------------------------------------*/

/*----------------------------------------------Main----------------------------------------------*/

.main-inner {
  min-height: 100%;
  height: auto !important;
  /*Cause footer to stick to bottom in IE 6*/
  height: 100%;
  vertical-align: bottom;
  padding-top: 70px;
  /*-------important!!!!!-------*/
}

.slideimage-container img {
  height: inherit;
  width: 100%;
  /* [disabled]padding-top: 90px; */
  /* [disabled]padding-bottom: 70px; */
  object-fit: cover;
  object-position: center;
  overflow: hidden;
}

/*----------update list-----------*/

.update-container {
  padding: 5px;
  width: 100%;
}

.update-container table {
  margin: 0 auto;
}

.update-container table tr {
  color: white;
  font-size: 10px;
  font-family: 'Kozuka Gothic Pr6N';
  text-align: left;
  font-weight: thin;
  padding: 5px 10px;
  vertical-align: top;
}

/*----------------------------------------------Main----------------------------------------------*/

/*----------------------------------------------Footer----------------------------------------------*/

.footer-inner {
  width: 100%;
  /* [disabled]padding-top: 15px; */
  /*space between Main and Footer*/
  height: 28px;
  bottom: 0;
  position: fixed;
  background-color: #393939;
  z-index: 1;
}

.line-footer {
  display: none;
  /* [disabled]width: 100%; */
  /* [disabled]height: 1px; */
  /* [disabled]border-bottom: 1px solid white; */
  /* [disabled]margin-bottom: 15px; */
  /* [disabled]position: absolute; */
}

.copyright {
  width: 100%;
  float: right;
  font-family: 'Kozuka Gothic Pr6N';
  color: #ffffff;
  font-size: 0.5px;
  bottom: 0px;
  padding: 10px 5px 0 0;
  /* [disabled]margin-right: 5px; */
  text-align: right;
  /* [disabled]position: absolute; */
}

<body oncontextmenu="return false">

  <div class="wrap">
    <!-- to define the maximum width -->

    <!-- Header -->
    <header>
      <div class="container">
        <div class="header-inner">
          <!-- Header Flex (logo and navbar) -->

          <!-- Hamburger -->

          <div class="hamburger" onclick="myFunction(this)">
            <div class="bar1"></div>
            <!-- <div class="bar2"></div> -->
            <div class="bar3"></div>
          </div>

          <div id="myDIV" class="dropdown" role="navigation">
            <a href="index.html">Home</a>
            <a href="News/index.html">News</a>
            <a href="Concept/index.html">Concept</a>
            <a href="Profile/index.html">Profile</a>
            <a href="Works/index.html">Works</a>
            <a href="Contact/index.html">Contact</a>
          </div>

          <!-- x is used to change hamburger menu, y is used to change side menu width -->
          <script>
            function myFunction(x) {
              x.classList.toggle("change");

              var y = document.getElementById("myDIV");
              y.classList.toggle("change");
            }
          </script>

          <!-- Hamburger -->

          <ul class="navbar" role="navigation">
            <li><a href="index.html">Home</a></li>
            <li><a href="News/index.html">News</a></li>
            <li><a href="Concept/index.html">Concept</a></li>
            <li><a href="Profile/index.html">Profile</a></li>
            <li><a href="Works/index.html">Works</a></li>
            <li><a href="Contact/index.html">Contact</a></li>
          </ul>

          <div class="line"></div>
        </div>
      </div>

    </header>

    <!-- Main Content -->
    <main>
      <div class="container">
        <div class="main-inner">
        </div>
      </div>

      <div class="container">
        <div class="update-container">
        </div>
      </div>

    </main>
    <!-- End Main Content -->

    <!-- Footer -->
    <footer>
      <div class="container">
        <div class="footer-inner">
          <div class="line-footer"></div>
          <div class="copyright">
            Copyright © 小野寺康都市設計事務所. All rights reserved.
          </div>
        </div>
      </div>
    </footer>
    <!-- End Footer -->
  </div>
</body>


问:
grep on unix / linux: how to replace or capture text?
So I'm pretty good with regular expressions, but I'm having some trouble with them on unix. Here are two things I'd love to know how to do:

1) Replace all text except letters, numbers, and underscore

In PHP I'd do this: (works great)```
preg_replace('#[^a-zA-Z0-9_]#','',$text).
```

In bash I tried this (with limited success); seems like it dosen't allow you to use the full set of regex:  ```
text="my #1 example!"
${text/[^a-zA-Z0-9_]/'')
```

I tried it with sed but it still seems to have problems with the full regex set:

```echo "my #1 example!" | sed s/[^a-zA-Z0-9\_]//
```

I'm sure there is a way to do it with grep, too, but it was breaking it into multiple lines when i tried:

```echo abc\!\@\#\$\%\^\&\*\(222 | grep -Eos '[a-zA-Z0-9\_]+'```

And finally I also tried using expr but it seemed like that had really limited support for extended regex...

2) Capture (multiple) parts of text

In PHP I could just do something like this:

```
preg_match('#(word1).*(word2)#',$text,$matches);
```

I'm not sure how that would be possible in *nix...

答:
what do you mean you can't use the regex syntax for bash?

```<code>$ text="my #1 example!"
$ echo ${text//[^a-zA-Z0-9_]/}
my1example
</code>```

you have to use // for more than 1 replacement.

for your 2nd question, with bash 3.2++

```<code>$ [[ $text =~ "(my).*(example)" ]]
$ echo ${BASH_REMATCH[1]}
my
$ echo ${BASH_REMATCH[2]}
example
</code>```

ContentLicense: CC BY-SA 2.5

Body:
So I'm pretty good with regular expressions, but I'm having some trouble with them on unix. Here are two things I'd love to know how to do:

1) Replace all text except letters, numbers, and underscore

In PHP I'd do this: (works great)

preg_replace('#[^a-zA-Z0-9_]#','',$text).

In bash I tried this (with limited success); seems like it dosen't allow you to use the full set of regex:

text="my #1 example!"
${text/[^a-zA-Z0-9_]/'')

I tried it with sed but it still seems to have problems with the full regex set:

echo "my #1 example!" | sed s/[^a-zA-Z0-9\_]//

I'm sure there is a way to do it with grep, too, but it was breaking it into multiple lines when i tried:

echo abc\!\@\#\$\%\^\&\*\(222 | grep -Eos '[a-zA-Z0-9\_]+'

And finally I also tried using expr but it seemed like that had really limited support for extended regex...

2) Capture (multiple) parts of text

In PHP I could just do something like this:

preg_match('#(word1).*(word2)#',$text,$matches);

I'm not sure how that would be possible in *nix...

Body:
what do you mean you can't use the regex syntax for bash?

$ text="my #1 example!"
$ echo ${text//[^a-zA-Z0-9_]/}
my1example

you have to use // for more than 1 replacement.

for your 2nd question, with bash 3.2++

$ [[ $text =~ "(my).*(example)" ]]
$ echo ${BASH_REMATCH[1]}
my
$ echo ${BASH_REMATCH[2]}
example


问:
Making transparent view over semitransparent view (Android)
I want to make one transparent rectangle view over one semitransparent rectangle view.

Desired:

┌──────────────┐

│　　　　　　　　　　│

│　┌─────────┐　│

│　│transparent　 │　│

│　└─────────┘　│

│ 50% transparent　　│

└──────────────┘

Actual:

┌────────────────┐

│　　　　　　　　 　　　│

│　┌───────────┐　│

│　│50% transparent　│　│

│　└───────────┘　│

│ 50% transparent 　　　│

└────────────────┘

Code:

```<code>    <View
    android:id="@+id/overlay_half_shade"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_below="@+id/overlay_textguide"
    android:layout_centerVertical="true"
    android:layout_centerHorizontal="true"
    android:layout_gravity="center"
    android:background="#80FFFFFF" /> // 50% transparent

<View
    android:id="@+id/overlay_transparent"
    android:layout_width="100dp"
    android:layout_height="100dp"
    android:layout_below="@+id/overlay_textguide"
    android:layout_centerVertical="true"
    android:layout_centerHorizontal="true"
    android:layout_gravity="center"
    android:background="@drawable/focus_thumbnail_slide" /> // custom drawable: transparent rectangle with stroke
</code>```

I guess that the whole transparency of the center region considers transparencies of both two overlapped boxes; resulting 50% transparency there. How can I solve this?

答:
Use Hierarchy like this </p>

```<code>  <RelativeLayout>

    <FrameLayout ....
           alpha =0.5/>

     <FrameLayout ....
           gravity=center
           alpha =0.9/>// decide your transperany
  </RelativeLayout>
</code>```

Body:
I want to make one transparent rectangle view over one semitransparent rectangle view.

Desired:

┌──────────────┐

│　　　　　　　　　　│

│　┌─────────┐　│

│　│transparent　 │　│

│　└─────────┘　│

│ 50% transparent　　│

└──────────────┘

Actual:

┌────────────────┐

│　　　　　　　　 　　　│

│　┌───────────┐　│

│　│50% transparent　│　│

│　└───────────┘　│

│ 50% transparent 　　　│

└────────────────┘

Code:

    <View
    android:id="@+id/overlay_half_shade"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_below="@+id/overlay_textguide"
    android:layout_centerVertical="true"
    android:layout_centerHorizontal="true"
    android:layout_gravity="center"
    android:background="#80FFFFFF" /> // 50% transparent

<View
    android:id="@+id/overlay_transparent"
    android:layout_width="100dp"
    android:layout_height="100dp"
    android:layout_below="@+id/overlay_textguide"
    android:layout_centerVertical="true"
    android:layout_centerHorizontal="true"
    android:layout_gravity="center"
    android:background="@drawable/focus_thumbnail_slide" /> // custom drawable: transparent rectangle with stroke

I guess that the whole transparency of the center region considers transparencies of both two overlapped boxes; resulting 50% transparency there. How can I solve this?

Body:
Use Hierarchy like this

  <RelativeLayout>

    <FrameLayout ....
           alpha =0.5/>

     <FrameLayout ....
           gravity=center
           alpha =0.9/>// decide your transperany
  </RelativeLayout>


问:
How can I set a thread's CPU affinity in Qt5?
Working with threads in Qt5, how can I set a single thread's CPU affinity?

I want to specify a mask of available CPU cores that the thread may run under.

In other words, what is the Qt5 equivalent to Posix thread's pthread_setaffinity_np() ?

Can I do this for threads managed by QThreadPool?

答:
Qt doesn't provide any public APIs for setting processor affinity. There's definitely no way to do this for a QThreadPool, which doesn't even provide an API for accessing the QThreads within the pool.

For explicitly-created QThread objects, you could try using the QThread::getCurrentThreadId() function to return a native "handle" to the thread, and then pass that to your system's thread-management library calls. But I would strongly recommend against this. The docs explicitly state:

Warning: The handle returned by this function is used for internal purposes and should not be used in any application code.

If you're building for a specific platform, you might be able to mix calls to your OS's library (e.g., pthreads), but that will not be portable and I have no idea if it will work.

Your best bet is probably to manage the CPU affinity of the whole application from the command-line. If you're on Linux, taskset is the way to go. For Windows, take a look at this SO answer. Unfortunately, Apple seems pretty determined to prevent users from setting thread affinity, at least from the command line.


问:
Why is my output equaling zero? (student)
I am a student in my first year of CIS courses, so I am a begineer. We are supposed to get input from a text file with an employee, the employee's department, hourly salary, and hours worked in given week, that looks like:

```<code>EID001, 1, 10.00, 40
EID002, 2, 10.50, 35
EID003, 3, 11.00, 30
EID004, 4, 11.50, 25
EID005, 5, 12.00, 20
EID006, 6, 12.50, 40
EID007, 7, 11.00, 25
.
.
.
(Employee ID, Department, Hourly Salary, Hours Worked)
</code>```

Then separate each field into elements of an array, validate each field, and calculate the total gross pay (Hourly Salary * Hours Worked) for each of the 7 departments.

My code:

```<code>    using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;

namespace Project_3_rev
{
    class Program
    {
        const int DEPARTMENTS = 7;
        const int FIELDS = 4;
        static void Main(string[] args)
        {
            FileStream fStream = new FileStream("project3data.txt", FileMode.Open, FileAccess.Read);
            StreamReader inFile = new StreamReader(fStream);
            string input = "";
            string[] fields = new string[FIELDS];
            string employee = "";
            int department = 0;
            double salary = 0.00;
            int hours = 0;

            double totalSalary = 0.00;
            int totalHours = 0;
            double[] grossPayArray = new double[DEPARTMENTS];

            input = inFile.ReadLine();
            while(input != null)
            {
                fields = input.Split(',');

                checkEmployee(input, fields, employee);
                checkDepartment(input, fields, department);

                for(int x = 1; x <= DEPARTMENTS; x++)
                {
                    totalSalary = 0.00;
                    totalHours = 0;
                    while (department == x)
                    {

                        checkSalary(input, fields, salary, department, totalSalary);
                        checkHours(input, fields, hours, department, totalHours);
                        grossPayArray[x - 1] = totalSalary * totalHours;
                    }
                }

                input = inFile.ReadLine();
            }

            displayOutput(grossPayArray);

        }

        static void checkEmployee(string inp, string[] fieldsArray, string emp)
        {
            if(fieldsArray[0] == null)
                Console.WriteLine("An Employee ID is invalid.");
        }

        static void checkDepartment(string inp, string[] fieldsArray, int dept)
        {
            if((!int.TryParse(fieldsArray[1], out dept)) || dept < 0 || dept > DEPARTMENTS)
            {
                Console.WriteLine("Department field is invalid: " + fieldsArray[1]);
            }

        }

        static void checkSalary(string inp, string[] fieldsArray, double sal, int dept, double totSal)
        {

                    if ((double.TryParse(fieldsArray[2], out sal)) && sal >= 10.00)
                        totSal = totSal * sal;
                    else
                        Console.WriteLine("Salary field is invalid: " + fieldsArray[2]);

        }

        static void checkHours(string inp, string[] fieldsArray, int hrs, int dept, int totHrs)
        {

                    if ((int.TryParse(fieldsArray[3], out hrs)) && hrs >= 0)
                        totHrs = totHrs * hrs;

                    else
                        Console.WriteLine("Hours field is invalid: " +  fieldsArray[3]);

        }

        static void displayOutput(double[] grossArray)
        {
            for(int x = 1; x <= DEPARTMENTS; x++)
            {
                Console.WriteLine("Department " + x + ": Gross Pay = " + grossArray[x-1]);
            }
        }

    }
}
</code>```

My output:

```<code>Department 1: Gross Pay = 0
Department 2: Gross Pay = 0
Department 3: Gross Pay = 0
Department 4: Gross Pay = 0
Department 5: Gross Pay = 0
Department 6: Gross Pay = 0
Department 7: Gross Pay = 0
</code>```

Why are the Gross Pays equaling zero?

Please keep in mind that I am in my first year of computer science. I am only allowed to use what we have learned and I only know the basics. Please cut me a little slack if this code is messy or my logic is way off. Thanks ahead of time.

答:
The problem of your code is this kind of function:

```<code>static void checkSalary(string inp, string[] fieldsArray, double sal, int dept, double totSal)
{
    if ((double.TryParse(fieldsArray[2], out sal)) && sal >= 10.00)
        totSal = totSal * sal;
    else
        Console.WriteLine("Salary field is invalid: " + fieldsArray[2]);
}
</code>```

Is similar to this kind of function:

```<code>function Increase(int number) {
    number = number + 1;
}

var number = 5;
Increase(number);
Console.WriteLine(number);
</code>```

What you get is 5, instead of your expectation, 6.

In C#, it's called "passed by value". The value is passed into the function, and no modification is affected to the outside variable. In your case, toSalary will remain 0.

YOu need to change to ref double toSalary to use "pass by reference".

Other thing you need to practice is debugging technique:

Put break point.

Print the value to check.

Write unit tests to verify your methods.

Body:
I am a student in my first year of CIS courses, so I am a begineer. We are supposed to get input from a text file with an employee, the employee's department, hourly salary, and hours worked in given week, that looks like:

EID001, 1, 10.00, 40
EID002, 2, 10.50, 35
EID003, 3, 11.00, 30
EID004, 4, 11.50, 25
EID005, 5, 12.00, 20
EID006, 6, 12.50, 40
EID007, 7, 11.00, 25
.
.
.
(Employee ID, Department, Hourly Salary, Hours Worked)

Then separate each field into elements of an array, validate each field, and calculate the total gross pay (Hourly Salary * Hours Worked) for each of the 7 departments.

My code:

    using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;

namespace Project_3_rev
{
    class Program
    {
        const int DEPARTMENTS = 7;
        const int FIELDS = 4;
        static void Main(string[] args)
        {
            FileStream fStream = new FileStream("project3data.txt", FileMode.Open, FileAccess.Read);
            StreamReader inFile = new StreamReader(fStream);
            string input = "";
            string[] fields = new string[FIELDS];
            string employee = "";
            int department = 0;
            double salary = 0.00;
            int hours = 0;

            double totalSalary = 0.00;
            int totalHours = 0;
            double[] grossPayArray = new double[DEPARTMENTS];

            input = inFile.ReadLine();
            while(input != null)
            {
                fields = input.Split(',');

                checkEmployee(input, fields, employee);
                checkDepartment(input, fields, department);

                for(int x = 1; x <= DEPARTMENTS; x++)
                {
                    totalSalary = 0.00;
                    totalHours = 0;
                    while (department == x)
                    {

                        checkSalary(input, fields, salary, department, totalSalary);
                        checkHours(input, fields, hours, department, totalHours);
                        grossPayArray[x - 1] = totalSalary * totalHours;
                    }
                }

                input = inFile.ReadLine();
            }

            displayOutput(grossPayArray);

        }

        static void checkEmployee(string inp, string[] fieldsArray, string emp)
        {
            if(fieldsArray[0] == null)
                Console.WriteLine("An Employee ID is invalid.");
        }

        static void checkDepartment(string inp, string[] fieldsArray, int dept)
        {
            if((!int.TryParse(fieldsArray[1], out dept)) || dept < 0 || dept > DEPARTMENTS)
            {
                Console.WriteLine("Department field is invalid: " + fieldsArray[1]);
            }

        }

        static void checkSalary(string inp, string[] fieldsArray, double sal, int dept, double totSal)
        {

                    if ((double.TryParse(fieldsArray[2], out sal)) && sal >= 10.00)
                        totSal = totSal * sal;
                    else
                        Console.WriteLine("Salary field is invalid: " + fieldsArray[2]);

        }

        static void checkHours(string inp, string[] fieldsArray, int hrs, int dept, int totHrs)
        {

                    if ((int.TryParse(fieldsArray[3], out hrs)) && hrs >= 0)
                        totHrs = totHrs * hrs;

                    else
                        Console.WriteLine("Hours field is invalid: " +  fieldsArray[3]);

        }

        static void displayOutput(double[] grossArray)
        {
            for(int x = 1; x <= DEPARTMENTS; x++)
            {
                Console.WriteLine("Department " + x + ": Gross Pay = " + grossArray[x-1]);
            }
        }

    }
}

My output:

Department 1: Gross Pay = 0
Department 2: Gross Pay = 0
Department 3: Gross Pay = 0
Department 4: Gross Pay = 0
Department 5: Gross Pay = 0
Department 6: Gross Pay = 0
Department 7: Gross Pay = 0

Why are the Gross Pays equaling zero?

Please keep in mind that I am in my first year of computer science. I am only allowed to use what we have learned and I only know the basics. Please cut me a little slack if this code is messy or my logic is way off. Thanks ahead of time.

Body:
The problem of your code is this kind of function:

static void checkSalary(string inp, string[] fieldsArray, double sal, int dept, double totSal)
{
    if ((double.TryParse(fieldsArray[2], out sal)) && sal >= 10.00)
        totSal = totSal * sal;
    else
        Console.WriteLine("Salary field is invalid: " + fieldsArray[2]);
}

Is similar to this kind of function:

function Increase(int number) {
    number = number + 1;
}

var number = 5;
Increase(number);
Console.WriteLine(number);

What you get is 5, instead of your expectation, 6.

In C#, it's called "passed by value". The value is passed into the function, and no modification is affected to the outside variable. In your case, toSalary will remain 0.

YOu need to change to ref double toSalary to use "pass by reference".

Other thing you need to practice is debugging technique:

Put break point.

Print the value to check.

Write unit tests to verify your methods.


问:
how to use ref in multi-step registration in react es6?
I'm trying to develop multistep registration, referring this link : https://www.viget.com/articles/building-a-multi-step-registration-form-with-react

But I could not use refs and don't know how to fix this.

This is the error msg I get everytime I click on 'next' button
error msg

and this is my code

```<code>              <input type="text"
                     className='singleComponent'
                     name='AppName'
                     ref='AppName'
                     defaultValue={ this.props.fieldValues.AppName }
                     />

            <button>Cancel</button>
            <button onClick={this.SaveAndContinue}>Next</button>

  SaveAndContinue(e){
      e.preventDefault();

    var data={
        AppName : this.refs.AppName,
  }

    this.props.saveValues(data)
    this.props.nextStep()
  }

  }
</code>```

Dependencies :

```<code>"react": "^16.1.0",
"react-dev-utils": "^4.2.1",
"react-dom": "^16.1.0",
</code>```

can someone help?

Thanks,

答:
While it may not be the exact cause of the issues you are seeing, it is recommended that you update from your implementation which uses string refs to a callback version.

So instead of:
ref='AppName'

Use:
ref={(input) => { this.AppName = input; }}

Then you will access the reference the element within AddApplicationField via:
this.AppName

This may solve your issue since there are known issues with the legacy string ref method.

See more here:
https://reactjs.org/docs/refs-and-the-dom.html

Body:
I'm trying to develop multistep registration, referring this link : https://www.viget.com/articles/building-a-multi-step-registration-form-with-react

But I could not use refs and don't know how to fix this.

This is the error msg I get everytime I click on 'next' button
error msg

and this is my code

              <input type="text"
                     className='singleComponent'
                     name='AppName'
                     ref='AppName'
                     defaultValue={ this.props.fieldValues.AppName }
                     />

            <button>Cancel</button>
            <button onClick={this.SaveAndContinue}>Next</button>

  SaveAndContinue(e){
      e.preventDefault();

    var data={
        AppName : this.refs.AppName,
  }

    this.props.saveValues(data)
    this.props.nextStep()
  }

  }

Dependencies :

"react": "^16.1.0",
"react-dev-utils": "^4.2.1",
"react-dom": "^16.1.0",

can someone help?

Thanks,


问:
Is SQL the assembly for databases?
Talking about hibernate and others ORMs, the ORMs evangelists talk about SQL like the assembly language for Databases.

I think is soon to assert this, but I guess can be true on a near future, not sure.

UPDATE: The analogy I was referring means SQL is to assembly what ORM is to C/Java/C#. Of course, an exact analogy is not possible. The question is if in the future, with more powerful computers the developers are going to use only ORM (or ORM like) instead of SQL.

答:
It is, in the following sense: an ORM provides a high-level, domain-specific API which emits SQL statements, in the same way that a high-level language creates domain-specific APIs and emits machine-language statements.

I.e.:

Orm is is a layer above SQL

And HLL is a layer above assembly

However, I don't mean to imply that people will stop using SQL and prefer ORMs, in the same way that people have stopped using assembly and prefer HLLs.

OwnerDisplayName: FerranB

Title: Is SQL the assembly for databases?

LastEditorDisplayName: FerranB

OwnerDisplayName: ChrisW


问:
How to map between int and property c#
In the project I'm working on, (.net Core) we are using a range slider (noUiSlider)to represent quality in a product filter.

Slider

The slider returns an array of numbers as an example [2, 4] would be returned if the slider was set to Good and Excellent and I would need to retrieve all the products that match Good, Very Good, and Excellent in quality.

Here in lies some of the unique problems with this.
The products are pulled from a third party service, and I only receive the quality as the string value. So I need a way to assign a number value to the string value I receive so I can check for all products that have a quality >= to qualityArray[0] and <= to qualityArray[1]

What would be the best way to map between string to int so I can do the >= and <= check with the quality range and at the same time map the int to a string so when displaying the list of products that match the range I only have to display the string value? (Very Good)

I was imagining using an Enum or a Dictionary but I'm not sure what the advantages of either would be.

答:
You could encapsulate a rating in its own class:

```<code>public class Rating
{
    public int Value { get; }

    private readonly IDictionary<string, int> _asValue = new Dictionary<string, int>
    {
        {"One", 1},
        {"Two", 2},
        {"Three", 3},
        {"Four", 4},
        {"Five", 5},
    };

    public Rating(string rating)
    {
        Value = _asValue[rating];
    }

    public override string ToString()
    {
        return _asValue.First(pair => pair.Value == Value).Key;
    }
}
</code>```

To compare ratings you would just need to get the Value from each rating:

```<code>var r1 = new Rating("One");
var r2 = new Rating("Two");
var result = r1.Value > r2.Value;
</code>```

Title: How to map between int and property c#

Body:
You could encapsulate a rating in its own class:

public class Rating
{
    public int Value { get; }

    private readonly IDictionary<string, int> _asValue = new Dictionary<string, int>
    {
        {"One", 1},
        {"Two", 2},
        {"Three", 3},
        {"Four", 4},
        {"Five", 5},
    };

    public Rating(string rating)
    {
        Value = _asValue[rating];
    }

    public override string ToString()
    {
        return _asValue.First(pair => pair.Value == Value).Key;
    }
}

To compare ratings you would just need to get the Value from each rating:

var r1 = new Rating("One");
var r2 = new Rating("Two");
var result = r1.Value > r2.Value;


问:
How to inject ClaimsPrincipal in Nancy
I have a Nancy module and a decorator class that needs to know the ClaimsPrincipal in order to retrieve the user's email address. So I have declared a constructor as

```<code>public EmailDecorator(IDbConnectionFactory connectionFactory,
                      IPrincipal principal,
                      IEmailClient emailClient) : base(connectionFactory)
</code>```

What I'm struggling to figure out is how to inject the principal into the constructor. I'm using Simple Injector for DI and it has been very effective. But if I override the ConfigureRequestContainer() method, which has as a parameter for the NancyContext, to instantiate IPrincipal I get an exception

```<code>protected override void ConfigureRequestContainer(
    TinyIoCContainer container, NancyContext context)
{
    container.Register<IPrincipal>((c, o) => context.CurrentUser);
    base.ConfigureRequestContainer(container, context);
}
</code>```

The exception indicates Simple Injector doesn't know about IPrincipal which is registered in the default TinyIOC container.

The configuration is invalid. Creating the instance for type InvoiceModule failed. The constructor of type EmailDecorator contains the parameter with name 'principal' and type IPrincipal that is not registered. Please ensure IPrincipal is registered, or change the constructor of EmailDecorator.

Edit

I've spent way too long trying to resolve this and I suspect the answer is to stop trying to do it this way. In my original example, I'm trying to inject IPrincipal into the decorator constructor which is incorrect. Instead I need to inject some form of service that allows me to derive IPrincipal when one of the methods in the decorator is called, e.g. Func<IPrincipal>. Nancy provides an override-able method ConfigureRequestContainer() that is called for each request, so could potentially be used:

```<code>protected override void ConfigureRequestContainer(TinyIoCContainer container, NancyContext context)
{
    container.Register<Func<IPrincipal>>((c, o) =>
    {
        return () => context.CurrentUser;
    });
}
</code>```

Except that the request container is a TinyIoCContainer and I'm using SimpleInjector. So, maybe I can add a SimpleInjector registration that offloads resolution to the request container?

```<code>_container.RegisterSingleton<Func<IPrincipal>>(() => nancy.Resolve<Func<IPrincipal>>());
</code>```

Actually no, nancy is not the same container as the request container. So maybe somewhere there is a container that can successfully resolve IPrincipal but I do not know how to access it. The objective of the exercise was to avoid having to modify the method signatures of the repo code to include the ClaimsPrincipal, kind of like the old days when it was possible to call Thread.CurrentPrincipal. Still looking for a clue but will start modifying the method signature to include a ClaimsPrincipal.

答:
The answer is to use IHttpContextAccessor. In Startup.cs add a new service definition in the ConfigureServices() method:

```<code>public void ConfigureServices(IServiceCollection services)
{
    services.AddSingleton<IAppSettings>(settings);
    services.AddSingleton<IHttpContextAccessor>(new HttpContextAccessor());
    …
 }
</code>```

Then pass app.ApplicationServices as a parameter to the bootstrapper:

```<code>public void Configure(IApplicationBuilder app, IHostingEnvironment env, IAppSettings settings)
{
    var log = ConfigureLogger(settings);
    app.UseOwin(buildFunc =>
    {
        buildFunc.UseMonitoringAndLogging(log, HealthCheckAsync);
        buildFunc.UseNancy(cfg =>
            cfg.Bootstrapper = new Bootstrapper(env, log, app.ApplicationServices));
    });
}
</code>```

In the Bootstrapper class ApplicationStartup() method, register the service in the Simple Injector container:

```<code>    public Bootstrapper(IHostingEnvironment env, ILogger log, IServiceProvider services)
    {
        _env = env;
        _log = log;
        _services = services;
    }

    …

    _container.Register<IHttpContextAccessor>(() =>
        (IHttpContextAccessor) _services.GetService(typeof(IHttpContextAccessor)));
</code>```

Then in the decorator class, add IHttpContextAccessor to the constructor:

```<code>public EmailDecorator(IDbConnectionFactory connectionFactory,
                      ILogger log,
                      IHttpContextAccessor httpContextAccessor,
                      IEmailClient emailClient) : base(connectionFactory, log)
{
    _emailClient = emailClient;
    _httpContextAccessor = httpContextAccessor;
}
</code>```

The ClaimsPrincipal can be accessed from the _httpContextAccessor.HttpContext property.

Title: How to inject ClaimsPrincipal in Nancy

Body:
I have a Nancy module and a decorator class that needs to know the ClaimsPrincipal in order to retrieve the user's email address. So I have declared a constructor as

public EmailDecorator(IDbConnectionFactory connectionFactory,
                      IPrincipal principal,
                      IEmailClient emailClient) : base(connectionFactory)

What I'm struggling to figure out is how to inject the principal into the constructor. I'm using Simple Injector for DI and it has been very effective. But if I override the ConfigureRequestContainer() method, which has as a parameter for the NancyContext, to instantiate IPrincipal I get an exception

protected override void ConfigureRequestContainer(
    TinyIoCContainer container, NancyContext context)
{
    container.Register<IPrincipal>((c, o) => context.CurrentUser);
    base.ConfigureRequestContainer(container, context);
}

The exception indicates Simple Injector doesn't know about IPrincipal which is registered in the default TinyIOC container.

The configuration is invalid. Creating the instance for type InvoiceModule failed. The constructor of type EmailDecorator contains the parameter with name 'principal' and type IPrincipal that is not registered. Please ensure IPrincipal is registered, or change the constructor of EmailDecorator.

Edit

I've spent way too long trying to resolve this and I suspect the answer is to stop trying to do it this way. In my original example, I'm trying to inject IPrincipal into the decorator constructor which is incorrect. Instead I need to inject some form of service that allows me to derive IPrincipal when one of the methods in the decorator is called, e.g. Func<IPrincipal>. Nancy provides an override-able method ConfigureRequestContainer() that is called for each request, so could potentially be used:

protected override void ConfigureRequestContainer(TinyIoCContainer container, NancyContext context)
{
    container.Register<Func<IPrincipal>>((c, o) =>
    {
        return () => context.CurrentUser;
    });
}

Except that the request container is a TinyIoCContainer and I'm using SimpleInjector. So, maybe I can add a SimpleInjector registration that offloads resolution to the request container?

_container.RegisterSingleton<Func<IPrincipal>>(() => nancy.Resolve<Func<IPrincipal>>());

Actually no, nancy is not the same container as the request container. So maybe somewhere there is a container that can successfully resolve IPrincipal but I do not know how to access it. The objective of the exercise was to avoid having to modify the method signatures of the repo code to include the ClaimsPrincipal, kind of like the old days when it was possible to call Thread.CurrentPrincipal. Still looking for a clue but will start modifying the method signature to include a ClaimsPrincipal.

Body:
The answer is to use IHttpContextAccessor. In Startup.cs add a new service definition in the ConfigureServices() method:

public void ConfigureServices(IServiceCollection services)
{
    services.AddSingleton<IAppSettings>(settings);
    services.AddSingleton<IHttpContextAccessor>(new HttpContextAccessor());
    …
 }

Then pass app.ApplicationServices as a parameter to the bootstrapper:

public void Configure(IApplicationBuilder app, IHostingEnvironment env, IAppSettings settings)
{
    var log = ConfigureLogger(settings);
    app.UseOwin(buildFunc =>
    {
        buildFunc.UseMonitoringAndLogging(log, HealthCheckAsync);
        buildFunc.UseNancy(cfg =>
            cfg.Bootstrapper = new Bootstrapper(env, log, app.ApplicationServices));
    });
}

In the Bootstrapper class ApplicationStartup() method, register the service in the Simple Injector container:

    public Bootstrapper(IHostingEnvironment env, ILogger log, IServiceProvider services)
    {
        _env = env;
        _log = log;
        _services = services;
    }

    …

    _container.Register<IHttpContextAccessor>(() =>
        (IHttpContextAccessor) _services.GetService(typeof(IHttpContextAccessor)));

Then in the decorator class, add IHttpContextAccessor to the constructor:

public EmailDecorator(IDbConnectionFactory connectionFactory,
                      ILogger log,
                      IHttpContextAccessor httpContextAccessor,
                      IEmailClient emailClient) : base(connectionFactory, log)
{
    _emailClient = emailClient;
    _httpContextAccessor = httpContextAccessor;
}

The ClaimsPrincipal can be accessed from the _httpContextAccessor.HttpContext property.


问:
Ajax send data and take values from database
I would like to:

send data from the index.php file using ajax to php

then based on it find the appropriate value in the database

and send the returned value to index.php and put it in "longitude" input.

I really have no idea how to do it.

For example: I write "lala" in input "bar", then click "submit" button and then find "longitude" in database where Nombre = "lala" and finally it appears in "longitude" input.

index.php:

```<code><form id="foo">
<label for="bar">A bar</label>
<input id="bar" name="bar" type="text" value="" />
<input type="submit" value="Send" />
</form>
<input id="longitude" name="longitude" type="text" value="" />
</code>```

index.js (send value) and next take data (longitude) and put to longitude:

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

    $('form').on('submit', function (e) {

      e.preventDefault();

      $.ajax({
        type: 'post',
        url: 'http://localhost/inne/phonegap_test/agregar.php',
        data: $('form').serialize(),
        success: function () {
          alert('form was submitted');
        }
      });

    });

  });
</code>```

agregar.php:

```<code>$servername = "localhost";
$username = "root";
$password = "";
$dbname = "inzynierka_test2";

$conn = new mysqli($servername, $username, $password, $dbname);

if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}

$val1 = $_POST['bar'];

$sql2 = "SELECT `longitude` FROM `lugar` WHERE `Nombre`= $val1 ORDER BY `ID` DESC LIMIT 1";
$result2 = $conn->query($sql2);

if ($result2->num_rows > 0) {
$row2 = $result2->fetch_assoc();
$cal2 = $row2["longitude"];
}
else{
    echo "Nie znalazło miasta";
}

echo json_encode(array( "longitude" => $cal2 ));
</code>```

答:
Send the returned value to index.php and put it in "longitude" input.

if all run well, try this

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

$('form').on('submit', function (e) {
  e.preventDefault();
  $.ajax({
    type: 'post',
    url: 'http://localhost/inne/phonegap_test/agregar.php',
    data: $('form').serialize(),

    //dont forget set return back
    success: function ( e) {

      //parse the data from json
      var data = JSON.parse(e);

      //set into longitude input
      $('#longitude').val(data.longitude);

      alert('form was submitted');
    }
  });
});
</code>```

});

and your php code

```<code>if ($result2->num_rows > 0) {
   $row2 = $result2->fetch_assoc();
   $cal2 = $row2["longitude"];
}
else{
   $cal2 = "Nie znalazło miasta";
 }
return json_encode(array( "longitude" => $cal2 ));
</code>```

Body:
I would like to:

send data from the index.php file using ajax to php

then based on it find the appropriate value in the database

and send the returned value to index.php and put it in "longitude" input.

I really have no idea how to do it.

For example: I write "lala" in input "bar", then click "submit" button and then find "longitude" in database where Nombre = "lala" and finally it appears in "longitude" input.

index.php:

<form id="foo">
A bar
<input id="bar" name="bar" type="text" value="" />
<input type="submit" value="Send" />
</form>
<input id="longitude" name="longitude" type="text" value="" />

index.js (send value) and next take data (longitude) and put to longitude:

$(function () {

    $('form').on('submit', function (e) {

      e.preventDefault();

      $.ajax({
        type: 'post',
        url: 'http://localhost/inne/phonegap_test/agregar.php',
        data: $('form').serialize(),
        success: function () {
          alert('form was submitted');
        }
      });

    });

  });

agregar.php:

$servername = "localhost";
$username = "root";
$password = "";
$dbname = "inzynierka_test2";

$conn = new mysqli($servername, $username, $password, $dbname);

if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}

$val1 = $_POST['bar'];

$sql2 = "SELECT `longitude` FROM `lugar` WHERE `Nombre`= $val1 ORDER BY `ID` DESC LIMIT 1";
$result2 = $conn->query($sql2);

if ($result2->num_rows > 0) {
$row2 = $result2->fetch_assoc();
$cal2 = $row2["longitude"];
}
else{
    echo "Nie znalazło miasta";
}

echo json_encode(array( "longitude" => $cal2 ));

Body:
Send the returned value to index.php and put it in "longitude" input.

if all run well, try this

$(function () {

$('form').on('submit', function (e) {
  e.preventDefault();
  $.ajax({
    type: 'post',
    url: 'http://localhost/inne/phonegap_test/agregar.php',
    data: $('form').serialize(),

    //dont forget set return back
    success: function ( e) {

      //parse the data from json
      var data = JSON.parse(e);

      //set into longitude input
      $('#longitude').val(data.longitude);

      alert('form was submitted');
    }
  });
});

});

and your php code

if ($result2->num_rows > 0) {
   $row2 = $result2->fetch_assoc();
   $cal2 = $row2["longitude"];
}
else{
   $cal2 = "Nie znalazło miasta";
 }
return json_encode(array( "longitude" => $cal2 ));


问:
pandas between time is not working
I want to filter morning tweets from a 1-month tweet dataset. The column date originally was a timestamp column therefore I converted it to date time, index, and use between time. But it returns an empty data frame. What's wrong?

```<code>import pandas as pd
import matplotlib.pyplot as plt

if __name__ == "__main__":
    df = pd.read_csv('inst.csv',encoding='utf-8')
    df.date = pd.to_datetime(df.date)
    df.set_index(pd.DatetimeIndex(df.date),inplace=True)
    mor = df.between_time('6:00','12:00')
    print(mor)
</code>```

Here's a piece of data

```<code>,X,Unnamed..0,id,owner_id,post_src,caption,likes,comments,date,code,location_id,location_name,location_slug,location_type,postal_code,lat,lng
4,3,3,1.54153890455e+18,27131715,https://scontent.cdninstagram.com/t51.2885-15/e35/19227888_434457730286781_8956364636005859328_n.jpg,"Courage doesn't mean you don't get afraid. Courage means you don't let fear stop you.
•
•
•
•
•
•
•
•
•
#vancouver #bcplace #beautifulday #beautifulbc #explorebc #clouds #sky #city #cityliving #eveningsky #seaside #adventure #bc #instagood #goodvibes #goodtimes #positivevibes #instadaily #instagram #picoftheday #instagold #pictureoftheday #igdaily",5,0,1497985779,BVkpXddDAEC,741066469,Yaletown,yaletown,NA,,49.2757019,-123.1199065
</code>```

答:
You're getting nothing back because you don't have any entries between those timestamps.  Here's an example, with your data:

```<code>import pandas as pd
df = pd.read_csv('inst.csv',encoding='utf-8')
df.date = pd.to_datetime(df.date)
df.set_index(pd.DatetimeIndex(df.date),inplace=True)
more = df.between_time('0:00','9:00')
less = df.between_time('11:00','12:00')
print(more)
</code>```

I get back:

```<code>                                Unnamed: 0  X  Unnamed..0            id  \
date
1970-01-01 00:00:01.497985779           4  3           3  1.541539e+18

                               owner_id  \
date
1970-01-01 00:00:01.497985779  27131715

                                                                        post_src  \
date
1970-01-01 00:00:01.497985779  https://scontent.cdninstagram.com/t51.2885-15/...

                                                                         caption  \
date
1970-01-01 00:00:01.497985779  Courage doesn't mean you don't get afraid. Cou...

                               likes  comments                          date  \
date
1970-01-01 00:00:01.497985779      5         0 1970-01-01 00:00:01.497985779

                                      code  location_id location_name  \
date
1970-01-01 00:00:01.497985779  BVkpXddDAEC    741066469      Yaletown

                              location_slug  location_type  postal_code  \
date
1970-01-01 00:00:01.497985779      yaletown            NaN          NaN

                                     lat         lng
date
1970-01-01 00:00:01.497985779  49.275702 -123.119906
</code>```

Then if I print less:

```<code>Empty DataFrame
Columns: [Unnamed: 0, X, Unnamed..0, id, owner_id, post_src, caption, likes, comments, date, code, location_id, location_name, location_slug, location_type, postal_code, lat, lng]
Index: []
</code>```

Here's my inst.csv, based off your example data:

```<code>,X,Unnamed..0,id,owner_id,post_src,caption,likes,comments,date,code,location_id,location_name,location_slug,location_type,postal_code,lat,lng 4,3,3,1.54153890455e+18,27131715,https://scontent.cdninstagram.com/t51.2885-15/e35/19227888_434457730286781_8956364636005859328_n.jpg,"Courage doesn't mean you don't get afraid. Courage means you don't let fear stop you. • • • • • • • • •
#vancouver #bcplace #beautifulday #beautifulbc #explorebc #clouds #sky #city #cityliving #eveningsky #seaside #adventure #bc #instagood #goodvibes #goodtimes #positivevibes #instadaily #instagram #picoftheday #instagold #pictureoftheday #igdaily",5,0,1497985779,BVkpXddDAEC,741066469,Yaletown,yaletown,NA,,49.2757019,-123.1199065
</code>```

If you want to be more explicit with your time strings, write 'AM' or 'PM', like this:

```<code>anotherWay = df.between_time('6:00PM','1:00AM')
</code>```

Title: pandas between time is not working

Body:
I want to filter morning tweets from a 1-month tweet dataset. The column date originally was a timestamp column therefore I converted it to date time, index, and use between time. But it returns an empty data frame. What's wrong?

import pandas as pd
import matplotlib.pyplot as plt

if __name__ == "__main__":
    df = pd.read_csv('inst.csv',encoding='utf-8')
    df.date = pd.to_datetime(df.date)
    df.set_index(pd.DatetimeIndex(df.date),inplace=True)
    mor = df.between_time('6:00','12:00')
    print(mor)

Here's a piece of data

,X,Unnamed..0,id,owner_id,post_src,caption,likes,comments,date,code,location_id,location_name,location_slug,location_type,postal_code,lat,lng
4,3,3,1.54153890455e+18,27131715,https://scontent.cdninstagram.com/t51.2885-15/e35/19227888_434457730286781_8956364636005859328_n.jpg,"Courage doesn't mean you don't get afraid. Courage means you don't let fear stop you.
•
•
•
•
•
•
•
•
•
#vancouver #bcplace #beautifulday #beautifulbc #explorebc #clouds #sky #city #cityliving #eveningsky #seaside #adventure #bc #instagood #goodvibes #goodtimes #positivevibes #instadaily #instagram #picoftheday #instagold #pictureoftheday #igdaily",5,0,1497985779,BVkpXddDAEC,741066469,Yaletown,yaletown,NA,,49.2757019,-123.1199065

Body:
You're getting nothing back because you don't have any entries between those timestamps.  Here's an example, with your data:

import pandas as pd
df = pd.read_csv('inst.csv',encoding='utf-8')
df.date = pd.to_datetime(df.date)
df.set_index(pd.DatetimeIndex(df.date),inplace=True)
more = df.between_time('0:00','9:00')
less = df.between_time('11:00','12:00')
print(more)

I get back:

                                Unnamed: 0  X  Unnamed..0            id  \
date
1970-01-01 00:00:01.497985779           4  3           3  1.541539e+18

                               owner_id  \
date
1970-01-01 00:00:01.497985779  27131715

                                                                        post_src  \
date
1970-01-01 00:00:01.497985779  https://scontent.cdninstagram.com/t51.2885-15/...

                                                                         caption  \
date
1970-01-01 00:00:01.497985779  Courage doesn't mean you don't get afraid. Cou...

                               likes  comments                          date  \
date
1970-01-01 00:00:01.497985779      5         0 1970-01-01 00:00:01.497985779

                                      code  location_id location_name  \
date
1970-01-01 00:00:01.497985779  BVkpXddDAEC    741066469      Yaletown

                              location_slug  location_type  postal_code  \
date
1970-01-01 00:00:01.497985779      yaletown            NaN          NaN

                                     lat         lng
date
1970-01-01 00:00:01.497985779  49.275702 -123.119906

Then if I print less:

Empty DataFrame
Columns: [Unnamed: 0, X, Unnamed..0, id, owner_id, post_src, caption, likes, comments, date, code, location_id, location_name, location_slug, location_type, postal_code, lat, lng]
Index: []

Here's my inst.csv, based off your example data:

,X,Unnamed..0,id,owner_id,post_src,caption,likes,comments,date,code,location_id,location_name,location_slug,location_type,postal_code,lat,lng 4,3,3,1.54153890455e+18,27131715,https://scontent.cdninstagram.com/t51.2885-15/e35/19227888_434457730286781_8956364636005859328_n.jpg,"Courage doesn't mean you don't get afraid. Courage means you don't let fear stop you. • • • • • • • • •
#vancouver #bcplace #beautifulday #beautifulbc #explorebc #clouds #sky #city #cityliving #eveningsky #seaside #adventure #bc #instagood #goodvibes #goodtimes #positivevibes #instadaily #instagram #picoftheday #instagold #pictureoftheday #igdaily",5,0,1497985779,BVkpXddDAEC,741066469,Yaletown,yaletown,NA,,49.2757019,-123.1199065

If you want to be more explicit with your time strings, write 'AM' or 'PM', like this:

anotherWay = df.between_time('6:00PM','1:00AM')


问:
rename file by joining two search results
I am learning python and also English, I am doing this code to read a TXT and find in it a sequence of numbers, then rename the file with the sequence found. But besides looking for this sequence of numbers, I needed to find some set of words, for example, if I find the words Apple, Watermelon and Pineapple, and not find Pumpkin, classifies TXT as "fruits", and when renaming the file renames with the sequence of digits plus an "f" of fruit for example:

```<code>name_files2 = os.listdir(path_txt)

for TXT in name_files2:
    with open(path_txt + '\\' + TXT, "r") as content:
        search = re.search(r'(\d{5})\-(\d{2})\-(\d{4})\.(\d)\.(\d{2})\.(\d{4})|'
                           r'(\d{5})\s*\-\s*(\d{2})\s*\.\s*(\d{4})\.(\d)\.(\d{2})\.(\d{4})|'
                           r'(\d{7})\-(\d{2})\-(\d{4})\.(\d)\.(\d{4})', content.read())
    if search is not None:
        name2 = search.group(0)
        name2 = re.sub(r"\D", "", name2)
        fp = os.path.join("18_digitos", name2 + "_%d.txt")
        postfix = 0
        while os.path.exists(fp % postfix):
            postfix += 1
        os.rename(
            os.path.join(path_txt, TXT),
            fp % postfix
        )
</code>```

I can find the words in this way in the text, but I can not do both at the same time

```<code>if text_complete.find("apple") >= 0 and text_complete.find("watermelon") >= 0 and \
                text_complete.find("pineapple") >= 0 and text_complete.find("pumpkin") < 0:
    print("Find Fruit")
</code>```

I need basically to make two codes work together, I need them to find the 18-digit sequence, identify the keywords and classify as fruits for example, and rename the file with the sequence found + key word ranking + increment. Example: 12345678901234567_f_0 , 12345678901234567_f_1.

Currently it only concatenates the sequence and increment, example: 12345678901234567_0 , 12345678901234567_1. The increment I made to differentiate the files when they have the same sequence of numbers

EDIT: what I am not getting is to join the sequence and classification fruit that were extracted from the same text. The same number, may have the classification fruits or vegetables, for example. So I need to find out which sequence came out each fruit or vegetable classification to rename the file

答:
If I understand correctly, you want to check the contents of the file twice: once to extract a sequence of numbers and once to check if it contains "fruit" words.

In order to look at the text more than once you should store the contents of the file in its own variable.

You can change the code in the with block to :

```<code>with open(path_txt + '\\' + TXT, "r") as content:
    text_complete = content.read()
</code>```

And the later you can check for your number sequence

```<code>search = re.search(r'...', text_complete.read()) # ... is your long regular expression
</code>```

And you can also run your if statement to check for "fruit" words:

```<code>if text_complete.find("apple") >= 0 and ... : # ... is the rest of your condition
    found_fruit = True
</code>```

By storing the contents of the file as a string as the text_complete variable, you can refer to it multiple times, checking for something different each time.

Body:
I am learning python and also English, I am doing this code to read a TXT and find in it a sequence of numbers, then rename the file with the sequence found. But besides looking for this sequence of numbers, I needed to find some set of words, for example, if I find the words Apple, Watermelon and Pineapple, and not find Pumpkin, classifies TXT as "fruits", and when renaming the file renames with the sequence of digits plus an "f" of fruit for example:

name_files2 = os.listdir(path_txt)

for TXT in name_files2:
    with open(path_txt + '\\' + TXT, "r") as content:
        search = re.search(r'(\d{5})\-(\d{2})\-(\d{4})\.(\d)\.(\d{2})\.(\d{4})|'
                           r'(\d{5})\s*\-\s*(\d{2})\s*\.\s*(\d{4})\.(\d)\.(\d{2})\.(\d{4})|'
                           r'(\d{7})\-(\d{2})\-(\d{4})\.(\d)\.(\d{4})', content.read())
    if search is not None:
        name2 = search.group(0)
        name2 = re.sub(r"\D", "", name2)
        fp = os.path.join("18_digitos", name2 + "_%d.txt")
        postfix = 0
        while os.path.exists(fp % postfix):
            postfix += 1
        os.rename(
            os.path.join(path_txt, TXT),
            fp % postfix
        )

I can find the words in this way in the text, but I can not do both at the same time

if text_complete.find("apple") >= 0 and text_complete.find("watermelon") >= 0 and \
                text_complete.find("pineapple") >= 0 and text_complete.find("pumpkin") < 0:
    print("Find Fruit")

I need basically to make two codes work together, I need them to find the 18-digit sequence, identify the keywords and classify as fruits for example, and rename the file with the sequence found + key word ranking + increment. Example: 12345678901234567_f_0 , 12345678901234567_f_1.

Currently it only concatenates the sequence and increment, example: 12345678901234567_0 , 12345678901234567_1. The increment I made to differentiate the files when they have the same sequence of numbers

EDIT: what I am not getting is to join the sequence and classification fruit that were extracted from the same text. The same number, may have the classification fruits or vegetables, for example. So I need to find out which sequence came out each fruit or vegetable classification to rename the file

Body:
If I understand correctly, you want to check the contents of the file twice: once to extract a sequence of numbers and once to check if it contains "fruit" words.

In order to look at the text more than once you should store the contents of the file in its own variable.

You can change the code in the with block to :

with open(path_txt + '\\' + TXT, "r") as content:
    text_complete = content.read()

And the later you can check for your number sequence

search = re.search(r'...', text_complete.read()) # ... is your long regular expression

And you can also run your if statement to check for "fruit" words:

if text_complete.find("apple") >= 0 and ... : # ... is the rest of your condition
    found_fruit = True

By storing the contents of the file as a string as the text_complete variable, you can refer to it multiple times, checking for something different each time.


问:
How could I add a class for all the text input under one ID?
give all text input a class "form-control" under table with ID "table-form" using jquery

```<code><table class="table table-bordered table-hover table-striped" id="table-form">
  <tr valign="baseline">
    <td nowrap align="right">ID:</td>
    <td><?php echo $row_Recordset1['ID']; ?></td>
  </tr>
  <tr valign="baseline">
    <td nowrap align="right">Cid:</td>
    <td><input type="text" name="cid" value="<?php echo htmlentities($row_Recordset1['cid'], ENT_COMPAT, 'utf-8'); ?>" size="32"></td>
  </tr>
  <tr valign="baseline">
    <td nowrap align="right">Text:</td>
    <td><input type="text" name="text" value="<?php echo htmlentities($row_Recordset1['text'], ENT_COMPAT, 'utf-8'); ?>" size="32"></td>
  </tr>
  <tr valign="baseline">
    <td nowrap align="right">Star:</td>
    <td><input type="text" name="star" value="<?php echo htmlentities($row_Recordset1['star'], ENT_COMPAT, 'utf-8'); ?>" size="32"></td>
  </tr>
  <tr valign="baseline">
    <td nowrap align="right"> </td>
    <td><input type="submit" value="Update record"></td>
  </tr>
</table>
</code>```

give all text input a class "form-control" under table with ID "table-form" using jquery

答:
You could do this.</p>

```<code>$('#table-form input[type=text]').addClass('form-control');
</code>```

Body:
give all text input a class "form-control" under table with ID "table-form" using jquery

    ID:
    <?php echo $row_Recordset1['ID']; ?>

    Cid:
    <input type="text" name="cid" value="<?php echo htmlentities($row_Recordset1['cid'], ENT_COMPAT, 'utf-8'); ?>" size="32">

    Text:
    <input type="text" name="text" value="<?php echo htmlentities($row_Recordset1['text'], ENT_COMPAT, 'utf-8'); ?>" size="32">

    Star:
    <input type="text" name="star" value="<?php echo htmlentities($row_Recordset1['star'], ENT_COMPAT, 'utf-8'); ?>" size="32">

    <input type="submit" value="Update record">

give all text input a class "form-control" under table with ID "table-form" using jquery

Body:
You could do this.

$('#table-form input[type=text]').addClass('form-control');


问:
Why does rendering a png from this pdf using imagemagick create these streaky artifacts?
I'm running ghostscript 9.22, libpng 1.6.34, and imagemagick 7.0.7-11 Q16

Here is the command that replicates the issue:

```<code>convert -density 400 icon.pdf -scale 1024x1024 ./appicon-1024x1024.png
</code>```

Here is a link to the input PDF:
https://www.pdf-archive.com/2017/12/06/icon/

Here is the output I see, with streaky horizontal line artifacts:

Interestingly, turning off antialiasing resolves the issue, but is not suitable for our use case.

答:
This command works perfectly fine for me using ImageMagick 6.9.9.25 Q16 Mac OSX and Ghostscript 9.21 and libpng @1.6.30_0.

```<code>convert -density 400 icon.pdf -scale 1024x1024 test.png
</code>```

I suspect it is either your Ghostscript or libpng version. Try upgrading.

Body:
I'm running ghostscript 9.22, libpng 1.6.34, and imagemagick 7.0.7-11 Q16

Here is the command that replicates the issue:

convert -density 400 icon.pdf -scale 1024x1024 ./appicon-1024x1024.png

Here is a link to the input PDF:
https://www.pdf-archive.com/2017/12/06/icon/

Here is the output I see, with streaky horizontal line artifacts:

Interestingly, turning off antialiasing resolves the issue, but is not suitable for our use case.

Body:
This command works perfectly fine for me using ImageMagick 6.9.9.25 Q16 Mac OSX and Ghostscript 9.21 and libpng @1.6.30_0.

convert -density 400 icon.pdf -scale 1024x1024 test.png

I suspect it is either your Ghostscript or libpng version. Try upgrading.