问:
CSS Float content creating whitespace and overlapping other div
I'm in the midst of creating a responsive portfolio at the moment and I'm running into a bit of trouble.

Before a certain breakpoint (css media query), the second and third paragraph in the 'About' section of my website are in floats. As the window gets smaller, the text starts to overlap the footer and eventually create a whitespace at the bottom and side. When it reaches the breakpoint, the floats are valued as 'none'.

How can I make it so that the height of the container is determined by how much content is in there (i.e. the normal behaviour)? I've tried a clearfix, but that doesn't seem to work.

https://codepen.io/webdevkid/pen/gmBVMj

HTML

```<code><body>
    <nav>
        <div id="logo"><a id="logo-link" href="index.html"><span id="word-1">Potential </span><span id="word-2">Beginning</span></a><div id="menu-icon"></div></div><div class="clear"></div>
            <ul id="main-links">
                <a href="#"><li><span class="word-position">About</span></li></a>
                <a href="#"><li><span class="word-position">Work</span></li></a>
                <a href="#"><li class="last-child"><span class="word-position">Contact</span></li></a>
            </ul>
    </nav>
    <div id="main-container">
        <div id="introductory-background">
            <div id="introductory-overlay">
                <div id="introductory-content">
                    <div id="introductory-container">
                        <h1 id="role-header">Junior Web Developer</h1>
                        <h3 id="role-support-text">...but that's not all I can do</h3>
                        <a id="read-more" class="no-select">Read More</a>
                    </div>
                </div>
            </div>
        </div>
        <div id="about-section">
            <br />
            <br />
            <div id="photo-frame">
                <div id="picture"></div>
            </div>
            <br />
            <div id="about-text-container">
                <p>Hi There! My name is Ed Garbutt, a Junior Web Developer based in South Buckinghamshire, with a huge passion for all things programming.</p>
                <br />
                <p id="about-left-side" class="side-by-side">Sadly, I'm not like most Developer out thers. I don't drink Red Bull or Monster Cans. I'm not a fan of Start Wars. I don't read Marvel Comic Books, but I am someone who likes going outside here and then.</p>
                <p id="about-right-side" class="side-by-side">All jokes aside, what you <b>will</b> get is someone who prides himself on attention to details, who will always rise to a challenge ans is constantly looking to better himself, building upon his existing knowledge of programming languages and frameworks.</p>
            </div>
        </div>
    </div>
    <footer>
        <p id="footer-text">
            © 2016 Ed Garbutt. All rights reserved.
        </p>
    </footer>
</body>
</code>```

CSS

```<code>    body {
    margin: 0;
}
nav {
  width: 100%;
  height: 50px;
  position: fixed;
  background-color: rgb(40, 40, 40);
  border-bottom-style: solid;
  border-bottom-color: rgb(238, 0, 0);
  border-bottom-width: 7.5px;
  padding-top: 14px;
  z-index: 10;
}

#logo {
    position: relative;
    bottom: 5px;
    font-size: 30px;
    padding-left: 8px;
    float: left;
    font-family: bebas;
}

#word-1 {
    color: rgb(0, 154, 205);
}

#word-2 {
    color: rgb(255, 250, 250);
}

ul#main-links {
  list-style: none;
  margin: 0;
  padding-right: 50px;
  float: right;
  height: 100%;
  border-bottom: 7.5px solid transparent;
  display: block;
font-size: 0;
}

ul#main-links li {
  display: inline-block;
  text-align: center;
  border-bottom-style: solid;
  border-bottom-width: 7.5px;
border-bottom-color: rgb(238, 0, 0);
  color: white;
  font-family: arcon;
  font-size: 18px;
  height: 100%;
    width: 90px;
  position: relative;
  z-index: 2;
}

a:link {
  text-decoration: none;
}

a:visited {
  text-decoration: none;
    color: white;
}

a:active {
  text-decoration: none;
    color: white;
}

a#logo-link {
    text-decoration: none;

}

a#logo-link:visited {
  text-decoration: none;
    color: inherit;
}

a#logo-link:active {
  text-decoration: none;
    color: inherit;
}

ul#main-links > a > li > span.word-position {
  position: relative;
    top: 5px;
}

#menu-icon {
    height: 48px;
    width: 48px;
    display: none;
    cursor: pointer;
    background-image: url("../images/hamburg-white-2.png");
}

#main-container {
    padding-top: 71.4px;
}

@media screen and (min-width: 656px) {
    ul#main-links {
        display: block !important;
    }
}

@media screen and (max-width: 656px) {

    nav {
        height: initial;
    }

    #logo {
        width: 100%;
        float: none;
        padding-left: 0;
        text-align: center;
        bottom: 8px;
    }

    #menu-icon {
        display: inline-block;
/*        float: right;*/
        position: absolute;
        right: 10px;
        top: -2px;
    }

    ul#main-links {
        display: none;
        float: none;
        padding-right: 0;
        padding-left: 0;
        width: 100%;
    }

    ul#main-links li {
        width: 100%;
        display: block;
        border: none;
        padding: 10px 0;
    }

    ul#main-links li:not(.last-child) {
        border-bottom-style: solid;
        border-bottom-color: rgb(238, 0, 0);
        border-bottom-width: 2.5px;
    }

    ul#main-links > a > li > span.word-position {
        top: 0px;
    }

    #main-container {
        padding-top: 62.4px;
    }
}

@media screen and (max-width: 400px) {
   #logo {
        bottom: 7.5px;
        font-size: 23px;
        padding-left: 10px;
        text-align: left;
    }

    #menu-icon {
        height: 32px;
        width: 32px;
        background-image: url("../images/hamburg-white-1.png");
        top: 0.4px;
        right: 20px;
    }

    #main-container {
        padding-top: 52.4px;
    }
}

/* ----INTORDUCTION---- */

#introductory-background {
    background-image: url('../images/eternity-1024x768.jpg');
    background-position: center center;
    background-repeat: no-repeat;
    background-size: cover;
    width: 100%;
/*    min-height: 527px;*/
    height: 90vh;
    background-size: 100% 100%;
    overflow: auto;
}

#introductory-overlay {
    display: table;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
}

#introductory-content {
    margin-left: auto;
    margin-right: auto;
    display: table-cell;
    vertical-align: middle;
    text-align: center;
}

#introductory-container {
    position: relative;
    bottom: 60px;
}

h1#role-header {
    display: block;
    position: relative;
    right: 5em;
    opacity: 0;
    font-size: 48px;
    color: rgb(255, 250, 250);
}

h3#role-support-text {
    display: block;
    opacity: 0;
    position: relative;
    top: 20px;
    font-size: 30px;
    color: rgb(255, 250, 250);
}

#read-more {
    border-radius: 38px;
    background-color: rgb(255, 250, 250);
    padding: 0.5em 1.5em;
    font-size: 24px;
    cursor: pointer;
}

@media screen and (max-width: 656px) {

    #introductory-container {
        bottom: 60px;
    }

    h1#role-header {
        font-size: 37px;
    }

    h3#role-support-text {
        top: 15px;
        font-size: 24px;
    }

    #read-more {
        font-size: 19px;
    }
}

@media screen and (max-width: 400px) {

    #introductory-container {
        bottom: 72.5px;
    }

   h1#role-header {
        font-size: 28px;
    }

    h3#role-support-text {
        top: 11px;
        font-size: 20px;
    }

    #read-more {
        font-size: 16px;
    }
}

/* -------------------- */
/* -------ABOUT-------- */

#about-section {
    width: 100%;
    height: 500px;
    background-color: rgb(131, 111, 235);
}

#photo-frame {
    margin: 0 auto;
    background-color: royalblue;
    width: 180px;
    height: 180px;
    border-radius: 100px;
    border-style: solid;
    border-color: beige;
    border-width: 7.5px;
    z-index: 2;
}

#photo-frame > #picture {
    width: 100%;
    height: 100%;
    background-image: url('../images/Ed.png');
    border-radius: 100px;
}

#about-section > #about-text-container {
    margin: 0 auto;
    width: 80%;
}

#about-section > #about-text-container > p {
    margin: 0;
    text-align: center;
/*    padding: 0 3rem;*/
    font-size: 22px;
}

#about-section > #about-text-container > p.side-by-side {
/*    display: inline-block;*/
    width: 45%;
    text-align: justify;
}

#about-section > #about-text-container > p#about-left-side {
    float: left;
}

#about-section > #about-text-container > p#about-right-side{
    float: right;
}

@media screen and (max-width: 868px) {
    #about-section > #about-text-container > p.side-by-side {
    /*    display: inline-block;*/
        width: 100%;
    }

    #about-section > #about-text-container > p#about-left-side {
        float: none;
        padding-bottom: 1.5rem;
    }

    #about-section > #about-text-container > p#about-right-side{
        float: none;
    }
}

@media screen and (max-width: 656px) {
    #photo-frame {
        width: 150px;
        height: 150px;
    }

    #about-section > #about-text-container {
        width: 90%;
    }

    #about-section > #about-text-container > p {
        text-align: justify;
        padding: 0 1.5rem;
        font-size: 20px;
    }
}

@media screen and (max-width: 400px) {
    #photo-frame {
        width: 125px;
        height: 125px;
    }

    #about-section > #about-text-container {
        width: 100%;
    }

    #about-section > #about-text-container > p {
        padding: 0 0.5rem;
        font-size: 18px;
    }
}

/* -------------------- */
/* -------FOOTER------- */

footer {
    width: 100%;
    background-color: black;
}

footer > p#footer-text {
    margin: 0;
    text-align: center;
    font-family: arial;
    color: rgb(169, 169, 169);
    padding: 20px;
    width: 100%;
    -moz-box-sizing: border-box;
    -webkit-box-sizing: border-box;
    box-sizing: border-box;
}

/* -------------------- */

.no-select {
    -webkit-touch-callout: none; /* iOS Safari */
    -webkit-user-select: none;   /* Safari */
    -khtml-user-select: none;    /* Konqueror HTML */
    -moz-user-select: none;      /* Firefox */
    -ms-user-select: none;       /* Internet Explorer/Edge */
    user-select: none;           /* Non-prefixed version, currently supported by Chrome and Opera */
}

.clearfix:before,
.clearfix:after {
    content: " ";
    display: table;
}
.clearfix:after {
    clear: both;
}
.clearfix {
    *zoom: 1;
}
</code>```

答:
Try this:

```<code>#about-section {
    width: 100%;
    background-color: rgb(131, 111, 235);
}
</code>```

Description

You are using #about-section id remove the height property or use height:auto, you have given a fixed height. And use float:left as well in p tag ids.

here your update code

