问:
How can I resolve a relative path to absolute path in golang?
Is there a api like 'path.resolve' in node? Or something can do the same?

For Example (nodejs code):
path.resolve("~/sample.sh")
Should got: /home/currentuser/sample.sh

答:
Resolving ~ (denoting the user home) is a different story, and usually it's the shell that resolves this. For details see Expand tilde to home directory.

If you want to do it from Go code, you may use the user.Current() function to get details about the current user, including its home folder which will be User.HomeDir. But still, you'll have to handle replacing this yourself.

Original answer follows.

You may use path.Join() or filepath.Join().

For example:

```<code>base := "/home/bob"
fmt.Println(path.Join(base, "work/go", "src/github.com"))
</code>```

Output:

```<code>/home/bob/work/go/src/github.com
</code>```

You may use path.Clean() and filepath.Clean() to "remove" dots . and double dots .. from  your path.

You may use filepath.Abs() to resolve relative paths and get an absolute (prepending the working directory if it's not absolute). filepath.Abs() also calls Clean() on the result.

For example:

```<code>fmt.Println(filepath.Abs("/home/bob/../alice"))
</code>```

Outputs:

```<code>/home/alice <nil>
</code>```

Try the examples on the Go Playground.

See related question: Resolving absolute path from relative path

Body:
Resolving ~ (denoting the user home) is a different story, and usually it's the shell that resolves this. For details see Expand tilde to home directory.

If you want to do it from Go code, you may use the user.Current() function to get details about the current user, including its home folder which will be User.HomeDir. But still, you'll have to handle replacing this yourself.

Original answer follows.

You may use path.Join() or filepath.Join().

For example:

base := "/home/bob"
fmt.Println(path.Join(base, "work/go", "src/github.com"))

Output:

/home/bob/work/go/src/github.com

You may use path.Clean() and filepath.Clean() to "remove" dots . and double dots .. from  your path.

You may use filepath.Abs() to resolve relative paths and get an absolute (prepending the working directory if it's not absolute). filepath.Abs() also calls Clean() on the result.

For example:

fmt.Println(filepath.Abs("/home/bob/../alice"))

Outputs:

/home/alice <nil>

Try the examples on the Go Playground.

See related question: Resolving absolute path from relative path


来源: stackexchange

问:
How do objects turn into arrays?
Example：

```<code>obj={"name":"111","age":"1111"}
</code>```

become

```<code>["name":"111","age":"111"]
</code>```

How do you do it? I don't know what to do

答:
**Array is ordered data structure (one of a Object) ! if you added array to property keys like this example array.length becomes 0 (lost index values). so don't use property keys with arrays ! use array to build up a ordered data structure **

var obj = {"name":"111","age":"1111"};
var arr = [];

for(var prop in obj){

 arr[prop] = obj[prop];

};

now arr becomes => [name: "111", age: "1111"];```

ContentLicense: CC BY-SA 3.0

Title: How do objects turn into arrays?

Body:
Example：

obj={"name":"111","age":"1111"}

become

["name":"111","age":"111"]

How do you do it? I don't know what to do


问:
Clear:both to stack two divs on top of eachother (inside parent div)
I have managed to achieve stacking two divs on top of eachother for the mobile at 480px by using clear:both (.vd-grid-xtra-box). They are inside a parent div. Unfortunately, I am trying to set them both at 100% width for the mobile but they are not responding. Why is this the case?

```<code><!doctype html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<title>Vivid Shop Display</title>
<link rel="stylesheet" href='css/vivid-style.css'>
<link rel='stylesheet' href='css/scroller.css'>
<link href="https://fonts.googleapis.com/css?family=Montserrat" rel="stylesheet">
</head>

<body>
<header>
<div class="vd-navigation-wrapper">
     <div class="vd-settings-wrapper">
        <div class="vd-user-settings">
        </div>
        <div class="vd-currency-selector">
        </div>
        <div class="vd-language-selector">
        </div>
     </div>
     <div class="vd-nav-wrapper">
            <ul>
                <li>Shop</li>
                <li>About</li>
                <li class="vd-logo-img"><img src="img/vivid_logo.png"/></li>
                <li>Lookbook</li>
                <li>Contact</li>
            </ul>
     </div>
      <div class="vd-cart-wrapper">
       <div class="vd-cart-selector"></div>
      </div>

</div>

<!--Mobile Navigation-->
  <nav class="vd-hide">
  <div class="header-top clearfix">
   <a class="nav toggle-menu" href="#">
      <i></i>
      <i></i>
      <i></i>
    </a>
    <h1 class="logo"><a href="#firstSection"><img src="img/harva_logo.png"/></a></h1>
  </div>
    <ul id="menu">
      <li data-menuanchor="firstSection">
        <a href="#firstSection" title="First Section">First Section</a>
      </li>
      <li data-menuanchor="secondSection">
        <a href="#secondSection" title="Second Section">Second Section</a>
      </li>
      <li data-menuanchor="thirdSection">
        <a href="#thirdSection" title="Second Section">Third Section</a>
      </li>
      <li data-menuanchor="fourthSection">
        <a href="#fourthSection" title="Fourth Section">Fourth Section</a>
      </li>
      <li data-menuanchor="fifthSection">
        <a href="#fifthSection" title="First Slide">First Slide</a>
      </li>
      <li data-menuanchor="fifthSection/1">
        <a href="#fifthSection/1" title="Second Slide">Second Slide</a>
      </li>
    </ul>
  </nav>
  </div>
 </header>
<!--End Mobile Navigation-->

<div class="vd-page-container">
 <div class="vd-grid">
  <div class="vd-grid-left-col">
    <div class="vd-grid-main-box vd-margin-bottom">
     <div class="vd-text-wrap">
        <h1>Header Text</h1>
        <h2>Secondary Title</h2>
        <p>Featured Text Here over two lines
if needed place here.</p>
</div>
    </div>

    <div class="vd-grid-sub-box">
        <h3>Header Text</h3>
        <p>Featured Text Here over two lines
if needed place here.</p>
    </div>
    <div class="vd-grid-sub-box vd-margin-right vd-margin-left">
        <h3>Header Text</h3>
        <p>Featured Text Here over two lines
if needed place here.</p>
    </div>
    <div class="vd-grid-sub-box">
        <h3>Header Text</h3>
        <p>Featured Text Here over two lines
if needed place here.</p>
    </div>
   </div>
    <div class="vd-grid-right-col vd-margin-left">
     <div class="vd-grid-xtra-box">
      <h4>Header Text</h4>
      <p>Featured Text Here over two lines
if needed place here.</p>
     </div>
      <div class="vd-grid-xtra-box vd-margin-top vd-margin-bottom">
     <h4>Header Text</h4>
      <p>Featured Text Here over two lines
if needed place here.</p>
     </div>
    </div>
 </div>
</div>
<div class="clear"></div>
    <footer class="vd-footer">
       <div class="vd-widget-area">
        <div class="vd-footer-text">
            <h4 class="vd-footer-title">V I V I D - SHOPIFY THEME</h4>
          <div class="rte">V I V I D is a customisable theme that looks and feels fantastic. Showcase your products on the visually stunning V I V I D Grid and choose your structure then let V I V I D do the rest!</div>
        </div>
          <div class="vd-footer-links">
              <h4 class="vd-footer-title">HELP</h4>
            <ul>
                <li><a class="" href="#">HELP | FAQ'S</a></li>
                <li><a class="" href="#">RETURNS</a></li>
                <li><a class="" href="#">HOW TO SHOP</a></li>
                <li><a class="" href="#">CONTACT US</a></li>
                <li><a class="" href="#">STOCKISTS</a></li>
            </ul>
          </div>
         <div class="vd-footer-links">
          <h4 class="vd-footer-title">POLICIES</h4>
            <ul>
                <li><a class="" href="#">DELIVERY & RETURNS POLICY</a></li>
                <li><a class="" href="#">TERMS & CONDITIONS</a></li>
                <li><a class="" href="#">PRIVACY POLICY</a></li>
                <li><a class="" href="#">SECURITY POLICY</a></li>
            </ul>
          </div>
    <div class="vd-footer-links">
         <h4 class="vd-footer-title">CONNECT</h4>
            <ul>
                <li><a class="vd-social-icon facebook" href="#" target="_blank">FACEBOOK</a></li>
                <li><a class="vd-social-icon twitter" href="#" target="_blank">TWITTER</a></li>
                <li><a class="vd-social-icon instagram" href="#" target="_blank">INSTAGRAM</a></li>
                <li><a class="vd-social-icon vimeo" href="#" target="_blank">VIMEO</a></li>
            </ul>
          </div>
        <div class="vd-signup">
            <h4 class="vd-footer-title">SIGN UP TO OUR NEWSLETTER</h4>
          <div class="wht">HTML Block to be added here for embedded email capture forms</div>
        </div>
    </div>
  <div class="vd-sub-footer">
      <ul class="vd-payment-options">
          <li class="vd-payment-icon american-express"></li>
          <li class="vd-payment-icon bitcoin"></li>
          <li class="vd-payment-icon jcb"></li>
          <li class="vd-payment-icon master"></li>
          <li class="vd-payment-icon paypal"></li>
          <li class="vd-payment-icon visa"></li>
      </ul>
    <div class="vd-copyright-wrapper">
      <p class="vd-copyright">Copyright © 2017 V I V I D Themes.</p>
      <p class="vd-attribution">"Virtual Visual Merchandising"</p>
    </div>
  </div>
</footer>
</body>
</html>
</code>```

CSS:

```<code>@charset "UTF-8";

/* CSS Document */

/*Vivid Global Styling*/

html {} body {
  margin: 0px;
  padding: 0px;
}
h1,
h2,
h3,
h4,
h5,
h6,
p,
ul,
li,
span {
  margin: 0px;
  padding: 0px;
}
h1 {
  margin: 0 0 14px 0;
}
h2 {
  margin: 0 0 10px 0;
}
.wht {
  color: #fff;
}
.clear {
  clear: both;
}
/*Vivid Page Settings*/

header {
  width: 100%;
  background-color: #fff;
  border-bottom: #000 1px solid;
}
.vd-hide {
  display: none;
}
.vd-settings-wrapper {
  width: 15%;
  max-width: 200px;
}
.vd-user-settings {
  width: 48px;
  height: 48px;
  border: 1px solid #000;
  background-color: #fff;
  float: left;
  margin: 12px 2px 0 21px;
}
.vd-currency-selector {
  width: 58px;
  height: 21px;
  border: 1px solid #000;
  background-color: #fff;
  float: left;
  margin: 12px 2px 1px 2px;
}
.vd-language-selector {
  width: 58px;
  height: 21px;
  border: 1px solid #000;
  background-color: #fff;
  float: left;
  margin: 3px 2px 0 2px;
}
/*Vivid Main Navigation*/

.vd-nav-wrapper {
  width: 75%;
  height: 78px;
  margin: 0 auto;
  text-align: center;
}
.vd-nav-wrapper ul {
  font-family: 'Montserrat', sans-serif;
  text-align: center;
  list-style: none;
  padding: 0;
  margin: 0;
}
.vd-nav-wrapper li {
  text-decoration: none;
  list-style: none;
  display: inline-block;
  margin: 22px 20px;
  vertical-align: middle;
}
.vd-nav-wrapper a {
  text-decoration: none;
  list-style: none;
  display: inline-block;
  margin: 18px 20px;
  vertical-align: middle;
}
.vd-logo-img {
  margin: 0px;
  padding: 0px;
}
/*Vivid Checkout Settings*/

.vd-cart-wrapper {
  width: 10%;
  z-index: 10;
}
.vd-cart-selector {
  width: 48px;
  height: 48px;
  border: 1px solid #000;
  background-color: #fff;
  margin: -11px 31px 0 2px;
  position: absolute;
  top: 23px;
  right: -9px;
}
/*Vivid Main Wrapper*/

.vd-page-container {
  width: 100%;
  margin: 0 auto;
}
/*Vivid Grid*/

.vd-grid h1,
h2,
h3,
h4,
h5,
h6 {
  font-family: 'Montserrat', sans-serif;
  line-height: 32px;
  color: #fff;
}
.vd-grid p,
span {
  font-family: "Gill Sans", "Gill Sans MT", "Myriad Pro", "DejaVu Sans Condensed", Helvetica, Arial, sans-serif;
  line-height: 17px;
  font-size: 0.85em;
  margin: 0;
  padding: 0;
  color: #fff;
}
.vd-grid h1 {
  margin: 0;
  padding: 0;
}
.vd-grid h2 {
  font-size: 1.2em;
  margin: 0 0 4px 0;
}
.vd-grid h3 {
  margin: 4px 0 4px 0;
}
.vd-grid h4 {
  margin: 4px 0 4px 0;
}
.vd-grid {
  width: 98.6%;
  margin: 13px auto;
}
.vd-grid-left-col {
  width: 77.6%;
  float: left;
}
.vd-grid-right-col {
  width: 20.8%;
  float: left;
}
.vd-grid-main-box {
  width: 93.5%;
  height: 460px;
  background-color: #000029;
  padding: 3.2%;
}
.vd-grid-main-box img {
  width: 100%;
  height: auto;
  position: absolute;
}
.vd-grid-sub-box {
  width: 30.8%;
  height: 159px;
  background-image: url(../img/granda_hj.jpg);
  background-size: cover;
  background-position: top center;
  background-color: #000029;
  float: left;
  padding: 0.9%;
  margin: 0 0 1% 0.2%;
}
.vd-grid-xtra-box {
  width: 94%;
  height: 332px;
  background-image: url(../img/tst_img.jpg);
  background-size: cover;
  background-position: center center;
  background-color: #000029;
  padding: 3%;
}
.vd-text-wrap {
  width: 100%;
  position: relative;
  top: 340px;
  left: 0px;
}
.vd-margin-top {
  margin-top: 4%;
}
.vd-margin-right {
  /*! margin-right:10px; */
  margin-right: 1%;
}
.vd-margin-left {
  /*! margin-left:10px; */
  margin-left: 0.8%;
}
.vd-margin-bottom {
  margin-bottom: 1%;
}
/*Vivid Footer*/

.vd-footer {
  font-family: "Gill Sans", "Gill Sans MT", "Myriad Pro", "DejaVu Sans Condensed", Helvetica, Arial, sans-serif;
  line-height: 16px;
  padding: 0 30px;
  padding-bottom: 55px;
  background-color: #000029;
  -webkit-transition: opacity 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94), -webkit-transform 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  -moz-transition: opacity 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94), -moz-transform 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  transition: opacity 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94), transform 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}
