问:
Keep div inside Container
I've the snippet below, and if you look into it then you can see that the lowest level of items is outside the container.

I know its because of the position:absolute; transform:translate(-33%).
But it's the only way so far i've been able to center the elements below the it's parrent.

Is the some way to "put" the 3 lowest elements into the container and make the whole thing scroll able from left to right?

body {
  background-color: #eaeaea;
  width: 2000px
}

.CB {
  background-color: #c4cfd8;
  width: 1200px;
  margin: 0 auto;
  margin-top: 50px;
  user-select: none;
  white-space: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  min-height: 200vh;
}

.CB .CB_Menu {
  width: 100%;
  height: 35px;
  background-color: #fff;
  margin-bottom: 20px;
}

.CB .CB_Content .Products,
.CB .CB_Content .Parts {
  text-align: center;
}

.CB .CB_Content .Products > div,
.CB .CB_Content .Parts > div {
  display: inline-block;
}

.CB .CB_Content .Products > div > div,
.CB .CB_Content .Parts > div > div {
  display: inline-table;
}

.CB .CB_Content .Products .Product,
.CB .CB_Content .Parts .Product,
.CB .CB_Content .Products .Part,
.CB .CB_Content .Parts .Part {
  width: 200px;
  height: 200px;
  background-color: #fff;
  margin: 0 10px;
  display: inline-table;
  border-radius: 5px;
  position: relative;
}

.CB .CB_Content .Products .Product .Product_Header,
.CB .CB_Content .Parts .Product .Product_Header,
.CB .CB_Content .Products .Part .Product_Header,
.CB .CB_Content .Parts .Part .Product_Header,
.CB .CB_Content .Products .Product .Part_Header,
.CB .CB_Content .Parts .Product .Part_Header,
.CB .CB_Content .Products .Part .Part_Header,
.CB .CB_Content .Parts .Part .Part_Header {
  background-color: #eaeaea;
  width: 100%;
  text-align: left;
  border-top-left-radius: 5px;
  border-top-right-radius: 5px;
}

.CB .CB_Content .Products .Product .Product_Header span,
.CB .CB_Content .Parts .Product .Product_Header span,
.CB .CB_Content .Products .Part .Product_Header span,
.CB .CB_Content .Parts .Part .Product_Header span,
.CB .CB_Content .Products .Product .Part_Header span,
.CB .CB_Content .Parts .Product .Part_Header span,
.CB .CB_Content .Products .Part .Part_Header span,
.CB .CB_Content .Parts .Part .Part_Header span {
  font-size: 16px;
}

.CB .CB_Content .Products .Product .Product_Header span a,
.CB .CB_Content .Parts .Product .Product_Header span a,
.CB .CB_Content .Products .Part .Product_Header span a,
.CB .CB_Content .Parts .Part .Product_Header span a,
.CB .CB_Content .Products .Product .Part_Header span a,
.CB .CB_Content .Parts .Product .Part_Header span a,
.CB .CB_Content .Products .Part .Part_Header span a,
.CB .CB_Content .Parts .Part .Part_Header span a {
  float: right;
  color: #000;
}

.CB .CB_Content .Products .Product .Product_Content,
.CB .CB_Content .Parts .Product .Product_Content,
.CB .CB_Content .Products .Part .Product_Content,
.CB .CB_Content .Parts .Part .Product_Content,
.CB .CB_Content .Products .Product .Part_Content,
.CB .CB_Content .Parts .Product .Part_Content,
.CB .CB_Content .Products .Part .Part_Content,
.CB .CB_Content .Parts .Part .Part_Content {
  text-align: left;
}

.CB .CB_Content .Products .Product .Product_Content .Product_Content_Left,
.CB .CB_Content .Parts .Product .Product_Content .Product_Content_Left,
.CB .CB_Content .Products .Part .Product_Content .Product_Content_Left,
.CB .CB_Content .Parts .Part .Product_Content .Product_Content_Left,
.CB .CB_Content .Products .Product .Part_Content .Product_Content_Left,
.CB .CB_Content .Parts .Product .Part_Content .Product_Content_Left,
.CB .CB_Content .Products .Part .Part_Content .Product_Content_Left,
.CB .CB_Content .Parts .Part .Part_Content .Product_Content_Left,
.CB .CB_Content .Products .Product .Product_Content .Part_Content_Left,
.CB .CB_Content .Parts .Product .Product_Content .Part_Content_Left,
.CB .CB_Content .Products .Part .Product_Content .Part_Content_Left,
.CB .CB_Content .Parts .Part .Product_Content .Part_Content_Left,
.CB .CB_Content .Products .Product .Part_Content .Part_Content_Left,
.CB .CB_Content .Parts .Product .Part_Content .Part_Content_Left,
.CB .CB_Content .Products .Part .Part_Content .Part_Content_Left,
.CB .CB_Content .Parts .Part .Part_Content .Part_Content_Left {
  width: 50%;
  min-height: 120px;
  float: left;
}

.CB .CB_Content .Products .Product .Product_Content .Product_Content_Left a,
.CB .CB_Content .Parts .Product .Product_Content .Product_Content_Left a,
.CB .CB_Content .Products .Part .Product_Content .Product_Content_Left a,
.CB .CB_Content .Parts .Part .Product_Content .Product_Content_Left a,
.CB .CB_Content .Products .Product .Part_Content .Product_Content_Left a,
.CB .CB_Content .Parts .Product .Part_Content .Product_Content_Left a,
.CB .CB_Content .Products .Part .Part_Content .Product_Content_Left a,
.CB .CB_Content .Parts .Part .Part_Content .Product_Content_Left a,
.CB .CB_Content .Products .Product .Product_Content .Part_Content_Left a,
.CB .CB_Content .Parts .Product .Product_Content .Part_Content_Left a,
.CB .CB_Content .Products .Part .Product_Content .Part_Content_Left a,
.CB .CB_Content .Parts .Part .Product_Content .Part_Content_Left a,
.CB .CB_Content .Products .Product .Part_Content .Part_Content_Left a,
.CB .CB_Content .Parts .Product .Part_Content .Part_Content_Left a,
.CB .CB_Content .Products .Part .Part_Content .Part_Content_Left a,
.CB .CB_Content .Parts .Part .Part_Content .Part_Content_Left a {
  display: block;
  color: #000;
}

.CB .CB_Content .Products .Product .Product_Content .Product_Content_right,
.CB .CB_Content .Parts .Product .Product_Content .Product_Content_right,
.CB .CB_Content .Products .Part .Product_Content .Product_Content_right,
.CB .CB_Content .Parts .Part .Product_Content .Product_Content_right,
.CB .CB_Content .Products .Product .Part_Content .Product_Content_right,
.CB .CB_Content .Parts .Product .Part_Content .Product_Content_right,
.CB .CB_Content .Products .Part .Part_Content .Product_Content_right,
.CB .CB_Content .Parts .Part .Part_Content .Product_Content_right,
.CB .CB_Content .Products .Product .Product_Content .Part_Content_right,
.CB .CB_Content .Parts .Product .Product_Content .Part_Content_right,
.CB .CB_Content .Products .Part .Product_Content .Part_Content_right,
.CB .CB_Content .Parts .Part .Product_Content .Part_Content_right,
.CB .CB_Content .Products .Product .Part_Content .Part_Content_right,
.CB .CB_Content .Parts .Product .Part_Content .Part_Content_right,
.CB .CB_Content .Products .Part .Part_Content .Part_Content_right,
.CB .CB_Content .Parts .Part .Part_Content .Part_Content_right {
  width: 50%;
  min-height: 120px;
}

.CB .CB_Content .Products .Product .Product_Content .Product_Content_right img,
.CB .CB_Content .Parts .Product .Product_Content .Product_Content_right img,
.CB .CB_Content .Products .Part .Product_Content .Product_Content_right img,
.CB .CB_Content .Parts .Part .Product_Content .Product_Content_right img,
.CB .CB_Content .Products .Product .Part_Content .Product_Content_right img,
.CB .CB_Content .Parts .Product .Part_Content .Product_Content_right img,
.CB .CB_Content .Products .Part .Part_Content .Product_Content_right img,
.CB .CB_Content .Parts .Part .Part_Content .Product_Content_right img,
.CB .CB_Content .Products .Product .Product_Content .Part_Content_right img,
.CB .CB_Content .Parts .Product .Product_Content .Part_Content_right img,
.CB .CB_Content .Products .Part .Product_Content .Part_Content_right img,
.CB .CB_Content .Parts .Part .Product_Content .Part_Content_right img,
.CB .CB_Content .Products .Product .Part_Content .Part_Content_right img,
.CB .CB_Content .Parts .Product .Part_Content .Part_Content_right img,
.CB .CB_Content .Products .Part .Part_Content .Part_Content_right img,
.CB .CB_Content .Parts .Part .Part_Content .Part_Content_right img {
  width: 100%;
}

.CB .CB_Content .Products .Product .Product_Footer,
.CB .CB_Content .Parts .Product .Product_Footer,
.CB .CB_Content .Products .Part .Product_Footer,
.CB .CB_Content .Parts .Part .Product_Footer,
.CB .CB_Content .Products .Product .Part_Footer,
.CB .CB_Content .Parts .Product .Part_Footer,
.CB .CB_Content .Products .Part .Part_Footer,
.CB .CB_Content .Parts .Part .Part_Footer {
  position: absolute;
  bottom: 0;
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: center;
}

.CB .CB_Content .Products .Product .Product_Footer a,
.CB .CB_Content .Parts .Product .Product_Footer a,
.CB .CB_Content .Products .Part .Product_Footer a,
.CB .CB_Content .Parts .Part .Product_Footer a,
.CB .CB_Content .Products .Product .Part_Footer a,
.CB .CB_Content .Parts .Product .Part_Footer a,
.CB .CB_Content .Products .Part .Part_Footer a,
.CB .CB_Content .Parts .Part .Part_Footer a {
  width: 50%;
  height: 25px;
  border: 1px solid #dddddd;
  background-color: #eaeaea;
  border-radius: 5px;
  margin-bottom: 10px;
  line-height: 25px;
  color: #000;
}

.CB .CB_Content .Products .Product .Product_Footer button,
.CB .CB_Content .Parts .Product .Product_Footer button,
.CB .CB_Content .Products .Part .Product_Footer button,
.CB .CB_Content .Parts .Part .Product_Footer button,
.CB .CB_Content .Products .Product .Part_Footer button,
.CB .CB_Content .Parts .Product .Part_Footer button,
.CB .CB_Content .Products .Part .Part_Footer button,
.CB .CB_Content .Parts .Part .Part_Footer button {
  width: 50%;
  height: 25px;
  border: 1px solid #dddddd;
  background-color: #eaeaea;
  border-radius: 5px;
  margin-bottom: 10px;
  padding: 4px 6px;
  color: #000;
}

.CB .CB_Content .lineTop {
  height: 25px;
  width: calc(100% - 25%);
  border-top: 1px dotted #fff;
  border-right: 1px dotted #fff;
  border-left: 1px dotted #fff;
  margin: 0 110px;
  display: none;
}

.CB .CB_Content .lineTop.active {
  display: block;
}

.CB .CB_Content .lineTop.none {
  border-right: none;
  width: 1px;
  margin-top: -2px;
}

.CB .CB_Content .lineTop.two {
  width: calc(100% - 50%);
}

.CB .CB_Content .lineTop .LineTop_Line {
  width: 219px;
  height: 100%;
  border-right: 1px dotted #fff;
  float: left;
}

.CB .CB_Content .lineBottom {
  display: none;
  height: 25px;
  width: 100%;
}

.CB .CB_Content .lineBottom.active {
  display: block;
}

.CB .CB_Content .lineBottom .LineBottom_Line {
  width: 50%;
  height: 100%;
  border-right: 1px dotted #fff;
}