Body:
I'm in the midst of creating a responsive portfolio at the moment and I'm running into a bit of trouble.

Before a certain breakpoint (css media query), the second and third paragraph in the 'About' section of my website are in floats. As the window gets smaller, the text starts to overlap the footer and eventually create a whitespace at the bottom and side. When it reaches the breakpoint, the floats are valued as 'none'.

How can I make it so that the height of the container is determined by how much content is in there (i.e. the normal behaviour)? I've tried a clearfix, but that doesn't seem to work.

https://codepen.io/webdevkid/pen/gmBVMj

HTML

Potential Beginning

About

Work

Contact

Junior Web Developer

...but that's not all I can do

                        Read More

Hi There! My name is Ed Garbutt, a Junior Web Developer based in South Buckinghamshire, with a huge passion for all things programming.

Sadly, I'm not like most Developer out thers. I don't drink Red Bull or Monster Cans. I'm not a fan of Start Wars. I don't read Marvel Comic Books, but I am someone who likes going outside here and then.

All jokes aside, what you will get is someone who prides himself on attention to details, who will always rise to a challenge ans is constantly looking to better himself, building upon his existing knowledge of programming languages and frameworks.

            © 2016 Ed Garbutt. All rights reserved.

CSS

    body {
    margin: 0;
}
nav {
  width: 100%;
  height: 50px;
  position: fixed;
  background-color: rgb(40, 40, 40);
  border-bottom-style: solid;
  border-bottom-color: rgb(238, 0, 0);
  border-bottom-width: 7.5px;
  padding-top: 14px;
  z-index: 10;
}

#logo {
    position: relative;
    bottom: 5px;
    font-size: 30px;
    padding-left: 8px;
    float: left;
    font-family: bebas;
}

#word-1 {
    color: rgb(0, 154, 205);
}

#word-2 {
    color: rgb(255, 250, 250);
}

ul#main-links {
  list-style: none;
  margin: 0;
  padding-right: 50px;
  float: right;
  height: 100%;
  border-bottom: 7.5px solid transparent;
  display: block;
font-size: 0;
}

ul#main-links li {
  display: inline-block;
  text-align: center;
  border-bottom-style: solid;
  border-bottom-width: 7.5px;
border-bottom-color: rgb(238, 0, 0);
  color: white;
  font-family: arcon;
  font-size: 18px;
  height: 100%;
    width: 90px;
  position: relative;
  z-index: 2;
}

a:link {
  text-decoration: none;
}

a:visited {
  text-decoration: none;
    color: white;
}

a:active {
  text-decoration: none;
    color: white;
}

a#logo-link {
    text-decoration: none;

}

a#logo-link:visited {
  text-decoration: none;
    color: inherit;
}

a#logo-link:active {
  text-decoration: none;
    color: inherit;
}

ul#main-links > a > li > span.word-position {
  position: relative;
    top: 5px;
}

#menu-icon {
    height: 48px;
    width: 48px;
    display: none;
    cursor: pointer;
    background-image: url("../images/hamburg-white-2.png");
}

#main-container {
    padding-top: 71.4px;
}

@media screen and (min-width: 656px) {
    ul#main-links {
        display: block !important;
    }
}

@media screen and (max-width: 656px) {

    nav {
        height: initial;
    }

    #logo {
        width: 100%;
        float: none;
        padding-left: 0;
        text-align: center;
        bottom: 8px;
    }

    #menu-icon {
        display: inline-block;
/*        float: right;*/
        position: absolute;
        right: 10px;
        top: -2px;
    }

    ul#main-links {
        display: none;
        float: none;
        padding-right: 0;
        padding-left: 0;
        width: 100%;
    }

    ul#main-links li {
        width: 100%;
        display: block;
        border: none;
        padding: 10px 0;
    }

    ul#main-links li:not(.last-child) {
        border-bottom-style: solid;
        border-bottom-color: rgb(238, 0, 0);
        border-bottom-width: 2.5px;
    }

    ul#main-links > a > li > span.word-position {
        top: 0px;
    }

    #main-container {
        padding-top: 62.4px;
    }
}

@media screen and (max-width: 400px) {
   #logo {
        bottom: 7.5px;
        font-size: 23px;
        padding-left: 10px;
        text-align: left;
    }

    #menu-icon {
        height: 32px;
        width: 32px;
        background-image: url("../images/hamburg-white-1.png");
        top: 0.4px;
        right: 20px;
    }

    #main-container {
        padding-top: 52.4px;
    }
}

/* ----INTORDUCTION---- */

#introductory-background {
    background-image: url('../images/eternity-1024x768.jpg');
    background-position: center center;
    background-repeat: no-repeat;
    background-size: cover;
    width: 100%;
/*    min-height: 527px;*/
    height: 90vh;
    background-size: 100% 100%;
    overflow: auto;
}

#introductory-overlay {
    display: table;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
}

#introductory-content {
    margin-left: auto;
    margin-right: auto;
    display: table-cell;
    vertical-align: middle;
    text-align: center;
}

#introductory-container {
    position: relative;
    bottom: 60px;
}

h1#role-header {
    display: block;
    position: relative;
    right: 5em;
    opacity: 0;
    font-size: 48px;
    color: rgb(255, 250, 250);
}

h3#role-support-text {
    display: block;
    opacity: 0;
    position: relative;
    top: 20px;
    font-size: 30px;
    color: rgb(255, 250, 250);
}

#read-more {
    border-radius: 38px;
    background-color: rgb(255, 250, 250);
    padding: 0.5em 1.5em;
    font-size: 24px;
    cursor: pointer;
}

@media screen and (max-width: 656px) {

    #introductory-container {
        bottom: 60px;
    }

    h1#role-header {
        font-size: 37px;
    }

    h3#role-support-text {
        top: 15px;
        font-size: 24px;
    }

    #read-more {
        font-size: 19px;
    }
}

@media screen and (max-width: 400px) {

    #introductory-container {
        bottom: 72.5px;
    }

   h1#role-header {
        font-size: 28px;
    }

    h3#role-support-text {
        top: 11px;
        font-size: 20px;
    }

    #read-more {
        font-size: 16px;
    }
}

/* -------------------- */
/* -------ABOUT-------- */

#about-section {
    width: 100%;
    height: 500px;
    background-color: rgb(131, 111, 235);
}

#photo-frame {
    margin: 0 auto;
    background-color: royalblue;
    width: 180px;
    height: 180px;
    border-radius: 100px;
    border-style: solid;
    border-color: beige;
    border-width: 7.5px;
    z-index: 2;
}

#photo-frame > #picture {
    width: 100%;
    height: 100%;
    background-image: url('../images/Ed.png');
    border-radius: 100px;
}

#about-section > #about-text-container {
    margin: 0 auto;
    width: 80%;
}

#about-section > #about-text-container > p {
    margin: 0;
    text-align: center;
/*    padding: 0 3rem;*/
    font-size: 22px;
}

#about-section > #about-text-container > p.side-by-side {
/*    display: inline-block;*/
    width: 45%;
    text-align: justify;
}

#about-section > #about-text-container > p#about-left-side {
    float: left;
}

#about-section > #about-text-container > p#about-right-side{
    float: right;
}

@media screen and (max-width: 868px) {
    #about-section > #about-text-container > p.side-by-side {
    /*    display: inline-block;*/
        width: 100%;
    }

    #about-section > #about-text-container > p#about-left-side {
        float: none;
        padding-bottom: 1.5rem;
    }

    #about-section > #about-text-container > p#about-right-side{
        float: none;
    }
}

@media screen and (max-width: 656px) {
    #photo-frame {
        width: 150px;
        height: 150px;
    }

    #about-section > #about-text-container {
        width: 90%;
    }

    #about-section > #about-text-container > p {
        text-align: justify;
        padding: 0 1.5rem;
        font-size: 20px;
    }
}

@media screen and (max-width: 400px) {
    #photo-frame {
        width: 125px;
        height: 125px;
    }

    #about-section > #about-text-container {
        width: 100%;
    }

    #about-section > #about-text-container > p {
        padding: 0 0.5rem;
        font-size: 18px;
    }
}

/* -------------------- */
/* -------FOOTER------- */

footer {
    width: 100%;
    background-color: black;
}

footer > p#footer-text {
    margin: 0;
    text-align: center;
    font-family: arial;
    color: rgb(169, 169, 169);
    padding: 20px;
    width: 100%;
    -moz-box-sizing: border-box;
    -webkit-box-sizing: border-box;
    box-sizing: border-box;
}

/* -------------------- */

.no-select {
    -webkit-touch-callout: none; /* iOS Safari */
    -webkit-user-select: none;   /* Safari */
    -khtml-user-select: none;    /* Konqueror HTML */
    -moz-user-select: none;      /* Firefox */
    -ms-user-select: none;       /* Internet Explorer/Edge */
    user-select: none;           /* Non-prefixed version, currently supported by Chrome and Opera */
}

.clearfix:before,
.clearfix:after {
    content: " ";
    display: table;
}
.clearfix:after {
    clear: both;
}
.clearfix {
    *zoom: 1;
}

Body:
Try this:

#about-section {
    width: 100%;
    background-color: rgb(131, 111, 235);
}

Description

You are using #about-section id remove the height property or use height:auto, you have given a fixed height. And use float:left as well in p tag ids.

here your update code


来源: stackexchange

问:
Click event doesn't work after append
I want to dynamic click on first click of paragraph but its not working.

$(document).ready(function() {
  $(".newclass").click(function() {
    var append_code = 'Youre clicked';
    $('body').append(append_code);
    $(".hrefclick").click();

    $(document).on('click', '.hrefclick', function(e) {
      alert("yess! You're clicked");
      // do whatever
    });
  });
});```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<p class="newclass">
  Hit me!
</p></code>```

js Fiddle

答:
You need to trigger the click() after the delegation, just change the order of your lines:

$(document).ready(function() {
  $(".newclass").click(function() {
    var append_code = 'Youre clicked';
    $('body').append(append_code);

    $(document).on('click', '.hrefclick', function(e) {
      alert("yess! You're clicked");
      // do whatever
    });
    $(".hrefclick").click();

  });
});```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<p class="newclass">
  Hit me!
</p></code>```

ContentLicense: CC BY-SA 3.0

Title: Click event doesn't work after append

Body:
I want to dynamic click on first click of paragraph but its not working.

$(document).ready(function() {
  $(".newclass").click(function() {
    var append_code = 'Youre clicked';
    $('body').append(append_code);
    $(".hrefclick").click();

    $(document).on('click', '.hrefclick', function(e) {
      alert("yess! You're clicked");
      // do whatever
    });
  });
});

  Hit me!

