text:
Q: Analogue of cyclic homology for e_n-algebras? Cyclic homology may be defined as the primitive part (with respect to a natural product) of the homology of the Lie algebra associated with the "stabilization" of an associative algebra $A$. Here the "stabilization" is the matrix algebra $Mat_n(A)$, where $n$ goes to infinity. This definition explains another name of cyclic homology - "additive K-theory".
I believe that there exists an analogous notion for $e_n$-algebras. For a $e_n$-algebra $A$ it must be the primitive part of the homology of the Lie algebra associated with a $e_n$-algebra, which is an appropriate "stabilization" of $A$.
Whether anyone has some ideas how this thing could be defined? What is the homology of the trivial algebra? Is it an additive version of something?

A: In the paper mentioned in the comments Francis defines a candidate for this. If $A$ is an $E_n$-algebra one has an equivalence of associative algebras $B = \int_{S^{n-1}} A \simeq (\int_{S^{n-1}} A)^{\rm op} = B^{\rm op}$. Thus, any left $B$-module has a canonical right $B$-module structure. Identifying $B$ with the $E_n$-enveloping algebra ${\rm Env}(A)$ this gives $A$ the natural structure of a left $\int_{S^{n-1}}A$-module structure. Letting $A^\tau$ be the induced right-module we can form
$$
A^\tau \otimes_{\int_{S^{n-1}} A} A
$$
which he calls the $E_n$-Hochschild homology of $A$. Using excision you can prove that $\int_{S^1} A = A \otimes_{A \otimes A^{\rm op}} A$, recovering classical Hochshild homology. Further if $A$ is commutative, or at least admits a $E_{n+1}$-refinement, then the above definition coincides with $\int_{S^n} A$.


text:
Q: How do I make my fixed sidebar scroll up as the footer comes up My problem is that the sidebar shouldn't be fixed once the footer enters the viewport.
I have found dozens of questions regarding the fixed sidebar, but the answers I found here are not solving my problem.
I found something similar here
but my problem is, I am not able to apply this solution as my HTML structure is different.
I would also prefer it if your answers were in pure js and not jquery

a {
  text-decoration: none;
  transition: all 0.3s;
  color: black;
  font-family: 'Montserrat', sans-serif;
  cursor: pointer;
}

ul,
ol {
  list-style: none;
  font-family: 'Montserrat', sans-serif;
}

.menu.container {
  padding: 1vw;
  font-family: 'Montserrat', sans-serif;
}

.menu ul li {
  display: inline-block;
  padding: 1vw;
}

.menu ul li a {
  padding: 1vw;
  font-size: 1.3vw;
}

.menu ul li a:hover {
  border-bottom: .2em solid black;
}

.title.container {
  width: 100%;
  position: fixed;
  top: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: #fff;
  /* border-top: 1px solid #cfab53; */
  border-bottom: 1px solid #cfab53;
  z-index: 2;
  /* margin-top: 2vw; */
  /* box-shadow: 0px 5px 5px 1px rgba(0,0,0,0.58);
    -webkit-box-shadow: 0px 5px 5px 1px rgba(0,0,0,0.58);
    -moz-box-shadow: 0px 5px 5px 1px rgba(0,0,0,0.58); */
}

.title .logo {
  padding: 1vw;
}

.title .logo h1 {
  font-family: 'GFS Didot', serif;
  color: #cfab53;
  font-size: 2.5vw;
  cursor: pointer;
}

.title .logo h3 {
  font-family: 'Dancing Script', cursive;
  /* color: #a1919e; */
  font-size: 1.3vw;
  font-weight: 400;
}

.sidebar.container {
  position: fixed;
  bottom: 0;
  left: 0;
  top: 6.7vw;
  width: 20%;
  z-index: 1;
  text-transform: uppercase;
  /* overflow-y: scroll; */
  padding: 1vw;
}

.sidebar .inner .categories * {
  padding: .5vw;
}

.sidebar .inner .categories h5 {
  font-size: 15px;
  font-weight: 400;
}

.sidebar .inner .categories p {
  font-size: 13px;
  text-indent: 1vw;
}

.sidebar .inner .categories h5 a:hover,
.sidebar .inner .categories p a:hover {
  color: #cfab53;
}