.CB .CB_Content .lineBottom .LineBottom_Line.Test {
  width: calc(50% - 300px);
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="CB">

  <div class="CB_Menu">
    header
  </div>

  <div class="CB_Content">

    <div class="Products">
      <div>
        <div class="Product">
          <div class="Product_Header">
            <span>Title<i class="fa fa-ellipsis-h"></i></span>
          </div>
          <div class="Product_Content">
            <div class="Product_Content_Left">
              Link 1
              Link 2
            </div>
            <div class="Product_Content_right">
              <img src="https://www.maltbazaren.dk/images/staal-300x300-t.png" />
            </div>
          </div>
          <div class="Product_Footer">
            <button>Show <i class="fa fa-caret-down"></i></button>
          </div>
        </div>
        <div class="lineBottom active">
          <div class="LineBottom_Line"></div>
        </div>
      </div>
    </div>
    <div class="Parts">
      <div>
        <div class="lineTop active">
          <div class="LineTop_Line"></div>
          <div class="LineTop_Line"></div>
        </div>
        <div>
          <div class="Part">
            <div class="Part_Header">
              <span>Title<i class="fa fa-ellipsis-h"></i></span>
            </div>
            <div class="Part_Content">
              <div class="Part_Content_Left">
                Link 1
                Link 2
              </div>
              <div class="Part_Content_right">
                <img src="https://www.maltbazaren.dk/images/staal-300x300-t.png" />
              </div>
            </div>
            <div class="Part_Footer">
              <button>Show <i class="fa fa-caret-down"></i></button>
            </div>
          </div>

          <div style="position:absolute; transform:translate(-33%)">
            <div class="lineBottom active">
              <div class="LineBottom_Line"></div>
            </div>

            <div class="sub_part">
              <div class="lineTop active">
                <div class="LineTop_Line"></div>
              </div>
              <div class="Parts">
                <div>
                  <div class="Part">
                    <div class="Part_Header">
                      <span>Title<i class="fa fa-ellipsis-h"></i></span>
                    </div>
                    <div class="Part_Content">
                      <div class="Part_Content_Left">
                        Link 1
                        Link 2
                      </div>
                      <div class="Part_Content_right">
                        <img src="https://www.maltbazaren.dk/images/staal-300x300-t.png" />
                      </div>
                    </div>
                    <div class="Part_Footer">
                      <button>Show <i class="fa fa-caret-down"></i></button>
                    </div>
                  </div>
                  <div class="Part">
                    <div class="Part_Header">
                      <span>Title<i class="fa fa-ellipsis-h"></i></span>
                    </div>
                    <div class="Part_Content">
                      <div class="Part_Content_Left">
                        Link 1
                        Link 2
                      </div>
                      <div class="Part_Content_right">
                        <img src="https://www.maltbazaren.dk/images/staal-300x300-t.png" />
                      </div>
                    </div>
                    <div class="Part_Footer">
                      <button>Show <i class="fa fa-caret-down"></i></button>
                    </div>
                  </div>
                  <div class="Part">
                    <div class="Part_Header">
                      <span>Title<i class="fa fa-ellipsis-h"></i></span>
                    </div>
                    <div class="Part_Content">
                      <div class="Part_Content_Left">
                        Link 1
                        Link 2
                      </div>
                      <div class="Part_Content_right">
                        <img src="https://www.maltbazaren.dk/images/staal-300x300-t.png" />
                      </div>
                    </div>
                    <div class="Part_Footer">
                      <button>Show <i class="fa fa-caret-down"></i></button>
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </div>

        </div>
        <div class="Part">
          <div class="Part_Header">
            <span>Title<i class="fa fa-ellipsis-h"></i></span>
          </div>
          <div class="Part_Content">
            <div class="Part_Content_Left">
              Link 1
              Link 2
            </div>
            <div class="Part_Content_right">
              <img src="https://www.maltbazaren.dk/images/staal-300x300-t.png" />
            </div>
          </div>
          <div class="Part_Footer">
            <button>Show <i class="fa fa-caret-down"></i></button>
          </div>
        </div>
        <div class="Part">
          <div class="Part_Header">
            <span>Title<i class="fa fa-ellipsis-h"></i></span>
          </div>
          <div class="Part_Content">
            <div class="Part_Content_Left">
              Link 1
              Link 2
            </div>
            <div class="Part_Content_right">
              <img src="https://www.maltbazaren.dk/images/staal-300x300-t.png" />
            </div>
          </div>
          <div class="Part_Footer">
            <button>Show <i class="fa fa-caret-down"></i></button>
          </div>
        </div>
        <div class="Part">
          <div class="Part_Header">
            <span>Title<i class="fa fa-ellipsis-h"></i></span>
          </div>
          <div class="Part_Content">
            <div class="Part_Content_Left">
              Link 1
              Link 2
            </div>
            <div class="Part_Content_right">
              <img src="https://www.maltbazaren.dk/images/staal-300x300-t.png" />
            </div>
          </div>
          <div class="Part_Footer">
            <button>Show <i class="fa fa-caret-down"></i></button>
          </div>
        </div>

      </div>
    </div>
  </div>
</div></code>```

答:
```<code><style>
    body {
  background-color: #eaeaea;
  width: 2000px
}

.CB {
  background-color: #c4cfd8;
  width: 1200px;
  margin: 0 auto;
  margin-top: 50px;
  user-select: none;
  white-space: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  min-height: 200vh;
}

.CB .CB_Menu {
  width: 100%;
  height: 35px;
  background-color: #fff;
  margin-bottom: 20px;
}

.CB .CB_Content .Products,
.CB .CB_Content .Parts {
  text-align: center;
}

.CB .CB_Content .Products > div,
.CB .CB_Content .Parts > div {
  display: inline-block;
}

.CB .CB_Content .Products > div > div,
.CB .CB_Content .Parts > div > div {
  display: inline-table;
}

.CB .CB_Content .Products .Product,
.CB .CB_Content .Parts .Product,
.CB .CB_Content .Products .Part,
.CB .CB_Content .Parts .Part {
  width: 200px;
  height: 200px;
  background-color: #fff;
  margin: 0 10px;
  display: inline-table;
  border-radius: 5px;
  position: relative;
}

.CB .CB_Content .Products .Product .Product_Header,
.CB .CB_Content .Parts .Product .Product_Header,
.CB .CB_Content .Products .Part .Product_Header,
.CB .CB_Content .Parts .Part .Product_Header,
.CB .CB_Content .Products .Product .Part_Header,
.CB .CB_Content .Parts .Product .Part_Header,
.CB .CB_Content .Products .Part .Part_Header,
.CB .CB_Content .Parts .Part .Part_Header {
  background-color: #eaeaea;
  width: 100%;
  text-align: left;
  border-top-left-radius: 5px;
  border-top-right-radius: 5px;
}

.CB .CB_Content .Products .Product .Product_Header span,
.CB .CB_Content .Parts .Product .Product_Header span,
.CB .CB_Content .Products .Part .Product_Header span,
.CB .CB_Content .Parts .Part .Product_Header span,
.CB .CB_Content .Products .Product .Part_Header span,
.CB .CB_Content .Parts .Product .Part_Header span,
.CB .CB_Content .Products .Part .Part_Header span,
.CB .CB_Content .Parts .Part .Part_Header span {
  font-size: 16px;
}

.CB .CB_Content .Products .Product .Product_Header span a,
.CB .CB_Content .Parts .Product .Product_Header span a,
.CB .CB_Content .Products .Part .Product_Header span a,
.CB .CB_Content .Parts .Part .Product_Header span a,
.CB .CB_Content .Products .Product .Part_Header span a,
.CB .CB_Content .Parts .Product .Part_Header span a,
.CB .CB_Content .Products .Part .Part_Header span a,
.CB .CB_Content .Parts .Part .Part_Header span a {
  float: right;
  color: #000;
}

.CB .CB_Content .Products .Product .Product_Content,
.CB .CB_Content .Parts .Product .Product_Content,
.CB .CB_Content .Products .Part .Product_Content,
.CB .CB_Content .Parts .Part .Product_Content,
.CB .CB_Content .Products .Product .Part_Content,
.CB .CB_Content .Parts .Product .Part_Content,
.CB .CB_Content .Products .Part .Part_Content,
.CB .CB_Content .Parts .Part .Part_Content {
  text-align: left;
}

.CB .CB_Content .Products .Product .Product_Content .Product_Content_Left,
.CB .CB_Content .Parts .Product .Product_Content .Product_Content_Left,
.CB .CB_Content .Products .Part .Product_Content .Product_Content_Left,
.CB .CB_Content .Parts .Part .Product_Content .Product_Content_Left,
.CB .CB_Content .Products .Product .Part_Content .Product_Content_Left,
.CB .CB_Content .Parts .Product .Part_Content .Product_Content_Left,
.CB .CB_Content .Products .Part .Part_Content .Product_Content_Left,
.CB .CB_Content .Parts .Part .Part_Content .Product_Content_Left,
.CB .CB_Content .Products .Product .Product_Content .Part_Content_Left,
.CB .CB_Content .Parts .Product .Product_Content .Part_Content_Left,
.CB .CB_Content .Products .Part .Product_Content .Part_Content_Left,
.CB .CB_Content .Parts .Part .Product_Content .Part_Content_Left,
.CB .CB_Content .Products .Product .Part_Content .Part_Content_Left,
.CB .CB_Content .Parts .Product .Part_Content .Part_Content_Left,
.CB .CB_Content .Products .Part .Part_Content .Part_Content_Left,
.CB .CB_Content .Parts .Part .Part_Content .Part_Content_Left {
  width: 50%;
  min-height: 120px;
  float: left;
}

.CB .CB_Content .Products .Product .Product_Content .Product_Content_Left a,
.CB .CB_Content .Parts .Product .Product_Content .Product_Content_Left a,
.CB .CB_Content .Products .Part .Product_Content .Product_Content_Left a,
.CB .CB_Content .Parts .Part .Product_Content .Product_Content_Left a,
.CB .CB_Content .Products .Product .Part_Content .Product_Content_Left a,
.CB .CB_Content .Parts .Product .Part_Content .Product_Content_Left a,
.CB .CB_Content .Products .Part .Part_Content .Product_Content_Left a,
.CB .CB_Content .Parts .Part .Part_Content .Product_Content_Left a,
.CB .CB_Content .Products .Product .Product_Content .Part_Content_Left a,
.CB .CB_Content .Parts .Product .Product_Content .Part_Content_Left a,
.CB .CB_Content .Products .Part .Product_Content .Part_Content_Left a,
.CB .CB_Content .Parts .Part .Product_Content .Part_Content_Left a,
.CB .CB_Content .Products .Product .Part_Content .Part_Content_Left a,
.CB .CB_Content .Parts .Product .Part_Content .Part_Content_Left a,
.CB .CB_Content .Products .Part .Part_Content .Part_Content_Left a,
.CB .CB_Content .Parts .Part .Part_Content .Part_Content_Left a {
  display: block;
  color: #000;
}

.CB .CB_Content .Products .Product .Product_Content .Product_Content_right,
.CB .CB_Content .Parts .Product .Product_Content .Product_Content_right,
.CB .CB_Content .Products .Part .Product_Content .Product_Content_right,
.CB .CB_Content .Parts .Part .Product_Content .Product_Content_right,
.CB .CB_Content .Products .Product .Part_Content .Product_Content_right,
.CB .CB_Content .Parts .Product .Part_Content .Product_Content_right,
.CB .CB_Content .Products .Part .Part_Content .Product_Content_right,
.CB .CB_Content .Parts .Part .Part_Content .Product_Content_right,
.CB .CB_Content .Products .Product .Product_Content .Part_Content_right,
.CB .CB_Content .Parts .Product .Product_Content .Part_Content_right,
.CB .CB_Content .Products .Part .Product_Content .Part_Content_right,
.CB .CB_Content .Parts .Part .Product_Content .Part_Content_right,
.CB .CB_Content .Products .Product .Part_Content .Part_Content_right,
.CB .CB_Content .Parts .Product .Part_Content .Part_Content_right,
.CB .CB_Content .Products .Part .Part_Content .Part_Content_right,
.CB .CB_Content .Parts .Part .Part_Content .Part_Content_right {
  width: 50%;
  min-height: 120px;
}

.CB .CB_Content .Products .Product .Product_Content .Product_Content_right img,
.CB .CB_Content .Parts .Product .Product_Content .Product_Content_right img,
.CB .CB_Content .Products .Part .Product_Content .Product_Content_right img,
.CB .CB_Content .Parts .Part .Product_Content .Product_Content_right img,
.CB .CB_Content .Products .Product .Part_Content .Product_Content_right img,
.CB .CB_Content .Parts .Product .Part_Content .Product_Content_right img,
.CB .CB_Content .Products .Part .Part_Content .Product_Content_right img,
.CB .CB_Content .Parts .Part .Part_Content .Product_Content_right img,
.CB .CB_Content .Products .Product .Product_Content .Part_Content_right img,
.CB .CB_Content .Parts .Product .Product_Content .Part_Content_right img,
.CB .CB_Content .Products .Part .Product_Content .Part_Content_right img,
.CB .CB_Content .Parts .Part .Product_Content .Part_Content_right img,
.CB .CB_Content .Products .Product .Part_Content .Part_Content_right img,
.CB .CB_Content .Parts .Product .Part_Content .Part_Content_right img,
.CB .CB_Content .Products .Part .Part_Content .Part_Content_right img,
.CB .CB_Content .Parts .Part .Part_Content .Part_Content_right img {
  width: 100%;
}

.CB .CB_Content .Products .Product .Product_Footer,
.CB .CB_Content .Parts .Product .Product_Footer,
.CB .CB_Content .Products .Part .Product_Footer,
.CB .CB_Content .Parts .Part .Product_Footer,
.CB .CB_Content .Products .Product .Part_Footer,
.CB .CB_Content .Parts .Product .Part_Footer,
.CB .CB_Content .Products .Part .Part_Footer,
.CB .CB_Content .Parts .Part .Part_Footer {
  position: absolute;
  bottom: 0;
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: center;
}

.CB .CB_Content .Products .Product .Product_Footer a,
.CB .CB_Content .Parts .Product .Product_Footer a,
.CB .CB_Content .Products .Part .Product_Footer a,
.CB .CB_Content .Parts .Part .Product_Footer a,
.CB .CB_Content .Products .Product .Part_Footer a,
.CB .CB_Content .Parts .Product .Part_Footer a,
.CB .CB_Content .Products .Part .Part_Footer a,
.CB .CB_Content .Parts .Part .Part_Footer a {
  width: 50%;
  height: 25px;
  border: 1px solid #dddddd;
  background-color: #eaeaea;
  border-radius: 5px;
  margin-bottom: 10px;
  line-height: 25px;
  color: #000;
}

.CB .CB_Content .Products .Product .Product_Footer button,
.CB .CB_Content .Parts .Product .Product_Footer button,
.CB .CB_Content .Products .Part .Product_Footer button,
.CB .CB_Content .Parts .Part .Product_Footer button,
.CB .CB_Content .Products .Product .Part_Footer button,
.CB .CB_Content .Parts .Product .Part_Footer button,
.CB .CB_Content .Products .Part .Part_Footer button,
.CB .CB_Content .Parts .Part .Part_Footer button {
  width: 50%;
  height: 25px;
  border: 1px solid #dddddd;
  background-color: #eaeaea;
  border-radius: 5px;
  margin-bottom: 10px;
  padding: 4px 6px;
  color: #000;
}

.CB .CB_Content .lineTop {
  height: 25px;
  width: calc(100% - 17%);
  border-top: 1px dotted #fff;
  border-right: 1px dotted #fff;
  border-left: 1px dotted #fff;
  margin: 0 110px;
  display: none;
}

.CB .CB_Content .lineTop.active {
  display: block;
}

.CB .CB_Content .lineTop.none {
  border-right: none;
  width: 1px;
  margin-top: -2px;
}

.CB .CB_Content .lineTop.two {
  width: calc(100% - 50%);
}

.CB .CB_Content .lineTop .LineTop_Line {
  width: 219px;
  height: 100%;
  border-right: 1px dotted #fff;
  float: left;
}

.CB .CB_Content .lineBottom {
  display: none;
  height: 25px;
  width: 115%;
}

.CB .CB_Content .lineBottom.active {
  display: block;
}

.CB .CB_Content .lineBottom .LineBottom_Line {
  width: 50%;
  height: 100%;
  border-right: 1px dotted #fff;
}

.CB .CB_Content .lineBottom .LineBottom_Line.Test {
  width: calc(50% - 300px);
}

.sub_part{ width: 445px; }
    </style>

    <div class="CB">

      <div class="CB_Menu">
        header
      </div>

      <div class="CB_Content">

        <div class="Products">
          <div>
            <div class="Product">
              <div class="Product_Header">
                <span>Title<a href="#"><i class="fa fa-ellipsis-h"></i></a></span>
              </div>
              <div class="Product_Content">
                <div class="Product_Content_Left">
                  <a href="#">Link 1</a>
                  <a href="#">Link 2</a>
                </div>
                <div class="Product_Content_right">
                  <img src="https://www.maltbazaren.dk/images/staal-300x300-t.png" />
                </div>
              </div>
              <div class="Product_Footer">
                <button>Show <i class="fa fa-caret-down"></i></button>
              </div>
            </div>
            <div class="lineBottom active">
              <div class="LineBottom_Line"></div>
            </div>
          </div>
        </div>
        <div class="Parts">
          <div>
            <div class="lineTop active">
              <div class="LineTop_Line"></div>
              <div class="LineTop_Line"></div>
            </div>
            <div>
              <div class="Part">
                <div class="Part_Header">
                  <span>Title<a href="#"><i class="fa fa-ellipsis-h"></i></a></span>
                </div>
                <div class="Part_Content">
                  <div class="Part_Content_Left">
                    <a href="#">Link 1</a>
                    <a href="#">Link 2</a>
                  </div>
                  <div class="Part_Content_right">
                    <img src="https://www.maltbazaren.dk/images/staal-300x300-t.png" />
                  </div>
                </div>
                <div class="Part_Footer">
                  <button>Show <i class="fa fa-caret-down"></i></button>
                </div>
              </div>

              <div style="position:absolute; transform:translate(-33%)">
                <div class="lineBottom active">
                  <div class="LineBottom_Line"></div>
                </div>

                <div class="sub_part">
                  <div class="lineTop active">
                    <div class="LineTop_Line"></div>
                  </div>
                  <div class="Parts">
                    <div>
                      <div class="Part">
                        <div class="Part_Header">
                          <span>Title<a href="#"><i class="fa fa-ellipsis-h"></i></a></span>
                        </div>
                        <div class="Part_Content">
                          <div class="Part_Content_Left">
                            <a href="#">Link 1</a>
                            <a href="#">Link 2</a>
                          </div>
                          <div class="Part_Content_right">
                            <img src="https://www.maltbazaren.dk/images/staal-300x300-t.png" />
                          </div>
                        </div>
                        <div class="Part_Footer">
                          <button>Show <i class="fa fa-caret-down"></i></button>
                        </div>
                      </div>
                      <div class="Part">
                        <div class="Part_Header">
                          <span>Title<a href="#"><i class="fa fa-ellipsis-h"></i></a></span>
                        </div>
                        <div class="Part_Content">
                          <div class="Part_Content_Left">
                            <a href="#">Link 1</a>
                            <a href="#">Link 2</a>
                          </div>
                          <div class="Part_Content_right">
                            <img src="https://www.maltbazaren.dk/images/staal-300x300-t.png" />
                          </div>
                        </div>
                        <div class="Part_Footer">
                          <button>Show <i class="fa fa-caret-down"></i></button>
                        </div>
                      </div>
                      <div class="Part">
                        <div class="Part_Header">
                          <span>Title<a href="#"><i class="fa fa-ellipsis-h"></i></a></span>
                        </div>
                        <div class="Part_Content">
                          <div class="Part_Content_Left">
                            <a href="#">Link 1</a>
                            <a href="#">Link 2</a>
                          </div>
                          <div class="Part_Content_right">
                            <img src="https://www.maltbazaren.dk/images/staal-300x300-t.png" />
                          </div>
                        </div>
                        <div class="Part_Footer">
                          <button>Show <i class="fa fa-caret-down"></i></button>
                        </div>
                      </div>
                    </div>
                  </div>
                </div>
              </div>

            </div>
            <div class="Part">
              <div class="Part_Header">
                <span>Title<a href="#"><i class="fa fa-ellipsis-h"></i></a></span>
              </div>
              <div class="Part_Content">
                <div class="Part_Content_Left">
                  <a href="#">Link 1</a>
                  <a href="#">Link 2</a>
                </div>
                <div class="Part_Content_right">
                  <img src="https://www.maltbazaren.dk/images/staal-300x300-t.png" />
                </div>
              </div>
              <div class="Part_Footer">
                <button>Show <i class="fa fa-caret-down"></i></button>
              </div>
            </div>
            <div class="Part">
              <div class="Part_Header">
                <span>Title<a href="#"><i class="fa fa-ellipsis-h"></i></a></span>
              </div>
              <div class="Part_Content">
                <div class="Part_Content_Left">
                  <a href="#">Link 1</a>
                  <a href="#">Link 2</a>
                </div>
                <div class="Part_Content_right">
                  <img src="https://www.maltbazaren.dk/images/staal-300x300-t.png" />
                </div>
              </div>
              <div class="Part_Footer">
                <button>Show <i class="fa fa-caret-down"></i></button>
              </div>
            </div>
            <div class="Part">
              <div class="Part_Header">
                <span>Title<a href="#"><i class="fa fa-ellipsis-h"></i></a></span>
              </div>
              <div class="Part_Content">
                <div class="Part_Content_Left">
                  <a href="#">Link 1</a>
                  <a href="#">Link 2</a>
                </div>
                <div class="Part_Content_right">
                  <img src="https://www.maltbazaren.dk/images/staal-300x300-t.png" />
                </div>
              </div>
              <div class="Part_Footer">
                <button>Show <i class="fa fa-caret-down"></i></button>
              </div>
            </div>

          </div>
        </div>
      </div>
    </div>
</code>```

Title: Keep div inside Container

Body:
I've the snippet below, and if you look into it then you can see that the lowest level of items is outside the container.

I know its because of the position:absolute; transform:translate(-33%).
But it's the only way so far i've been able to center the elements below the it's parrent.

Is the some way to "put" the 3 lowest elements into the container and make the whole thing scroll able from left to right?

body {
  background-color: #eaeaea;
  width: 2000px
}

.CB {
  background-color: #c4cfd8;
  width: 1200px;
  margin: 0 auto;
  margin-top: 50px;
  user-select: none;
  white-space: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  min-height: 200vh;
}

.CB .CB_Menu {
  width: 100%;
  height: 35px;
  background-color: #fff;
  margin-bottom: 20px;
}

.CB .CB_Content .Products,
.CB .CB_Content .Parts {
  text-align: center;
}

.CB .CB_Content .Products > div,
.CB .CB_Content .Parts > div {
  display: inline-block;
}

.CB .CB_Content .Products > div > div,
.CB .CB_Content .Parts > div > div {
  display: inline-table;
}

.CB .CB_Content .Products .Product,
.CB .CB_Content .Parts .Product,
.CB .CB_Content .Products .Part,
.CB .CB_Content .Parts .Part {
  width: 200px;
  height: 200px;
  background-color: #fff;
  margin: 0 10px;
  display: inline-table;
  border-radius: 5px;
  position: relative;
}

.CB .CB_Content .Products .Product .Product_Header,
.CB .CB_Content .Parts .Product .Product_Header,
.CB .CB_Content .Products .Part .Product_Header,
.CB .CB_Content .Parts .Part .Product_Header,
.CB .CB_Content .Products .Product .Part_Header,
.CB .CB_Content .Parts .Product .Part_Header,
.CB .CB_Content .Products .Part .Part_Header,
.CB .CB_Content .Parts .Part .Part_Header {
  background-color: #eaeaea;
  width: 100%;
  text-align: left;
  border-top-left-radius: 5px;
  border-top-right-radius: 5px;
}

.CB .CB_Content .Products .Product .Product_Header span,
.CB .CB_Content .Parts .Product .Product_Header span,
.CB .CB_Content .Products .Part .Product_Header span,
.CB .CB_Content .Parts .Part .Product_Header span,
.CB .CB_Content .Products .Product .Part_Header span,
.CB .CB_Content .Parts .Product .Part_Header span,
.CB .CB_Content .Products .Part .Part_Header span,
.CB .CB_Content .Parts .Part .Part_Header span {
  font-size: 16px;
}

.CB .CB_Content .Products .Product .Product_Header span a,
.CB .CB_Content .Parts .Product .Product_Header span a,
.CB .CB_Content .Products .Part .Product_Header span a,
.CB .CB_Content .Parts .Part .Product_Header span a,
.CB .CB_Content .Products .Product .Part_Header span a,
.CB .CB_Content .Parts .Product .Part_Header span a,
.CB .CB_Content .Products .Part .Part_Header span a,
.CB .CB_Content .Parts .Part .Part_Header span a {
  float: right;
  color: #000;
}

.CB .CB_Content .Products .Product .Product_Content,
.CB .CB_Content .Parts .Product .Product_Content,
.CB .CB_Content .Products .Part .Product_Content,
.CB .CB_Content .Parts .Part .Product_Content,
.CB .CB_Content .Products .Product .Part_Content,
.CB .CB_Content .Parts .Product .Part_Content,
.CB .CB_Content .Products .Part .Part_Content,
.CB .CB_Content .Parts .Part .Part_Content {
  text-align: left;
}

.CB .CB_Content .Products .Product .Product_Content .Product_Content_Left,
.CB .CB_Content .Parts .Product .Product_Content .Product_Content_Left,
.CB .CB_Content .Products .Part .Product_Content .Product_Content_Left,
.CB .CB_Content .Parts .Part .Product_Content .Product_Content_Left,
.CB .CB_Content .Products .Product .Part_Content .Product_Content_Left,
.CB .CB_Content .Parts .Product .Part_Content .Product_Content_Left,
.CB .CB_Content .Products .Part .Part_Content .Product_Content_Left,
.CB .CB_Content .Parts .Part .Part_Content .Product_Content_Left,
.CB .CB_Content .Products .Product .Product_Content .Part_Content_Left,
.CB .CB_Content .Parts .Product .Product_Content .Part_Content_Left,
.CB .CB_Content .Products .Part .Product_Content .Part_Content_Left,
.CB .CB_Content .Parts .Part .Product_Content .Part_Content_Left,
.CB .CB_Content .Products .Product .Part_Content .Part_Content_Left,
.CB .CB_Content .Parts .Product .Part_Content .Part_Content_Left,
.CB .CB_Content .Products .Part .Part_Content .Part_Content_Left,
.CB .CB_Content .Parts .Part .Part_Content .Part_Content_Left {
  width: 50%;
  min-height: 120px;
  float: left;
}

.CB .CB_Content .Products .Product .Product_Content .Product_Content_Left a,
.CB .CB_Content .Parts .Product .Product_Content .Product_Content_Left a,
.CB .CB_Content .Products .Part .Product_Content .Product_Content_Left a,
.CB .CB_Content .Parts .Part .Product_Content .Product_Content_Left a,
.CB .CB_Content .Products .Product .Part_Content .Product_Content_Left a,
.CB .CB_Content .Parts .Product .Part_Content .Product_Content_Left a,
.CB .CB_Content .Products .Part .Part_Content .Product_Content_Left a,
.CB .CB_Content .Parts .Part .Part_Content .Product_Content_Left a,
.CB .CB_Content .Products .Product .Product_Content .Part_Content_Left a,
.CB .CB_Content .Parts .Product .Product_Content .Part_Content_Left a,
.CB .CB_Content .Products .Part .Product_Content .Part_Content_Left a,
.CB .CB_Content .Parts .Part .Product_Content .Part_Content_Left a,
.CB .CB_Content .Products .Product .Part_Content .Part_Content_Left a,
.CB .CB_Content .Parts .Product .Part_Content .Part_Content_Left a,
.CB .CB_Content .Products .Part .Part_Content .Part_Content_Left a,
.CB .CB_Content .Parts .Part .Part_Content .Part_Content_Left a {
  display: block;
  color: #000;
}

.CB .CB_Content .Products .Product .Product_Content .Product_Content_right,
.CB .CB_Content .Parts .Product .Product_Content .Product_Content_right,
.CB .CB_Content .Products .Part .Product_Content .Product_Content_right,
.CB .CB_Content .Parts .Part .Product_Content .Product_Content_right,
.CB .CB_Content .Products .Product .Part_Content .Product_Content_right,
.CB .CB_Content .Parts .Product .Part_Content .Product_Content_right,
.CB .CB_Content .Products .Part .Part_Content .Product_Content_right,
.CB .CB_Content .Parts .Part .Part_Content .Product_Content_right,
.CB .CB_Content .Products .Product .Product_Content .Part_Content_right,
.CB .CB_Content .Parts .Product .Product_Content .Part_Content_right,
.CB .CB_Content .Products .Part .Product_Content .Part_Content_right,
.CB .CB_Content .Parts .Part .Product_Content .Part_Content_right,
.CB .CB_Content .Products .Product .Part_Content .Part_Content_right,
.CB .CB_Content .Parts .Product .Part_Content .Part_Content_right,
.CB .CB_Content .Products .Part .Part_Content .Part_Content_right,
.CB .CB_Content .Parts .Part .Part_Content .Part_Content_right {
  width: 50%;
  min-height: 120px;
}

.CB .CB_Content .Products .Product .Product_Content .Product_Content_right img,
.CB .CB_Content .Parts .Product .Product_Content .Product_Content_right img,
.CB .CB_Content .Products .Part .Product_Content .Product_Content_right img,
.CB .CB_Content .Parts .Part .Product_Content .Product_Content_right img,
.CB .CB_Content .Products .Product .Part_Content .Product_Content_right img,
.CB .CB_Content .Parts .Product .Part_Content .Product_Content_right img,
.CB .CB_Content .Products .Part .Part_Content .Product_Content_right img,
.CB .CB_Content .Parts .Part .Part_Content .Product_Content_right img,
.CB .CB_Content .Products .Product .Product_Content .Part_Content_right img,
.CB .CB_Content .Parts .Product .Product_Content .Part_Content_right img,
.CB .CB_Content .Products .Part .Product_Content .Part_Content_right img,
.CB .CB_Content .Parts .Part .Product_Content .Part_Content_right img,
.CB .CB_Content .Products .Product .Part_Content .Part_Content_right img,
.CB .CB_Content .Parts .Product .Part_Content .Part_Content_right img,
.CB .CB_Content .Products .Part .Part_Content .Part_Content_right img,
.CB .CB_Content .Parts .Part .Part_Content .Part_Content_right img {
  width: 100%;
}

.CB .CB_Content .Products .Product .Product_Footer,
.CB .CB_Content .Parts .Product .Product_Footer,
.CB .CB_Content .Products .Part .Product_Footer,
.CB .CB_Content .Parts .Part .Product_Footer,
.CB .CB_Content .Products .Product .Part_Footer,
.CB .CB_Content .Parts .Product .Part_Footer,
.CB .CB_Content .Products .Part .Part_Footer,
.CB .CB_Content .Parts .Part .Part_Footer {
  position: absolute;
  bottom: 0;
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: center;
}

.CB .CB_Content .Products .Product .Product_Footer a,
.CB .CB_Content .Parts .Product .Product_Footer a,
.CB .CB_Content .Products .Part .Product_Footer a,
.CB .CB_Content .Parts .Part .Product_Footer a,
.CB .CB_Content .Products .Product .Part_Footer a,
.CB .CB_Content .Parts .Product .Part_Footer a,
.CB .CB_Content .Products .Part .Part_Footer a,
.CB .CB_Content .Parts .Part .Part_Footer a {
  width: 50%;
  height: 25px;
  border: 1px solid #dddddd;
  background-color: #eaeaea;
  border-radius: 5px;
  margin-bottom: 10px;
  line-height: 25px;
  color: #000;
}

.CB .CB_Content .Products .Product .Product_Footer button,
.CB .CB_Content .Parts .Product .Product_Footer button,
.CB .CB_Content .Products .Part .Product_Footer button,
.CB .CB_Content .Parts .Part .Product_Footer button,
.CB .CB_Content .Products .Product .Part_Footer button,
.CB .CB_Content .Parts .Product .Part_Footer button,
.CB .CB_Content .Products .Part .Part_Footer button,
.CB .CB_Content .Parts .Part .Part_Footer button {
  width: 50%;
  height: 25px;
  border: 1px solid #dddddd;
  background-color: #eaeaea;
  border-radius: 5px;
  margin-bottom: 10px;
  padding: 4px 6px;
  color: #000;
}

.CB .CB_Content .lineTop {
  height: 25px;
  width: calc(100% - 25%);
  border-top: 1px dotted #fff;
  border-right: 1px dotted #fff;
  border-left: 1px dotted #fff;
  margin: 0 110px;
  display: none;
}

.CB .CB_Content .lineTop.active {
  display: block;
}

.CB .CB_Content .lineTop.none {
  border-right: none;
  width: 1px;
  margin-top: -2px;
}

.CB .CB_Content .lineTop.two {
  width: calc(100% - 50%);
}

.CB .CB_Content .lineTop .LineTop_Line {
  width: 219px;
  height: 100%;
  border-right: 1px dotted #fff;
  float: left;
}

.CB .CB_Content .lineBottom {
  display: none;
  height: 25px;
  width: 100%;
}

.CB .CB_Content .lineBottom.active {
  display: block;
}

.CB .CB_Content .lineBottom .LineBottom_Line {
  width: 50%;
  height: 100%;
  border-right: 1px dotted #fff;
}

.CB .CB_Content .lineBottom .LineBottom_Line.Test {
  width: calc(50% - 300px);
}

    header

            Title

              Link 1
              Link 2

            <button>Show </button>

              Title

                Link 1
                Link 2

              <button>Show </button>

                      Title

                        Link 1
                        Link 2

                      <button>Show </button>

                      Title

                        Link 1
                        Link 2

                      <button>Show </button>

                      Title

                        Link 1
                        Link 2

                      <button>Show </button>

            Title

              Link 1
              Link 2

            <button>Show </button>

            Title

              Link 1
              Link 2

            <button>Show </button>

            Title

              Link 1
              Link 2

            <button>Show </button>


来源: stackexchange

问:
Credentials cannot be used for NTLM authentication
I am getting

org.apache.commons.httpclient.auth.InvalidCredentialsException:
Credentials cannot be used for NTLM authentication:

exception in eclipse

Whether it is possible mention eclipse to take system proxy settings directly?

```<code>public class HttpGetProxy {
    private static final String PROXY_HOST = "proxy.****.com";
    private static final int PROXY_PORT = 6050;

    public static void main(String[] args) {
        HttpClient client = new HttpClient();
        HttpMethod method = new GetMethod("https://kodejava.org");

        HostConfiguration config = client.getHostConfiguration();
        config.setProxy(PROXY_HOST, PROXY_PORT);

        String username = "*****";
        String password = "*****";
        Credentials credentials = new UsernamePasswordCredentials(username, password);
        AuthScope authScope = new AuthScope(PROXY_HOST, PROXY_PORT);

        client.getState().setProxyCredentials(authScope, credentials);

        try {
            client.executeMethod(method);

            if (method.getStatusCode() == HttpStatus.SC_OK) {
                String response = method.getResponseBodyAsString();
                System.out.println("Response = " + response);
            }
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            method.releaseConnection();
        }
    }
}
</code>```

Exception:

Dec 08, 2017 1:41:39 PM
org.apache.commons.httpclient.auth.AuthChallengeProcessor selectAuthScheme
INFO: ntlm authentication scheme selected
Dec 08, 2017 1:41:39 PM org.apache.commons.httpclient.HttpMethodDirector executeConnect
SEVERE: Credentials cannot be used for NTLM authentication:
org.apache.commons.httpclient.UsernamePasswordCredentials
org.apache.commons.httpclient.auth.InvalidCredentialsException: Credentials
cannot be used for NTLM authentication:
enter code here
org.apache.commons.httpclient.UsernamePasswordCredentials
at org.apache.commons.httpclient.auth.NTLMScheme.authenticate(NTLMScheme.java:332)
at org.apache.commons.httpclient.HttpMethodDirector.authenticateProxy(HttpMethodDirector.java:320)
at org.apache.commons.httpclient.HttpMethodDirector.executeConnect(HttpMethodDirector.java:491)
at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:391)
at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:171)
at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397)
at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:323)
at HttpGetProxy.main(HttpGetProxy.java:31)

Dec 08, 2017 1:41:39 PM org.apache.commons.httpclient.HttpMethodDirector processProxyAuthChallenge
INFO: Failure authenticating with NTLM @proxy.****.com:6050

答: I think you need to use credentials in the form of domain\username in the "username" field, for NTLM authentication to work properly.</p>

ContentLicense: CC BY-SA 4.0

Body:
I am getting

org.apache.commons.httpclient.auth.InvalidCredentialsException:
Credentials cannot be used for NTLM authentication:

exception in eclipse

Whether it is possible mention eclipse to take system proxy settings directly?

public class HttpGetProxy {
    private static final String PROXY_HOST = "proxy.****.com";
    private static final int PROXY_PORT = 6050;

    public static void main(String[] args) {
        HttpClient client = new HttpClient();
        HttpMethod method = new GetMethod("https://kodejava.org");

        HostConfiguration config = client.getHostConfiguration();
        config.setProxy(PROXY_HOST, PROXY_PORT);

        String username = "*****";
        String password = "*****";
        Credentials credentials = new UsernamePasswordCredentials(username, password);
        AuthScope authScope = new AuthScope(PROXY_HOST, PROXY_PORT);

        client.getState().setProxyCredentials(authScope, credentials);

        try {
            client.executeMethod(method);

            if (method.getStatusCode() == HttpStatus.SC_OK) {
                String response = method.getResponseBodyAsString();
                System.out.println("Response = " + response);
            }
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            method.releaseConnection();
        }
    }
}

Exception:

Dec 08, 2017 1:41:39 PM
org.apache.commons.httpclient.auth.AuthChallengeProcessor selectAuthScheme
INFO: ntlm authentication scheme selected
Dec 08, 2017 1:41:39 PM org.apache.commons.httpclient.HttpMethodDirector executeConnect
SEVERE: Credentials cannot be used for NTLM authentication:
org.apache.commons.httpclient.UsernamePasswordCredentials
org.apache.commons.httpclient.auth.InvalidCredentialsException: Credentials
cannot be used for NTLM authentication:
enter code here
org.apache.commons.httpclient.UsernamePasswordCredentials
at org.apache.commons.httpclient.auth.NTLMScheme.authenticate(NTLMScheme.java:332)
at org.apache.commons.httpclient.HttpMethodDirector.authenticateProxy(HttpMethodDirector.java:320)
at org.apache.commons.httpclient.HttpMethodDirector.executeConnect(HttpMethodDirector.java:491)
at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:391)
at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:171)
at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397)
at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:323)
at HttpGetProxy.main(HttpGetProxy.java:31)

Dec 08, 2017 1:41:39 PM org.apache.commons.httpclient.HttpMethodDirector processProxyAuthChallenge
INFO: Failure authenticating with NTLM @proxy.****.com:6050

ContentLicense: CC BY-SA 3.0


问:
Catch redirection and make it go to an iframe
I'm trying to use Diigo with sciencedirect.com but apparently the pages are not static, they keep changing, but I can access the same paper through the same link every time. The problem is that this link then redirects the page to a dynamic one in science direct.

I was thinking, is it possible through JavaScript or Greasemonkey to catch the redirection and send it to an iframe, so that the main page could be the initial link?

An example:

http://linkinghub.elsevier.com/retrieve/pii/0924-8579(95)90674-L

答:
I was tinking, is it possible trhough javascript on greasemonkey to catch the redirection and send it to an iframe, so that the main page could be the initial link?

No it's not possible to do this with Greasemoneky, you'd have to use a Firefox add-on in order to do this.

ContentLicense: CC BY-SA 2.5


问:
Passing value from Table View to textfield in IOS
I have a textfield in my view controller, in which when user type car name it shows related car name list in table view and user can select the any car from table view. If car name has space between name for example: "Honda Civic" the space is replaced by %20 and becomes "Honda%20Civic" and it pass value from textfield to the API.Now I'm getting an issue that when I type any letter like ho it shows list of cars of Honda when I select any car it comes textfield text , when I send the textfield value it goes to ho instead of the name I have selected from table view. How can I send it to the API the name of car I have selected from tableview list?
My code to replaced space by %20 is this,

```<code>-(void)textFieldDidChanges :(UITextField *)theTextField{
result=theTextField.text;
NSLog(@"XXX%@",result);
result=[result stringByReplacingOccurrencesOfString:@" " withString:@"%20"];
NSLog(@"VVV %@",result);
//just use this result where you want
}
</code>```

This is table view methods,

```<code>- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
if (tableView==_year01) {
    return [year1Array count];
}else{
    return [carArray count];
}
return YES;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

static NSString *CellIdentifier = @"Cell";

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

if (cell == nil) {
    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}

if (tableView == _year01){
    cell.textLabel.text=[year1Array objectAtIndex:indexPath.row];
}else{
    cell.textLabel.text=[carArray objectAtIndex:indexPath.row];
}

cell.backgroundColor=[UIColor darkGrayColor];
cell.textLabel.textColor=[UIColor whiteColor];

return cell;

}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