js Fiddle

Body:
You need to trigger the click() after the delegation, just change the order of your lines:

$(document).ready(function() {
  $(".newclass").click(function() {
    var append_code = '<a href="google.com" class="hrefclick">Youre clicked</a>';
    $('body').append(append_code);

    $(document).on('click', '.hrefclick', function(e) {
      alert("yess! You're clicked");
      // do whatever
    });
    $(".hrefclick").click();

  });
});

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<p class="newclass">
  Hit me!
</p>


问:
How to create flyout effect using jQuery
See: http://www.obout.com/flyout/flyout.aspx

How to create a flyout effect similar to the one shown in the page linked to above using jQuery?

答: You can use the 'transfer' effect in the jQuery UI effect-package: http://jqueryui.com/demos/effect/</p>

ContentLicense: CC BY-SA 2.5


问:
How to include an external jar lib in my Ant build
I have the following build.xml:

```<code><project>

<target name="clean">
    <delete dir="./build"/>
</target>

<target name="compile">
    <mkdir dir="./build/classes"/>
    <javac srcdir="./src" destdir="./build/classes"/>
</target>

<target name="jar">
    <mkdir dir="./build/jar"/>
    <jar destfile="./build/jar/DependencyFinder.jar" basedir="./build/classes">
        <manifest>
            <attribute name="DependencyFinder" value="main"/>
        </manifest>
    </jar>
</target>

<target name="run">
    <java jar="./build/jar/DependencyFinder.jar" classname="${main-class}" fork="true"/>
</target>

</project>
</code>```

Here is my directory structure:

/build
/lib
/MagicFolder
/Src
/build.xml

Folder src contains .java files.

Path to MagicFolder should be an input parameter.

lib has external .jar library which should be included in my build.

build folder which will have compiled .jar and.class` files

QUESTION:
How should I change my build.xml? My build.xml should:

Add external lib ./lib/jbl.jar

When I run my application put 2 input parametrs for my application

答:
try with this:</p>

```<code><target name="jar" depends="clean,compile" >
   <jar destfile="./build/jar/DependencyFinder.jar">
    <fileset dir="./lib" includes="jbl.jar,mysql*.jar" />
    <fileset dir="./build/classes" excludes="**/form/*.class,**/orm/*.class,**/org/w3/xmldsig/*.class"/>
   </jar>
</target>
</code>```

Body:
I have the following build.xml:

<project>

<target name="clean">
    <delete dir="./build"/>
</target>

<target name="compile">
    <mkdir dir="./build/classes"/>
    <javac srcdir="./src" destdir="./build/classes"/>
</target>

<target name="jar">
    <mkdir dir="./build/jar"/>
    <jar destfile="./build/jar/DependencyFinder.jar" basedir="./build/classes">
        <manifest>
            <attribute name="DependencyFinder" value="main"/>
        </manifest>
    </jar>
</target>

<target name="run">
    <java jar="./build/jar/DependencyFinder.jar" classname="${main-class}" fork="true"/>
</target>

</project>

Here is my directory structure:

/build
/lib
/MagicFolder
/Src
/build.xml

Folder src contains .java files.

Path to MagicFolder should be an input parameter.

lib has external .jar library which should be included in my build.

build folder which will have compiled .jar and.class` files

QUESTION:
How should I change my build.xml? My build.xml should:

Add external lib ./lib/jbl.jar

When I run my application put 2 input parametrs for my application

Body:
try with this:

<target name="jar" depends="clean,compile" >
   <jar destfile="./build/jar/DependencyFinder.jar">
    <fileset dir="./lib" includes="jbl.jar,mysql*.jar" />
    <fileset dir="./build/classes" excludes="**/form/*.class,**/orm/*.class,**/org/w3/xmldsig/*.class"/>
   </jar>
</target>


问:
Align fields correctly
I really need your help to correctly format/position my form fields and its labels with proper indention and margins. The labels "CATEGORY A" and "CATEGORY B" are just sample text, but actually they will be dynamically changed its content and length, so it is important to auto-wrap it before it overlaps on "Button1" and "Button2" elements.  I am using bootstrap here to make my fields responsive.

This is the actual design format that I want to achieve:

And this is the current code that I have so far.

JSFIDDLE

<link href="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet"/>

 Field 1

        <input class="form-control " id="main-label-1" name="main-field-1" placeholder="Number" title="Enter Value" type="text">

 Field 2

        <input class="form-control " id="main-label-2" name="main-field-2" placeholder="Number" title="Enter Value" type="text">

Other Fields

CATEGORY A <button class="btn btn-primary" style="min-width:55px;margin-right:3px;margin-bottom:3px;padding:3px" title="">Button 1</button><button class="btn btn-primary" style="min-width:55px;margin-right:3px;margin-bottom:3px;padding:3px" title="">Button 2</button>

 Field 1

        <input class="form-control " id="main-label-1" name="main-field-1" placeholder="Number" title="Enter Value" type="text">

 Field 2

        <input class="form-control " id="main-label-2" name="main-field-2" placeholder="Number" title="Enter Value" type="text">

CATEGORY B <button class="btn btn-primary" style="min-width:55px;margin-right:3px;margin-bottom:3px;padding:3px" title="">Button 1</button><button class="btn btn-primary" style="min-width:55px;margin-right:3px;margin-bottom:3px;padding:3px" title="">Button 2</button>

 Field 1

        <input class="form-control " id="main-label-1" name="main-field-1" placeholder="Number" title="Enter Value" type="text">

 Field 2

        <input class="form-control " id="main-label-2" name="main-field-2" placeholder="Number" title="Enter Value" type="text">

```

答:
I think you may need to use some offsets to achieve what you are looking for

Here is one solution you may have to view full page since I did not optimize the smaller viewports. ( I will leave that for you if you want something different )

Notice also that the longer categories will wrap lines as needed
and I am not sure if you knew about the btn-sizing classes

another note that may have been causing you some issue was attempting to use inline styles that may break some of the bootstrap classes whenever possible find bootstrap classes that fit your need or create a custom class to fit your need. It makes editing later much easier

.other-fields {
  margin: 40px 0 20px;
  font-weight: 700;
}

.btn-custom {
  min-width: 55px;
  margin-right: 3px;
  margin-bottom: 3px;
  padding: 3px
}
.row.row-fg.category{
  margin-top:20px;
  margin-bottom:20px;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">

<!-- Latest compiled and minified JavaScript -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>

<div class="container">
<form class="form">
  <div class="row row-fg ">
    <label class="control-label  col-md-3" for="main-field-1">Field 1</label>
    <div class="form_field  col-md-9  required">
      <input class="form-control " id="main-label-1" name="main-field-1" placeholder="Number" title="Enter Value" type="text">
      <div class="" style="display:none"></div>
    </div>
  </div>

  <div class="row row-fg ">
    <label class="control-label  col-md-3" for="main-field-2">Field 2</label>
    <div class="form_field  col-md-9  required">
      <input class="form-control " id="main-label-2" name="main-field-2" placeholder="Number" title="Enter Value" type="text">
      <div class="" style="display:none"></div>
    </div>
  </div>
  <div class="of-cont">

    <h4 class="other-fields">Other Fields</h4>

    <div class="row row-fg category">
      <div class="col-md-offset-1 col-md-3">
        CATEGORY A
      </div>
      <div class="col-md-8">
        <button class="btn btn-primary btn-custom">Button 1</button>
        <button class="btn btn-primary btn-custom" title="">Button 2</button>
      </div>
    </div>

    <div class="row row-fg ">
      <label class="control-label col-md-offset-1  col-md-2 text-right" for="main-field-1">Field 1</label>
      <div class="form_field col-md-offset-1  col-md-8  required">
        <input class="form-control " id="main-label-1" name="main-field-1" placeholder="Number" title="Enter Value" type="text">
        <div class="" style="display:none"></div>
      </div>
    </div>

    <div class="row row-fg ">
      <label class="control-label col-md-offset-1  col-md-2 text-right" for="main-field-1">Field 1</label>
      <div class="form_field col-md-offset-1  col-md-8  required">
        <input class="form-control " id="main-label-1" name="main-field-1" placeholder="Number" title="Enter Value" type="text">
        <div class="" style="display:none"></div>
      </div>
    </div>

  </div>

  <div class="row row-fg category">
    <div class="col-md-offset-1 col-md-3">

      CATEGORY B is a long title that should wrap lines. Notice these btns are using btn sizing classes

    </div>
    <div class="col-md-8">
      <button class="btn btn-primary  btn-xs">Button 1</button>
      <button class="btn btn-primary  btn-sm" title="">Button 2</button>
    </div>
  </div>

  <div class="row row-fg ">
    <label class="control-label col-md-offset-1 col-md-2 text-right" for="main-field-1">Field 1</label>
    <div class="form_field col-md-offset-1  col-md-8  required">
      <input class="form-control " id="main-label-1" name="main-field-1" placeholder="Number" title="Enter Value" type="text">
      <div class="" style="display:none"></div>
    </div>
  </div>

  <div class="row row-fg ">
    <label class="control-label col-md-offset-1  col-md-2 text-right" for="main-field-1">Field 1</label>
    <div class="form_field col-md-offset-1 col-md-8  required">
      <input class="form-control " id="main-label-1" name="main-field-1" placeholder="Number" title="Enter Value" type="text">
      <div class="" style="display:none"></div>
    </div>
  </div>
  </form>
</div></code>```

Title: Align fields correctly

Body:
I think you may need to use some offsets to achieve what you are looking for

Here is one solution you may have to view full page since I did not optimize the smaller viewports. ( I will leave that for you if you want something different )

Notice also that the longer categories will wrap lines as needed
and I am not sure if you knew about the btn-sizing classes

another note that may have been causing you some issue was attempting to use inline styles that may break some of the bootstrap classes whenever possible find bootstrap classes that fit your need or create a custom class to fit your need. It makes editing later much easier

.other-fields {
  margin: 40px 0 20px;
  font-weight: 700;
}

.btn-custom {
  min-width: 55px;
  margin-right: 3px;
  margin-bottom: 3px;
  padding: 3px
}
.row.row-fg.category{
  margin-top:20px;
  margin-bottom:20px;
}

<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">

<!-- Latest compiled and minified JavaScript -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>