.main.container {
  /* right: 0;
    bottom: 0;
    left: 20%;
    top: 0vw;
    position: absolute; */
  width: 100%;
  padding: 1vw;
  z-index: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.main .category {
  padding-top: 6.7vw;
  width: 80%;
}

.main .category h2 {
  padding: 1vw;
}

.main .category hr {
  border: none;
  border-top: .1vw solid #cfab53;
  width: 50%;
  margin-left: 1vw;
  margin-bottom: 1vw;
}

.main .category .products {
  display: flex;
  flex-wrap: wrap;
}

.main .category .products .card {
  width: 30%;
  margin: 1vw;
  padding: 1vw;
  /* border: 1px solid #cfab53; */
  position: relative;
  min-height: 28vw;
}

.main .category .products .card .prodimg img {
  width: 100%;
  position: absolute;
  top: 0;
  left: 0;
  background-color: #cfab53;
  min-height: 20vw;
}

.main .category .products .card .prodimg img.primary {
  z-index: 1;
}

.main .category .products .card .prodimg:hover img.primary {
  display: none;
}

.main .category .products .card .desc {
  display: flex;
  justify-content: space-between;
  width: 100%;
  position: absolute;
  left: 0;
  bottom: 2vw;
}

.main .category .products .card .desc h3 a:hover {
  color: #cfab53;
}

.main .category .products .card .type {
  display: flex;
  width: 100%;
  position: absolute;
  left: 0;
  bottom: 0;
  align-items: center;
}

.main .category .products .card .type .border {
  border-radius: 10000px;
  border: 1px solid #bdbdbd;
  padding: 2px;
  margin-right: 5px;
}

.main .category .products .card .type .border .color {
  border-radius: 10000px;
  width: 13px;
  height: 13px;
  background-color: #cfab53;
}

.footer.container {
  /* position: absolute;
    bottom: 0;
    left: 0;
    right: 0; */
  width: 100%;
  border-top: 1px solid #cfab53;
  background-color: white;
}

.footer .top {
  display: flex;
  padding: 1vw;
  justify-content: space-between;
  align-items: flex-start;
}

.footer .top .column {
  width: 25%;
  padding: 1vw;
}

.footer .top .column h1 {
  font-size: 23px;
  letter-spacing: -2px;
  padding: .5vw;
}

.footer .top .column p {
  letter-spacing: -1px;
  font-size: 15px;
}

.footer .top .column a {
  letter-spacing: -1px;
  font-size: 15px;
}

.footer .top .column a:hover {
  color: #cfab53;
}

.footer .logo {
  padding: 1vw 2vw 0vw;
}

.footer .logo h1 {
  font-family: 'GFS Didot', serif;
  color: #cfab53;
  font-size: 35px;
  letter-spacing: normal;
  cursor: pointer;
}

.footer .top .site h3 {
  font-family: 'Dancing Script', cursive;
  font-size: 30px;
  font-weight: 400;
}

.footer .top .site p {
  font-size: 15px;
  padding: 1vw 0vw;
  font-weight: 600;
  letter-spacing: normal;
}

.footer .top .customer ul li {
  padding: .3vw .5vw;
}

.footer .top .customer ul li a {
  letter-spacing: -1px;
  font-size: 15px;
}

.footer .top .contact p,
.footer .top .contact a {
  padding: .3vw .5vw;
}

.footer .top .contact .email {
  display: flex;
  flex-direction: column;
}

.footer .top .sign p {
  padding: .5vw 0;
}

.footer .top .sign .input {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  border: 1px solid #cfab53;
  margin: 1vw 0vw;
}

.footer .top .sign .input .fa-envelope {
  color: #cfab53;
  padding: 0vw 0vw 0vw .5vw;
  width: 10%;
}

.footer .top .sign .input input {
  border: none;
  padding: 0vw .5vw;
  margin: 0vw 0vw 0vw 0vw;
  width: 80%;
}

.footer .top .sign .input i.fa-chevron-right {
  background-color: #cfab53;
  color: white;
  padding: 5px;
  width: 10%;
  text-align: center;
  cursor: pointer;
}

.footer .top .sign .input i.fa-chevron-right:hover {
  background-color: #bb9c4d;
}

.footer .bottom {
  display: flex;
  justify-content: flex-end;
  align-items: center;
}

.footer .socials {
  display: flex;
  justify-content: flex-end;
  align-items: center;
}

.footer .socials * {
  padding: .5vw;
  font-size: 12px;
  letter-spacing: -1px;
}

.footer .socials a:hover {
  color: #cfab53;
}

.footer .socials .icons i {
  font-size: 18px;
  font-weight: 700;
}

.footer .socials .icons i.fa-instagram:hover {
  color: #bc2a8d;
}

.footer .socials .icons i.fa-pinterest:hover {
  color: #bd081c;
}

.footer .socials .icons i.fa-twitter:hover {
  color: #1DA1F2;
}

κοσμήματα

kosmimata jewelry

Home

Shop

Blog

Bracelets + Anklets

Bracelets

Chain Bracelets

Cuffs And Bangles

Zodiac Bracelets

Men's Bracelets

Anklets

Wedding

Men's

Bracelets

Circle Bracelet

$120.00

14k Yellow Gold

Circle Bracelet

$120.00

14k Yellow Gold

Circle Bracelet

$120.00

14k Yellow Gold

Circle Bracelet

$120.00

14k Yellow Gold

Circle Bracelet

$120.00

14k Yellow Gold

Chain Bracelets

Circle Bracelet

$120.00

14k Yellow Gold

Circle Bracelet

$120.00

14k Yellow Gold

Circle Bracelet

$120.00

14k Yellow Gold

Circle Bracelet

$120.00

14k Yellow Gold

Circle Bracelet

$120.00

14k Yellow Gold

Cuffs And Bangles

Circle Bracelet

$120.00

14k Yellow Gold

Circle Bracelet

$120.00

14k Yellow Gold

Circle Bracelet

$120.00

14k Yellow Gold

Circle Bracelet

$120.00

14k Yellow Gold

Circle Bracelet

$120.00

14k Yellow Gold

κοσμήματα

Kosmimata jewelry

Accessorise yourself with the best there is

Customer Care

Shipping & Returns

Order Status

Payment Methods

Ring Sizer

Visit

1985 Bel Meadow Drive,

Los Angeles, California

90017

        info@kosmimata.com
        213-829-0743

Sign up to have insider info on new arrivals, early access and more.

        <input type="email" placeholder="Your Email">

      Terms and Conditions
      Privacy Policy
      Site Map

©Kosmimata Inc.

A: It looks like you are trying to have the sidebar follow the content until there's not enough space, then it locks in place. You could do this with JS, but it's far easier with CSS position:sticky;
Here's MDN's documentation
Sticky

The element is positioned according to the normal flow of the document, and then offset relative to its nearest scrolling ancestor and containing block (nearest block-level ancestor), including table-related elements, based on the values of top, right, bottom, and left. The offset does not affect the position of any other elements.

position: -webkit-sticky;
position: sticky;
top: 20px;

You will need to tweak the HTML so that the sidebar and main content are in the same container for this to work. There are also a few CSS changes that I made as well.
Try this:

.trueContainer {
  display:flex;
  align-items: flex-start;
  padding-top:6.7vw
}

a {
  text-decoration: none;
  transition: all 0.3s;
  color: black;
  font-family: 'Montserrat', sans-serif;
  cursor: pointer;
}

.sidebar.container {
  position: sticky;
  top:0;
  left:0;
  width: 20%;
  z-index: 1;
  text-transform: uppercase;
  /* overflow-y: scroll; */
  padding: 1vw;
}

.sidebar .inner .categories * {
  padding: .5vw;
}

.sidebar .inner .categories h5 {
  font-size: 15px;
  font-weight: 400;
}

.sidebar .inner .categories p {
  font-size: 13px;
  text-indent: 1vw;
}

.sidebar .inner .categories h5 a:hover,
.sidebar .inner .categories p a:hover {
  color: #cfab53;
}

.main.container {
  /* right: 0;
    bottom: 0;
    left: 20%;
    top: 0vw;
    position: absolute; */
  width: 80%;
  padding: 1vw;
  z-index: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.main .category {
  /* padding-top: 6.7vw; */
  width: 100%;
}

.main .category h2 {
  padding: 1vw;
}

.main .category hr {
  border: none;
  border-top: .1vw solid #cfab53;
  width: 50%;
  margin-left: 1vw;
  margin-bottom: 1vw;
}

.main .category .products {
  display: flex;
  flex-wrap: wrap;
}

.main .category .products .card {
  width: 30%;
  margin: 1vw;
  padding: 1vw;
  /* border: 1px solid #cfab53; */
  position: relative;
  min-height: 28vw;
}

.main .category .products .card .prodimg img {
  width: 100%;
  position: absolute;
  top: 0;
  left: 0;
  background-color: #cfab53;
  min-height: 20vw;
}

.main .category .products .card .prodimg img.primary {
  z-index: 1;
}

.main .category .products .card .prodimg:hover img.primary {
  display: none;
}

.main .category .products .card .desc {
  display: flex;
  justify-content: space-between;
  width: 100%;
  position: absolute;
  left: 0;
  bottom: 2vw;
}

.main .category .products .card .desc h3 a:hover {
  color: #cfab53;
}

.main .category .products .card .type {
  display: flex;
  width: 100%;
  position: absolute;
  left: 0;
  bottom: 0;
  align-items: center;
}

.main .category .products .card .type .border {
  border-radius: 10000px;
  border: 1px solid #bdbdbd;
  padding: 2px;
  margin-right: 5px;
}

.main .category .products .card .type .border .color {
  border-radius: 10000px;
  width: 13px;
  height: 13px;
  background-color: #cfab53;
}

.footer.container {
  /* position: absolute;
    bottom: 0;
    left: 0;
    right: 0; */
  width: 100%;
  border-top: 1px solid #cfab53;
  background-color: white;
}

.footer .top {
  display: flex;
  padding: 1vw;
  justify-content: space-between;
  align-items: flex-start;
}

.footer .top .column {
  width: 25%;
  padding: 1vw;
}

.footer .top .column h1 {
  font-size: 23px;
  letter-spacing: -2px;
  padding: .5vw;
}

.footer .top .column p {
  letter-spacing: -1px;
  font-size: 15px;
}

.footer .top .column a {
  letter-spacing: -1px;
  font-size: 15px;
}

.footer .top .column a:hover {
  color: #cfab53;
}

.footer .logo {
  padding: 1vw 2vw 0vw;
}

.footer .logo h1 {
  font-family: 'GFS Didot', serif;
  color: #cfab53;
  font-size: 35px;
  letter-spacing: normal;
  cursor: pointer;
}

.footer .top .site h3 {
  font-family: 'Dancing Script', cursive;
  font-size: 30px;
  font-weight: 400;
}

.footer .top .site p {
  font-size: 15px;
  padding: 1vw 0vw;
  font-weight: 600;
  letter-spacing: normal;
}

.footer .top .customer ul li {
  padding: .3vw .5vw;
}

.footer .top .customer ul li a {
  letter-spacing: -1px;
  font-size: 15px;
}

.footer .top .contact p,
.footer .top .contact a {
  padding: .3vw .5vw;
}

.footer .top .contact .email {
  display: flex;
  flex-direction: column;
}

.footer .top .sign p {
  padding: .5vw 0;
}

.footer .top .sign .input {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  border: 1px solid #cfab53;
  margin: 1vw 0vw;
}

.footer .top .sign .input .fa-envelope {
  color: #cfab53;
  padding: 0vw 0vw 0vw .5vw;
  width: 10%;
}

.footer .top .sign .input input {
  border: none;
  padding: 0vw .5vw;
  margin: 0vw 0vw 0vw 0vw;
  width: 80%;
}

.footer .top .sign .input i.fa-chevron-right {
  background-color: #cfab53;
  color: white;
  padding: 5px;
  width: 10%;
  text-align: center;
  cursor: pointer;
}

.footer .top .sign .input i.fa-chevron-right:hover {
  background-color: #bb9c4d;
}

.footer .bottom {
  display: flex;
  justify-content: flex-end;
  align-items: center;
}

.footer .socials {
  display: flex;
  justify-content: flex-end;
  align-items: center;
}

.footer .socials * {
  padding: .5vw;
  font-size: 12px;
  letter-spacing: -1px;
}

.footer .socials a:hover {
  color: #cfab53;
}

.footer .socials .icons i {
  font-size: 18px;
  font-weight: 700;
}

.footer .socials .icons i.fa-instagram:hover {
  color: #bc2a8d;
}

.footer .socials .icons i.fa-pinterest:hover {
  color: #bd081c;
}

.footer .socials .icons i.fa-twitter:hover {
  color: #1DA1F2;
}

Bracelets + Anklets

Bracelets

Chain Bracelets

Cuffs And Bangles

Zodiac Bracelets

Men's Bracelets

Anklets

Wedding

Men's

Bracelets

Circle Bracelet

$120.00

14k Yellow Gold

Circle Bracelet

$120.00

14k Yellow Gold

Circle Bracelet

$120.00

14k Yellow Gold

Circle Bracelet

$120.00

14k Yellow Gold

Circle Bracelet

$120.00

14k Yellow Gold

κοσμήματα

Kosmimata jewelry

Accessorise yourself with the best there is

Customer Care

Shipping & Returns

Order Status

Payment Methods

Ring Sizer

Visit

1985 Bel Meadow Drive,

Los Angeles, California

90017

        info@kosmimata.com
        213-829-0743

Sign up to have insider info on new arrivals, early access and more.

        <input type="email" placeholder="Your Email">

      Terms and Conditions
      Privacy Policy
      Site Map

©Kosmimata Inc.

A: You're going to want to move your sidebar into your main content. That way, you can use position: sticky; top: 0;. I added a few other styles to position your content. Is this what you're looking for?

:root {
  --nav-height: 150px;
}

html {
    scroll-behavior: smooth;
}

body {
  margin: 0;
}

nav {
  position: fixed;
  height: var(--nav-height);
  width: 100%;
  background: lightcoral;
  text-align: center;
  font-size: 40px;
  z-index: 1;
}

a {
  text-decoration: none;
  transition: all 0.3s;
  color: black;
  font-family: "Montserrat", sans-serif;
  cursor: pointer;
}

.sidebar.container {
  position: sticky;
  align-self: flex-start;
  width: 20%;
  top: var(--nav-height);
  z-index: 1;
  text-transform: uppercase;
  padding: 1vw;
}

.sidebar .inner .categories * {
  padding: 0.5vw;
}

.sidebar .inner .categories h5 {
  font-size: 15px;
  font-weight: 400;
}

.sidebar .inner .categories p {
  font-size: 13px;
  text-indent: 1vw;
}

.sidebar .inner .categories h5 a:hover,
.sidebar .inner .categories p a:hover {
  color: #cfab53;
}

.main.container {
  position: relative;
  width: 100%;
  padding: var(--nav-height) 1vw 1vw;
  z-index: 0;
  display: flex;
}

.main .category {
  padding-top: 6.7vw;
  width: 80%;
  align-self: center;
}

.main .category h2 {
  padding: 1vw;
}

.main .category hr {
  border: none;
  border-top: 0.1vw solid #cfab53;
  width: 50%;
  margin-left: 1vw;
  margin-bottom: 1vw;
}

.main .category .products {
  display: flex;
  flex-wrap: wrap;
}

.main .category .products .card {
  width: 30%;
  margin: 1vw;
  padding: 1vw;
  /* border: 1px solid #cfab53; */
  position: relative;
  min-height: 28vw;
}

.main .category .products .card .prodimg img {
  width: 100%;
  position: absolute;
  top: 0;
  left: 0;
  background-color: #cfab53;
  min-height: 20vw;
}

.main .category .products .card .prodimg img.primary {
  z-index: 1;
}

.main .category .products .card .prodimg:hover img.primary {
  display: none;
}

.main .category .products .card .desc {
  display: flex;
  justify-content: space-between;
  width: 100%;
  position: absolute;
  left: 0;
  bottom: 2vw;
}

.main .category .products .card .desc h3 a:hover {
  color: #cfab53;
}

.main .category .products .card .type {
  display: flex;
  width: 100%;
  position: absolute;
  left: 0;
  bottom: 0;
  align-items: center;
}

.main .category .products .card .type .border {
  border-radius: 10000px;
  border: 1px solid #bdbdbd;
  padding: 2px;
  margin-right: 5px;
}

.main .category .products .card .type .border .color {
  border-radius: 10000px;
  width: 13px;
  height: 13px;
  background-color: #cfab53;
}

.footer.container {
  /* position: absolute;
  bottom: 0;
  left: 0;
  right: 0; */
  width: 100%;
  border-top: 1px solid #cfab53;
  background-color: white;
}

.footer .top {
  display: flex;
  padding: 1vw;
  justify-content: space-between;
  align-items: flex-start;
}

.footer .top .column {
  width: 25%;
  padding: 1vw;
}

.footer .top .column h1 {
  font-size: 23px;
  letter-spacing: -2px;
  padding: 0.5vw;
}

.footer .top .column p {
  letter-spacing: -1px;
  font-size: 15px;
}

.footer .top .column a {
  letter-spacing: -1px;
  font-size: 15px;
}

.footer .top .column a:hover {
  color: #cfab53;
}

.footer .logo {
  padding: 1vw 2vw 0vw;
}

.footer .logo h1 {
  font-family: "GFS Didot", serif;
  color: #cfab53;
  font-size: 35px;
  letter-spacing: normal;
  cursor: pointer;
}

.footer .top .site h3 {
  font-family: "Dancing Script", cursive;
  font-size: 30px;
  font-weight: 400;
}

.footer .top .site p {
  font-size: 15px;
  padding: 1vw 0vw;
  font-weight: 600;
  letter-spacing: normal;
}

.footer .top .customer ul li {
  padding: 0.3vw 0.5vw;
}

.footer .top .customer ul li a {
  letter-spacing: -1px;
  font-size: 15px;
}

.footer .top .contact p,
.footer .top .contact a {
  padding: 0.3vw 0.5vw;
}

.footer .top .contact .email {
  display: flex;
  flex-direction: column;
}

.footer .top .sign p {
  padding: 0.5vw 0;
}

.footer .top .sign .input {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  border: 1px solid #cfab53;
  margin: 1vw 0vw;
}

.footer .top .sign .input .fa-envelope {
  color: #cfab53;
  padding: 0vw 0vw 0vw 0.5vw;
  width: 10%;
}

.footer .top .sign .input input {
  border: none;
  padding: 0vw 0.5vw;
  margin: 0vw 0vw 0vw 0vw;
  width: 80%;
}

.footer .top .sign .input i.fa-chevron-right {
  background-color: #cfab53;
  color: white;
  padding: 5px;
  width: 10%;
  text-align: center;
  cursor: pointer;
}

.footer .top .sign .input i.fa-chevron-right:hover {
  background-color: #bb9c4d;
}

.footer .bottom {
  display: flex;
  justify-content: flex-end;
  align-items: center;
}

.footer .socials {
  display: flex;
  justify-content: flex-end;
  align-items: center;
}

.footer .socials * {
  padding: 0.5vw;
  font-size: 12px;
  letter-spacing: -1px;
}

.footer .socials a:hover {
  color: #cfab53;
}

.footer .socials .icons i {
  font-size: 18px;
  font-weight: 700;
}

.footer .socials .icons i.fa-instagram:hover {
  color: #bc2a8d;
}

.footer .socials .icons i.fa-pinterest:hover {
  color: #bd081c;
}

.footer .socials .icons i.fa-twitter:hover {
  color: #1da1f2;
}
I AM YOUR TOP NAV

Bracelets + Anklets

Bracelets

Chain Bracelets

Cuffs And Bangles

Zodiac Bracelets

Men's Bracelets

Anklets

Wedding

Men's

Bracelets

Circle Bracelet

$120.00

14k Yellow Gold

Circle Bracelet

$120.00

14k Yellow Gold

Circle Bracelet

$120.00

14k Yellow Gold

Circle Bracelet

$120.00

14k Yellow Gold

Circle Bracelet

$120.00

14k Yellow Gold

κοσμήματα

Kosmimata jewelry

Accessorise yourself with the best there is

Customer Care

Shipping & Returns

Order Status

Payment Methods

Ring Sizer

Visit

1985 Bel Meadow Drive,

Los Angeles, California

90017

        info@kosmimata.com
        213-829-0743

Sign up to have insider info on new arrivals, early access and more.

        <input type="email" placeholder="Your Email">

      Terms and Conditions
      Privacy Policy
      Site Map

©Kosmimata Inc.

redpajama_set_name: RedPajamaStackExchange


text:
Q: Background color layer with pseudo css

 .product-item-info::after {
            background-color: #e3e3e3;
            content:" ";
           height:300px;
            width:300px;
        }

.product-item-info {
    height: 300px;
}

Is it possible to create a color background layer as pseudo element, what I try now and is not working
.product-item-info:after {
    background-color: #e3e3e3;
    content:"";
    height:300px;
    width:400px;
}

A: ::before and ::after are display: inline by default. You'll want to set display: block for your width and height properties to be applied:

.product-item-info::after {
    background-color: #e3e3e3;
    content:" ";
    height: 300px;
    width: 300px;
    display: block; /* this is what you need */
}

.product-item-info {
    height: 300px;
    background-color: red; /* for demonstration purposes */
}

A: Here is an example of what you are trying to do.
Also for pseudo elements you should use "::"

.product-item-info {
  width: 300px;
  height: 300px;
  border: 1px solid red;
  position: relative;
}
.product-item-info::before {
  background-color: lightgreen;
  content: " ";
  height: 150px;
  width: 150px;
  position: absolute;
  top: 0;
  left: 0;
}
.product-item-info::after {
  background-color: lightblue;
  content: " ";
  height: 150px;
  width: 150px;
  position: absolute;
  bottom: 0;
  right: 0;
}


text:
Q: Change the background colour and hide the radio buttons within a particular divs when a checkbox is inactive Here is a JSFIDDLE to my code.
Here, when the check box is unchecked I need to turn the back ground colour to white and hide the radio buttons.
Meanwhile when it is checked I want to show the background colour as the current one and show the radio buttons

         <input id="bonus-credit-checkbox" name="bonus-credit-checkbox" type="checkbox" value="" />
         Your bonus credits

             Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis

         I prefer for:

             <input checked id="newsletter-male" name="newsletter-gender" type="radio">
             Women

             <input id="newsletter-female" name="newsletter-gender" type="radio">
             Men

A: And my solution (fiddle):
HTML:

    ...

JS:
$('#bonus-credit-checkbox').on('change', function() {
    $('.newsletter-box').toggleClass('unchecked', !$(this).prop('checked'));
});

CSS:
.unchecked {
    background: #fff;
}

.unchecked span.newsletter-preference {
    display: none;
}

A: This does exactly what you want to do: http://jsfiddle.net/aMyLb/5/
$(function(){
$("#bonus-credit-checkbox").change(function(){
    if($(this).is(":checked")){
        $(".gender-radio").hide();
        $(".newsletter-box").css("background-color", "#fff");
    }
    else{
        $(".gender-radio").show();
        $(".newsletter-box").css("background-color", "#f6f2ef");
    }
});
});

A: Just for all the folks with jQuery... here comes an CSS-only solution:
#bonus-credit-checkbox:not(:checked) ~ .newsletter-preference{
    display:none;
}

only works in modern browsers, don't fulfills your background-color requirement and you have to change your html a little as seen in this fiddle - as such not a real answer to your question, just a proof of concept. :-)

A: CHECK OUT THIS SOLUTION.
WORKING DEMO
THIS IS WORKING. You need to make the background of the main div white by default. Also you have to make the radio button div "display:none;".
JQUERY
$(function(){
    $("#bonus-credit-checkbox").change(function(){
        if($(this).is(":checked")){
            $('.newsletter-preference').hide();
            $('div').css('background-color', '#fff');
        }
        else{
            $('.newsletter-preference').show();
            $('div').css('background-color', '#f6f2ef');
        }
    });
});


text:
Q: Why am I getting error "#let or #subject called without a block"? I wonder how to pass code to shared examples.
I have these specs (snipped)
let(:property) { subject.send(type) }

    context 'when one or both depending properties are not set' do
      shared_examples_for 'not set' do |init_proc|
        it "imperial.value returns nil" do
          init_proc.call
          expect(property.imperial.value).to eq(nil)
        end
        # 3 similar examples snipped
      end

      context "when neither is set" do
        include_examples 'not set', Proc.new { }
      end

      context "when #{type1.inspect} is not set" do
        include_examples 'not set',  # error in this line
          Proc.new { subject.send("#{type2}=", [100, :imperial]) }
      end

      context "when #{type2.inspect} is not set" do
        include_examples 'not set',
          Proc.new { subject.send("#{type1}=", [100, :imperial]) }
      end
    end

What is surprising me is the error I get:
RuntimeError:
   #let or #subject called without a block

I thought this would work. It's as if Proc.new calls subject right away, instead when I call init_proc.call. Is that what's going on?
If not, then what's causing the error?
PS. Question is not how to get this code to work. I got this code to work, I am only interested in explanation why I got the error before.


text:
Q: Displaying image and setContactTestBitMask is not the same I have the following code
static const CGFloat kPipeWidth=56;

(void)topObstacle {

    Obstacle *pipeTop = [Obstacle spriteNodeWithImageNamed:@"pipetop-1"];

    [pipeTop setCenterRect:CGRectMake(26.0/kPipeWidth, 26.0/kPipeWidth, 4.0/kPipeWidth, 4.0/kPipeWidth)];

    [pipeTop setYScale:pipeTopHeight/kPipeWidth];
    [pipeTop setPosition:CGPointMake(self.size.width+(pipeTop.size.width/2),
        self.size.height-(pipeTop.size.height/2))];
    [self addChild:pipeTop];

    pipeTop.physicsBody = [SKPhysicsBody bodyWithRectangleOfSize:pipeTop.size];
    [pipeTop.physicsBody setAffectedByGravity:NO];
    [pipeTop.physicsBody setDynamic:NO];

    [pipeTop.physicsBody setCategoryBitMask:kPipeCategory];
    [pipeTop.physicsBody setCollisionBitMask:kplayerCategory];
}

The pipe picture is displayed correctly, however the collision area is not correctly set up. What is wrong with my code!
Thanks for your help

A: There are a few things that could be causing this:

*

*I believe the yScale will scale the image down but not change the value when later used to set the physics body size.  (essentially the physics body = original image size)

*I do not see a contactBitMask which will allow you to check when your (flappy felipe or mario?) comes in contact with the pipe.
To fix this try:

*

*Draw a rectangle using the same variables you currently use and color it black.  This will show you where the physics body is being drawn.

*set them to have a contact event and then log their contact


text:
Q: how to use cloudera manager for monitor the components of CDH4 I have already install CDH4 without using cloudera manager. I wanted to use cloudera manager so that i can monitor the different components of CDH4. Please suggest me how to use the manager now.

A: I have recently had to undertake the same task of importing already installed and running clusters into new Cloudera Manager instances.
I would firstly suggest taking your time to read through as much documentation as possible to fully understand the processes and key components.
As a short answer, you need to manually import all your cluster configurations and assignments into Cloudera Manager so that they can be managed. A rough outline of the plan I used is below:

*

*Setup MySQL instance on NEW hardware (can use postgresql)

*Create Cloudera Manager user on all servers (must be sudo enabled)

*Setup ssh key access between cloudera-manager server and all other hosts

*

*Useful Docs below:
    - http://www.cloudera.com/content/cloudera-content/cloudera-docs/CM4Ent/latest/Cloudera-Manager-Installation-Guide/cmig_install_mysql.html
    - http://www.cloudera.com/content/cloudera-content/cloudera-docs/CM4Ent/latest/Cloudera-Manager-Installation-Guide/cmig_install_path_B.html

*Install Cloudera Manager and agent/daemon packages on Cloudera Manager server

*Shutdown all services using cluster and cluster services

*Save the namespace

*Backup Meta Data and Configuration files to MULTIPLE LOCATIONS

*Ensure the backup can be loaded by starting a single instance NN

*Install Cloudera Manager agent and daemon on all production servers

*Start the services on the Cloudera Manager server

*Access the Cloudera Manager interface

*Skip Setup Wizard

*Add all hosts to Cloudera Manager

*Create HDFS service - DO NOT start the service

*

*Check hosts assignments are correct

*Input all configuration file parameters and verify (this means each servers conf files need to be input manually)

*Run host inspector and configuration check

*Perform the above process for remaining services
I hope this provides a some assistance for you. If you have any other questions I will be happy to try and assist you as much as I can.
Regards,
James

A: I just recorded a webinar titled "Installing Cloudera Manager in < 30 mins" for Global Knowledge. Available at: http://www.globalknowledge.com/training/coursewebsem.asp?pageid=9&courseid=20221&catid=248&country=United+States (register in the upper right of page). In the video, I install CM on Ubuntu, set up the core components (Hadoop only), and then browse through some of the graphs for monitoring.


text:
Q: Trying to understand free body diagram Please consider the following image:

Now I'm just trying to understand how exactly this thing is rotated...I'm looking at it exactly like on the image of the car...So the normal force is slightly bent because of the angle, but the angle seems to be on the opposite side from where it should be, I'd think it would be the lower corner, not the upper.

A: Think of it this way: You have the standard $x$- and $y$-axes centered on the car. For a flat road, the positive $y$-axis points in the direction of the normal force. When we tip the road, you have to tip the axes as well. Since we tip the negative $x$-axis up $\beta$, that tips the positive $y$-axis to the right $\beta$. The normal force is making an angle with the positive $y$-axis as shown in the picture.


text:
Q: HTML Javascript and Java runtime communication My group has a project that is upposed to connect a web page to a databse. the webpage is written in html, css, and javascript, and the database is written in mysql. we know there are issues with accessing databases from javascript, so we built a driver class from java that is supposed to control communication between the two.
the problem is that we do not know how to connect javascript with java during runtime. the way it is built, the javascript simply needs to call a java function and get the results. is there any simple way to do this? perhaps a certain library? we have little to no knowledge of other similar tools (i.e. jsp, xml) and would like to stick to the languages listed above.

A: You can create a Java HTTP JSON server and then make a call to it from Javascript by using AJAX calls.
See here: Java simple HTTP JSON server

A: In order to provide easy access to java code(including static/dynamic web content) over HTTP interface you've to use one of the (servlet) containers - jetty, tomcat, spring-boot, etc.
In my opinion, since you've minimal experience developing/deploying java web applications jetty might be good option as it have good documentation to get started. Spring Boot is popular choice for Enterprise web development using Java - it might be more than you want to chew for the moment.
The Servlet(web) and JDBC(database) APIs what you will end up using on Java side.


text:
Q: Why Earth's axis is in this particular position with respect to the perihelion? Imagine viewing the Earth from some point in space over the North pole, and let's just assume Earth is at the perihelion of its orbit (for simplicity's sake, let's also ignore precession).
Take the plane $\pi$ which passes through the center of our planet, is orthogonal to the ecliptic and also containes the Earth's axis.
My question is: does this plane contain also the center of the Sun?
It seems that this should be the case but it's not at all obvious to me.

A: As far as I can tell it's just a coincidence.  Currently the solstice occurs on or around December 21, while the perihelion of Earth's orbit is on or around January 4.  However, both the direction of the Earth's pole and the location of the perihelion precess with time;  these are known as axial precession (aka precession of the equinoxes) and apsidal precession respectively.  The periods of these precessions are not the same;  Earth's axial precession has a period of about 26,000 years, while its apsidal precession has a period of about 112,000 years.  Over time, then, the perihelion moves around Earth's orbit relative to the seasons:

(Image from Wikipedia)
This cycle is an important contributor to cyclical variations in the Earth's climate, known as Milankovitch cycles.


text:
Q: Mock Non-existent Interface in PHP I am new to PHP unit testing and I need some clarity on how can we mock non-existent Interface. Basically, In my project, I want to test one protected method which is expecting two arguments one is Interface and another is a string.
I want to understand how can I pass Interface as an argument in a method. I tried to Mock the Interface but it's not working for me.
This is my main class

namespace App\Models;

class VerifyNs {
    protected function NsCheck(SomeInterface $url, string $domain) {
        $answer= dns_get_record($domain, DNS_NS);
        if (!empty($answer[0]['target']), ('example.com' == substr($answer[0]['target'], -11)) {
            $result = 'NS verification for @url passed., ['@url ' => $url ->getName()]';
            return $result
        }

        return 'failed;
    }

}

Here is the test case

class VerifyNsTest extends \PHPUnit\Framework\TestCase
{
    /**
     * To call protected method
     * @param $object
     * @param string $method
     * @param array $parameters
     * @return mixed
     * @throws \Exception
     */
    private function callMethod($object, string $method , array $parameters = [])
    {
        try {
            $className = get_class($object);
            $reflection = new \ReflectionClass($className);
        } catch (\ReflectionException $e) {
           throw new \Exception($e->getMessage());
        }

        $method = $reflection->getMethod($method);
        $method->setAccessible(true);

        return $method->invokeArgs($object, $parameters);
    }

    /**
    * Tests for verifying NS of the domain.
    *
    * @dataProvider providerTestNsCheck
    */
    public function testCheckNs($site, $url, $expected_result) {
        $site_name = $this->getMockBuilder(SomeInterface::class)
                          ->setMethods(['getName'])
                          ->getMock();

        $site_name->method('getName')->willReturn($site);

        $verifyNs = new \App\Models\VerifyNs();
        $this->assertEquals($expected_result, $this->callMethod($verifyNs, 'NsCheck', [ $site_name, $url]));
    }

    /**
     * Data provider for testCheckNs().
     *
     */
    public function providerTestNsCheck() {
        return [
        [
            'mysite',
            'example.com',
            'NS verification for mysite passed.',

        ],       [
            'google',
            'google.com',
            'failed.'
            ]
        ],
        ];
    }

}

After running this, it's giving me an error
TypeError: Argument 1 passed to App\Models\VerifyNs::NsCheck() must be an instance of App\Models\SomeInterface, instance of Mock_SomeInterface_1ee04960 given
Can someone please help here? Is it possible to mock non_existent Interface and pass it as an argument to the method?

A: I was able to resolve this issue using prophesize
$site = $this->prophesize(SomeInterface::class);
$object =$site->reveal()
then passing $object in the callMethod.


text:
Q: Check referential integrity in stored procedure I have a customer table and an order table in an sql server 2000 database.
I don't want an order to be in the order table with a customerID that doesn't exist in the customer table so I have put a foreign key constraint on customerID.
This all works fine but when writing a stored procedure that could possibly violate the constraint, is there a way to check whether the constraint will be violated and, if it will be, skip/rollback the query?
At the minute all that happens is the stored procedure returns an error that is displayed on my asp page and looks rather ugly + most users wont understand it.
I would like a more elegant way of handling the error if possible.
Thanks

A: You have two options:

*

*Add error handling to catch the ugly, error inspect it to see if it's a FK constraint violation and display this to the user. This is IMHO the better solution.

*Add code in the stored procedure like the following:

if exists (select null from customer where customerid=@customerId )
begin
  --The customer existed so insert order
end
else
begin
  --Do something to tell you code to display error message
end

With the second option you will want to watch your transactional consistency. For example what happens if a customer is deleted after your check is made.

A: You can inspect the data before attempting the operation, or you can attempt the operation and then check the errors after each statement, then ROLLBACK etc.
But you can handle it entirely within stored procedures and return appropriately to the caller according to your design.
Have a look at this article: http://www.sommarskog.se/error-handling-II.html
In SQL Server 2005, there is a possibility of using TRY/CATCH


text:
Q: Four divs positioning: 2 on sides, 2 in the middle I want to arrange 4 divs' position, 2 on sides and 2 in the middle.
like:
         |  div middle top  |
div left |                  | div right
         |  div middle down |

Using CSS, is there any way to achieve this?

A: Used to this
HTml

left

Right

Top Div

bottom div

Css
html,body{height:100%;}

.parent{overflow:hidden;
border:solid 1px red; margin:0 auto;width:600px;height:100%;}
.pull-left{
    width:25%;float:left;
}
.pull-right{width:25%;float:right;}
.centerDiv{margin:0 25%;position:relative; height:100%;}
.topDiv{position: absolute;top:0;left:0;right:0;}
.bottomDiv{position: absolute;bottom:0;left:0;right:0;}

Demo

A: Check it this, you can check live demo: http://cssdesk.com/2JEQA
HTML

CSS:
#left {
    float:left;
}