UITableViewCell *selectedCell=[tableView cellForRowAtIndexPath:indexPath];
NSLog(@"Cell %@",selectedCell);

if (tableView == _year01){
    self.year1.text=@"";
    self.year1.text=[year1Array objectAtIndex:indexPath.row];
    self.year01.hidden=YES;
}else{
    self.carName.text=@"";
    self.carName.text=[carArray objectAtIndex:indexPath.row];
    _carTable.hidden=YES;
    [_carName resignFirstResponder];
}
}
</code>```

This is I'm storing in NSUserdefault and passing to next view,

```<code> [[NSUserDefaults standardUserDefaults] setObject:result forKey:@"name"];` [[NSUserDefaults standardUserDefaults] synchronize];`
</code>```

The value in result come the letter I write instead of the value selected from table view list.

答:
i don't know which place you used NSUserDeafults. store textfield did end finishing

        [[NSUserDefaults standardUserDefaults] setObject:textfield.text forKey:@"name"];

Body:
I have a textfield in my view controller, in which when user type car name it shows related car name list in table view and user can select the any car from table view. If car name has space between name for example: "Honda Civic" the space is replaced by %20 and becomes "Honda%20Civic" and it pass value from textfield to the API.Now I'm getting an issue that when I type any letter like ho it shows list of cars of Honda when I select any car it comes textfield text , when I send the textfield value it goes to ho instead of the name I have selected from table view. How can I send it to the API the name of car I have selected from tableview list?
My code to replaced space by %20 is this,

-(void)textFieldDidChanges :(UITextField *)theTextField{
result=theTextField.text;
NSLog(@"XXX%@",result);
result=[result stringByReplacingOccurrencesOfString:@" " withString:@"%20"];
NSLog(@"VVV %@",result);
//just use this result where you want
}

This is table view methods,

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
if (tableView==_year01) {
    return [year1Array count];
}else{
    return [carArray count];
}
return YES;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

static NSString *CellIdentifier = @"Cell";

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

if (cell == nil) {
    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}

if (tableView == _year01){
    cell.textLabel.text=[year1Array objectAtIndex:indexPath.row];
}else{
    cell.textLabel.text=[carArray objectAtIndex:indexPath.row];
}

cell.backgroundColor=[UIColor darkGrayColor];
cell.textLabel.textColor=[UIColor whiteColor];

return cell;

}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

UITableViewCell *selectedCell=[tableView cellForRowAtIndexPath:indexPath];
NSLog(@"Cell %@",selectedCell);

if (tableView == _year01){
    self.year1.text=@"";
    self.year1.text=[year1Array objectAtIndex:indexPath.row];
    self.year01.hidden=YES;
}else{
    self.carName.text=@"";
    self.carName.text=[carArray objectAtIndex:indexPath.row];
    _carTable.hidden=YES;
    [_carName resignFirstResponder];
}
}

This is I'm storing in NSUserdefault and passing to next view,

 [[NSUserDefaults standardUserDefaults] setObject:result forKey:@"name"];` [[NSUserDefaults standardUserDefaults] synchronize];`

The value in result come the letter I write instead of the value selected from table view list.


问:
Woocommerce Variable Product page
We hired a developer to create a custom bit of code which went in to Woocommerce > Single Product > Add To Cart > Variable.php

You can see how the page has been modified to look here: Example of Single Variable Product Page

```<code>   <?php
/**
 * Variable product add to cart
 *
 * @author      WooThemes
 * @package     WooCommerce/Templates
 * @version     2.1.0
 */

if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly

function omniwp_output_variation_row( $ref, $dimensions, $qty, $price1, $price2, $price3, $price4, $id ) {
?>
        <tr id="ctl00_ContentPlaceHolder1_rptPrices_ctl00_tr" class="">
          <td class="colRef"><?php echo $ref ?></td>
          <td class="colDimensions"><?php echo $dimensions ?></td>
          <td class="colPackQty"><?php echo $qty ?></td>
          <td class="colPPI1"><?php echo $price1 ?></td>
          <td class="colPPI2-4"><?php echo $price2 ?></td>
          <td class="colPPI5-9"><?php echo $price3 ?></td>
          <td class="colPPI10"><?php echo $price4 ?></td>
          <td class="colOrderQty"><input name="qty_variation_id[<?php echo $id ?>]" class="textbox txtQty" type="text"></td>
        </tr>
<?php
}

global $woocommerce, $product, $post;

$discounts              = '';
$_enable_discount       = get_post_meta( $product->post->ID, '_enablediscount', true);
$dpta_overall_discounts = get_option( 'dpta_overall_discounts' );

if ( $_enable_discount == 'yes' ) {

    $_attached_discount = get_post_meta( $product->post->ID, '_attacheddiscount', true);
    $discounts          = array_shift( dpta_get_applicable_discount( $_attached_discount ) );

} elseif ( isset( $dpta_overall_discounts['common'] )
    && $dpta_overall_discounts['common'] == 'yes'
    && isset( $dpta_overall_discounts['commondiscount'] ) )  {

    $_attached_discount = $dpta_overall_discounts['commondiscount'];
    $discounts          = array_shift( dpta_get_applicable_discount( $_attached_discount ) );

}

