问:
NavBar and Search Bar in the same line
so I have this project where I was given a screenshot of a website and have to replicate it while using HTML and CSS code purely. But I have gotten myself into a little predicament where my navbar has excess space that I don't want because I want a search bar to go where that excess space is at.

html {
background-color: lightgrey;
font-size: 100%;
}

body{
  margin: 5%;
  margin-top: 0;
  font-family: Georgia, "Times New Roman", Times, serif, Arial, Helvetica, sans-serif;

}

/* Navigation Bar*/
nav ul{
  list-style-type: none;
  margin: 0;
  padding: 0;
  overflow: hidden;
  background-color: #e9eed0
}

#current a{
    background-color: #b8d03b;
    color: white;
}

.nav li {
  float: left;
  border-right: 1px solid #bbb
}

.nav li a {
  display: block;
  color: #8c8f7d;
  text-align: center;
  padding: 14px 16px;
  text-decoration: none;
}

/* Search Bar */

.search {
  float: right;
}
 /* Heading */
.heading{
  background-color: #f6f6f6;
  border: 1px solid #b8d03b;
  border-bottom:.5px solid #b8d03b;
}

/* Main text area */

.main {
  display: block;
  background-color: #ffffff;
  color: grey;
  border: 1px solid #b8d03b;
  float: left;
}

.content{
  width: 50%;
  float: left;
  padding: 5px 15px;
}

.middle{
  width:30%;
  float: left;
  padding: 5px 15px;
  margin: 0px 5px 5px 5px;
}

.sidebar{
  width: 10%;
  padding: 5px 15px;
  float: left;
}

/* Calendar */
.october{
  text-align: center;
}
.weekdays {
    margin: 0;
    padding: 10px 0;
    background-color: #cccccc;
    text-align: center;
}

.weekdays li {
    display: inline-block;
    color: #ffffff;
    width: 10%;
    text-align: center;
}

.days {
    text-align: center;
    padding: 10px 0;
    background: #eee;
    margin: 0;
}

.days li {
    list-style-type: none;
    display: inline-block;
    width: 10%;
    text-align: center;
    margin-bottom: 5px;
    font-size:12px;
    color: #777;
}