.wrapper{
   float:left;
}

#right {
    float:left;
}

A: This answer is the same as Rohit Azad answer, I just added height and background color so that you could see it clearly. If you want this I would be happy if you give the credit to him. :)
HTML

left

Right

Top Div

bottom div

CSS
html,body{height:100%;}

.parent{
overflow:hidden;
border:solid 1px red;
margin:0 auto;
width:600px;
height:100%;
}

.pull-left{
width:25%;
float:left;
background-color:red;
height:100%;
}

.pull-right{
width:25%;
float:right;
background-color:blue;
height:100%;
}

.centerDiv{
margin:0 25%;
position:relative;
height:100%;
}

.topDiv{
position: absolute;
top:0;left:0;
right:0;
background-color:yellow;
height:50%;
}

.bottomDiv{
position: absolute;
bottom:0;left:0;
right:0;
background-color:green;
height:50%;
}

JSFIDDLE


text:
Q: Do Transport Layer (TCP and UDP) reads/inspects IP headers (Source IP, Destination IP etc.)? We all know that a TCP socket is identified by a four tuple entry:
src ip,
dest ip,
src port
dest port
TCP does the job of Multiplexing and Demultiplexing the Data from/to differnt processes running on the host.
In case of Demultiplexing, Destination IP information is there only in IP Headers. How come Dest IP is read by Transport Layer (TCP)?
Plz explain I m very much confused?