<div class="container">
<form class="form">
  <div class="row row-fg ">
    <label class="control-label  col-md-3" for="main-field-1">Field 1</label>
    <div class="form_field  col-md-9  required">
      <input class="form-control " id="main-label-1" name="main-field-1" placeholder="Number" title="Enter Value" type="text">
      <div class="" style="display:none"></div>
    </div>
  </div>

  <div class="row row-fg ">
    <label class="control-label  col-md-3" for="main-field-2">Field 2</label>
    <div class="form_field  col-md-9  required">
      <input class="form-control " id="main-label-2" name="main-field-2" placeholder="Number" title="Enter Value" type="text">
      <div class="" style="display:none"></div>
    </div>
  </div>
  <div class="of-cont">

    <h4 class="other-fields">Other Fields</h4>

    <div class="row row-fg category">
      <div class="col-md-offset-1 col-md-3">
        CATEGORY A
      </div>
      <div class="col-md-8">
        <button class="btn btn-primary btn-custom">Button 1</button>
        <button class="btn btn-primary btn-custom" title="">Button 2</button>
      </div>
    </div>

    <div class="row row-fg ">
      <label class="control-label col-md-offset-1  col-md-2 text-right" for="main-field-1">Field 1</label>
      <div class="form_field col-md-offset-1  col-md-8  required">
        <input class="form-control " id="main-label-1" name="main-field-1" placeholder="Number" title="Enter Value" type="text">
        <div class="" style="display:none"></div>
      </div>
    </div>

    <div class="row row-fg ">
      <label class="control-label col-md-offset-1  col-md-2 text-right" for="main-field-1">Field 1</label>
      <div class="form_field col-md-offset-1  col-md-8  required">
        <input class="form-control " id="main-label-1" name="main-field-1" placeholder="Number" title="Enter Value" type="text">
        <div class="" style="display:none"></div>
      </div>
    </div>

  </div>

  <div class="row row-fg category">
    <div class="col-md-offset-1 col-md-3">

      CATEGORY B is a long title that should wrap lines. Notice these btns are using btn sizing classes

    </div>
    <div class="col-md-8">
      <button class="btn btn-primary  btn-xs">Button 1</button>
      <button class="btn btn-primary  btn-sm" title="">Button 2</button>
    </div>
  </div>

  <div class="row row-fg ">
    <label class="control-label col-md-offset-1 col-md-2 text-right" for="main-field-1">Field 1</label>
    <div class="form_field col-md-offset-1  col-md-8  required">
      <input class="form-control " id="main-label-1" name="main-field-1" placeholder="Number" title="Enter Value" type="text">
      <div class="" style="display:none"></div>
    </div>
  </div>

  <div class="row row-fg ">
    <label class="control-label col-md-offset-1  col-md-2 text-right" for="main-field-1">Field 1</label>
    <div class="form_field col-md-offset-1 col-md-8  required">
      <input class="form-control " id="main-label-1" name="main-field-1" placeholder="Number" title="Enter Value" type="text">
      <div class="" style="display:none"></div>
    </div>
  </div>
  </form>
</div>


问:
How to toggleClass with SignalR hub.server?
I am currently learning SignalR with .Net MVC and following a tutorial to work on a simple app. Right now it is working alright, but I am having trouble understanding some part and also if possible, want to sort of enhance it.

Plane Seats Tutorial link

Right now the app is working as when a user clicks on a seat, it reserves it. And there is no going back. I want to implement like a toggle, where if the user wants to change seat, he gets to unreserve his selected seat, and then be free to reserve another one. I am not being able to do it with myHub.server.selectSeat(userId, $(this).toggleClass(settings.selectingSeatCss));. Whenever I click on a seat, it gives me this error in the Dev tools

Uncaught: Converting circular structure to JSON

```<code>var settings = {
    rows: 5,
    cols: 15,
    rowCssPrefix: 'row-',
    colCssPrefix: 'col-',
    seatWidth: 35,
    seatHeight: 35,
    seatCss: 'seat',
    selectedSeatCss: 'selectedSeat',
    selectingSeatCss: 'selectingSeat'
};
$(function() {
    //// Start the hub
    window.hubReady = $.connection.hub.start();
});
$.connection.hub.start().done(function() {
    // Call the server side function AFTER the connection has been started
    myHub.server.createUser();
    //invoke for the user data
    myHub.server.populateSeatData();
});
// Seat selection
$('.' + settings.seatCss).click(function() {
    if ($(this).hasClass(settings.selectedSeatCss)) {
        alert('Sorry, this seat has been already reserved');
    } else {
        //$(this).toggleClass(settings.selectingSeatCss);
        //myHub.server.selectSeat(userId, $(this).toggleClass(settings.selectingSeatCss));
        myHub.server.selectSeat(userId, $(this)[0].innerText);
    }
});
// Client method to broadcast the message
myHub.client.createUser = function(message) {
    userId = message;
};
//get seats data
myHub.client.populateSeatData = function(message) {
    var parsedSeatsData = JSON.parse(message);
    $('li.seat').removeClass(settings.selectedSeatCss);
    $.each(parsedSeatsData, function(index, value) {
        $("a:contains('" + value.seatnumber + "')").parent("li").toggleClass(settings.selectedSeatCss);
    });
};
// Client method to broadcast the message as user selected the seat
myHub.client.selectSeat = function(message) {
    var parsedSeatData = JSON.parse(message);
    $("a:contains('" + parsedSeatData.seatnumber + "')").parent("li").toggleClass(settings.selectedSeatCss);
};
</code>```

And can anyone please briefly explain what is str.push doing in this block of code? What is it exactly pushing into the array?

```<code>var init = function(reservedSeat) {
    var str = [],
        seatNo, className;
    for (i = 0; i < settings.rows; i++) {
        for (j = 2; j < settings.cols; j++) {
            seatNo = (i + j * settings.rows + 1);
            className = settings.seatCss + ' ' + settings.rowCssPrefix + i.toString() + ' ' + settings.colCssPrefix + j.toString();
            if ($.isArray(reservedSeat) && $.inArray(seatNo, reservedSeat) != -1) {
                className += ' ' + settings.selectedSeatCss;
            }
            str.push('<li class="' + className + '"' + 'style="top:' + (i * settings.seatHeight).toString() + 'px;left:' + (j * settings.seatWidth).toString() + 'px">' + '<a title="' + seatNo + '">' + seatNo + '</a>' + '</li>');
        }
    }
    $('#place').html(str.join(''));
};
</code>```

答:
I had to use a toggleSeat() function instead of just using toggleClass.

```<code>public void toggleSeat(int userId, int seatNumber)
        {
            PlaneSeatArrangment mySeat = allSeats.Where(s => s.SeatNumber == seatNumber).FirstOrDefault();
            var retunData = JsonConvert.SerializeObject(mySeat);
            if (mySeat != null && userId == mySeat.UserId)

            ..............
        }
</code>```

Body:
I am currently learning SignalR with .Net MVC and following a tutorial to work on a simple app. Right now it is working alright, but I am having trouble understanding some part and also if possible, want to sort of enhance it.

Plane Seats Tutorial link

Right now the app is working as when a user clicks on a seat, it reserves it. And there is no going back. I want to implement like a toggle, where if the user wants to change seat, he gets to unreserve his selected seat, and then be free to reserve another one. I am not being able to do it with myHub.server.selectSeat(userId, $(this).toggleClass(settings.selectingSeatCss));. Whenever I click on a seat, it gives me this error in the Dev tools

Uncaught: Converting circular structure to JSON

var settings = {
    rows: 5,
    cols: 15,
    rowCssPrefix: 'row-',
    colCssPrefix: 'col-',
    seatWidth: 35,
    seatHeight: 35,
    seatCss: 'seat',
    selectedSeatCss: 'selectedSeat',
    selectingSeatCss: 'selectingSeat'
};
$(function() {
    //// Start the hub
    window.hubReady = $.connection.hub.start();
});
$.connection.hub.start().done(function() {
    // Call the server side function AFTER the connection has been started
    myHub.server.createUser();
    //invoke for the user data
    myHub.server.populateSeatData();
});
// Seat selection
$('.' + settings.seatCss).click(function() {
    if ($(this).hasClass(settings.selectedSeatCss)) {
        alert('Sorry, this seat has been already reserved');
    } else {
        //$(this).toggleClass(settings.selectingSeatCss);
        //myHub.server.selectSeat(userId, $(this).toggleClass(settings.selectingSeatCss));
        myHub.server.selectSeat(userId, $(this)[0].innerText);
    }
});
// Client method to broadcast the message
myHub.client.createUser = function(message) {
    userId = message;
};
//get seats data
myHub.client.populateSeatData = function(message) {
    var parsedSeatsData = JSON.parse(message);
    $('li.seat').removeClass(settings.selectedSeatCss);
    $.each(parsedSeatsData, function(index, value) {
        $("a:contains('" + value.seatnumber + "')").parent("li").toggleClass(settings.selectedSeatCss);
    });
};
// Client method to broadcast the message as user selected the seat
myHub.client.selectSeat = function(message) {
    var parsedSeatData = JSON.parse(message);
    $("a:contains('" + parsedSeatData.seatnumber + "')").parent("li").toggleClass(settings.selectedSeatCss);
};

And can anyone please briefly explain what is str.push doing in this block of code? What is it exactly pushing into the array?