$currency_symbol     = get_woocommerce_currency_symbol();
$currency_symbol_len = strlen( $currency_symbol );

$dimensions         = false;
$cartons            = false;
$product_attributes = $product->get_attributes();

if ( $product_attributes ) {

$dimensions_values  = explode( '|' , $product_attributes['dimensions']['value'] );
$dimensions_keys    = array_map( 'sanitize_title', $dimensions_values );
$dimensions         = array_combine( $dimensions_keys, $dimensions_values );

$cartons_values  = explode( '|' , $product_attributes['cartons']['value'] );
$cartons_keys    = array_map( 'sanitize_title', $cartons_values );
$cartons         = array_combine( $cartons_keys, $cartons_values );

}

?>

<?php do_action( 'woocommerce_before_add_to_cart_form' ); ?>

<form class="variations_form cart" method="post" enctype="multipart/form-data" data-product_id="<?php echo $post->ID; ?>" data-product_variations="<?php echo esc_attr( json_encode( $available_variations ) ) ?>">
    <?php if ( ! empty( $available_variations ) ) : ?>
    <table>
      <thead>
        <tr>
          <th class="colRef" rowspan="2" scope="col">Ref.</th>
          <th class="colDimensions" rowspan="2" scope="col">Dimensions</th>
          <th class="colPackQty" rowspan="2" scope="col">Pack Qty.</th>
          <th class="colPPI" colspan="4" scope="colgroup">Price per Pack</th>
          <th class="colOrderQty" rowspan="2" scope="col">Order Qty.</th>
        </tr>
        <tr>
          <th class="colPPI1" scope="col">1</th>
          <th class="colPPI2-4" scope="col">2-4</th>
          <th class="colPPI5-9" scope="col">5-9</th>
          <th class="colPPI10" scope="col">10+</th>
        </tr>
      </thead>
      <tbody>
<?php

    foreach ( $available_variations as $variation ) {

        $name = false;
        $qty  = '';

        if ( $dimensions && array_key_exists( 'attribute_dimensions', $variation['attributes'] ) )
            $name = $dimensions[ $variation['attributes']['attribute_dimensions'] ];
        elseif ( $cartons && array_key_exists( 'attribute_cartons', $variation['attributes'] ) )
            $name = $cartons[ $variation['attributes']['attribute_cartons'] ];
        elseif ( array_key_exists( 'attribute_pa_dimensions', $variation['attributes'] ) ) {
            $term = get_term_by( 'slug', $variation['attributes']['attribute_pa_dimensions'], 'pa_dimensions');
            if ( $term )
                $name = $term->name;
        }

        if ( ! $name ) {
            $option = 'Not found variation attribute for  `' . print_r( $variation['attributes'], true ) . '`';
            $qty    = '-';
        } else {
            $option = substr( $name, 0, strpos( $name, '(' ) - 1  );
            if ( strpos( $name, '(Qty.' ) )
                $qty = substr( $name, strpos( $name, '(Qty.' ) + 5, -1 );
            elseif ( strpos( $name, '(Qty' ) )
                $qty = substr( $name, strpos( $name, '(Qty' ) + 4, -1 );

            $qty = str_replace( ')', '', $qty );

        }

        $price1 = $variation['price_html'];

        if ( empty( $price1 ) )
            $price1 = '<span class="price">' . wc_price( $product->get_variation_price( 'min', $display = true ) ) . '</span>';
    //  $price1 = '<span class="price">' . wc_price( $product->get_price() ) . '</span>';

        if ( empty( $discounts ) ) {
            $price2 = $price3 = $price4 = $price1 . ' no discounts';
        } else {

            $price = substr( $price1, strpos( $price1, $currency_symbol ) + $currency_symbol_len  );
            $price = substr( $price, 0, strpos( $price, '<' )  );
            $price = str_replace( array( '.', ',' ), '', $price ); // remove any number formating
            $price = $price / 100;                                 // make price a float with 2 digits

            $price2 = '<span class="price">' . wc_price( $price - ( $price / 100 ) * $discounts['rules'][1]['amount'] ) . '</span>';
            $price3 = '<span class="price">' . wc_price( $price - ( $price / 100 ) * $discounts['rules'][2]['amount'] ) . '</span>';
            $price4 = '<span class="price">' . wc_price( $price - ( $price / 100 ) * $discounts['rules'][3]['amount'] ) . '</span>';
        }

        omniwp_output_variation_row(
            $ref = $variation['sku'],
            $variation_dimensions = esc_html( apply_filters( 'woocommerce_variation_option_name', $option ) ),
            $qty,
            $price1,
            $price2,
            $price3,
            $price4,
            $field_name = $variation['variation_id']
            );
    }
?>
      </tbody>
      <tfoot>
        <tr>
          <th class="colRef" rowspan="2" scope="col">Ref.</th>
          <th class="colDimensions" rowspan="2" scope="col">Dimensions</th>
          <th class="colPackQty" rowspan="2" scope="col">Pack Qty.</th>
          <th class="colPPI" colspan="4" scope="colgroup">Price per Pack</th>
          <th class="colOrderQty" rowspan="2" scope="col">Order Qty.</th>
        </tr>
        <tr>
          <th class="colPPI1" scope="col">1</th>
          <th class="colPPI2-4" scope="col">2-4</th>
          <th class="colPPI5-9" scope="col">5-9</th>
          <th class="colPPI10" scope="col">10+</th>
        </tr>
      </tfoot>
    </table>

        <?php do_action( 'woocommerce_before_add_to_cart_button' ); ?>

        <div class="multiple_variation_wrap">
            <div class="variations_button">
                <button type="submit" class="single_add_to_cart_button button alt"><?php echo $product->single_add_to_cart_text(); ?></button>
                <input type="hidden" name="multiple-add-to-cart" value="<?php echo $product->id; ?>" />
                <input type="hidden" name="product_id" value="<?php echo esc_attr( $post->ID ); ?>" />
                <input type="hidden" name="xvariation_id" value="multiple-add-to-cart" />
            </div>
        </div>

        <?php do_action( 'woocommerce_after_add_to_cart_button' ); ?>

    <?php else : ?>

        <p class="stock out-of-stock"><?php _e( 'This product is currently out of stock and unavailable.', 'woocommerce' ); ?></p>

        <?php endif; ?>

        </form>

        <?php do_action( 'woocommerce_after_add_to_cart_form' ); ?>
</code>```

However, when we try to update woocommerce to the latest version, it breaks this code (and Single Variable Product page) and no longer looks like it should. Can anyone spot anything glaring that needs changing. I was thinking maybe there were some deprecated functions that are no longer used/ need changing.

I'd really appreciate any help from someone that know PHP and Woocommerce :)

Paul

答:
Yes, a few changes have come in like, There is a need to update

```<code>$product->id to $product->get_id()
</code>```

and

```<code>$product->product_type to $product->get_type()
</code>```

since Woocommerce 3.0.0 update.

Title: Woocommerce Variable Product page

Body:
We hired a developer to create a custom bit of code which went in to Woocommerce > Single Product > Add To Cart > Variable.php

You can see how the page has been modified to look here: Example of Single Variable Product Page

   <?php
/**
 * Variable product add to cart
 *
 * @author      WooThemes
 * @package     WooCommerce/Templates
 * @version     2.1.0
 */

if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly

function omniwp_output_variation_row( $ref, $dimensions, $qty, $price1, $price2, $price3, $price4, $id ) {
?>

          <?php echo $ref ?>
          <?php echo $dimensions ?>
          <?php echo $qty ?>
          <?php echo $price1 ?>
          <?php echo $price2 ?>
          <?php echo $price3 ?>
          <?php echo $price4 ?>
          <input name="qty_variation_id[<?php echo $id ?>]" class="textbox txtQty" type="text">

<?php
}

global $woocommerce, $product, $post;

$discounts              = '';
$_enable_discount       = get_post_meta( $product->post->ID, '_enablediscount', true);
$dpta_overall_discounts = get_option( 'dpta_overall_discounts' );

if ( $_enable_discount == 'yes' ) {

    $_attached_discount = get_post_meta( $product->post->ID, '_attacheddiscount', true);
    $discounts          = array_shift( dpta_get_applicable_discount( $_attached_discount ) );

} elseif ( isset( $dpta_overall_discounts['common'] )
    && $dpta_overall_discounts['common'] == 'yes'
    && isset( $dpta_overall_discounts['commondiscount'] ) )  {

    $_attached_discount = $dpta_overall_discounts['commondiscount'];
    $discounts          = array_shift( dpta_get_applicable_discount( $_attached_discount ) );

}

$currency_symbol     = get_woocommerce_currency_symbol();
$currency_symbol_len = strlen( $currency_symbol );

$dimensions         = false;
$cartons            = false;
$product_attributes = $product->get_attributes();

if ( $product_attributes ) {

$dimensions_values  = explode( '|' , $product_attributes['dimensions']['value'] );
$dimensions_keys    = array_map( 'sanitize_title', $dimensions_values );
$dimensions         = array_combine( $dimensions_keys, $dimensions_values );

$cartons_values  = explode( '|' , $product_attributes['cartons']['value'] );
$cartons_keys    = array_map( 'sanitize_title', $cartons_values );
$cartons         = array_combine( $cartons_keys, $cartons_values );

}

?>

<?php do_action( 'woocommerce_before_add_to_cart_form' ); ?>

<form class="variations_form cart" method="post" enctype="multipart/form-data" data-product_id="<?php echo $post->ID; ?>" data-product_variations="<?php echo esc_attr( json_encode( $available_variations ) ) ?>">
    <?php if ( ! empty( $available_variations ) ) : ?>

          Ref.
          Dimensions
          Pack Qty.
          Price per Pack
          Order Qty.

          1
          2-4
          5-9
          10+

<?php

    foreach ( $available_variations as $variation ) {

        $name = false;
        $qty  = '';

        if ( $dimensions && array_key_exists( 'attribute_dimensions', $variation['attributes'] ) )
            $name = $dimensions[ $variation['attributes']['attribute_dimensions'] ];
        elseif ( $cartons && array_key_exists( 'attribute_cartons', $variation['attributes'] ) )
            $name = $cartons[ $variation['attributes']['attribute_cartons'] ];
        elseif ( array_key_exists( 'attribute_pa_dimensions', $variation['attributes'] ) ) {
            $term = get_term_by( 'slug', $variation['attributes']['attribute_pa_dimensions'], 'pa_dimensions');
            if ( $term )
                $name = $term->name;
        }

        if ( ! $name ) {
            $option = 'Not found variation attribute for  `' . print_r( $variation['attributes'], true ) . '`';
            $qty    = '-';
        } else {
            $option = substr( $name, 0, strpos( $name, '(' ) - 1  );
            if ( strpos( $name, '(Qty.' ) )
                $qty = substr( $name, strpos( $name, '(Qty.' ) + 5, -1 );
            elseif ( strpos( $name, '(Qty' ) )
                $qty = substr( $name, strpos( $name, '(Qty' ) + 4, -1 );

            $qty = str_replace( ')', '', $qty );

        }

        $price1 = $variation['price_html'];

        if ( empty( $price1 ) )
            $price1 = '' . wc_price( $product->get_variation_price( 'min', $display = true ) ) . '';
    //  $price1 = '' . wc_price( $product->get_price() ) . '';

        if ( empty( $discounts ) ) {
            $price2 = $price3 = $price4 = $price1 . ' no discounts';
        } else {

            $price = substr( $price1, strpos( $price1, $currency_symbol ) + $currency_symbol_len  );
            $price = substr( $price, 0, strpos( $price, '<' )  );
            $price = str_replace( array( '.', ',' ), '', $price ); // remove any number formating
            $price = $price / 100;                                 // make price a float with 2 digits

            $price2 = '' . wc_price( $price - ( $price / 100 ) * $discounts['rules'][1]['amount'] ) . '';
            $price3 = '' . wc_price( $price - ( $price / 100 ) * $discounts['rules'][2]['amount'] ) . '';
            $price4 = '' . wc_price( $price - ( $price / 100 ) * $discounts['rules'][3]['amount'] ) . '';
        }

        omniwp_output_variation_row(
            $ref = $variation['sku'],
            $variation_dimensions = esc_html( apply_filters( 'woocommerce_variation_option_name', $option ) ),
            $qty,
            $price1,
            $price2,
            $price3,
            $price4,
            $field_name = $variation['variation_id']
            );
    }
?>

          Ref.
          Dimensions
          Pack Qty.
          Price per Pack
          Order Qty.

          1
          2-4
          5-9
          10+

        <?php do_action( 'woocommerce_before_add_to_cart_button' ); ?>

                <button type="submit" class="single_add_to_cart_button button alt"><?php echo $product->single_add_to_cart_text(); ?></button>
                <input type="hidden" name="multiple-add-to-cart" value="<?php echo $product->id; ?>" />
                <input type="hidden" name="product_id" value="<?php echo esc_attr( $post->ID ); ?>" />
                <input type="hidden" name="xvariation_id" value="multiple-add-to-cart" />

        <?php do_action( 'woocommerce_after_add_to_cart_button' ); ?>

    <?php else : ?>

<?php _e( 'This product is currently out of stock and unavailable.', 'woocommerce' ); ?>

        <?php endif; ?>

        </form>

        <?php do_action( 'woocommerce_after_add_to_cart_form' ); ?>

However, when we try to update woocommerce to the latest version, it breaks this code (and Single Variable Product page) and no longer looks like it should. Can anyone spot anything glaring that needs changing. I was thinking maybe there were some deprecated functions that are no longer used/ need changing.

I'd really appreciate any help from someone that know PHP and Woocommerce :)

Paul

Body:
Yes, a few changes have come in like, There is a need to update

$product->id to $product->get_id()

and

$product->product_type to $product->get_type()

since Woocommerce 3.0.0 update.


问:
Does CDI reuse proxies for RequestScoped?
If I create a bean annotated with @RequestScoped I expect that it will instantiate a new proxy instance with each new request.

From the other hand each request is associated with its own thread.

My question is: will CDI reuse previously created proxy object of my bean/service if the new request reuses previously created thread from a pool?

答:
First of all, it's important to understand that client proxy object != bean instance (or contextual instance if we want to follow the spec wording). For @RequestScoped a new bean instance is always created for each request. However, @RequestScoped is a normal scope, which means that a client proxy is injected (and this proxy delegates to the bean instance).

Now back to your question to client proxy object - the strategy is implementation-specific. The spec states that a container might instantiate one client proxy object per bean and share it between multiple injection points. But it's not required (see also this documentation). Reference implementation (Weld, WildFly, GlassFish, etc.) DOES share client proxy objects. But again, we're speaking about client proxies, not bean instances.

WRT thread association - request context is associated with one thread but when the request ends the context is destroyed (incl. all bean instances) and the thread is dissociated.


问:
What is the correct type for returning a C99 `bool` to Rust via the FFI?
A colleague and I have been scratching our heads over how to return a bool from <stdbool.h> (a.k.a. _Bool) back to Rust via the FFI.

We have our C99 code we want to use from Rust:

bool
myfunc(void) {
   ...
}
```

<p>We let Rust know about <code>myfunc</code> using an <code>extern C</code> block:</p>

```extern "C" {
    fn myfunc() -> T;
}
```

What concrete type should T be?

Rust doesn't have a c_bool in the libc crate, and if you search the internet, you will find various GitHub issues and RFCs where people discuss this, but don't really come to any consensus as to what is both correct and portable:

https://github.com/rust-lang/rfcs/issues/1982#issuecomment-297534238

https://github.com/rust-lang/rust/issues/14608

https://github.com/rust-lang/rfcs/issues/992

https://github.com/rust-lang/rust/pull/46156

As far as I can gather:

The size of a bool in C99 is undefined other than the fact it must be at least large enough to store true (1) and false (0). In other words, at least one bit long.

It could even be one bit wide.

Its size might be ABI defined.

This comment suggests that if a C99 bool is passed into a function as a parameter or out of a function as the return value, and the bool is smaller than a C int then it is promoted to the same size as an int. Under this scenario, we can tell Rust T is u32.

All right, but what if (for some reason) a C99 bool is 64 bits wide? Is u32 still safe? Perhaps under this scenario we truncate the 4 most significant bytes, which would be fine, since the 4 least significant bytes are more than enough to represent true and false.

Is my reasoning correct? Until Rust gets a libc::c_bool, what would you use for T and why is it safe and portable for all possible sizes of a C99 bool (>=1 bit)?

答:
After a lot of thought, I'm going to try answering my own question. Please comment if you can find a hole in the following reasoning.

This is not the correct answer -- see the comments below

I think a Rust u8 is always safe for T.

We know that a C99 bool is an integer large enough to store 0 or 1, which means it's free to be an unsigned integer of at least 1-bit, or (if you are feeling weird) a signed integer of at least 2-bits.

Let's break it down by case:

If the C99 bool is 8-bits then a Rust u8 is perfect. Even in the signed case, the top bit will be a zero since representing 0 and 1 never requires a negative power of two.

If the C99 bool is larger than a Rust u8, then by "casting it down" to a 8-bit size, we only ever discard leading zeros. Thus this is safe too.

Now consider the case where the C99 bool is smaller than the Rust u8. When returning a value from a C function, it's not possible to return a value of size less than one byte due to the underlying calling convention. The CC will require return value to be loaded into a register or into a location on the stack. Since the smallest register or memory location is one byte, the return value will need to be extended (with zeros) to at least a one byte sized value (and I believe the same is true of function arguments, which too must adhere to calling convention). If the value is extended to a one-byte value, then it's the same as case 1. If the value is extended to a larger size, then it's the same as case 2.

Body:
A colleague and I have been scratching our heads over how to return a bool from <stdbool.h> (a.k.a. _Bool) back to Rust via the FFI.

We have our C99 code we want to use from Rust:

bool
myfunc(void) {
   ...
}

We let Rust know about myfunc using an extern C block:

extern "C" {
    fn myfunc() -> T;
}

What concrete type should T be?

Rust doesn't have a c_bool in the libc crate, and if you search the internet, you will find various GitHub issues and RFCs where people discuss this, but don't really come to any consensus as to what is both correct and portable:

https://github.com/rust-lang/rfcs/issues/1982#issuecomment-297534238

https://github.com/rust-lang/rust/issues/14608

https://github.com/rust-lang/rfcs/issues/992

https://github.com/rust-lang/rust/pull/46156

As far as I can gather:

The size of a bool in C99 is undefined other than the fact it must be at least large enough to store true (1) and false (0). In other words, at least one bit long.

It could even be one bit wide.

Its size might be ABI defined.

This comment suggests that if a C99 bool is passed into a function as a parameter or out of a function as the return value, and the bool is smaller than a C int then it is promoted to the same size as an int. Under this scenario, we can tell Rust T is u32.

All right, but what if (for some reason) a C99 bool is 64 bits wide? Is u32 still safe? Perhaps under this scenario we truncate the 4 most significant bytes, which would be fine, since the 4 least significant bytes are more than enough to represent true and false.

Is my reasoning correct? Until Rust gets a libc::c_bool, what would you use for T and why is it safe and portable for all possible sizes of a C99 bool (>=1 bit)?


问:
Autocomplete from 10 000 items in .NET
I've got an in memory collection of around 10K objects. I want to give users the ability to type part of the item name or description and display an autocomplete list. What is an efficient way to do it? I really need the fastest possible response time, users are very fast.

Thanks a lot,
Mary

答: Arrange your data as a Trie.

Title: Autocomplete from 10 000 items in .NET

Body: Arrange your data as a Trie.


问:
Excel macro that open and prepares Access
I have a code that open access from excel:

```<code>Dim objShell As Object

Set objShell = CreateObject("Shell.Application")
objShell.Open "\\acrtnd\share$\PUBLIC\!tools\preportDST.accdb"
Set objShell = Nothing
</code>```

I would like to little automatized that and add to it code that will paste value in to field in access and run macro in access that start calculation, but I have not knowidge about manageing other office parts from inside excel. The text box name is "txt_PasteField" and VBA macro in access is name "run_calculation", I try something like this below but objShell do not allow such actions.

```<code>Dim objShell As Object

Set objShell = CreateObject("Shell.Application")
objShell.Open "\\acrtnd\share$\PUBLIC\!tools\preportDST.accdb"
     objShell.txt_PasteField.Value = Sheets("dashboard").Cells(5, 1).Value
     call objShell.run_calculation
Set objShell = Nothing
</code>```

Can someone provide be way to do that or navigate me to needed command?
Thanks in advance for helping.

答:
I'll try to help you, but I'm still a little unclear on the details. Since a text field has to be either on a form or a report, you have to open it first. Also, if you want to influence the Access application after opening it, you will need to use OLE automation.

Dim appAccess As Object
Set appAccess = CreateObject("Access.Application")
With appAccess
    .OpenCurrentDatabase "\\acrtnd\share$\PUBLIC\!tools\preportDST.accdb"
    .UserControl = True
    .DoCmd.OpenForm "MyForm"
    .Forms!MyForm.txt_PasteField.Value = Sheets("dashboard").Cells(5, 1).Value
    .Run "run_calculation"
End With
```

Body:
I have a code that open access from excel:

Dim objShell As Object

Set objShell = CreateObject("Shell.Application")
objShell.Open "\\acrtnd\share$\PUBLIC\!tools\preportDST.accdb"
Set objShell = Nothing

I would like to little automatized that and add to it code that will paste value in to field in access and run macro in access that start calculation, but I have not knowidge about manageing other office parts from inside excel. The text box name is "txt_PasteField" and VBA macro in access is name "run_calculation", I try something like this below but objShell do not allow such actions.

Dim objShell As Object

Set objShell = CreateObject("Shell.Application")
objShell.Open "\\acrtnd\share$\PUBLIC\!tools\preportDST.accdb"
     objShell.txt_PasteField.Value = Sheets("dashboard").Cells(5, 1).Value
     call objShell.run_calculation
Set objShell = Nothing

Can someone provide be way to do that or navigate me to needed command?
Thanks in advance for helping.


问:
can I modify the consumer auto-offset-reset to latest of kafka stream？
Working with kafka 0.10.1.0, I used these config

```<code>val props = new Properties
props.put(StreamsConfig.APPLICATION_ID_CONFIG, applicationId)
props.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, broker)
props.put(StreamsConfig.KEY_SERDE_CLASS_CONFIG, Serdes.String.getClass)
props.put(StreamsConfig.VALUE_SERDE_CLASS_CONFIG, Serdes.Integer.getClass)
props.put(StreamsConfig.consumerPrefix(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG), "latest")
</code>```

but these code props.put(StreamsConfig.consumerPrefix(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG), "latest")
does not work, what is the reason?

I read the code of org.apache.kafka.streams.StreamsConfig, there has some code:

```<code>private static final Map<String, Object> CONSUMER_DEFAULT_OVERRIDES;
static
{
    Map<String, Object> tempConsumerDefaultOverrides = new HashMap<>();
    tempConsumerDefaultOverrides.put(ConsumerConfig.MAX_POLL_RECORDS_CONFIG, "1000");
    tempConsumerDefaultOverrides.put(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, "earliest");
    tempConsumerDefaultOverrides.put(ConsumerConfig.ENABLE_AUTO_COMMIT_CONFIG, "false");

    CONSUMER_DEFAULT_OVERRIDES = Collections.unmodifiableMap(tempConsumerDefaultOverrides);
}

public Map<String, Object> getConsumerConfigs(StreamThread streamThread, String groupId, String clientId) throws ConfigException {
    final Map<String, Object> consumerProps = getClientPropsWithPrefix(CONSUMER_PREFIX, ConsumerConfig.configNames());

    // disable auto commit and throw exception if there is user overridden values,
    // this is necessary for streams commit semantics
    if (consumerProps.containsKey(ConsumerConfig.ENABLE_AUTO_COMMIT_CONFIG)) {
        throw new ConfigException("Unexpected user-specified consumer config " + ConsumerConfig.ENABLE_AUTO_COMMIT_CONFIG
                + ", as the streams client will always turn off auto committing.");
    }

    consumerProps.putAll(CONSUMER_DEFAULT_OVERRIDES);

    // bootstrap.servers should be from StreamsConfig
    consumerProps.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, this.originals().get(BOOTSTRAP_SERVERS_CONFIG));
    // add client id with stream client id prefix, and group id
    consumerProps.put(ConsumerConfig.GROUP_ID_CONFIG, groupId);
    consumerProps.put(CommonClientConfigs.CLIENT_ID_CONFIG, clientId + "-consumer");

    // add configs required for stream partition assignor
    consumerProps.put(StreamsConfig.InternalConfig.STREAM_THREAD_INSTANCE, streamThread);
    consumerProps.put(StreamsConfig.REPLICATION_FACTOR_CONFIG, getInt(REPLICATION_FACTOR_CONFIG));
    consumerProps.put(StreamsConfig.NUM_STANDBY_REPLICAS_CONFIG, getInt(NUM_STANDBY_REPLICAS_CONFIG));
    consumerProps.put(ConsumerConfig.PARTITION_ASSIGNMENT_STRATEGY_CONFIG, StreamPartitionAssignor.class.getName());
    consumerProps.put(StreamsConfig.WINDOW_STORE_CHANGE_LOG_ADDITIONAL_RETENTION_MS_CONFIG, getLong(WINDOW_STORE_CHANGE_LOG_ADDITIONAL_RETENTION_MS_CONFIG));
    if (!getString(ZOOKEEPER_CONNECT_CONFIG).equals("")) {
        consumerProps.put(StreamsConfig.ZOOKEEPER_CONNECT_CONFIG, getString(ZOOKEEPER_CONNECT_CONFIG));
    }

    consumerProps.put(APPLICATION_SERVER_CONFIG, getString(APPLICATION_SERVER_CONFIG));
    return consumerProps;
}
</code>```

It will be use the CONSUMER_DEFAULT_OVERRIDES override the config of I set?

答:
This is a bug of 0.10.1.0,which is fixed in 0.10.1.1 and beyond.
https://issues.apache.org/jira/browse/KAFKA-4361</p>

Body:
Working with kafka 0.10.1.0, I used these config

val props = new Properties
props.put(StreamsConfig.APPLICATION_ID_CONFIG, applicationId)
props.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, broker)
props.put(StreamsConfig.KEY_SERDE_CLASS_CONFIG, Serdes.String.getClass)
props.put(StreamsConfig.VALUE_SERDE_CLASS_CONFIG, Serdes.Integer.getClass)
props.put(StreamsConfig.consumerPrefix(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG), "latest")

but these code props.put(StreamsConfig.consumerPrefix(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG), "latest")
does not work, what is the reason?

I read the code of org.apache.kafka.streams.StreamsConfig, there has some code:

private static final Map<String, Object> CONSUMER_DEFAULT_OVERRIDES;
static
{
    Map<String, Object> tempConsumerDefaultOverrides = new HashMap<>();
    tempConsumerDefaultOverrides.put(ConsumerConfig.MAX_POLL_RECORDS_CONFIG, "1000");
    tempConsumerDefaultOverrides.put(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, "earliest");
    tempConsumerDefaultOverrides.put(ConsumerConfig.ENABLE_AUTO_COMMIT_CONFIG, "false");

    CONSUMER_DEFAULT_OVERRIDES = Collections.unmodifiableMap(tempConsumerDefaultOverrides);
}

public Map<String, Object> getConsumerConfigs(StreamThread streamThread, String groupId, String clientId) throws ConfigException {
    final Map<String, Object> consumerProps = getClientPropsWithPrefix(CONSUMER_PREFIX, ConsumerConfig.configNames());

    // disable auto commit and throw exception if there is user overridden values,
    // this is necessary for streams commit semantics
    if (consumerProps.containsKey(ConsumerConfig.ENABLE_AUTO_COMMIT_CONFIG)) {
        throw new ConfigException("Unexpected user-specified consumer config " + ConsumerConfig.ENABLE_AUTO_COMMIT_CONFIG
                + ", as the streams client will always turn off auto committing.");
    }

    consumerProps.putAll(CONSUMER_DEFAULT_OVERRIDES);

    // bootstrap.servers should be from StreamsConfig
    consumerProps.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, this.originals().get(BOOTSTRAP_SERVERS_CONFIG));
    // add client id with stream client id prefix, and group id
    consumerProps.put(ConsumerConfig.GROUP_ID_CONFIG, groupId);
    consumerProps.put(CommonClientConfigs.CLIENT_ID_CONFIG, clientId + "-consumer");

    // add configs required for stream partition assignor
    consumerProps.put(StreamsConfig.InternalConfig.STREAM_THREAD_INSTANCE, streamThread);
    consumerProps.put(StreamsConfig.REPLICATION_FACTOR_CONFIG, getInt(REPLICATION_FACTOR_CONFIG));
    consumerProps.put(StreamsConfig.NUM_STANDBY_REPLICAS_CONFIG, getInt(NUM_STANDBY_REPLICAS_CONFIG));
    consumerProps.put(ConsumerConfig.PARTITION_ASSIGNMENT_STRATEGY_CONFIG, StreamPartitionAssignor.class.getName());
    consumerProps.put(StreamsConfig.WINDOW_STORE_CHANGE_LOG_ADDITIONAL_RETENTION_MS_CONFIG, getLong(WINDOW_STORE_CHANGE_LOG_ADDITIONAL_RETENTION_MS_CONFIG));
    if (!getString(ZOOKEEPER_CONNECT_CONFIG).equals("")) {
        consumerProps.put(StreamsConfig.ZOOKEEPER_CONNECT_CONFIG, getString(ZOOKEEPER_CONNECT_CONFIG));
    }

    consumerProps.put(APPLICATION_SERVER_CONFIG, getString(APPLICATION_SERVER_CONFIG));
    return consumerProps;
}

It will be use the CONSUMER_DEFAULT_OVERRIDES override the config of I set?


问:
ReyclerView isn't working
I'm trying to show list of my model on recyclerview. but for some reason it doesnt show anything. I'm getting my list items from FirebaseDatabase and save all the data on "videoList". Then i want to presents the data that i have received, but it doesnt show anything.

Please tell me what i'm doing wrong.

```<code>  public class MyPlayListFragment extends Fragment {
    private FirebaseDatabase refToVideos;
    private FirebaseUser currentUser;
    private ArrayList<Video> videosList;
    private VideoViewAdapter adapter;
    private RecyclerView rvVideos;

public MyPlayListFragment() {
    // Required empty public constructor
}

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    View v = inflater.inflate(R.layout.fragment_my_play_list, container, false);
    rvVideos = (RecyclerView)v.findViewById(R.id.rvVideos);

    return v;
}

@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    videosList = new ArrayList<>();
    refToVideos = FirebaseDatabase.getInstance();
    currentUser = FirebaseAuth.getInstance().getCurrentUser();

    refToVideos.getReference(Params.VIDEOS).addListenerForSingleValueEvent(new ValueEventListener() {
        @Override
        public void onDataChange(DataSnapshot dataSnapshot) {
            for (DataSnapshot snapshot : dataSnapshot.getChildren()){
                videosList.add(snapshot.getValue(Video.class));
            }
        }

        @Override
        public void onCancelled(DatabaseError databaseError) {

        }
    });

    adapter = new VideoViewAdapter(getContext(),videosList);
    rvVideos.setLayoutManager(new LinearLayoutManager(getContext()));
    rvVideos.setAdapter(adapter);

}

public class VideoViewAdapter extends RecyclerView.Adapter<VideoViewHolder>{
  private LayoutInflater inflater;
  private Context context;
  private ArrayList<Video> data;

  public VideoViewAdapter( Context context, ArrayList<Video> data) {
      this.context = context;
      this.inflater = LayoutInflater.from(context);
      this.data = data;
  }

  @Override
  public VideoViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
      View v = inflater.inflate(R.layout.video_item,parent,false);
      return new VideoViewHolder(v);
  }

  @Override
  public void onBindViewHolder(VideoViewHolder holder, int position) {
      Video video = data.get(position);
      holder.tvTitleVideo.setText(video.getVideoName());
      holder.tvLikes.setText(String.valueOf(video.getLikes()));
      holder.tvViews.setText(String.valueOf(video.getViews()));
      Uri uri = Uri.parse(video.getVideoURL());
      holder.videoViewUser.setVideoURI(uri);
      holder.videoViewUser.start();

  }

  @Override
  public int getItemCount() {
      return 0;
  }
}

public  class VideoViewHolder extends RecyclerView.ViewHolder{
    private TextView tvTitleVideo,tvLikes,tvViews;
    private VideoView videoViewUser;

    public VideoViewHolder(View itemView) {
        super(itemView);
        tvTitleVideo = (TextView) itemView.findViewById(R.id.videoTitle);
        tvLikes = (TextView)itemView.findViewById(R.id.tvLikes);
        tvViews = (TextView)itemView.findViewById(R.id.tvViews);
        videoViewUser = (VideoView)itemView.findViewById(R.id.videoViewUser);

      }
    }

 }
</code>```

答:
You are using below code

```<code> @Override
 public int getItemCount() {
  return 0;
 }
</code>```

You are returning zero. This is the reason that nothing is shown. You need to return data list size. in Your case it should be videosList.size()

Title: ReyclerView isn't working

Body:
I'm trying to show list of my model on recyclerview. but for some reason it doesnt show anything. I'm getting my list items from FirebaseDatabase and save all the data on "videoList". Then i want to presents the data that i have received, but it doesnt show anything.

Please tell me what i'm doing wrong.

  public class MyPlayListFragment extends Fragment {
    private FirebaseDatabase refToVideos;
    private FirebaseUser currentUser;
    private ArrayList<Video> videosList;
    private VideoViewAdapter adapter;
    private RecyclerView rvVideos;

public MyPlayListFragment() {
    // Required empty public constructor
}

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    View v = inflater.inflate(R.layout.fragment_my_play_list, container, false);
    rvVideos = (RecyclerView)v.findViewById(R.id.rvVideos);

    return v;
}

@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    videosList = new ArrayList<>();
    refToVideos = FirebaseDatabase.getInstance();
    currentUser = FirebaseAuth.getInstance().getCurrentUser();

    refToVideos.getReference(Params.VIDEOS).addListenerForSingleValueEvent(new ValueEventListener() {
        @Override
        public void onDataChange(DataSnapshot dataSnapshot) {
            for (DataSnapshot snapshot : dataSnapshot.getChildren()){
                videosList.add(snapshot.getValue(Video.class));
            }
        }

        @Override
        public void onCancelled(DatabaseError databaseError) {

        }
    });

    adapter = new VideoViewAdapter(getContext(),videosList);
    rvVideos.setLayoutManager(new LinearLayoutManager(getContext()));
    rvVideos.setAdapter(adapter);

}

public class VideoViewAdapter extends RecyclerView.Adapter<VideoViewHolder>{
  private LayoutInflater inflater;
  private Context context;
  private ArrayList<Video> data;

  public VideoViewAdapter( Context context, ArrayList<Video> data) {
      this.context = context;
      this.inflater = LayoutInflater.from(context);
      this.data = data;
  }

  @Override
  public VideoViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
      View v = inflater.inflate(R.layout.video_item,parent,false);
      return new VideoViewHolder(v);
  }

  @Override
  public void onBindViewHolder(VideoViewHolder holder, int position) {
      Video video = data.get(position);
      holder.tvTitleVideo.setText(video.getVideoName());
      holder.tvLikes.setText(String.valueOf(video.getLikes()));
      holder.tvViews.setText(String.valueOf(video.getViews()));
      Uri uri = Uri.parse(video.getVideoURL());
      holder.videoViewUser.setVideoURI(uri);
      holder.videoViewUser.start();

  }

  @Override
  public int getItemCount() {
      return 0;
  }
}

public  class VideoViewHolder extends RecyclerView.ViewHolder{
    private TextView tvTitleVideo,tvLikes,tvViews;
    private VideoView videoViewUser;

    public VideoViewHolder(View itemView) {
        super(itemView);
        tvTitleVideo = (TextView) itemView.findViewById(R.id.videoTitle);
        tvLikes = (TextView)itemView.findViewById(R.id.tvLikes);
        tvViews = (TextView)itemView.findViewById(R.id.tvViews);
        videoViewUser = (VideoView)itemView.findViewById(R.id.videoViewUser);

      }
    }

 }

Body:
You are using below code

 @Override
 public int getItemCount() {
  return 0;
 }

You are returning zero. This is the reason that nothing is shown. You need to return data list size. in Your case it should be videosList.size()