.vd-widget-area {
  padding: 15px 0 10px;
  border-top: 0px solid #e5e5e5;
  max-width: 1260px;
  margin: 0 auto 0px;
}
.vd-footer-text {
  display: inline-block;
  vertical-align: top;
  width: 26%;
  padding-right: 60px;
  font-size: 12px;
  color: white;
  -moz-font-smoothing: none;
  font-smoothing: antialiased;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
.vd-footer-links {
  display: inline-block;
  vertical-align: top;
  padding: 0 30px 25px 0;
  width: 12%;
  line-height: 22px;
  font-size: 12px;
  color: white;
}
.vd-footer-links ul {
  margin: 0;
  padding: 0;
  list-style: outside none;
  display: block;
  vertical-align: top;
}
.vd-footer-links li {
  font-size: 12px;
  color: white;
  text-decoration: none;
}
.vd-footer-links a {
  font-size: 12px;
  color: #ccc;
  text-decoration: none;
}
.vd-footer-links a:hover {
  font-size: 12px;
  color: white;
}
.vd-footer-title {
  font-family: 'Montserrat', sans-serif;
}
.vd-signup {
  display: inline-block;
  max-width: 305px;
  width: 26%;
  font-size: 12px;
}
.vd-sub-footer {
  border-top: 1px solid #e5e5e5;
  padding-top: 25px;
  margin-top: 0px;
  font-size: 0;
  max-width: 1260px;
  margin: 0 auto;
}
/*Vivid Payment Icons*/

.vd-payment-icon {
  font-size: 20px;
  vertical-align: middle;
  line-height: 1.2;
  color: #a7a7a7;
}
.vd-footer-linklist .vd-social-icon:before {
  font-size: 16px;
  width: 16px;
  text-align: center;
  margin-right: 5px;
  font-family: 'Social Icons';
  display: inline-block;
  vertical-align: middle;
  line-height: 1;
  font-weight: normal;
  font-style: normal;
  speak: none;
  text-decoration: inherit;
  text-transform: none;
  text-rendering: optimizeLegibility;
  -moz-font-smoothing: none;
  font-smoothing: antialiased;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
.vd-payment-options {
  float: right;
  width: 50%;
  margin: 0;
  padding: 0;
  text-align: right;
  font-size: 12px;
  text-decoration: none;
  display: block;
  list-style: outside none;
}
.vd-payment-options ul {
  display: block-inline;
  list-style-type: outside none;
}
.vd-payment-options li {
  display: block-inline;
  float: right;
  padding: 0 0 0 10px;
  list-style-type: outside none;
}
.american-express:before {
  content: "\f001";
}
.bitcoin:before {
  content: "\f006";
}
.jcb:before {
  content: "\f028";
}
.master:before {
  content: "\f02d";
}
.paypal:before {
  content: "\f033";
}
.visa:before {
  content: "\f045";
}
/*Vivid Copyright*/

.vd-copyright-wrapper {
  float: left;
  margin: 0;
  width: 50%;
  font-size: 12px;
  color: white;
  -moz-font-smoothing: none;
  font-smoothing: antialiased;
  -webkit-font-smoothing: antialiased;
}
/*Vivid Responsive*/

@media (min--moz-device-pixel-ratio: 1.3),
(-o-min-device-pixel-ratio: 2.6/2),
(-webkit-min-device-pixel-ratio: 1.3),
(min-device-pixel-ratio: 1.3),
(min-resolution: 1.3dppx) {}

@media screen and (max-width: 928px) {
  .vd-grid-left-col {
    width: 100%;
  }
  .vd-grid-right-col {
    overflow: hidden;
    width: 100%;
    margin: 0;
    clear: both;
  }
  .vd-grid-right-col > div {
    width: 49%;
    box-sizing: border-box;
    margin: 0;
  }
  .vd-grid-right-col > div:first-child {
    margin-right:2%;
  }
  .vd-grid-xtra-box {
    float: left;
  }
  .vd-footer{
    margin-top: 20px;
  }
}

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

    .vd-grid-sub-box {

        width: 100%;
    }

    .vd-grid-xtra-box {

    clear: both;
    width: 100%
    display: block;

    }

    .vd-grid-right-col {

    width: 100%

    }
}
</code>```

答:
Have you tried calling it inside media queries like below?

```<code>@media all and (max-width:480px) {
 .vd-grid-xtra-box{
   width:100%;
   float:none;
   clear:both;
 }
}
</code>```

Hope this will work out for you. Also make sure that you haven't used !important code property to above class in any other css rule.

Body:
I have managed to achieve stacking two divs on top of eachother for the mobile at 480px by using clear:both (.vd-grid-xtra-box). They are inside a parent div. Unfortunately, I am trying to set them both at 100% width for the mobile but they are not responding. Why is this the case?

<!doctype html>

<meta charset="UTF-8">
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<title>Vivid Shop Display</title>
<link rel="stylesheet" href='css/vivid-style.css'>
<link rel='stylesheet' href='css/scroller.css'>
<link href="https://fonts.googleapis.com/css?family=Montserrat" rel="stylesheet">

Shop

About

Lookbook

Contact

        First Section

        Second Section

        Third Section

        Fourth Section

        First Slide

        Second Slide

Header Text

Secondary Title

Featured Text Here over two lines
if needed place here.

Header Text

Featured Text Here over two lines
if needed place here.

Header Text

Featured Text Here over two lines
if needed place here.

Header Text

Featured Text Here over two lines
if needed place here.

Header Text

Featured Text Here over two lines
if needed place here.

Header Text

Featured Text Here over two lines
if needed place here.

V I V I D - SHOPIFY THEME

V I V I D is a customisable theme that looks and feels fantastic. Showcase your products on the visually stunning V I V I D Grid and choose your structure then let V I V I D do the rest!

HELP

HELP | FAQ'S

RETURNS

HOW TO SHOP

CONTACT US

STOCKISTS

POLICIES

DELIVERY & RETURNS POLICY

TERMS & CONDITIONS

PRIVACY POLICY

SECURITY POLICY

CONNECT

FACEBOOK

TWITTER

INSTAGRAM

VIMEO

SIGN UP TO OUR NEWSLETTER

HTML Block to be added here for embedded email capture forms

Copyright © 2017 V I V I D Themes.

"Virtual Visual Merchandising"

CSS:

@charset "UTF-8";

/* CSS Document */

/*Vivid Global Styling*/

html {} body {
  margin: 0px;
  padding: 0px;
}
h1,
h2,
h3,
h4,
h5,
h6,
p,
ul,
li,
span {
  margin: 0px;
  padding: 0px;
}
h1 {
  margin: 0 0 14px 0;
}
h2 {
  margin: 0 0 10px 0;
}
.wht {
  color: #fff;
}
.clear {
  clear: both;
}
/*Vivid Page Settings*/

header {
  width: 100%;
  background-color: #fff;
  border-bottom: #000 1px solid;
}
.vd-hide {
  display: none;
}
.vd-settings-wrapper {
  width: 15%;
  max-width: 200px;
}
.vd-user-settings {
  width: 48px;
  height: 48px;
  border: 1px solid #000;
  background-color: #fff;
  float: left;
  margin: 12px 2px 0 21px;
}
.vd-currency-selector {
  width: 58px;
  height: 21px;
  border: 1px solid #000;
  background-color: #fff;
  float: left;
  margin: 12px 2px 1px 2px;
}
.vd-language-selector {
  width: 58px;
  height: 21px;
  border: 1px solid #000;
  background-color: #fff;
  float: left;
  margin: 3px 2px 0 2px;
}
/*Vivid Main Navigation*/

.vd-nav-wrapper {
  width: 75%;
  height: 78px;
  margin: 0 auto;
  text-align: center;
}
.vd-nav-wrapper ul {
  font-family: 'Montserrat', sans-serif;
  text-align: center;
  list-style: none;
  padding: 0;
  margin: 0;
}
.vd-nav-wrapper li {
  text-decoration: none;
  list-style: none;
  display: inline-block;
  margin: 22px 20px;
  vertical-align: middle;
}
.vd-nav-wrapper a {
  text-decoration: none;
  list-style: none;
  display: inline-block;
  margin: 18px 20px;
  vertical-align: middle;
}
.vd-logo-img {
  margin: 0px;
  padding: 0px;
}
/*Vivid Checkout Settings*/

.vd-cart-wrapper {
  width: 10%;
  z-index: 10;
}
.vd-cart-selector {
  width: 48px;
  height: 48px;
  border: 1px solid #000;
  background-color: #fff;
  margin: -11px 31px 0 2px;
  position: absolute;
  top: 23px;
  right: -9px;
}
/*Vivid Main Wrapper*/

.vd-page-container {
  width: 100%;
  margin: 0 auto;
}
/*Vivid Grid*/

.vd-grid h1,
h2,
h3,
h4,
h5,
h6 {
  font-family: 'Montserrat', sans-serif;
  line-height: 32px;
  color: #fff;
}
.vd-grid p,
span {
  font-family: "Gill Sans", "Gill Sans MT", "Myriad Pro", "DejaVu Sans Condensed", Helvetica, Arial, sans-serif;
  line-height: 17px;
  font-size: 0.85em;
  margin: 0;
  padding: 0;
  color: #fff;
}
.vd-grid h1 {
  margin: 0;
  padding: 0;
}
.vd-grid h2 {
  font-size: 1.2em;
  margin: 0 0 4px 0;
}
.vd-grid h3 {
  margin: 4px 0 4px 0;
}
.vd-grid h4 {
  margin: 4px 0 4px 0;
}
.vd-grid {
  width: 98.6%;
  margin: 13px auto;
}
.vd-grid-left-col {
  width: 77.6%;
  float: left;
}
.vd-grid-right-col {
  width: 20.8%;
  float: left;
}
.vd-grid-main-box {
  width: 93.5%;
  height: 460px;
  background-color: #000029;
  padding: 3.2%;
}
.vd-grid-main-box img {
  width: 100%;
  height: auto;
  position: absolute;
}
.vd-grid-sub-box {
  width: 30.8%;
  height: 159px;
  background-image: url(../img/granda_hj.jpg);
  background-size: cover;
  background-position: top center;
  background-color: #000029;
  float: left;
  padding: 0.9%;
  margin: 0 0 1% 0.2%;
}
.vd-grid-xtra-box {
  width: 94%;
  height: 332px;
  background-image: url(../img/tst_img.jpg);
  background-size: cover;
  background-position: center center;
  background-color: #000029;
  padding: 3%;
}
.vd-text-wrap {
  width: 100%;
  position: relative;
  top: 340px;
  left: 0px;
}
.vd-margin-top {
  margin-top: 4%;
}
.vd-margin-right {
  /*! margin-right:10px; */
  margin-right: 1%;
}
.vd-margin-left {
  /*! margin-left:10px; */
  margin-left: 0.8%;
}
.vd-margin-bottom {
  margin-bottom: 1%;
}
/*Vivid Footer*/

.vd-footer {
  font-family: "Gill Sans", "Gill Sans MT", "Myriad Pro", "DejaVu Sans Condensed", Helvetica, Arial, sans-serif;
  line-height: 16px;
  padding: 0 30px;
  padding-bottom: 55px;
  background-color: #000029;
  -webkit-transition: opacity 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94), -webkit-transform 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  -moz-transition: opacity 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94), -moz-transform 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  transition: opacity 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94), transform 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}
.vd-widget-area {
  padding: 15px 0 10px;
  border-top: 0px solid #e5e5e5;
  max-width: 1260px;
  margin: 0 auto 0px;
}
.vd-footer-text {
  display: inline-block;
  vertical-align: top;
  width: 26%;
  padding-right: 60px;
  font-size: 12px;
  color: white;
  -moz-font-smoothing: none;
  font-smoothing: antialiased;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
.vd-footer-links {
  display: inline-block;
  vertical-align: top;
  padding: 0 30px 25px 0;
  width: 12%;
  line-height: 22px;
  font-size: 12px;
  color: white;
}
.vd-footer-links ul {
  margin: 0;
  padding: 0;
  list-style: outside none;
  display: block;
  vertical-align: top;
}
.vd-footer-links li {
  font-size: 12px;
  color: white;
  text-decoration: none;
}
.vd-footer-links a {
  font-size: 12px;
  color: #ccc;
  text-decoration: none;
}
.vd-footer-links a:hover {
  font-size: 12px;
  color: white;
}
.vd-footer-title {
  font-family: 'Montserrat', sans-serif;
}
.vd-signup {
  display: inline-block;
  max-width: 305px;
  width: 26%;
  font-size: 12px;
}
.vd-sub-footer {
  border-top: 1px solid #e5e5e5;
  padding-top: 25px;
  margin-top: 0px;
  font-size: 0;
  max-width: 1260px;
  margin: 0 auto;
}
/*Vivid Payment Icons*/

.vd-payment-icon {
  font-size: 20px;
  vertical-align: middle;
  line-height: 1.2;
  color: #a7a7a7;
}
.vd-footer-linklist .vd-social-icon:before {
  font-size: 16px;
  width: 16px;
  text-align: center;
  margin-right: 5px;
  font-family: 'Social Icons';
  display: inline-block;
  vertical-align: middle;
  line-height: 1;
  font-weight: normal;
  font-style: normal;
  speak: none;
  text-decoration: inherit;
  text-transform: none;
  text-rendering: optimizeLegibility;
  -moz-font-smoothing: none;
  font-smoothing: antialiased;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
.vd-payment-options {
  float: right;
  width: 50%;
  margin: 0;
  padding: 0;
  text-align: right;
  font-size: 12px;
  text-decoration: none;
  display: block;
  list-style: outside none;
}
.vd-payment-options ul {
  display: block-inline;
  list-style-type: outside none;
}
.vd-payment-options li {
  display: block-inline;
  float: right;
  padding: 0 0 0 10px;
  list-style-type: outside none;
}
.american-express:before {
  content: "\f001";
}
.bitcoin:before {
  content: "\f006";
}
.jcb:before {
  content: "\f028";
}
.master:before {
  content: "\f02d";
}
.paypal:before {
  content: "\f033";
}
.visa:before {
  content: "\f045";
}
/*Vivid Copyright*/

.vd-copyright-wrapper {
  float: left;
  margin: 0;
  width: 50%;
  font-size: 12px;
  color: white;
  -moz-font-smoothing: none;
  font-smoothing: antialiased;
  -webkit-font-smoothing: antialiased;
}
/*Vivid Responsive*/

@media (min--moz-device-pixel-ratio: 1.3),
(-o-min-device-pixel-ratio: 2.6/2),
(-webkit-min-device-pixel-ratio: 1.3),
(min-device-pixel-ratio: 1.3),
(min-resolution: 1.3dppx) {}

@media screen and (max-width: 928px) {
  .vd-grid-left-col {
    width: 100%;
  }
  .vd-grid-right-col {
    overflow: hidden;
    width: 100%;
    margin: 0;
    clear: both;
  }
  .vd-grid-right-col > div {
    width: 49%;
    box-sizing: border-box;
    margin: 0;
  }
  .vd-grid-right-col > div:first-child {
    margin-right:2%;
  }
  .vd-grid-xtra-box {
    float: left;
  }
  .vd-footer{
    margin-top: 20px;
  }
}

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

    .vd-grid-sub-box {

        width: 100%;
    }

    .vd-grid-xtra-box {

    clear: both;
    width: 100%
    display: block;

    }

    .vd-grid-right-col {

    width: 100%

    }
}

Body:
Have you tried calling it inside media queries like below?

@media all and (max-width:480px) {
 .vd-grid-xtra-box{
   width:100%;
   float:none;
   clear:both;
 }
}

Hope this will work out for you. Also make sure that you haven't used !important code property to above class in any other css rule.


问:
r create adjacency matrix or edge list from adjacency list
I have an adjacency list and I am trying to make it into and adjacency matrix or edge list. This is in order to conduct network analysis on the network built from the adjacency matrix or edge list. I am using R.
An example of adjacency list is as follows (each row has different amount of entries, and the empty entries are NA):

```<code>[17,50,90,NA,NA;
80,67,NA,NA,NA;
33,31,32, NA,NA;
33,31,32,NA,NA;
354,56,87,97,32;
....]
</code>```

I tried using R: Adjacency list to Adjacency matrix but this only works if my adjacency list has two entries (ie there are more than two neighbors in a group). I get an edge list but only taking into account the first two entries in my list.

I also tried using From list to adjacency matrix but using igraph and make_graph(unlist(mydata)) led to the error: "At type_indexededgelist.c:117 : cannot create empty graph with negative number of vertices, Invalid value"

I need an adjacency matrix which takes into account the weights that would be in the network (like if entry 31 and 32 are in two rows, then their edge weight would be 2).
Thank you for any help.

Body:
I have an adjacency list and I am trying to make it into and adjacency matrix or edge list. This is in order to conduct network analysis on the network built from the adjacency matrix or edge list. I am using R.
An example of adjacency list is as follows (each row has different amount of entries, and the empty entries are NA):

[17,50,90,NA,NA;
80,67,NA,NA,NA;
33,31,32, NA,NA;
33,31,32,NA,NA;
354,56,87,97,32;
....]

I tried using R: Adjacency list to Adjacency matrix but this only works if my adjacency list has two entries (ie there are more than two neighbors in a group). I get an edge list but only taking into account the first two entries in my list.

I also tried using From list to adjacency matrix but using igraph and make_graph(unlist(mydata)) led to the error: "At type_indexededgelist.c:117 : cannot create empty graph with negative number of vertices, Invalid value"

I need an adjacency matrix which takes into account the weights that would be in the network (like if entry 31 and 32 are in two rows, then their edge weight would be 2).
Thank you for any help.

Body:
I have an adjacency list and I am trying to make it into an[...] edge list.

Maybe you could do

lst <- read.csv(header=F, comment.char=";", colClasses="integer", text="
17,50,90,NA,NA;
80,67,NA,NA,NA;
33,31,32,NA,NA;
33,31,32,NA,NA;
354,56,87,97,32;")
m <- as.matrix(lst)
e <- stack(split(m, row(m)))[,2:1]
(e <- e[complete.cases(e),])
# 1    1     17
# 2    1     50
# 3    1     90
# 6    2     80
# 7    2     67
# 11   3     33
# 12   3     31
# 13   3     32
# 16   4     33
# 17   4     31
# 18   4     32
# 21   5    354
# 22   5     56
# 23   5     87
# 24   5     97
# 25   5     32

or

e <- apply(lst, 1, function(x)x[!is.na(x)])
(e <- do.call(rbind, lapply(e, embed, 2))[,2:1])
#      [,1] [,2]
# [1,]   17   50
# [2,]   50   90
# [3,]   80   67
# [4,]   33   31
# [5,]   31   32
# [6,]   33   31
# [7,]   31   32
# [8,]  354   56
# [9,]   56   87
# [10,]   87   97
# [11,]   97   32

depending on what you need/what your "adjacency list" represents.


问:
Get xml attributes and values using ruby
I am using nokogiri library in ruby to parse a webpage. I am getting the XML result as:

```<code>#<Nokogiri::XML::Element:0x1399140 name="p" children=[#<Nokogiri::XML::Text:0x1398264 "\n">,
#<Nokogiri::XML::Element:0x1395d50 name="i" attributes=[#<Nokogiri::XML::Attr:0x1395cb4 name="class" value="icon-pctgrm p-01_g">,
#<Nokogiri::XML::Attr:0x1395ca8 name="title" value="new">]>,
#<Nokogiri::XML::Text:0x1394e20 "\n">]>
</code>```

From this result I need to get the final result as class:icon-pctgrm p-01_g, title:new

答:
First save the xml as test.xml in the same directory of this script and then run this-

```<code>require 'nokogiri'

File.foreach(File.open("test.xml")) do |line|
  if /Attr/.match(line)
    print line.split('name=')[-1].split('"')[1] + ":" + line.split('value=')[1].split('"')[1] + ", "
  end
end
</code>```

This will give the expected result as- class:icon-pctgrm p-01_g, title:new,

Body:
I am using nokogiri library in ruby to parse a webpage. I am getting the XML result as:

#<Nokogiri::XML::Element:0x1399140 name="p" children=[#<Nokogiri::XML::Text:0x1398264 "\n">,
#<Nokogiri::XML::Element:0x1395d50 name="i" attributes=[#<Nokogiri::XML::Attr:0x1395cb4 name="class" value="icon-pctgrm p-01_g">,
#<Nokogiri::XML::Attr:0x1395ca8 name="title" value="new">]>,
#<Nokogiri::XML::Text:0x1394e20 "\n">]>

From this result I need to get the final result as class:icon-pctgrm p-01_g, title:new

Body:
First save the xml as test.xml in the same directory of this script and then run this-

require 'nokogiri'

File.foreach(File.open("test.xml")) do |line|
  if /Attr/.match(line)
    print line.split('name=')[-1].split('"')[1] + ":" + line.split('value=')[1].split('"')[1] + ", "
  end
end

This will give the expected result as- class:icon-pctgrm p-01_g, title:new,


问:
Ansible tries to connect to VM IP before executing the role creating the VM
I'm trying to develop an Ansible script to generate a VM. I wrote a myvm role that contains the script that orchestrates vmware_guest. This script contains a delegate_to: localhost which vmware_guest requires.

Then, I added my new-to-be-vm to hosts, and added the following to hosts:

```<code>[myvms]
myvm1
</code>```

and extended site.yml with:

```<code>- hosts: myvms
  roles:
    - myvm
</code>```

Now, when I run:

ansible-playbook site.yml -i hosts --limit myvm1

it fails with:

fatal: [myvm1]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: Connection reset by 192.168.10.13 port 22\r\n", "unreachable": true}

It seems ansible tries to connect to the vm ip before reading the actual role that creates the vm where it delegates to localhost. Adding 'delegate_to' to site.yml fails, however.

How can I fix my Ansible scripts to properly generate the VM for me?

答:
Add gather_facts: false to the play.

```<code>- hosts: myvms
  gather_facts: false
  roles:
    - myvm
</code>```

Ansible by default connects to target machines and runs script which collect data (facts).

Body:
I'm trying to develop an Ansible script to generate a VM. I wrote a myvm role that contains the script that orchestrates vmware_guest. This script contains a delegate_to: localhost which vmware_guest requires.

Then, I added my new-to-be-vm to hosts, and added the following to hosts:

[myvms]
myvm1

and extended site.yml with:

- hosts: myvms
  roles:
    - myvm

Now, when I run:

ansible-playbook site.yml -i hosts --limit myvm1

it fails with:

fatal: [myvm1]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: Connection reset by 192.168.10.13 port 22\r\n", "unreachable": true}

It seems ansible tries to connect to the vm ip before reading the actual role that creates the vm where it delegates to localhost. Adding 'delegate_to' to site.yml fails, however.

How can I fix my Ansible scripts to properly generate the VM for me?

Body:
Add gather_facts: false to the play.

- hosts: myvms
  gather_facts: false
  roles:
    - myvm

Ansible by default connects to target machines and runs script which collect data (facts).


问:
Do I need to delete an static std::map?
In some classes I have an static std::map with pointers inside. My question is if I need to delete at the end of the program or this memory is automatically freed. My concern is if the pointers stored inside are correctly deleted through our destructors when std::map is deleted.

Thanks.

答: Like in any case of storage class which stores pointers: you are responsible to deallocate memory they point to. Storage class is responsible only to clean its own resources. Relying on reclaiming memory by OS at the process termination is a bad practice. </p>

ContentLicense: CC BY-SA 2.5

Title: Do I need to delete an static std::map?


问:
How to get JSON object from another JSON object in swift 3
how can I get applicationStateJson in below code, I can parse the bellow JSON object from data but can not able to get applicationStateJson from it

```<code>{
applicationStateJson =     {
    "address_status" = 0;
    email = "xxxxxxxx;
    "email_status" = 0;
    "first_name" = xxx;
    "last_name" = "";
    "login_status" = 1;
    loginstype = "<null>";
    mobile = xxxxxx;
    "mobile_status" = 1;
    notifications =         (
    );
    "notifications_size" = 0;
    "otp_status" = 3;
    "profile_id" = "<null>";
    "profile_name" = "virtual_recruiter";
    "user_id" = 454;
    "user_status" = 1;
    "virtual_recruiter_id" =xxx;
};
"error_msg" = "<null>";
status = "<null>";
}
</code>```

code as

```<code>do {
 let json = try JSONSerialization.jsonObject(with: data, options: JSONSerialization.ReadingOptions.mutableContainers) as AnyObject
print(json)
let applicationStateJson = try json["applicationStateJson"]
} catch { print(error.localizedDescription) }
</code>```

答:
The root object of the JSON is a clearly a dictionary, not AnyObject (an object but I-have-no-idea-what-it-is).

The value for key applicationStateJson is a dictionary, too.

```<code>do {
   if let json = try JSONSerialization.jsonObject(with: data) as? [String:Any],
      let applicationStateJson = json["applicationStateJson"] as? [String:Any] {
         print(applicationStateJson)
   }
} catch {
   print(error)
}
</code>```

As always, .mutableContainers is completely meaningless in Swift

Body:
how can I get applicationStateJson in below code, I can parse the bellow JSON object from data but can not able to get applicationStateJson from it

{
applicationStateJson =     {
    "address_status" = 0;
    email = "xxxxxxxx;
    "email_status" = 0;
    "first_name" = xxx;
    "last_name" = "";
    "login_status" = 1;
    loginstype = "<null>";
    mobile = xxxxxx;
    "mobile_status" = 1;
    notifications =         (
    );
    "notifications_size" = 0;
    "otp_status" = 3;
    "profile_id" = "<null>";
    "profile_name" = "virtual_recruiter";
    "user_id" = 454;
    "user_status" = 1;
    "virtual_recruiter_id" =xxx;
};
"error_msg" = "<null>";
status = "<null>";
}

code as

do {
 let json = try JSONSerialization.jsonObject(with: data, options: JSONSerialization.ReadingOptions.mutableContainers) as AnyObject
print(json)
let applicationStateJson = try json["applicationStateJson"]
} catch { print(error.localizedDescription) }

Body:
The root object of the JSON is a clearly a dictionary, not AnyObject (an object but I-have-no-idea-what-it-is).

The value for key applicationStateJson is a dictionary, too.

do {
   if let json = try JSONSerialization.jsonObject(with: data) as? [String:Any],
      let applicationStateJson = json["applicationStateJson"] as? [String:Any] {
         print(applicationStateJson)
   }
} catch {
   print(error)
}

As always, .mutableContainers is completely meaningless in Swift


问:
What's the meaning of a ! before a command in the shell?
What is the purpose of a shell command (part of a shell script) starting with an exclamation mark?

Concrete example:

In foo.sh:

```<code>#!/usr/bin/env bash
set -e
! docker stop foo
! docker rm -f foo
# ... other stuff
</code>```

I know that without the space the exclamation mark is used for history replacements and ! <expression> according to the man page can be used to evaluate "True if expr is false". But in the example context that does not make sense to me.

答:
If you don't want the script to fail in both cases, error or success of the command, you can also use this alternative:

```<code>set -e
docker stop foo || true
</code>```

The boolean or true makes the pipeline always have 0 as the return value.

ContentLicense: CC BY-SA 4.0

Body:
What is the purpose of a shell command (part of a shell script) starting with an exclamation mark?

Concrete example:

In foo.sh:

#!/usr/bin/env bash
set -e
! docker stop foo
! docker rm -f foo
# ... other stuff

I know that without the space the exclamation mark is used for history replacements and ! <expression> according to the man page can be used to evaluate "True if expr is false". But in the example context that does not make sense to me.

Body:
If you don't want the script to fail in both cases, error or success of the command, you can also use this alternative:

set -e
docker stop foo || true

The boolean or true makes the pipeline always have 0 as the return value.


问:
Javascript loop through Json
Trying to figure out how to loop through users in the following Json response:

```<code>{ "id": 23, "users": { "26": "user 333", "27": "user 222" } }
</code>```

A normal for-loop is not working, i.e for(i = 0; i <object.users.length; i++). So I started thinking maybe it's not a normal array because there are no [] brackets. But even the simplest operation fails: alert(object.users[0]).

I need help figuring out how I can loop through each user and get both key and value (key:value).

答:
I think this may help</p>

```<code> var response = { "id": 23, "users": { "26": "user 333", "27": "user 222" }};

              var usersVar = response.users;
                 for(var key in usersVar){
                   console.log(usersVar[key]);
                 }
</code>```

Title: Javascript loop through Json

Body:
Trying to figure out how to loop through users in the following Json response:

{ "id": 23, "users": { "26": "user 333", "27": "user 222" } }

A normal for-loop is not working, i.e for(i = 0; i <object.users.length; i++). So I started thinking maybe it's not a normal array because there are no [] brackets. But even the simplest operation fails: alert(object.users[0]).

I need help figuring out how I can loop through each user and get both key and value (key:value).

Body:
I think this may help

 var response = { "id": 23, "users": { "26": "user 333", "27": "user 222" }};

              var usersVar = response.users;
                 for(var key in usersVar){
                   console.log(usersVar[key]);
                 }


问:
How to remove Input Form and paste URL directly on facebook V2.7 JQuery?
Sorry Idont know how to explain or type exact tittle on my question, anyway i will try to explain it here.

What I need?
I dont Required this
<form id="get_shares">
  <input type="text" id="url" placeholder="Input URL" size="50" />
  <button>Get shares</button>
</form> rather i need to just paste the url directly like this:
#url=http://youtube.com

My Question is how to implement this or how to do it? Thanks Guys

Here is the working code:

jQuery(function($) {
  var token = "666987483466439|b3e1a0948513223b0bc51b32a735e2cf";
  $("#get_shares").submit(function() {
    $.ajax({
      url: "https://graph.facebook.com/v2.7/",
      dataType: "jsonp",
      type: "GET",
      data: { access_token: token, id: $("#url").val() },
      success: function(data) {
        $("#results").html(data.share.share_count);
        $("#comments").html(data.share.comment_count);
      }
    });
    return false;
  });
});```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<form id="get_shares">
  <input type="text" id="url" placeholder="Input URL" size="50" />
  <button>Get shares</button>
</form>

<span><strong>Shares:</strong></span>
<span id="results">0 Shares</span>
<div></div>

<span><strong>Comments:</strong></span>
<span id="comments">0 Comments</span></code>```

答:
I solved the issued!

0

```

Body:
Sorry Idont know how to explain or type exact tittle on my question, anyway i will try to explain it here.

What I need?
I dont Required this
<form id="get_shares">
  <input type="text" id="url" placeholder="Input URL" size="50" />
  <button>Get shares</button>
</form> rather i need to just paste the url directly like this:
#url=http://youtube.com

My Question is how to implement this or how to do it? Thanks Guys

Here is the working code:

jQuery(function($) {
  var token = "666987483466439|b3e1a0948513223b0bc51b32a735e2cf";
  $("#get_shares").submit(function() {
    $.ajax({
      url: "https://graph.facebook.com/v2.7/",
      dataType: "jsonp",
      type: "GET",
      data: { access_token: token, id: $("#url").val() },
      success: function(data) {
        $("#results").html(data.share.share_count);
        $("#comments").html(data.share.comment_count);
      }
    });
    return false;
  });
});

<form id="get_shares">
  <input type="text" id="url" placeholder="Input URL" size="50" />
  <button>Get shares</button>
</form>

Shares:
0 Shares

Comments:
0 Comments

Body:
I solved the issued!

<script type="text/javascript" src="//code.jquery.com/jquery-1.12.4.js"></script>

<div id="fb-like-div">0</div>

<script type="text/javascript">

$(function(){
var url = 'http://facebook.com';
var apiUrl = 'https://graph.facebook.com/?ids='+url;
$.ajax({url: apiUrl, success: function(result){

        $.each( result, function( key, val ) {

         console.log(key + ' - ' + val['share']['share_count']);

         var shareCount = val['share']['share_count'];

         $("#fb-like-div").html(shareCount);

    });

    }});

});
</script>


问:
Sweetalert2 breaking my angular build. What to do?
While doing npm run build,

Got this error
ERROR in vendor.97ddeaba56b47c113f33.bundle.js from UglifyJs
Unexpected token: operator (>)

Body:
I think sweetalert.js file is breaking your build.

You can add sweetalert.js file in assets and provide its link in index.html

or you can use CDN link of  sweetalert.js file in index.html

Like this : <script src="https://unpkg.com/sweetalert/dist/sweetalert.min.js"></script>


问:
Bpel 12c - Call webservices with basic authentication
I'm using Oracle BPEL 12c to develop a process.

I need to call a external service with basic authentication. I need to pass the credentials received on my exposed service endpoint to the external service.

When i call, i receive this:

```<code><remoteFault xmlns="http://schemas.oracle.com/bpel/extension">
-<part name="summary">
<summary>
oracle.fabric.common.FabricException: oracle.fabric.common.FabricException: Error in getting XML input stream:XXXXXX?WSDL: Server Authentication Required: Error in getting XML input stream: XXXX?WSDL: Server Authentication Required
</summary>
</part>
-<part name="detail">
<detail>Server Authentication Required</detail>
</part>
</remoteFault>
</code>```

I tried to define on the composite, also the oracle.webservices.auth.password and oracle.webservices.auth.username password for the external service.

Also the javax.xml.ws.security.auth.username and javax.xml.ws.security.auth.password properties without sucess.

Any sugestion?

Kind regards,
Ricardo

答:
I suppose your composite snippet should look like this:

```<code><reference name="Service1" ui:wsdlLocation="test1.wsdl">
    <interface.wsdl  interface="http://tempuri.org/#wsdl.interface(IService1)"/>
    <binding.ws port="http://tempuri.org/#wsdl.endpoint(Service1/BasicHttpBinding_IService1)"  location="test1.wsdl" soapVersion="1.1">
        <property name="weblogic.wsee.wsat.transaction.flowOption" type="xs:string" many="false">WSDLDriven</property>
        <property name="oracle.webservices.auth.username" type="xs:string" many="false">test</property>
        <property name="oracle.webservices.auth.password" type="xs:string" many="false">password</property>
        <property name="oracle.webservices.preemptiveBasicAuth" type="xs:string" many="false">true</property>
    </binding.ws>
</reference>
</code>```

And also good practice to use variables when defining user and password instead of explicitly username and password

```<code>    <property name="oracle.webservices.auth.username" type="xs:string" many="false">{$username}</property>
     <property name="oracle.webservices.auth.password" type="xs:string" many="false">{$password}</property>
</code>```

and then override them in generated cfg_plan.xml while deploying composite application

```<code> <reference name="Service1">
     <!--Add search and replace rules for the binding properties-->
     <binding type="ws">
        <attribute name="port">
           <replace>{your_port}</replace>
        </attribute>
        <attribute name="location">
           <replace>{your_location}</replace>
        </attribute>
        <property name="weblogic.wsee.wsat.transaction.flowOption">
           <replace>WSDLDriven</replace>
        </property>
        <property name="oracle.webservices.auth.username">
           <replace>test</replace>
        </property>
        <property name="oracle.webservices.auth.password">
           <replace>password</replace>
        </property>
        <property name="oracle.webservices.preemptiveBasicAuth">
           <replace>true</replace>
        </property>
     </binding>
  </reference>
</code>```

Body:
I'm using Oracle BPEL 12c to develop a process.

I need to call a external service with basic authentication. I need to pass the credentials received on my exposed service endpoint to the external service.

When i call, i receive this:

<remoteFault xmlns="http://schemas.oracle.com/bpel/extension">
-<part name="summary">

oracle.fabric.common.FabricException: oracle.fabric.common.FabricException: Error in getting XML input stream:XXXXXX?WSDL: Server Authentication Required: Error in getting XML input stream: XXXX?WSDL: Server Authentication Required

</part>
-<part name="detail">
<detail>Server Authentication Required</detail>
</part>
</remoteFault>

I tried to define on the composite, also the oracle.webservices.auth.password and oracle.webservices.auth.username password for the external service.

Also the javax.xml.ws.security.auth.username and javax.xml.ws.security.auth.password properties without sucess.

Any sugestion?

Kind regards,
Ricardo

Body:
I suppose your composite snippet should look like this:

<reference name="Service1" ui:wsdlLocation="test1.wsdl">
    <interface.wsdl  interface="http://tempuri.org/#wsdl.interface(IService1)"/>
    <binding.ws port="http://tempuri.org/#wsdl.endpoint(Service1/BasicHttpBinding_IService1)"  location="test1.wsdl" soapVersion="1.1">
        <property name="weblogic.wsee.wsat.transaction.flowOption" type="xs:string" many="false">WSDLDriven</property>
        <property name="oracle.webservices.auth.username" type="xs:string" many="false">test</property>
        <property name="oracle.webservices.auth.password" type="xs:string" many="false">password</property>
        <property name="oracle.webservices.preemptiveBasicAuth" type="xs:string" many="false">true</property>
    </binding.ws>
</reference>

And also good practice to use variables when defining user and password instead of explicitly username and password

    <property name="oracle.webservices.auth.username" type="xs:string" many="false">{$username}</property>
     <property name="oracle.webservices.auth.password" type="xs:string" many="false">{$password}</property>

and then override them in generated cfg_plan.xml while deploying composite application

 <reference name="Service1">
     <!--Add search and replace rules for the binding properties-->
     <binding type="ws">
        <attribute name="port">
           <replace>{your_port}</replace>
        </attribute>
        <attribute name="location">
           <replace>{your_location}</replace>
        </attribute>
        <property name="weblogic.wsee.wsat.transaction.flowOption">
           <replace>WSDLDriven</replace>
        </property>
        <property name="oracle.webservices.auth.username">
           <replace>test</replace>
        </property>
        <property name="oracle.webservices.auth.password">
           <replace>password</replace>
        </property>
        <property name="oracle.webservices.preemptiveBasicAuth">
           <replace>true</replace>
        </property>
     </binding>
  </reference>


问:
Get php variable in JavaScript - options
I'm aware that there are similar questions, however, I have a few issues with them, as they mentioned a few possibilities and I'm not sure which one is best for my situation.

I have a form that has one section where you can enter the name of an xml-file, which is then generated using php. The name of the file is stored in a variable using php. In order to access the xml-file, I wanted to retrieve the value of the php-variable in JavaScript.
According to what I read, there are a few possibilities:

An Ajax-request. My problem: I tried to follow this tutorial (https://www.w3schools.com/xml/ajax_php.asp). I don't fully understand this tutorial though.

First of all, in the first example, what is "this"? (e.g this.responseText)

Secondly, why is it "gethint.php?q=" + str instead of simply "gethint.php" (in xmlhttp.open())?

Finally, what does $q = $_REQUEST["q"]; tell me exactly? I know that some kind of a variable is declared but I don't understand what is does exactly.

I also read that you could use cookies, but would that make sense in my instance?
Please let me know if you need further information and thank you very much in advance for your replies.

Edit: Here's the code I tried to follow:
HTML:

```<code><html>
<head>
<script>
    function showHint(str) {
        if (str.length == 0) {
            document.getElementById("txtHint").innerHTML = "";
            return;
        } else {
            var xmlhttp = new XMLHttpRequest();
            xmlhttp.onreadystatechange = function() {
            if (this.readyState == 4 && this.status == 200) {
                document.getElementById("txtHint").innerHTML = this.responseText;
            }
        };
        xmlhttp.open("GET", "gethint.php?q=" + str, true);
        xmlhttp.send();
    }
}
</script>
</head>
<body>

    <p><b>Start typing a name in the input field below:</b></p>
    <form>
        First name: <input type="text" onkeyup="showHint(this.value)">
    </form>
    <p>Suggestions: <span id="txtHint"></span></p>
</body>
</html>
</code>```

PHP:

```<code>// get the q parameter from URL
$q = $_REQUEST["q"];

$hint = "";

// lookup all hints from array if $q is different from ""
if ($q !== "") {
    $q = strtolower($q);
    $len=strlen($q);
    foreach($a as $name) {
        if (stristr($q, substr($name, 0, $len))) {
            if ($hint === "") {
                $hint = $name;
            } else {
                $hint .= ", $name";
            }
        }
    }
}

// Output "no suggestion" if no hint was found or output correct values
echo $hint === "" ? "no suggestion" : $hint;
?>
</code>```

$a is an array of names, which I did not include in the extract in order to save space.

Here's my code:

HTML:

```<code><body onload="alertFunction()">
    <h1 id="title">Append to me:</h1>
    <p id="paragraph"></p>
</body>
</code>```

JavaScript:

```<code>function alertFunction() {
    var xhttp;

    var xhttp = new XMLHttpRequest();

    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
            var filename = xhttp.responseText;
            alert(filename);
        }
    };
    xhttp.open("GET", "profile3.php?q=", true);
    xhttp.send();
};
</code>```

PHP:

```<code><?php
    $q = $_REQUEST["q"];
    echo $filename
?>
</code>```

$filename is declared to be the name of my xml-document. I did not include that piece of code because I know that that's not the problem.

答:
1. First of all, in the first example, what is "this"? (e.g this.responseText)

As simple, "this" evaluates to the value of the ThisBinding of the current execution context;ref

2. Secondly, why is it "gethint.php?q=" + str instead of simply "gethint.php" (in xmlhttp.open())?

This is nothing just passing the input value to server to get the matching result.This will treat as GET method

3.Finally, what does $q = $_REQUEST["q"]; tell me exactly? I know that some kind of a variable is declared but I don't understand what is does exactly.

This is php code to get the value form POST/GET method. From 2 the parameter is passing to serve. This can access from server using $_REQUEST["q"]

Body:
I'm aware that there are similar questions, however, I have a few issues with them, as they mentioned a few possibilities and I'm not sure which one is best for my situation.

I have a form that has one section where you can enter the name of an xml-file, which is then generated using php. The name of the file is stored in a variable using php. In order to access the xml-file, I wanted to retrieve the value of the php-variable in JavaScript.
According to what I read, there are a few possibilities:

An Ajax-request. My problem: I tried to follow this tutorial (https://www.w3schools.com/xml/ajax_php.asp). I don't fully understand this tutorial though.

First of all, in the first example, what is "this"? (e.g this.responseText)

Secondly, why is it "gethint.php?q=" + str instead of simply "gethint.php" (in xmlhttp.open())?

Finally, what does $q = $_REQUEST["q"]; tell me exactly? I know that some kind of a variable is declared but I don't understand what is does exactly.

I also read that you could use cookies, but would that make sense in my instance?
Please let me know if you need further information and thank you very much in advance for your replies.

Edit: Here's the code I tried to follow:
HTML:

Start typing a name in the input field below:

    <form>
        First name: <input type="text" onkeyup="showHint(this.value)">
    </form>

Suggestions:

PHP:

// get the q parameter from URL
$q = $_REQUEST["q"];

$hint = "";

// lookup all hints from array if $q is different from ""
if ($q !== "") {
    $q = strtolower($q);
    $len=strlen($q);
    foreach($a as $name) {
        if (stristr($q, substr($name, 0, $len))) {
            if ($hint === "") {
                $hint = $name;
            } else {
                $hint .= ", $name";
            }
        }
    }
}

// Output "no suggestion" if no hint was found or output correct values
echo $hint === "" ? "no suggestion" : $hint;
?>

$a is an array of names, which I did not include in the extract in order to save space.

Here's my code:

HTML:

Append to me:

JavaScript:

function alertFunction() {
    var xhttp;

    var xhttp = new XMLHttpRequest();

    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
            var filename = xhttp.responseText;
            alert(filename);
        }
    };
    xhttp.open("GET", "profile3.php?q=", true);
    xhttp.send();
};

PHP:

<?php
    $q = $_REQUEST["q"];
    echo $filename
?>

$filename is declared to be the name of my xml-document. I did not include that piece of code because I know that that's not the problem.


答:
If I understand the situation correctly, you don't delete the map itself. But you probably need to delete the objects the map is pointing to. It would probably be a really good idea to use a smart pointer such as Boost shared_ptr in your map instead of native pointers. Then the objects would be cleaned up automatically.

Edit:
Using Boost ptr_map might be an even better idea.

Title: Do I need to delete an static std::map?

Body:
In some classes I have an static std::map with pointers inside. My question is if I need to delete at the end of the program or this memory is automatically freed. My concern is if the pointers stored inside are correctly deleted through our destructors when std::map is deleted.

Thanks.


问:
calling elasticsearch from classic asp works against a simple search, but cannot get a complex search to work
If I send a simple query to Elastic using the following code construct, in the response back I obtain my expected results:

```<code>webaddress = "http://localhost:9200/" + index + "/_search?q='hello world'"

set xml = server.Createobject("MSXML2.ServerXMLHTTP")

xml.Open "GET", webaddress ,False

xml.setRequestHeader "Authorization", "Basic " & Base64Encode("elastic:elastic123")

xml.Send
</code>```

Now if I want to send a much more complex query such that It's not practical or possibly even possible to place the query on a single 'q' parameter as above. i.e.

the query:

```<code>get myindex/_search
{
    "query":{"match": {"headline": "overseas territory"},
             "match" : {"bodytext": "british territory"}
            }
}
</code>```

So I would build this up into a variable. lets call it mySearch

Then my webaddress becomes :

```<code>webaddress = "http://localhost:9200/" + index + "/_search"
</code>```

and xml.send becomes :

```<code>xml.Send mySearch
</code>```

mySearch gets ignored and I receive back a default first 10 records from the variable webaddress.

The above search term is built in the following way in script:

```<code>Function TermBuilder(query)

    dim queryArray
    dim termString

    queryArray = split(query," ")

    termString = "{ ""query"" :{"

    For i = LBound(queryArray) to UBound(queryArray)
        termString = termString + """match"": {""headline"": """ + queryArray(i) + """ } ,""match"": { ""bodytext"": """  + queryArray(i) + """},"

    next
    termString = mid(termString, 1, len(termString) - 1) 'remove trailing comma

    termString = termString + "}}"

    TermBuilder = termString

  End Function
</code>```

How should I pass my complex search so that it is recognised. I dont have the luxury of curl

答: Ok, I had a couple of issue's the first was that I needed to use a 'POST' as opposed to 'GET' also when I created my index, I created the properties using CamelCase notation, but in the index's _source property they were all lowercase. After deleteing the index and creating the properties using lowercase and reindexing the index, I'm now obtaining my desired records.</p>

Body:
If I send a simple query to Elastic using the following code construct, in the response back I obtain my expected results:

webaddress = "http://localhost:9200/" + index + "/_search?q='hello world'"

set xml = server.Createobject("MSXML2.ServerXMLHTTP")

xml.Open "GET", webaddress ,False

xml.setRequestHeader "Authorization", "Basic " & Base64Encode("elastic:elastic123")

xml.Send

Now if I want to send a much more complex query such that It's not practical or possibly even possible to place the query on a single 'q' parameter as above. i.e.

the query:

get myindex/_search
{
    "query":{"match": {"headline": "overseas territory"},
             "match" : {"bodytext": "british territory"}
            }
}

So I would build this up into a variable. lets call it mySearch

Then my webaddress becomes :

webaddress = "http://localhost:9200/" + index + "/_search"

and xml.send becomes :

xml.Send mySearch

mySearch gets ignored and I receive back a default first 10 records from the variable webaddress.

The above search term is built in the following way in script:

Function TermBuilder(query)

    dim queryArray
    dim termString

    queryArray = split(query," ")

    termString = "{ ""query"" :{"

    For i = LBound(queryArray) to UBound(queryArray)
        termString = termString + """match"": {""headline"": """ + queryArray(i) + """ } ,""match"": { ""bodytext"": """  + queryArray(i) + """},"

    next
    termString = mid(termString, 1, len(termString) - 1) 'remove trailing comma

    termString = termString + "}}"

    TermBuilder = termString

  End Function

How should I pass my complex search so that it is recognised. I dont have the luxury of curl


问:
jQuery validation are not working
code:

        $(document).ready(function(){
           $("#insert").click(function(event){
               event.preventDefault();
               name = $("#name").val();
               phone = $("#phone").val();
               email = $("#email").val();
               message = $("#message").val();
               if(name == '')
               {
                   $(".msg").text("Please enter your name");
               }
               else if (email !== "") {
                    if (!isValidEmailAddress(email)) {
                        $("msg").show();
                        $("#email").focus();
                        return false;
                    }
                }
           });
        });
                function isValidEmailAddress(emailAddress) {
            var pattern = new RegExp(/^(("[\w-+\s]+")|([\w-+]+(?:\.[\w-+]+)*)|("[\w-+\s]+")([\w-+]+(?:\.[\w-+]+)*))(@((?:[\w-+]+\.)*\w[\w-+]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][\d]\.|1[\d]{2}\.|[\d]{1,2}\.))((25[0-5]|2[0-4][\d]|1[\d]{2}|[\d]{1,2})\.){2}(25[0-5]|2[0-4][\d]|1[\d]{2}|[\d]{1,2})\]?$)/i);
            return pattern.test(emailAddress);
        };```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<form method="post">
  <input class="form-control1" id="name" name="name" placeholder="Enter Your Name" type="text">
  <input class="form-control1" id="email" name="email" placeholder="Enter Your Email Id"  type="text">
  <input class="form-control1" id="phone" name="phone" placeholder="Enter Your Phone"  type="text">
  <textarea class="form-control1" name="message" id="message" placeholder="Enter Your Message" ></textarea>
  <input name="insert" id="insert" value="Submit" type="submit">
 </form></code>```

In this code I have created a contact form and want to validate phone and email using jQuery. Now, when I use If statement and click on button it show me please enter your name after enter name when I click on button again it show me the same message. So, How can I fix this problem ?Please help me.

Thank You

答:
```<code>if (!isValidEmailAddress(email)) {
       $("msg").show();
       $("#email").focus();
       return false;
}
</code>```

On This code of yours correct $("msg").show(); With $(".msg").show();

Title: jQuery validation are not working

Body:
code:

        $(document).ready(function(){
           $("#insert").click(function(event){
               event.preventDefault();
               name = $("#name").val();
               phone = $("#phone").val();
               email = $("#email").val();
               message = $("#message").val();
               if(name == '')
               {
                   $(".msg").text("Please enter your name");
               }
               else if (email !== "") {
                    if (!isValidEmailAddress(email)) {
                        $("msg").show();
                        $("#email").focus();
                        return false;
                    }
                }
           });
        });
                function isValidEmailAddress(emailAddress) {
            var pattern = new RegExp(/^(("[\w-+\s]+")|([\w-+]+(?:\.[\w-+]+)*)|("[\w-+\s]+")([\w-+]+(?:\.[\w-+]+)*))(@((?:[\w-+]+\.)*\w[\w-+]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][\d]\.|1[\d]{2}\.|[\d]{1,2}\.))((25[0-5]|2[0-4][\d]|1[\d]{2}|[\d]{1,2})\.){2}(25[0-5]|2[0-4][\d]|1[\d]{2}|[\d]{1,2})\]?$)/i);
            return pattern.test(emailAddress);
        };

<form method="post">
  <input class="form-control1" id="name" name="name" placeholder="Enter Your Name" type="text">
  <input class="form-control1" id="email" name="email" placeholder="Enter Your Email Id"  type="text">
  <input class="form-control1" id="phone" name="phone" placeholder="Enter Your Phone"  type="text">
  <textarea class="form-control1" name="message" id="message" placeholder="Enter Your Message" ></textarea>
  <input name="insert" id="insert" value="Submit" type="submit">
 </form>

In this code I have created a contact form and want to validate phone and email using jQuery. Now, when I use If statement and click on button it show me please enter your name after enter name when I click on button again it show me the same message. So, How can I fix this problem ?Please help me.

Thank You

Body:
if (!isValidEmailAddress(email)) {
       $("msg").show();
       $("#email").focus();
       return false;
}

On This code of yours correct $("msg").show(); With $(".msg").show();


问:
Select nested sublist of a list based on condition in R
I do have the following simple example of a nested list:

```<code>list(list(structure(list(group = "a", def = "control"), .Names =  c("group",
"def"))), list(structure(list(group = "b", def = "disease1"), .Names = c("group",
"def"))))
</code>```

The structure is as follows:

```<code>str(t1)
List of 2
$ :List of 1
..$ :List of 2
.. ..$ group: chr "a"
.. ..$ def  : chr "control"
$ :List of 1
..$ :List of 2
.. ..$ group: chr "b"
.. ..$ def  : chr "disease1"
</code>```

Is there an easy way of getting only the nested list that satisfies a specific condition. As an example, if I knew only the name of the group, e.g., "a", how would I get the according sublist; in the example, this would be the first nested list:

```<code>[[1]]
[[1]]$group
[1] "a"

[[1]]$def
[1] "control"
</code>```

So essentially I am looking for a way to apply group == "a" in this nested list structure.

答:
We can extract a sublist of a list using lapply. We can write a function as well.

```<code>get_sublist <- function(group_name) {
   lst[lapply(lst, function(x) x[[1]][[1]]) == group_name]
}

get_sublist("a")
#[[1]]
#[[1]][[1]]
#[[1]][[1]]$group
#[1] "a"

#[[1]][[1]]$def
#[1] "control"

get_sublist("b")
#[[1]]
#[[1]][[1]]
#[[1]][[1]]$group
#[1] "b"

#[[1]][[1]]$def
#[1] "disease1"
</code>```

Body:
I do have the following simple example of a nested list:

list(list(structure(list(group = "a", def = "control"), .Names =  c("group",
"def"))), list(structure(list(group = "b", def = "disease1"), .Names = c("group",
"def"))))

The structure is as follows:

str(t1)
List of 2
$ :List of 1
..$ :List of 2
.. ..$ group: chr "a"
.. ..$ def  : chr "control"
$ :List of 1
..$ :List of 2
.. ..$ group: chr "b"
.. ..$ def  : chr "disease1"

Is there an easy way of getting only the nested list that satisfies a specific condition. As an example, if I knew only the name of the group, e.g., "a", how would I get the according sublist; in the example, this would be the first nested list:

[[1]]
[[1]]$group
[1] "a"

[[1]]$def
[1] "control"

So essentially I am looking for a way to apply group == "a" in this nested list structure.

Body:
We can extract a sublist of a list using lapply. We can write a function as well.

get_sublist <- function(group_name) {
   lst[lapply(lst, function(x) x[[1]][[1]]) == group_name]
}

get_sublist("a")
#[[1]]
#[[1]][[1]]
#[[1]][[1]]$group
#[1] "a"

#[[1]][[1]]$def
#[1] "control"

get_sublist("b")
#[[1]]
#[[1]][[1]]
#[[1]][[1]]$group
#[1] "b"

#[[1]][[1]]$def
#[1] "disease1"


问:
No module named sympy
Hi I'm learning linear algebra with python with an Edx course. (http://nbviewer.ipython.org/github/ULAFF/notebooks/tree/may-14-2014/).

On "02.4.2.10 Practice with matrix-vector multiplication" with the first box, the code is:

```<code>import generate_problems as gp
print("What is the result of the matrix vector product below?")

p = gp.Problem()

p.new_problem()
</code>```

generate_problems is a module that the professor at Edx created. However, I got an error importing sympy.

I got the error below:

```<code>---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-10-79d56e0988cb> in <module>()
----> 1 import generate_problems as gp
      2 print("What is the result of the matrix vector product below?")
      3
      4 p = gp.Problem()
      5

/Users/user/Desktop/Course/Python/ipython/notebooks-master/generate_problems.py in <module>()
      2 from numpy import matrix
      3
----> 4 from sympy import init_printing, Matrix, MatMul, latex, Rational, zeros
      5 from IPython.display import Math
      6

ImportError: No module named sympy
</code>```

I downloaded and installed sympy and it works in sympy directory in the terminal(Mac OS X yosemite) if I import.Could someone help me?

答:
you can also do it in the jupyter notebook. Write in a cell this, and Run that cell:

```<code>!pip install --upgrade
!pip install sympy
import sympy
</code>```

If your kernel uses python3, then use "pip3" instead. You may have to do Kernel->Restart, if it doesn't work straight away.

If it still doesn't find the module because Jupyter doesn't load the correct folder where it is installed. then consider doing either

```<code>import sys
sys.path.append('my/path/to/module/folder')
#the (successful) line "!pip install sympy " should tell you where this path is
</code>```

or (on the bash terminal)

```<code>echo "PYTHONPATH=\"$PYTHONPATH:my/path/to/module/folder\"" >> ~/.bashrc
source ~/.bashrc
# then restart jupyter notebook
</code>```

Title: No module named sympy

Body:
Hi I'm learning linear algebra with python with an Edx course. (http://nbviewer.ipython.org/github/ULAFF/notebooks/tree/may-14-2014/).

On "02.4.2.10 Practice with matrix-vector multiplication" with the first box, the code is:

import generate_problems as gp
print("What is the result of the matrix vector product below?")

p = gp.Problem()

p.new_problem()

generate_problems is a module that the professor at Edx created. However, I got an error importing sympy.

I got the error below:

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-10-79d56e0988cb> in <module>()
----> 1 import generate_problems as gp
      2 print("What is the result of the matrix vector product below?")
      3
      4 p = gp.Problem()
      5

/Users/user/Desktop/Course/Python/ipython/notebooks-master/generate_problems.py in <module>()
      2 from numpy import matrix
      3
----> 4 from sympy import init_printing, Matrix, MatMul, latex, Rational, zeros
      5 from IPython.display import Math
      6

ImportError: No module named sympy

I downloaded and installed sympy and it works in sympy directory in the terminal(Mac OS X yosemite) if I import.Could someone help me?

Body:
you can also do it in the jupyter notebook. Write in a cell this, and Run that cell:

!pip install --upgrade
!pip install sympy
import sympy

If your kernel uses python3, then use "pip3" instead. You may have to do Kernel->Restart, if it doesn't work straight away.

If it still doesn't find the module because Jupyter doesn't load the correct folder where it is installed. then consider doing either

import sys
sys.path.append('my/path/to/module/folder')
#the (successful) line "!pip install sympy " should tell you where this path is

or (on the bash terminal)

echo "PYTHONPATH=\"$PYTHONPATH:my/path/to/module/folder\"" >> ~/.bashrc
source ~/.bashrc
# then restart jupyter notebook


问:
How to create automate tasks on Odoo 10?
I'm trying to create a task that runs periodicaly.

I made this file on a directory called 'Data' and added it to the manifest file :

```<code><?xml version="1.0" encoding="utf-8"?>
<odoo>
<data noupdate="1">
        <record id="ir_cron_scheduler_action" model="ir.cron">
            <field name="name">scheduler</field>
            <field name="user_id" ref="base.user_root"/>
            <field name="interval_number">1</field>
            <field name="interval_type">minutes</field>
            <field name="numbercall">-1</field>
             <field eval="False" name="doall"/>
            <field eval="'res.company'" name="model"/>
            <field eval="'refresh'" name="function"/>
         </record>
   </data>
</code>```

and I have the following method on that model

```<code>def refresh(self):
    _logger.info(' This is a test')
</code>```

But it seems is not working, doesn't print on the logger.
Any Idea?

答:
As @Karaka Mohamed said, you should add @api.model to your method. And then, I would add some attributes to the XML like args, to specify empty arguments, or nextcall, in which you have to indicate the date of the first execution of the cron task. It should be a future date, unless you set the attribute doall to True (this will run the non-executed cron tasks of the past).

From that nextcall date on, your cron task will be executed every minute forever (as you specified in your definition).

An example, with this line your task will be executed for the first time five minutes after being generated:

```<code><field name="args" eval="'()'"/>
<field name="nextcall" eval="(DateTime.now() + timedelta(minutes=5)).strftime('%Y-%m-%d 00:00:00')" />
</code>```

Warning: as you have set <data noupdate="1"> at the top of your XML document, changes made here are not going to be updated in the database. So, you can set these changes directly in PostgreSQL, in ir_cron table, or you can modify the XML ID of the cron task, to create a new one the following time you upgrade your module.

Body:
I'm trying to create a task that runs periodicaly.

I made this file on a directory called 'Data' and added it to the manifest file :

<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data noupdate="1">
        <record id="ir_cron_scheduler_action" model="ir.cron">
            <field name="name">scheduler</field>
            <field name="user_id" ref="base.user_root"/>
            <field name="interval_number">1</field>
            <field name="interval_type">minutes</field>
            <field name="numbercall">-1</field>
             <field eval="False" name="doall"/>
            <field eval="'res.company'" name="model"/>
            <field eval="'refresh'" name="function"/>
         </record>
   </data>

and I have the following method on that model

def refresh(self):
    _logger.info(' This is a test')

But it seems is not working, doesn't print on the logger.
Any Idea?

Body:
As @Karaka Mohamed said, you should add @api.model to your method. And then, I would add some attributes to the XML like args, to specify empty arguments, or nextcall, in which you have to indicate the date of the first execution of the cron task. It should be a future date, unless you set the attribute doall to True (this will run the non-executed cron tasks of the past).

From that nextcall date on, your cron task will be executed every minute forever (as you specified in your definition).

An example, with this line your task will be executed for the first time five minutes after being generated:

<field name="args" eval="'()'"/>
<field name="nextcall" eval="(DateTime.now() + timedelta(minutes=5)).strftime('%Y-%m-%d 00:00:00')" />

Warning: as you have set <data noupdate="1"> at the top of your XML document, changes made here are not going to be updated in the database. So, you can set these changes directly in PostgreSQL, in ir_cron table, or you can modify the XML ID of the cron task, to create a new one the following time you upgrade your module.


问:
How to know if a closed GitHub issue was fixed or not?
There is an issue on the Rust GitHub repository that someone else opened where I am interested in a solution being provided. The issue is closed, but I don't know if it has been solved or not.

I read the GitHub help pages about issues, but I didn't find what I am looking for.

How can I find out the reason of the closing of that issue? Is this issue fixed? Did they include macros for creating e.g. HashMaps with initial values into the standard library?

答:
From the comment chain you can see

rust-highfive closed this on 25 Dec 2014

You can also see the same user added a comment just before closing the issue

This issue has been moved to the RFCs repo: rust-lang/rfcs#542

The linked RFC (Request for Comments) is still open implying that it is still open for discussion.

The lifetime for Rust RFCs can be seen at the-rfc-life-cycle.

It appears the most popular consensus is to current use the maplit crate.


问:
How to download file from server using nodejs
I want to download file from other website to my pc using expressjs

I tried to use: res.download to download but it seems to be worked on my own server only

Here is my code:

```<code>res.download('http://apkleecher.com/download/dl.php?dl=com.instagram.android', 'folder', function(err){
                if (err) {
                    console.log(err);
                } else {

                }
            });
</code>```

And it return the error:

{ Error: ENOENT: no such file or directory, stat '/home/keitaro/Desktop/google-play/http:/apkleecher.com/download/dl.php?dl=com.instagram.android'
    errno: -2,
    code: 'ENOENT',
    syscall: 'stat',
    path: '/home/keitaro/Desktop/google-play/http:/apkleecher.com/download/dl.php?dl=com.instagram.android',
    expose: false,
    statusCode: 404,
    status: 404 }

In my guess, the problem is in the path of url.

答:
res.download requires a path to your local filesystem.

try this:

res.redirect("http://apkleecher.com/download/dl.php?dl=com.instagram.android")

Body:
I want to download file from other website to my pc using expressjs

I tried to use: res.download to download but it seems to be worked on my own server only

Here is my code:

res.download('http://apkleecher.com/download/dl.php?dl=com.instagram.android', 'folder', function(err){
                if (err) {
                    console.log(err);
                } else {

                }
            });

And it return the error:

{ Error: ENOENT: no such file or directory, stat '/home/keitaro/Desktop/google-play/http:/apkleecher.com/download/dl.php?dl=com.instagram.android'
    errno: -2,
    code: 'ENOENT',
    syscall: 'stat',
    path: '/home/keitaro/Desktop/google-play/http:/apkleecher.com/download/dl.php?dl=com.instagram.android',
    expose: false,
    statusCode: 404,
    status: 404 }

In my guess, the problem is in the path of url.


答:
Try this one instead of alert you can use $('.msg') but in your code, i'm found any .msg class element so there I used the alert instead.

```<code>   <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
    <script>
        function isValidEmailAddress(emailAddress) {
            var pattern = new RegExp(/^(("[\w-+\s]+")|([\w-+]+(?:\.[\w-+]+)*)|("[\w-+\s]+")([\w-+]+(?:\.[\w-+]+)*))(@((?:[\w-+]+\.)*\w[\w-+]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][\d]\.|1[\d]{2}\.|[\d]{1,2}\.))((25[0-5]|2[0-4][\d]|1[\d]{2}|[\d]{1,2})\.){2}(25[0-5]|2[0-4][\d]|1[\d]{2}|[\d]{1,2})\]?$)/i);
            return pattern.test(emailAddress);
        };
    </script>
    <script>
        $(document).ready(function(){
           $("#insert").click(function(event){

               event.preventDefault();
               name = $("#name").val();
               phone = $("#phone").val();
               email = $("#email").val();
               message = $("#message").val();
               if(name == '')
               {
                  alert("Please enter your name");
                   return false;
               }

                var filter = /^[0-9+]+$/;
                if (!filter.test(phone)){

                    alert("Invalid Phone");
                    return false;
               }
               if (!isValidEmailAddress(email)) {
                        alert("Invalid Email");
                        $("#email").focus();
                        return false;
               }

           });
        });
    </script>

    <form method="post">

        <input class="form-control1" id="name" name="name" placeholder="Enter Your Name" type="text">
        <input class="form-control1" id="email" name="email" placeholder="Enter Your Email Id"  type="text">
        <input class="form-control1" id="phone" name="phone" placeholder="Enter Your Phone"  type="text">
        <textarea class="form-control1" name="message" id="message" placeholder="Enter Your Message" ></textarea>
        <input name="insert" id="insert" value="Submit" type="submit">
    </form>
</code>```

Title: jQuery validation are not working

Body:
Try this one instead of alert you can use $('.msg') but in your code, i'm found any .msg class element so there I used the alert instead.

   <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
    <script>
        function isValidEmailAddress(emailAddress) {
            var pattern = new RegExp(/^(("[\w-+\s]+")|([\w-+]+(?:\.[\w-+]+)*)|("[\w-+\s]+")([\w-+]+(?:\.[\w-+]+)*))(@((?:[\w-+]+\.)*\w[\w-+]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][\d]\.|1[\d]{2}\.|[\d]{1,2}\.))((25[0-5]|2[0-4][\d]|1[\d]{2}|[\d]{1,2})\.){2}(25[0-5]|2[0-4][\d]|1[\d]{2}|[\d]{1,2})\]?$)/i);
            return pattern.test(emailAddress);
        };
    </script>
    <script>
        $(document).ready(function(){
           $("#insert").click(function(event){

               event.preventDefault();
               name = $("#name").val();
               phone = $("#phone").val();
               email = $("#email").val();
               message = $("#message").val();
               if(name == '')
               {
                  alert("Please enter your name");
                   return false;
               }

                var filter = /^[0-9+]+$/;
                if (!filter.test(phone)){

                    alert("Invalid Phone");
                    return false;
               }
               if (!isValidEmailAddress(email)) {
                        alert("Invalid Email");
                        $("#email").focus();
                        return false;
               }

           });
        });
    </script>

    <form method="post">

        <input class="form-control1" id="name" name="name" placeholder="Enter Your Name" type="text">
        <input class="form-control1" id="email" name="email" placeholder="Enter Your Email Id"  type="text">
        <input class="form-control1" id="phone" name="phone" placeholder="Enter Your Phone"  type="text">
        <textarea class="form-control1" name="message" id="message" placeholder="Enter Your Message" ></textarea>
        <input name="insert" id="insert" value="Submit" type="submit">
    </form>


问:
Using function in Javascript
Example:

```<code>function pcs()
{
    var t1 = document.getElementById("tot1").value
    var pb = document.getElementById("pcbox").value
    var pc = ""

    if (t1==! && pb==!)
    {
        document.getElementId("rbox").innerHTML = ""
    }
}
</code>```

My question is if t1 and pb are null the function pcs() is not called... Why?

答:
if(t1==! && pb==!) --> this is absolutly wrong.... What are you trying to check?

Maybe if(t1!="" && pb!="")?

OwnerDisplayName: aravinth

LastEditorDisplayName: RoBorg

Title: Using function in Javascript

Body:
Example:

function pcs()
{
    var t1 = document.getElementById("tot1").value
    var pb = document.getElementById("pcbox").value
    var pc = ""

    if (t1==! && pb==!)
    {
        document.getElementId("rbox").innerHTML = ""
    }
}

My question is if t1 and pb are null the function pcs() is not called... Why?

OwnerDisplayName: Sergio


问:
Web app getting zoomed in chrome
I am making a react application. When I open the application in chrome browser, it gets zoomed in. I have to zoom out chrome to 75% to see the actual applicatio. In 100% my application looks all zoomed. Why is this happening and how can I solve it?</p>

答:
Check your head section for metatag declaration. Mostly there should be the problem with user-scalable value. It should be 1.0 for perfect result.

Here is the full code for correct meta tag

<meta name="viewport" content="width=device-width, initial-scale=1">

<meta name="viewport" content="initial-scale=1.0, user-scalable=no" /> ```

If its not working well for you, please share your website link to review further.

Title: Web app getting zoomed in chrome

Body:
Check your head section for metatag declaration. Mostly there should be the problem with user-scalable value. It should be 1.0 for perfect result.

Here is the full code for correct meta tag

<!-- For 100% page rendering -->

<meta name="viewport" content="width=device-width, initial-scale=1">

<!-- OR
* To lock the zoom of the page -->

<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />

If its not working well for you, please share your website link to review further.


问:
Jenkins error: FATAL: null -- java.lang.NullPointerException
Jenkins sometimes reports an error and sometimes my build goes perfect:

Error:

FATAL: null

```<code>java.lang.NullPointerException
    at hudson.scm.SubversionChangeLogBuilder.run(SubversionChangeLogBuilder.java:137)
    at hudson.scm.SubversionSCM.calcChangeLog(SubversionSCM.java:730)
    at hudson.scm.SubversionSCM.checkout(SubversionSCM.java:865)
    at hudson.scm.SCM.checkout(SCM.java:495)
    at hudson.model.AbstractProject.checkout(AbstractProject.java:1276)
    at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:560)
    at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86)
    at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:485)
    at hudson.model.Run.execute(Run.java:1735)
    at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
    at hudson.model.ResourceController.execute(ResourceController.java:97)
    at hudson.model.Executor.run(Executor.java:405)
</code>```

Any idea how to resolve the issue?

答: High probably the issue is solved. At the SVN-update some folder can't be found on the repo-anymore. After deleting these folders it seem to be solved.</p>

Body:
Jenkins sometimes reports an error and sometimes my build goes perfect:

Error:

FATAL: null

java.lang.NullPointerException
    at hudson.scm.SubversionChangeLogBuilder.run(SubversionChangeLogBuilder.java:137)
    at hudson.scm.SubversionSCM.calcChangeLog(SubversionSCM.java:730)
    at hudson.scm.SubversionSCM.checkout(SubversionSCM.java:865)
    at hudson.scm.SCM.checkout(SCM.java:495)
    at hudson.model.AbstractProject.checkout(AbstractProject.java:1276)
    at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:560)
    at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86)
    at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:485)
    at hudson.model.Run.execute(Run.java:1735)
    at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
    at hudson.model.ResourceController.execute(ResourceController.java:97)
    at hudson.model.Executor.run(Executor.java:405)

Any idea how to resolve the issue?


问:
Parse realm model using jackson
Getting unknown key while converting realm model into json object using jackson library.

Here is my realm model instance.

```<code>    public class RecordData extends RealmObject {

    public RecordData() {

    }

    private FormData formData;

    @Nullable
    @JsonProperty("values")
    private RealmList<Values> values;

    @Nullable
    @JsonProperty("value")
    private String value;
}
</code>```

Code for converting realm model to json object.

```<code>JSONObject recordDataJsonObject = new JSONObject(new ObjectMapper().writeValueAsString(formData.getRecordData()));
</code>```

Output  from parse json :

```<code>{"loaded":true,"managed":false,"valid":true,"value":"fdfdf","values":[]}
</code>```

Realm version : io.realm:realm-gradle-plugin:4.1.1

Rxjava version : 'io.reactivex.rxjava2:rxjava:2.1.6'

Jackson version : com.fasterxml.jackson.core:jackson-databind:2.8.6

Why i am getting loaded, managed and valid boolean values ?

答:
You could use @JsonIgnoreProperties annotation:

```<code>@JsonIgnoreProperties({"loaded", "managed", "valid"})
public class RecordData extends RealmObject {

    public RecordData() {

    }

    private FormData formData;

    @Nullable
    @JsonProperty("values")
    private RealmList<Values> values;

    @Nullable
    @JsonProperty("value")
    private String value;
}
</code>```

Another option is to use @RealmClass public class RecordData implements RealmModel.

Title: Parse realm model using jackson

Body:
Getting unknown key while converting realm model into json object using jackson library.

Here is my realm model instance.

    public class RecordData extends RealmObject {

    public RecordData() {

    }

    private FormData formData;

    @Nullable
    @JsonProperty("values")
    private RealmList<Values> values;

    @Nullable
    @JsonProperty("value")
    private String value;
}

Code for converting realm model to json object.

JSONObject recordDataJsonObject = new JSONObject(new ObjectMapper().writeValueAsString(formData.getRecordData()));

Output  from parse json :

{"loaded":true,"managed":false,"valid":true,"value":"fdfdf","values":[]}

Realm version : io.realm:realm-gradle-plugin:4.1.1

Rxjava version : 'io.reactivex.rxjava2:rxjava:2.1.6'

Jackson version : com.fasterxml.jackson.core:jackson-databind:2.8.6

Why i am getting loaded, managed and valid boolean values ?

Body:
You could use @JsonIgnoreProperties annotation:

@JsonIgnoreProperties({"loaded", "managed", "valid"})
public class RecordData extends RealmObject {

    public RecordData() {

    }

    private FormData formData;

    @Nullable
    @JsonProperty("values")
    private RealmList<Values> values;

    @Nullable
    @JsonProperty("value")
    private String value;
}

Another option is to use @RealmClass public class RecordData implements RealmModel.


问:
Does hot-reload pick up changes to assets?
Does hot-reload pick up new assets, changed assets, or changes to the pubspec.yml?</p>

答:
changed assets: Yes.

changes to the pubspec.yml: Maybe. Please check by yourself and do reply with what result you get.

It would be better to restart in such cases. Hot-reload may or may not work.


问:
What is the difference between a Docker image and a container?
When using Docker, we start with a base image. We boot it up, create changes and those changes are saved in layers forming another image.

So eventually I have an image for my PostgreSQL instance and an image for my web application, changes to which keep on being persisted.

What is a container?

答:
In short:

Container is a division (virtual) in a kernel which shares a common OS and runs an image (Docker image).

A container is a self-sustainable application that will have packages and all the necessary dependencies together to run the code.


问:
select2 - How to change the value to the first option of the list with jQuery?
I have a form with a select2 dropdown.

The dropdown is in a "modal" window and I want to be able to reset my form when the modal is closed.

Behaviour wanted: When the modal is opened, I want the default value to be the first option in my select.

```<code><select id="mylist">
    <option value="4">A</option>
    <option value="2">B</option>
    <option value="1">C</option>
    <option value="3">D</option>
</select>
</code>```

In this case, the selected value would be A (value = 4).

Note that these values are populated dynamically and it cannot be hardcoded.

My reset function would be:

```<code>function reset() {
    $('#mylist').val( /* Code I'm looking for goes here */ );
}
</code>```

答:
For all select2 in form:

```<code>$('#formId select').each( function( key, value ) {
  $(this).val($(this).find('option:first-child').val()).trigger('change');
});
</code>```

Body:
I have a form with a select2 dropdown.

The dropdown is in a "modal" window and I want to be able to reset my form when the modal is closed.

Behaviour wanted: When the modal is opened, I want the default value to be the first option in my select.

<select id="mylist">
    <option value="4">A</option>
    <option value="2">B</option>
    <option value="1">C</option>
    <option value="3">D</option>
</select>

In this case, the selected value would be A (value = 4).

Note that these values are populated dynamically and it cannot be hardcoded.

My reset function would be:

function reset() {
    $('#mylist').val( /* Code I'm looking for goes here */ );
}

Body:
For all select2 in form:

$('#formId select').each( function( key, value ) {
  $(this).val($(this).find('option:first-child').val()).trigger('change');
});


问:
Does OpenGL care if I work with large numbers?
For example, I could relate the positions where I draw my entities to the screen before sending them to OpenGL - or: I give OpenGL the direct coordinates, relative to the game world, which are of course in a much larger scale.

Is drawing with large vertex coordinates slow?

答:
There aren't speed issues, but you will find that you get accuracy issues as the differences between your numbers will be very small in relation to the size of the numbers.

For example, if you model is centred at (0,0,0) and is 10 x 10 x 10 then two points at opposite sides of your model are at (-5,-5,-5) and (5,5,5). If that same model is centred at (1000,1000,1000) then your points are (995,995,995) and (1005,1005,1005).

While the absolute difference is the same, the difference relative to the coordinates isn't.

This could lead to rounding errors and display artefacts.

You should arrange the coordinates of models so that the centre of the model is at (0,0,0).


问:
Self join and get unique records between a date
I have my table and data as follows where I am trying to filter based on period and get results

```<code>CREATE TABLE testData
(
    Id int,
    period date,
    value decimal(18,2)
)

INSERT INTO testData
VALUES (1, '2001-08-01', 400), (2, '2001-09-01', 400), (2, '2001-09-01', 300)
</code>```

I have a fiddle which is giving results but not as expected you can check fiddle here http://sqlfiddle.com/#!6/beb4c/5

This is my SQL query

```<code>SELECT
    a.id,
    [value] - (SELECT TOP 1 b.[value]
               FROM testData b
               WHERE b.period = a.period
               ORDER BY b.id DESC) x
FROM
    testData a
</code>```

Output I am expecting is

```<code>1  2001-08-01 400
2  2001-09-01 100
</code>```

答:
try This

```<code>WITH CTE
AS
(
    SELECT
      SeqNo = ROW_NUMBER() OVER(PARTITION BY Id ORDER BY Period),
      *
    FROM TestData

)
SELECT
  A.Id,
  A.Period,
  Value = ISNULL(A.Value,0) - ISNULL(Q.Value,0)
  FROM CTE A
    LEFT JOIN(
      SELECT
        B.Id,
        B.period,
        Value = SUM(B.Value)
        FROM CTE B
          WHERE B.SeqNo <> 1
          GROUP BY B.Period,B.Id
     )Q
     ON A.Id = Q.Id
     WHERE A.SeqNo = 1
</code>```

Fiddle Link Here

Body:
I have my table and data as follows where I am trying to filter based on period and get results

CREATE TABLE testData
(
    Id int,
    period date,
    value decimal(18,2)
)

INSERT INTO testData
VALUES (1, '2001-08-01', 400), (2, '2001-09-01', 400), (2, '2001-09-01', 300)

I have a fiddle which is giving results but not as expected you can check fiddle here http://sqlfiddle.com/#!6/beb4c/5

This is my SQL query

SELECT
    a.id,
    [value] - (SELECT TOP 1 b.[value]
               FROM testData b
               WHERE b.period = a.period
               ORDER BY b.id DESC) x
FROM
    testData a

Output I am expecting is

1  2001-08-01 400
2  2001-09-01 100

Body:
try This

WITH CTE
AS
(
    SELECT
      SeqNo = ROW_NUMBER() OVER(PARTITION BY Id ORDER BY Period),
      *
    FROM TestData

)
SELECT
  A.Id,
  A.Period,
  Value = ISNULL(A.Value,0) - ISNULL(Q.Value,0)
  FROM CTE A
    LEFT JOIN(
      SELECT
        B.Id,
        B.period,
        Value = SUM(B.Value)
        FROM CTE B
          WHERE B.SeqNo <> 1
          GROUP BY B.Period,B.Id
     )Q
     ON A.Id = Q.Id
     WHERE A.SeqNo = 1

Fiddle Link Here


问:
Gradle project refresh failed (Android), Not After message
i faced with this message when sync gradle :

答:
In my case there was problem of JDK path.

I just set  path of JDK for Android Studio.

File -> Project Structure -> From Left Side Panel "SDK Location" -> JDK Location -> Click to select JDK Path.