问:
How to search for array of string in each row of another column and get the count in excel
I have a excel with a column Address and another lookup column(List) containing list of lookup strings:-

Address

List

St Dunstans Street;  Waterlooville;    PO7 5YT; United Kingdom

London

Simone Weil Avenue;  Week;    EX18 0DJ; United Kingdom

Whitehill

Greyfriars Road;  Carbrooke;    IP25 8PW; United Kingdom

Southampton

Terrick Rd;  Elham;  CT4 9GQ;   United Kingdom

Jameston

Earls Avenue;  Whitehill;    ME13 2QW; United Kingdom

United Kingdom

Cheriton Rd;  West Newton;    HU11 7LB; United Kingdom

Marlborough Crescent;  Southampton;    SO15 4JL; United Kingdom

Baldock Street;  Newton;  ML12   6PZ; United Kingdom

I want to search for all the strigns in List in Address column and return the count of strings matching
What I want to achieve :-

Address
Count_Flag

List

St Dunstans Street;  Waterlooville;    PO7 5YT; United Kingdom
1

London

Simone Weil Avenue;  Week;    EX18 0DJ; United Kingdom
1

Whitehill

Greyfriars Road;  Carbrooke;    IP25 8PW; United Kingdom
1

Southampton

Terrick Rd;  Elham;  CT4 9GQ;   United Kingdom
1

Jameston

Earls Avenue;  Whitehill;    ME13 2QW; United Kingdom
2

United Kingdom

Cheriton Rd;  West Newton;    HU11 7LB; United Kingdom
1

Marlborough Crescent;  Southampton;    SO15 4JL; United Kingdom
2

Baldock Street;  Newton;  ML12   6PZ; United Kingdom
1

I tried something like this :

```<code>=--ISNUMBER(SEARCH(@$D$2:$D$6,A2))
</code>```

答:
You can use:

Formula in B2:

```<code>=SUM(--ISNUMBER(FIND("; "&D$2:D$6&";","; "&A2&";")))
</code>```

Or if you don't have ms365, then use SUMPRODUCT() isntead of SUM().

Note that the concatenated semi-colons are there to prevent false positive matches. Drag down the formula.

Body:
I have a excel with a column Address and another lookup column(List) containing list of lookup strings:-

Address

List

St Dunstans Street;  Waterlooville;    PO7 5YT; United Kingdom

London

Simone Weil Avenue;  Week;    EX18 0DJ; United Kingdom

Whitehill

Greyfriars Road;  Carbrooke;    IP25 8PW; United Kingdom

Southampton

Terrick Rd;  Elham;  CT4 9GQ;   United Kingdom

Jameston

Earls Avenue;  Whitehill;    ME13 2QW; United Kingdom

United Kingdom

Cheriton Rd;  West Newton;    HU11 7LB; United Kingdom

Marlborough Crescent;  Southampton;    SO15 4JL; United Kingdom

Baldock Street;  Newton;  ML12   6PZ; United Kingdom

I want to search for all the strigns in List in Address column and return the count of strings matching
What I want to achieve :-

Address
Count_Flag

List

St Dunstans Street;  Waterlooville;    PO7 5YT; United Kingdom
1

London

Simone Weil Avenue;  Week;    EX18 0DJ; United Kingdom
1

Whitehill

Greyfriars Road;  Carbrooke;    IP25 8PW; United Kingdom
1

Southampton

Terrick Rd;  Elham;  CT4 9GQ;   United Kingdom
1

Jameston

Earls Avenue;  Whitehill;    ME13 2QW; United Kingdom
2

United Kingdom

Cheriton Rd;  West Newton;    HU11 7LB; United Kingdom
1

Marlborough Crescent;  Southampton;    SO15 4JL; United Kingdom
2

Baldock Street;  Newton;  ML12   6PZ; United Kingdom
1

I tried something like this :

=--ISNUMBER(SEARCH(@$D$2:$D$6,A2))

Body:
You can use:

Formula in B2:

=SUM(--ISNUMBER(FIND("; "&D$2:D$6&";","; "&A2&";")))

Or if you don't have ms365, then use SUMPRODUCT() isntead of SUM().

Note that the concatenated semi-colons are there to prevent false positive matches. Drag down the formula.


来源: stackexchange

问:
Cannot POST /users/create error while creating form using nodejs express and mysql
I was creating a form and taking user data, but after filling the details and submitting the form it shows Cannot POST /users/create
. Tried but didnt find anything.

app.js file-

```<code>const express = require('express');
const db = require("./database");

const app = express();
const port = 3000;

app.use(express.urlencoded({extended:false}))
app.set("view engine", "ejs");
app.get("/",(req, res) => {
    res.render("users");
})
app.post('/create', (req, res) => {
    const userDetails = req.body;

    const sql = 'INSERT INTO users SET ?';
    db.query(sql, userDetails,(err, data) => {
        if (err) throw err;
        console.log("user data inserted sucessfully");
    });
    res.redirect('users')
});
app.listen(port, () => {
    console.log(`server created successfully ${port}`);
})
</code>```

users.ejs file-

```<code><div class="user-detail">
    <h2>Create user data</h2>
    <form action="/users/create" method="POST">
        <label>Full name</label>
        <input type="text" placeholder="Enter full name" name="fullName" required>
        <input type="email" placeholder="Enter Email Address" name="emailAddress" required>
        <input type="text" placeholder="Enter city name" name="city" required>
        <input type="text" placeholder="Enter country name" name="country" required>
        <button type="submit">Submit</button>
    </form>
</div>
</code>```

Output-
database created successfully
server started successfully

答:
Correct me if I am wrong, but your routes doesn't match.
In your ejs file you wrote: <form action='users/create'....>
In your app.js file the route in your post request is:

```<code>app.post('/create', (req, res) => {...}
</code>```

You have to call the same endpoint in your frontend as defined in your backend.

ContentLicense: CC BY-SA 4.0

Body:
I was creating a form and taking user data, but after filling the details and submitting the form it shows Cannot POST /users/create
. Tried but didnt find anything.

app.js file-

const express = require('express');
const db = require("./database");

const app = express();
const port = 3000;

app.use(express.urlencoded({extended:false}))
app.set("view engine", "ejs");
app.get("/",(req, res) => {
    res.render("users");
})
app.post('/create', (req, res) => {
    const userDetails = req.body;

    const sql = 'INSERT INTO users SET ?';
    db.query(sql, userDetails,(err, data) => {
        if (err) throw err;
        console.log("user data inserted sucessfully");
    });
    res.redirect('users')
});
app.listen(port, () => {
    console.log(`server created successfully ${port}`);
})

users.ejs file-

Create user data

    <form action="/users/create" method="POST">
        Full name
        <input type="text" placeholder="Enter full name" name="fullName" required>
        <input type="email" placeholder="Enter Email Address" name="emailAddress" required>
        <input type="text" placeholder="Enter city name" name="city" required>
        <input type="text" placeholder="Enter country name" name="country" required>
        <button type="submit">Submit</button>
    </form>

Output-
database created successfully
server started successfully

Body:
Correct me if I am wrong, but your routes doesn't match.
In your ejs file you wrote: <form action='users/create'....>
In your app.js file the route in your post request is:

app.post('/create', (req, res) => {...}

You have to call the same endpoint in your frontend as defined in your backend.


问:
How to correctly place an image outside the container, and make them adaptive, HTML/CSS?
Maket link: https://www.figma.com/file/hYoPHDHOzzgzEPo4crMmy1/UH15U7CD4WZkbhcW?node-id=2%3A334

Project link: https://plupiks.github.io/Real-Estate-LandingPage/

I have a layout, it has an image of a building. This image is outside of the container. I was able to take the image out of the container, but I can’t adapt it anymore. If I give the image width: 100%; height: auto; , its dimensions no longer correspond to those specified in the layout.

The question is, how to move images outside the container so that they can then be adapted without changing the original image dimensions?

Worked with preprocessor SCSS.

```<code><div class="hero">
        <div class="container">
          <div class="hero--wrapper">
            <div class="hero--blok-left">
              <div class="hero--descr">Welcome to Besnik Agency</div>
              <h1 class="hero--title">Discover a place you’ll love to live.</h1>
              <p class="hero--subtitle">
                Get the best real estate deals first, before they hit the mass market! hot foreclosure deals with one simple search
              </p>
              <button class="button hero--button">More About Us</button>
            </div>
            <div class="hero--block-right">
              <div class="hero--img">
                <svg width="584" height="620" viewBox="0 0 584 620" fill="none" xmlns="http://www.w3.org/2000/svg">
                  <path d="M241.032 610.998L231.713 201.367L58.0327 201.367L60.5743 610.998H241.032Z" fill="#F1F6FF" />
                  <path d="M302.879 608.881V337.77L512.566 343.89V608.881H302.879Z" fill="#FEFCED" />
                  <path d="M58.033 201.367L60.5747 610.998H159.276L154.616 201.367H58.033Z" fill="#7398F7" />
                  <path d="M182.997 159.855H110.983V201.369H182.997V159.855Z" fill="#1F1D42" />
                  <path d="M110.983 159.855V201.369H159.698C136.315 196.285 129.057 171.575 128.351 159.855H110.983Z" fill="#1F1717" />
                  <path
                    d="M152.498 89.1111L144.026 88.2639C141.908 87.4167 141.484 77.6737 149.533 79.7917C155.971 81.4861 154.192 86.7107 152.498 89.1111Z"
                    fill="#0E173D"
                  />
                  <path d="M152.498 89.112L144.026 88.2648V100.549L152.498 101.397V89.112Z" fill="#0E173D" />
                  <path d="M144.025 100.548L152.497 101.396L183.845 123.847H110.56L144.025 100.548Z" fill="#1F1D42" />
                  <path d="M323.636 403.007H316.859V451.298H313.893V456.381H326.602V449.604H323.636V403.007Z" fill="#1B2A63" />
                  <path d="M512.566 612.269H302.879V473.325L512.566 476.385V612.269Z" fill="#A3BDFF" />
                  <path d="M448.177 242.458L221.546 235.257L302.879 337.77L520.614 344.124L448.177 242.458Z" fill="#063183" />
                  <path d="M302.879 337.77L520.614 344.124L316.011 238.258L221.546 235.257L302.879 337.77Z" fill="#7087FB" />
                  <path
                    d="M221.546 235.257L302.879 337.77V605.915L152.921 613.117V476.291V337.77L193.164 284.819H184.268L221.546 235.257Z"
                    fill="#CFDEF3"
                  />
                  <path d="M250.776 297.527H206.297V350.902H250.776V297.527Z" fill="#0C183F" />
                  <rect x="211.38" y="303.033" width="15.2499" height="18.6388" fill="#1F326B" />
                  <rect x="232.56" y="303.033" width="15.2499" height="18.6388" fill="#1F326B" />
                  <rect x="232.56" y="328.451" width="15.2499" height="18.6388" fill="#1F326B" />
                  <path d="M110.562 123.846H183.846H188.929V125.964H104.631V123.846H110.562Z" stroke="black" />
                  <path d="M150.804 378.012H303.727H512.99" stroke="black" stroke-width="4" />
                  <path d="M151.652 486.457H301.186H511.297" stroke="black" stroke-width="5" />
                  <path d="M151.652 486.457H301.186" stroke="#5267FA" stroke-width="6" />
                  <rect x="211.38" y="328.451" width="15.2499" height="18.6388" fill="#1F326B" />
                  <path d="M113.525 289.901H91.0741V350.901H115.22L113.525 289.901Z" fill="#0E173D" />
                  <path d="M113.525 395.381H91.0741V456.381H115.22L113.525 395.381Z" fill="#0C193F" />
                  <path d="M114.797 267.027H91.9224V220.43C97.3446 205.18 106.325 214.076 110.138 220.43L114.797 267.027Z" fill="#1F1D42" />
                  <path
                    d="M352.019 247.118H327.873L306.693 240.763V201.368V199.25L327.873 198.677L353.714 197.979L353.597 201.368L352.019 247.118Z"
                    fill="#1F326B"
                  />
                  <path d="M352.019 247.118H327.874V201.368V198.677L353.714 197.979L353.597 201.368L352.019 247.118Z" fill="#FEFDE8" />
                  <path d="M306.693 199.25L327.873 198.677L353.714 197.979L353.597 201.368H327.873H306.693V199.25Z" fill="#112F7F" />
                  <rect x="180.881" y="125.966" width="1.69444" height="33.8888" fill="#0C1942" />
                  <rect x="241.032" y="166.632" width="1.69444" height="189.777" transform="rotate(90 241.032 166.632)" fill="#0C1942" />
                  <rect x="241.032" y="199.673" width="1.69444" height="189.777" transform="rotate(90 241.032 199.673)" fill="#0C1942" />
                  <path d="M58.0009 231.867H155.855H232.501" stroke="#18265D" stroke-width="4" />
                  <rect x="241.032" y="186.118" width="1.69444" height="189.777" transform="rotate(90 241.032 186.118)" fill="#081334" />
                  <rect x="110.56" y="125.966" width="1.69444" height="33.8888" fill="#132355" />
                  <rect x="128.352" y="131.895" width="1.69444" height="27.9582" fill="#132355" />
                  <rect x="131.741" y="131.895" width="1.69444" height="27.9582" fill="#132355" />
                  <rect x="136.824" y="131.895" width="1.69444" height="27.9582" fill="#132355" />
                  <path
                    d="M221.546 235.257L227.259 244.153M302.879 337.77L296.72 330.145M227.259 244.153L453.308 249.66M227.259 244.153L237.524 256.861M237.524 256.861L462.061 261.944M237.524 256.861L248.816 270.84M248.816 270.84L470.813 274.229M248.816 270.84L257.976 282.18M257.976 282.18L479.566 286.514M257.976 282.18L269.004 295.833M269.004 295.833L488.42 298.939M269.004 295.833L278.243 307.27M278.243 307.27L497.739 312.019M278.243 307.27L290.561 322.52M290.561 322.52H505.221M290.561 322.52L296.72 330.145M296.72 330.145L512.918 333.322"
                    stroke="#A3BDFF"
                    stroke-width="4"
                  />
                  <rect x="83.4506" y="168.327" width="1.69444" height="31.3471" fill="#121B3A" />
                  <rect x="51.2557" y="168.327" width="1.69444" height="31.3471" fill="#121B3A" />
                  <rect x="239.338" y="168.327" width="1.69444" height="31.3471" fill="#121B3A" />
                  <path d="M377.436 511.026H363.88V579.651H377.436V511.026Z" fill="#0C183F" />
                  <path d="M363.88 579.651H377.436V545.339H363.88V579.651Z" fill="#17275F" />
                  <path d="M489.691 548.304H467.24V580.499H489.691V548.304Z" fill="#17275F" />
                  <path d="M148.687 79.7914L146.992 1" stroke="black" stroke-width="3" />
                  <rect x="210.534" y="168.327" width="1.69444" height="31.3471" fill="#121B3A" />
                  <rect x="151.227" y="168.327" width="1.69444" height="31.3471" fill="#121B3A" />
                  <rect x="77.5193" y="168.327" width="1.69444" height="31.3471" fill="#121B3A" />
                  <rect x="204.602" y="168.327" width="1.69444" height="31.3471" fill="#121B3A" />
                  <rect x="204.602" y="168.327" width="1.69444" height="31.3471" fill="#121B3A" />
                  <rect x="145.298" y="168.327" width="1.69444" height="31.3471" fill="#121B3A" />
                  <rect x="158.853" y="131.895" width="1.69444" height="27.9582" fill="#121B3A" />
                  <rect x="162.241" y="131.895" width="1.69444" height="27.9582" fill="#121B3A" />
                  <rect x="152.921" y="131.895" width="1.69444" height="27.9582" fill="#121B3A" />
                  <path d="M467.24 580.499H489.691V564.402H467.24V580.499Z" fill="#0F1C49" />
                  <path d="M503.67 556.353H495.198V574.145L503.67 573.721V556.353Z" fill="#FAF2E2" />
                  <path
                    d="M200.365 511.449V548.727H204.601V604.643H211.803V546.185H207.143V517.803H248.657V546.185H241.879V604.643H246.115V548.727H254.164V511.449H200.365Z"
                    fill="#0D0808"
                  />
                  <path d="M241.881 546.186V604.644H211.805V546.186H207.145V517.804H248.659V546.186H241.881Z" fill="#17275F" />
                  <path d="M584 611.421H0V620H584V611.421Z" fill="#091D39" />
                  <path
                    d="M571.873 611.422V576.686M510.026 576.686V611.422M446.485 576.686V611.422M385.909 576.686V611.422M323.214 576.686V611.422M259.249 576.686V611.422M201.638 576.686V611.422M136.826 576.686V611.422M74.132 576.686V611.422M14.4031 576.686V611.422"
                    stroke="black"
                    stroke-width="4"
                  />
                  <path
                    d="M571.873 582C558.6 593.579 527.648 609.789 510.026 582C495.623 590.755 462.751 602.78 446.485 581.769C433.776 590.241 403.869 603.288 385.908 587.699C373.341 593.489 343.209 601.594 323.214 587.699C305.705 591.371 268.399 596.511 259.249 587.699C247.388 591.371 219.26 596.511 201.638 587.699C184.553 591.371 147.67 596.511 136.826 587.699C118.752 593.912 89.8057 602.102 74.1318 587.699C57.0807 591.371 23.3695 597.311 13.5004 588.5"
                    stroke="black"
                    stroke-width="3"
                  />
                  <circle cx="571.965" cy="574.965" r="2.96527" fill="#06162A" />
                  <circle cx="510.026" cy="574.568" r="2.96527" fill="#06162A" />
                  <circle cx="446.484" cy="575.416" r="2.96527" fill="#06162A" />
                  <circle cx="385.965" cy="574.965" r="2.96527" fill="#06162A" />
                  <circle cx="322.965" cy="574.965" r="2.96527" fill="#06162A" />
                  <circle cx="259.249" cy="575.416" r="2.96527" fill="#06162A" />
                  <circle cx="201.638" cy="574.568" r="2.96527" fill="#06162A" />
                  <circle cx="136.965" cy="574.568" r="2.96527" fill="#06162A" />
                  <circle cx="73.9653" cy="576.262" r="2.96527" fill="#06162A" />
                  <circle cx="13.9653" cy="577.965" r="2.96527" fill="#06162A" />
                  <path d="M56.7639 45.479L69.4722 56.4928L82.1805 45.479" stroke="black" stroke-width="4" />
                  <path d="M8.47162 38.7016L21.1799 49.7154L33.8882 38.7016" stroke="black" stroke-width="4" />
                  <path d="M63.5413 16.675L76.2496 27.6889L88.9579 16.675" stroke="black" stroke-width="4" />
                  <path d="M133.014 20.9098L145.722 31.9236L158.431 20.9098" stroke="black" stroke-width="4" />
                  <path d="M255.86 390.298H210.11L211.805 458.076H255.86V390.298Z" fill="#0F1F4C" />
                  <path d="M244.847 401.736H221.125V446.638H244.847V401.736Z" fill="#142553" />
                </svg>
              </div>
            </div>
          </div>
        </div>
      </div>
</code>```
```<code>.hero {
  position: relative;
  background-color: $blueElis;
  font-size: 16px;
}

.hero--wrapper {
  display: flex;
  column-gap: 4.1875em;
  padding-top: 7.125em;
}

.hero--blok-left {
  flex: 0 0 50.37%;
  margin-top: 5.6875em;
}

.hero--descr {
  margin-bottom: 0.444em;
  @include SWCL(1.125em, 500, $pigeonBlue, 1.6875);
}

.hero--title {
  margin-bottom: 0.46875em;
  @include SWCL(4em, 700, $darkBlue, 1.1875);
}

.hero--subtitle {
  @include SWCL(1.125em, 400, $marengo, 2);
  margin-bottom: 2.222em;
}
.hero--button {
}

.hero--block-right {
  display: flex;
  align-items: flex-end;
}
.hero--img {
  width: 36.5em;
  height: auto;
  & svg {
    max-width: 100%;
    height: auto;
  }
}

// Adaptive

@media only screen and (max-width: 1024px) {
  .header {
    font-size: 14px;
  }
}

</code>```

答:
```<code>.hero--img {
    width: 100%;
    height: auto;
    max-width: 36.5em;
}
</code>```

Body:
Maket link: https://www.figma.com/file/hYoPHDHOzzgzEPo4crMmy1/UH15U7CD4WZkbhcW?node-id=2%3A334

Project link: https://plupiks.github.io/Real-Estate-LandingPage/

I have a layout, it has an image of a building. This image is outside of the container. I was able to take the image out of the container, but I can’t adapt it anymore. If I give the image width: 100%; height: auto; , its dimensions no longer correspond to those specified in the layout.

The question is, how to move images outside the container so that they can then be adapted without changing the original image dimensions?

Worked with preprocessor SCSS.

Welcome to Besnik Agency

Discover a place you’ll love to live.

                Get the best real estate deals first, before they hit the mass market! hot foreclosure deals with one simple search

              <button class="button hero--button">More About Us</button>

                <svg width="584" height="620" viewBox="0 0 584 620" fill="none" xmlns="http://www.w3.org/2000/svg">
                  <path d="M241.032 610.998L231.713 201.367L58.0327 201.367L60.5743 610.998H241.032Z" fill="#F1F6FF" />
                  <path d="M302.879 608.881V337.77L512.566 343.89V608.881H302.879Z" fill="#FEFCED" />
                  <path d="M58.033 201.367L60.5747 610.998H159.276L154.616 201.367H58.033Z" fill="#7398F7" />
                  <path d="M182.997 159.855H110.983V201.369H182.997V159.855Z" fill="#1F1D42" />
                  <path d="M110.983 159.855V201.369H159.698C136.315 196.285 129.057 171.575 128.351 159.855H110.983Z" fill="#1F1717" />
                  <path
                    d="M152.498 89.1111L144.026 88.2639C141.908 87.4167 141.484 77.6737 149.533 79.7917C155.971 81.4861 154.192 86.7107 152.498 89.1111Z"
                    fill="#0E173D"
                  />
                  <path d="M152.498 89.112L144.026 88.2648V100.549L152.498 101.397V89.112Z" fill="#0E173D" />
                  <path d="M144.025 100.548L152.497 101.396L183.845 123.847H110.56L144.025 100.548Z" fill="#1F1D42" />
                  <path d="M323.636 403.007H316.859V451.298H313.893V456.381H326.602V449.604H323.636V403.007Z" fill="#1B2A63" />
                  <path d="M512.566 612.269H302.879V473.325L512.566 476.385V612.269Z" fill="#A3BDFF" />
                  <path d="M448.177 242.458L221.546 235.257L302.879 337.77L520.614 344.124L448.177 242.458Z" fill="#063183" />
                  <path d="M302.879 337.77L520.614 344.124L316.011 238.258L221.546 235.257L302.879 337.77Z" fill="#7087FB" />
                  <path
                    d="M221.546 235.257L302.879 337.77V605.915L152.921 613.117V476.291V337.77L193.164 284.819H184.268L221.546 235.257Z"
                    fill="#CFDEF3"
                  />
                  <path d="M250.776 297.527H206.297V350.902H250.776V297.527Z" fill="#0C183F" />
                  <rect x="211.38" y="303.033" width="15.2499" height="18.6388" fill="#1F326B" />
                  <rect x="232.56" y="303.033" width="15.2499" height="18.6388" fill="#1F326B" />
                  <rect x="232.56" y="328.451" width="15.2499" height="18.6388" fill="#1F326B" />
                  <path d="M110.562 123.846H183.846H188.929V125.964H104.631V123.846H110.562Z" stroke="black" />
                  <path d="M150.804 378.012H303.727H512.99" stroke="black" stroke-width="4" />
                  <path d="M151.652 486.457H301.186H511.297" stroke="black" stroke-width="5" />
                  <path d="M151.652 486.457H301.186" stroke="#5267FA" stroke-width="6" />
                  <rect x="211.38" y="328.451" width="15.2499" height="18.6388" fill="#1F326B" />
                  <path d="M113.525 289.901H91.0741V350.901H115.22L113.525 289.901Z" fill="#0E173D" />
                  <path d="M113.525 395.381H91.0741V456.381H115.22L113.525 395.381Z" fill="#0C193F" />
                  <path d="M114.797 267.027H91.9224V220.43C97.3446 205.18 106.325 214.076 110.138 220.43L114.797 267.027Z" fill="#1F1D42" />
                  <path
                    d="M352.019 247.118H327.873L306.693 240.763V201.368V199.25L327.873 198.677L353.714 197.979L353.597 201.368L352.019 247.118Z"
                    fill="#1F326B"
                  />
                  <path d="M352.019 247.118H327.874V201.368V198.677L353.714 197.979L353.597 201.368L352.019 247.118Z" fill="#FEFDE8" />
                  <path d="M306.693 199.25L327.873 198.677L353.714 197.979L353.597 201.368H327.873H306.693V199.25Z" fill="#112F7F" />
                  <rect x="180.881" y="125.966" width="1.69444" height="33.8888" fill="#0C1942" />
                  <rect x="241.032" y="166.632" width="1.69444" height="189.777" transform="rotate(90 241.032 166.632)" fill="#0C1942" />
                  <rect x="241.032" y="199.673" width="1.69444" height="189.777" transform="rotate(90 241.032 199.673)" fill="#0C1942" />
                  <path d="M58.0009 231.867H155.855H232.501" stroke="#18265D" stroke-width="4" />
                  <rect x="241.032" y="186.118" width="1.69444" height="189.777" transform="rotate(90 241.032 186.118)" fill="#081334" />
                  <rect x="110.56" y="125.966" width="1.69444" height="33.8888" fill="#132355" />
                  <rect x="128.352" y="131.895" width="1.69444" height="27.9582" fill="#132355" />
                  <rect x="131.741" y="131.895" width="1.69444" height="27.9582" fill="#132355" />
                  <rect x="136.824" y="131.895" width="1.69444" height="27.9582" fill="#132355" />
                  <path
                    d="M221.546 235.257L227.259 244.153M302.879 337.77L296.72 330.145M227.259 244.153L453.308 249.66M227.259 244.153L237.524 256.861M237.524 256.861L462.061 261.944M237.524 256.861L248.816 270.84M248.816 270.84L470.813 274.229M248.816 270.84L257.976 282.18M257.976 282.18L479.566 286.514M257.976 282.18L269.004 295.833M269.004 295.833L488.42 298.939M269.004 295.833L278.243 307.27M278.243 307.27L497.739 312.019M278.243 307.27L290.561 322.52M290.561 322.52H505.221M290.561 322.52L296.72 330.145M296.72 330.145L512.918 333.322"
                    stroke="#A3BDFF"
                    stroke-width="4"
                  />
                  <rect x="83.4506" y="168.327" width="1.69444" height="31.3471" fill="#121B3A" />
                  <rect x="51.2557" y="168.327" width="1.69444" height="31.3471" fill="#121B3A" />
                  <rect x="239.338" y="168.327" width="1.69444" height="31.3471" fill="#121B3A" />
                  <path d="M377.436 511.026H363.88V579.651H377.436V511.026Z" fill="#0C183F" />
                  <path d="M363.88 579.651H377.436V545.339H363.88V579.651Z" fill="#17275F" />
                  <path d="M489.691 548.304H467.24V580.499H489.691V548.304Z" fill="#17275F" />
                  <path d="M148.687 79.7914L146.992 1" stroke="black" stroke-width="3" />
                  <rect x="210.534" y="168.327" width="1.69444" height="31.3471" fill="#121B3A" />
                  <rect x="151.227" y="168.327" width="1.69444" height="31.3471" fill="#121B3A" />
                  <rect x="77.5193" y="168.327" width="1.69444" height="31.3471" fill="#121B3A" />
                  <rect x="204.602" y="168.327" width="1.69444" height="31.3471" fill="#121B3A" />
                  <rect x="204.602" y="168.327" width="1.69444" height="31.3471" fill="#121B3A" />
                  <rect x="145.298" y="168.327" width="1.69444" height="31.3471" fill="#121B3A" />
                  <rect x="158.853" y="131.895" width="1.69444" height="27.9582" fill="#121B3A" />
                  <rect x="162.241" y="131.895" width="1.69444" height="27.9582" fill="#121B3A" />
                  <rect x="152.921" y="131.895" width="1.69444" height="27.9582" fill="#121B3A" />
                  <path d="M467.24 580.499H489.691V564.402H467.24V580.499Z" fill="#0F1C49" />
                  <path d="M503.67 556.353H495.198V574.145L503.67 573.721V556.353Z" fill="#FAF2E2" />
                  <path
                    d="M200.365 511.449V548.727H204.601V604.643H211.803V546.185H207.143V517.803H248.657V546.185H241.879V604.643H246.115V548.727H254.164V511.449H200.365Z"
                    fill="#0D0808"
                  />
                  <path d="M241.881 546.186V604.644H211.805V546.186H207.145V517.804H248.659V546.186H241.881Z" fill="#17275F" />
                  <path d="M584 611.421H0V620H584V611.421Z" fill="#091D39" />
                  <path
                    d="M571.873 611.422V576.686M510.026 576.686V611.422M446.485 576.686V611.422M385.909 576.686V611.422M323.214 576.686V611.422M259.249 576.686V611.422M201.638 576.686V611.422M136.826 576.686V611.422M74.132 576.686V611.422M14.4031 576.686V611.422"
                    stroke="black"
                    stroke-width="4"
                  />
                  <path
                    d="M571.873 582C558.6 593.579 527.648 609.789 510.026 582C495.623 590.755 462.751 602.78 446.485 581.769C433.776 590.241 403.869 603.288 385.908 587.699C373.341 593.489 343.209 601.594 323.214 587.699C305.705 591.371 268.399 596.511 259.249 587.699C247.388 591.371 219.26 596.511 201.638 587.699C184.553 591.371 147.67 596.511 136.826 587.699C118.752 593.912 89.8057 602.102 74.1318 587.699C57.0807 591.371 23.3695 597.311 13.5004 588.5"
                    stroke="black"
                    stroke-width="3"
                  />
                  <circle cx="571.965" cy="574.965" r="2.96527" fill="#06162A" />
                  <circle cx="510.026" cy="574.568" r="2.96527" fill="#06162A" />
                  <circle cx="446.484" cy="575.416" r="2.96527" fill="#06162A" />
                  <circle cx="385.965" cy="574.965" r="2.96527" fill="#06162A" />
                  <circle cx="322.965" cy="574.965" r="2.96527" fill="#06162A" />
                  <circle cx="259.249" cy="575.416" r="2.96527" fill="#06162A" />
                  <circle cx="201.638" cy="574.568" r="2.96527" fill="#06162A" />
                  <circle cx="136.965" cy="574.568" r="2.96527" fill="#06162A" />
                  <circle cx="73.9653" cy="576.262" r="2.96527" fill="#06162A" />
                  <circle cx="13.9653" cy="577.965" r="2.96527" fill="#06162A" />
                  <path d="M56.7639 45.479L69.4722 56.4928L82.1805 45.479" stroke="black" stroke-width="4" />
                  <path d="M8.47162 38.7016L21.1799 49.7154L33.8882 38.7016" stroke="black" stroke-width="4" />
                  <path d="M63.5413 16.675L76.2496 27.6889L88.9579 16.675" stroke="black" stroke-width="4" />
                  <path d="M133.014 20.9098L145.722 31.9236L158.431 20.9098" stroke="black" stroke-width="4" />
                  <path d="M255.86 390.298H210.11L211.805 458.076H255.86V390.298Z" fill="#0F1F4C" />
                  <path d="M244.847 401.736H221.125V446.638H244.847V401.736Z" fill="#142553" />
                </svg>

.hero {
  position: relative;
  background-color: $blueElis;
  font-size: 16px;
}

.hero--wrapper {
  display: flex;
  column-gap: 4.1875em;
  padding-top: 7.125em;
}

.hero--blok-left {
  flex: 0 0 50.37%;
  margin-top: 5.6875em;
}

.hero--descr {
  margin-bottom: 0.444em;
  @include SWCL(1.125em, 500, $pigeonBlue, 1.6875);
}

.hero--title {
  margin-bottom: 0.46875em;
  @include SWCL(4em, 700, $darkBlue, 1.1875);
}

.hero--subtitle {
  @include SWCL(1.125em, 400, $marengo, 2);
  margin-bottom: 2.222em;
}
.hero--button {
}

.hero--block-right {
  display: flex;
  align-items: flex-end;
}
.hero--img {
  width: 36.5em;
  height: auto;
  & svg {
    max-width: 100%;
    height: auto;
  }
}

// Adaptive

@media only screen and (max-width: 1024px) {
  .header {
    font-size: 14px;
  }
}


答:
It will work if you mount your app on the /users path:

express().use("/users", require("./app.js")).listen(80);
```
<p>but not if you run it "standalone":</p>
<pre class="lang-js prettyprint-override"><code>require("./app.js").listen(80);
</code>```

Title: Cannot POST /users/create error while creating form using nodejs express and mysql

Body:
It will work if you mount your app on the /users path:

express().use("/users", require("./app.js")).listen(80);

but not if you run it "standalone":

require("./app.js").listen(80);


问:
Find rows with same non-null values
This seems like a rather straightforward problem, yet I have not been able to find the solution:

In a table test, I have some subset of columns which I am interested in, say a,b,c,d,e,f.

Some or most of these columns are NULL, but at least one is always filled.

Now for some rows, returned, say by:

```<code>SELECT rowid,a,b,c,d,e,f LIMIT 1;
</code>```

I would like to get the number of rows which have the same non-null values.

So for example if a,d,f are the columns that are not NULL for this row, the result would be the same as for:

```<code>SELECT COUNT(*)
FROM test WHERE a=a_ AND d=d_ AND f=f_

SELECT a as a_, d as d_, f as f_ FROM test LIMIT 1;
</code>```

How can this be done in one step / line? Or do I need a temporary table?

答:
You can use the operator IS to compare safely values that may be NULL:

```<code>SELECT COUNT(*)
FROM test t1
INNER JOIN (SELECT a, b, c, d, e, f FROM test LIMIT 1) t2
ON (t1.a, t1.b, t1.c, t1.d, t1.e, t1.f) IS (t2.a, t2.b, t2.c, t2.d, t2.e, t2.f);
</code>```

or with a CTE:

```<code>WITH cte AS (SELECT a, b, c, d, e, f FROM test LIMIT 1)
SELECT COUNT(*)
FROM test t1 INNER JOIN cte t2
ON (t1.a, t1.b, t1.c, t1.d, t1.e, t1.f) IS (t2.a, t2.b, t2.c, t2.d, t2.e, t2.f);
</code>```

See the demo.

Title: Find rows with same non-null values

Body:
This seems like a rather straightforward problem, yet I have not been able to find the solution:

In a table test, I have some subset of columns which I am interested in, say a,b,c,d,e,f.

Some or most of these columns are NULL, but at least one is always filled.

Now for some rows, returned, say by:

SELECT rowid,a,b,c,d,e,f LIMIT 1;

I would like to get the number of rows which have the same non-null values.

So for example if a,d,f are the columns that are not NULL for this row, the result would be the same as for:

SELECT COUNT(*)
FROM test WHERE a=a_ AND d=d_ AND f=f_

SELECT a as a_, d as d_, f as f_ FROM test LIMIT 1;

How can this be done in one step / line? Or do I need a temporary table?

Body:
You can use the operator IS to compare safely values that may be NULL:

SELECT COUNT(*)
FROM test t1
INNER JOIN (SELECT a, b, c, d, e, f FROM test LIMIT 1) t2
ON (t1.a, t1.b, t1.c, t1.d, t1.e, t1.f) IS (t2.a, t2.b, t2.c, t2.d, t2.e, t2.f);

or with a CTE:

WITH cte AS (SELECT a, b, c, d, e, f FROM test LIMIT 1)
SELECT COUNT(*)
FROM test t1 INNER JOIN cte t2
ON (t1.a, t1.b, t1.c, t1.d, t1.e, t1.f) IS (t2.a, t2.b, t2.c, t2.d, t2.e, t2.f);

See the demo.


问:
Protobuf to json in python
I have an object that I de-serialize using protobuf in Python. When I print the object it looks like a python object, however when I try to convert it to json I have all sorts of problems.

For example, if I use json.dumps() I get that the object (the generated code from protoc) does not contain a _ dict _ error.

If I use jsonpickle I get UnicodeDecodeError: 'utf8' codec can't decode byte 0x9d in position 97: invalid start byte.

Test code below is using jsonpickle with the error shown above.

```<code>if len(sys.argv) < 2:
    print ("Error: missing ser file")
    sys.exit()
else :
    fileLocation = sys.argv[1]

org = BuildOrgObject(fileLocation)

org = org.Deserialize()

#print (org)
jsonObj = jsonpickle.encode(org)
print (jsonObj)
</code>```

答:
Here's my function to convert a proto3 object to a JSON object (i.e. Python dictionary):

```<code>def protobuf_to_dict(proto_obj):
    key_list = proto_obj.DESCRIPTOR.fields_by_name.keys()
    d = {}
    for key in key_list:
        d[key] = getattr(proto_obj, key)
    return d
</code>```

Since the converters from Google's protobuf library don't seem to work in some cases with the 3.19 version, this function leverages the Descriptor class present on each Protobuf object.

Here, getattr(obj, string_attribute) returns the value given by obj.attribute

ContentLicense: CC BY-SA 3.0

Title: Protobuf to json in python

Body:
I have an object that I de-serialize using protobuf in Python. When I print the object it looks like a python object, however when I try to convert it to json I have all sorts of problems.

For example, if I use json.dumps() I get that the object (the generated code from protoc) does not contain a _ dict _ error.

If I use jsonpickle I get UnicodeDecodeError: 'utf8' codec can't decode byte 0x9d in position 97: invalid start byte.

Test code below is using jsonpickle with the error shown above.

if len(sys.argv) < 2:
    print ("Error: missing ser file")
    sys.exit()
else :
    fileLocation = sys.argv[1]

org = BuildOrgObject(fileLocation)

org = org.Deserialize()

#print (org)
jsonObj = jsonpickle.encode(org)
print (jsonObj)

Body:
Here's my function to convert a proto3 object to a JSON object (i.e. Python dictionary):

def protobuf_to_dict(proto_obj):
    key_list = proto_obj.DESCRIPTOR.fields_by_name.keys()
    d = {}
    for key in key_list:
        d[key] = getattr(proto_obj, key)
    return d

Since the converters from Google's protobuf library don't seem to work in some cases with the 3.19 version, this function leverages the Descriptor class present on each Protobuf object.

Here, getattr(obj, string_attribute) returns the value given by obj.attribute


问:
How do I set my page so that the Enter key event does not trigger postback?
In one of my asp web pages there is a textbox, where I use jQuery to display content in textbox above it when user hit the Enter key. However, it always trigger postback, so the content will disappear immediately after displaying. How do I keep that postback from happening?</p>

答:
This should do it.</p>

```<code>$('your selector').keyup(function (e) {
    if (e.keyCode === 13) {
        e.preventDefault();
    }
});
</code>```

Body:
This should do it.

$('your selector').keyup(function (e) {
    if (e.keyCode === 13) {
        e.preventDefault();
    }
});


问:
Getting org.springframework.beans.NotWritablePropertyException
I am currently learning Spring. I am in dependency injection topic and I am trying to practice injecting Reference obejct into setters through DI. But I am facing a issue.

Client.java

```<code>package bean.driver;

import bean.Car;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class Client {

    public static void main(String [] args)
    {
        String files[] = new String[]{"engine.xml","car.xml"};
        ApplicationContext applicationContext = new ClassPathXmlApplicationContext(files);

        Car car = (Car) applicationContext.getBean("car");
        //car.printdata();
        car.printcardata();

    }
}
</code>```

Car.java

```<code>package bean;

public class Car {

    private String carname;
    private Engine engine;
    private int cost;
    private int yearofRelease;
    private int maxspeed;
    private Inventory inventory;
    private String engineversion;

    /*Car(String carname, Engine engine)
    {
        this.carname = carname;
        this.engine = engine;
    }*/
    Car(String name,Engine engine,Inventory inventory, int maxspeed)
    {
        this.carname = name;
        this.maxspeed = maxspeed;
        this.engine = engine;
        this.inventory = inventory;
    }

    public void setCost(int cost)
    {
        this.cost = cost;
    }
    public void setYearofRelease(int yearofRelease)
    {
        this.yearofRelease = yearofRelease;
        System.out.println(engine.getEngineversion());
    }
    /*public void setEngine(Engine engine2)
    {
        this.engineversion = engine2.getEngineversion();
    }
    public String getEngineversion()
    {
        return engineversion;
    }*/

    public void setEngineVersion(Engine engine)
    {
        this.engineversion = engine.getEngineversion();
    }
    public void printdata()
    {
        System.out.println(carname + " "+ engine.getModel() +" "+cost+" "+yearofRelease);
    }

    public void printcardata()
    {
        System.out.println("Carname:-"+carname+"\n"+"Cost:-"+cost+"\n"+"MaxSpeed:-"+maxspeed+"\n"+
                "Year of Release:-"+yearofRelease+"\n"+"Engine model:-"+engine.getModel()+"\n"+
                "No of Units:-"+inventory.getNoofinitalunits()+"\n"+"Engine Version:-"+engineversion);
    }

}
</code>```

Engine.java

```<code>package bean;

public class Engine {

    private String model;
    private String engineversion;

    Engine(String model)
    {
        this.model = model;
    }

    public void setEngineversion(String engineversion) {
        this.engineversion = engineversion;
    }

    public String getModel()
    {
        return model;
    }

    public String getEngineversion()
    {
        return engineversion;
    }
}
</code>```

car.xml

<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN"
        "https://www.springframework.org/dtd/spring-beans-2.0.dtd">

<beans>

    <bean id="car" class="bean.Car">

         <constructor-arg ref="engine"/>

         <constructor-arg>
         <ref bean="inventory"></ref>
        </constructor-arg>

        <constructor-arg value="Suzuki"/>
        <constructor-arg>
            <value>230</value>
        </constructor-arg>

        <property name="cost" value="10"/>
        <property name="yearofRelease">
            <value>1994</value>
        </property>

        <property name="engine" ref="engine"></property>

    </bean>

    <bean id="inventory" class="bean.Inventory">
        <constructor-arg>
            <value>1000</value>
        </constructor-arg>
    </bean>

    <bean id="engine2" class="bean.Engine">
        <constructor-arg value="S88"/>
        <property name="engineversion" value="V11"/>
    </bean>
</beans>
```
<p>engine.xml</p>
<pre class="lang-xml prettyprint-override"><code><!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN"
        "https://www.springframework.org/dtd/spring-beans-2.0.dtd">

<beans>

    <bean id="engine" class="bean.Engine">

        <constructor-arg value="S88"/>
        <property name="engineversion" value="V11"/>

    </bean>

    <bean id="engine2" class="bean.Engine">

        <constructor-arg value="S88"/>
        <property name="engineversion" value="V11"/>

    </bean>

</beans>
</code>```

Error

```<code>"C:\Program Files\Java\jdk-15.0.1\bin\java.exe" "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2020.2.3\lib\idea_rt.jar=51693:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2020.2.3\bin" -Dfile.encoding=UTF-8 -classpath D:\Spring-2\target\classes;C:\Users\chris\Downloads\spring-beans-5.3.15.jar;C:\Users\chris\Downloads\spring-context-5.3.15.jar;C:\Users\chris\Downloads\spring-core-5.3.15.jar;C:\Users\chris\Downloads\spring-expression-5.3.15.jar;C:\Users\chris\Downloads\commons-logging-1.2.jar bean.driver.Client
V11
Feb 06, 2022 1:53:20 PM org.springframework.context.support.ClassPathXmlApplicationContext refresh
WARNING: Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'car' defined in class path resource [car.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'engine' of bean class [bean.Car]: Bean property 'engine' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'car' defined in class path resource [car.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'engine' of bean class [bean.Car]: Bean property 'engine' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1744)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1452)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:619)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542)
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:953)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583)
    at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:144)
    at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:95)
    at bean.driver.Client.main(Client.java:12)
Caused by: org.springframework.beans.NotWritablePropertyException: Invalid property 'engine' of bean class [bean.Car]: Bean property 'engine' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
    at org.springframework.beans.BeanWrapperImpl.createNotWritablePropertyException(BeanWrapperImpl.java:243)
    at org.springframework.beans.AbstractNestablePropertyAccessor.processLocalProperty(AbstractNestablePropertyAccessor.java:432)
    at org.springframework.beans.AbstractNestablePropertyAccessor.setPropertyValue(AbstractNestablePropertyAccessor.java:278)
    at org.springframework.beans.AbstractNestablePropertyAccessor.setPropertyValue(AbstractNestablePropertyAccessor.java:266)
    at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:104)
    at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:79)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1740)

Process finished with exit code 1
</code>```

See the property name is engine and also in xml document I have mentioned as engine only. But still getting the error.

答:
Xml configuration is old ,its better you read about new xml configuration.
You should change your xml file like below code.

Car.xml

```<code><?xml version="1.0" encoding="UTF-8"?>
<beans:beans
        xmlns:beans="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://www.springframework.org/schema/beans
       http://www.springframework.org/schema/beans/spring-beans.xsd">

    <beans:bean id="car" class="com.example.stackoverfollw.Car">

        <beans:constructor-arg index="0" value="220"/>
        <beans:constructor-arg index="1" ref="engine"/>
        <beans:constructor-arg index="2" ref="inventory"/>
        <beans:constructor-arg index="3" value="650"/>
    </beans:bean>

    <beans:bean id="engine" class="com.example.stackoverfollw.Engine">
        <beans:constructor-arg value="V11"/>
    </beans:bean>

    <beans:bean id="inventory" class="com.example.stackoverfollw.Inventory">
    </beans:bean>

</beans:beans>
</code>```

Engine.xml

```<code><?xml version="1.0" encoding="UTF-8"?>
<beans:beans
        xmlns:beans="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://www.springframework.org/schema/beans
       http://www.springframework.org/schema/beans/spring-beans.xsd">

    <beans:bean id="engine" class="com.example.stackoverfollw.Engine">
        <beans:constructor-arg value="v22"/>
    </beans:bean>

</beans:beans>
</code>```

For more information about bean

https://www.tutorialspoint.com/spring/spring_bean_definition.htm#:~:text=A%20bean%20is%20an%20object,seen%20in%20the%20previous%20chapters

https://docs.spring.io/spring-framework/docs/4.2.x/spring-framework-reference/html/xsd-configuration.html

Body:
I am currently learning Spring. I am in dependency injection topic and I am trying to practice injecting Reference obejct into setters through DI. But I am facing a issue.

Client.java

package bean.driver;

import bean.Car;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class Client {

    public static void main(String [] args)
    {
        String files[] = new String[]{"engine.xml","car.xml"};
        ApplicationContext applicationContext = new ClassPathXmlApplicationContext(files);

        Car car = (Car) applicationContext.getBean("car");
        //car.printdata();
        car.printcardata();

    }
}

Car.java

package bean;

public class Car {

    private String carname;
    private Engine engine;
    private int cost;
    private int yearofRelease;
    private int maxspeed;
    private Inventory inventory;
    private String engineversion;

    /*Car(String carname, Engine engine)
    {
        this.carname = carname;
        this.engine = engine;
    }*/
    Car(String name,Engine engine,Inventory inventory, int maxspeed)
    {
        this.carname = name;
        this.maxspeed = maxspeed;
        this.engine = engine;
        this.inventory = inventory;
    }

    public void setCost(int cost)
    {
        this.cost = cost;
    }
    public void setYearofRelease(int yearofRelease)
    {
        this.yearofRelease = yearofRelease;
        System.out.println(engine.getEngineversion());
    }
    /*public void setEngine(Engine engine2)
    {
        this.engineversion = engine2.getEngineversion();
    }
    public String getEngineversion()
    {
        return engineversion;
    }*/

    public void setEngineVersion(Engine engine)
    {
        this.engineversion = engine.getEngineversion();
    }
    public void printdata()
    {
        System.out.println(carname + " "+ engine.getModel() +" "+cost+" "+yearofRelease);
    }

    public void printcardata()
    {
        System.out.println("Carname:-"+carname+"\n"+"Cost:-"+cost+"\n"+"MaxSpeed:-"+maxspeed+"\n"+
                "Year of Release:-"+yearofRelease+"\n"+"Engine model:-"+engine.getModel()+"\n"+
                "No of Units:-"+inventory.getNoofinitalunits()+"\n"+"Engine Version:-"+engineversion);
    }

}

Engine.java

package bean;

public class Engine {

    private String model;
    private String engineversion;

    Engine(String model)
    {
        this.model = model;
    }

    public void setEngineversion(String engineversion) {
        this.engineversion = engineversion;
    }

    public String getModel()
    {
        return model;
    }

    public String getEngineversion()
    {
        return engineversion;
    }
}

car.xml

<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN"
        "https://www.springframework.org/dtd/spring-beans-2.0.dtd">

<beans>

    <bean id="car" class="bean.Car">

         <constructor-arg ref="engine"/>

         <constructor-arg>
         <ref bean="inventory"></ref>
        </constructor-arg>

        <constructor-arg value="Suzuki"/>
        <constructor-arg>
            <value>230</value>
        </constructor-arg>

        <property name="cost" value="10"/>
        <property name="yearofRelease">
            <value>1994</value>
        </property>

        <property name="engine" ref="engine"></property>

    </bean>

    <bean id="inventory" class="bean.Inventory">
        <constructor-arg>
            <value>1000</value>
        </constructor-arg>
    </bean>

    <bean id="engine2" class="bean.Engine">
        <constructor-arg value="S88"/>
        <property name="engineversion" value="V11"/>
    </bean>
</beans>

engine.xml

<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN"
        "https://www.springframework.org/dtd/spring-beans-2.0.dtd">

<beans>

    <bean id="engine" class="bean.Engine">

        <constructor-arg value="S88"/>
        <property name="engineversion" value="V11"/>

    </bean>

    <bean id="engine2" class="bean.Engine">

        <constructor-arg value="S88"/>
        <property name="engineversion" value="V11"/>

    </bean>

</beans>

Error

"C:\Program Files\Java\jdk-15.0.1\bin\java.exe" "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2020.2.3\lib\idea_rt.jar=51693:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2020.2.3\bin" -Dfile.encoding=UTF-8 -classpath D:\Spring-2\target\classes;C:\Users\chris\Downloads\spring-beans-5.3.15.jar;C:\Users\chris\Downloads\spring-context-5.3.15.jar;C:\Users\chris\Downloads\spring-core-5.3.15.jar;C:\Users\chris\Downloads\spring-expression-5.3.15.jar;C:\Users\chris\Downloads\commons-logging-1.2.jar bean.driver.Client
V11
Feb 06, 2022 1:53:20 PM org.springframework.context.support.ClassPathXmlApplicationContext refresh
WARNING: Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'car' defined in class path resource [car.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'engine' of bean class [bean.Car]: Bean property 'engine' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'car' defined in class path resource [car.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'engine' of bean class [bean.Car]: Bean property 'engine' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1744)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1452)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:619)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542)
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:953)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583)
    at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:144)
    at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:95)
    at bean.driver.Client.main(Client.java:12)