.days li .active {
    color: #3c8cd7 !important
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<title> Final Project </title>
<link rel="stylesheet" href="style.css">
</head>

<body>
  <header role='banner'>
    <nav>
      <ul class="nav">
        <li id="current">Home </li>
        <li>ELA </li>
        <li> Photos</li>
        <li> About</li>
        <li> Contact</li>
      </ul>
    </nav>
  </header>
  <div class="search">
    <form method="get" action="search-results.php" role="search">
      <label for="search"> Search: </label>
      <input type="search" size="30">
      <input type="submit" value="Search" />
  </div>
  <div class="heading">
  <p><span> News Flash</span> By Guillermo Molina </p>
  <p><small>>> Home</small></p>
</div>
<div class="main">

<article class="content">
  <p><small>posted on Novermber 16, 2017 by Guillermo Molina</small></p>
  <h1>About This Template</h1>
  <p><strong>News Flash</strong> Denec leo. Vivamus fermnetum nibh in augue.
  Praesent a lacus at erna congue rutrum. Nulla enim erosm porttitor eu, tempus
id, varius non, nib. Duis enim nula luctus eu, dapibus lacinia, venenatis id  quam.
 Vestibulum imperdiet, magna nec eleifend rutrum, nunc lectus vestibulum velit, euismod lacinia quam nisl id lorem. Quisque erat.
</p>

<p>Vestibulum imperdiet, magna nec eleifend rutrum, nunc lectus vestibulum
velit, euismod lacinia quam nisl id lorem. Quisque erat.</p>

<h2>A Heading Level 2</h2>
<p>This paragraph is followed by a sample unordered list:</p>

<ul>
  <li>Consectetuer adipiscing elit</li>
  <li>Metus aliquam pellentesque</li>
  <li>Urnanet non molestie semper</li>
  <li>Proin gravida orci porttitor</li>
</ul>

<h3>Heading Level 3</h3>
<p>While this is followed by a blockquote:</p>
<blockquote cite="http://www.google.com">
  Donec leo, vivamus nibh in augue praesent a lacus at urna congue rutrum. Quisque dictum integer nisl risus, sagittis convallis,
  rutrum id, congue, and nibh.
</blockquote>
<p> Comments(33) Permalink </p>

<hr>
<p>TAGS: DOLOR IPSUM SIT AMET DOLOR IPSUM LOREM SIT AMET </p>

</article>

<section class="middle">
  <h2>Recent Posts</h2>
  <h3>Aliquam Libero</h3>
  <p>Nullam ante orci, eget, tempus quis, ultrices in, est. Curabitur sit amet nulla. Nam in massa. Sed vel tellus. Curabitur sem urna,
  consequat vel, sescipit in, mattis placerat, nulla. Sed ac leo. Pellentesque imperdiet.More...</p>
  <h3>Semper Vestibulum</h3>
  <p>DOnec leo, vivamus fermentum nibh in augue praesent a lacus at urna congue rutrum. Quisque dictum integer nisl risus, sagittis convallis, rutrum id,
  congue, and nibh More...  </p>
</section>
<aside class="sidebar">
<h2>Categories</h2>
Aliquam libero
Consectetuer elit
Metus pellentesque
Suspendisse mauris
Urnanet molestie semper
Proin orci porttitor

<h2>Archives</h2>
September(23)
August(31)
July(31)
June(30)
(31)

<h2>Calendar</h2>

<p class="october">October 2017</p>
<ul class="weekdays">
  <li>M</li>
  <li>T</li>
  <li>W</li>
  <li>T</li>
  <li>F</li>
  <li>S</li>
  <li>S</li>
</ul>

<ul class="days">
  <li>1</li>
  <li>2</li>
  <li>3</li>
  <li>4</li>
  <li>5</li>
  <li>6</li>
  <li>7</li>
  <li>8</li>
  <li>9</li>
  <li><span class="active">10</span></li>
  <li>11</li>
  <li>12</li>
  <li>13</li>
  <li>14</li>
  <li>15</li>
  <li>16</li>
  <li>17</li>
  <li>18</li>
  <li>19</li>
  <li>20</li>
  <li>21</li>
  <li>22</li>
  <li>23</li>
  <li>24</li>
  <li>25</li>
  <li>26</li>
  <li>27</li>
  <li>28</li>
  <li>29</li>
  <li>30</li>
  <li>31</li>
</ul>
</aside>
</div>
</body>

</html></code>```

I'm wondering changes I can make to my code in order to make the search bar be right next to the navbar while getting rid of the excess space that the navbar has.

答:
html {
background-color: lightgrey;
font-size: 100%;
}

body{
  margin: 5%;
  margin-top: 0;
  font-family: Georgia, "Times New Roman", Times, serif, Arial, Helvetica, sans-serif;

}

/* Navigation Bar*/
nav ul{
  list-style-type: none;
  margin: 0;
  padding: 0;
  overflow: hidden;
  background-color: #e9eed0
}

#current a{
    background-color: #b8d03b;
    color: white;
}

.nav li {
  float: left;
  border-right: 1px solid #bbb
}

.nav li a {
  display: block;
  color: #8c8f7d;
  text-align: center;
  padding: 14px 16px;
  text-decoration: none;
}

/* Search Bar */

.search {
  float: right;
}
 /* Heading */
.heading{
  background-color: #f6f6f6;
  border: 1px solid #b8d03b;
  border-bottom:.5px solid #b8d03b;
}

/* Main text area */

.main {
  display: block;
  background-color: #ffffff;
  color: grey;
  border: 1px solid #b8d03b;
  float: left;
}

.content{
  width: 50%;
  float: left;
  padding: 5px 15px;
}

.middle{
  width:30%;
  float: left;
  padding: 5px 15px;
  margin: 0px 5px 5px 5px;
}

.sidebar{
  width: 10%;
  padding: 5px 15px;
  float: left;
}

/* Calendar */
.october{
  text-align: center;
}
.weekdays {
    margin: 0;
    padding: 10px 0;
    background-color: #cccccc;
    text-align: center;
}

.weekdays li {
    display: inline-block;
    color: #ffffff;
    width: 10%;
    text-align: center;
}

.days {
    text-align: center;
    padding: 10px 0;
    background: #eee;
    margin: 0;
}

.days li {
    list-style-type: none;
    display: inline-block;
    width: 10%;
    text-align: center;
    margin-bottom: 5px;
    font-size:12px;
    color: #777;
}

.days li .active {
    color: #3c8cd7 !important
}

/** Added ***/
      nav{
        width: 100%;
      }
      .navbar{
        float: left
      }
      .search{
        float: right;
      }
      .clearfix{
        clear: both;
      }```
<pre class="snippet-code-html lang-html prettyprint-override"><code><!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8"/>
  <title> Final Project </title>
  <link rel="stylesheet" href="style.css">
  <style>
  nav{
    width: 100%;
  }
  .navbar{
    float: left
  }
  .search{
    float: right;
  }
  .clearfix{
    clear: both;
  }
  </style>
</head>

<body>
  <header role='banner'>
    <nav>
      <div class="navbar">
        <ul class="nav">
          <li id="current">Home </li>
          <li>ELA </li>
          <li> Photos</li>
          <li> About</li>
          <li> Contact</li>
        </ul>
      </div>
      <div class="search">
        <form method="get" action="search-results.php" role="search">
          <label for="search"> Search: </label>
          <input type="search" size="30">
          <input type="submit" value="Search" />
        </form>
      </div>
      <div class="clearfix"></div>
    </nav>
  </header>

  <div class="heading">
    <p><span> News Flash</span> By Guillermo Molina </p>
    <p><small>>> Home</small></p>
  </div>
  <div class="main">

    <article class="content">
      <p><small>posted on Novermber 16, 2017 by Guillermo Molina</small></p>
      <h1>About This Template</h1>
      <p><strong>News Flash</strong> Denec leo. Vivamus fermnetum nibh in augue.
        Praesent a lacus at erna congue rutrum. Nulla enim erosm porttitor eu, tempus
        id, varius non, nib. Duis enim nula luctus eu, dapibus lacinia, venenatis id  quam.
        Vestibulum imperdiet, magna nec eleifend rutrum, nunc lectus vestibulum velit, euismod lacinia quam nisl id lorem. Quisque erat.
      </p>

      <p>Vestibulum imperdiet, magna nec eleifend rutrum, nunc lectus vestibulum
      velit, euismod lacinia quam nisl id lorem. Quisque erat.</p>

      <h2>A Heading Level 2</h2>
      <p>This paragraph is followed by a sample unordered list:</p>

      <ul>
        <li>Consectetuer adipiscing elit</li>
        <li>Metus aliquam pellentesque</li>
        <li>Urnanet non molestie semper</li>
        <li>Proin gravida orci porttitor</li>
      </ul>

      <h3>Heading Level 3</h3>
      <p>While this is followed by a blockquote:</p>
      <blockquote cite="http://www.google.com">
        Donec leo, vivamus nibh in augue praesent a lacus at urna congue rutrum. Quisque dictum integer nisl risus, sagittis convallis,
        rutrum id, congue, and nibh.
      </blockquote>
      <p> Comments(33) Permalink </p>

      <hr>
      <p>TAGS: DOLOR IPSUM SIT AMET DOLOR IPSUM LOREM SIT AMET </p>

    </article>

    <section class="middle">
      <h2>Recent Posts</h2>
      <h3>Aliquam Libero</h3>
      <p>Nullam ante orci, eget, tempus quis, ultrices in, est. Curabitur sit amet nulla. Nam in massa. Sed vel tellus. Curabitur sem urna,
        consequat vel, sescipit in, mattis placerat, nulla. Sed ac leo. Pellentesque imperdiet.More...</p>
        <h3>Semper Vestibulum</h3>
        <p>DOnec leo, vivamus fermentum nibh in augue praesent a lacus at urna congue rutrum. Quisque dictum integer nisl risus, sagittis convallis, rutrum id,
          congue, and nibh More...  </p>
        </section>
        <aside class="sidebar">
          <h2>Categories</h2>
          Aliquam libero
          Consectetuer elit
          Metus pellentesque
          Suspendisse mauris
          Urnanet molestie semper
          Proin orci porttitor

          <h2>Archives</h2>
          September(23)
          August(31)
          July(31)
          June(30)
          (31)

          <h2>Calendar</h2>

          <p class="october">October 2017</p>
          <ul class="weekdays">
            <li>M</li>
            <li>T</li>
            <li>W</li>
            <li>T</li>
            <li>F</li>
            <li>S</li>
            <li>S</li>
          </ul>

          <ul class="days">
            <li>1</li>
            <li>2</li>
            <li>3</li>
            <li>4</li>
            <li>5</li>
            <li>6</li>
            <li>7</li>
            <li>8</li>
            <li>9</li>
            <li><span class="active">10</span></li>
            <li>11</li>
            <li>12</li>
            <li>13</li>
            <li>14</li>
            <li>15</li>
            <li>16</li>
            <li>17</li>
            <li>18</li>
            <li>19</li>
            <li>20</li>
            <li>21</li>
            <li>22</li>
            <li>23</li>
            <li>24</li>
            <li>25</li>
            <li>26</li>
            <li>27</li>
            <li>28</li>
            <li>29</li>
            <li>30</li>
            <li>31</li>
          </ul>
        </aside>
      </div>
    </body>

    </html></code>```

You have to add some more classes,

extra css

```<code>  nav{
    width: 100%;
  }
  .navbar{
    float: left
  }
  .search{
    float: right;
  }
  .clearfix{
    clear: both;
  }
</code>```

And nav html little modified

```<code><nav>
  <div class="navbar">
    <ul class="nav">
      <li id="current"><a href="index.html">Home </a></li>
      <li><a href="ela.html">ELA</a> </li>
      <li><a href="photos.html"> Photos</a></li>
      <li> <a href="about.html">About</a></li>
      <li> <a href="contacts.html">Contact</a></li>
    </ul>
  </div>
  <div class="search">
    <form method="get" action="search-results.php" role="search">
      <label for="search"> Search: </label>
      <input type="search" size="30">
      <input type="submit" value="Search" />
    </form>
  </div>
  <div class="clearfix"></div>
</nav>
</code>```

Just use the float:right and float:left and then clear:both.
Check this..

Title: NavBar and Search Bar in the same line

Body:
so I have this project where I was given a screenshot of a website and have to replicate it while using HTML and CSS code purely. But I have gotten myself into a little predicament where my navbar has excess space that I don't want because I want a search bar to go where that excess space is at.

html {
background-color: lightgrey;
font-size: 100%;
}

body{
  margin: 5%;
  margin-top: 0;
  font-family: Georgia, "Times New Roman", Times, serif, Arial, Helvetica, sans-serif;

}

/* Navigation Bar*/
nav ul{
  list-style-type: none;
  margin: 0;
  padding: 0;
  overflow: hidden;
  background-color: #e9eed0
}

#current a{
    background-color: #b8d03b;
    color: white;
}

.nav li {
  float: left;
  border-right: 1px solid #bbb
}

.nav li a {
  display: block;
  color: #8c8f7d;
  text-align: center;
  padding: 14px 16px;
  text-decoration: none;
}

/* Search Bar */

.search {
  float: right;
}
 /* Heading */
.heading{
  background-color: #f6f6f6;
  border: 1px solid #b8d03b;
  border-bottom:.5px solid #b8d03b;
}

/* Main text area */

.main {
  display: block;
  background-color: #ffffff;
  color: grey;
  border: 1px solid #b8d03b;
  float: left;
}

.content{
  width: 50%;
  float: left;
  padding: 5px 15px;
}

.middle{
  width:30%;
  float: left;
  padding: 5px 15px;
  margin: 0px 5px 5px 5px;
}

.sidebar{
  width: 10%;
  padding: 5px 15px;
  float: left;
}

/* Calendar */
.october{
  text-align: center;
}
.weekdays {
    margin: 0;
    padding: 10px 0;
    background-color: #cccccc;
    text-align: center;
}

.weekdays li {
    display: inline-block;
    color: #ffffff;
    width: 10%;
    text-align: center;
}

.days {
    text-align: center;
    padding: 10px 0;
    background: #eee;
    margin: 0;
}

.days li {
    list-style-type: none;
    display: inline-block;
    width: 10%;
    text-align: center;
    margin-bottom: 5px;
    font-size:12px;
    color: #777;
}

.days li .active {
    color: #3c8cd7 !important
}

<!DOCTYPE html>

<meta charset="utf-8"/>
<title> Final Project </title>
<link rel="stylesheet" href="style.css">

Home

ELA

 Photos

 About

 Contact

    <form method="get" action="search-results.php" role="search">
       Search:
      <input type="search" size="30">
      <input type="submit" value="Search" />

 News Flash By Guillermo Molina

>> Home

posted on Novermber 16, 2017 by Guillermo Molina

About This Template

News Flash Denec leo. Vivamus fermnetum nibh in augue.
  Praesent a lacus at erna congue rutrum. Nulla enim erosm porttitor eu, tempus
id, varius non, nib. Duis enim nula luctus eu, dapibus lacinia, venenatis id  quam.
 Vestibulum imperdiet, magna nec eleifend rutrum, nunc lectus vestibulum velit, euismod lacinia quam nisl id lorem. Quisque erat.

Vestibulum imperdiet, magna nec eleifend rutrum, nunc lectus vestibulum
velit, euismod lacinia quam nisl id lorem. Quisque erat.

A Heading Level 2

This paragraph is followed by a sample unordered list:

Consectetuer adipiscing elit

Metus aliquam pellentesque

Urnanet non molestie semper

Proin gravida orci porttitor

Heading Level 3

While this is followed by a blockquote:

  Donec leo, vivamus nibh in augue praesent a lacus at urna congue rutrum. Quisque dictum integer nisl risus, sagittis convallis,
  rutrum id, congue, and nibh.

 Comments(33) Permalink

TAGS: DOLOR IPSUM SIT AMET DOLOR IPSUM LOREM SIT AMET

Recent Posts

Aliquam Libero

Nullam ante orci, eget, tempus quis, ultrices in, est. Curabitur sit amet nulla. Nam in massa. Sed vel tellus. Curabitur sem urna,
  consequat vel, sescipit in, mattis placerat, nulla. Sed ac leo. Pellentesque imperdiet.More...

Semper Vestibulum

DOnec leo, vivamus fermentum nibh in augue praesent a lacus at urna congue rutrum. Quisque dictum integer nisl risus, sagittis convallis, rutrum id,
  congue, and nibh More...

Categories

Aliquam libero
Consectetuer elit
Metus pellentesque
Suspendisse mauris
Urnanet molestie semper
Proin orci porttitor

Archives

September(23)
August(31)
July(31)
June(30)
(31)

Calendar

October 2017

M

T

W

T

F

S

S

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

I'm wondering changes I can make to my code in order to make the search bar be right next to the navbar while getting rid of the excess space that the navbar has.

Body:
html {
background-color: lightgrey;
font-size: 100%;
}

body{
  margin: 5%;
  margin-top: 0;
  font-family: Georgia, "Times New Roman", Times, serif, Arial, Helvetica, sans-serif;

}

/* Navigation Bar*/
nav ul{
  list-style-type: none;
  margin: 0;
  padding: 0;
  overflow: hidden;
  background-color: #e9eed0
}

#current a{
    background-color: #b8d03b;
    color: white;
}

.nav li {
  float: left;
  border-right: 1px solid #bbb
}

.nav li a {
  display: block;
  color: #8c8f7d;
  text-align: center;
  padding: 14px 16px;
  text-decoration: none;
}

/* Search Bar */

.search {
  float: right;
}
 /* Heading */
.heading{
  background-color: #f6f6f6;
  border: 1px solid #b8d03b;
  border-bottom:.5px solid #b8d03b;
}

/* Main text area */

.main {
  display: block;
  background-color: #ffffff;
  color: grey;
  border: 1px solid #b8d03b;
  float: left;
}

.content{
  width: 50%;
  float: left;
  padding: 5px 15px;
}

.middle{
  width:30%;
  float: left;
  padding: 5px 15px;
  margin: 0px 5px 5px 5px;
}

.sidebar{
  width: 10%;
  padding: 5px 15px;
  float: left;
}

/* Calendar */
.october{
  text-align: center;
}
.weekdays {
    margin: 0;
    padding: 10px 0;
    background-color: #cccccc;
    text-align: center;
}

.weekdays li {
    display: inline-block;
    color: #ffffff;
    width: 10%;
    text-align: center;
}

.days {
    text-align: center;
    padding: 10px 0;
    background: #eee;
    margin: 0;
}

.days li {
    list-style-type: none;
    display: inline-block;
    width: 10%;
    text-align: center;
    margin-bottom: 5px;
    font-size:12px;
    color: #777;
}

.days li .active {
    color: #3c8cd7 !important
}

/** Added ***/
      nav{
        width: 100%;
      }
      .navbar{
        float: left
      }
      .search{
        float: right;
      }
      .clearfix{
        clear: both;
      }

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8"/>
  <title> Final Project </title>
  <link rel="stylesheet" href="style.css">
  <style>
  nav{
    width: 100%;
  }
  .navbar{
    float: left
  }
  .search{
    float: right;
  }
  .clearfix{
    clear: both;
  }
  </style>
</head>

<body>
  <header role='banner'>
    <nav>
      <div class="navbar">
        <ul class="nav">
          <li id="current"><a href="index.html">Home </a></li>
          <li><a href="ela.html">ELA</a> </li>
          <li><a href="photos.html"> Photos</a></li>
          <li> <a href="about.html">About</a></li>
          <li> <a href="contacts.html">Contact</a></li>
        </ul>
      </div>
      <div class="search">
        <form method="get" action="search-results.php" role="search">
          <label for="search"> Search: </label>
          <input type="search" size="30">
          <input type="submit" value="Search" />
        </form>
      </div>
      <div class="clearfix"></div>
    </nav>
  </header>

  <div class="heading">
    <p><span> News Flash</span> By Guillermo Molina </p>
    <p><small>>> Home</small></p>
  </div>
  <div class="main">

    <article class="content">
      <p><small>posted on Novermber 16, 2017 by Guillermo Molina</small></p>
      <h1>About This Template</h1>
      <p><strong>News Flash</strong> Denec leo. Vivamus fermnetum nibh in augue.
        Praesent a lacus at erna congue rutrum. Nulla enim erosm porttitor eu, tempus
        id, varius non, nib. Duis enim nula luctus eu, dapibus lacinia, venenatis id  quam.
        Vestibulum imperdiet, magna nec eleifend rutrum, nunc lectus vestibulum velit, euismod lacinia quam nisl id lorem. Quisque erat.
      </p>

      <p>Vestibulum imperdiet, magna nec eleifend rutrum, nunc lectus vestibulum
      velit, euismod lacinia quam nisl id lorem. Quisque erat.</p>

      <h2>A Heading Level 2</h2>
      <p>This paragraph is followed by a sample unordered list:</p>

      <ul>
        <li><a href="https://www.google.com" target="_blank">Consectetuer adipiscing elit</a></li>
        <li><a href="https://www.google.com" target="_blank">Metus aliquam pellentesque</a></li>
        <li><a href="https://www.google.com" target="_blank">Urnanet non molestie semper</a></li>
        <li><a href="https://www.google.com" target="_blank">Proin gravida orci porttitor</a></li>
      </ul>

      <h3>Heading Level 3</h3>
      <p>While this is followed by a blockquote:</p>
      <blockquote cite="http://www.google.com">
        Donec leo, vivamus nibh in augue praesent a lacus at urna congue rutrum. Quisque dictum integer nisl risus, sagittis convallis,
        rutrum id, congue, and nibh.
      </blockquote>
      <p> <a href="https://www.google.com" target="_blank">Comments(33)</a> <a href="https://www.google.com">Permalink</a> </p>

      <hr>
      <p>TAGS: <a href="https://www.google.com">DOLOR IPSUM SIT AMET DOLOR IPSUM LOREM SIT AMET</a> </p>

    </article>

    <section class="middle">
      <h2>Recent Posts</h2>
      <h3>Aliquam Libero</h3>
      <p>Nullam ante orci, eget, tempus quis, ultrices in, est. Curabitur sit amet nulla. Nam in massa. Sed vel tellus. Curabitur sem urna,
        consequat vel, sescipit in, mattis placerat, nulla. Sed ac leo. Pellentesque imperdiet.<a href="https://www.google.com" target="_blank">More...</a></p>
        <h3>Semper Vestibulum</h3>
        <p>DOnec leo, vivamus fermentum nibh in augue praesent a lacus at urna congue rutrum. Quisque dictum integer nisl risus, sagittis convallis, rutrum id,
          congue, and nibh <a href="https://www.google.com" target="_blank">More...</a>  </p>
        </section>
        <aside class="sidebar">
          <h2>Categories</h2>
          <a href="https://www.google.com" target="_blank">Aliquam libero</a>
          <a href="https://www.google.com" target="_blank">Consectetuer elit</a>
          <a href="https://www.google.com" target="_blank">Metus pellentesque</a>
          <a href="https://www.google.com" target="_blank">Suspendisse mauris</a>
          <a href="https://www.google.com" target="_blank">Urnanet molestie semper</a>
          <a href="https://www.google.com" target="_blank">Proin orci porttitor</a>

          <h2>Archives</h2>
          <a href="https://www.google.com" target="_blank">September</a>(23)
          <a href="https://www.google.com" target="_blank">August</a>(31)
          <a href="https://www.google.com" target="_blank">July</a>(31)
          <a href="https://www.google.com" target="_blank">June</a>(30)
          <a href="https://www.google.com" target="_blank">(31)</a>

          <h2>Calendar</h2>

          <p class="october">October 2017</p>
          <ul class="weekdays">
            <li>M</li>
            <li>T</li>
            <li>W</li>
            <li>T</li>
            <li>F</li>
            <li>S</li>
            <li>S</li>
          </ul>

          <ul class="days">
            <li>1</li>
            <li>2</li>
            <li>3</li>
            <li>4</li>
            <li>5</li>
            <li>6</li>
            <li>7</li>
            <li>8</li>
            <li>9</li>
            <li><span class="active">10</span></li>
            <li>11</li>
            <li>12</li>
            <li>13</li>
            <li>14</li>
            <li>15</li>
            <li>16</li>
            <li>17</li>
            <li>18</li>
            <li>19</li>
            <li>20</li>
            <li>21</li>
            <li>22</li>
            <li>23</li>
            <li>24</li>
            <li>25</li>
            <li>26</li>
            <li>27</li>
            <li>28</li>
            <li>29</li>
            <li>30</li>
            <li>31</li>
          </ul>
        </aside>
      </div>
    </body>

    </html>

You have to add some more classes,

extra css

  nav{
    width: 100%;
  }
  .navbar{
    float: left
  }
  .search{
    float: right;
  }
  .clearfix{
    clear: both;
  }

And nav html little modified

<nav>
  <div class="navbar">
    <ul class="nav">
      <li id="current"><a href="index.html">Home </a></li>
      <li><a href="ela.html">ELA</a> </li>
      <li><a href="photos.html"> Photos</a></li>
      <li> <a href="about.html">About</a></li>
      <li> <a href="contacts.html">Contact</a></li>
    </ul>
  </div>
  <div class="search">
    <form method="get" action="search-results.php" role="search">
      <label for="search"> Search: </label>
      <input type="search" size="30">
      <input type="submit" value="Search" />
    </form>
  </div>
  <div class="clearfix"></div>
</nav>

Just use the float:right and float:left and then clear:both.
Check this..


来源: stackexchange

问:
Updating time without refreshing the page with Javascript
I'm building an app that displays the current time without have to refresh.
I'm calling the time below, but when I display it I have to refresh the page to update the time. How do I continuously update the time?</p>

```<code>function GetTime(){
var today = new Date();
var hour = today.getHours();
var minute = today.getMinutes();

        if (hour>=12){                  //Adding endings
                suffix = "P.M.";}
        else{
                suffix = "A.M.";}

minute = addZero(minute);       //Call addZero function
hour = removeMilitary(hour);    //Call removeMilitary Function

var fullTime = hour + ":" + minute + " " + suffix;  //Combine hour minute and the suffix

        function addZero(number){
                        if (number<10){
                            number = "0" + number;
                        }
                        return number;
        }

        function removeMilitary(hour){ //This function can be removed if desired by user.

            if (hour > 0 && hour <= 12) {
                hour = "" + hour;
            } else if (hour > 12) {
                hour = "" + (hour - 12);
            } else if (hour == 0) {
                hour= "12";
            }
            return hour;
        }
return fullTime;

}
</code>```

答:
UPDATE I forgot the setInterval but someone else already pointed at it, so mix both answers and you're done!

Look at getElementById and innerHTML.

Something like the following snippet at the end of your function (instead of return fulltime ) should work:

```<code>...
var myElement = documentGetElementById('mydiv');
myElement.innerHTML = fulltime;
...
</code>```

Of course you need to define some HTML element with

 or whatever you choose.

ContentLicense: CC BY-SA 3.0

Body:
I'm building an app that displays the current time without have to refresh.
I'm calling the time below, but when I display it I have to refresh the page to update the time. How do I continuously update the time?

function GetTime(){
var today = new Date();
var hour = today.getHours();
var minute = today.getMinutes();

        if (hour>=12){                  //Adding endings
                suffix = "P.M.";}
        else{
                suffix = "A.M.";}

minute = addZero(minute);       //Call addZero function
hour = removeMilitary(hour);    //Call removeMilitary Function

var fullTime = hour + ":" + minute + " " + suffix;  //Combine hour minute and the suffix

        function addZero(number){
                        if (number<10){
                            number = "0" + number;
                        }
                        return number;
        }

        function removeMilitary(hour){ //This function can be removed if desired by user.

            if (hour > 0 && hour <= 12) {
                hour = "" + hour;
            } else if (hour > 12) {
                hour = "" + (hour - 12);
            } else if (hour == 0) {
                hour= "12";
            }
            return hour;
        }
return fullTime;

}

Body:
UPDATE I forgot the setInterval but someone else already pointed at it, so mix both answers and you're done!

Look at getElementById and innerHTML.

Something like the following snippet at the end of your function (instead of return fulltime ) should work:

...
var myElement = documentGetElementById('mydiv');
myElement.innerHTML = fulltime;
...

Of course you need to define some HTML element with <div id="mydiv"></div> or whatever you choose.


问:
Automate the Boring Stuff With Python Madlibs Project With Shelve Module
I've been learning python as my first coding language with the book 'Automate the Boring Stuff With Python', and after the chapter about reading/writing files and using the shelve module I managed to create the madlibs program. The only problem is I am sure I was suppose to use the shelve module, but I am still not sure how that works. Here is the code:

```<code>import re

basemadlibs = open('C:\\Users\\Username\\Desktop\\MADLIBS.txt', 'r')
#creates a string out of the contents of the madlibs file
newmadlibslist = list(basemadlibs.read())
newtext = ''.join(newmadlibslist)
#regex for finding placeholders(VERB, ADJECTIVE, ect.) in the  madlibs file content
placeholders = re.compile(r'[A-Z]{2,10}')
#replaces the placeholders with a %s
emptytext = placeholders.sub('%s', newtext)
#creates a list of inputs to substitute the %s in the emptystring
replacements = []
for i in range(len(placeholders.findall(newtext))):
    print('type a\\an: ' + placeholders.findall(newtext)[i])
    replacement = input()
    replacements.append(replacement)
#string formats the %s placeholders with the replacements
madlibcompleted = emptytext % tuple(replacements)
#prints the completed mad lib
print(madlibcompleted)
#saves a copy of the completed madlib to the desktop called 'alterdMADLIBS.txt'
alteredmadlibs = open('C:\\users\\Username\\Desktop\\alteredMADLIBS.txt', 'w')
alteredmadlibs.write(madlibcompleted)
alteredmadlibs.close()
basemadlibs.close()
</code>```

Can someone explain to me how the shelve module would make this more efficient? Thanks!

答:
The only problem is I am sure I was suppose to use the shelve module, but I am still not sure how that works.

No, that's not mandatory. Though, it is mandatory for the previous problem. For this problem, you must use files, since you've also learned files in the same chapter.

Anyway, this is my code:

```<code>#!/usr/bin/python

import re

file = open('madlibs')
text = file.read()
file.close()

regex = re.compile(r'(ADJECTIVE)|(NOUN)|(VERB)')

for i in regex.findall(text):
    for j in i:
        if j != '':
            reg = re.compile(r'{}'.format(j))
            inp_text = input('Enter the substitute for %s: ' %j)
            text = reg.sub(inp_text, text, 1)

print(text)

file = open('madlibs_ans', 'w')
file.write(text)
file.close()
</code>```

For me, this looks simpler. : )

Body:
I've been learning python as my first coding language with the book 'Automate the Boring Stuff With Python', and after the chapter about reading/writing files and using the shelve module I managed to create the madlibs program. The only problem is I am sure I was suppose to use the shelve module, but I am still not sure how that works. Here is the code:

import re

basemadlibs = open('C:\\Users\\Username\\Desktop\\MADLIBS.txt', 'r')
#creates a string out of the contents of the madlibs file
newmadlibslist = list(basemadlibs.read())
newtext = ''.join(newmadlibslist)
#regex for finding placeholders(VERB, ADJECTIVE, ect.) in the  madlibs file content
placeholders = re.compile(r'[A-Z]{2,10}')
#replaces the placeholders with a %s
emptytext = placeholders.sub('%s', newtext)
#creates a list of inputs to substitute the %s in the emptystring
replacements = []
for i in range(len(placeholders.findall(newtext))):
    print('type a\\an: ' + placeholders.findall(newtext)[i])
    replacement = input()
    replacements.append(replacement)
#string formats the %s placeholders with the replacements
madlibcompleted = emptytext % tuple(replacements)
#prints the completed mad lib
print(madlibcompleted)
#saves a copy of the completed madlib to the desktop called 'alterdMADLIBS.txt'
alteredmadlibs = open('C:\\users\\Username\\Desktop\\alteredMADLIBS.txt', 'w')
alteredmadlibs.write(madlibcompleted)
alteredmadlibs.close()
basemadlibs.close()

Can someone explain to me how the shelve module would make this more efficient? Thanks!

Body:
The only problem is I am sure I was suppose to use the shelve module, but I am still not sure how that works.

No, that's not mandatory. Though, it is mandatory for the previous problem. For this problem, you must use files, since you've also learned files in the same chapter.

Anyway, this is my code:

#!/usr/bin/python

import re

file = open('madlibs')
text = file.read()
file.close()

regex = re.compile(r'(ADJECTIVE)|(NOUN)|(VERB)')

for i in regex.findall(text):
    for j in i:
        if j != '':
            reg = re.compile(r'{}'.format(j))
            inp_text = input('Enter the substitute for %s: ' %j)
            text = reg.sub(inp_text, text, 1)

print(text)

file = open('madlibs_ans', 'w')
file.write(text)
file.close()

For me, this looks simpler. : )

ContentLicense: CC BY-SA 4.0


问:
How to get all records from one table between dates of column in another table
I'm using sql server, I have a queues table has a column called process_date, and a users table has a column called process_date, there is no relation between the two tables. I want to get all users that has been processed with one queue depending on process_date (I have the queue_id and I want to return all users that have been processed with that queue)
How can I write a query to do so?

update: the process_date is date time so it's not a match for the queue and the users, that's why I needed to get the process date for the previous queue and then the current queue and then get the users that were processed in that date range

答:
With so little detail to work with any answer will likewise be "thin on detail" too. e.g.

```<code>select * from users u
inner join queue q on u.process_date = q.process_date
</code>```

or if there is some form of delay then perhaps a small time range may be needed: e.g.

```<code>select * from users u
inner join queue q on u.process_date between q.process_date and dateadd(minute,1,q.process_date)
</code>```

Body:
With so little detail to work with any answer will likewise be "thin on detail" too. e.g.

select * from users u
inner join queue q on u.process_date = q.process_date

or if there is some form of delay then perhaps a small time range may be needed: e.g.

select * from users u
inner join queue q on u.process_date between q.process_date and dateadd(minute,1,q.process_date)


问:
View controller not displaying subviews correctly when programmatically set as root view controller

I've been building my view controllers programmatically by setting a custom view in the loadView() method. While changing my root view controller in AppDelegate to a specified view controller, I've noticed that the view controller does not display it's subviews properly laid out, if it even gets displayed. Using the view debugger, I see that the views are seen as being in the view hierarchy but they are no where to be found, so I end up with blank view controller. What's odd is that when I instead present the view controller from another view controller, only then is it properly laid out and all views are visible. My view controllers all follow the same creation shown below.

```<code>class ViewController: UIViewController {

    private var rootView: View? {
        get { return self.viewIfLoaded as? View ?? .none }
        set (view) { self.view = view }
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

    init() {
        super.init(nibName: nil, bundle: nil)
    }

    override func viewDidLoad() {
        super.viewDidLoad()
    }

    override func loadView() {
        self.rootView = View()
    }

}
</code>```

And here is how I am creating my custom views for my view controllers

```<code>class View: UIView {

    // Lazy declare views here

    fileprivate var shouldSetupConstraints = true

    override init(frame: CGRect) {
        super.init(frame: frame)
        setupView()
    }

    required init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
        setupView()
    }

    override func updateConstraints() {
        if(shouldSetupConstraints) {

            // Adding constraints here

            shouldSetupConstraints = false
        }
        super.updateConstraints()
    }

    func setupView() {

        // Adding subviews here

    }

}
</code>```

Here is how I am setting the root view controller in my AppDelegate

```<code>func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {

    window = UIWindow(frame: UIScreen.main.bounds)
    window?.backgroundColor = Palette.backgroundColor
    window?.rootViewController = MyViewController()
    window?.makeKeyAndVisible()
    return true

}
</code>```

I expect my programmatically laid out view controllers to be displayed properly while being set as the root view controller, but instead the views are not visible or not laid out properly. They are only displaying correctly when the view controller is presented by another view controller.

答:
Looks like this behavior was being caused by not setting

self.translatesAutoresizingMaskIntoConstraints = false

in setupView() in my custom view.

Body:
I've been building my view controllers programmatically by setting a custom view in the loadView() method. While changing my root view controller in AppDelegate to a specified view controller, I've noticed that the view controller does not display it's subviews properly laid out, if it even gets displayed. Using the view debugger, I see that the views are seen as being in the view hierarchy but they are no where to be found, so I end up with blank view controller. What's odd is that when I instead present the view controller from another view controller, only then is it properly laid out and all views are visible. My view controllers all follow the same creation shown below.

class ViewController: UIViewController {

    private var rootView: View? {
        get { return self.viewIfLoaded as? View ?? .none }
        set (view) { self.view = view }
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

    init() {
        super.init(nibName: nil, bundle: nil)
    }

    override func viewDidLoad() {
        super.viewDidLoad()
    }

    override func loadView() {
        self.rootView = View()
    }

}

And here is how I am creating my custom views for my view controllers

class View: UIView {

    // Lazy declare views here

    fileprivate var shouldSetupConstraints = true

    override init(frame: CGRect) {
        super.init(frame: frame)
        setupView()
    }

    required init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
        setupView()
    }

    override func updateConstraints() {
        if(shouldSetupConstraints) {

            // Adding constraints here

            shouldSetupConstraints = false
        }
        super.updateConstraints()
    }

    func setupView() {

        // Adding subviews here

    }

}

Here is how I am setting the root view controller in my AppDelegate

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {

    window = UIWindow(frame: UIScreen.main.bounds)
    window?.backgroundColor = Palette.backgroundColor
    window?.rootViewController = MyViewController()
    window?.makeKeyAndVisible()
    return true

}

I expect my programmatically laid out view controllers to be displayed properly while being set as the root view controller, but instead the views are not visible or not laid out properly. They are only displaying correctly when the view controller is presented by another view controller.


问:
Make an array from input field
I want create an array like this from input field.

```<code>$array = array(
    array (
        'menu_primary' => 'Primary 1',
        'menu_secondary' => array( 'Secondary 1', 'Secondary 2', 'Secondary N' ),
    ),

    array (
        'menu_primary' => 'Primary 2',
        'menu_secondary' => array( 'Secondary 1', 'Secondary 2', 'Secondary N' ),
    ),

    array (
        'menu_primary' => 'Primary N',
        'menu_secondary' => array( 'Secondary 1', 'Secondary 2', 'Secondary N' ),
    ),
);
</code>```

I try this method, but not working fine.

```<code><input type='text' name='front_page_options_settings[menu_primary][menu_primary][]' value=''>
    <input type='text' name='front_page_options_settings[menu_primary][menu_primary][menu_secondary][]' value=''>
    <input type='text' name='front_page_options_settings[menu_primary][menu_primary][menu_secondary][]' value=''>

    <input type='text' name='front_page_options_settings[menu_primary][menu_primary][]' value=''>
    <input type='text' name='front_page_options_settings[menu_primary][menu_primary][menu_secondary][]' value=''>
    <input type='text' name='front_page_options_settings[menu_primary][menu_primary][menu_secondary][]' value=''>
</code>```

Please help.

答:
You can use for loop and add the key of primary to [] instead.

```<code><?php foreach($array as $menu_arrays): ?>
    <?php foreach($menu_arrays as $pri_key => $menu_array): ?>

        <!-- Primary Menu -->
        <input type='text' name='front_page_options_settings[menu_primary][<?php echo $key; ?>]' value='<?php echo $menu_array['menu_primary']?>'>

        <!-- Secondary Menu -->
        <?php foreach($menu_secondary as $sec_key => $secondary): ?>
        <input type='text' name='front_page_options_settings[menu_primary][<?php echo $key; ?>][]' value='<?php echo $secondary; ?>'>
        <?php endforeach;?>
    <?php ?>
<?php ?>
</code>```

You can just remove the echo in value if you don't want it.
For getting the of array inputs. You can refer to this
Html/PHP - Form - Input as array

Title: Make an array from input field

Body:
I want create an array like this from input field.

$array = array(
    array (
        'menu_primary' => 'Primary 1',
        'menu_secondary' => array( 'Secondary 1', 'Secondary 2', 'Secondary N' ),
    ),

    array (
        'menu_primary' => 'Primary 2',
        'menu_secondary' => array( 'Secondary 1', 'Secondary 2', 'Secondary N' ),
    ),

    array (
        'menu_primary' => 'Primary N',
        'menu_secondary' => array( 'Secondary 1', 'Secondary 2', 'Secondary N' ),
    ),
);

I try this method, but not working fine.

<input type='text' name='front_page_options_settings[menu_primary][menu_primary][]' value=''>
    <input type='text' name='front_page_options_settings[menu_primary][menu_primary][menu_secondary][]' value=''>
    <input type='text' name='front_page_options_settings[menu_primary][menu_primary][menu_secondary][]' value=''>

    <input type='text' name='front_page_options_settings[menu_primary][menu_primary][]' value=''>
    <input type='text' name='front_page_options_settings[menu_primary][menu_primary][menu_secondary][]' value=''>
    <input type='text' name='front_page_options_settings[menu_primary][menu_primary][menu_secondary][]' value=''>

Please help.

Body:
You can use for loop and add the key of primary to [] instead.

<?php foreach($array as $menu_arrays): ?>
    <?php foreach($menu_arrays as $pri_key => $menu_array): ?>

        <!-- Primary Menu -->
        <input type='text' name='front_page_options_settings[menu_primary][<?php echo $key; ?>]' value='<?php echo $menu_array['menu_primary']?>'>

        <!-- Secondary Menu -->
        <?php foreach($menu_secondary as $sec_key => $secondary): ?>
        <input type='text' name='front_page_options_settings[menu_primary][<?php echo $key; ?>][]' value='<?php echo $secondary; ?>'>
        <?php endforeach;?>
    <?php ?>
<?php ?>

You can just remove the echo in value if you don't want it.
For getting the of array inputs. You can refer to this
Html/PHP - Form - Input as array


问:
System.ServiceModel.AddressAccessDeniedException: HTTP could not register URL http::8080
I have created my first self-hosted WCF service. I hosted it in a C# console app but it throws an error:

System.ServiceModel.AddressAccessDeniedException: HTTP could not register URL http: 8080

When I run Visual Studio 2013 as administrator, then it works well, but not if I don't. So any way to get it done automatically instead of starting VS as an ADMIN?

So far I created a HelloService class library in which I added a WCF service which consists of an interface IHelloService and HelloService.

IHelloService:

```<code>namespace HelloService
{
    [ServiceContract]
    public interface IHelloService
    {
        [OperationContract]
        String GetMsg();
    }
}
</code>```

HelloService:

```<code>namespace HelloService
{
    public class HelloService : IHelloService
    {
        public String GetMsg()
        {
            return "Service Accessed";
        }
    }
}
</code>```

Then I created a C# console app HelloServiceHost which has an app.config file:

```<code><?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <system.serviceModel>
    <behaviors>
      <serviceBehaviors >
        <behavior name="MexBehaviour">
          <serviceMetadata httpGetEnabled="true"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <services>
      <service name="HelloService.HelloService"
               behaviorConfiguration="MexBehaviour" >
        <endpoint
            address="HelloService"
            binding="basicHttpBinding"
            contract="HelloService.IHelloService"></endpoint>
        <endpoint
            address="HelloService"
            binding="netTcpBinding"
            contract="HelloService.IHelloService"></endpoint>
        <endpoint
            address="mex"
            binding="mexHttpBinding"
            contract="IMetadataExchange"></endpoint>
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:8080/"/>
            <add baseAddress="net.tcp://localhost:8081/"/>
          </baseAddresses>
        </host>
      </service>
    </services>
  </system.serviceModel>
</configuration>
</code>```

and program.cs file:

```<code>using HelloService;
using System.ServiceModel;

namespace HelloServiceHost
{
    class Program
    {
        static void Main(string[] args)
        {
            using(ServiceHost sh = new ServiceHost(typeof(HelloService.HelloService)))
            {
                sh.Open();
                Console.WriteLine("Host Started @"+ System.DateTime.UtcNow.ToShortDateString());
                sh.Close();
            }
        }
    }
}
</code>```

I followed a video tutorial exactly but it's not working why ?

I am using VS 2013, .net 4

答:
Root path URL (http://+:8080/) permissions are needed in your case:

```<code>netsh http add urlacl url=http://+:8080/ user=%USERDOMAIN%\%USERNAME%
</code>```

show all URL reservations:

```<code>netsh http show urlacl | FIND "URL"
</code>```

Body:
I have created my first self-hosted WCF service. I hosted it in a C# console app but it throws an error:

System.ServiceModel.AddressAccessDeniedException: HTTP could not register URL http: 8080

When I run Visual Studio 2013 as administrator, then it works well, but not if I don't. So any way to get it done automatically instead of starting VS as an ADMIN?

So far I created a HelloService class library in which I added a WCF service which consists of an interface IHelloService and HelloService.

IHelloService:

namespace HelloService
{
    [ServiceContract]
    public interface IHelloService
    {
        [OperationContract]
        String GetMsg();
    }
}

HelloService:

namespace HelloService
{
    public class HelloService : IHelloService
    {
        public String GetMsg()
        {
            return "Service Accessed";
        }
    }
}

Then I created a C# console app HelloServiceHost which has an app.config file:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <system.serviceModel>
    <behaviors>
      <serviceBehaviors >
        <behavior name="MexBehaviour">
          <serviceMetadata httpGetEnabled="true"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <services>
      <service name="HelloService.HelloService"
               behaviorConfiguration="MexBehaviour" >
        <endpoint
            address="HelloService"
            binding="basicHttpBinding"
            contract="HelloService.IHelloService"></endpoint>
        <endpoint
            address="HelloService"
            binding="netTcpBinding"
            contract="HelloService.IHelloService"></endpoint>
        <endpoint
            address="mex"
            binding="mexHttpBinding"
            contract="IMetadataExchange"></endpoint>
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:8080/"/>
            <add baseAddress="net.tcp://localhost:8081/"/>
          </baseAddresses>
        </host>
      </service>
    </services>
  </system.serviceModel>
</configuration>

and program.cs file:

using HelloService;
using System.ServiceModel;

namespace HelloServiceHost
{
    class Program
    {
        static void Main(string[] args)
        {
            using(ServiceHost sh = new ServiceHost(typeof(HelloService.HelloService)))
            {
                sh.Open();
                Console.WriteLine("Host Started @"+ System.DateTime.UtcNow.ToShortDateString());
                sh.Close();
            }
        }
    }
}

I followed a video tutorial exactly but it's not working why ?

I am using VS 2013, .net 4

Body:
Root path URL (http://+:8080/) permissions are needed in your case:

netsh http add urlacl url=http://+:8080/ user=%USERDOMAIN%\%USERNAME%

show all URL reservations:

netsh http show urlacl | FIND "URL"


问:
Rerunning program on MARS-simulator without resetting memory
I want to test my program on random inputs, but each time I reset it, all of the registers and data reset.

Is it possible to run the program again without the registers and data resetting each time?

答:
I think you want to check that your code doesn't depend on some registers or memory being zero.  This is the low-level version of checking for use of uninitialized variables in higher level languages like C.

The industrial-strength version of this is Valgrind, which does support MIPS.  IDK if you can build it to run inside SPIM, though; it's designed to run on real OSes like Linux (on MIPS).  It only tracks memory, not uninitialized registers, though (because most people use it on asm generated by compilers, which generally don't have this problem).  See for example pinpointing "conditional jump or move depends on uninitialized value(s)" valgrind message.

For your purposes, your best bet is to manually put "poison" values into all your registers, and as much memory as you want.  The values that were present at the end of the last run are less likely to be good choices; that wouldn't catch a problem where either the initial zero or the value you write later both happen to work for some code that reads it before the write.

For example, 0xDEADBEEF is a good constant that you can recognize if you see it while debugging or in your program's output.  It's also unlikely to be a valid pointer or index.  See that link for more about what makes good poison.

e.g.

```<code>li  $t0,  0xDEADBEEF
move $t1, $t0
move $t2, $t0
...
</code>```

You can probably write a macro to repeat it for all registers except the stack pointer, especially if you use the "raw" register numbers like $1, $2, etc.  (mapping table from semantic names to raw names.  Probably your macro should init everything except $29 ($sp), including $1 ($at) and the kernel-temporary regs).  To write a macro like that, use text substitution to create $1..$28, after putting your constant into $30 and $31.

Body:
I think you want to check that your code doesn't depend on some registers or memory being zero.  This is the low-level version of checking for use of uninitialized variables in higher level languages like C.

The industrial-strength version of this is Valgrind, which does support MIPS.  IDK if you can build it to run inside SPIM, though; it's designed to run on real OSes like Linux (on MIPS).  It only tracks memory, not uninitialized registers, though (because most people use it on asm generated by compilers, which generally don't have this problem).  See for example pinpointing "conditional jump or move depends on uninitialized value(s)" valgrind message.

For your purposes, your best bet is to manually put "poison" values into all your registers, and as much memory as you want.  The values that were present at the end of the last run are less likely to be good choices; that wouldn't catch a problem where either the initial zero or the value you write later both happen to work for some code that reads it before the write.

For example, 0xDEADBEEF is a good constant that you can recognize if you see it while debugging or in your program's output.  It's also unlikely to be a valid pointer or index.  See that link for more about what makes good poison.

e.g.

li  $t0,  0xDEADBEEF
move $t1, $t0
move $t2, $t0
...

You can probably write a macro to repeat it for all registers except the stack pointer, especially if you use the "raw" register numbers like $1, $2, etc.  (mapping table from semantic names to raw names.  Probably your macro should init everything except $29 ($sp), including $1 ($at) and the kernel-temporary regs).  To write a macro like that, use text substitution to create $1..$28, after putting your constant into $30 and $31.


问:
SVN "repair move" from the command-line
My IDE doesn't know that I use Subversion, and any time I rename a class (Java) it renames the file without notifying the version control system. I would of course like the file's history to be retained. I understand that in TortoiseSVN there is an option called "repair move" that fixes the move, but that's not an option since I'm on Ubuntu. Is there a way to repair the move from the command-line?</p>

答:
Is there a way to repair the move from the command-line?

No, this is SVN issue 1802. It has been open since 2003 so don't hold your breath.

ContentLicense: CC BY-SA 2.5

Title: SVN "repair move" from the command-line


答:
In your CSS rules add this:

```<code>header {
    display: inline-block;
}

div.search {
    line-height: 45px;
}
</code>```

You only need the first one, the second is purely decorative

Title: NavBar and Search Bar in the same line

Body:
In your CSS rules add this:

header {
    display: inline-block;
}

div.search {
    line-height: 45px;
}

You only need the first one, the second is purely decorative


答:
I assume you will use the setInterval() function.
just add this to your button onclick;

```<code>setInterval(function(){Document.getElementById("div").innerHTML = getTime},1000);
</code>```

Title: Updating time without refreshing the page with Javascript

Body:
I assume you will use the setInterval() function.
just add this to your button onclick;

setInterval(function(){Document.getElementById("div").innerHTML = getTime},1000);


问:
C# Listview - How to change the color of each new item?
I add items to a ListView control from the click event of a Button. I want each new item to be colored red and the older items colored white (so only the newest item added to the ListView is colored red).

I did something like this, but it only alternates the colors between red and white:

```<code>for (int i = 0; i <= listView1.Items.Count - 1; i++)
{
    if (listView1.Items[i].Index % 2 == 0)
    {
        listView1.Items[i].BackColor = Color.Red;
    }
    else
    {
        listView1.Items[i].BackColor = Color.White;
    }
}
</code>```

How can I have only the newest added item to be colored red?

答:
```<code>    private void listView_DrawItem(object sender, DrawListViewItemEventArgs e)
    {
        if (e.ItemIndex != (listView.Items.Count - 1))
        {
            // Draw the background and focus rectangle for a selected item.
        }
        else
        {
            // Draw the background for an unselected item.
            using (LinearGradientBrush brush =new LinearGradientBrush(e.Bounds, Color.Red, Color.Red, LinearGradientMode.Horizontal))
            {
                e.Graphics.FillRectangle(brush, e.Bounds);
            }
        }

        // Draw the item text for views other than the Details view.
        if (listView.View != View.Details)
        {
            e.DrawText();
        }
    }
</code>```

Body:
I add items to a ListView control from the click event of a Button. I want each new item to be colored red and the older items colored white (so only the newest item added to the ListView is colored red).

I did something like this, but it only alternates the colors between red and white:

for (int i = 0; i <= listView1.Items.Count - 1; i++)
{
    if (listView1.Items[i].Index % 2 == 0)
    {
        listView1.Items[i].BackColor = Color.Red;
    }
    else
    {
        listView1.Items[i].BackColor = Color.White;
    }
}

How can I have only the newest added item to be colored red?


问:
how to get the form value updated in angular 4 material with binding in place
```<code>import {Component,ViewChild} from '@angular/core';
import {NgForm} from '@angular/forms'

@Component({
  selector: 'checkbox-configurable-example',
  templateUrl: 'checkbox-configurable-example.html',
  styleUrls: ['checkbox-configurable-example.css'],
})
export class CheckboxConfigurableExample {
  @ViewChild('formData') formData: NgForm;

  checked = false;
  indeterminate = false;
  align = 'start';
  disabled = false;

  imcheckedVal = false;
  changeCheck(){
    this.imcheckedVal = this.formData.value.check4
  }

}
</code>```

template

```<code><form #formData = 'ngForm'>
  <md-card>
    <md-card-content>
      <h2 class="example-h2">Checkbox configuration</h2>

      <section class="example-section">
        <md-checkbox name ='check1' class="example-margin" [(ngModel)]="checked">Checked</md-checkbox>
        <md-checkbox name ='check2' class="example-margin" [(ngModel)]="indeterminate">Indeterminate</md-checkbox>
      </section>

      <section class="example-section">
        <label class="example-margin">Align:</label>
        <md-radio-group  name ='radGroup' [(ngModel)]="align">
          <md-radio-button name ='rad1' class="example-margin" value="start">Start</md-radio-button>
          <md-radio-button name ='rad2' class="example-margin" value="end">End</md-radio-button>
        </md-radio-group>
      </section>

      <section class="example-section">
        <md-checkbox  name ='check3' class="example-margin" [(ngModel)]="disabled">Disabled</md-checkbox>
      </section>
    </md-card-content>
  </md-card>

  <md-card class="result">
    <md-card-content>
      <h2 class="example-h2">Result</h2>

      <section class="example-section">
        <md-checkbox name ='check4' ngModel
            class="example-margin"
            [checked]="checked"
            [indeterminate]="indeterminate"
            [align]="align"
            [disabled]="disabled">
          I'm a checkbox
        </md-checkbox>
      </section>
    </md-card-content>
  </md-card>
</form>
<button (click) = 'changeCheck()'>get checkbox value</button>
Check box vaue is: {{imcheckedVal}}

<!-- Copyright 2017 Google Inc. All Rights Reserved.
    Use of this source code is governed by an MIT-style license that
    can be found in the LICENSE file at http://angular.io/license -->
</code>```

https://plnkr.co/edit/fhWWH3Mr994zn1vXKVAT?p=preview

In the above link there i have copied the angular material example and modified to suit my needs.

There is a form element at the top which is used later to retrieve data.

The problem is if u click the first checkbox, the checkbox in result at bottom gets selected but the value of the form element isn't changed u can see this by clicking the button at bottom. The form value only changes if u manually click the bottom checkbox. How do i get the form value to change with the bind in place

答:
As Dean Chalk metions you just have to add both [(ngModel)] as well as name attributes to your material component here is a code snipet that might give you an idea.

component.html

```<code><mat-form-field>
 <input matInput [value]="selectedWell.permit_date"
 [matDatepicker]="picker1" placeholder="Permit Date:"
 [(ngModel)]="selectedWell.permit_date"
 name="selectedWell.permit_date">
 <mat-datepicker-toggle matSuffix [for]="picker1"></mat-datepicker-toggle>
 <mat-datepicker #picker1></mat-datepicker>
</mat-form-field>

...

<button mat-button (click)="SaveWellDetails()" color="primary">Primary</button>
</code>```

component.ts

```<code>import ...
@Component({
...
})
export class WellSearchComponent implements OnInit {
...
SaveWellDetails()
{
  console.log(this.selectedWell);
}
</code>```

With this you will have the updated object in within the button's click methof, remember that in the end the task is easy, you just have to let know your view with the model they are supposed to be binded from angular will do the rest, notice the material2 material4 syntax [()]

Body:
import {Component,ViewChild} from '@angular/core';
import {NgForm} from '@angular/forms'

@Component({
  selector: 'checkbox-configurable-example',
  templateUrl: 'checkbox-configurable-example.html',
  styleUrls: ['checkbox-configurable-example.css'],
})
export class CheckboxConfigurableExample {
  @ViewChild('formData') formData: NgForm;

  checked = false;
  indeterminate = false;
  align = 'start';
  disabled = false;

  imcheckedVal = false;
  changeCheck(){
    this.imcheckedVal = this.formData.value.check4
  }

}

template

<form #formData = 'ngForm'>
  <md-card>
    <md-card-content>

Checkbox configuration

        <md-checkbox name ='check1' class="example-margin" [(ngModel)]="checked">Checked</md-checkbox>
        <md-checkbox name ='check2' class="example-margin" [(ngModel)]="indeterminate">Indeterminate</md-checkbox>

        Align:
        <md-radio-group  name ='radGroup' [(ngModel)]="align">
          <md-radio-button name ='rad1' class="example-margin" value="start">Start</md-radio-button>
          <md-radio-button name ='rad2' class="example-margin" value="end">End</md-radio-button>
        </md-radio-group>

        <md-checkbox  name ='check3' class="example-margin" [(ngModel)]="disabled">Disabled</md-checkbox>

    </md-card-content>
  </md-card>

  <md-card class="result">
    <md-card-content>

Result

        <md-checkbox name ='check4' ngModel
            class="example-margin"
            [checked]="checked"
            [indeterminate]="indeterminate"
            [align]="align"
            [disabled]="disabled">
          I'm a checkbox
        </md-checkbox>

    </md-card-content>
  </md-card>
</form>
<button (click) = 'changeCheck()'>get checkbox value</button>
Check box vaue is: {{imcheckedVal}}

https://plnkr.co/edit/fhWWH3Mr994zn1vXKVAT?p=preview

In the above link there i have copied the angular material example and modified to suit my needs.

There is a form element at the top which is used later to retrieve data.

The problem is if u click the first checkbox, the checkbox in result at bottom gets selected but the value of the form element isn't changed u can see this by clicking the button at bottom. The form value only changes if u manually click the bottom checkbox. How do i get the form value to change with the bind in place

Body:
As Dean Chalk metions you just have to add both [(ngModel)] as well as name attributes to your material component here is a code snipet that might give you an idea.

component.html

<mat-form-field>
 <input matInput [value]="selectedWell.permit_date"
 [matDatepicker]="picker1" placeholder="Permit Date:"
 [(ngModel)]="selectedWell.permit_date"
 name="selectedWell.permit_date">
 <mat-datepicker-toggle matSuffix [for]="picker1"></mat-datepicker-toggle>
 <mat-datepicker #picker1></mat-datepicker>
</mat-form-field>

...

<button mat-button (click)="SaveWellDetails()" color="primary">Primary</button>

component.ts

import ...
@Component({
...
})
export class WellSearchComponent implements OnInit {
...
SaveWellDetails()
{
  console.log(this.selectedWell);
}

With this you will have the updated object in within the button's click methof, remember that in the end the task is easy, you just have to let know your view with the model they are supposed to be binded from angular will do the rest, notice the material2 material4 syntax [()]


问:
Good way to generate GUIDs on app engine?
I was wondering if anyone knows of a good way to generate GUIDs on python google app engine. I feel like there is a simple way that people are using, what would you suggest.</p>

答:
Any chance they are guid's for things you're storing in the datastore?

If so, I believe object.key is a GUID


问:
Dynamic field generation with CSS Togglebuttons and .on() binders

Question:

I am trying to build a dynamic form using jQuery. There are a few standard html form inputs in a row in addition to a CSS stylized "hidden checkbox" toggle button. (Example)

The first row is statically coded, and there is a button to add more rows to the form for batch submissions. JQuery applied to the .on(click) event works perfectly with the static content, but newly appended form rows ignore the binding. Even jsfiddle's dynamic display doesn't appear to function, though it is possible my fiddle example has a bug that my working copy doesn't have. (Fiddle)

```<code>/*    activeToggle is the selector for the container and descendants,
//    .toggleHappy is the hidden input element within activeToggle    */
$(activeToggle).on("click", ".toggleHappy", function(e) {
    e.preventDefault();
    $(this).val(($(this).val() == 0) ? 1 : 0);
    console.log($(this).val());
});
</code>```

I have researched and found the common mistake of using .click() instead of delegating using .on(click, selector, fn()) and am thus using the latter now.

What is frustrating is I have another .on(click) that IS working with the dynamic content. (the remove function) So, I was hoping another pair of eyes might help me find out what my mistake is. I know this is very similar to other questions on the basic subject, but I have read quite a number of those discussions first, and have applied many of them to get where I currently am.

Updates:

I tried what Madhavan suggested and it does in fact work, but as expected, only for the first-child. So dynamically added rows are not pointed to. Thanks for the fast look. I feel like it might be a selector/scope issue, but whats weird is that once the page is loaded, I can type this directly into console and it works?

```<code>//this works run from console, but doesn't fire from a real click?
$(".theContainer .data .switch .toggleHappy").first().click();
</code>```

ANSWER I have been working on another project in the interim and it is starting to look like .on(event, selector, fn) is not working at all for dynamically added items. But, I had a breakthrough! The other project was slightly simplified, and I found the following:

```<code>//.theContainer is static
//.data .switch .toggleHappy is the dynamic chain created

//does not delegate and bind dynamically
$(".theContainer").on("click", ".data .switch .toggleHappy", function() {});

//DOES work!
$(".theContainer").on("click", ".toggleHappy", function() {});
</code>```

It would appear that a selector like .path .to .element only works well on existing static content, while .element allows .on() to be bound and delegated properly for dynamically generated nodes. See the updated fiddle.

The part that confused me was that hopping into the console and referencing dynamic elements with the full selector DID work on dynamic elements, but the events weren't delegated to them. Thanks again for the eyes that looked over this question, hope it helps someone else, because I still haven't found this on the web yet.

答:
It appears that delegating jQuery events with .on() will only work on static content when the selector used within .on() is a list of consecutive elements. In my code, I had a single container which was static, I delegated an event to it referencing multiple elements between the container and the destination elements. It would work locally for any number of statically identified elements, but any dynamically added ones would ignore the bindings. It also would throw no errors, and it WOULD respond to lines of script executed within the console directly, using the same selector chaining as the function. I found the following:

```<code>//.theContainer is static
//.data .switch .toggleHappy is the dynamic chain created

//does not delegate and bind dynamically
$(".theContainer").on("click", ".data .switch .toggleHappy", function() {});

//DOES work!
$(".theContainer").on("click", ".toggleHappy", function() {});
</code>```

It would appear that a selector like ".path .to .element" only works well on existing static content, while ".element" allows .on() to be bound and delegated properly for dynamically generated nodes. See the updated fiddle.

The part that confused me was that hopping into the console and referencing dynamic elements with the full selector DID work on dynamic elements, but the events weren't delegated to them. Thanks again for the eyes that looked over this question, hope it helps someone else, because I still haven't found this on the web yet.

Body:
Question:

I am trying to build a dynamic form using jQuery. There are a few standard html form inputs in a row in addition to a CSS stylized "hidden checkbox" toggle button. (Example)

The first row is statically coded, and there is a button to add more rows to the form for batch submissions. JQuery applied to the .on(click) event works perfectly with the static content, but newly appended form rows ignore the binding. Even jsfiddle's dynamic display doesn't appear to function, though it is possible my fiddle example has a bug that my working copy doesn't have. (Fiddle)

/*    activeToggle is the selector for the container and descendants,
//    .toggleHappy is the hidden input element within activeToggle    */
$(activeToggle).on("click", ".toggleHappy", function(e) {
    e.preventDefault();
    $(this).val(($(this).val() == 0) ? 1 : 0);
    console.log($(this).val());
});

I have researched and found the common mistake of using .click() instead of delegating using .on(click, selector, fn()) and am thus using the latter now.

What is frustrating is I have another .on(click) that IS working with the dynamic content. (the remove function) So, I was hoping another pair of eyes might help me find out what my mistake is. I know this is very similar to other questions on the basic subject, but I have read quite a number of those discussions first, and have applied many of them to get where I currently am.

Updates:

I tried what Madhavan suggested and it does in fact work, but as expected, only for the first-child. So dynamically added rows are not pointed to. Thanks for the fast look. I feel like it might be a selector/scope issue, but whats weird is that once the page is loaded, I can type this directly into console and it works?

//this works run from console, but doesn't fire from a real click?
$(".theContainer .data .switch .toggleHappy").first().click();

ANSWER I have been working on another project in the interim and it is starting to look like .on(event, selector, fn) is not working at all for dynamically added items. But, I had a breakthrough! The other project was slightly simplified, and I found the following:

//.theContainer is static
//.data .switch .toggleHappy is the dynamic chain created

//does not delegate and bind dynamically
$(".theContainer").on("click", ".data .switch .toggleHappy", function() {});

//DOES work!
$(".theContainer").on("click", ".toggleHappy", function() {});

It would appear that a selector like .path .to .element only works well on existing static content, while .element allows .on() to be bound and delegated properly for dynamically generated nodes. See the updated fiddle.

The part that confused me was that hopping into the console and referencing dynamic elements with the full selector DID work on dynamic elements, but the events weren't delegated to them. Thanks again for the eyes that looked over this question, hope it helps someone else, because I still haven't found this on the web yet.

Body:
It appears that delegating jQuery events with .on() will only work on static content when the selector used within .on() is a list of consecutive elements. In my code, I had a single container which was static, I delegated an event to it referencing multiple elements between the container and the destination elements. It would work locally for any number of statically identified elements, but any dynamically added ones would ignore the bindings. It also would throw no errors, and it WOULD respond to lines of script executed within the console directly, using the same selector chaining as the function. I found the following:

//.theContainer is static
//.data .switch .toggleHappy is the dynamic chain created

//does not delegate and bind dynamically
$(".theContainer").on("click", ".data .switch .toggleHappy", function() {});

//DOES work!
$(".theContainer").on("click", ".toggleHappy", function() {});

It would appear that a selector like ".path .to .element" only works well on existing static content, while ".element" allows .on() to be bound and delegated properly for dynamically generated nodes. See the updated fiddle.

The part that confused me was that hopping into the console and referencing dynamic elements with the full selector DID work on dynamic elements, but the events weren't delegated to them. Thanks again for the eyes that looked over this question, hope it helps someone else, because I still haven't found this on the web yet.


问:
C++ min and max
I am trying to get the min and max numbers of a series of integers and I am able to get the min with this code but not the max and not sure what i am doing wrong.</p>

```<code>#include <iostream>
#include <climits>
using namespace std;

int main()
{
//Declare variables.
int number, max, min;

//Set the values.
max = INT_MIN;
min = INT_MAX;

cout << "Enter -99 to end series" << endl;
while (number != -99)
{
    //Compare values and set the max and min.
    if (number > max)
        max = number;
    if (number < min)
        min = number;

    //Ask the user to enter the integers.
    cout << "Enter a number in a series: " << endl;
    cin >> number;
}

//Display the largest and smallest number.
cout << "The largest number is: " << max << endl;
cout << "The smallest number is: " << min << endl;

system("pause");
return 0;
}
</code>```

答:
The problem lies with your uninitialized number. When you enter your while loop for the first time, the program will take whatever value in number (which has not been initialized thus can be anything) to compare with max and min. Then, your next comparison will be compared to your uninitialized value.

To resolve this, simply take your user input before the while loop.

```<code>cout << "Enter -99 to end series" << endl;
//Ask the user to enter the integers.
cout << "Enter a number in a series: " << endl;
cin >> number;
while (number != -99)
{
    //Compare values and set the max and min.
    if (number > max)
        max = number;
    if (number < min)
        min = number;

    //Ask the user to enter the integers.
    cout << "Enter a number in a series: " << endl;
    cin >> number;
}
</code>```

Title: C++ min and max

Body:
I am trying to get the min and max numbers of a series of integers and I am able to get the min with this code but not the max and not sure what i am doing wrong.

#include <iostream>
#include <climits>
using namespace std;

int main()
{
//Declare variables.
int number, max, min;

//Set the values.
max = INT_MIN;
min = INT_MAX;

cout << "Enter -99 to end series" << endl;
while (number != -99)
{
    //Compare values and set the max and min.
    if (number > max)
        max = number;
    if (number < min)
        min = number;

    //Ask the user to enter the integers.
    cout << "Enter a number in a series: " << endl;
    cin >> number;
}

//Display the largest and smallest number.
cout << "The largest number is: " << max << endl;
cout << "The smallest number is: " << min << endl;

system("pause");
return 0;
}

Body:
The problem lies with your uninitialized number. When you enter your while loop for the first time, the program will take whatever value in number (which has not been initialized thus can be anything) to compare with max and min. Then, your next comparison will be compared to your uninitialized value.

To resolve this, simply take your user input before the while loop.

cout << "Enter -99 to end series" << endl;
//Ask the user to enter the integers.
cout << "Enter a number in a series: " << endl;
cin >> number;
while (number != -99)
{
    //Compare values and set the max and min.
    if (number > max)
        max = number;
    if (number < min)
        min = number;

    //Ask the user to enter the integers.
    cout << "Enter a number in a series: " << endl;
    cin >> number;
}


问:
Change view controller on click UIButton Swift (without storyboard)
How do you change the view controller when a button is clicked. I am not using the Storyboard. The views were  all created programmatically.

I tried adding a target to the button and then calling the following method to push the new View Controller:

```<code>func switchView() {
   print(123)
   let prodListController = ProductListController()
   self.navigationController?.pushViewController(prodListController, animated: true)
}
</code>```

This was called from within the UIviewController class.

Any help will be greatly appreciated. Thanks!!

EDIT:
Made the following modifications:

```<code>window = UIWindow(frame: UIScreen.main.bounds)
window?.makeKeyAndVisible()
window?.rootViewController = UINavigationController(rootViewController: ProductListController())
</code>```

答:
You can try this code to push another viewcontroller

```<code>self.window = UIWindow(frame: UIScreen.mainScreen().bounds)
var navVC = UINavigationController()
var yourVC = YourViewController()
navVC.viewControllers = [yourVC]
self.window!.rootViewController = navVC
self.window?.makeKeyAndVisible()
</code>```

hope this will resolve your problem.

Body:
How do you change the view controller when a button is clicked. I am not using the Storyboard. The views were  all created programmatically.

I tried adding a target to the button and then calling the following method to push the new View Controller:

func switchView() {
   print(123)
   let prodListController = ProductListController()
   self.navigationController?.pushViewController(prodListController, animated: true)
}

This was called from within the UIviewController class.

Any help will be greatly appreciated. Thanks!!

EDIT:
Made the following modifications:

window = UIWindow(frame: UIScreen.main.bounds)
window?.makeKeyAndVisible()
window?.rootViewController = UINavigationController(rootViewController: ProductListController())

Body:
You can try this code to push another viewcontroller

self.window = UIWindow(frame: UIScreen.mainScreen().bounds)
var navVC = UINavigationController()
var yourVC = YourViewController()
navVC.viewControllers = [yourVC]
self.window!.rootViewController = navVC
self.window?.makeKeyAndVisible()

hope this will resolve your problem.


问:
Select a random position on the border of an array
I've initialized an array of zeros. I'd now like to randomly select positions on the border of the array. If the position is 0, I would then set it to 1, while if it is 1, I would do nothing and repeat the process.

Here's what I currently have:

```<code>D = 50 # lattice dims
N = 200 # total number of particles at the end
a = np.zeros((D,D)) # playing board array

# place particle at the center of the board
a[int(D/2), int(D/2)] = 1

border_list = [0, 1, 2, 3]

i = 0
while i < N:
    border = random.choice(border_list)
    pos = math.floor((D)*random.random())
    if border == 0:
        if a[0, pos] == 0:
            a[0, pos] = 1
            i += 1
    if border == 1:
        if a[pos, 0] == 0:
            a[pos, 0] = 1
            i += 1
    if border == 2:
        if a[int(D-1), pos] == 0:
            a[int(D-1), pos] = 1
            i += 1
    if border == 3:
        if a[pos, int(D-1)] == 0:
            a[pos, int(D-1)] = 1
            i += 1
</code>```

Seems pretty inefficient to me. Any advice regarding improving it?

答:
Rewritten from comments:

```<code>almostD = D - 1
choices_for_y = [0, almostD]
i = 0
while i < D:
    x = random.randint(0, almostD)      # anywhere horisontally
    y = random.choice(choices_for_y)    # top or bottom
    if random.random() < 0.5:           # flip x and y in half the cases
        x, y = y, x
    if a[x, y] == 0:
        a[x, y] = 1
        i += 1
</code>```

However, note that this, just like your code, has double the chances of placing a dot in corners than along the edge. Also note that this is not much speedup vs your code; just less lines.

Body:
I've initialized an array of zeros. I'd now like to randomly select positions on the border of the array. If the position is 0, I would then set it to 1, while if it is 1, I would do nothing and repeat the process.

Here's what I currently have:

D = 50 # lattice dims
N = 200 # total number of particles at the end
a = np.zeros((D,D)) # playing board array

# place particle at the center of the board
a[int(D/2), int(D/2)] = 1

border_list = [0, 1, 2, 3]

i = 0
while i < N:
    border = random.choice(border_list)
    pos = math.floor((D)*random.random())
    if border == 0:
        if a[0, pos] == 0:
            a[0, pos] = 1
            i += 1
    if border == 1:
        if a[pos, 0] == 0:
            a[pos, 0] = 1
            i += 1
    if border == 2:
        if a[int(D-1), pos] == 0:
            a[int(D-1), pos] = 1
            i += 1
    if border == 3:
        if a[pos, int(D-1)] == 0:
            a[pos, int(D-1)] = 1
            i += 1

Seems pretty inefficient to me. Any advice regarding improving it?

Body:
Rewritten from comments:

almostD = D - 1
choices_for_y = [0, almostD]
i = 0
while i < D:
    x = random.randint(0, almostD)      # anywhere horisontally
    y = random.choice(choices_for_y)    # top or bottom
    if random.random() < 0.5:           # flip x and y in half the cases
        x, y = y, x
    if a[x, y] == 0:
        a[x, y] = 1
        i += 1

However, note that this, just like your code, has double the chances of placing a dot in corners than along the edge. Also note that this is not much speedup vs your code; just less lines.


问:
Improve order by json field performance on mysql
I have this table:

```<code>CREATE TABLE `mytable` (
  `session_id` mediumint(8) UNSIGNED NOT NULL,
  `data` json NOT NULL,
  `jobname` varchar(100) COLLATE utf8_unicode_ci GENERATED ALWAYS AS
    (json_unquote(json_extract(`data`,'$.jobname'))) VIRTUAL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci
PARTITION BY HASH (session_id)
PARTITIONS 10;

ALTER TABLE `mytable`
  ADD KEY `session` (`session_id`),
  ADD KEY `jobname` (`jobname`);
</code>```

It has 2 million rows.

When execute this query, it takes around 23 sec to get the result.

```<code>SELECT JSON_EXTRACT(f.data, '$.jobdesc') AS jobdesc
FROM mytable f
WHERE f.session_id = 1
ORDER BY jobdesc DESC
</code>```

I understand that it is slow because there is no index for jobdesc field.
On data's column, I have 12 fields. I want to let user to be able to sort all fields. If I add index for each field, is it good approach?
Is there any way to improve it?

I am using MYSQL 5.7.13.

答:
You would have to create a virtual column with an index for each of your 12 fields, if you want the user to have the option of sorting by.

```<code>CREATE TABLE `mytable` (
  `session_id` mediumint(8) UNSIGNED NOT NULL,
  `data` json NOT NULL,
  `jobname` varchar(100) AS (json_unquote(json_extract(`data`,'$.jobname'))),
  `jobdesc` varchar(100) AS (json_unquote(json_extract(`data`,'$.jobdesc'))),
  ...other extracted virtual fields...
  KEY (`jobname`),
  KEY (`jobdesc`),
  ...other indexes on virtual columns...
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci
PARTITION BY HASH (session_id)
PARTITIONS 10;
</code>```

This makes me wonder: why bother using JSON? Why not just declare 12 conventional, non-virtual columns with indexes?

```<code>CREATE TABLE `mytable` (
  `session_id` mediumint(8) UNSIGNED NOT NULL,
  ...no `data` column needed...
  `jobname` varchar(100),
  `jobdesc` varchar(100),
  ...
  KEY (`jobname`),
  KEY (`jobdesc`),
  ...
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci
PARTITION BY HASH (session_id)
PARTITIONS 10;
</code>```

JSON is best when you treat it as a single atomic document, and don't try to use SQL operations on fields within it. If you regularly need to access fields within your JSON, make them into conventional columns.

Body:
I have this table:

CREATE TABLE `mytable` (
  `session_id` mediumint(8) UNSIGNED NOT NULL,
  `data` json NOT NULL,
  `jobname` varchar(100) COLLATE utf8_unicode_ci GENERATED ALWAYS AS
    (json_unquote(json_extract(`data`,'$.jobname'))) VIRTUAL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci
PARTITION BY HASH (session_id)
PARTITIONS 10;

ALTER TABLE `mytable`
  ADD KEY `session` (`session_id`),
  ADD KEY `jobname` (`jobname`);

It has 2 million rows.

When execute this query, it takes around 23 sec to get the result.

SELECT JSON_EXTRACT(f.data, '$.jobdesc') AS jobdesc
FROM mytable f
WHERE f.session_id = 1
ORDER BY jobdesc DESC

I understand that it is slow because there is no index for jobdesc field.
On data's column, I have 12 fields. I want to let user to be able to sort all fields. If I add index for each field, is it good approach?
Is there any way to improve it?

I am using MYSQL 5.7.13.

Body:
You would have to create a virtual column with an index for each of your 12 fields, if you want the user to have the option of sorting by.

CREATE TABLE `mytable` (
  `session_id` mediumint(8) UNSIGNED NOT NULL,
  `data` json NOT NULL,
  `jobname` varchar(100) AS (json_unquote(json_extract(`data`,'$.jobname'))),
  `jobdesc` varchar(100) AS (json_unquote(json_extract(`data`,'$.jobdesc'))),
  ...other extracted virtual fields...
  KEY (`jobname`),
  KEY (`jobdesc`),
  ...other indexes on virtual columns...
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci
PARTITION BY HASH (session_id)
PARTITIONS 10;

This makes me wonder: why bother using JSON? Why not just declare 12 conventional, non-virtual columns with indexes?

CREATE TABLE `mytable` (
  `session_id` mediumint(8) UNSIGNED NOT NULL,
  ...no `data` column needed...
  `jobname` varchar(100),
  `jobdesc` varchar(100),
  ...
  KEY (`jobname`),
  KEY (`jobdesc`),
  ...
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci
PARTITION BY HASH (session_id)
PARTITIONS 10;

JSON is best when you treat it as a single atomic document, and don't try to use SQL operations on fields within it. If you regularly need to access fields within your JSON, make them into conventional columns.


问:
@Html.DeleteConfirmation in a Plugin View (Admin) in asp.net core 2.0
Looking at core code examples of say... Edit Action for SpecificationAttribute. I am looking to replicate this delete function in the same manner in my plugin, however, getting an error.

Getting this error

'IHtmlHelper' does not contain a definition for 'DeleteConfirmation' and no extension method 'DeleteConfirmation' accepting a first argument of type 'IHtmlHelper' could be found (are you missing a using directive or an assembly reference?)

I have used in 3.90 but it getting error in 4.0 asp.net core Has anyone used @Html.DeleteConfirmation in a plugin (on administration side) that could give me a clues

I have a span element in the html like the following;

```<code><span id="myattribute-delete" class="k-button">@T("Admin.Common.Delete")</span>
</code>```

And trying to use @Html.DeleteConfirmation("myattribute-delete")

I know I probably need to double check my route, by the error is leading me to think the issue is not a routing issue.

答:
As @Stephen stated it's not part of MVC, and it's custom helper by nopCommerce.

@Html.DeleteConfirmation is helper till/in nopCommerce 3.90, but in 4.0 it has been changed to

```<code><nop-delete-confirmation asp-model-id="@Model.Id" asp-button-id="myattribute-delete" />
</code>```

And that helper located at Nop.Web.Framework.TagHelpers.Adminso you have to add reference of it to your view file.

Body:
Looking at core code examples of say... Edit Action for SpecificationAttribute. I am looking to replicate this delete function in the same manner in my plugin, however, getting an error.

Getting this error

'IHtmlHelper' does not contain a definition for 'DeleteConfirmation' and no extension method 'DeleteConfirmation' accepting a first argument of type 'IHtmlHelper' could be found (are you missing a using directive or an assembly reference?)

I have used in 3.90 but it getting error in 4.0 asp.net core Has anyone used @Html.DeleteConfirmation in a plugin (on administration side) that could give me a clues

I have a span element in the html like the following;

@T("Admin.Common.Delete")

And trying to use @Html.DeleteConfirmation("myattribute-delete")

I know I probably need to double check my route, by the error is leading me to think the issue is not a routing issue.

Body:
As @Stephen stated it's not part of MVC, and it's custom helper by nopCommerce.

@Html.DeleteConfirmation is helper till/in nopCommerce 3.90, but in 4.0 it has been changed to

<nop-delete-confirmation asp-model-id="@Model.Id" asp-button-id="myattribute-delete" />

And that helper located at Nop.Web.Framework.TagHelpers.Adminso you have to add reference of it to your view file.


问:
Install NupenGL offline in VS2017?
Trying to install this specific NuGet package in an offline VS2017 environment.

However, despite downloading the .nupkg file and saving it in the specified offline NuGet package directory under "NuGet Package Manager Settings", the package does not appear in the list in the NuGet package manager in VS2017.

Do I need to unzip the file first? Have tried that but receive the error that the .nupkg file does not contain a .nuspec file (despite clearly containing one in File Explorer).

Could someone with VS2017 try to install this specific NuGet package in an offline VS2017 environment and provide a clearly worded, unambiguous step-by-step guide on how to install the package?

答:
Could someone with VS2017 try to install this specific NuGet package in an offline VS2017 environment and provide a clearly worded, unambiguous step-by-step guide on how to install the package?

To accomplish install nuget package in an offline VS2017 environment, please following below steps:

Manually download that nuget package, save it to your local location, for example, D:\Test\NuGet. You will get a file ending in .nupakg: nupengl.core.0.1.0.1.nupkg.

Open a command prompt with administrator from start menu, switch the path to where nuget.exe exists, for example, C:\Users\Admin. Then add the download package to the ffline NuGet package directory: C:\Program Files (x86)\Microsoft SDKs\NuGetPackages by below command:

```<code>nuget add "D:\Test\NuGet\nupengl.core.0.1.0.1.nupkg" -source "C:\Program Files (x86)\Microsoft SDKs\NuGetPackages"
</code>```

After that, you will find the nuget package be added to the the offline NuGet package directory with a hierarchical layout:

Then you can use this nuget package when your Visual Studio 2017 without an internet connection:

Title: Install NupenGL offline in VS2017?

Body:
Could someone with VS2017 try to install this specific NuGet package in an offline VS2017 environment and provide a clearly worded, unambiguous step-by-step guide on how to install the package?

To accomplish install nuget package in an offline VS2017 environment, please following below steps:

Manually download that nuget package, save it to your local location, for example, D:\Test\NuGet. You will get a file ending in .nupakg: nupengl.core.0.1.0.1.nupkg.

Open a command prompt with administrator from start menu, switch the path to where nuget.exe exists, for example, C:\Users\Admin. Then add the download package to the ffline NuGet package directory: C:\Program Files (x86)\Microsoft SDKs\NuGetPackages by below command:

nuget add "D:\Test\NuGet\nupengl.core.0.1.0.1.nupkg" -source "C:\Program Files (x86)\Microsoft SDKs\NuGetPackages"

After that, you will find the nuget package be added to the the offline NuGet package directory with a hierarchical layout:

Then you can use this nuget package when your Visual Studio 2017 without an internet connection: