问:
4 Column Footer Not Stacking for Mobile
So basically I've got this 4 column footer and it's perfect, but rather than stacking for mobile, it just gets smashed.
I just want each category to stack once it swaps to mobile view, or just shrink responsively across all sizes.
I've tried setting widths but no luck.  Any help or tips would be appreciated!

footer .clear {
  clear: both;
  float: none;
}

footer {
  background: #222;
  overflow: hidden;
  border-top: solid 1px #000;
  padding: 58px 0 0;
  font-family: arial, helvetica, sans-serif;
  line-height: 1.5em;
}

footer p,
footer ul,
footer a,
footer .btn {
  font-family: arial, helvetica, sans-serif;
  line-height: 1.5em;
  text-transform: none;
}

footer li {
  font-size: .875em;
  line-height: 1.5em;
}

footer .btn {
  background: #4497c4;
  background-image: -webkit-linear-gradient(top, #4497c4, #2d6a8e);
  background-image: -moz-linear-gradient(top, #4497c4, #2d6a8e);
  background-image: -ms-linear-gradient(top, #4497c4, #2d6a8e);
  background-image: -o-linear-gradient(top, #4497c4, #2d6a8e);
  background-image: linear-gradient(to bottom, #4497c4, #2d6a8e);
  -webkit-border-radius: 5;
  -moz-border-radius: 5;
  border-radius: 5px;
  -webkit-box-shadow: 0px 1px 2px #ffffff;
  -moz-box-shadow: 0px 1px 2px #ffffff;
  box-shadow: 0px 1px 2px #ffffff;
  color: #ffffff!important;
  font-size: 15px;
  padding: 5px 15px 6px 15px;
  border: solid #25658a 1px;
  text-decoration: none;
  -moz-box-shadow: 0 1px 0 rgba(255, 255, 255, 0.2) inset;
  -webkit-box-shadow: 0 1px 0 rgba(255, 255, 255, 0.2) inset;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.2) inset;
}

footer .content {
  max-width: 1000px;
  margin: 0 auto;
  padding: 0 20px;
}

@media screen and (max-width: 768px) {
  footer .content {
    padding: 0 10px;
  }
}

footer .last {
  margin-right: 0px !important;
}

@media only screen and (max-width: 485px) {
  footer .last {
    clear: both;
  }
}

#emailsignup {
  float: left;
  width: 330px;
}

#emailsignup .footer-logo {
  display: block;
  width: 155px;
  height: 41px;
  background: url("https://www.proxibid.com/images/footer-logo-proxibid.png") top left no-repeat;
  text-indent: -9999px;
  margin-bottom: 30px;
}

#emailsignup a,
#helpfullinks a,
#social a,
#poweredby a {
  color: rgba(255, 255, 255, 0.7);
  text-decoration: none;
}

#emailsignup p {
  font-size: 13px;
  color: #FFF;
  margin: 0px 0px 16px;
}

#helpfullinks {
  float: right;
}

@media only screen and (max-width: 825px) {
  #helpfullinks {
    float: none;
    clear: both;
  }
}

#helpfullinks div {
  float: left;
  margin-right: 45px;
  width: 20%;
}

#helpfullinks div a {
  display: inline;
  margin-top: -6px;
  margin-bottom: 8px;
}

#helpfullinks p.category {
  color: #FFF;
  font-size: 21px;
  margin: 0 0 14px;
}

#helpfullinks p.category a {
  color: #FFF;
}

#helpfullinks ul {
  list-style-type: none;
  padding: 0px;
  margin: 14px 0 0 0;
}

#helpfullinks li {
  padding: 0px;
  margin: 0 0 6px;
  font-size: 15px;
}

#poweredby {
  max-width: 100%;
  margin: 115px auto 0;
  overflow: hidden;
  text-align: center;
}

@media screen and (max-width: 768px) {
  #poweredby {
    margin: 26px auto 0;
  }
}

#poweredby p {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.7);
  margin: 0 0 10px;
  text-align: center;
}

#poweredby ul {
  display: inline-block;
  margin: 0px auto;
  list-style-type: none;
  padding: 0px;
}

#poweredby li {
  margin: 0 40px 0 0;
  float: left;
}

@media only screen and (max-width: 495px) {
  #poweredby li {
    margin: 0 0 10px 0;
    float: none;
    clear: both;
  }
}

#poweredby .footer-divvy {
  display: block;
  width: 77px;
  height: 24px;
  background: url("https://www.proxibid.com/images/footer-logo-divvy.png") top left no-repeat;
  text-indent: -9999px;
}

#poweredby .footer-finest {
  display: block;
  width: 77px;
  height: 24px;
  background: url("https://www.proxibid.com/images/footer-logo-thefinest.png") top left no-repeat;
  text-indent: -9999px;
}

#poweredby .footer-apn {
  display: block;
  width: 77px;
  height: 24px;
  background: url("https://www.proxibid.com/images/footer-logo-apn.png") top left no-repeat;
  text-indent: -9999px;
}

#social {
  margin: 60px auto;
  overflow: hidden;
  text-align: center;
}

@media screen and (max-width: 768px) {
  #social {
    margin: 26px auto;
  }
}

#social ul {
  margin: 0px auto;
  list-style-type: none;
  padding: 0px;
}

#social ul.social,
#social ul.contact {
  display: inline-block;
}

#social li {
  margin: 0 17px 0 0;
  float: left;
  color: rgba(255, 255, 255, 0.7);
}

@media only screen and (max-width: 495px) {
  #social li {
    margin: 0 0 10px 0;
    float: none;
    clear: both;
  }
}

#social li a {
  color: rgba(255, 255, 255, 0.7);
}

iframe {
  overflow: hidden;
}

#footerSealiFrame {
  border: medium none;
  height: 175px;
  margin: 0 auto;
  width: 100%;
  display: block;
  overflow: hidden;
}

@media only screen and (max-width: 600px) {
  #footerSealiFrame {
    height: 285px;
  }
  #footerSeals>img,
  #footerSeals>embed,
  #footerSeals>object,
  #footerSeals>a {
    display: inline-block !important;
    margin: 0 6px 10px !important;
    vertical-align: middle !important;
  }
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><footer>
  <div class="content">
    <div id="helpfullinks">
      <div>
        <p class="category">About</p>
        <ul>
          <li>Our Mission</li>
          <li>AdaptaPASS</li>
          <li>Affiliates</li>
          <li>Campus Representatives</li>
          <li>Privacy Policy</li>
        </ul>
      </div>
      <div>
        <p class="category">Products</p>
        <ul>
          <li>All-Access Course Bundles</li>
          <li>CRAM Courses</li>
          <li>Audio Lectures</li>
          <li>TestBank Software</li>
          <li>Digital Flashcards</li>
          <li>Exam Stress Relief</li>
        </ul>
      </div>
      <div>
        <p class="category">Resources</p>
        <ul>
          <li>Free Assessment</li>
          <li>Start a Free Trial</li>
          <li>Blog</li>
          <li>Requirements by State</li>
        </ul>
      </div>
      <div class="last">
        <p class="category">Support</p>
        <ul>
          <li>(800) 824 2811</li>
          <li>Use the chat feature below to reach one of our support specialists</li>
          <li>Contact Us</li>
          <li>Login to AdaptaPASS</li>
          <li>Login to myYaeger Student Portal</li>
        </ul>
      </div>
      <div class="clear"></div>
    </div>
    <div class="clear"></div>
    <div id="poweredby">
      <ul>
        <li class="last"><img src="include/images/footerlogo.png"></li>
      </ul>
    </div>
    <div class="clear"></div>
    <div id="social">
      <ul class="social">
        <li>Facebook</li>
        <li>Twitter</li>
        <li>YouTube</li>
        <li class="last">LinkedIn</li>
      </ul>
      <div class="clear"></div>
      <ul class="contact">
        <li class="last">©2017 Yaegar CPA Review, All Rights Reserved</li>
      </ul>
    </div>
  </div>
</footer></code>```

答:
Essentially, what you need to do is kill the floats and reset the width at the appropriate viewport widths, for example:

```<code>#helpfullinks div { /* for the sake of demonstration */
  float: none;
  width: 100%;
}
</code>```

footer .clear {
  clear: both;
  float: none;
}

footer {
  background: #222;
  overflow: hidden;
  border-top: solid 1px #000;
  padding: 58px 0 0;
  font-family: arial, helvetica, sans-serif;
  line-height: 1.5em;
}

footer p,
footer ul,
footer a,
footer .btn {
  font-family: arial, helvetica, sans-serif;
  line-height: 1.5em;
  text-transform: none;
}

footer li {
  font-size: .875em;
  line-height: 1.5em;
}

footer .btn {
  background: #4497c4;
  background-image: -webkit-linear-gradient(top, #4497c4, #2d6a8e);
  background-image: -moz-linear-gradient(top, #4497c4, #2d6a8e);
  background-image: -ms-linear-gradient(top, #4497c4, #2d6a8e);
  background-image: -o-linear-gradient(top, #4497c4, #2d6a8e);
  background-image: linear-gradient(to bottom, #4497c4, #2d6a8e);
  -webkit-border-radius: 5;
  -moz-border-radius: 5;
  border-radius: 5px;
  -webkit-box-shadow: 0px 1px 2px #ffffff;
  -moz-box-shadow: 0px 1px 2px #ffffff;
  box-shadow: 0px 1px 2px #ffffff;
  color: #ffffff!important;
  font-size: 15px;
  padding: 5px 15px 6px 15px;
  border: solid #25658a 1px;
  text-decoration: none;
  -moz-box-shadow: 0 1px 0 rgba(255, 255, 255, 0.2) inset;
  -webkit-box-shadow: 0 1px 0 rgba(255, 255, 255, 0.2) inset;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.2) inset;
}

footer .content {
  max-width: 1000px;
  margin: 0 auto;
  padding: 0 20px;
}

@media screen and (max-width: 768px) {
  footer .content {
    padding: 0 10px;
  }
}

footer .last {
  margin-right: 0px !important;
}

@media only screen and (max-width: 485px) {
  footer .last {
    clear: both;
  }
}

#emailsignup {
  float: left;
  width: 330px;
}

#emailsignup .footer-logo {
  display: block;
  width: 155px;
  height: 41px;
  background: url("https://www.proxibid.com/images/footer-logo-proxibid.png") top left no-repeat;
  text-indent: -9999px;
  margin-bottom: 30px;
}

#emailsignup a,
#helpfullinks a,
#social a,
#poweredby a {
  color: rgba(255, 255, 255, 0.7);
  text-decoration: none;
}

#emailsignup p {
  font-size: 13px;
  color: #FFF;
  margin: 0px 0px 16px;
}

#helpfullinks {
  float: right;
}

@media only screen and (max-width: 825px) {
  #helpfullinks {
    float: none;
    clear: both;
  }
}

#helpfullinks div {
  float: left;
  margin-right: 45px;
  width: 20%;
}

#helpfullinks div a {
  display: inline;
  margin-top: -6px;
  margin-bottom: 8px;
}

#helpfullinks p.category {
  color: #FFF;
  font-size: 21px;
  margin: 0 0 14px;
}

#helpfullinks p.category a {
  color: #FFF;
}

#helpfullinks ul {
  list-style-type: none;
  padding: 0px;
  margin: 14px 0 0 0;
}

#helpfullinks li {
  padding: 0px;
  margin: 0 0 6px;
  font-size: 15px;
}

#poweredby {
  max-width: 100%;
  margin: 115px auto 0;
  overflow: hidden;
  text-align: center;
}

@media screen and (max-width: 768px) {
  #poweredby {
    margin: 26px auto 0;
  }
}

#poweredby p {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.7);
  margin: 0 0 10px;
  text-align: center;
}

#poweredby ul {
  display: inline-block;
  margin: 0px auto;
  list-style-type: none;
  padding: 0px;
}

#poweredby li {
  margin: 0 40px 0 0;
  float: left;
}

@media only screen and (max-width: 495px) {
  #poweredby li {
    margin: 0 0 10px 0;
    float: none;
    clear: both;
  }
}

#poweredby .footer-divvy {
  display: block;
  width: 77px;
  height: 24px;
  background: url("https://www.proxibid.com/images/footer-logo-divvy.png") top left no-repeat;
  text-indent: -9999px;
}

#poweredby .footer-finest {
  display: block;
  width: 77px;
  height: 24px;
  background: url("https://www.proxibid.com/images/footer-logo-thefinest.png") top left no-repeat;
  text-indent: -9999px;
}

#poweredby .footer-apn {
  display: block;
  width: 77px;
  height: 24px;
  background: url("https://www.proxibid.com/images/footer-logo-apn.png") top left no-repeat;
  text-indent: -9999px;
}

#social {
  margin: 60px auto;
  overflow: hidden;
  text-align: center;
}

@media screen and (max-width: 768px) {
  #social {
    margin: 26px auto;
  }
}

#social ul {
  margin: 0px auto;
  list-style-type: none;
  padding: 0px;
}

#social ul.social,
#social ul.contact {
  display: inline-block;
}

#social li {
  margin: 0 17px 0 0;
  float: left;
  color: rgba(255, 255, 255, 0.7);
}

@media only screen and (max-width: 495px) {
  #social li {
    margin: 0 0 10px 0;
    float: none;
    clear: both;
  }
}

#social li a {
  color: rgba(255, 255, 255, 0.7);
}

iframe {
  overflow: hidden;
}

#footerSealiFrame {
  border: medium none;
  height: 175px;
  margin: 0 auto;
  width: 100%;
  display: block;
  overflow: hidden;
}

@media only screen and (max-width: 600px) {
  #footerSealiFrame {
    height: 285px;
  }
  #footerSeals>img,
  #footerSeals>embed,
  #footerSeals>object,
  #footerSeals>a {
    display: inline-block !important;
    margin: 0 6px 10px !important;
    vertical-align: middle !important;
  }
}

/* Additional */

@media (max-width: 600px) {
  #helpfullinks div {
    float: none;
    width: 100%;
    border-bottom: 1px solid #5a5a5a;
    margin-bottom: 10px;
    padding-bottom: 10px;
  }
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><footer>
  <div class="content">
    <div id="helpfullinks">
      <div>
        <p class="category">About</p>
        <ul>
          <li>Our Mission</li>
          <li>AdaptaPASS</li>
          <li>Affiliates</li>
          <li>Campus Representatives</li>
          <li>Privacy Policy</li>
        </ul>
      </div>
      <div>
        <p class="category">Products</p>
        <ul>
          <li>All-Access Course Bundles</li>
          <li>CRAM Courses</li>
          <li>Audio Lectures</li>
          <li>TestBank Software</li>
          <li>Digital Flashcards</li>
          <li>Exam Stress Relief</li>
        </ul>
      </div>
      <div>
        <p class="category">Resources</p>
        <ul>
          <li>Free Assessment</li>
          <li>Start a Free Trial</li>
          <li>Blog</li>
          <li>Requirements by State</li>
        </ul>
      </div>
      <div class="last">
        <p class="category">Support</p>
        <ul>
          <li>(800) 824 2811</li>
          <li>Use the chat feature below to reach one of our support specialists</li>
          <li>Contact Us</li>
          <li>Login to AdaptaPASS</li>
          <li>Login to myYaeger Student Portal</li>
        </ul>
      </div>
      <div class="clear"></div>
    </div>
    <div class="clear"></div>
    <div id="poweredby">
      <ul>
        <li class="last"><img src="include/images/footerlogo.png"></li>
      </ul>
    </div>
    <div class="clear"></div>
    <div id="social">
      <ul class="social">
        <li>Facebook</li>
        <li>Twitter</li>
        <li>YouTube</li>
        <li class="last">LinkedIn</li>
      </ul>
      <div class="clear"></div>
      <ul class="contact">
        <li class="last">©2017 Yaegar CPA Review, All Rights Reserved</li>
      </ul>
    </div>
  </div>
</footer></code>```

Bonus

Because it's Friday and I'm feeling particularly generous, here's a flex-box method:

```<code>#helpfullinks {
  display: flex;
  flex-direction: column;
  flex-flow: wrap;
}
</code>```

footer .clear {
  clear: both;
  float: none;
}

footer {
  background: #222;
  overflow: hidden;
  border-top: solid 1px #000;
  padding: 58px 0 0;
  font-family: arial, helvetica, sans-serif;
  line-height: 1.5em;
}

footer p,
footer ul,
footer a,
footer .btn {
  font-family: arial, helvetica, sans-serif;
  line-height: 1.5em;
  text-transform: none;
}

footer li {
  font-size: .875em;
  line-height: 1.5em;
}

footer .btn {
  background: #4497c4;
  background-image: -webkit-linear-gradient(top, #4497c4, #2d6a8e);
  background-image: -moz-linear-gradient(top, #4497c4, #2d6a8e);
  background-image: -ms-linear-gradient(top, #4497c4, #2d6a8e);
  background-image: -o-linear-gradient(top, #4497c4, #2d6a8e);
  background-image: linear-gradient(to bottom, #4497c4, #2d6a8e);
  -webkit-border-radius: 5;
  -moz-border-radius: 5;
  border-radius: 5px;
  -webkit-box-shadow: 0px 1px 2px #ffffff;
  -moz-box-shadow: 0px 1px 2px #ffffff;
  box-shadow: 0px 1px 2px #ffffff;
  color: #ffffff!important;
  font-size: 15px;
  padding: 5px 15px 6px 15px;
  border: solid #25658a 1px;
  text-decoration: none;
  -moz-box-shadow: 0 1px 0 rgba(255, 255, 255, 0.2) inset;
  -webkit-box-shadow: 0 1px 0 rgba(255, 255, 255, 0.2) inset;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.2) inset;
}

footer .content {
  max-width: 1000px;
  margin: 0 auto;
  padding: 0 20px;
}

@media screen and (max-width: 768px) {
  footer .content {
    padding: 0 10px;
  }
}

footer .last {
  margin-right: 0px !important;
}

@media only screen and (max-width: 485px) {
  footer .last {
    clear: both;
  }
}

#emailsignup {
  float: left;
  width: 330px;
}

#emailsignup .footer-logo {
  display: block;
  width: 155px;
  height: 41px;
  background: url("https://www.proxibid.com/images/footer-logo-proxibid.png") top left no-repeat;
  text-indent: -9999px;
  margin-bottom: 30px;
}

#emailsignup a,
#helpfullinks a,
#social a,
#poweredby a {
  color: rgba(255, 255, 255, 0.7);
  text-decoration: none;
}

#emailsignup p {
  font-size: 13px;
  color: #FFF;
  margin: 0px 0px 16px;
}

#helpfullinks {
  float: right;
}

@media only screen and (max-width: 825px) {
  #helpfullinks {
    float: none;
    clear: both;
  }
}

#helpfullinks div {
  float: left;
  margin-right: 45px;
  width: 20%;
}

#helpfullinks div a {
  display: inline;
  margin-top: -6px;
  margin-bottom: 8px;
}

#helpfullinks p.category {
  color: #FFF;
  font-size: 21px;
  margin: 0 0 14px;
}

#helpfullinks p.category a {
  color: #FFF;
}

#helpfullinks ul {
  list-style-type: none;
  padding: 0px;
  margin: 14px 0 0 0;
}

#helpfullinks li {
  padding: 0px;
  margin: 0 0 6px;
  font-size: 15px;
}

#poweredby {
  max-width: 100%;
  margin: 115px auto 0;
  overflow: hidden;
  text-align: center;
}

@media screen and (max-width: 768px) {
  #poweredby {
    margin: 26px auto 0;
  }
}

#poweredby p {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.7);
  margin: 0 0 10px;
  text-align: center;
}

#poweredby ul {
  display: inline-block;
  margin: 0px auto;
  list-style-type: none;
  padding: 0px;
}

#poweredby li {
  margin: 0 40px 0 0;
  float: left;
}

@media only screen and (max-width: 495px) {
  #poweredby li {
    margin: 0 0 10px 0;
    float: none;
    clear: both;
  }
}

#poweredby .footer-divvy {
  display: block;
  width: 77px;
  height: 24px;
  background: url("https://www.proxibid.com/images/footer-logo-divvy.png") top left no-repeat;
  text-indent: -9999px;
}

#poweredby .footer-finest {
  display: block;
  width: 77px;
  height: 24px;
  background: url("https://www.proxibid.com/images/footer-logo-thefinest.png") top left no-repeat;
  text-indent: -9999px;
}

#poweredby .footer-apn {
  display: block;
  width: 77px;
  height: 24px;
  background: url("https://www.proxibid.com/images/footer-logo-apn.png") top left no-repeat;
  text-indent: -9999px;
}

#social {
  margin: 60px auto;
  overflow: hidden;
  text-align: center;
}

@media screen and (max-width: 768px) {
  #social {
    margin: 26px auto;
  }
}

#social ul {
  margin: 0px auto;
  list-style-type: none;
  padding: 0px;
}

#social ul.social,
#social ul.contact {
  display: inline-block;
}

#social li {
  margin: 0 17px 0 0;
  float: left;
  color: rgba(255, 255, 255, 0.7);
}

@media only screen and (max-width: 495px) {
  #social li {
    margin: 0 0 10px 0;
    float: none;
    clear: both;
  }
}

#social li a {
  color: rgba(255, 255, 255, 0.7);
}

iframe {
  overflow: hidden;
}

#footerSealiFrame {
  border: medium none;
  height: 175px;
  margin: 0 auto;
  width: 100%;
  display: block;
  overflow: hidden;
}

@media only screen and (max-width: 600px) {
  #footerSealiFrame {
    height: 285px;
  }
  #footerSeals>img,
  #footerSeals>embed,
  #footerSeals>object,
  #footerSeals>a {
    display: inline-block !important;
    margin: 0 6px 10px !important;
    vertical-align: middle !important;
  }
}

/* Bonus (let's get Flexy) */

@media (max-width: 600px) {
  #helpfullinks {
    display: flex;
    flex-direction: column;
    flex-flow: wrap;
  }
  #helpfullinks div {
    width: 100%;
    margin-right: auto;
    margin-left: auto;
    border-bottom: 1px solid #5a5a5a;
    margin-bottom: 10px;
    padding-bottom: 10px;
  }
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><footer>
  <div class="content">
    <div id="helpfullinks">
      <div>
        <p class="category">About</p>
        <ul>
          <li>Our Mission</li>
          <li>AdaptaPASS</li>
          <li>Affiliates</li>
          <li>Campus Representatives</li>
          <li>Privacy Policy</li>
        </ul>
      </div>
      <div>
        <p class="category">Products</p>
        <ul>
          <li>All-Access Course Bundles</li>
          <li>CRAM Courses</li>
          <li>Audio Lectures</li>
          <li>TestBank Software</li>
          <li>Digital Flashcards</li>
          <li>Exam Stress Relief</li>
        </ul>
      </div>
      <div>
        <p class="category">Resources</p>
        <ul>
          <li>Free Assessment</li>
          <li>Start a Free Trial</li>
          <li>Blog</li>
          <li>Requirements by State</li>
        </ul>
      </div>
      <div class="last">
        <p class="category">Support</p>
        <ul>
          <li>(800) 824 2811</li>
          <li>Use the chat feature below to reach one of our support specialists</li>
          <li>Contact Us</li>
          <li>Login to AdaptaPASS</li>
          <li>Login to myYaeger Student Portal</li>
        </ul>
      </div>
      <div class="clear"></div>
    </div>
    <div class="clear"></div>
    <div id="poweredby">
      <ul>
        <li class="last"><img src="include/images/footerlogo.png"></li>
      </ul>
    </div>
    <div class="clear"></div>
    <div id="social">
      <ul class="social">
        <li>Facebook</li>
        <li>Twitter</li>
        <li>YouTube</li>
        <li class="last">LinkedIn</li>
      </ul>
      <div class="clear"></div>
      <ul class="contact">
        <li class="last">©2017 Yaegar CPA Review, All Rights Reserved</li>
      </ul>
    </div>
  </div>