Caused by: org.springframework.beans.NotWritablePropertyException: Invalid property 'engine' of bean class [bean.Car]: Bean property 'engine' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
    at org.springframework.beans.BeanWrapperImpl.createNotWritablePropertyException(BeanWrapperImpl.java:243)
    at org.springframework.beans.AbstractNestablePropertyAccessor.processLocalProperty(AbstractNestablePropertyAccessor.java:432)
    at org.springframework.beans.AbstractNestablePropertyAccessor.setPropertyValue(AbstractNestablePropertyAccessor.java:278)
    at org.springframework.beans.AbstractNestablePropertyAccessor.setPropertyValue(AbstractNestablePropertyAccessor.java:266)
    at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:104)
    at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:79)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1740)

Process finished with exit code 1

See the property name is engine and also in xml document I have mentioned as engine only. But still getting the error.

Body:
Xml configuration is old ,its better you read about new xml configuration.
You should change your xml file like below code.

Car.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans:beans
        xmlns:beans="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://www.springframework.org/schema/beans
       http://www.springframework.org/schema/beans/spring-beans.xsd">

    <beans:bean id="car" class="com.example.stackoverfollw.Car">

        <beans:constructor-arg index="0" value="220"/>
        <beans:constructor-arg index="1" ref="engine"/>
        <beans:constructor-arg index="2" ref="inventory"/>
        <beans:constructor-arg index="3" value="650"/>
    </beans:bean>

    <beans:bean id="engine" class="com.example.stackoverfollw.Engine">
        <beans:constructor-arg value="V11"/>
    </beans:bean>

    <beans:bean id="inventory" class="com.example.stackoverfollw.Inventory">
    </beans:bean>