var init = function(reservedSeat) {
    var str = [],
        seatNo, className;
    for (i = 0; i < settings.rows; i++) {
        for (j = 2; j < settings.cols; j++) {
            seatNo = (i + j * settings.rows + 1);
            className = settings.seatCss + ' ' + settings.rowCssPrefix + i.toString() + ' ' + settings.colCssPrefix + j.toString();
            if ($.isArray(reservedSeat) && $.inArray(seatNo, reservedSeat) != -1) {
                className += ' ' + settings.selectedSeatCss;
            }
            str.push('
' + '' + seatNo + '' + '
');
        }
    }
    $('#place').html(str.join(''));
};

Body:
I had to use a toggleSeat() function instead of just using toggleClass.

public void toggleSeat(int userId, int seatNumber)
        {
            PlaneSeatArrangment mySeat = allSeats.Where(s => s.SeatNumber == seatNumber).FirstOrDefault();
            var retunData = JsonConvert.SerializeObject(mySeat);
            if (mySeat != null && userId == mySeat.UserId)

            ..............
        }


问:
caffe what is SetLossWeights?
I am reading caffe's Layer source code but I got following questions:

What is Layer::SetLossWeights function doing? I know that inside Layer class, there is a loss_ variable, which documents:

The vector that indicates whether each top blob has a non-zero weight
  in the objective function.

Do they have some relationships ?

Inside the caffe.proto file, LayerParameter loss_weight is only for loss layers, is that correct?

Thanks very much.

答:
The purpose of loss weight is to combine loss from multiple layers. So Layer::SetLossWeights is assigning the loss weight to loss_ variable and diff blob which is used in forward to compute total loss.

As default layers with suffix loss have loss weight 1 and others with 0. But any layer that is able to backpropagate can be given a non-zero loss_weight.

For detail information see caffe loss tutorial.

Edit:

Loss weight will only change if it is input to another layer that does backprop which is not intended by the authors. As they said for Accuracy layer in this pull request it will break. The purpose of the diff in loss layer is to store loss weight not store gradient. For more detail you can see this discussion in caffe-users group.

Title: caffe what is SetLossWeights?


问:
Pass connections with https using pauseOnConnect
I am using the pauseOnConnect option on net.createServer() to allow me to pass connections to workers I created using cluster.

```<code>server = net.createServer({ pauseOnConnect : true }, function(connection){
    console.log('passing connection to worker...');
    // received a connection and need to pass it to the appropriate worker
    var workerIndex = getWorkerIndex(connection.remoteAddress, numberOfProcesses);
    var worker = workers[workerIndex];
    worker.send("sticky-session:connection", connection);
}).listen(portNumber, function(){
    logger.info("Server started on port " + portNumber);
});
</code>```

Is there a way for me to use pauseOnConnect with https, either by using the https module or converting a net server to use https?

答:
I have created an example based on Elad's solution

Here is a full example of how to use both (http and https) servers with node.js cluster

var express = require('express'),
    cluster = require('cluster'),
    http = require('http'),
    https = require('https'),
    sio = require('socket.io'),
    fs = require('fs');

var httpPort = 3000,
    httpsPort = 4000,
    num_processes = require('os').cpus().length,
    httpsOptions = {
        key: fs.readFileSync('pkey.pem'),
        cert: fs.readFileSync('cert.pem')
    };

if (cluster.isMaster) {
    // This stores our workers. We need to keep them to be able to reference
    // them based on source IP address. It's also useful for auto-restart,
    // for example.
    var workers = [];

    // Helper function for spawning worker at index 'i'.
    var spawn = function(i) {
        workers[i] = cluster.fork();

        // Optional: Restart worker on exit
        workers[i].on('exit', function(code, signal) {
            console.log('respawning worker', i);
            spawn(i);
        });
    };

    // Spawn workers.
    for (var i = 0; i < num_processes; i++) {
        spawn(i);
    }

    // Helper function for getting a worker index based on IP address.
    // This is a hot path so it should be really fast. The way it works
    // is by converting the IP address to a number by removing non numeric
    // characters, then compressing it to the number of slots we have.
    //
    // Compared against "real" hashing (from the sticky-session code) and
    // "real" IP number conversion, this function is on par in terms of
    // worker index distribution only much faster.
    var worker_index = function(ip, len) {
        var s = '';
        for (var i = 0, _len = ip.length; i < _len; i++) {
            if (!isNaN(ip[i])) {
                s += ip[i];
            }
        }

        return Number(s) % len;
    };

    // Create the outside facing server listening on our http port.
    var httpServer = http.createServer();
    httpServer.on('connection', function(connection) {
        //pauseOnConnect
        connection.pause();

        // We received a connection and need to pass it to the appropriate
        // worker. Get the worker for this connection's source IP and pass
        // it the connection.
        if(connection.remoteAddress) {
            var worker = workers[_workerIndex(connection.remoteAddress, numProcesses)];
            worker.send(eventMessage, connection);
        }
    });
    httpServer.listen(httpPort, function() {
        console.log('http-Server up and running at %s port', httpPort);
    });

    // Create the outside facing server listening on our https port.
    var httpsServer = https.createServer(httpsOptions);
    httpsServer.on('connection', function(connection) {
        //pauseOnConnect
        connection.pause();

        // We received a connection and need to pass it to the appropriate
        // worker. Get the worker for this connection's source IP and pass
        // it the connection.
        if(connection.remoteAddress) {
            var worker = workers[worker_index(connection.remoteAddress, num_processes)];
            worker.send('sticky-session:https-connection', connection);
        }
    });
    httpsServer.listen(httpsPort, function() {
        console.log('https-Server up and running at %s port', httpsPort);
    });
} else {
    // Note we don't use a port here because the master listens on it for us.
    var app = new express();
    app.get('/', function(req, res) {
        res.send("Hello World!");
    });

    // Here you might use middleware, attach routes, etc.

    // Don't expose our internal server to the outside.
    var httpServer = http.createServer(app).listen(0, 'localhost'),
        httpsServer = https.createServer(httpsOptions, app).listen(0, 'localhost'),
        io = sio(httpServer);
    io.attach(httpsServer);

    // Here you might use Socket.IO middleware for authorization etc.

    // Listen to messages sent from the master. Ignore everything else.
    process.on('message', function(message, connection) {
        if ( (message !== 'sticky-session:connection' && message !== 'sticky-session:https-connection') || !connection ) {
            return;
        }

        switch(message) {
            case "sticky-session:connection":
                // Emulate a connection event on the http server by emitting the
                // event with the connection the master sent us.
                httpServer.emit('connection', connection);
                break;
            case "sticky-session:https-connection":
                // Emulate a connection event on the https server by emitting the
                // event with the connection the master sent us.
                httpsServer.emit('connection', connection);
                break;
        }

        connection.resume();
    });
}
```

Body:
I am using the pauseOnConnect option on net.createServer() to allow me to pass connections to workers I created using cluster.

server = net.createServer({ pauseOnConnect : true }, function(connection){
    console.log('passing connection to worker...');
    // received a connection and need to pass it to the appropriate worker
    var workerIndex = getWorkerIndex(connection.remoteAddress, numberOfProcesses);
    var worker = workers[workerIndex];
    worker.send("sticky-session:connection", connection);
}).listen(portNumber, function(){
    logger.info("Server started on port " + portNumber);
});

Is there a way for me to use pauseOnConnect with https, either by using the https module or converting a net server to use https?


问:
Fake REST server in node.js
Many times I need a REST server with fake data, to start coding before other service is finished.

I need an easy and fast way to create a fake REST server, based  on a config file. The fake server must allow to configure several routes, specifying the HTTP method, and the returned payload and HTTP code (that could be different depending on parameters in query string or path).

It will be a plus that the payload could be configured to be JSON or plain text (depending on the service). A node.js module will be the best option, but other options will be ok if they do the job.

答:
You can try the JSON Server:

https://github.com/typicode/json-server

https://www.npmjs.com/package/json-server

From the readme:

"Get a full fake REST API with zero coding in less than 30 seconds (seriously)"

It powers the JSON Placeholder:

https://jsonplaceholder.typicode.com/

that lets you create fake REST APIs without even starting your own server.

Title: Fake REST server in node.js


问:
Need C library that implements set operations
I'm looking for a C library (not C++) that implements set operations. I need to support the following operations:

intersection

union

elementOf

isSubset

insert (add to set)

clone

equals

Could I just use the libc binary tree routines?

答: I haven't used it myself, but pblSet looks solid.</p>


问:
How to get Google map Markers from URLs using asynctask?
I am trying to get Markers from URL. What I want is get all Markers from this web service.

My code is not working. It is getting map_icon from the web service but not showing on the map. What can I do to make it work?

Log message:

```<code> E/pj: http://towncitycards.com/wp-content/uploads/2015/01/googlemapicons/5percent.png
 W/art: Suspending all threads took: 78.773ms
 E/addMarkers: 0
 W/System.err: android.os.NetworkOnMainThreadException
 W/System.err:     at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1303)
 W/System.err:     at java.net.Inet6AddressImpl.lookupHostByName(Inet6AddressImpl.java:86)
 W/System.err:     at java.net.Inet6AddressImpl.lookupAllHostAddr(Inet6AddressImpl.java:74)
 W/System.err:     at java.net.InetAddress.getAllByName(InetAddress.java:752)
 W/System.err:     at com.android.okhttp.internal.Network$1.resolveInetAddresses(Network.java:29)
 W/System.err:     at com.android.okhttp.internal.http.RouteSelector.resetNextInetSocketAddress(RouteSelector.java:187)
 W/System.err:     at com.android.okhttp.internal.http.RouteSelector.nextProxy(RouteSelector.java:156)
 W/System.err:     at com.android.okhttp.internal.http.RouteSelector.next(RouteSelector.java:98)
 W/System.err:     at com.android.okhttp.internal.http.HttpEngine.createNextConnection(HttpEngine.java:345)
 W/System.err:     at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:328)
 W/System.err:     at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:246)
 W/System.err:     at com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:457)
 W/System.err:     at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:405)
 W/System.err:     at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:243)
 W/System.err:     at app.towncitycards.activities.Frnt_mapActivity.addMarkers(Frnt_mapActivity.java:299)
 W/System.err:     at app.towncitycards.activities.Frnt_mapActivity.access$300(Frnt_mapActivity.java:73)
 W/System.err:     at app.towncitycards.activities.Frnt_mapActivity$Frnt_mIcons_Activity.onPostExecute(Frnt_mapActivity.java:428)
 W/System.err:     at app.towncitycards.activities.Frnt_mapActivity$Frnt_mIcons_Activity.onPostExecute(Frnt_mapActivity.java:332)
 W/System.err:     at android.os.AsyncTask.finish(AsyncTask.java:667)
 W/System.err:     at android.os.AsyncTask.-wrap1(AsyncTask.java)
 W/System.err:     at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:684)
 W/System.err:     at android.os.Handler.dispatchMessage(Handler.java:102)
 W/System.err:     at android.os.Looper.loop(Looper.java:154)
 W/System.err:     at android.app.ActivityThread.main(ActivityThread.java:6119)
 W/System.err:     at java.lang.reflect.Method.invoke(Native Method)
 W/System.err:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
 W/System.err:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
 E/pj: http://towncitycards.com/wp-content/uploads/2015/01/googlemapicons/save£2.png
 E/addMarkers: 1
 W/System.err: android.os.NetworkOnMainThreadException
 W/System.err:     at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1303)
 W/System.err:     at java.net.Inet6AddressImpl.lookupHostByName(Inet6AddressImpl.java:86)
 W/System.err:     at java.net.Inet6AddressImpl.lookupAllHostAddr(Inet6AddressImpl.java:74)
 W/System.err:     at java.net.InetAddress.getAllByName(InetAddress.java:752)
 W/System.err:     at com.android.okhttp.internal.Network$1.resolveInetAddresses(Network.java:29)
 W/System.err:     at com.android.okhttp.internal.http.RouteSelector.resetNextInetSocketAddress(RouteSelector.java:187)
 W/System.err:     at com.android.okhttp.internal.http.RouteSelector.nextProxy(RouteSelector.java:156)
 W/System.err:     at com.android.okhttp.internal.http.RouteSelector.next(RouteSelector.java:98)
 W/System.err:     at com.android.okhttp.internal.http.HttpEngine.createNextConnection(HttpEngine.java:345)
 W/System.err:     at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:328)
 W/System.err:     at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:246)
 W/System.err:     at com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:457)
 W/System.err:     at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:405)
 W/System.err:     at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:243)
 W/System.err:     at app.towncitycards.activities.Frnt_mapActivity.addMarkers(Frnt_mapActivity.java:299)
 W/System.err:     at app.towncitycards.activities.Frnt_mapActivity.access$300(Frnt_mapActivity.java:73)
 W/System.err:     at app.towncitycards.activities.Frnt_mapActivity$Frnt_mIcons_Activity.onPostExecute(Frnt_mapActivity.java:428)
 W/System.err:     at app.towncitycards.activities.Frnt_mapActivity$Frnt_mIcons_Activity.onPostExecute(Frnt_mapActivity.java:332)
 W/System.err:     at android.os.AsyncTask.finish(AsyncTask.java:667)
 W/System.err:     at android.os.AsyncTask.-wrap1(AsyncTask.java)
 W/System.err:     at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:684)
 W/System.err:     at android.os.Handler.dispatchMessage(Handler.java:102)
 W/System.err:     at android.os.Looper.loop(Looper.java:154)
 W/System.err:     at android.app.ActivityThread.main(ActivityThread.java:6119)
 W/System.err:     at java.lang.reflect.Method.invoke(Native Method)
 W/System.err:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
 W/System.err:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