A: What is called TCP in this context, is in reallity TCP/IP as in TCP over IP (UDP/IP is the same thing). In fact, [TC|UD]P and IP are extremly interwoven codewise in all major current socket implementations.
The socket itself works from the IP layer upward, thus it has the Destination IP info, only the socket protocol handler specialises this to TCP. So by calling
socket(PF_INET, SOCK_STREAM, IPPROTO_TCP)

(Or its equivalents in other languages) you will create an IP socket (first parameter), that uses TCP (3rd parameter). This implies, that the socket has the IP information as well as the TCP info,


text:
Q: Check combobox on inactive tabs in tabcontrol I need to be able to check the selecteditem of a combobox in a tab control whether the tab is selected or not.
Currently I'm doing it based off of if the combobox is visible or not but this only checks the ones for the selected tab.
Is there a way I could get the selecteditem of the combo boxes on the 'inactive' tabs?
Each tab has a tablelayoutpanel which contains the combo boxes in question, but as mentioned above the cbo.visible is only true for the currently selected tab.
Private Function checkAnswers(ByVal table As TableLayoutPanel, ByVal ResponseKey As String) As Boolean
    Dim allAnswered As Boolean = True
    Dim s As String = ""
    For Each c As Control In table.Controls

        If c.GetType() Is GetType(Label) Then
            Dim lbl As Label = CType(c, Label)
            s = lbl.Text
        End If

        If TypeOf c Is ComboBox Then
            Dim cbo As ComboBox = c
            If Responses(ResponseKey)(s) = "NotAnswered" And cbo.Visible = True Then 'Combobox is showing and isnt answered
                allAnswered = False
            End If
        End If
    Next
    Return allAnswered
End Function