</footer></code>```

Title: 4 Column Footer Not Stacking for Mobile

Body:
So basically I've got this 4 column footer and it's perfect, but rather than stacking for mobile, it just gets smashed.
I just want each category to stack once it swaps to mobile view, or just shrink responsively across all sizes.
I've tried setting widths but no luck.  Any help or tips would be appreciated!

footer .clear {
  clear: both;
  float: none;
}

footer {
  background: #222;
  overflow: hidden;
  border-top: solid 1px #000;
  padding: 58px 0 0;
  font-family: arial, helvetica, sans-serif;
  line-height: 1.5em;
}

footer p,
footer ul,
footer a,
footer .btn {
  font-family: arial, helvetica, sans-serif;
  line-height: 1.5em;
  text-transform: none;
}

footer li {
  font-size: .875em;
  line-height: 1.5em;
}

footer .btn {
  background: #4497c4;
  background-image: -webkit-linear-gradient(top, #4497c4, #2d6a8e);
  background-image: -moz-linear-gradient(top, #4497c4, #2d6a8e);
  background-image: -ms-linear-gradient(top, #4497c4, #2d6a8e);
  background-image: -o-linear-gradient(top, #4497c4, #2d6a8e);
  background-image: linear-gradient(to bottom, #4497c4, #2d6a8e);
  -webkit-border-radius: 5;
  -moz-border-radius: 5;
  border-radius: 5px;
  -webkit-box-shadow: 0px 1px 2px #ffffff;
  -moz-box-shadow: 0px 1px 2px #ffffff;
  box-shadow: 0px 1px 2px #ffffff;
  color: #ffffff!important;
  font-size: 15px;
  padding: 5px 15px 6px 15px;
  border: solid #25658a 1px;
  text-decoration: none;
  -moz-box-shadow: 0 1px 0 rgba(255, 255, 255, 0.2) inset;
  -webkit-box-shadow: 0 1px 0 rgba(255, 255, 255, 0.2) inset;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.2) inset;
}

footer .content {
  max-width: 1000px;
  margin: 0 auto;
  padding: 0 20px;
}

@media screen and (max-width: 768px) {
  footer .content {
    padding: 0 10px;
  }
}

footer .last {
  margin-right: 0px !important;
}

@media only screen and (max-width: 485px) {
  footer .last {
    clear: both;
  }
}

#emailsignup {
  float: left;
  width: 330px;
}

#emailsignup .footer-logo {
  display: block;
  width: 155px;
  height: 41px;
  background: url("https://www.proxibid.com/images/footer-logo-proxibid.png") top left no-repeat;
  text-indent: -9999px;
  margin-bottom: 30px;
}

#emailsignup a,
#helpfullinks a,
#social a,
#poweredby a {
  color: rgba(255, 255, 255, 0.7);
  text-decoration: none;
}

#emailsignup p {
  font-size: 13px;
  color: #FFF;
  margin: 0px 0px 16px;
}

#helpfullinks {
  float: right;
}

@media only screen and (max-width: 825px) {
  #helpfullinks {
    float: none;
    clear: both;
  }
}

#helpfullinks div {
  float: left;
  margin-right: 45px;
  width: 20%;
}

#helpfullinks div a {
  display: inline;
  margin-top: -6px;
  margin-bottom: 8px;
}

#helpfullinks p.category {
  color: #FFF;
  font-size: 21px;
  margin: 0 0 14px;
}

#helpfullinks p.category a {
  color: #FFF;
}

#helpfullinks ul {
  list-style-type: none;
  padding: 0px;
  margin: 14px 0 0 0;
}

#helpfullinks li {
  padding: 0px;
  margin: 0 0 6px;
  font-size: 15px;
}

#poweredby {
  max-width: 100%;
  margin: 115px auto 0;
  overflow: hidden;
  text-align: center;
}

@media screen and (max-width: 768px) {
  #poweredby {
    margin: 26px auto 0;
  }
}

#poweredby p {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.7);
  margin: 0 0 10px;
  text-align: center;
}

#poweredby ul {
  display: inline-block;
  margin: 0px auto;
  list-style-type: none;
  padding: 0px;
}

#poweredby li {
  margin: 0 40px 0 0;
  float: left;
}

@media only screen and (max-width: 495px) {
  #poweredby li {
    margin: 0 0 10px 0;
    float: none;
    clear: both;
  }
}

#poweredby .footer-divvy {
  display: block;
  width: 77px;
  height: 24px;
  background: url("https://www.proxibid.com/images/footer-logo-divvy.png") top left no-repeat;
  text-indent: -9999px;
}

#poweredby .footer-finest {
  display: block;
  width: 77px;
  height: 24px;
  background: url("https://www.proxibid.com/images/footer-logo-thefinest.png") top left no-repeat;
  text-indent: -9999px;
}

#poweredby .footer-apn {
  display: block;
  width: 77px;
  height: 24px;
  background: url("https://www.proxibid.com/images/footer-logo-apn.png") top left no-repeat;
  text-indent: -9999px;
}

#social {
  margin: 60px auto;
  overflow: hidden;
  text-align: center;
}

@media screen and (max-width: 768px) {
  #social {
    margin: 26px auto;
  }
}

#social ul {
  margin: 0px auto;
  list-style-type: none;
  padding: 0px;
}

#social ul.social,
#social ul.contact {
  display: inline-block;
}

#social li {
  margin: 0 17px 0 0;
  float: left;
  color: rgba(255, 255, 255, 0.7);
}

@media only screen and (max-width: 495px) {
  #social li {
    margin: 0 0 10px 0;
    float: none;
    clear: both;
  }
}

#social li a {
  color: rgba(255, 255, 255, 0.7);
}

iframe {
  overflow: hidden;
}

#footerSealiFrame {
  border: medium none;
  height: 175px;
  margin: 0 auto;
  width: 100%;
  display: block;
  overflow: hidden;
}

@media only screen and (max-width: 600px) {
  #footerSealiFrame {
    height: 285px;
  }
  #footerSeals>img,
  #footerSeals>embed,
  #footerSeals>object,
  #footerSeals>a {
    display: inline-block !important;
    margin: 0 6px 10px !important;
    vertical-align: middle !important;
  }
}

About

Our Mission

AdaptaPASS

Affiliates

Campus Representatives

Privacy Policy

Products

All-Access Course Bundles

CRAM Courses

Audio Lectures

TestBank Software

Digital Flashcards

Exam Stress Relief

Resources

Free Assessment

Start a Free Trial

Blog

Requirements by State

Support

(800) 824 2811

Use the chat feature below to reach one of our support specialists

Contact Us

Login to AdaptaPASS

Login to myYaeger Student Portal

Facebook

Twitter

YouTube

LinkedIn

©2017 Yaegar CPA Review, All Rights Reserved

Body:
Essentially, what you need to do is kill the floats and reset the width at the appropriate viewport widths, for example:

#helpfullinks div { /* for the sake of demonstration */
  float: none;
  width: 100%;
}

footer .clear {
  clear: both;
  float: none;
}

footer {
  background: #222;
  overflow: hidden;
  border-top: solid 1px #000;
  padding: 58px 0 0;
  font-family: arial, helvetica, sans-serif;
  line-height: 1.5em;
}

footer p,
footer ul,
footer a,
footer .btn {
  font-family: arial, helvetica, sans-serif;
  line-height: 1.5em;
  text-transform: none;
}

footer li {
  font-size: .875em;
  line-height: 1.5em;
}

footer .btn {
  background: #4497c4;
  background-image: -webkit-linear-gradient(top, #4497c4, #2d6a8e);
  background-image: -moz-linear-gradient(top, #4497c4, #2d6a8e);
  background-image: -ms-linear-gradient(top, #4497c4, #2d6a8e);
  background-image: -o-linear-gradient(top, #4497c4, #2d6a8e);
  background-image: linear-gradient(to bottom, #4497c4, #2d6a8e);
  -webkit-border-radius: 5;
  -moz-border-radius: 5;
  border-radius: 5px;
  -webkit-box-shadow: 0px 1px 2px #ffffff;
  -moz-box-shadow: 0px 1px 2px #ffffff;
  box-shadow: 0px 1px 2px #ffffff;
  color: #ffffff!important;
  font-size: 15px;
  padding: 5px 15px 6px 15px;
  border: solid #25658a 1px;
  text-decoration: none;
  -moz-box-shadow: 0 1px 0 rgba(255, 255, 255, 0.2) inset;
  -webkit-box-shadow: 0 1px 0 rgba(255, 255, 255, 0.2) inset;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.2) inset;
}

footer .content {
  max-width: 1000px;
  margin: 0 auto;
  padding: 0 20px;
}

@media screen and (max-width: 768px) {
  footer .content {
    padding: 0 10px;
  }
}

footer .last {
  margin-right: 0px !important;
}

@media only screen and (max-width: 485px) {
  footer .last {
    clear: both;
  }
}

#emailsignup {
  float: left;
  width: 330px;
}

#emailsignup .footer-logo {
  display: block;
  width: 155px;
  height: 41px;
  background: url("https://www.proxibid.com/images/footer-logo-proxibid.png") top left no-repeat;
  text-indent: -9999px;
  margin-bottom: 30px;
}

#emailsignup a,
#helpfullinks a,
#social a,
#poweredby a {
  color: rgba(255, 255, 255, 0.7);
  text-decoration: none;
}

#emailsignup p {
  font-size: 13px;
  color: #FFF;
  margin: 0px 0px 16px;
}

#helpfullinks {
  float: right;
}

@media only screen and (max-width: 825px) {
  #helpfullinks {
    float: none;
    clear: both;
  }
}

#helpfullinks div {
  float: left;
  margin-right: 45px;
  width: 20%;
}

#helpfullinks div a {
  display: inline;
  margin-top: -6px;
  margin-bottom: 8px;
}

#helpfullinks p.category {
  color: #FFF;
  font-size: 21px;
  margin: 0 0 14px;
}

#helpfullinks p.category a {
  color: #FFF;
}

#helpfullinks ul {
  list-style-type: none;
  padding: 0px;
  margin: 14px 0 0 0;
}

#helpfullinks li {
  padding: 0px;
  margin: 0 0 6px;
  font-size: 15px;
}

#poweredby {
  max-width: 100%;
  margin: 115px auto 0;
  overflow: hidden;
  text-align: center;
}

@media screen and (max-width: 768px) {
  #poweredby {
    margin: 26px auto 0;
  }
}

#poweredby p {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.7);
  margin: 0 0 10px;
  text-align: center;
}

#poweredby ul {
  display: inline-block;
  margin: 0px auto;
  list-style-type: none;
  padding: 0px;
}

#poweredby li {
  margin: 0 40px 0 0;
  float: left;
}

@media only screen and (max-width: 495px) {
  #poweredby li {
    margin: 0 0 10px 0;
    float: none;
    clear: both;
  }
}

#poweredby .footer-divvy {
  display: block;
  width: 77px;
  height: 24px;
  background: url("https://www.proxibid.com/images/footer-logo-divvy.png") top left no-repeat;
  text-indent: -9999px;
}

#poweredby .footer-finest {
  display: block;
  width: 77px;
  height: 24px;
  background: url("https://www.proxibid.com/images/footer-logo-thefinest.png") top left no-repeat;
  text-indent: -9999px;
}

#poweredby .footer-apn {
  display: block;
  width: 77px;
  height: 24px;
  background: url("https://www.proxibid.com/images/footer-logo-apn.png") top left no-repeat;
  text-indent: -9999px;
}

#social {
  margin: 60px auto;
  overflow: hidden;
  text-align: center;
}

@media screen and (max-width: 768px) {
  #social {
    margin: 26px auto;
  }
}

#social ul {
  margin: 0px auto;
  list-style-type: none;
  padding: 0px;
}

#social ul.social,
#social ul.contact {
  display: inline-block;
}

#social li {
  margin: 0 17px 0 0;
  float: left;
  color: rgba(255, 255, 255, 0.7);
}

@media only screen and (max-width: 495px) {
  #social li {
    margin: 0 0 10px 0;
    float: none;
    clear: both;
  }
}

#social li a {
  color: rgba(255, 255, 255, 0.7);
}

iframe {
  overflow: hidden;
}

#footerSealiFrame {
  border: medium none;
  height: 175px;
  margin: 0 auto;
  width: 100%;
  display: block;
  overflow: hidden;
}

@media only screen and (max-width: 600px) {
  #footerSealiFrame {
    height: 285px;
  }
  #footerSeals>img,
  #footerSeals>embed,
  #footerSeals>object,
  #footerSeals>a {
    display: inline-block !important;
    margin: 0 6px 10px !important;
    vertical-align: middle !important;
  }
}

/* Additional */

@media (max-width: 600px) {
  #helpfullinks div {
    float: none;
    width: 100%;
    border-bottom: 1px solid #5a5a5a;
    margin-bottom: 10px;
    padding-bottom: 10px;
  }
}

<footer>
  <div class="content">
    <div id="helpfullinks">
      <div>
        <p class="category">About</p>
        <ul>
          <li><a href="#">Our Mission</a></li>
          <li><a href="#">AdaptaPASS</a></li>
          <li><a href="#">Affiliates</a></li>
          <li><a href="#">Campus Representatives</a></li>
          <li><a href="#">Privacy Policy</a></li>
        </ul>
      </div>
      <div>
        <p class="category">Products</p>
        <ul>
          <li><a href="#">All-Access Course Bundles</a></li>
          <li><a href="#">CRAM Courses</a></li>
          <li><a href="#">Audio Lectures</a></li>
          <li><a href="#">TestBank Software</a></li>
          <li><a href="#">Digital Flashcards</a></li>
          <li><a href="#">Exam Stress Relief</a></li>
        </ul>
      </div>
      <div>
        <p class="category">Resources</p>
        <ul>
          <li><a href="#">Free Assessment</a></li>
          <li><a href="#">Start a Free Trial</a></li>
          <li><a href="#">Blog</a></li>
          <li><a href="#">Requirements by State</a></li>
        </ul>
      </div>
      <div class="last">
        <p class="category">Support</p>
        <ul>
          <li><a href="#">(800) 824 2811</a></li>
          <li><a href="#">Use the chat feature below to reach one of our support specialists</a></li>
          <li><a href="#">Contact Us</a></li>
          <li><a href="#">Login to AdaptaPASS</a></li>
          <li><a href="#">Login to myYaeger Student Portal</a></li>
        </ul>
      </div>
      <div class="clear"></div>
    </div>
    <div class="clear"></div>
    <div id="poweredby">
      <ul>
        <li class="last"><img src="include/images/footerlogo.png"></li>
      </ul>
    </div>
    <div class="clear"></div>
    <div id="social">
      <ul class="social">
        <li><a target="_blank" href="#">Facebook</a></li>
        <li><a target="_blank" href="#">Twitter</a></li>
        <li><a target="_blank" href="#">YouTube</a></li>
        <li class="last"><a target="_blank" href="#">LinkedIn</a></li>
      </ul>
      <div class="clear"></div>
      <ul class="contact">
        <li class="last">&copy;2017 Yaegar CPA Review, All Rights Reserved</li>
      </ul>
    </div>
  </div>
</footer>

Bonus

Because it's Friday and I'm feeling particularly generous, here's a flex-box method:

#helpfullinks {
  display: flex;
  flex-direction: column;
  flex-flow: wrap;
}

footer .clear {
  clear: both;
  float: none;
}

footer {
  background: #222;
  overflow: hidden;
  border-top: solid 1px #000;
  padding: 58px 0 0;
  font-family: arial, helvetica, sans-serif;
  line-height: 1.5em;
}

footer p,
footer ul,
footer a,
footer .btn {
  font-family: arial, helvetica, sans-serif;
  line-height: 1.5em;
  text-transform: none;
}

footer li {
  font-size: .875em;
  line-height: 1.5em;
}

footer .btn {
  background: #4497c4;
  background-image: -webkit-linear-gradient(top, #4497c4, #2d6a8e);
  background-image: -moz-linear-gradient(top, #4497c4, #2d6a8e);
  background-image: -ms-linear-gradient(top, #4497c4, #2d6a8e);
  background-image: -o-linear-gradient(top, #4497c4, #2d6a8e);
  background-image: linear-gradient(to bottom, #4497c4, #2d6a8e);
  -webkit-border-radius: 5;
  -moz-border-radius: 5;
  border-radius: 5px;
  -webkit-box-shadow: 0px 1px 2px #ffffff;
  -moz-box-shadow: 0px 1px 2px #ffffff;
  box-shadow: 0px 1px 2px #ffffff;
  color: #ffffff!important;
  font-size: 15px;
  padding: 5px 15px 6px 15px;
  border: solid #25658a 1px;
  text-decoration: none;
  -moz-box-shadow: 0 1px 0 rgba(255, 255, 255, 0.2) inset;
  -webkit-box-shadow: 0 1px 0 rgba(255, 255, 255, 0.2) inset;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.2) inset;
}

footer .content {
  max-width: 1000px;
  margin: 0 auto;
  padding: 0 20px;
}

@media screen and (max-width: 768px) {
  footer .content {
    padding: 0 10px;
  }
}

footer .last {
  margin-right: 0px !important;
}

@media only screen and (max-width: 485px) {
  footer .last {
    clear: both;
  }
}

#emailsignup {
  float: left;
  width: 330px;
}

#emailsignup .footer-logo {
  display: block;
  width: 155px;
  height: 41px;
  background: url("https://www.proxibid.com/images/footer-logo-proxibid.png") top left no-repeat;
  text-indent: -9999px;
  margin-bottom: 30px;
}

#emailsignup a,
#helpfullinks a,
#social a,
#poweredby a {
  color: rgba(255, 255, 255, 0.7);
  text-decoration: none;
}

#emailsignup p {
  font-size: 13px;
  color: #FFF;
  margin: 0px 0px 16px;
}

#helpfullinks {
  float: right;
}

@media only screen and (max-width: 825px) {
  #helpfullinks {
    float: none;
    clear: both;
  }
}

#helpfullinks div {
  float: left;
  margin-right: 45px;
  width: 20%;
}

#helpfullinks div a {
  display: inline;
  margin-top: -6px;
  margin-bottom: 8px;
}

#helpfullinks p.category {
  color: #FFF;
  font-size: 21px;
  margin: 0 0 14px;
}

#helpfullinks p.category a {
  color: #FFF;
}

#helpfullinks ul {
  list-style-type: none;
  padding: 0px;
  margin: 14px 0 0 0;
}

#helpfullinks li {
  padding: 0px;
  margin: 0 0 6px;
  font-size: 15px;
}

#poweredby {
  max-width: 100%;
  margin: 115px auto 0;
  overflow: hidden;
  text-align: center;
}

@media screen and (max-width: 768px) {
  #poweredby {
    margin: 26px auto 0;
  }
}

#poweredby p {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.7);
  margin: 0 0 10px;
  text-align: center;
}

#poweredby ul {
  display: inline-block;
  margin: 0px auto;
  list-style-type: none;
  padding: 0px;
}

#poweredby li {
  margin: 0 40px 0 0;
  float: left;
}

@media only screen and (max-width: 495px) {
  #poweredby li {
    margin: 0 0 10px 0;
    float: none;
    clear: both;
  }
}

#poweredby .footer-divvy {
  display: block;
  width: 77px;
  height: 24px;
  background: url("https://www.proxibid.com/images/footer-logo-divvy.png") top left no-repeat;
  text-indent: -9999px;
}

#poweredby .footer-finest {
  display: block;
  width: 77px;
  height: 24px;
  background: url("https://www.proxibid.com/images/footer-logo-thefinest.png") top left no-repeat;
  text-indent: -9999px;
}

#poweredby .footer-apn {
  display: block;
  width: 77px;
  height: 24px;
  background: url("https://www.proxibid.com/images/footer-logo-apn.png") top left no-repeat;
  text-indent: -9999px;
}

#social {
  margin: 60px auto;
  overflow: hidden;
  text-align: center;
}

@media screen and (max-width: 768px) {
  #social {
    margin: 26px auto;
  }
}

#social ul {
  margin: 0px auto;
  list-style-type: none;
  padding: 0px;
}

#social ul.social,
#social ul.contact {
  display: inline-block;
}

#social li {
  margin: 0 17px 0 0;
  float: left;
  color: rgba(255, 255, 255, 0.7);
}

@media only screen and (max-width: 495px) {
  #social li {
    margin: 0 0 10px 0;
    float: none;
    clear: both;
  }
}

#social li a {
  color: rgba(255, 255, 255, 0.7);
}

iframe {
  overflow: hidden;
}

#footerSealiFrame {
  border: medium none;
  height: 175px;
  margin: 0 auto;
  width: 100%;
  display: block;
  overflow: hidden;
}

@media only screen and (max-width: 600px) {
  #footerSealiFrame {
    height: 285px;
  }
  #footerSeals>img,
  #footerSeals>embed,
  #footerSeals>object,
  #footerSeals>a {
    display: inline-block !important;
    margin: 0 6px 10px !important;
    vertical-align: middle !important;
  }
}

/* Bonus (let's get Flexy) */

@media (max-width: 600px) {
  #helpfullinks {
    display: flex;
    flex-direction: column;
    flex-flow: wrap;
  }
  #helpfullinks div {
    width: 100%;
    margin-right: auto;
    margin-left: auto;
    border-bottom: 1px solid #5a5a5a;
    margin-bottom: 10px;
    padding-bottom: 10px;
  }
}

<footer>
  <div class="content">
    <div id="helpfullinks">
      <div>
        <p class="category">About</p>
        <ul>
          <li><a href="#">Our Mission</a></li>
          <li><a href="#">AdaptaPASS</a></li>
          <li><a href="#">Affiliates</a></li>
          <li><a href="#">Campus Representatives</a></li>
          <li><a href="#">Privacy Policy</a></li>
        </ul>
      </div>
      <div>
        <p class="category">Products</p>
        <ul>
          <li><a href="#">All-Access Course Bundles</a></li>
          <li><a href="#">CRAM Courses</a></li>
          <li><a href="#">Audio Lectures</a></li>
          <li><a href="#">TestBank Software</a></li>
          <li><a href="#">Digital Flashcards</a></li>
          <li><a href="#">Exam Stress Relief</a></li>
        </ul>
      </div>
      <div>
        <p class="category">Resources</p>
        <ul>
          <li><a href="#">Free Assessment</a></li>
          <li><a href="#">Start a Free Trial</a></li>
          <li><a href="#">Blog</a></li>
          <li><a href="#">Requirements by State</a></li>
        </ul>
      </div>
      <div class="last">
        <p class="category">Support</p>
        <ul>
          <li><a href="#">(800) 824 2811</a></li>
          <li><a href="#">Use the chat feature below to reach one of our support specialists</a></li>
          <li><a href="#">Contact Us</a></li>
          <li><a href="#">Login to AdaptaPASS</a></li>
          <li><a href="#">Login to myYaeger Student Portal</a></li>
        </ul>
      </div>
      <div class="clear"></div>
    </div>
    <div class="clear"></div>
    <div id="poweredby">
      <ul>
        <li class="last"><img src="include/images/footerlogo.png"></li>
      </ul>
    </div>
    <div class="clear"></div>
    <div id="social">
      <ul class="social">
        <li><a target="_blank" href="#">Facebook</a></li>
        <li><a target="_blank" href="#">Twitter</a></li>
        <li><a target="_blank" href="#">YouTube</a></li>
        <li class="last"><a target="_blank" href="#">LinkedIn</a></li>
      </ul>
      <div class="clear"></div>
      <ul class="contact">
        <li class="last">&copy;2017 Yaegar CPA Review, All Rights Reserved</li>
      </ul>
    </div>
  </div>
</footer>


来源: stackexchange

问:
Fs2 how to fold then append to a Stream
I want to append to a Stream

But next stream relies on previous Stream's folding result

Here is how I did, but the Stream s is evaluated twice

scasite link

```<code>import fs2._

def ints(start: Int) = Stream.iterate(start) { i =>
  println(i)
  i + 1
}.take(10)

val s = ints(0)

def foldAppend(init: Int)(f: (Int, Int) => Int)(next: Int => Stream[Pure, Int]) = {
  s ++ s.fold(init)(f).flatMap(next)
}

val res = foldAppend(0)((s, i) => s + 1)(ints)
println(res.toList)
</code>```

How can I implement the foldAppend method that evalute s only once.

答: Have you considered using scala.collection.immutable.Stream? It's cached, so it won't be evaluated multiple times.

ContentLicense: CC BY-SA 3.0

Title: Fs2 how to fold then append to a Stream

Body:
I want to append to a Stream

But next stream relies on previous Stream's folding result

Here is how I did, but the Stream s is evaluated twice

scasite link

import fs2._

def ints(start: Int) = Stream.iterate(start) { i =>
  println(i)
  i + 1
}.take(10)

val s = ints(0)

def foldAppend(init: Int)(f: (Int, Int) => Int)(next: Int => Stream[Pure, Int]) = {
  s ++ s.fold(init)(f).flatMap(next)
}

val res = foldAppend(0)((s, i) => s + 1)(ints)
println(res.toList)

How can I implement the foldAppend method that evalute s only once.


问:
retrieve data from database and put into textview
I am successful in inserting data into the database but when i try to retrieve data and display in textView it gets directed to the MainActivity.

The Regiser_page.java is as follows

```<code>public class Register_Page extends Activity {
    int from_Where_I_Am_Coming = 0;
    private no.nordicsemi.android.nrftoolbox.myDbAdapter mydb ;
    Button b1,b2;
    TextView name ;
    TextView email;
    TextView pass;
    TextView dob;
    TextView gender;
    TextView phone;
    TextView city;
    int id_To_Update = 0;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_register__page);
        name = (TextView) findViewById(R.id.editText_name);
        phone = (TextView) findViewById(R.id.editText_phone);
        email = (TextView) findViewById(R.id.editText_email);
        pass = (TextView) findViewById(R.id.editText_pass);
        dob = (TextView) findViewById(R.id.editText_dob);
        gender=(TextView)findViewById(R.id.editText_gender);
        city=(TextView)findViewById(R.id.editText_city);
        b1=(Button)findViewById(R.id.button_register);
        b2=(Button)findViewById(R.id.button_view);
        mydb = new no.nordicsemi.android.nrftoolbox.myDbAdapter(this);

public void addUser(View view) {

        if(mydb.insertContact(name.getText().toString(), email.getText().toString(),
                pass.getText().toString(), dob.getText().toString(),
                gender.getText().toString(),phone.getText().toString(),city.getText().toString())){
            Toast.makeText(getApplicationContext(), "done",
                    Toast.LENGTH_SHORT).show();

        } else{
            Toast.makeText(getApplicationContext(), "not done",
                    Toast.LENGTH_SHORT).show();
        }

    }

}
 public void getmydata(View v){
        Intent intent =new Intent();
        intent.setClass(this ,View_Profile.class);
        startActivity(intent);
    }
</code>```

The Activity_register_page.xml is as follows:

```<code><?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.NestedScrollView
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="no.nordicsemi.android.nrftoolbox.Register_Page">

    <RelativeLayout
        android:id="@+id/layout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="#ffffff"
        android:orientation="vertical"
        android:weightSum="1">

        <TextView
            android:id="@+id/register"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignEnd="@+id/editText_name"
            android:layout_alignParentTop="true"
            android:layout_marginLeft="100dp"
            android:layout_marginTop="28dp"
            android:layout_weight="0.36"
            android:text="Register Here"
            android:textAlignment="center"
            android:textAllCaps="true"
            android:textColor="#3333ff"
            android:textSize="28dp" />

        <Button
            android:id="@+id/button_view"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="790dp"
            android:onClick="mydata"
            android:text="View data" />

        <TextView
            android:id="@+id/textView_name"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="14sp"
            android:layout_marginTop="70sp"
            android:autoText="false"
            android:text="Name :"
            android:textColor="#3368ff"
            android:textColorLink="#000000"
            android:textSize="20sp" />

        <EditText
            android:id="@+id/editText_name"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="10sp"
            android:layout_marginRight="10sp"
            android:layout_marginTop="100sp"
            android:ems="10"
            android:hint="Enter your name"
            android:inputType="textPersonName" />

        <TextView
            android:id="@+id/textView_email"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="14sp"
            android:layout_marginTop="160sp"
            android:text="Email-id :"
            android:textColor="#3368ff"
            android:textColorLink="#000000"
            android:textSize="20sp" />

        <EditText
            android:id="@+id/editText_email"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="10sp"
            android:layout_marginRight="10sp"
            android:layout_marginTop="190sp"
            android:ems="10"
            android:hint="Enter Email-id"
            android:inputType="textEmailAddress" />

        <TextView
            android:id="@+id/textView_pass"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="14dp"
            android:layout_marginTop="250dp"
            android:hint="Enter Password"
            android:text="Password"
            android:textColor="#3368ff"
            android:textSize="20sp" />

        <EditText
            android:id="@+id/editText_pass"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="10dp"
            android:layout_marginRight="10dp"
            android:layout_marginTop="280dp"
            android:ems="10"
            android:hint="Enter Password"
            android:inputType="textPassword" />

        <TextView
            android:id="@+id/textView_dob"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="14sp"
            android:layout_marginTop="450sp"
            android:text="Date of Birth :"
            android:textColor="#3368ff"
            android:textColorLink="#000000"
            android:textSize="20sp" />

        <EditText
            android:id="@+id/editText_dob"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="10dp"
            android:layout_marginRight="10dp"
            android:layout_marginTop="480dp"
            android:ems="10"
            android:hint="Date of Birth"
            android:inputType="date" />

        <TextView
            android:id="@+id/textView_phone"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="14sp"
            android:layout_marginTop="540sp"
            android:text="Phone No. :"
            android:textColor="#3368ff"
            android:textColorLink="#000000"
            android:textSize="20sp" />

        <EditText
            android:id="@+id/editText_phone"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="10sp"
            android:layout_marginRight="10sp"
            android:layout_marginTop="570sp"
            android:ems="10"
            android:hint="Enter Phone No."
            android:inputType="phone" />

        <TextView
            android:id="@+id/textView_city"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="14sp"
            android:layout_marginTop="630sp"
            android:text="City :"
            android:textColor="#3368ff"
            android:textColorLink="#000000"
            android:textSize="20sp" />

        <EditText
            android:id="@+id/editText_city"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="10sp"
            android:layout_marginRight="10sp"
            android:layout_marginTop="660sp"
            android:ems="10"
            android:hint="Enter your City"
            android:inputType="textPersonName" />

        <TextView
            android:id="@+id/textView_gender"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="14sp"
            android:layout_marginTop="340sp"
            android:text="Gender :"
            android:textColor="#3368ff"
            android:textColorLink="#000000"
            android:textSize="20sp" />

        <EditText
            android:id="@+id/editText_gender"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="10dp"
            android:layout_marginRight="10dp"
            android:layout_marginTop="370dp"
            android:ems="10"
            android:hint="M/F/Others"
            android:inputType="textPersonName" />

        <Button
            android:id="@+id/button_register"
            android:layout_width="150dp"
            android:layout_height="wrap_content"
            android:layout_marginBottom="20dp"
            android:layout_marginLeft="110dp"
            android:layout_marginTop="720dp"
            android:background="#3368ff"
            android:onClick="addUser"
            android:text="Register"
            android:textAlignment="center"
            android:textColor="#ffffff" />

    </RelativeLayout>
</android.support.v4.widget.NestedScrollView>
</code>```

The View_Profile.java is as follows:

```<code>public class View_Profile extends AppCompatActivity {
    TextView name, email, pass, phone, gender, city, dob;
    int id_To_Update=0;
    private no.nordicsemi.android.nrftoolbox.myDbAdapter mydb;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_view__profile);
        name = (TextView) findViewById(R.id.textView_name);
        phone = (TextView) findViewById(R.id.textView_phone);
        email = (TextView) findViewById(R.id.textView_email);
        pass = (TextView) findViewById(R.id.textView_pass);
        gender = (TextView) findViewById(R.id.textView_gender);
        dob = (TextView) findViewById(R.id.textView_dob);
        city = (TextView) findViewById(R.id.textView_city);
        mydb = new no.nordicsemi.android.nrftoolbox.myDbAdapter(this);
        Cursor rs = mydb.getData(1);
        id_To_Update = 1;
        rs.moveToFirst();

        String nam = rs.getString(rs.getColumnIndex(mydb.CONTACTS_COLUMN_NAME));
        String phon = rs.getString(rs.getColumnIndex(mydb.CONTACTS_COLUMN_PHONE));
        String emai = rs.getString(rs.getColumnIndex(mydb.CONTACTS_COLUMN_EMAIL));
        String cit = rs.getString(rs.getColumnIndex(mydb.CONTACTS_COLUMN_CITY));
        String gend = rs.getString(rs.getColumnIndex(mydb.CONTACTS_COLUMN_GENDER));
        String pas = rs.getString(rs.getColumnIndex(mydb.CONTACTS_COLUMN_PASS));
        String dobb = rs.getString(rs.getColumnIndex(mydb.CONTACTS_COLUMN_DOB));

        if (!rs.isClosed())  {
            rs.close();
        }

        name.setText((CharSequence)nam);
        name.setFocusable(false);
        name.setClickable(false);

        email.setText((CharSequence)emai);
        email.setFocusable(false);
        email.setClickable(false);

        pass.setText((CharSequence)pas);
        pass.setFocusable(false);
        pass.setClickable(false);

        dob.setText((CharSequence)dobb);
        dob.setFocusable(false);
        dob.setClickable(false);

        gender.setText((CharSequence)gend);
        gender.setFocusable(false);
        gender.setClickable(false);

        phone.setText((CharSequence)phon);
        phone.setFocusable(false);
        phone.setClickable(false);

        city.setText((CharSequence)cit);
        city.setFocusable(false);
        city.setClickable(false);

    }
}
</code>```

The myDbAdapter.java is as follows:

```<code>public class myDbAdapter extends SQLiteOpenHelper {

    public static final String DATABASE_NAME = "MyDBName.db";
    public static final String CONTACTS_TABLE_NAME = "contacts";
    public static final String CONTACTS_COLUMN_ID = "id";
    public static final String CONTACTS_COLUMN_NAME = "name";
    public static final String CONTACTS_COLUMN_EMAIL = "email";
    public static final String CONTACTS_COLUMN_PASS = "password";
    public static final String CONTACTS_COLUMN_DOB = "date-of-birth";
    public static final String CONTACTS_COLUMN_GENDER = "gender";
    public static final String CONTACTS_COLUMN_PHONE="phone";
    public static final String CONTACTS_COLUMN_CITY="city";
    private HashMap hp;

    public myDbAdapter(Context context) {
        super(context, DATABASE_NAME , null, 1);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        // TODO Auto-generated method stub
        db.execSQL(
                "create table contacts " +
                        "(id integer primary key, name text,email text,pass text, dob text,gender text,phone text,city text)"
        );
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        // TODO Auto-generated method stub
        db.execSQL("DROP TABLE IF EXISTS contacts");
        onCreate(db);
    }

    public boolean insertContact (String name, String email, String pass, String dob,String gender,String phone,String city) {
        SQLiteDatabase db = this.getWritableDatabase();
        ContentValues contentValues = new ContentValues();
        contentValues.put("name", name);
        contentValues.put("email", email);
        contentValues.put("password", pass);
        contentValues.put("date-of-birth", dob);
        contentValues.put("gender", gender);
        contentValues.put("phone",phone);
        contentValues.put("city",city);
        db.insert("contacts", null, contentValues);
        return true;
    }

    public Cursor getData(int id) {
        SQLiteDatabase db = this.getReadableDatabase();
        Cursor res =  db.rawQuery( "select * from contacts where id="+id+"", null );

        return res;
    }

    public int numberOfRows(){
        SQLiteDatabase db = this.getReadableDatabase();
        int numRows = (int) DatabaseUtils.queryNumEntries(db, CONTACTS_TABLE_NAME);
        return numRows;
    }

    public boolean updateContact (Integer id, String name, String email, String pass, String dob,String gender,String phone,String city) {
        SQLiteDatabase db = this.getWritableDatabase();
        ContentValues contentValues = new ContentValues();
        contentValues.put("name", name);
        contentValues.put("email", email);
        contentValues.put("password", pass);
        contentValues.put("date-of-birth", dob);
        contentValues.put("gender", gender);
        contentValues.put("phone",phone);
        contentValues.put("city",city);
        db.update("contacts", contentValues, "id = ? ", new String[] { Integer.toString(id) } );
        return true;
    }

    public Integer deleteContact (Integer id) {
        SQLiteDatabase db = this.getWritableDatabase();
        return db.delete("contacts",
                "id = ? ",
                new String[] { Integer.toString(id) });
    }

    public ArrayList<String> getAllCotacts() {
        ArrayList<String> array_list = new ArrayList<String>();

        //hp = new HashMap();
        SQLiteDatabase db = this.getReadableDatabase();
        Cursor res =  db.rawQuery( "select * from contacts", null );
        res.moveToFirst();

        while(res.isAfterLast() == false){
            array_list.add(res.getString(res.getColumnIndex(CONTACTS_COLUMN_NAME)));
            res.moveToNext();
        }
        return array_list;
    }
}
</code>```

What is the error that is directing View_Profile to MainActivity and results in failure of the display of the result??

My log file shows this error :

```<code>near "-": syntax error
 Error inserting phone=5895346896 email=man@gmail.com name=my name gender=male password=47ufvjtio city=bangalore date-of-birth=30-02-95
                                                                                android.database.sqlite.SQLiteException: near "-": syntax error (code 1): , while compiling: INSERT INTO contacts(phone,email,name,gender,password,city,date-of-birth) VALUES (?,?,?,?,?,?,?)
                                                                                at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
                                                                                at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:889)
                                                                                at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:500)
                                                                                at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588)
                                                                                at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:58)
                                                                                at android.database.sqlite.SQLiteStatement.<init>(SQLiteStatement.java:31)
                                                                                at android.database.sqlite.SQLiteDatabase.insertWithOnConflict(SQLiteDatabase.java:1469)
                                                                                at android.database.sqlite.SQLiteDatabase.insert(SQLiteDatabase.java:1341)
                                                                                at no.nordicsemi.android.nrftoolbox.myDbAdapter.insertContact(myDbAdapter.java:60)
                                                                                at no.nordicsemi.android.nrftoolbox.Register_Page.addUser(Register_Page.java:194)
                                                                                at java.lang.reflect.Method.invoke(Native Method)
                                                                                at java.lang.reflect.Method.invoke(Method.java:372)
                                                                                at android.view.View$1.onClick(View.java:4020)
                                                                                at android.view.View.performClick(View.java:4785)
                                                                                at android.view.View$PerformClick.run(View.java:19888)
                                                                                at android.os.Handler.handleCallback(Handler.java:739)
                                                                                at android.os.Handler.dispatchMessage(Handler.java:95)
                                                                                at android.os.Looper.loop(Looper.java:135)
                                                                                at android.app.ActivityThread.main(ActivityThread.java:5276)
                                                                                at java.lang.reflect.Method.invoke(Native Method)
                                                                                at java.lang.reflect.Method.invoke(Method.java:372)
                                                                                at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:911)
                                                                                at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:706)
</code>```

Is there any error in the insertContact code?? or why is this not working?

答:
Let's make it clear :

*** You are creating table with column "dob"

```<code> @Override
public void onCreate(SQLiteDatabase db) {
    // TODO Auto-generated method stub
    db.execSQL(
            "create table contacts " +
                    "(id integer primary key, name text,email text,pass text, dob text,gender text,phone text,city text)"
    );
}
</code>```

*** Now look into

```<code>public boolean insertContact (String name, String email, String pass, String dob,String gender,String phone,String city) {
    SQLiteDatabase db = this.getWritableDatabase();
    ContentValues contentValues = new ContentValues();
    contentValues.put("name", name);
    contentValues.put("email", email);
    contentValues.put("password", pass);
    //contentValues.put("date-of-birth", dob);
    // it should be "dob" instead of "date-of-birth"
    contentValues.put("dob", dob);
    // like this
    contentValues.put("gender", gender);
    contentValues.put("phone",phone);
    contentValues.put("city",city);
    db.insert("contacts", null, contentValues);
    return true;
}
</code>```

** also  make change here

```<code>// public static final String CONTACTS_COLUMN_DOB = "date-of-birth";
 // as
public static final String CONTACTS_COLUMN_DOB = "dob";
</code>```

It's all about mismatching column name of date of birth

Body:
I am successful in inserting data into the database but when i try to retrieve data and display in textView it gets directed to the MainActivity.

The Regiser_page.java is as follows

public class Register_Page extends Activity {
    int from_Where_I_Am_Coming = 0;
    private no.nordicsemi.android.nrftoolbox.myDbAdapter mydb ;
    Button b1,b2;
    TextView name ;
    TextView email;
    TextView pass;
    TextView dob;
    TextView gender;
    TextView phone;
    TextView city;
    int id_To_Update = 0;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_register__page);
        name = (TextView) findViewById(R.id.editText_name);
        phone = (TextView) findViewById(R.id.editText_phone);
        email = (TextView) findViewById(R.id.editText_email);
        pass = (TextView) findViewById(R.id.editText_pass);
        dob = (TextView) findViewById(R.id.editText_dob);
        gender=(TextView)findViewById(R.id.editText_gender);
        city=(TextView)findViewById(R.id.editText_city);
        b1=(Button)findViewById(R.id.button_register);
        b2=(Button)findViewById(R.id.button_view);
        mydb = new no.nordicsemi.android.nrftoolbox.myDbAdapter(this);

public void addUser(View view) {

        if(mydb.insertContact(name.getText().toString(), email.getText().toString(),
                pass.getText().toString(), dob.getText().toString(),
                gender.getText().toString(),phone.getText().toString(),city.getText().toString())){
            Toast.makeText(getApplicationContext(), "done",
                    Toast.LENGTH_SHORT).show();

        } else{
            Toast.makeText(getApplicationContext(), "not done",
                    Toast.LENGTH_SHORT).show();
        }

    }

}
 public void getmydata(View v){
        Intent intent =new Intent();
        intent.setClass(this ,View_Profile.class);
        startActivity(intent);
    }

The Activity_register_page.xml is as follows:

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.NestedScrollView
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="no.nordicsemi.android.nrftoolbox.Register_Page">

    <RelativeLayout
        android:id="@+id/layout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="#ffffff"
        android:orientation="vertical"
        android:weightSum="1">

        <TextView
            android:id="@+id/register"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignEnd="@+id/editText_name"
            android:layout_alignParentTop="true"
            android:layout_marginLeft="100dp"
            android:layout_marginTop="28dp"
            android:layout_weight="0.36"
            android:text="Register Here"
            android:textAlignment="center"
            android:textAllCaps="true"
            android:textColor="#3333ff"
            android:textSize="28dp" />

        <Button
            android:id="@+id/button_view"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="790dp"
            android:onClick="mydata"
            android:text="View data" />

        <TextView
            android:id="@+id/textView_name"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="14sp"
            android:layout_marginTop="70sp"
            android:autoText="false"
            android:text="Name :"
            android:textColor="#3368ff"
            android:textColorLink="#000000"
            android:textSize="20sp" />

        <EditText
            android:id="@+id/editText_name"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="10sp"
            android:layout_marginRight="10sp"
            android:layout_marginTop="100sp"
            android:ems="10"
            android:hint="Enter your name"
            android:inputType="textPersonName" />

        <TextView
            android:id="@+id/textView_email"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="14sp"
            android:layout_marginTop="160sp"
            android:text="Email-id :"
            android:textColor="#3368ff"
            android:textColorLink="#000000"
            android:textSize="20sp" />

        <EditText
            android:id="@+id/editText_email"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="10sp"
            android:layout_marginRight="10sp"
            android:layout_marginTop="190sp"
            android:ems="10"
            android:hint="Enter Email-id"
            android:inputType="textEmailAddress" />

        <TextView
            android:id="@+id/textView_pass"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="14dp"
            android:layout_marginTop="250dp"
            android:hint="Enter Password"
            android:text="Password"
            android:textColor="#3368ff"
            android:textSize="20sp" />

        <EditText
            android:id="@+id/editText_pass"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="10dp"
            android:layout_marginRight="10dp"
            android:layout_marginTop="280dp"
            android:ems="10"
            android:hint="Enter Password"
            android:inputType="textPassword" />

        <TextView
            android:id="@+id/textView_dob"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="14sp"
            android:layout_marginTop="450sp"
            android:text="Date of Birth :"
            android:textColor="#3368ff"
            android:textColorLink="#000000"
            android:textSize="20sp" />

        <EditText
            android:id="@+id/editText_dob"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="10dp"
            android:layout_marginRight="10dp"
            android:layout_marginTop="480dp"
            android:ems="10"
            android:hint="Date of Birth"
            android:inputType="date" />

        <TextView
            android:id="@+id/textView_phone"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="14sp"
            android:layout_marginTop="540sp"
            android:text="Phone No. :"
            android:textColor="#3368ff"
            android:textColorLink="#000000"
            android:textSize="20sp" />

        <EditText
            android:id="@+id/editText_phone"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="10sp"
            android:layout_marginRight="10sp"
            android:layout_marginTop="570sp"
            android:ems="10"
            android:hint="Enter Phone No."
            android:inputType="phone" />

        <TextView
            android:id="@+id/textView_city"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="14sp"
            android:layout_marginTop="630sp"
            android:text="City :"
            android:textColor="#3368ff"
            android:textColorLink="#000000"
            android:textSize="20sp" />

        <EditText
            android:id="@+id/editText_city"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="10sp"
            android:layout_marginRight="10sp"
            android:layout_marginTop="660sp"
            android:ems="10"
            android:hint="Enter your City"
            android:inputType="textPersonName" />

        <TextView
            android:id="@+id/textView_gender"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="14sp"
            android:layout_marginTop="340sp"
            android:text="Gender :"
            android:textColor="#3368ff"
            android:textColorLink="#000000"
            android:textSize="20sp" />

        <EditText
            android:id="@+id/editText_gender"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="10dp"
            android:layout_marginRight="10dp"
            android:layout_marginTop="370dp"
            android:ems="10"
            android:hint="M/F/Others"
            android:inputType="textPersonName" />

        <Button
            android:id="@+id/button_register"
            android:layout_width="150dp"
            android:layout_height="wrap_content"
            android:layout_marginBottom="20dp"
            android:layout_marginLeft="110dp"
            android:layout_marginTop="720dp"
            android:background="#3368ff"
            android:onClick="addUser"
            android:text="Register"
            android:textAlignment="center"
            android:textColor="#ffffff" />

    </RelativeLayout>
</android.support.v4.widget.NestedScrollView>

The View_Profile.java is as follows:

public class View_Profile extends AppCompatActivity {
    TextView name, email, pass, phone, gender, city, dob;
    int id_To_Update=0;
    private no.nordicsemi.android.nrftoolbox.myDbAdapter mydb;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_view__profile);
        name = (TextView) findViewById(R.id.textView_name);
        phone = (TextView) findViewById(R.id.textView_phone);
        email = (TextView) findViewById(R.id.textView_email);
        pass = (TextView) findViewById(R.id.textView_pass);
        gender = (TextView) findViewById(R.id.textView_gender);
        dob = (TextView) findViewById(R.id.textView_dob);
        city = (TextView) findViewById(R.id.textView_city);
        mydb = new no.nordicsemi.android.nrftoolbox.myDbAdapter(this);
        Cursor rs = mydb.getData(1);
        id_To_Update = 1;
        rs.moveToFirst();

        String nam = rs.getString(rs.getColumnIndex(mydb.CONTACTS_COLUMN_NAME));
        String phon = rs.getString(rs.getColumnIndex(mydb.CONTACTS_COLUMN_PHONE));
        String emai = rs.getString(rs.getColumnIndex(mydb.CONTACTS_COLUMN_EMAIL));
        String cit = rs.getString(rs.getColumnIndex(mydb.CONTACTS_COLUMN_CITY));
        String gend = rs.getString(rs.getColumnIndex(mydb.CONTACTS_COLUMN_GENDER));
        String pas = rs.getString(rs.getColumnIndex(mydb.CONTACTS_COLUMN_PASS));
        String dobb = rs.getString(rs.getColumnIndex(mydb.CONTACTS_COLUMN_DOB));

        if (!rs.isClosed())  {
            rs.close();
        }

        name.setText((CharSequence)nam);
        name.setFocusable(false);
        name.setClickable(false);

        email.setText((CharSequence)emai);
        email.setFocusable(false);
        email.setClickable(false);

        pass.setText((CharSequence)pas);
        pass.setFocusable(false);
        pass.setClickable(false);

        dob.setText((CharSequence)dobb);
        dob.setFocusable(false);
        dob.setClickable(false);

        gender.setText((CharSequence)gend);
        gender.setFocusable(false);
        gender.setClickable(false);

        phone.setText((CharSequence)phon);
        phone.setFocusable(false);
        phone.setClickable(false);

        city.setText((CharSequence)cit);
        city.setFocusable(false);
        city.setClickable(false);

    }
}

The myDbAdapter.java is as follows:

public class myDbAdapter extends SQLiteOpenHelper {

    public static final String DATABASE_NAME = "MyDBName.db";
    public static final String CONTACTS_TABLE_NAME = "contacts";
    public static final String CONTACTS_COLUMN_ID = "id";
    public static final String CONTACTS_COLUMN_NAME = "name";
    public static final String CONTACTS_COLUMN_EMAIL = "email";
    public static final String CONTACTS_COLUMN_PASS = "password";
    public static final String CONTACTS_COLUMN_DOB = "date-of-birth";
    public static final String CONTACTS_COLUMN_GENDER = "gender";
    public static final String CONTACTS_COLUMN_PHONE="phone";
    public static final String CONTACTS_COLUMN_CITY="city";
    private HashMap hp;

    public myDbAdapter(Context context) {
        super(context, DATABASE_NAME , null, 1);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        // TODO Auto-generated method stub
        db.execSQL(
                "create table contacts " +
                        "(id integer primary key, name text,email text,pass text, dob text,gender text,phone text,city text)"
        );
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        // TODO Auto-generated method stub
        db.execSQL("DROP TABLE IF EXISTS contacts");
        onCreate(db);
    }

    public boolean insertContact (String name, String email, String pass, String dob,String gender,String phone,String city) {
        SQLiteDatabase db = this.getWritableDatabase();
        ContentValues contentValues = new ContentValues();
        contentValues.put("name", name);
        contentValues.put("email", email);
        contentValues.put("password", pass);
        contentValues.put("date-of-birth", dob);
        contentValues.put("gender", gender);
        contentValues.put("phone",phone);
        contentValues.put("city",city);
        db.insert("contacts", null, contentValues);
        return true;
    }

    public Cursor getData(int id) {
        SQLiteDatabase db = this.getReadableDatabase();
        Cursor res =  db.rawQuery( "select * from contacts where id="+id+"", null );

        return res;
    }

    public int numberOfRows(){
        SQLiteDatabase db = this.getReadableDatabase();
        int numRows = (int) DatabaseUtils.queryNumEntries(db, CONTACTS_TABLE_NAME);
        return numRows;
    }

    public boolean updateContact (Integer id, String name, String email, String pass, String dob,String gender,String phone,String city) {
        SQLiteDatabase db = this.getWritableDatabase();
        ContentValues contentValues = new ContentValues();
        contentValues.put("name", name);
        contentValues.put("email", email);
        contentValues.put("password", pass);
        contentValues.put("date-of-birth", dob);
        contentValues.put("gender", gender);
        contentValues.put("phone",phone);
        contentValues.put("city",city);
        db.update("contacts", contentValues, "id = ? ", new String[] { Integer.toString(id) } );
        return true;
    }

    public Integer deleteContact (Integer id) {
        SQLiteDatabase db = this.getWritableDatabase();
        return db.delete("contacts",
                "id = ? ",
                new String[] { Integer.toString(id) });
    }

    public ArrayList<String> getAllCotacts() {
        ArrayList<String> array_list = new ArrayList<String>();

        //hp = new HashMap();
        SQLiteDatabase db = this.getReadableDatabase();
        Cursor res =  db.rawQuery( "select * from contacts", null );
        res.moveToFirst();

        while(res.isAfterLast() == false){
            array_list.add(res.getString(res.getColumnIndex(CONTACTS_COLUMN_NAME)));
            res.moveToNext();
        }
        return array_list;
    }
}

What is the error that is directing View_Profile to MainActivity and results in failure of the display of the result??

My log file shows this error :

near "-": syntax error
 Error inserting phone=5895346896 email=man@gmail.com name=my name gender=male password=47ufvjtio city=bangalore date-of-birth=30-02-95
                                                                                android.database.sqlite.SQLiteException: near "-": syntax error (code 1): , while compiling: INSERT INTO contacts(phone,email,name,gender,password,city,date-of-birth) VALUES (?,?,?,?,?,?,?)
                                                                                at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
                                                                                at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:889)
                                                                                at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:500)
                                                                                at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588)
                                                                                at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:58)
                                                                                at android.database.sqlite.SQLiteStatement.<init>(SQLiteStatement.java:31)
                                                                                at android.database.sqlite.SQLiteDatabase.insertWithOnConflict(SQLiteDatabase.java:1469)
                                                                                at android.database.sqlite.SQLiteDatabase.insert(SQLiteDatabase.java:1341)
                                                                                at no.nordicsemi.android.nrftoolbox.myDbAdapter.insertContact(myDbAdapter.java:60)
                                                                                at no.nordicsemi.android.nrftoolbox.Register_Page.addUser(Register_Page.java:194)
                                                                                at java.lang.reflect.Method.invoke(Native Method)
                                                                                at java.lang.reflect.Method.invoke(Method.java:372)
                                                                                at android.view.View$1.onClick(View.java:4020)
                                                                                at android.view.View.performClick(View.java:4785)
                                                                                at android.view.View$PerformClick.run(View.java:19888)
                                                                                at android.os.Handler.handleCallback(Handler.java:739)
                                                                                at android.os.Handler.dispatchMessage(Handler.java:95)
                                                                                at android.os.Looper.loop(Looper.java:135)
                                                                                at android.app.ActivityThread.main(ActivityThread.java:5276)
                                                                                at java.lang.reflect.Method.invoke(Native Method)
                                                                                at java.lang.reflect.Method.invoke(Method.java:372)
                                                                                at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:911)
                                                                                at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:706)

Is there any error in the insertContact code?? or why is this not working?

Body:
Let's make it clear :

*** You are creating table with column "dob"

 @Override
public void onCreate(SQLiteDatabase db) {
    // TODO Auto-generated method stub
    db.execSQL(
            "create table contacts " +
                    "(id integer primary key, name text,email text,pass text, dob text,gender text,phone text,city text)"
    );
}

*** Now look into

public boolean insertContact (String name, String email, String pass, String dob,String gender,String phone,String city) {
    SQLiteDatabase db = this.getWritableDatabase();
    ContentValues contentValues = new ContentValues();
    contentValues.put("name", name);
    contentValues.put("email", email);
    contentValues.put("password", pass);
    //contentValues.put("date-of-birth", dob);
    // it should be "dob" instead of "date-of-birth"
    contentValues.put("dob", dob);
    // like this
    contentValues.put("gender", gender);
    contentValues.put("phone",phone);
    contentValues.put("city",city);
    db.insert("contacts", null, contentValues);
    return true;
}

** also  make change here

// public static final String CONTACTS_COLUMN_DOB = "date-of-birth";
 // as
public static final String CONTACTS_COLUMN_DOB = "dob";

It's all about mismatching column name of date of birth


问:
How to generate random numbers in many ranges
I am wondering how to generate random numbers in the following way in R:

```<code> randomly choose 1 number between 1 and 15
 randomly choose 1 number between 16 and 30
 ...
 randomly choose 1 number between 86 and 100