</beans:beans>

Engine.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans:beans
        xmlns:beans="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://www.springframework.org/schema/beans
       http://www.springframework.org/schema/beans/spring-beans.xsd">

    <beans:bean id="engine" class="com.example.stackoverfollw.Engine">
        <beans:constructor-arg value="v22"/>
    </beans:bean>

</beans:beans>

For more information about bean

https://www.tutorialspoint.com/spring/spring_bean_definition.htm#:~:text=A%20bean%20is%20an%20object,seen%20in%20the%20previous%20chapters

https://docs.spring.io/spring-framework/docs/4.2.x/spring-framework-reference/html/xsd-configuration.html


问:
Access n:th element of every list in list of lists
I have a problem in python and one step I need to do is to access the second element of every list in a list of lists. The list is:

```<code>[(0, 'Gallery', 'PROPN', 'nsubj'), (1, 'unveils', 'VERB', 'root'), (2, 'interactive', 'ADJ', 'amod')]

[(0, 'A', 'DET' 'det'), (1 'Christmas' , 'PROPN', 'compound'), (2, 'tree' ,'NOUN', 'nsubjpass')]
</code>```

The list goes on like that with different sentences for each list.

What I am trying to do is access the third (index 2) element of every list of every tuple. So from the first list, I want to get:

PROPN (from 'Gallery')

VERB (from 'unveils')

ADJ (from 'interactive')

And from the second list I want to get:

DET (from 'A')

PROPN (from 'Christmas')

NOUN (from 'nsubjpass)

What I've tried to do is this:

```<code>for word in list:
      print(list[word[0]][2])
</code>```

But that only outputs the second element from the first list. I tried creating another foor-loop but that didn't work, I suspect I did it wrong but I'm not sure how to solve it

Help would be appreciated

Thanks in advance!

答:
when you are enumerating over the list in the for loop:

```<code>for word in words:
    pass // do something
</code>```

You have already accessed the element in the list and stored it in word.

As such, word[0] in your loop would be accessing the first element in your word tuple which is not what you'd like to do.

Instead, you'd like to access word[2] in your tuple, so something like this should work:

```<code>first_list = [(0, 'Gallery', 'PROPN', 'nsubj'), (1, 'unveils', 'VERB', 'root'), (2, 'interactive', 'ADJ', 'amod')]

second_list = [(0, 'A', 'DET' 'det'), (1, 'Christmas' , 'PROPN', 'compound'), (2, 'tree' ,'NOUN', 'nsubjpass')]

def print_word_pos(words):
    for word in words:
        print(word[2])

print_word_pos(first_list)
print_word_pos(second_list)
</code>```

Another thing is that you should not be naming your lists as list since list is a reserved python keyword and might (will) cause conflict later down the line.

Now if the first two lists were combined, you'd want to loop over each list and then for each word in that list, print out the part of speech.

```<code>def print_word_pos(list_of_words):
    for words in list_of_words:
        for word in words:
            print(word[2])
</code>```

Body:
I have a problem in python and one step I need to do is to access the second element of every list in a list of lists. The list is:

[(0, 'Gallery', 'PROPN', 'nsubj'), (1, 'unveils', 'VERB', 'root'), (2, 'interactive', 'ADJ', 'amod')]

[(0, 'A', 'DET' 'det'), (1 'Christmas' , 'PROPN', 'compound'), (2, 'tree' ,'NOUN', 'nsubjpass')]

The list goes on like that with different sentences for each list.

What I am trying to do is access the third (index 2) element of every list of every tuple. So from the first list, I want to get:

PROPN (from 'Gallery')

VERB (from 'unveils')

ADJ (from 'interactive')

And from the second list I want to get:

DET (from 'A')

PROPN (from 'Christmas')

NOUN (from 'nsubjpass)

What I've tried to do is this:

for word in list:
      print(list[word[0]][2])

But that only outputs the second element from the first list. I tried creating another foor-loop but that didn't work, I suspect I did it wrong but I'm not sure how to solve it

Help would be appreciated

Thanks in advance!

Body:
when you are enumerating over the list in the for loop:

for word in words:
    pass // do something

You have already accessed the element in the list and stored it in word.

As such, word[0] in your loop would be accessing the first element in your word tuple which is not what you'd like to do.

Instead, you'd like to access word[2] in your tuple, so something like this should work:

first_list = [(0, 'Gallery', 'PROPN', 'nsubj'), (1, 'unveils', 'VERB', 'root'), (2, 'interactive', 'ADJ', 'amod')]

second_list = [(0, 'A', 'DET' 'det'), (1, 'Christmas' , 'PROPN', 'compound'), (2, 'tree' ,'NOUN', 'nsubjpass')]

def print_word_pos(words):
    for word in words:
        print(word[2])

print_word_pos(first_list)
print_word_pos(second_list)

Another thing is that you should not be naming your lists as list since list is a reserved python keyword and might (will) cause conflict later down the line.

Now if the first two lists were combined, you'd want to loop over each list and then for each word in that list, print out the part of speech.

def print_word_pos(list_of_words):
    for words in list_of_words:
        for word in words:
            print(word[2])


问:
Binary Tree Transversing
I'm really new to coding and was stuck at one of the Leetcode problems on Binary Tree Transversing.

Can anyone please explain what the following line of code means:

```<code>def preorderTraversal(self, root: Optional[TreeNode]) -> List[int]:
</code>```

From what I understood, the core was trying to define a function pre-order traversal and a class TreeNode was defined earlier. However I was not able to get what root: Optional[TreeNode] and ->List[int] meant.

Thanks in advance

答:
If it helps, you can ignore the type hints in that function declaration. If you change it to this, it will still work:

```<code>def preorderTraversal(self, root):
</code>```

The type hints are helping editors (and you) to know the expected type of parameters and of the function's return value:

Optional: this means the value could be None

TreeNode: this means the value is an instance of the class TreeNode. LeetCode provides its definition in a comment block in the original code template you get to work with. It is indeed predefined.

List[int]: this means the returned value should be a list, and the list elements should be integers.

Title: Binary Tree Transversing

Body:
I'm really new to coding and was stuck at one of the Leetcode problems on Binary Tree Transversing.

Can anyone please explain what the following line of code means:

def preorderTraversal(self, root: Optional[TreeNode]) -> List[int]:

From what I understood, the core was trying to define a function pre-order traversal and a class TreeNode was defined earlier. However I was not able to get what root: Optional[TreeNode] and ->List[int] meant.

Thanks in advance

Body:
If it helps, you can ignore the type hints in that function declaration. If you change it to this, it will still work:

def preorderTraversal(self, root):

The type hints are helping editors (and you) to know the expected type of parameters and of the function's return value:

Optional: this means the value could be None

TreeNode: this means the value is an instance of the class TreeNode. LeetCode provides its definition in a comment block in the original code template you get to work with. It is indeed predefined.

List[int]: this means the returned value should be a list, and the list elements should be integers.


问:
Brownie test IndexError: list index out of range
Macbook Pro : Monterey

Intel Core i7

Brownie v1.17.2

Ganache CLI v6.12.2 (ganache-core: 2.13.2)

I am learning solidity according to reference(https://www.youtube.com/watch?v=M576WGiDBdQ&t=25510s).

I wrote and deployed a smart contract（scripts/deploy.py） using brownie framework, it worked.

Then tried to write a test script（tests/test_simple_storage.py） that gave me error information in the terminal.

Googled this and tried to delete all the files in brownie projects' build folder and deployed the contract（scripts/deploy.py） again， it's the same error.

And tried to change the private key and index, for accounts[0]to account[-1]and account[1]， the same error result.

FYI:I typed the command "ganache-cli —deterministic " in the terminal. So the account and private key are not random.

Saved the Ganache's account[0]'s private key in .env files,like this

.env

```<code>export PRIVATE_KEY=0x91114a07f248a1c50951cb11557af5424cc6a49bf61521874c9ae3f4ae239a6d
</code>```

Error Info：

```<code>(base) liwei@liweideMacBook-Pro Brownie_Simple_Storage % brownie test
Brownie v1.17.2 - Python development framework for Ethereum

========================================================== test session starts ===========================================================
platform darwin -- Python 3.8.5, pytest-6.2.5, py-1.11.0, pluggy-1.0.0
rootdir: /Users/liwei/Desktop/demos/practice/Brownie_Simple_Storage
plugins: eth-brownie-1.17.2, xdist-1.34.0, hypothesis-6.27.3, web3-5.25.0, forked-1.3.0
collected 0 items / 1 error

================================================================= ERRORS =================================================================
_____________________________________________ ERROR collecting tests/test_simple_storage.py ______________________________________________
tests/test_simple_storage.py:5: in <module>
    account = accounts[0]
E   IndexError: list index out of range
======================================================== short test summary info =========================================================
FAILED tests/test_simple_storage.py - IndexError: list index out of range
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
============================================================ 1 error in 0.25s ============================================================
(base) liwei@liweideMacBook-Pro Brownie_Simple_Storage %

</code>```

test script--"tests/test_simple_storage.py“

```<code>from brownie import accounts, SimpleStorage

# Arrange
account = accounts[0]
print(account)
# Act
simple_storage = SimpleStorage.deploy({"from": account})
starting_value = simple_storage.retrieve()
expected = 0
# Assert
assert starting_value == expected

</code>```

smartcontract deployed well,use the same local blockchain,ganache-cli
“scripts/deploy.py”

```<code>from brownie import accounts, config, SimpleStorage
import os

def deploy_simple_storage():

    # load from you set encrypted , not from ganache-cli which is brownie automated connceted to
    # account = accounts.load("MG515-account")
    # print(account)

    # add private key use enviroment variables
    # account = accounts.add(os.getenv("PRIVATE_KEY"))
    # print(account)

    # .deploy() , always need a "from"key in a dictinary when making a transaction
    account = accounts.add(config["wallets"]["from_key"])
    simple_storage = SimpleStorage.deploy({"from": account})
    stored_value = simple_storage.retrieve()
    print("Current stored value is ：")
    print(stored_value)
    print("Updating Contract...")
    transaction = simple_storage.store(15, {"from": account})
    transaction.wait(1)
    updated_store_value = simple_storage.retrieve()
    print("Current stored value is ：")
    print(updated_store_value)
    print(account)

def main():
    deploy_simple_storage()

</code>```

updated on 20220111

After read brownie docs find this command "network.connect("development")" ,is this command set the network right , I remembered brownie should default connect to development network.

so updated the code like this

```<code>from brownie import accounts, SimpleStorage, network

network.connect("development")

# Arrange
account = accounts[0]

print(accounts)
# Act
simple_storage = SimpleStorage.deploy({"from": account})
starting_value = simple_storage.retrieve()
expected = 0
# Assert

assert starting_value == expected
</code>```

and the terminal give one warning information

```<code>(base) liwei@liweideMacBook-Pro Brownie_Simple_Storage % brownie test
Brownie v1.17.2 - Python development framework for Ethereum

========================================================== test session starts ==========================================================
platform darwin -- Python 3.8.5, pytest-6.2.5, py-1.11.0, pluggy-1.0.0
rootdir: /Users/liwei/Desktop/demos/practice/Brownie_Simple_Storage
plugins: eth-brownie-1.17.2, xdist-1.34.0, hypothesis-6.27.3, web3-5.25.0, forked-1.3.0
collected 0 items

=========================================================== warnings summary ============================================================
../../../../.local/pipx/venvs/eth-brownie/lib/python3.8/site-packages/brownie/network/main.py:44
  /Users/liwei/.local/pipx/venvs/eth-brownie/lib/python3.8/site-packages/brownie/network/main.py:44: BrownieEnvironmentWarning: Development network has a block height of 2
    warnings.warn(

-- Docs: https://docs.pytest.org/en/stable/warnings.html
========================================================== 1 warning in 0.49s ===========================================================
</code>```

答:
the problem solved,forget to write the part "def test_deploy():"</p>
```<code>def test_deploy():
    # Arrange
    account = accounts[0]

    # Act
    simple_storage = SimpleStorage.deploy({"from": account})
    starting_value = simple_storage.retrieve()
    expected = 0
    # Assert

    assert starting_value == expected
</code>```

Body:
Macbook Pro : Monterey

Intel Core i7

Brownie v1.17.2

Ganache CLI v6.12.2 (ganache-core: 2.13.2)

I am learning solidity according to reference(https://www.youtube.com/watch?v=M576WGiDBdQ&t=25510s).

I wrote and deployed a smart contract（scripts/deploy.py） using brownie framework, it worked.

Then tried to write a test script（tests/test_simple_storage.py） that gave me error information in the terminal.

Googled this and tried to delete all the files in brownie projects' build folder and deployed the contract（scripts/deploy.py） again， it's the same error.

And tried to change the private key and index, for accounts[0]to account[-1]and account[1]， the same error result.

FYI:I typed the command "ganache-cli —deterministic " in the terminal. So the account and private key are not random.

Saved the Ganache's account[0]'s private key in .env files,like this

.env

export PRIVATE_KEY=0x91114a07f248a1c50951cb11557af5424cc6a49bf61521874c9ae3f4ae239a6d

Error Info：

(base) liwei@liweideMacBook-Pro Brownie_Simple_Storage % brownie test
Brownie v1.17.2 - Python development framework for Ethereum

========================================================== test session starts ===========================================================
platform darwin -- Python 3.8.5, pytest-6.2.5, py-1.11.0, pluggy-1.0.0
rootdir: /Users/liwei/Desktop/demos/practice/Brownie_Simple_Storage
plugins: eth-brownie-1.17.2, xdist-1.34.0, hypothesis-6.27.3, web3-5.25.0, forked-1.3.0
collected 0 items / 1 error

================================================================= ERRORS =================================================================
_____________________________________________ ERROR collecting tests/test_simple_storage.py ______________________________________________
tests/test_simple_storage.py:5: in <module>
    account = accounts[0]
E   IndexError: list index out of range
======================================================== short test summary info =========================================================
FAILED tests/test_simple_storage.py - IndexError: list index out of range
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
============================================================ 1 error in 0.25s ============================================================
(base) liwei@liweideMacBook-Pro Brownie_Simple_Storage %

test script--"tests/test_simple_storage.py“

from brownie import accounts, SimpleStorage

# Arrange
account = accounts[0]
print(account)
# Act
simple_storage = SimpleStorage.deploy({"from": account})
starting_value = simple_storage.retrieve()
expected = 0
# Assert
assert starting_value == expected

smartcontract deployed well,use the same local blockchain,ganache-cli
“scripts/deploy.py”

from brownie import accounts, config, SimpleStorage
import os

def deploy_simple_storage():

    # load from you set encrypted , not from ganache-cli which is brownie automated connceted to
    # account = accounts.load("MG515-account")
    # print(account)

    # add private key use enviroment variables
    # account = accounts.add(os.getenv("PRIVATE_KEY"))
    # print(account)

    # .deploy() , always need a "from"key in a dictinary when making a transaction
    account = accounts.add(config["wallets"]["from_key"])
    simple_storage = SimpleStorage.deploy({"from": account})
    stored_value = simple_storage.retrieve()
    print("Current stored value is ：")
    print(stored_value)
    print("Updating Contract...")
    transaction = simple_storage.store(15, {"from": account})
    transaction.wait(1)
    updated_store_value = simple_storage.retrieve()
    print("Current stored value is ：")
    print(updated_store_value)
    print(account)

def main():
    deploy_simple_storage()

updated on 20220111

After read brownie docs find this command "network.connect("development")" ,is this command set the network right , I remembered brownie should default connect to development network.

so updated the code like this

from brownie import accounts, SimpleStorage, network

network.connect("development")

# Arrange
account = accounts[0]

print(accounts)
# Act
simple_storage = SimpleStorage.deploy({"from": account})
starting_value = simple_storage.retrieve()
expected = 0
# Assert

assert starting_value == expected

and the terminal give one warning information

(base) liwei@liweideMacBook-Pro Brownie_Simple_Storage % brownie test
Brownie v1.17.2 - Python development framework for Ethereum

========================================================== test session starts ==========================================================
platform darwin -- Python 3.8.5, pytest-6.2.5, py-1.11.0, pluggy-1.0.0
rootdir: /Users/liwei/Desktop/demos/practice/Brownie_Simple_Storage
plugins: eth-brownie-1.17.2, xdist-1.34.0, hypothesis-6.27.3, web3-5.25.0, forked-1.3.0
collected 0 items

=========================================================== warnings summary ============================================================
../../../../.local/pipx/venvs/eth-brownie/lib/python3.8/site-packages/brownie/network/main.py:44
  /Users/liwei/.local/pipx/venvs/eth-brownie/lib/python3.8/site-packages/brownie/network/main.py:44: BrownieEnvironmentWarning: Development network has a block height of 2
    warnings.warn(

-- Docs: https://docs.pytest.org/en/stable/warnings.html
========================================================== 1 warning in 0.49s ===========================================================

Body:
the problem solved,forget to write the part "def test_deploy():"

def test_deploy():
    # Arrange
    account = accounts[0]

    # Act
    simple_storage = SimpleStorage.deploy({"from": account})
    starting_value = simple_storage.retrieve()
    expected = 0
    # Assert

    assert starting_value == expected


问:
Slot stops after certain child element in Vue2
I have two simple vue components and want to use one in the default slot of the other. For some reason it takes only the first element but does not show anything after that. If I put standard  before this first element it will show up normal, but if I place if after it will also not be displayed.

The page:

```<code><div id="app">
    <v-app>
        <v-main>
            <gantt-chart>
                <div> this is visible </div>
                <gantt-row key="1" title="test 1"/>
                <div> nothing of this and beyond is shown</div>
                <gantt-row key="2" title="test 2"/>
                <gantt-row key="3" title="test 3"/>
            </gantt-chart>
        </v-main>
    </v-app>
</div>
<script type="text/javascript">
    Vue.component("gantt-chart", httpVueLoader('/plugin_assets/javascripts/components/GanttChart.vue'));
    Vue.component("gantt-row", httpVueLoader('/plugin_assets/javascripts/components/GanttRow.vue'));
    var app = new Vue({
        el: '#app',
    })
</script>
</code>```

gantt-chart.vue:

<template>

      <slot />

</template>

```
<p>gantt-row.vue:</p>
<pre class="lang-html prettyprint-override"><code><template>
    <div>
      {{ title }}
    </div>
</template>

<script>
module.exports = {
  props: ["title"],
  name:"GanttRow",
  data() {
    return {};
  },
  computed: {},
  methods: {},
};
</script>

<style scoped></style>
</code>```

result:

答:
One of the caveats of in-DOM templates is that custom elements cannot be self-closing. The DOM parser sees <gantt-row />, but treats it only as an opening tag. Since the tag is technically not yet closed, it wraps the following elements as children. GanttRow.vue's template has no <slot>, so the nested elements would not be visible. This all occurs before the scripting stage (before Vue receives the DOM for template handling).

For instance, run the code snippet below, and inspect the resulting document:

 this is visible

<gantt-row key="1" title="test 1"/>

 nothing of this and beyond is shown

<gantt-row key="2" title="test 2"/>
<gantt-row key="3" title="test 3"/>```
</div>
</div>
</p>
<p>You'll notice that becomes:</p>
<pre class="lang-html prettyprint-override"><code><div> this is visible </div>
<gantt-row key="1" title="test 1">
  <div> nothing of this and beyond is shown</div>
  <gantt-row key="2" title="test 2">
    <gantt-row key="3" title="test 3">
      <script type="text/javascript"></script>
    </gantt-row>
  </gantt-row>
</gantt-row>
</code>```

If you prefer to continue using in-DOM templates, use a normal closing tag for Vue components:

<gantt-chart>

 this is visible

  <gantt-row key="1" title="test 1"></gantt-row>

 everything below is also shown now

  <gantt-row key="2" title="test 2"></gantt-row>

  <gantt-row key="3" title="test 3"></gantt-row>
</gantt-chart>
```

Body:
I have two simple vue components and want to use one in the default slot of the other. For some reason it takes only the first element but does not show anything after that. If I put standard  before this first element it will show up normal, but if I place if after it will also not be displayed.

The page:

    <v-app>
        <v-main>
            <gantt-chart>

 this is visible

                <gantt-row key="1" title="test 1"/>

 nothing of this and beyond is shown

                <gantt-row key="2" title="test 2"/>
                <gantt-row key="3" title="test 3"/>
            </gantt-chart>
        </v-main>
    </v-app>

gantt-chart.vue:

<template>

      <slot />

</template>

gantt-row.vue:

<template>

      {{ title }}

</template>

result:

Body:
One of the caveats of in-DOM templates is that custom elements cannot be self-closing. The DOM parser sees <gantt-row />, but treats it only as an opening tag. Since the tag is technically not yet closed, it wraps the following elements as children. GanttRow.vue's template has no <slot>, so the nested elements would not be visible. This all occurs before the scripting stage (before Vue receives the DOM for template handling).

For instance, run the code snippet below, and inspect the resulting document:

<div> this is visible </div>
<gantt-row key="1" title="test 1"/>
<div> nothing of this and beyond is shown</div>
<gantt-row key="2" title="test 2"/>
<gantt-row key="3" title="test 3"/>

You'll notice that becomes:

<div> this is visible </div>
<gantt-row key="1" title="test 1">
  <div> nothing of this and beyond is shown</div>
  <gantt-row key="2" title="test 2">
    <gantt-row key="3" title="test 3">
      <script type="text/javascript"></script>
    </gantt-row>
  </gantt-row>
</gantt-row>

If you prefer to continue using in-DOM templates, use a normal closing tag for Vue components:

<gantt-chart>
  <div> this is visible </div>
  <gantt-row key="1" title="test 1"></gantt-row>
  <div> everything below is also shown now </div>

  <gantt-row key="2" title="test 2"></gantt-row>

  <gantt-row key="3" title="test 3"></gantt-row>
</gantt-chart>


问:
Different Widgets on theme change flutter dart
I wanted to implement multiple themes in my flutter app with certain colors. Now I want the user to be able, to switch between dark- and light mode but the widgets are different when dark mode is applied... Look at the designs below

As you can see the widgets are completely different... If you know how to do it, please leave me an answer, thanks!

答:
to do so, you have to implement a MultiProvider for changing themes, a sharedpreferences plugin for saving and restoring booleans. and to change a certain color you use a boolean. Example :

mytheme.dart

```<code>const MaterialColor myColor = MaterialColor(0xFF134E57, <int, Color>{
  50: Color(0xFFE6ECED),
  100: Color(0xFFBFD0D3),
  200: Color(0xFF95B1B5),
  300: Color(0xFF6B9297),
  400: Color(0xFF4B7A81),
  500: Color(0xFF2B636B), //warna tombol add
  600: Color(0xFF265B63),
  700: Color(0xFF205158),
  800: Color(0xFF1A474E),
  900: Color(0xFF10353C),
});

ThemeData light = ThemeData(
  fontFamily: 'NunitoRE',
  brightness: Brightness.light,
  primarySwatch: myColor,
  textTheme: const TextTheme(bodyText2: TextStyle(color: Color(0xff010101))),
  appBarTheme: const AppBarTheme(
    iconTheme: IconThemeData(color: Color(0xfffafafa)),
    backgroundColor: Color(0xFF134E57),
    titleSpacing: 0,
    elevation: 0,
    centerTitle: false,
    titleTextStyle: TextStyle(color: Color(0xfffafafa), fontSize: 18, fontFamily: "NunitoBL", shadows: shaDow),
  ),
);

ThemeData dark = ThemeData(
  fontFamily: 'NunitoRE',
  brightness: Brightness.dark,
  hintColor: const Color(0xb3ffffff),
  focusColor: const Color(0xb3ffffff),
  textTheme: const TextTheme(bodyText2: TextStyle(color: Color(0xfffafafa))),
  appBarTheme: const AppBarTheme(
    elevation: 0,
    iconTheme: IconThemeData(color: Color(0xfffafafa)),
    backgroundColor: Color(0xFF222222),
    titleSpacing: 0,
    centerTitle: false,
    titleTextStyle: TextStyle(color: Color(0xfffafafa), fontSize: 18, fontFamily: "NunitoBL", shadows: shaDow),
  ),

);
</code>```

this is Provider of theme
my_prov.dart

```<code>import 'package:flutter/foundation.dart';
import 'package:shared_preferences/shared_preferences.dart';

class MyProv extends ChangeNotifier {
  final String mytheme = "mytheme";
  SharedPreferences _prefs;

  bool _isDark;

  bool get isDark => _isDark;

  MyProv() {
    _isDark = false;
    _loadFromPrefs();
  }

  toggleTheme() {
    _isDark = !_isDark;
    _saveToPrefs();
    notifyListeners();
  }

  _initPrefs() async {
    if (_prefs == null) {
      return _prefs = await SharedPreferences.getInstance();
    }
  }

  _loadFromPrefs() async {
    await _initPrefs();
    _isDark = _prefs.getBool(mytheme) ?? false;
    notifyListeners();
  }

  _saveToPrefs() async {
    await _initPrefs();
    _prefs.setBool(mytheme, _isDark);
  }
}
</code>```

main.dart
we return as Multiprovider

```<code>import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'home.dart';
import 'package:my_app_name/my_prov.dart';
import 'package:my_app_name/mytheme.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatefulWidget {
  const MyApp({Key key}) : super(key: key);

  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  @override
  Widget build(BuildContext context) {
    return MultiProvider(
        providers: [
          ChangeNotifierProvider<MyProv>(create: (_) => MyProv()),
        ],
        child: Consumer<MyProv>(
          builder: (context, MyProv notifier, child) {
            return MaterialApp(
              debugShowCheckedModeBanner: false,
              theme: notifier.isGel ? dark : light,
              home: const Home(),
            );
          },
        ));
  }
}
</code>```

home.dart

```<code>import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:my_app_name/my_prov.dart';
import 'package:my_app_name/mytheme.dart';

class Home extends StatefulWidget {
  const Home({Key key}) : super(key: key);

  @override
  _HomeState createState() => _HomeState();
}

class _HomeState extends State<Home> {
  @override
  Widget build(BuildContext context) {
    // all colors will follow my_theme.dart theme colors.
    // but if you want to make a different color, simply add a boolean isDark in front of it, then fill it with the color you want
    return Consumer<MyProv>(
      builder: (context, notifier, child) => Scaffold(
        drawer: const Drawer(),
        appBar: AppBar(
          backgroundColor: Theme.of(context).focusColor, //
          title: Text('My App'),
          actions: [
            IconButton(
              onPressed: () {
                notifier.toggleTheme();
              },
              icon: notifier.isDark ? Icon(Icons.brightness_3) : Icon(Icons.light_mode),
            ),
          ],
        ),
        body: Column(
          children: [
            Container(
              height: 200,
              width: double.infinity,
              color: notifier.isDark ? Color(0xFF085C75) : Color(0xFF427508),
            ),
          ],
        ),
      ),
    );
  }
}
</code>```

I hope this solution can solve your problem

Body:
to do so, you have to implement a MultiProvider for changing themes, a sharedpreferences plugin for saving and restoring booleans. and to change a certain color you use a boolean. Example :

mytheme.dart

const MaterialColor myColor = MaterialColor(0xFF134E57, <int, Color>{
  50: Color(0xFFE6ECED),
  100: Color(0xFFBFD0D3),
  200: Color(0xFF95B1B5),
  300: Color(0xFF6B9297),
  400: Color(0xFF4B7A81),
  500: Color(0xFF2B636B), //warna tombol add
  600: Color(0xFF265B63),
  700: Color(0xFF205158),
  800: Color(0xFF1A474E),
  900: Color(0xFF10353C),
});

ThemeData light = ThemeData(
  fontFamily: 'NunitoRE',
  brightness: Brightness.light,
  primarySwatch: myColor,
  textTheme: const TextTheme(bodyText2: TextStyle(color: Color(0xff010101))),
  appBarTheme: const AppBarTheme(
    iconTheme: IconThemeData(color: Color(0xfffafafa)),
    backgroundColor: Color(0xFF134E57),
    titleSpacing: 0,
    elevation: 0,
    centerTitle: false,
    titleTextStyle: TextStyle(color: Color(0xfffafafa), fontSize: 18, fontFamily: "NunitoBL", shadows: shaDow),
  ),
);

ThemeData dark = ThemeData(
  fontFamily: 'NunitoRE',
  brightness: Brightness.dark,
  hintColor: const Color(0xb3ffffff),
  focusColor: const Color(0xb3ffffff),
  textTheme: const TextTheme(bodyText2: TextStyle(color: Color(0xfffafafa))),
  appBarTheme: const AppBarTheme(
    elevation: 0,
    iconTheme: IconThemeData(color: Color(0xfffafafa)),
    backgroundColor: Color(0xFF222222),
    titleSpacing: 0,
    centerTitle: false,
    titleTextStyle: TextStyle(color: Color(0xfffafafa), fontSize: 18, fontFamily: "NunitoBL", shadows: shaDow),
  ),

);

this is Provider of theme
my_prov.dart

import 'package:flutter/foundation.dart';
import 'package:shared_preferences/shared_preferences.dart';

class MyProv extends ChangeNotifier {
  final String mytheme = "mytheme";
  SharedPreferences _prefs;

  bool _isDark;

  bool get isDark => _isDark;

  MyProv() {
    _isDark = false;
    _loadFromPrefs();
  }

  toggleTheme() {
    _isDark = !_isDark;
    _saveToPrefs();
    notifyListeners();
  }

  _initPrefs() async {
    if (_prefs == null) {
      return _prefs = await SharedPreferences.getInstance();
    }
  }

  _loadFromPrefs() async {
    await _initPrefs();
    _isDark = _prefs.getBool(mytheme) ?? false;
    notifyListeners();
  }

  _saveToPrefs() async {
    await _initPrefs();
    _prefs.setBool(mytheme, _isDark);
  }
}

main.dart
we return as Multiprovider

import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'home.dart';
import 'package:my_app_name/my_prov.dart';
import 'package:my_app_name/mytheme.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatefulWidget {
  const MyApp({Key key}) : super(key: key);

  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  @override
  Widget build(BuildContext context) {
    return MultiProvider(
        providers: [
          ChangeNotifierProvider<MyProv>(create: (_) => MyProv()),
        ],
        child: Consumer<MyProv>(
          builder: (context, MyProv notifier, child) {
            return MaterialApp(
              debugShowCheckedModeBanner: false,
              theme: notifier.isGel ? dark : light,
              home: const Home(),
            );
          },
        ));
  }
}

home.dart

import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:my_app_name/my_prov.dart';
import 'package:my_app_name/mytheme.dart';

class Home extends StatefulWidget {
  const Home({Key key}) : super(key: key);

  @override
  _HomeState createState() => _HomeState();
}

class _HomeState extends State<Home> {
  @override
  Widget build(BuildContext context) {
    // all colors will follow my_theme.dart theme colors.
    // but if you want to make a different color, simply add a boolean isDark in front of it, then fill it with the color you want
    return Consumer<MyProv>(
      builder: (context, notifier, child) => Scaffold(
        drawer: const Drawer(),
        appBar: AppBar(
          backgroundColor: Theme.of(context).focusColor, //
          title: Text('My App'),
          actions: [
            IconButton(
              onPressed: () {
                notifier.toggleTheme();
              },
              icon: notifier.isDark ? Icon(Icons.brightness_3) : Icon(Icons.light_mode),
            ),
          ],
        ),
        body: Column(
          children: [
            Container(
              height: 200,
              width: double.infinity,
              color: notifier.isDark ? Color(0xFF085C75) : Color(0xFF427508),
            ),
          ],
        ),
      ),
    );
  }
}

I hope this solution can solve your problem