</code>```

My code

```<code>public class Frnt_mapActivity extends Activity {

public String Shop_title;
public String Shop_address;
public String Shop_icons;
ProgressDialog mDialog;
JSONObject jsonobject3;
JSONArray jsonarray3;
 // Google Map
private static GoogleMap googlemap;

ArrayList<SearchBeams>getAllimgs;
// Location
ArrayList<String> world_locationlist;
ArrayList<LocationBeams> worldlocation;
// Looking for
ArrayList<String> looking_forlist;
ArrayList<LookingForBeams> world_looking_for;

public static ArrayList<SearchBeams> searchdata_list;
public static ArrayList<NormalSearchBeams> normlSearchList;
public static String mid;
public static String mpost_title;
public static String mimage;
public static List<String> imglist;

ArrayList<All_products_lat_long> venueList;

RelativeLayout r1;
public static ArrayList<SearchBeams> GetIMG;
public static TextView txtlocation;
public static TextView txtlookingfor;

public static ArrayList<All_products_lat_long> mpItm;
String vals;

private int i;
private Intent intent;
HashMap<Marker, Integer> hashMap=new HashMap<Marker, Integer>();
public static LatLng latlong ;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.frnt_map_activity);

    googlemap=((MapFragment)getFragmentManager().findFragmentById(R.id.places_map)).getMap();
    googlemap.setMapType(GoogleMap.MAP_TYPE_NORMAL);
    googlemap.setMyLocationEnabled(true);
    googlemap.getUiSettings().setZoomControlsEnabled(true);
    googlemap.getUiSettings().setMyLocationButtonEnabled(true);
    googlemap.getUiSettings().setCompassEnabled(true);
    googlemap.getUiSettings().setRotateGesturesEnabled(true);
    googlemap.getUiSettings().setZoomGesturesEnabled(true);
    googlemap.setMyLocationEnabled(true);
    intent=new Intent(Frnt_mapActivity.this,MainActivity.class);
    googlemap.setOnInfoWindowClickListener(new OnInfoWindowClickListener() {

        @Override
        public void onInfoWindowClick(Marker arg0) {
             i=hashMap.get(arg0);
                intent.putExtra("PRODUCT_ID", venueList.get(i).getId());
                startActivity(intent);
                //overridePendingTransition( R.anim.slide_right, R.anim.slide_left );
        }
    });

    new Frnt_mIcons_Activity().execute();

}
private void addMarkers() {

        for(int k=0; k<venueList.size(); k += 1){

            //nirmal
            try{
                Log.e("pj",venueList.get(k).getMap_icon());

                //new AddMarkerAsyncTask(venueList.get(k),k).execute();

                double ln = Double.parseDouble(venueList.get(k).getLongitude());
                double la = Double.parseDouble(venueList.get(k).getLatitude());
                String title=venueList.get(k).getPost_title()==null?"":venueList.get(k).getPost_title();
                URL url = new URL(venueList.get(k).getMap_icon());
                Bitmap image = BitmapFactory.decodeStream(url.openConnection().getInputStream());
                BitmapDescriptor bd=BitmapDescriptorFactory.fromBitmap(image);

                Marker marker=googlemap.addMarker(new MarkerOptions()
                        .position(new LatLng(la, ln))
                        .title(title)
                        .icon(bd));
                hashMap.put(marker, k);

            }catch (Exception e){
                Log.e("addMarkers",k+"");
                e.printStackTrace();
            }

        }
        }

/******************FOR MAP******************/
class Frnt_mIcons_Activity extends AsyncTask<String, String, String> {

    public ArrayList<All_products_lat_long> maplist;

    @Override
    protected void onPreExecute() {
        mDialog = new ProgressDialog(Frnt_mapActivity.this);
        mDialog.setMessage("Loading...");
        mDialog.setCancelable(false);
        mDialog.show();
        super.onPreExecute();
    }