</code>```

I know that I can do this with a loop but I am wondering if there is any non-loop way to do this. I tried to google around but didn't find much helpful.

答:
Use runif(). It works as runif(n, min = x, max = y).

n is the number of randomly generated numbers that you want. min and max are the range from which the numbers can be drawn.

In your case:

```<code>> runif(1, min=1, max=15)
[1] 2.916329
> runif(1, min=16, max=30)
[1] 28.54506
> runif(1, min=86, max=100)
[1] 87.43045
</code>```

Note that the numbers generated above have decimal figures. If you want whole integers, insert the above inside round() i.e.

```<code>> round(runif(1, min=1, max=15), digits=0)
[1] 7
> round(runif(1, min=16, max=30), digits=0)
[1] 23
> round(runif(1, min=86, max=100), digits=0)
[1] 90
</code>```

Body:
I am wondering how to generate random numbers in the following way in R:

 randomly choose 1 number between 1 and 15
 randomly choose 1 number between 16 and 30
 ...
 randomly choose 1 number between 86 and 100

I know that I can do this with a loop but I am wondering if there is any non-loop way to do this. I tried to google around but didn't find much helpful.

Body:
Use runif(). It works as runif(n, min = x, max = y).

n is the number of randomly generated numbers that you want. min and max are the range from which the numbers can be drawn.

In your case:

> runif(1, min=1, max=15)
[1] 2.916329
> runif(1, min=16, max=30)
[1] 28.54506
> runif(1, min=86, max=100)
[1] 87.43045

Note that the numbers generated above have decimal figures. If you want whole integers, insert the above inside round() i.e.

> round(runif(1, min=1, max=15), digits=0)
[1] 7
> round(runif(1, min=16, max=30), digits=0)
[1] 23
> round(runif(1, min=86, max=100), digits=0)
[1] 90


问:
PANDAS select rows that contain most recent observation of pairing
The Problem:

I am looking to select only the most recent record of price within each pairing of uid and retailer.

The Data:

```<code>import pandas as pd
import numpy as np
data = {"uid":{"0":"123","1":"345","2":"678","3":"123","4":"345","5":"123","6":"678","7":"369","8":"890","9":"678"},"retailer":{"0":"GUY","1":"GUY","2":"GUY","3":"GUY","4":"GUY","5":"GAL","6":"GUY","7":"GAL","8":"GAL","9":"GUY"},"upload date":{"0":"11/17/17","1":"11/17/17","2":"11/16/17","3":"11/16/17","4":"11/16/17","5":"11/17/17","6":"11/17/17","7":"11/17/17","8":"11/17/17","9":"11/15/17"},"price":{"0":12.00,"1":1.23, "2":34.00, "3":69.69, "4":13.72, "5":49.98, "6":98.02, "7":1.02,"8":98.23,"9":12.69}}
df = pd.DataFrame(data=data)
df = df[['uid','retailer','upload date','price']]
df['upload date']=pd.to_datetime(df['upload date'])
</code>```

Solution:

```<code>idx = df.groupby(['uid','retailer'])['upload date'].max().rename('upload date')
idx.reset_index(inplace=True)
solution = idx.merge(df, how='left', on=['uid','retailer','upload date'])
</code>```

Question:

I would like to be able to leverage indices to get to my solution. Either, I'd like to be able to use join, or find the max date of each pairing with a function that retains the indices of the original data frame.

JOIN ERROR:

```<code>idx.set_index(['uid','retailer','upload date']).join(df, on=['uid','retailer','upload date'])
</code>```

Returns:

```<code>ValueError: len(left_on) must equal the number of levels in the index of "right"
</code>```

答:
IIUC,idxmax

```<code>df.loc[df.groupby(['uid','retailer'])['upload date'].idxmax()]
Out[168]:
   uid retailer upload date  price
5  123      GAL  2017-11-17  49.98
0  123      GUY  2017-11-17  12.00
1  345      GUY  2017-11-17   1.23
7  369      GAL  2017-11-17   1.02
6  678      GUY  2017-11-17  98.02
8  890      GAL  2017-11-17  98.23
</code>```

Or reindex

```<code>df.reindex(df.groupby(['uid','retailer'])['upload date'].idxmax().values)
</code>```

If you want join the document stated :Join columns with other DataFrame either on index or on a key column

```<code>idx.set_index(['uid','retailer','upload date']).join(df.set_index(['uid','retailer','upload date']))
Out[175]:
                          price
uid retailer upload date
123 GAL      2017-11-17   49.98
    GUY      2017-11-17   12.00
345 GUY      2017-11-17    1.23
369 GAL      2017-11-17    1.02
678 GUY      2017-11-17   98.02
890 GAL      2017-11-17   98.23
</code>```

To get your expected output you need adding .reset_index() at the end

Or doing something like

```<code>idx.join(df.set_index(['uid','retailer','upload date']),on=['uid','retailer','upload date'])
Out[177]:
   uid retailer upload date  price
0  123      GAL  2017-11-17  49.98
1  123      GUY  2017-11-17  12.00
2  345      GUY  2017-11-17   1.23
3  369      GAL  2017-11-17   1.02
4  678      GUY  2017-11-17  98.02
5  890      GAL  2017-11-17  98.23
</code>```

Body:
The Problem:

I am looking to select only the most recent record of price within each pairing of uid and retailer.

The Data:

import pandas as pd
import numpy as np
data = {"uid":{"0":"123","1":"345","2":"678","3":"123","4":"345","5":"123","6":"678","7":"369","8":"890","9":"678"},"retailer":{"0":"GUY","1":"GUY","2":"GUY","3":"GUY","4":"GUY","5":"GAL","6":"GUY","7":"GAL","8":"GAL","9":"GUY"},"upload date":{"0":"11/17/17","1":"11/17/17","2":"11/16/17","3":"11/16/17","4":"11/16/17","5":"11/17/17","6":"11/17/17","7":"11/17/17","8":"11/17/17","9":"11/15/17"},"price":{"0":12.00,"1":1.23, "2":34.00, "3":69.69, "4":13.72, "5":49.98, "6":98.02, "7":1.02,"8":98.23,"9":12.69}}
df = pd.DataFrame(data=data)
df = df[['uid','retailer','upload date','price']]
df['upload date']=pd.to_datetime(df['upload date'])

Solution:

idx = df.groupby(['uid','retailer'])['upload date'].max().rename('upload date')
idx.reset_index(inplace=True)
solution = idx.merge(df, how='left', on=['uid','retailer','upload date'])

Question:

I would like to be able to leverage indices to get to my solution. Either, I'd like to be able to use join, or find the max date of each pairing with a function that retains the indices of the original data frame.

JOIN ERROR:

idx.set_index(['uid','retailer','upload date']).join(df, on=['uid','retailer','upload date'])

Returns:

ValueError: len(left_on) must equal the number of levels in the index of "right"

Body:
IIUC,idxmax

df.loc[df.groupby(['uid','retailer'])['upload date'].idxmax()]
Out[168]:
   uid retailer upload date  price
5  123      GAL  2017-11-17  49.98
0  123      GUY  2017-11-17  12.00
1  345      GUY  2017-11-17   1.23
7  369      GAL  2017-11-17   1.02
6  678      GUY  2017-11-17  98.02
8  890      GAL  2017-11-17  98.23

Or reindex

df.reindex(df.groupby(['uid','retailer'])['upload date'].idxmax().values)

If you want join the document stated :Join columns with other DataFrame either on index or on a key column

idx.set_index(['uid','retailer','upload date']).join(df.set_index(['uid','retailer','upload date']))
Out[175]:
                          price
uid retailer upload date
123 GAL      2017-11-17   49.98
    GUY      2017-11-17   12.00
345 GUY      2017-11-17    1.23
369 GAL      2017-11-17    1.02
678 GUY      2017-11-17   98.02
890 GAL      2017-11-17   98.23

To get your expected output you need adding .reset_index() at the end

Or doing something like

idx.join(df.set_index(['uid','retailer','upload date']),on=['uid','retailer','upload date'])
Out[177]:
   uid retailer upload date  price
0  123      GAL  2017-11-17  49.98
1  123      GUY  2017-11-17  12.00
2  345      GUY  2017-11-17   1.23
3  369      GAL  2017-11-17   1.02
4  678      GUY  2017-11-17  98.02
5  890      GAL  2017-11-17  98.23


问:
JQuery not filter
```<code>function() {
              $(this).animate({ width: 130 }, 300, function() { });
        });
</code>```

I wanna animate only those li's whose width is not 160

Thanks

答:
```<code>$('li').filter(function() { return $(this).width() != 160 }).animate({ width: 130 }, 300, function() { });
</code>```

For readability:

```<code>jQuery.expr[':'].width = function(e, ix, match) { return $(e).width() == match[3]; };
</code>```

You may then, at any point, do:

```<code>$('li:not(:width(160))').animate({ width: 130 }, 300, function() { });
</code>```

ContentLicense: CC BY-SA 2.5

Title: JQuery not filter

Body:
function() {
              $(this).animate({ width: 130 }, 300, function() { });
        });

I wanna animate only those li's whose width is not 160

Thanks

Body:
$('li').filter(function() { return $(this).width() != 160 }).animate({ width: 130 }, 300, function() { });

For readability:

jQuery.expr[':'].width = function(e, ix, match) { return $(e).width() == match[3]; };

You may then, at any point, do:

$('li:not(:width(160))').animate({ width: 130 }, 300, function() { });