--EDIT--
The method where checkAnswers is being called:
Private Sub SubmitAnswers(ByRef tab As TabPage, ByRef table As TableLayoutPanel, ByRef ResponseKey As String)

    Dim instAnswer As CaisseAnswerBU = New CaisseAnswerBU

    Dim allAnswered As Boolean = True

    If Not checkAnswers(table, ResponseKey) AndAlso isEndofQuestions = True Then
        allAnswered = False
        MessageBox.Show("You must give an answer for all of " & tab.Text & "'s questions", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
    ElseIf checkAnswers(table, ResponseKey) AndAlso isEndofQuestions = True Then

        counter = 0

        For Each t As TabPage In ApplicantTab.TabPages
            If Not hiddenPages.Contains(t) Then
                For Each de As DictionaryEntry In Responses(ResponseKey)

                    If Responses(ResponseKey).Count <> 0 Then
                        instAnswer.applicantID = appList(counter).applicantId
                        instAnswer.applicationID = instApplication.applicationId
                        For Each dict As DictionaryEntry In questionHash
                            If de.Key = dict.Value Then
                                instAnswer.questionID = dict.Key
                            End If
                        Next

                        If de.Value = "Yes" Then
                            instAnswer.answer = True
                        Else
                            instAnswer.answer = False
                        End If
                        instAnswer.Create()
                    End If

                Next
                counter += 1
            End If
        Next
    End If

End Sub


text:
Q: Can the Windows 10 download via Windows Update be interrupted? Can the Windows 10 download via Windows Update be interrupted? I have seen the Windows Update doing it's thing in the background for a few days now, and I do switch off / sleep my computer every day, as any normal person would. Do I have to let my computer run overnight with the automatic sleep settings turned off?

A: If you want to upgrade to Windows 10 I would advice you to get the Media Creation Tool which is provided by Microsoft. You can choose to Upgrade your Windows version from there and set which data should be kept.
This lets you download Windows 10 correctly and it shows a better status of the whole process. I have used it today to upgrade an older Laptop to Windows 10 and it took about 1,5 hours(it depends on your download speed of course). So you might want to give that a try.


text:
Q: can someone explain to me what I did wrong? I need help unscrambling this code. I am only allowed to use these specific lines of code, but I need to 'unscramble' it to make it work. To me, this code looks good but I don't seem to get it to work so I would like to find out why this is the case.
The assignment that I am trying to solve is as follows:

Read in the file using the csv reader and build a dictionary with the tree species as the key and a count of the number of times the tree appears. Use the "in" operator to see if a tree has been added, and if not set it to 1.
Print the dictionary with the counts at the end.

My code is as follows:
from BrowserFile import open as _
import csv
with open("treeinventory.csv", "r", newline='') as f:
    count = {}
    reader = csv.reader(f)
    for yard in reader:
        for tree in yard:
            if tree in count:
                count[tree] = 1
            else:
                count[tree] = count[tree] + 1
print(count)

I would love if someone can help me and also explain why this code is not able to work as it is, i am trying to learn and this would be very helpful!
thank you!

A: Generally, we don't solve "homework" problems on SO.  You should also try to ask specific questions.  Also put better titles on your questions.  And, as such, I always like to post This to help new question askers out.
Since I'm here: The answer to your assignment is that line 9 and line 11 are swapped.
This is because the logic seems to set that dict count with the key tree is being set to 1 if the key is in the dict, and add 1 to the value stored at count[tree] if it's not in the dict.  This will result in a KeyError exception to be thrown when the value is accessed to do this addition in the statement count[tree] + 1, because, there is no value there yet.
Of course, without the input file, I can't actually run the code to verify it, so please try this out for yourself and update your question with specific issues if any come up.


text:
Q: selecting clients with only one product in SQL database I have a table that has a primaryCustomerID and PositionCode columns.
The PriamryCustomerID contains the clients banking portfolio ID and the PositionCode contains the code of the banking products (WSO and PB).
I have to select clients with WSO PositionCode but there must not have PB code.
if select clients where PositionCode is WSO it excludes the PB clients but that doesn't mean that the clients do not have PB.
kindly assist.
Thanks

A: This will list all customer with a position code = 'WSO' that do not have also a line with position code = 'PB'. Should work both on sql-server and mySQL.
SELECT a.primaryCustomerID, a.PositionCode
from table a
where a.positionCode = 'WSO'
and not exists (select 1 from table b where b.primaryCustomerID = a.primaryCustomerID and b.positionCode = 'PB')

A: primaryCustomerID  - PositionCode
1   PB
1   WSO
2   WSO
3   PB
4   PB
4   WSO
Assuming this is your table and you are expecting the query to return Primary CustomerID - 2
Here is a sample query in mysql(assuming table name to be xyz), not an optimized query but returns result 2,
select * from xyz
where positionCode = 'WSO' and PrimaryCustomerID not in ( select PrimaryCustomerID from xyz
where positionCode = 'PB' )

A: You can use -
SELECT a.primaryCustomerID, a.PositionCode
FROM table a LEFT JOIN table b ON b.primaryCustomerID = a.primaryCustomerID
WHERE  b.positionCode = 'PB' and a.positionCode = 'WSO' and B.primaryCustomerID IS NULL


text:
Q: CUDA 9.1 installation error: does not have a version.txt file! Ensure you are installing to an existing toolkit directory I'm installing the run file version of CUDA 9.1 on a linux box which has CUDA 8.0 on it.
The file I'm installing is: cuda_9.1.85.1_linux.run
sudo cuda_9.1.85.1_linux.run

The download options were: Linux / x86_64 / Ubuntu / 16.04 (linux mint) / runfile (local) / Base Installer
The error I get is:
Installation directory '/usr/local/cuda-9.1' does not have a version.txt file!
Ensure you are installing to an existing toolkit directory.

This perplexes me because CUDA 9 is not installed, the whole point of running the installer is to install it.

A: You might be trying to install the "patch" instead of the main installer.

Is your file about 70 MB size instead of the more expected 1.7 GB size? If yes, then you are probably installing the "patch" first before the main installer.
I also tried installing the "patch" first and got an error and then I was confused. Then I realized I had the wrong filename and did an ls -alrth and got the filename for the larger 1.7 GB installer and tried that and now it is installing without the error message.
The files I downloaded were not clearly labeled to indicate what file was the installer and what was the main installer (the filenames are all cuda_${version}.run).

A: The answer here is that you need to first install the CUDA 9.1 package which I found in my distribution's package manager. Then, second, this installation, the CUDA 9.1 toolkit, is installed on top of that. There is a patch to install on top of the toolkit. Lastly, you will need to install cuDNN if you're installing this for deep learning.

A: @Trevor Boyd Smith is correct
u need to install "cuda_9.0.176_384.81_linux.run" first
Then run these patches in order
cuda_9.0.176.1_linux.run
cuda_9.0.176.2_linux.run
cuda_9.0.176.3_linux.run
cuda_9.0.176.4_linux.run


text:
Q: Convert hash into number I want to convert the names of a dataset into numbers. I have a dataset made with pandas that looks like this:

I want the user_id and business_id to be numbers. So that I can easily go to user 1 and business 1.
I don't know how to do this while still keeping the IDs identical. So I don't want the same business to have two different numbers. Does anyone know how I can do this easily? I know how to convert the IDs to numbers but I don't know how can I make sure that the same id keeps the same number.

A: Maybe you can try the use of dict, because a dict stores distinct keys only. For example:
df1=pd.DataFrame({'business_id':['fszudif-6','fszudif-6','fsfhdks'],
             'user_id':['sdf','sdf','ui5'],
             'col3':[100,200,300]})
dict1=dict(zip(df1['business_id'],df1['business_id'].apply(lambda
    x:hash(x))))
print (dict1)
df1['business_id']=df1['business_id'].apply(lambda x: dict1[x])
print (df1)

gives you a dictionary with only two keys, because the value 'fszudif-6' from column business_id is repeated.
{3071153201467878330: 'fszudif-6', 4676342635135106290: 'fsfhdks'}
           business_id user_id  col3
0  3071153201467878330     sdf   100
1  3071153201467878330     sdf   200
2  4676342635135106290     ui5   300

In the lambda function you can change hash(x) to any function you prefer to convert str to int, it is just an example.


text:
Q: Add custom field to CERTAIN cms pages I have found quite a number of tutorials for adding a field to the Magento CMS for any pages, but can this be done for just certain pages? E.g. for the homepage I would like to ask a number of different datapoints. I do not like the full WYSIWYG editor,

A: The Magento homepage has a unique "layout handle"  called: cms_index_index.
You can add "blocks" and templates based on the layout in: cms.xml
Let us know if you need further assistance
Update
For adding custom fields in the backend for a specific CMS page try this:

*

*Create and observer which detects which CMS page is being loaded in backend (the event you want to observe is: adminhtml_cms_page_edit_tab_content_prepare_form)

*If it is correct display custom field

You can see this article for more info:
http://www.atwix.com/magento/adding-custom-attribute-to-a-cms-page/


text:
Q: VBA : Increasingly Specific Tags Related to: Is tagging a question [excel-vba] preferable to tagging it [excel] [vba]?
I have notices that people are increasingly tagging questions access-vba, excel-vba and so forth. A lot of VBA works with all Office applications, so I think it would be better to only have a vba tag, which can be narrowed by the addition of the application tag, when required. Referring to the related question above, it seems that this may be a popular choice.
Is adding meta tags the best way to deal with this?
EDIT: Tag synonyms have been added at https://stackoverflow.com/tags/vba/synonyms, thanks to Lance Roberts.


text:
Q: spi 74hc595 Cascading atmega64 I have a problem with displaying 40 values displayed on the 7 segment (40 components 74hc595 cascade link.
enter image description here
I implement my program on arduino and it works well
Here is my code:
 static const byte Pattern[] = {
    B00010100, // 0
    B00111111, // 1
    B10011000, // 2
    B00011010, // 3
    B00110011, // 4
    B01010010, // 5
    B01010000, // 6
    B00011111, // 7
    B00010000, // 8
    B00010010, // 9
    B00010000}; // BLANK

byte HC595_DS_POS = 2;     //Data pin (DS) pin location

byte HC595_SH_CP_POS = 3;  //Shift Clock (SH_CP) pin location
byte HC595_ST_CP_POS = 4;  //Store Clock (ST_CP) pin location

void IE74595_Out(uint8_t *p, unsigned char n)
{
  unsigned char i, j;
  uint8_t b;

  digitalWrite(HC595_ST_CP_POS,0);
  digitalWrite(HC595_SH_CP_POS,0);

  for(j=0;j<n;j++)
  {
    b = Pattern[*(p+n-j-1)];    // Lay byte cao nhat truoc

    for(i=0;i<8;i++)
    {

      digitalWrite(HC595_SH_CP_POS,0);

      if(b & 0b00000001)
      {

       digitalWrite(HC595_DS_POS,1);

      }
      else
      {

        digitalWrite(HC595_DS_POS,0);

      }

      digitalWrite(HC595_SH_CP_POS,1);

      b=b>>1;  //Now bring next bit at MSB position

    }
  }

digitalWrite(HC595_ST_CP_POS,1);

}

void setup()
{
  // put your setup code here, to run once:
  pinMode(HC595_ST_CP_POS, OUTPUT);
  pinMode(HC595_SH_CP_POS, OUTPUT);
  pinMode(HC595_DS_POS, OUTPUT);

}

void loop() {

   uint8_t Data[40]={2,5,1,3,2,1,3,6,1,9,4,8,1,7,0,5,1,2,5,6,5,4,1,4,1,8,1,3,1,9,5,6,4,5,6,2,6,1,0,2};

          IE74595_Out(Data,40);

}

And then I remade another program on atmel studio and I load it via extrem burner and Usbasp in my card
Here is my code :
    #define F_CPU 8000000UL
#include <avr/io.h>
#include <util/delay.h>

static const uint8_t Pattern[] = {
    0b00010100, // 0
    0b00111111, // 1
    0b10011000, // 2
    0b00011010, // 3
    0b00110011, // 4
    0b01010010, // 5
    0b01010000, // 6
    0b00011111, // 7
    0b00010000, // 8
    0b00010010, // 9
        0b00010000}; // BLANK

#define output_low(port,pin) port &= ~(1<<pin)
#define output_high(port,pin) port |= (1<<pin)
#define set_input(portdir,pin) portdir &= ~(1<<pin)
#define set_output(portdir,pin) portdir |= (1<<pin)

#define HC595_DS_POS PC4    //Data pin (DS) pin location
#define HC595_SH_CP_POS PC5  //Shift Clock (SH_CP) pin location
#define HC595_ST_CP_POS PC6  //Store Clock (ST_CP) pin location

#define HC595_PORT   PORTC
#define HC595_DDR    DDRC

void IE74595_Out(uint8_t *p, unsigned char n)
{
    unsigned char i, j;
    uint8_t b;

    output_low(HC595_PORT,HC595_ST_CP_POS);
     output_low(HC595_PORT,HC595_SH_CP_POS);

    for(j=0;j<n;j++)
    {
        b = Pattern[*(p+n-j-1)];// Lay byte cao nhat truoc

        for(i=0;i<8;i++)
        {
            output_low(HC595_PORT,HC595_SH_CP_POS);

            if(b & 0b00000001)
            {

                output_high(HC595_PORT,HC595_DS_POS);

            }
            else
            {

                output_low(HC595_PORT,HC595_DS_POS);

            }

            output_high(HC595_PORT,HC595_SH_CP_POS);
            b=b>>1;

        }
    }

    output_high(HC595_PORT,HC595_ST_CP_POS);
}

int main(void)
{
     set_output(DDRC,HC595_DS_POS);
    set_output(DDRC,HC595_SH_CP_POS);
    set_output(DDRC,HC595_ST_CP_POS);

    uint8_t Data[40]={5,9,1,6,1,1,0,9,1,7,1,5,4,2,6,2,8,7,0,7,1,2,3,5,1,5,4,2,1,7,5,9,1,9,4,8,1,5,2,9};

 while (1)
 {

    IE74595_Out(Data,40);
        return 1;

 }

}

Here is my card
enter image description here
The display is not like that of the arduino
I only have the last value displayed
I have developed my electronic card in china.
Is the problem of the material ???
The only difference between the two programs is:
DigitalWrite () on arduino
And Output_High () or output_Low on atmel
Is the implementation of DigitalWrite == Output_high() or output_Low()  ????
Must i Write the last instruction Return 1; after the while ????
Thank's

A: The 10K pull-down resistor on the SS (Slave Select) is designed to keep the registers from clocking in bits while the main processor is booting, and the SS line might be "floating" and in an indeterminate state.
Here is the date sheet of 74hc595
The call to SPI.transfer() sends a byte to the register (a bit at a time) and then bringing the LATCH (otherwise known as SS or ST) line high causes the data to be transferred from the register's internal memory to the output pins.
Pin connections
Pin connections for Uno and similar:


text:
Q: VSCode syntax for keydown recognition I have a line of code that works great!
If e.Key = Key.Return Then
I'd like to also look for Control+Return, but cannot figure out the right combination for the Key.+Return Then
Please help.


text:
Q: unable to create new user in mysql I am trying to create a new user in mysql 5.6, but while executing the query i am getting an error. please help.
mysql> create user dsuser@'%' indentified by 'Passw0rd';

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near 'indentified by 'Passw0rd'' at line 1

A: CREATE USER 'dsuser'@'%' IDENTIFIED BY 'Passw0rd';

Don't forget the quotes around your username as well.

A: create user 'dsuser'@'%' indentified by 'Passw0rd';


text:
Q: Three.js - Keep an object's location static with respect to the camera I am wondering how I could keep an object's location static with regard to the camera.
I.e. I have two objects, one which I want to observe from multiple angles using the trackball camera and another one which should always remain static with regard to the current camera view.
E.g. overlaying a mesh (to be observed from multiple angles using the trackball camera) on an image (static position with regard to trackball camera).
Hope I explained my question alright.
Thanks for any advice :)
Currently I have:
object.position.copy( camera.position );
object.rotation.copy( camera.rotation );
object.updateMatrix();

EDIT
I figured it out:
object.position.copy( camera.position );
object.rotation.copy( camera.rotation );
object.updateMatrix();
object.translateZ( - 10 );

A: There are many different methods.
If you want to keep an object static in the camera's field of view:
 camera.lookAt(object);

Another method to copy all of an object's transforms onto the camera:
 //add camera as a child of object
 object.add(camera);


text:
Q: Is there a faster way of inserting N^2 items than using an N^2 Loop? You have a database where Many Foos have Many Bars, so:
Foo --< FooBar >-- Bar

You have 10 Foos and 10 Bars and need to associate every Foo with every Bar by inserting 100 records into FooBar
Is there a more efficient way to perform this other than the following N^2 Loop, or are we stuck with this?
def associate(foos, bars):
    for foo in foos:
        for bar in bars:
            # INSERT INTO foobar (foo_id, bar_id) VALUES (foo.id, bar.id)

A: You need to insert n^2 elements. There is no way to do this faster than in n^2. The only thing I can suggest is to use batch insert instead of individual inserts.

A: The only way you can get faster than O(n^2) is by not inserting n^2 elements. In your case, you could perhaps only store records where the two items are not related, if you expect to only have a few of these. In SQL, you could then form your queries to account for this, or in case of general usage, set up an updatable view to make such an inverted table act like normal.


text:
Q: react native navigation.navigate is not working in nested navigator //Here is my App.js file
import React, {Suspense} from 'react';
import {
  SafeAreaView,
  Text,
  View,
  Button,
  Image,
  TouchableOpacity,
} from 'react-native';
import {
  NavigationContainer,
  getFocusedRouteNameFromRoute,
} from '@react-navigation/native';
import {createStackNavigator} from '@react-navigation/stack';
import {createDrawerNavigator} from '@react-navigation/drawer';
import DrawerNavigator from './navigation/DrawerNavigator';
const SinginScreens = React.lazy(() => import('./screens/Login/SinginScreens'));
const Billing = React.lazy(() => import('./screens/Home/Billing'));

const Stack = createStackNavigator();
const Drawer = createDrawerNavigator();

const Loading = () => {
  return <SafeAreaView>{/* <Text>Loading</Text> */}</SafeAreaView>;
};

const Routes = ({navigation}) => {
  return (
    <NavigationContainer>
      <Stack.Navigator
      initialRouteName={'Main'}>
        <Stack.Screen
          name={'Main'}
          component={DrawerNavigator}
          options={{
            headerShown: false,
          }}
        />
<Stack.Screen
          name="Billing"
          component={Billing}
          options={{
            headerLeft: null,
            headerShown: false,
          }}
        />
        <Stack.Screen
          name="SinginScreen"
          component={SinginScreens}

          options={{
            headerShown: false,
            gestureEnabled: false,
          }}
        />

      </Stack.Navigator>
    </NavigationContainer>
  );
};

class App extends React.PureComponent {
  render() {
    return (
      <Suspense fallback={<Loading />}>
        <Routes />
      </Suspense>
    );
  }
}

export default App;

//Here is my stack navigator
import React from 'react';
import {createStackNavigator} from '@react-navigation/stack';
import {Button} from 'react-native';
import {NavigationContainer} from '@react-navigation/native';
const Dashboard = React.lazy(() => import('../screens/Home/Dashboard.js'));

const Splash = React.lazy(() => import('../screens/Login/Splash'));

import {AuthContext} from './context';
const Stack = createStackNavigator();

const StackNavigator = ({route, navigation}) => {
  return (
    // <NavigationContainer>
    <Stack.Navigator initialRouteName="Splash">
      <Stack.Screen
        name="Splash"
        component={Splash}
        options={{headerShown: false, gestureEnabled: false}}
      />
      <Stack.Screen
        name="Dashboard"
        component={Dashboard}
        options={{headerShown: false,}}
      />
    </Stack.Navigator>
  );
};

export default StackNavigator;

//Here is my drawer navigator
import React, {useState,useEffect} from 'react';
import {
  createDrawerNavigator,
  DrawerContentScrollView,
  DrawerItemList,
  DrawerItem,
} from '@react-navigation/drawer';
import {
  SafeAreaView,
  Text,
  View,
  Button,
  Image,
  TouchableOpacity,
  StyleSheet,

} from 'react-native';
import {DrawerActions} from '@react-navigation/native';
import StackNavigator from './StackNavigator';
import { useNavigation } from '@react-navigation/native';

const Drawer = createDrawerNavigator()

const CustomDrawer = props => {
  return (
    <View style={{flex: 1}}>
      <DrawerContentScrollView {...props}>
        <DrawerItemList {...props} />
        <DrawerItem
          {...props}
          label="Contacts"
          labelStyle={styles.itemStyle}
          icon={(focused, size, color) => (
            <Image
              style={{width: 25, height: 25}}
              source={require('../assets/images/ic_contacts1.png')}
              resizeMode="contain"
            />
          )}
          onPress={() => {
            props.navigation.closeDrawer();

          }}
        />

<DrawerItem
          {...props}
          label="POS Catalog"
          labelStyle={styles.itemStyle}
          icon={(focused, size, color) => (
            <Image
              style={{width: 25, height: 25}}
              source={require('../assets/images/catalog.png')}
              resizeMode="contain"
            />
          )}
          onPress={() => {
            props.navigation.closeDrawer();

          }}
        />

      </DrawerContentScrollView>
    </View>
  );
};

const DrawerNavigator = () => {
  return (
    <Drawer.Navigator
    drawerContent={props => <CustomDrawer {...props} />}
    screenOptions={{
        drawerPosition: 'right',
        // drawerType:"permanent",
        headerTintColor: '#000000',
        headerTitleStyle: {
          fontWeight: 'bold', //Set Header text style
        },
      }}>

    <Drawer.Screen
    name="Home"
    component={StackNavigator}

     options={{
      drawerIcon: ({focused, size}) => (
        <Ionicons name="ios-home-outline" size={size} color={'#000'} />
      ),
      headerStyle: {
        backgroundColor: 'white',
      },
      headerShown: false,
      headerTintColor: 'black',
    }}/>
    </Drawer.Navigator>
  );
};

export default DrawerNavigator;

I have drawer and stack navigator in my react native application.I have Screens called Splash,SigninScreen,Billing and Dashboard.
Screens in navigator
Splash,Dashboard- Stack Navigator
SigninScreen,Billing-App.js file(mentioned these screens out of drawer navigator to remove drawer for these screens)
What i want to achieve is when app is opening splash screen comes first and from splashscreen i am navigating to signinscreen using navigation.replace('SinginScreen') to avaoid back navigating to splash screen again when user clicks back button in 'SigninScreen'.
Similarly i am using navigation.replace('Billing') when navigating from SigninScreen to Billing to avoid back navigating to SigninScreen again when user clicks back button in Billing.
Now Inside Billing i am using navigation.navigate('Dashboard') to navigate from Billing to Dashboard page.Here i am facing error like The action 'NAVIGATE' with payload {"name":"Dashboard"} was not handled by any navigator.
Do you have a screen named 'Dashboard'?
Note:
I want to navigate to Dashboard page from Billing and also i don't want the user to go back again billing from Dashboard.


text:
Q: 32 bit systems logical address In a 32 bit system a logical address is divided as |10|10|12|, page directory offset, page table offset and page offset.
Since a page in x86 systems is 4KBytes, and to represent 4K entries, log2(4K) = 12 bits are required, hence the 12.
So the number of bits remaining = (32-12) = 20.
Assuming my understanding is right so far, my question is where did the 10 and 10 come from?
Why is not 8 and 12 or something else?

A: Uniformity here allows for smaller and simpler code (and hardware likely as well).
If you look closely at the formats of the page directory and page table entries, you'll notice that they are almost identical on the x86.
Now, if you make one of PDEs point back at the PD, accessing all PDEs and PTEs becomes trivial. I don't know if this thing was planned in the days when the i80386 was being designed or not, but it certainly comes in handy.


text:
Q: Should I use floating point's NaN, or floating point + bool for a data set that contains invalid values? I have a large amount of data to process with math intensive operations on each data set. Much of it is analogous to image processing. However, since this data is read directly from a physical device, many of the pixel values can be invalid.
This makes NaN's property of representing values that are not a number and spreading on arithmetic operations very compelling. However, it also seems to require turning off some optimizations such as gcc's -ffast-math, plus we need to be cross platform. Our current design uses a simple struct that contains a float value and a bool indicating validity.
While it seems NaN was designed with this use in mind,
others think it is more trouble than it is worth. Does anyone have advice based on their more intimate experience with IEEE754 with performance in mind?

A: If invalid data is very common, you are of course wasting a lot of time on running this data through the processing. If the invalid data is common enough it is probably better to be running some kind of sparse datastructure of only the valid data. If it is not very common, you can of course keep a sparse datastructure of which data is invalid. That way you would not waste a bool for each value. But maybe memory is not a problem for you...
If you are doing operations such as multipling two possibly invalid data entries, I understand it is compelling to use NaNs instead of doing checks on both variables to see if they are valid and setting the same flag in the resultant.
How portable do you need to be? Will you ever need to be able to port it to an architecture with only fixed point support? If that is the case, I think your choice is clear.
Personally I would only use NaNs if it proved to be much faster. Otherwise I'd say the code gets more clear if you have explicit handling of invalid data.

A: Since the floating-point numbers come from a device, they probably have a limited range. You can use some other special number, rather than NaN, to indicate absense of data, e.g. 1e37. This solution is portable. I do not know whether or not is more convinient for you than using a bool flag.

A: BRIEF: For strictest portability, don't use NaNs. Use a separate valid bit.  E.g. a template like Valid.  However, if you know that you will only ever run on IEEE 754-2008 machines, and not IEEE 754-1985 (see below), then you may get away with it.
For performance, it is probably faster not to use NaNs on most of the machines that you have access to.  However, I have been involved with hardware design of FP on several machines that are improving NaN handling performance, so there is a trend to make NaNs faster, and, in particular, signalling NaNs should soon be faster than Valid.
DETAIL:
Not all floating point formats have NaNs. Not all systems use IEEE floating point. IBM hex floating point can still be found on some machines - actually systems, since IBM now supports IEEE FP on more recent machines.
Furthermore, IEEE Floating Point itself had compatibility issues wrt NaNs, in IEEE 754-1985.  E.g, see wikipedia http://en.wikipedia.org/wiki/NaN:

The original IEEE 754 standard from 1985 (IEEE 754-1985) only
  described binary floating point formats, and did not specify how the
  signaled/quiet state was to be tagged. In practice, the most
  significant bit of the significand determined whether a NaN is
  signalling or quiet. Two different implementations, with reversed
  meanings, resulted.
  * most processors (including those of the Intel/AMD x86-32/x86-64 family, the Motorola 68000 family, the AIM PowerPC family, the ARM
  family, and the Sun SPARC family) set the signaled/quiet bit to
  non-zero if the NaN is quiet, and to zero if the NaN is signaling.
  Thus, on these processors, the bit represents an 'is_quiet' flag.
  * in NaNs generated by the PA-RISC and MIPS processors, the signaled/quiet bit is zero if the NaN is quiet, and non-zero if the
  NaN is signaling. Thus, on these processors, the bit represents an
  'is_signaling' flag.

This, if your code may run on older HP machines, or current MIPS machines (which are ubiquitous in embedded systems), you should not depend on a fixed encoding of NaN, but should have a machine dependent #ifdef for your special NaNs.
IEEE 754-2008 standardizes NaN encodings, so this is getting better.  It depends on your market.
As for performance: many machines essentially trap, or otherwise take a major hiccup in performance, when performing computations involving both SNaNs (which must trap) and QNaNs (which don't need to trap, i.e. which could be fast - and which are getting faster in some machines as we speak.)
I can say with confidence that on older machines, particularly older Intel machines, you did NOT want to use NaNs if you cared about performance.  E.g. http://www.cygnus-software.com/papers/x86andinfinity.html says "The Intel Pentium 4 handles infinities, NANs, and denormals very badly. ... If you write code that adds floating point numbers at the rate of one per clock cycle, and then throw infinities at it as input, the performance drops. A lot. A huge amount. ... NANs are even slower. Addition with NANs takes about 930 cycles. ... Denormals are a bit trickier to measure."
Get the picture? Almost 1000x slower to use a NaN than to do a normal floating point operation?  In this case it is almost guaranteed that using a template like Valid will be faster.
However, see the reference to "Pentium 4"? That's a really old web page. For years people like me have been saying "QNaNs should be faster", and it has slowly taken hold.
More recently (2009), Microsoft says http://connect.microsoft.com/VisualStudio/feedback/details/498934/big-performance-penalty-for-checking-for-nans-or-infinity "If you do math on arrays of double that contain large numbers of NaN's or Infinities, there is an order of magnitude performance penalty."
If I feel impelled, I may go and run a microbenchmark on some machines.  But you should get the picture.
This should be changing because it is not that hard to make QNaNs fast.  But it has always been a chicken and egg problem: hardware guys like those I work with say "Nobody uses NaNs, so we won;t make them fast", while software guys don't use NaNs because they are slow.  Still, the tide is slowly changing.
Heck, if you are using gcc and want best performance, you turn on optimizations like "-ffinite-math-only ... Allow optimizations for floating-point arithmetic that assume that arguments and results are not NaNs or +-Infs."  Similar is true for most compilers.
By the way, you can google like I did, "NaN performance floating point" and check refs out yourself.  And/or run your own microbenchmarks.
Finally, I have been assuming that you are using a template like
template<typename T> class Valid {
    ...
    bool valid;
    T value;
    ...
};

I like templates like this, because they can bring "validity tracking" not just to FP, but also to integer (Valid), etc.
But, they can have a big cost. The operations are probably not much more expensive than NaN handling on old machines, but the data density can be really poor.  sizeof(Valid) may sometimes be 2*sizeof(float).  This bad density may hurt performance much more than the operations involved.
By the way, you should consider template specialization, so that Valid uses NaNs if they arte available and fast, and a valid bit otherwise.
template <> class Valid<float> {
    float value;
    bool is_valid() {
        return value != my_special_NaN;
    }
}

etc.
Anyway, you are better off having as few valid bits as possible, and packing them elsewhere, rather than Valid right close to the value.  E.g.
struct Point { float x, y, z; };
Valid<Point> pt;

is better (density wise) than
struct Point_with_Valid_Coords { Valid<float> x, y, z; };

unless you are using NaNs - or some other special encoding.
And
struct Point_with_Valid_Coords { float x, y, z; bool valid_x, valid_y, valid_z };

is in between - but then you have to do all the code yourself.
BTW, I have been assuming you are using C++.  If FORTRAN or Java ...
BOTTOM LINE:  separate valid bits is probably faster and more portable.
But NaN handling is speeding up, and one day soon will be good enough
By the way, my preference: create a Valid template.  Then you can use it for all data types.  Specialize it for NaNs if it helps.  Although my life is making things faster, IMHO it is usually more important to make the code clean.


text:
Q: How to wrap an HtmlElement in an HtmlDocument Is it possible to wrap an HtmlElement with another HtmlElement? And if so, how?
Lets say, I have this HTML, and I want to wrap the img with an additional div:

  <title>foo</title>

Hello World

I've tried using following snippet (n.b. document element is an HtmlDocument):
$htmlFile = New-Object -ComObject "HTMLFile"
$htmlFile.IHtmlDocument2_write((gc -Path "./html.htm" -Raw))
$htmlFile.documentElement.getElementsByTagName("img") | %{
  $div = $htmlFile.createElement("div")
  $div.className += "nonbreakingImage"
  $void = $div.appendChild($_)
  $_.OuterHtml = $div.OuterHtml
}

But this, unfortunately, just removes the image tag:

Hello World

Another Idea was, to do something like this:
$htmlFile = New-Object -ComObject "HTMLFile"
$htmlFile.IHtmlDocument2_write((gc -Path "./html.htm" -Raw))
$htmlFile.documentElement.getElementsByTagName("img") | %{
  $parent = $_.parentNode
  $void = $parent.removeChild($_)
  $div = $parent.appendChild($htmlFile.createElement("div"))
  $div.className += " nonbreakingImage"
  $void = $div.appendChild($_)
}

But that leaves me with a wrong child order:

Hello World

Any ideas and hints are welcome!

A: You can replace  node with a
 node then add (now floating)  node to newly added
. In code:
$htmlFile.documentElement.getElementsByTagName("img") | %{
  $div = $htmlFile.createElement("div")
  $div.className += " nonbreakingImage"

  $_.parentNode.replaceChild($div, $_)
  $div.appendChild($_)
}

In alternative you may $_.insertBefore($div, ...) of node obtained by $_.previousSibling(...) but it's longer.


text:
Q: Is clEnqueueNDRangeKernel ever synchronous? The following code does not use any callbacks or clWaitForEvents and yet it works perfectly. But I thought clEnqueueNDRangeKernel was non-blocking.
void CL::executeApp1()
{
    cl_int status = 0;
    const int d1Size = 1024000;
    int* myInt = new int[d1Size];

    cl_mem mem1 = clCreateBuffer(context, 0, sizeof(int)*d1Size, NULL, &status);
    status = clEnqueueWriteBuffer(queue, mem1, CL_TRUE, 0, sizeof(int)*d1Size, myInt, 0, NULL, NULL);
    status = clSetKernelArg(kernel, 0, sizeof(cl_mem), &mem1);

    size_t global[] = {d1Size};
    cl_event execute;
    status = clEnqueueNDRangeKernel(queue, kernel, 1, NULL, global, NULL, 0, NULL, &execute);
    //clWaitForEvents(1, &execute);
    status = clEnqueueReadBuffer(queue, mem1, CL_FALSE, 0, sizeof(int)*d1Size, myInt, 0, NULL, NULL);

    string s = "";
    for(int i = 0; i < d1Size; i++)
    {
        s += to_string(myInt[i]);
        s += " ";
    }

    result = (char*)malloc(sizeof(char)*s.length());
    strcpy(result, s.c_str());
}

A: Thats true is non-blocking.
However you only have 1 queue, and it is probably not set as OUT_OF_ORDER_QUEUE. So, it will run everything in order.
First the write, then the kernel, and finally the read.
If you don't use two queues for IO and execution, the only call that needs to be blocking is the readBuffer().


text:
Q: Django: filter() on multiple instances of related models My model is as following: I have set of Dudes, and each Dude has a set of preferences. I can easily find Dudes based on their single preference, but I need to find those preferring two different things. I tried to pass two Q objects to filter() function, but in generated SQL those two Q object refer to the same related Preference. I want them to refer to two different Preferences. To make matters worse, I need to query several attributes of related model (=Preference), so I cannot use simple __in.
Model:
class Dude(models.Model):
    name = models.CharField(max_length=200)

class Preference(models.Model):
    name =     models.CharField(max_length=200)
    how_much = models.CharField(max_length=200)
    dude =     models.ForeignKey(Dude)

Test Case:
class DudesTestCase(TestCase):
    def setUp(self):
        dude = Dude.objects.create(name = 'Dude')
        cheese = Preference.objects.create(name = 'Cheese', how_much = "very", dude = dude)
        bacon = Preference.objects.create(name = 'Bacon', how_much = "absolutely_love", dude = dude)

    # does work
    def test_cheese_lovers(self):
        d = Dude.objects.filter(preference__name = 'Cheese', how_much = "very")
        self.assertEquals(d[0].name, 'Dude')

    # does not work - wants a single Preference to be both cheese and bacon
    def test_cheese_and_bacon_lovers(self):
        d = Dude.objects.filter(
                Q(preference__name = 'Cheese', how_much = "very"),
                Q(preference__name = 'Bacon', how_much = "absolutely_love"),
        )
        self.assertEquals(d[0].name, 'Dude')

Clarification:
I don't want to find dudes liking either cheese or bacon, I need folks satisfying both conditions at the same time.

A: I think this should work
def test_cheese_and_bacon_lovers(self):
    d = Dude.objects.filter(
        preference__name='Cheese',
        how_much__in=("very", "absolutely_love"),
    ).filter(
        preference__name='Bacon',
        how_much__in=("very", "absolutely_love"),
    )
    self.assertEquals(d[0].name, 'Dude')

This usage is described in the docs here:
https://docs.djangoproject.com/en/1.8/topics/db/queries/#spanning-multi-valued-relationships

A: Add related name to model:
class Preference(models.Model):
    name = models.CharField(max_length=200)
    dude = models.ForeignKey(Dude, related_name='preferences')

And use IN and annotate:
Dude.objects.filter(preferences__name__in=['Cheese', 'Bacon']) \
  .annotate(cnt=Count('preferences__name') \
  .filter(cnt=2)


text:
Q: type checking for conditional expression In the following code:
main() {
   print('Starting....');
   int x = 10;
   int y = x > 3 ? 'aaa' : 7;
   print(y);
}

This is the output:
Starting....
Unhandled exception:
type 'String' is not a subtype of type 'int'
#0      main (file:///tmp/main.dart:4:12)
#1      _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:301:19)
#2      _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:168:12)

why isn't there a compile time error on the assignment to y? Why only runtime error?
version: Dart VM version: 2.8.4 (stable) (Unknown timestamp) on "linux_x64"
Thanks!

A: The reason is that Dart does still try to make implicit type casts as default behavior. So in this case, Dart will automatically assume you can cast the String into a int. This behavior can be disabled and will also be disabled by default when non-nullable types are supported:
https://dart.dev/guides/language/analysis-options#enabling-additional-type-checks
You can add the following to analysis_options.yaml (I do also recommend to add implicit-dynamic: false but this is not necessary for this specific issue):
analyzer:
  strong-mode:
    implicit-casts: false

And you will then get an error from the analyzer:
Analyzing bin/stackoverflow.dart...
  error • A value of type 'Object' can't be assigned to a variable of type 'int'. • bin/stackoverflow.dart:4:11 • invalid_assignment
1 error found.

The reason why the error are saying Object is because Dart has analyzed x > 3 ? 'aaa' : 7 into the return type of Object since that is the only thing in common for int and String.

A: You are trying to parse the string 'aaa' in a type called int. 'aaa' is not a number so error.
String y = x > 3 ? 'aaa' : '7';

or do:
int y = x > 3 ? 2 : 7;


text:
Q: How to round 0.4999... ? Is it 0 or 1? If you want to round the repeating decimal 0.4999... to a whole number what is the right answer? Is it 0 or 1?
On the one hand you only look at the first digit when you round numbers which in this case is 4 so the answer should be 0.
On the other hand 0.4999... is only another representation for 0.5 which makes the result 1.
My question
Which of these rules wins? (My gut feeling is that the most consistent result should be 1)
Edit
Just for clarification: What is meant by rounding here is replacing a fractional decimal number by one with fewer digits with the "Round half up"-Tie-breaking method.

A: You're right. Since $.4\bar{9}=.5,$ if you want your rounding function to be well-defined you'll have to require an exception: round based on the first digit after the one you're rounding to, unless it's a $4$ followed by infinitely many $9$s.

A: It is not obvious that 0.5 should be rounded to 1.  Obviously 0.49999... should be treated the same because it is the same number.
Wikipedia rounding article

A: I find very convenient to define rounding as follows: $$ round(x) = \left \lfloor  x + \frac{1}{2}\right \rfloor$$
Considering this rule, what follows is understanding the context. If you are working with a computer, you have only a fixed number of decimal positions to work with, in which case, if x=0.4999999999999999 (16 decimal positions), then
round(x)=floor(0.4999999999999999 + 0.5)=
        =floor(0.9999999999999999)=
        =0

Of course, if you are talking about a real number, then 0.4999... equals 0.5, in which case $round(x)=1$.
So, the real question here is: are you working with a fixed number of decimal positions or not? If the answer is 'yes', then definitely round(x)=0. If the answer is 'no', then you are talking about a number which is equal to 0.5, and $round(x)=1$

A: $1 - 0.5 =0.5 \quad$  and $\quad 1 - 0.4999\ldots = 0.500\ldots = 0.5 \quad$ so  $\quad 0.5 = 0.4\overline9 $
Well, the above line says the proof / intuition. From our information... $0.5$ well rounds to $1$.

A: @fgp answered this well but there is another aspect that I don't think has been touched on in any of the answers.  What is the type of thing that we should consider as an input to the process of rounding?  If it is a real number, we are unable to apply the rule without a specific digit sequence representing that number.  If instead we interpret rounding as an operation on a possibly infinite digit sequence, we can now apply the rule, but its result has no meaning for general real numbers.  One way out which has been discussed is to make a bijection between digit sequences and reals by disallowing digit sequences ending in $999...$, and this view effectively unasks the question by taking the position that $0.4999...$ is not a valid representation of a real number, but I think this is an overly burdensome technicality.
I think an easier way to look at it is just to say that rounding is an operation that applies to finite digit sequences and not to real numbers in general nor to infinite digit sequences.  When we say something like "$\pi$ rounds down to $3$" it is a lazy way of saying that all sufficiently precise approximations do.  But when we say "$0.5$ rounds up to $1$", exactly that is meant, because we don't mean to suggest that $0.4 + \sum_{k=2}^{n}{9 \cdot 10^{-k}}$ will round up to $1$ for sufficiently large $n$.  And without context, if it is said about a real number $x$ that "$x$ rounds up to $1$" then that can be read as "$x$ has a finite decimal representation which rounds up to $1$, or $x$ has no finite decimal representation and all sufficiently precise finite decimal approximations to $x$ round up to $1$".  In this way we can meaningfully discuss rounding real numbers in terms of rounding finite digit sequences, and without explicitly addressing the problem of sequences ending in $999...$.

A: It's $1$, because $0.49\ldots$ is the same as $0.5$. If rounding is to be well-defined, it can't map one real number to two integers, so whatever it maps $0.49\ldots$ to, it better maps it to the same integer as $0.5$. You could round both to $0$, of course, but that wouldn't then be the way we usually round.
What this shows you is that rounding doesn't commute with limits, i.e. there's a difference between find the limit of a sequence and then rounding, and rounding first and then finding the limit. As you correctly observed, all values $a_n = 0.4\underbrace{9\ldots 9}_{n\text{ times}}$ are rounded down to zero. Thus, $$
  \lim_{n\to\infty} \text{round }(a_n) = 0
$$
On the other hand, $\lim_{n\to\infty} a_n = 0.5$, and thus $$
  \text{round }\left(\lim_{n\to\infty} a_n\right) = 1
$$
There's another word for functions which don't commute with limit - they're called non-continuous. So what you have discovered is simply that rounding is not a continuous function.

A: For $0\le x\le 1$, we round $x$ to $1$ if $x\ge \frac12$ and to $0$ if $x<\frac12$ (though there are many conventions, see e.g. Wikipedia on rounding; the section "Table-maker's dilemma" a bit further down may also be interesting). Since $0.4\bar9=\frac12$, we should round to $1$.
Another way of looking at this is that we always consider only the standard decimal expansion (i.e. we prefer $\bar0$ over $\bar 9$), and we are allowed to treat the first decimal as $4$ only if we know that it cannot turn out as $5$ "later". Thus if an inexact measurement gives us that $0.495\le x\le0.5$, we cannot say definitely, what $\operatorname{round}(x)$ should be (we could if the measurement resulted in $0.495<x<0.5$).
This is not different from the fact that we cannot say definitely  what $\operatorname{round}(x)$ should be if our measuremen merely says that $0.4997<x<0.5003$.

A: If you consistently use the round-up half method you don't always look at the first digit of the numeral when rounding numbers.  You go by the method.  The method allows that if we have anything else than a half-way value, then you can round by the rule "if (working in base 10) the first digit of the numeral after the decimal point belongs to {0, 1, 2, 3, 4}, then round down, if the first digit of the decimal point belongs to {5, 6, 7, 8, 9}, then round up."  But, that rule does not say anything about half-way values.  Going by q=FLOOR(y + .5) we can reason as follows:  q=FLOOR(.499... + 5)=FLOOR(.999...)=FLOOR(1)=1, since .999...=1.  So, that method yields that .499... rounds to 1.

A: It is the same as 0.5 by definition of decimal numbering.

A: This is just an obersvation that I was missing in the many answers already given.
While there is absolutely no doubt that the mathematical function $\Bbb R\to\Bbb Z$ defined by $x\mapsto\lfloor x+\frac12\rfloor$ when applied to the real (in fact rational) number represented by the repetitive infinite decimal sequence $0.4\overline9$ takes as value the integer$~1$, saying that this is what happens when rounding the repeating decimal $0.4999\ldots$ is misleading. That is because "rounding" suggests an operation done during actual computation. This ignores the often overlooked fact that it is impossible to do arithmetic computations with infinite decimals. This does not mean of course that there isn't a class of infinite decimals with which computations are possible; for instance if all decimals are repeating, then one can replace them by rational numbers and compute with those, which is definitely possible. However the misconception is that, because we can do arithmetic on numbers with any fixed number of decimal places and the procedures for doing so are always basically the same, therefore one can apply these same procedures to infinite decimals. However just looking at these procedures will reveal that this is plainly false: all of these procedures need at some point (often right at the beginning) to locate the final decimal position, and for an infinite decimal such a position simply does not exist. This means that in practice whenever one needs rounding decimal numbers as a computational operation, then those decimals are necessarily finite, and the number $0.4999\ldots$ simply cannot occur.
In fact there is no effective system for computing with (general) true real numbers at all, for the simple reason that the majority of the real numbers cannot be represented in any way (a concrete representation having to be, by the nature of things in the real world, finite). One can however restrict to the (countable) subset of real numbers that do allow some kind of representation (which is less brutal that restricting to some arbitrarily chosen finite subset of numbers declared representable, as is done in numeric computation), and then arithmetic and other kinds of computation do become possible, and indeed can be done without having to introduce approximations. This has been studied in constructive mathematics, but it turns out that for this purpose representing real numbers by infinite decimals, which might be produced on demand by a finite algorithm, is not a viable option. Even just finding the first decimal of the sum of two numbers so given by infinite decimals cannot be assured by an algorithm; this is in fact closely related to issues invoked in this question and the related $0.9999\ldots$ problematic. This in contrast to computations with formal power series with integer (or rational) coefficients: these suffer from the same "most elements cannot be represented" problem as the real numbers, but if one sticks to series whose coefficients can be computed by an algorithm, then all arithmetic (and many other) operations on them can be performed algorithmically without problem.
A more workable way to represent real numbers is by a sequence of definite approximations (rational numbers with a given maximal error), with some kind of guarantee that the error tends to $0$. But even then there are sacrifices one has to make: it is impossible to computations with discontinuous functions (like the floor or round-to-integer operations): in the constructive theory of real numbers there only exist continuous functions. So all of this is rather far removed from what one does in numeric computation, where real numbers are necessarily approximated, the number of decimals finite, and the question of how to round $0.4\overline9$ moot; the rule for rounding of looking at the first digit to be discarded in the rounding is perfectly valid in practice.

A: If we round c to d, then c approximately equals d.  If d also consists of an integer, then c lies closer to d than any other integer i.  In other words for all integers i such that i does not equal d, ABS(ci-)>ABS(cd-), where ABS(ci-) indicates the number by which c and i differ by (the absolute value of the difference of c an i).  This implies that we can use the distance metric between real numbers to see how rounding works as follows.
Consider the set S=={[l, lu+2/), (lu+2/, u]} where ul-=1.  In other words, l and u differ by 1, and we consider the set of all numbers between x and y except for the midpoint m==lu+2/ between them.  We can use the metric function D(x,y)=|xy-|=ABS(xy-), where x belongs to S and y belongs to {l, u}, to determine how to round all members of S by following rule:
If D(x, l)>D(x, u), then round to u.
If D(x, u)>D(x, l), then round to l.
Since .5=.49999..., it follows that D(.49999..., 1)=D(.49999...., 0)=.4999...=.5.  Thus, the distance function D(x, y)=ABS(xy-) does not give us any guide as to how to round here.
Consequently, we have several different choices that we can make which will not go against our intuition of rounding as follows:

*

*Choose to round .49999... to 1 (maybe you value larger numbers in general),

*Choose to round .49999... to 0 (maybe you value smaller numbers in general),

*Choose to allow .49999... to get rounded to both as one pleases or sees fit at particular points in time, or

*Choose to round .49999... to neither 0 nor 1 (maybe you don't want to make a choice here).

None of those possibilities win or lose until we have a standard to measure a winner or loser for the rules.  There also doesn't exist a "right answer" here unless we have a means to determine what properties a "right answer" has in this context.  I suspect that many people would resist 3. with the possibility that one could round .4999... to 1 at one time, and then round .4999... to 0 at another as one pleases, thus indicating arbitrariness.  But, it does not follow that such comes as an improper procedure unless one first rates such "arbitrariness" as bad, and something so utterly awful and terrible that we or others must never, ever engage in such "arbitrariness".  Perhaps many people would see 4. as "evasive", but unless there exists a logical basis to picking either 0 or 1, anyone accused of "evasiveness" by picking 4. could very well respond to such a charge, that anyone who sees choosing 4. as indicating "evasiveness", insists dogmatically that all such questions absolutely must have answers, and/or that the people claiming "evasiveness" have copped out of making choices on the basis of logic as much as possible.
So, what sort of choice do you want to make?


text:
Q: How to look up a word in the Mac OS X dictionary with AppleScript? How can I look up a word in the Mac OS X dictionary through AppleScript?

A: Dictionary.app is not scriptable but it supports its own URL scheme, which you can exploit from AppleScript:
open location "dict://mandolin"


text:
Q: Bootstrapping failed when deploying iOS app to external testers via cloud platform I am generating an iOS build for distribution to external testers in services such as AWS Device Farm or Applause. The build is being generated with app-store distribution, since I don't know what devices the app will run on (thus I can't use ad-hoc distribution). These external testing platforms re-sign the app as part of their distribution process to testers, as seen here or here.
The build generates an IPA successfully. This one can't be installed on a local device though, since it is intended for App Store Connect (and it does work in TestFlight BTW). When I upload this IPA to one of these external platforms, then it crashes on launch.
This is the error message:
"Bootstrapping failed for <FBApplicationProcess: 0x116773190; application<my.bundle.identifier>:-1> with error: <NSError: 0x282b9bf30; domain: RBSRequestErrorDomain; code: 5; reason: \"The launchd job couldn't be started.\"> {",

I am using an account registered in the Apple Developer Program and signing certificates are up to date (I can distribute without problems via TestFlight).
How can I run the app successfully for manual testing on these cloud platforms?