    // Slow Implementation
    private String inputStreamToString(InputStream is) {
        String s = "";
        String line = "";
        // Wrap a BufferedReader around the InputStream
        BufferedReader rd = new BufferedReader(new InputStreamReader(is));
        // Read response until the end
        try {
            while ((line = rd.readLine()) != null) {
                s += line;
                }
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        // Return full string
        return s;
    }

    @Override
    protected String doInBackground(String... params) {
        // TODO Auto-generated method stub
        maplist = new ArrayList<All_products_lat_long>();

        HostnameVerifier hostnameVerifier = org.apache.http.conn.ssl.SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER;

        DefaultHttpClient client = new DefaultHttpClient();

        SchemeRegistry registry = new SchemeRegistry();
        SSLSocketFactory socketFactory = SSLSocketFactory.getSocketFactory();
        socketFactory.setHostnameVerifier((X509HostnameVerifier) hostnameVerifier);
        registry.register(new Scheme("http", socketFactory, 443));
        SingleClientConnManager mgr = new SingleClientConnManager(client.getParams(), registry);
        DefaultHttpClient httpClient = new DefaultHttpClient(mgr, client.getParams());

// Set verifier
            HttpsURLConnection.setDefaultHostnameVerifier(hostnameVerifier);

        HttpPost httpPost = new HttpPost("http://towncitycards.com/webservice_action.php?action=all_products");

        try{

            HttpResponse response = httpClient.execute(httpPost);
            String data = inputStreamToString(response.getEntity().getContent());
            jsonobject3 = new JSONObject(data);
            jsonarray3 = new JSONArray(jsonobject3.getString("all_products"));
            venueList =new ArrayList<All_products_lat_long>();
            for(int j=0; j<jsonarray3.length();j++){
                JSONObject itemobj = jsonarray3.getJSONObject(j);
                //SHOW SEARCH RESULT
                All_products_lat_long searchItems = new All_products_lat_long();

                searchItems.setId(itemobj.getString("ID"));
                searchItems.setPost_title(itemobj.getString("post_title"));
                searchItems.setMap_icon(itemobj.getString("map_icon"));
                searchItems.setLongitude(itemobj.getString("longitude"));
                searchItems.setLatitude(itemobj.getString("latitude"));
    //          System.out.println("######Ashish is object >>"+itemobj);
                venueList.add(searchItems);
    //      System.out.println("SEARCHLISTSS@@@@@@@"+venueList.get(j).getLongitude());
            }
        }catch(Exception e){
            e.printStackTrace();
        }
        return null;
    }

    @Override
    public void onPostExecute(String result) {
        super.onPostExecute(result);

        //System.out.println("SEARCHLISTSS@@@@@@@"+venueList);
        //System.out.println("AAAAAAAAAAAAAAAAAAAAAAAAAAA"+venueList);
        try{
            if(venueList.size()>0)
            {
            addMarkers();
        //Toast.makeText(Frnt_mapActivity.this,"Search for the venue11.",Toast.LENGTH_SHORT).show();

            }
            else
            Toast.makeText(Frnt_mapActivity.this,"Search for the venue.",Toast.LENGTH_SHORT).show();
            //LatLng coordinate = new LatLng(22.75852160, 75.8911550);
            LatLng coordinate = new LatLng(50.85514, 0.58382);
            CameraUpdate yourLocation = CameraUpdateFactory.newLatLngZoom(coordinate, 18);
            googlemap.animateCamera(yourLocation);
            for (int i = 0; i < jsonarray3.length(); i++) {

                jsonobject3 = jsonarray3.getJSONObject(i);

                Shop_title = jsonobject3.optString("post_title");
                Shop_address = jsonobject3.optString("map_icon");
                Shop_icons = jsonobject3.optString("map_icon");
                        //}
            }

        }catch(Exception e){
            e.printStackTrace();
        }

        if(mDialog!=null && mDialog.isShowing()){
            mDialog.dismiss();
        }
        }
    }

}
</code>```

答:
NetworkOnMainThreadException The exception that is thrown when an application attempts to perform a networking operation on its main thread.

in your onPostExecute() move your Json parsing code to doInBackground

Now in addMarkers() method use picasso to load the marker image and use the bitmap.

```<code> private Target target = new Target() {
      @Override
      public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
           //here you get the image bitmap
           //do your work
      }

      @Override
      public void onBitmapFailed(Drawable errorDrawable) {
      }

      @Override
      public void onPrepareLoad(Drawable placeHolderDrawable) {
      }
}
</code>```

call it using:

```<code>  Picasso.with(this).load("your_url").into(target);
</code>```

in gradle add: compile 'com.squareup.picasso:picasso:2.5.2'

Body:
I am trying to get Markers from URL. What I want is get all Markers from this web service.

My code is not working. It is getting map_icon from the web service but not showing on the map. What can I do to make it work?

Log message:

 E/pj: http://towncitycards.com/wp-content/uploads/2015/01/googlemapicons/5percent.png
 W/art: Suspending all threads took: 78.773ms
 E/addMarkers: 0
 W/System.err: android.os.NetworkOnMainThreadException
 W/System.err:     at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1303)
 W/System.err:     at java.net.Inet6AddressImpl.lookupHostByName(Inet6AddressImpl.java:86)
 W/System.err:     at java.net.Inet6AddressImpl.lookupAllHostAddr(Inet6AddressImpl.java:74)
 W/System.err:     at java.net.InetAddress.getAllByName(InetAddress.java:752)
 W/System.err:     at com.android.okhttp.internal.Network$1.resolveInetAddresses(Network.java:29)
 W/System.err:     at com.android.okhttp.internal.http.RouteSelector.resetNextInetSocketAddress(RouteSelector.java:187)
 W/System.err:     at com.android.okhttp.internal.http.RouteSelector.nextProxy(RouteSelector.java:156)
 W/System.err:     at com.android.okhttp.internal.http.RouteSelector.next(RouteSelector.java:98)
 W/System.err:     at com.android.okhttp.internal.http.HttpEngine.createNextConnection(HttpEngine.java:345)
 W/System.err:     at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:328)
 W/System.err:     at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:246)
 W/System.err:     at com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:457)
 W/System.err:     at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:405)
 W/System.err:     at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:243)
 W/System.err:     at app.towncitycards.activities.Frnt_mapActivity.addMarkers(Frnt_mapActivity.java:299)
 W/System.err:     at app.towncitycards.activities.Frnt_mapActivity.access$300(Frnt_mapActivity.java:73)
 W/System.err:     at app.towncitycards.activities.Frnt_mapActivity$Frnt_mIcons_Activity.onPostExecute(Frnt_mapActivity.java:428)
 W/System.err:     at app.towncitycards.activities.Frnt_mapActivity$Frnt_mIcons_Activity.onPostExecute(Frnt_mapActivity.java:332)
 W/System.err:     at android.os.AsyncTask.finish(AsyncTask.java:667)
 W/System.err:     at android.os.AsyncTask.-wrap1(AsyncTask.java)
 W/System.err:     at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:684)
 W/System.err:     at android.os.Handler.dispatchMessage(Handler.java:102)
 W/System.err:     at android.os.Looper.loop(Looper.java:154)
 W/System.err:     at android.app.ActivityThread.main(ActivityThread.java:6119)
 W/System.err:     at java.lang.reflect.Method.invoke(Native Method)
 W/System.err:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
 W/System.err:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
 E/pj: http://towncitycards.com/wp-content/uploads/2015/01/googlemapicons/save£2.png
 E/addMarkers: 1
 W/System.err: android.os.NetworkOnMainThreadException
 W/System.err:     at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1303)
 W/System.err:     at java.net.Inet6AddressImpl.lookupHostByName(Inet6AddressImpl.java:86)
 W/System.err:     at java.net.Inet6AddressImpl.lookupAllHostAddr(Inet6AddressImpl.java:74)
 W/System.err:     at java.net.InetAddress.getAllByName(InetAddress.java:752)
 W/System.err:     at com.android.okhttp.internal.Network$1.resolveInetAddresses(Network.java:29)
 W/System.err:     at com.android.okhttp.internal.http.RouteSelector.resetNextInetSocketAddress(RouteSelector.java:187)
 W/System.err:     at com.android.okhttp.internal.http.RouteSelector.nextProxy(RouteSelector.java:156)
 W/System.err:     at com.android.okhttp.internal.http.RouteSelector.next(RouteSelector.java:98)
 W/System.err:     at com.android.okhttp.internal.http.HttpEngine.createNextConnection(HttpEngine.java:345)
 W/System.err:     at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:328)
 W/System.err:     at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:246)
 W/System.err:     at com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:457)
 W/System.err:     at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:405)
 W/System.err:     at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:243)
 W/System.err:     at app.towncitycards.activities.Frnt_mapActivity.addMarkers(Frnt_mapActivity.java:299)
 W/System.err:     at app.towncitycards.activities.Frnt_mapActivity.access$300(Frnt_mapActivity.java:73)
 W/System.err:     at app.towncitycards.activities.Frnt_mapActivity$Frnt_mIcons_Activity.onPostExecute(Frnt_mapActivity.java:428)
 W/System.err:     at app.towncitycards.activities.Frnt_mapActivity$Frnt_mIcons_Activity.onPostExecute(Frnt_mapActivity.java:332)
 W/System.err:     at android.os.AsyncTask.finish(AsyncTask.java:667)
 W/System.err:     at android.os.AsyncTask.-wrap1(AsyncTask.java)
 W/System.err:     at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:684)
 W/System.err:     at android.os.Handler.dispatchMessage(Handler.java:102)
 W/System.err:     at android.os.Looper.loop(Looper.java:154)
 W/System.err:     at android.app.ActivityThread.main(ActivityThread.java:6119)
 W/System.err:     at java.lang.reflect.Method.invoke(Native Method)
 W/System.err:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
 W/System.err:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)

My code

public class Frnt_mapActivity extends Activity {

public String Shop_title;
public String Shop_address;
public String Shop_icons;
ProgressDialog mDialog;
JSONObject jsonobject3;
JSONArray jsonarray3;
 // Google Map
private static GoogleMap googlemap;

ArrayList<SearchBeams>getAllimgs;
// Location
ArrayList<String> world_locationlist;
ArrayList<LocationBeams> worldlocation;
// Looking for
ArrayList<String> looking_forlist;
ArrayList<LookingForBeams> world_looking_for;

public static ArrayList<SearchBeams> searchdata_list;
public static ArrayList<NormalSearchBeams> normlSearchList;
public static String mid;
public static String mpost_title;
public static String mimage;
public static List<String> imglist;

ArrayList<All_products_lat_long> venueList;

RelativeLayout r1;
public static ArrayList<SearchBeams> GetIMG;
public static TextView txtlocation;
public static TextView txtlookingfor;

public static ArrayList<All_products_lat_long> mpItm;
String vals;

private int i;
private Intent intent;
HashMap<Marker, Integer> hashMap=new HashMap<Marker, Integer>();
public static LatLng latlong ;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.frnt_map_activity);

    googlemap=((MapFragment)getFragmentManager().findFragmentById(R.id.places_map)).getMap();
    googlemap.setMapType(GoogleMap.MAP_TYPE_NORMAL);
    googlemap.setMyLocationEnabled(true);
    googlemap.getUiSettings().setZoomControlsEnabled(true);
    googlemap.getUiSettings().setMyLocationButtonEnabled(true);
    googlemap.getUiSettings().setCompassEnabled(true);
    googlemap.getUiSettings().setRotateGesturesEnabled(true);
    googlemap.getUiSettings().setZoomGesturesEnabled(true);
    googlemap.setMyLocationEnabled(true);
    intent=new Intent(Frnt_mapActivity.this,MainActivity.class);
    googlemap.setOnInfoWindowClickListener(new OnInfoWindowClickListener() {

        @Override
        public void onInfoWindowClick(Marker arg0) {
             i=hashMap.get(arg0);
                intent.putExtra("PRODUCT_ID", venueList.get(i).getId());
                startActivity(intent);
                //overridePendingTransition( R.anim.slide_right, R.anim.slide_left );
        }
    });

    new Frnt_mIcons_Activity().execute();

}
private void addMarkers() {

        for(int k=0; k<venueList.size(); k += 1){

            //nirmal
            try{
                Log.e("pj",venueList.get(k).getMap_icon());

                //new AddMarkerAsyncTask(venueList.get(k),k).execute();

                double ln = Double.parseDouble(venueList.get(k).getLongitude());
                double la = Double.parseDouble(venueList.get(k).getLatitude());
                String title=venueList.get(k).getPost_title()==null?"":venueList.get(k).getPost_title();
                URL url = new URL(venueList.get(k).getMap_icon());
                Bitmap image = BitmapFactory.decodeStream(url.openConnection().getInputStream());
                BitmapDescriptor bd=BitmapDescriptorFactory.fromBitmap(image);

                Marker marker=googlemap.addMarker(new MarkerOptions()
                        .position(new LatLng(la, ln))
                        .title(title)
                        .icon(bd));
                hashMap.put(marker, k);

            }catch (Exception e){
                Log.e("addMarkers",k+"");
                e.printStackTrace();
            }

        }
        }

/******************FOR MAP******************/
class Frnt_mIcons_Activity extends AsyncTask<String, String, String> {

    public ArrayList<All_products_lat_long> maplist;

    @Override
    protected void onPreExecute() {
        mDialog = new ProgressDialog(Frnt_mapActivity.this);
        mDialog.setMessage("Loading...");
        mDialog.setCancelable(false);
        mDialog.show();
        super.onPreExecute();
    }

    // Slow Implementation
    private String inputStreamToString(InputStream is) {
        String s = "";
        String line = "";
        // Wrap a BufferedReader around the InputStream
        BufferedReader rd = new BufferedReader(new InputStreamReader(is));
        // Read response until the end
        try {
            while ((line = rd.readLine()) != null) {
                s += line;
                }
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        // Return full string
        return s;
    }

    @Override
    protected String doInBackground(String... params) {
        // TODO Auto-generated method stub
        maplist = new ArrayList<All_products_lat_long>();

        HostnameVerifier hostnameVerifier = org.apache.http.conn.ssl.SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER;

        DefaultHttpClient client = new DefaultHttpClient();

        SchemeRegistry registry = new SchemeRegistry();
        SSLSocketFactory socketFactory = SSLSocketFactory.getSocketFactory();
        socketFactory.setHostnameVerifier((X509HostnameVerifier) hostnameVerifier);
        registry.register(new Scheme("http", socketFactory, 443));
        SingleClientConnManager mgr = new SingleClientConnManager(client.getParams(), registry);
        DefaultHttpClient httpClient = new DefaultHttpClient(mgr, client.getParams());

// Set verifier
            HttpsURLConnection.setDefaultHostnameVerifier(hostnameVerifier);

        HttpPost httpPost = new HttpPost("http://towncitycards.com/webservice_action.php?action=all_products");

        try{

            HttpResponse response = httpClient.execute(httpPost);
            String data = inputStreamToString(response.getEntity().getContent());
            jsonobject3 = new JSONObject(data);
            jsonarray3 = new JSONArray(jsonobject3.getString("all_products"));
            venueList =new ArrayList<All_products_lat_long>();
            for(int j=0; j<jsonarray3.length();j++){
                JSONObject itemobj = jsonarray3.getJSONObject(j);
                //SHOW SEARCH RESULT
                All_products_lat_long searchItems = new All_products_lat_long();

                searchItems.setId(itemobj.getString("ID"));
                searchItems.setPost_title(itemobj.getString("post_title"));
                searchItems.setMap_icon(itemobj.getString("map_icon"));
                searchItems.setLongitude(itemobj.getString("longitude"));
                searchItems.setLatitude(itemobj.getString("latitude"));
    //          System.out.println("######Ashish is object >>"+itemobj);
                venueList.add(searchItems);
    //      System.out.println("SEARCHLISTSS@@@@@@@"+venueList.get(j).getLongitude());
            }
        }catch(Exception e){
            e.printStackTrace();
        }
        return null;
    }

    @Override
    public void onPostExecute(String result) {
        super.onPostExecute(result);

        //System.out.println("SEARCHLISTSS@@@@@@@"+venueList);
        //System.out.println("AAAAAAAAAAAAAAAAAAAAAAAAAAA"+venueList);
        try{
            if(venueList.size()>0)
            {
            addMarkers();
        //Toast.makeText(Frnt_mapActivity.this,"Search for the venue11.",Toast.LENGTH_SHORT).show();

            }
            else
            Toast.makeText(Frnt_mapActivity.this,"Search for the venue.",Toast.LENGTH_SHORT).show();
            //LatLng coordinate = new LatLng(22.75852160, 75.8911550);
            LatLng coordinate = new LatLng(50.85514, 0.58382);
            CameraUpdate yourLocation = CameraUpdateFactory.newLatLngZoom(coordinate, 18);
            googlemap.animateCamera(yourLocation);
            for (int i = 0; i < jsonarray3.length(); i++) {

                jsonobject3 = jsonarray3.getJSONObject(i);

                Shop_title = jsonobject3.optString("post_title");
                Shop_address = jsonobject3.optString("map_icon");
                Shop_icons = jsonobject3.optString("map_icon");
                        //}
            }

        }catch(Exception e){
            e.printStackTrace();
        }

        if(mDialog!=null && mDialog.isShowing()){
            mDialog.dismiss();
        }
        }
    }

}

Body:
NetworkOnMainThreadException The exception that is thrown when an application attempts to perform a networking operation on its main thread.

in your onPostExecute() move your Json parsing code to doInBackground

Now in addMarkers() method use picasso to load the marker image and use the bitmap.

 private Target target = new Target() {
      @Override
      public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
           //here you get the image bitmap
           //do your work
      }

      @Override
      public void onBitmapFailed(Drawable errorDrawable) {
      }

      @Override
      public void onPrepareLoad(Drawable placeHolderDrawable) {
      }
}

call it using:

  Picasso.with(this).load("your_url").into(target);

in gradle add: compile 'com.squareup.picasso:picasso:2.5.2'


问:
Github code search on any branch
It is against general git workflow to make feature changes on a master branch. Sow= if I were to fork a repo my work ends up in .. feature branches..

How can I search those non-master branches on github?

Actually - even advanced search on Github seems to not find much of anything except for repository names and README files. It is not searching the codebase??

Here is an example of searching the yahoo user account for Process

: that should come up with dozens if not hundreds of hits. But we get .. four hits ..

So in general the github code search is a bit of a mystery .  I really want to find certain code snippets .. either on master or another branch .. is there a way to do this??

答:
There are tabs just below the header of the page - Repositories, Code, Commits, etc. If I click the Code tab I get 2k+ results.

There are some restrictions with searching code on GitHub, however, and branches other than master are not considered in the search. Also, only files smaller than 384 KB and repositories with less than 500,000 files are searchable. You can find more information related to searching code on GitHub here: https://help.github.com/articles/searching-code/

ContentLicense: CC BY-SA 4.0

Title: Github code search on any branch


问:
How to insert multiple, increasing by 1, rows to mysql database with php
I want to add 30 rows to my SQL database. The table has 3 columns: "Year", "Month", "Day". The rows should by added to "Day" column. I use the following code, as I want to do it once. When I post it through RESTeasy I can see in PHPmyadmin that only last row was added, in this case: "2017" "1" "31".

```<code>// Add days in month
$app->post('/api/calendar/add', function (Request $request, Response $response) {
    $year = $request->getParam('Year');
    $month = $request->getParam('Month');
    $day = $request->getParam('Day');

    $day = 1;
    while($day < 31) {
        $day = $day + 1;
        $sql = "INSERT INTO `days` (`Year`, `Month`, `Day`) VALUES ('2017', '1', '$day')";
        };

    try {
        // Get DB Object
        $dbcalendar = new dbcalendar();
        // Connect
        $dbcalendar = $dbcalendar->connect();

        $stmt = $dbcalendar->prepare($sql);

        $stmt->bindParam(':Year', $year);
        $stmt->bindParam('Month', $month);
        $stmt->bindParam('Day', $day);

        $stmt->execute();

        echo '{"notice": {"text": "Days Added"}';

    } catch(PDOException $e) {
        echo '{"error": {"text": '.$e->getMessage().'}';
    }
</code>```

答:
You need move try catch into the while

```<code>// Add days in month
$app->post('/api/calendar/add', function (Request $request, Response $response) {
    $year = $request->getParam('Year');
    $month = $request->getParam('Month');
    $day = $request->getParam('Day');

    $day = 1;
    while($day < 31) {
        $day = $day + 1;
        $sql = "INSERT INTO `days` (`Year`, `Month`, `Day`) VALUES ('2017', '1', '$day')";

        try {
            // Get DB Object
            $dbcalendar = new dbcalendar();
            // Connect
            $dbcalendar = $dbcalendar->connect();

            $stmt = $dbcalendar->prepare($sql);

            $stmt->bindParam(':Year', $year);
            $stmt->bindParam('Month', $month);
            $stmt->bindParam('Day', $day);

            $stmt->execute();

            echo '{"notice": {"text": "Days Added"}';

        } catch(PDOException $e) {
            echo '{"error": {"text": '.$e->getMessage().'}';
        }
    };
});
</code>```

Body:
I want to add 30 rows to my SQL database. The table has 3 columns: "Year", "Month", "Day". The rows should by added to "Day" column. I use the following code, as I want to do it once. When I post it through RESTeasy I can see in PHPmyadmin that only last row was added, in this case: "2017" "1" "31".

// Add days in month
$app->post('/api/calendar/add', function (Request $request, Response $response) {
    $year = $request->getParam('Year');
    $month = $request->getParam('Month');
    $day = $request->getParam('Day');

    $day = 1;
    while($day < 31) {
        $day = $day + 1;
        $sql = "INSERT INTO `days` (`Year`, `Month`, `Day`) VALUES ('2017', '1', '$day')";
        };

    try {
        // Get DB Object
        $dbcalendar = new dbcalendar();
        // Connect
        $dbcalendar = $dbcalendar->connect();

        $stmt = $dbcalendar->prepare($sql);

        $stmt->bindParam(':Year', $year);
        $stmt->bindParam('Month', $month);
        $stmt->bindParam('Day', $day);

        $stmt->execute();

        echo '{"notice": {"text": "Days Added"}';

    } catch(PDOException $e) {
        echo '{"error": {"text": '.$e->getMessage().'}';
    }

Body:
You need move try catch into the while

// Add days in month
$app->post('/api/calendar/add', function (Request $request, Response $response) {
    $year = $request->getParam('Year');
    $month = $request->getParam('Month');
    $day = $request->getParam('Day');

    $day = 1;
    while($day < 31) {
        $day = $day + 1;
        $sql = "INSERT INTO `days` (`Year`, `Month`, `Day`) VALUES ('2017', '1', '$day')";

        try {
            // Get DB Object
            $dbcalendar = new dbcalendar();
            // Connect
            $dbcalendar = $dbcalendar->connect();

            $stmt = $dbcalendar->prepare($sql);

            $stmt->bindParam(':Year', $year);
            $stmt->bindParam('Month', $month);
            $stmt->bindParam('Day', $day);

            $stmt->execute();

            echo '{"notice": {"text": "Days Added"}';

        } catch(PDOException $e) {
            echo '{"error": {"text": '.$e->getMessage().'}';
        }
    };
});


问:
Google-maps geocoding service
Hi I'm using google documentation in geocoding service.

The script should display the location Casablanca but it still show the default location in austalia

The problem is that geocoder.geocode(...) is not executed

```<code>function initMap() {

var geocoder = new google.maps.Geocoder();
var map = new google.maps.Map(document.getElementById('map'), {
        center: {lat: -34.397, lng: 150.644},
        scrollwheel: false,
        zoom: 8,
      });
codeAddress(geocoder,map);
}
function codeAddress(geocoder, map)
{
  var addr = "Casablanca";
  geocoder.geocode( {'addr':addr}, function(results, status)
  {
    if (status == google.maps.GeocoderStatus.OK)
    {
      map.setCenter(results[0].geometry.addr);//center the map over the result
      //place a marker at the location
      var marker = new google.maps.Marker(
      {
          map: map,
          position: results[0].geometry.addr
      });
    } else {
      alert('Geocode was not successful for the following reason: ' + status);
   }
  });
}
</code>```

PS:
I'm using GooglMapper https://github.com/bradcornford/Googlmapper

I appreciate any help.

答:
```<code>geocoder.geocode( {'addr':addr}, function(results, status)
</code>```

Should be:

```<code>geocoder.geocode( {'address':addr}, function(results, status)
</code>```

The GeocoderRequest object literal contains the following fields:

```<code>{
 address: string,
 location: LatLng,
 placeId: string,
 bounds: LatLngBounds,
 componentRestrictions: GeocoderComponentRestrictions,
 region: string
}
</code>```

Taken from the documentation

Title: Google-maps geocoding service

Body:
Hi I'm using google documentation in geocoding service.

The script should display the location Casablanca but it still show the default location in austalia

The problem is that geocoder.geocode(...) is not executed

function initMap() {

var geocoder = new google.maps.Geocoder();
var map = new google.maps.Map(document.getElementById('map'), {
        center: {lat: -34.397, lng: 150.644},
        scrollwheel: false,
        zoom: 8,
      });
codeAddress(geocoder,map);
}
function codeAddress(geocoder, map)
{
  var addr = "Casablanca";
  geocoder.geocode( {'addr':addr}, function(results, status)
  {
    if (status == google.maps.GeocoderStatus.OK)
    {
      map.setCenter(results[0].geometry.addr);//center the map over the result
      //place a marker at the location
      var marker = new google.maps.Marker(
      {
          map: map,
          position: results[0].geometry.addr
      });
    } else {
      alert('Geocode was not successful for the following reason: ' + status);
   }
  });
}

PS:
I'm using GooglMapper https://github.com/bradcornford/Googlmapper

I appreciate any help.

Body:
geocoder.geocode( {'addr':addr}, function(results, status)

Should be:

geocoder.geocode( {'address':addr}, function(results, status)

The GeocoderRequest object literal contains the following fields:

{
 address: string,
 location: LatLng,
 placeId: string,
 bounds: LatLngBounds,
 componentRestrictions: GeocoderComponentRestrictions,
 region: string
}

Taken from the documentation