问:
Same data split into training, dev and test set
I am struggling to have the same split of data on every iteration in the following function ?

```<code>def data(filename):

    X_train = data('train-images.gz')
    Y_train = data('train-labels.gz')
    X_test = data('t10k-images.gz')
    Y_test = data('t10k-labels.gz')

    X_train, X_devel = X_train[:, :-devel_size], X_train[:, -devel_size:]
    Y_train, Y_devel = Y_train[:-devel_size], Y_train[-devel_size:]

    return X_train, Y_train, X_devel, Y_devel, X_test, Y_test
</code>```

How can I have the same split of data to training & validation for the above function when I call it?

The reason is, I want to re-run the function with several optimization techniques and compare the accuracy.

答:
Set the random seeds.</p>

```<code>tf.random.set_seed(1)
np.random.seed(1)
</code>```

Body:
I am struggling to have the same split of data on every iteration in the following function ?

def data(filename):

    X_train = data('train-images.gz')
    Y_train = data('train-labels.gz')
    X_test = data('t10k-images.gz')
    Y_test = data('t10k-labels.gz')

    X_train, X_devel = X_train[:, :-devel_size], X_train[:, -devel_size:]
    Y_train, Y_devel = Y_train[:-devel_size], Y_train[-devel_size:]

    return X_train, Y_train, X_devel, Y_devel, X_test, Y_test

How can I have the same split of data to training & validation for the above function when I call it?

The reason is, I want to re-run the function with several optimization techniques and compare the accuracy.

Body:
Set the random seeds.

tf.random.set_seed(1)
np.random.seed(1)


来源: stackexchange

问:
how to create project id incrementally in sql based on identity column
I have a project table:

```<code>CREATE TABLE DOC.BRAND
(
    ID int PRIMARY KEY IDENTITY (1, 1),
    project_id varchar(150) ,
    project_name varchar(250) ,
)
</code>```

For example, project_id should be PRJ001, PRJ002 based on identity column value as shown here:

```<code>+----+-------------+---------------+
| ID | project_id  | project_name  |
+----+-------------+---------------+
| 1  | PRJ001      | PROJECT1      |
| 2  | PRJ002      | PROJECT2      |
+----+-------------+---------------+
</code>```

How we can achieve that using a stored procedure or is there any table-level setting?

答:
If you are using SQL Server (which seems likely based on the syntax), you can use a computed column:

```<code>CREATE TABLE DOC.BRAND (
    ID int PRIMARY KEY IDENTITY (1, 1),
    project_id as ('PRJ' + format(id, '000')),
    project_name varchar(250)
);
</code>```

Here is a db<>fiddle.

ContentLicense: CC BY-SA 4.0

Body:
I have a project table:

CREATE TABLE DOC.BRAND
(
    ID int PRIMARY KEY IDENTITY (1, 1),
    project_id varchar(150) ,
    project_name varchar(250) ,
)

For example, project_id should be PRJ001, PRJ002 based on identity column value as shown here:

+----+-------------+---------------+
| ID | project_id  | project_name  |
+----+-------------+---------------+
| 1  | PRJ001      | PROJECT1      |
| 2  | PRJ002      | PROJECT2      |
+----+-------------+---------------+

How we can achieve that using a stored procedure or is there any table-level setting?

Body:
If you are using SQL Server (which seems likely based on the syntax), you can use a computed column:

CREATE TABLE DOC.BRAND (
    ID int PRIMARY KEY IDENTITY (1, 1),
    project_id as ('PRJ' + format(id, '000')),
    project_name varchar(250)
);

Here is a db<>fiddle.


问:
Azure File storage content-type is always application/octet-stream
I'm currently having issue with Azure File storage when I build up a URL with a shared access signature (SAS) Token.  The file will download in the browser, but the content-type is always application/octet-stream rather than changing to match the mime type of the file.  If I put the file in Azure BLOB storage and build up a URL with a SAS Token, it sends the correct content-type for my file (image/jpeg).

I've upgraded my storage account from V1 to V2 thinking that was the problem, but it didn't fix it.

Does anyone have a clue what I could try that might get Azure File storage to return the correct content-type using a URL with SAS Token to download the file?

答:
```<code>// here you define your file content type
CloudBlockBlob cloudBlockBlob = container.GetBlockBlobReference(file.FileName);
                cloudBlockBlob.Properties.ContentType = file.ContentType; //content type
</code>```

ContentLicense: CC BY-SA 3.0


问:
Scale Html List based on resolution
I have a
 containing a series of elements, they are formatted with CSS so they form a half donut chart.
I want to make this mobile-friendly so the content scales along with the screen.

I have tried to used media queries to change the width, and height of the elements and also the border-radius size with no success.

    body {
      font: normal 16px/1.5 'Roboto', sans-serif;
      padding: 130px 0 0 0;
      background: #f1f1f1;
    }

    /* RESET STYLES
    –––––––––––––––––––––––––––––––––––––––––––––––––– */

    .chart-skills {
      margin: 0 auto;
      padding: 0;
      list-style-type: none;
    overflow: hidden;
    }

    .chart-skills *,
    .chart-skills::before {
      box-sizing: border-box;
    }

    /* CHART-SKILLS STYLES
    –––––––––––––––––––––––––––––––––––––––––––––––––– */

    .chart-skills {
      position: relative;
      width: 800px;
      height: 400px;
    }

    .chart-skills::before,
    .chart-skills::after {
      position: absolute;
    }

    .chart-skills::before {
      content: '';
      width: inherit;
      height: inherit;
      border: 45px solid rgba(211, 211, 211, .3);
      border-bottom: none;
      border-top-left-radius: 400px;
      border-top-right-radius: 400px;
    }

    .chart-skills::after {
      content: 'Low to High Risk';
      left: 50%;
      bottom: 10px;
      transform: translateX(-50%);
      font-size: 1.1rem;
      font-weight: bold;
      color: #009933;
    }

    .chart-skills li {
      position: absolute;
      top: 100%;
      left: 0;
      width: inherit;
      height: inherit;
      border: 45px solid;
      border-top: none;
      border-bottom-left-radius: 400px;
      border-bottom-right-radius: 400px;
      transform-origin: 50% 0;
    animation-fill-mode: forwards;
    animation-duration: .1s;
    animation-timing-function: linear;
    transform-style: preserve-3d;
    backface-visibility: hidden;
    }

    .chart-skills li:nth-child(1) {
      z-index: 19;
      border-color: #00FF00;
      animation-name: rotate-1;

    }

    .chart-skills li:nth-child(2) {
      z-index: 18;
      border-color: #24FF00;
      animation-name: rotate-2;
      animation-delay: .1s;

    }

    .chart-skills li:nth-child(3) {
      z-index: 17;
      border-color: #47FF00;
      animation-name: rotate-3;
      animation-delay: .2s;
    }

    .chart-skills li:nth-child(4) {
      z-index: 16;
      border-color: #58FF00;
      animation-name: rotate-4;
      animation-delay: .3s;

    }

    .chart-skills li:nth-child(5) {
      z-index: 15;
      border-color: #6AFF00;
      animation-name: rotate-5;
      animation-delay: .4s;
    }

    .chart-skills li:nth-child(6) {
      z-index: 14;
      border-color: #8DFF00;
      animation-name: rotate-6;
      animation-delay: .6s;

    }

    .chart-skills li:nth-child(7) {
      z-index: 13;
      border-color: #B0FF00;
      animation-name: rotate-7;
      animation-delay: .7s;

    }

    .chart-skills li:nth-child(8) {
      z-index: 12;
      border-color: #D4FF00;
      animation-name: rotate-8;
      animation-delay: .8s;

    }

    .chart-skills li:nth-child(9) {
      z-index: 11;
      border-color: #F7FF00;
      animation-name: rotate-9;
      animation-delay: .9s;

    }

    .chart-skills li:nth-child(10) {
      z-index: 10;
      border-color: #FFF600;
      animation-name: rotate-10;
      animation-delay: 1s;

    }

    .chart-skills li:nth-child(11) {
      z-index: 9;
      border-color: #FFE400;
      animation-name: rotate-11;
      animation-delay: 1.1s;

    }

    .chart-skills li:nth-child(12) {
      z-index: 8;
      border-color: #FFD300;
      animation-name: rotate-12;
      animation-delay: 1.2s;

    }

    .chart-skills li:nth-child(13) {
      z-index: 7;
      border-color: #FFAF00;
      animation-name: rotate-13;
      animation-delay: 1.3s;

    }

    .chart-skills li:nth-child(14) {
      z-index: 6;
      border-color: #FF8C00;
      animation-name: rotate-14;
      animation-delay: 1.4s;

    }

    .chart-skills li:nth-child(15) {
      z-index: 5;
      border-color: #FF6900;
      animation-name: rotate-15;
      animation-delay: 1.5s;

    }

    .chart-skills li:nth-child(16) {
      z-index: 4;
      border-color: #FF4600;
      animation-name: rotate-16;
      animation-delay: 1.6s;
    }

    .chart-skills li:nth-child(17) {
      z-index: 3;
      border-color: #FF2300;
      animation-name: rotate-17;
      animation-delay: 1.7s;
    }
    .chart-skills li:nth-child(18) {
      z-index: 2;
      border-color: #FF1100;
      animation-name: rotate-18;
      animation-delay: 1.8s;
    }

    .chart-skills li:nth-child(19) {
      z-index: 1;
      border-color: #FF0000;
      animation-name: rotate-19;
      animation-delay: 1.9s;
    }

    /*----------------------------------------------------------------------------------------------------------------------------------*/
    @keyframes rotate-1{
      100% {
        transform: rotate(9.5deg);
      }
    }

    @keyframes rotate-2{
      0% {
        transform: rotate(9.5deg);
      }
      100% {
        transform: rotate(19deg);
      }
    }

    @keyframes rotate-3{
      0% {
        transform: rotate(19deg);
      }
      100% {
        transform: rotate(28.5deg);
      }
    }

    @keyframes rotate-4{
      0% {
        transform: rotate(28.5deg);
      }
      100% {
        transform: rotate(38deg);
      }
    }
    @keyframes rotate-5{
      0% {
        transform: rotate(38deg);
      }
      100% {
        transform: rotate(47.5deg);
      }
    }

    @keyframes rotate-6{
      0% {
        transform: rotate(47.5deg);
      }
      100% {
        transform: rotate(57deg);
      }
    }

    @keyframes rotate-7{
      0% {
        transform: rotate(57deg);
      }
      100% {
        transform: rotate(66.5deg);
      }
    }

    @keyframes rotate-8{
      0% {
        transform: rotate(66.5deg);
      }
      100% {
        transform: rotate(76deg);
      }
    }

    @keyframes rotate-9{
      0% {
        transform: rotate(76deg);
      }
      100% {
        transform: rotate(85.5deg);
      }
    }

    @keyframes rotate-10{
      0% {
        transform: rotate(85.5deg);
      }
      100% {
        transform: rotate(95deg);
      }
    }

    @keyframes rotate-11{
      0% {
        transform: rotate(95deg);
      }
      100% {
        transform: rotate(104.5deg);
      }
    }

    @keyframes rotate-12{
      0% {
        transform: rotate(104.5deg);
      }
      100% {
        transform: rotate(114deg);
      }
    }

    @keyframes rotate-13{
      0% {
        transform: rotate(114deg);
      }
      100% {
        transform: rotate(123.5deg);
      }
    }

    @keyframes rotate-14{
      0% {
        transform: rotate(123.5deg);
      }
      100% {
        transform: rotate(133deg);
      }
    }

    @keyframes rotate-15{
      0% {
        transform: rotate(133deg);
      }
      100% {
        transform: rotate(142.5deg);
      }
    }

    @keyframes rotate-16{
      0% {
        transform: rotate(142.5deg);
      }
      100% {
        transform: rotate(152deg);
      }
    }

    @keyframes rotate-17{
      0% {
        transform: rotate(152deg);
      }
      100% {
        transform: rotate(161.5deg);
      }
    }

    @keyframes rotate-18{
      0% {
        transform: rotate(161.5deg);
      }
      100% {
        transform: rotate(171deg);
      }
    }

    @keyframes rotate-19{
      0% {
        transform: rotate(171deg);
      }
      100% {
        transform: rotate(180deg);
      }
    }

    .chart-skills span {
      position: absolute;
      font-size: .85rem;
    }

    /*-------------------------------------------------------------------------------------------------------------------*/
    .chart-skills li:nth-child(1) span {
      top: 20px;
      left: 10px;
      transform: rotate(-9.5deg);
    }

    .chart-skills li:nth-child(2) span {
      top: -5px;
      left: 2px;
      transform: rotate(-19deg);
    }

    .chart-skills li:nth-child(3) span {
      top: 10px;
      left: 0px;
      transform: rotate(-28.5deg);
    }

    .chart-skills li:nth-child(4) span {
      top: 60px;
      left: 10px;
      transform: rotate(-38deg);
    }

    .chart-skills li:nth-child(5) span {
      top: 45px;
      left: 0px;
      transform: rotate(-47.5deg);
    }

    .chart-skills li:nth-child(6) span {
      top: 50px;
      left:  0px;
      transform: rotate(-57deg);
    }

    .chart-skills li:nth-child(7) span {
      top: 55px;
      left: -5px;
      transform: rotate(-66.5deg);
    }

    .chart-skills li:nth-child(8) span {
      top: 5px;
      left: -10px;
      transform: rotate(-76deg);
    }

    .chart-skills li:nth-child(9) span {
      top: 105px;
      left: 5px;
      transform: rotate(-85.5deg);
    }

    .chart-skills li:nth-child(10) span {
      top: 15px;
      left: -35px;
      transform: rotate(-95deg);
    }

    .chart-skills li:nth-child(11) span {
      top: -25px;
      left: -25px;
      transform: rotate(-104.5deg);
    }

    .chart-skills li:nth-child(12) span {
      top: -40px;
      left: -10px;
      transform: rotate(-114deg);
    }

    .chart-skills li:nth-child(13) span {
      top: -75px;
      left: 10px;
      transform: rotate(-123.5deg);
    }

    .chart-skills li:nth-child(14) span {
      top: 35px;
      left: -5px;
      transform: rotate(-133deg);
    }
    .chart-skills li:nth-child(15) span {
      top: -25px;
      left: -5px;
      transform: rotate(-142.5deg);
    }

    .chart-skills li:nth-child(16) span {
      top: -15px;
      left: 10px;
      transform: rotate(-152deg);
    }

    .chart-skills li:nth-child(17) span {
      top: -10px;
      left: 10px;
      transform: rotate(-161.5deg);
    }

    .chart-skills li:nth-child(18) span {
      top: 0px;
      left: 10px;
      transform: rotate(-171deg);
    }

    .chart-skills li:nth-child(19) span {
      top: 10px;
      left: 10px;
      transform: rotate(-180deg);
    }
    @keyframes fade-in {
      0%,
      90% {
        opacity: 0;
      }
      100% {
        opacity: 1;
      }```
<pre class="snippet-code-html lang-html prettyprint-override"><code>    <ul class="chart-skills">
      <li><span>US savings bonds</span></li>
      <li><span>Savings accounts, money market accounts and CDs</span></li>
      <li><span>US Treasury bills, notes and bonds</span></li>
      <li><span>Annuities</span></li>
      <li><span>Money market funds</span></li>
      <li><span>Municipal bonds</span></li>
      <li><span>Corporate bonds</span></li>
      <li><span>High-yield</span></li>
      <li><span>REITs and MLPs</span></li>
      <li><span>Rental real estate</span></li>
      <li><span>Preferred stock</span></li>
      <li><span>Index funds</span></li>
      <li><span>Mutual funds</span></li>
      <li><span>Large-cap stocks</span></li>
      <li><span>Mid-cap stocks</span></li>
      <li><span>Small-cap stocks</span></li>
      <li><span>Commodities</span></li>
      <li><span>Options</span></li>
      <li><span>Futures</span></li>
    </ul></code>```

答:
I find the easiest solution in a case like this, is to use a different sizing unit like rem. Rem is a relative unit based on the root font size instead of the parent size like em. So whatever is defined as the Body font size will impact all rem sizes.

What's cool is that, you can also use rem based sizes for width, height, padding, box-shadow, border and so on. This means when you change the base size EVERYTHING using rem units will resize.

A typical setup looks like this:

This is important to get an easily understood base size

```<code>body {
  font-size: 62.5%;
  /* uses browser base size (16px) to make 1rem = 10px for easy math! */
}
</code>```

Then in your other CSS change everything you want to scale to be rem based. (I'm simplifying quite a bit here)

```<code>.chart-skills {

      width: 80rem;
      height: 40rem;
    }
.chart-skills::before {
      border: 4.5rem solid rgba(211, 211, 211, .3);
      border-top-left-radius: 40rem;
      border-top-right-radius: 40rem;
    }

.chart-skills::after {
      bottom: 1rem;
    }

    .chart-skills li {
      border-bottom-left-radius: 40rem;
      border-bottom-right-radius: 40rem;
      /* I might make the border radius 50% instead if that's easier */
    }
</code>```

Then in the media query simply change the body{ font-size: xx%} to something that scales correctly.

Title: Scale Html List based on resolution

Body:
I have a
 containing a series of elements, they are formatted with CSS so they form a half donut chart.
I want to make this mobile-friendly so the content scales along with the screen.

I have tried to used media queries to change the width, and height of the elements and also the border-radius size with no success.

    body {
      font: normal 16px/1.5 'Roboto', sans-serif;
      padding: 130px 0 0 0;
      background: #f1f1f1;
    }

    /* RESET STYLES
    –––––––––––––––––––––––––––––––––––––––––––––––––– */

    .chart-skills {
      margin: 0 auto;
      padding: 0;
      list-style-type: none;
    overflow: hidden;
    }

    .chart-skills *,
    .chart-skills::before {
      box-sizing: border-box;
    }

    /* CHART-SKILLS STYLES
    –––––––––––––––––––––––––––––––––––––––––––––––––– */

    .chart-skills {
      position: relative;
      width: 800px;
      height: 400px;
    }

    .chart-skills::before,
    .chart-skills::after {
      position: absolute;
    }

    .chart-skills::before {
      content: '';
      width: inherit;
      height: inherit;
      border: 45px solid rgba(211, 211, 211, .3);
      border-bottom: none;
      border-top-left-radius: 400px;
      border-top-right-radius: 400px;
    }

    .chart-skills::after {
      content: 'Low to High Risk';
      left: 50%;
      bottom: 10px;
      transform: translateX(-50%);
      font-size: 1.1rem;
      font-weight: bold;
      color: #009933;
    }

    .chart-skills li {
      position: absolute;
      top: 100%;
      left: 0;
      width: inherit;
      height: inherit;
      border: 45px solid;
      border-top: none;
      border-bottom-left-radius: 400px;
      border-bottom-right-radius: 400px;
      transform-origin: 50% 0;
    animation-fill-mode: forwards;
    animation-duration: .1s;
    animation-timing-function: linear;
    transform-style: preserve-3d;
    backface-visibility: hidden;
    }

    .chart-skills li:nth-child(1) {
      z-index: 19;
      border-color: #00FF00;
      animation-name: rotate-1;

    }

    .chart-skills li:nth-child(2) {
      z-index: 18;
      border-color: #24FF00;
      animation-name: rotate-2;
      animation-delay: .1s;

    }

    .chart-skills li:nth-child(3) {
      z-index: 17;
      border-color: #47FF00;
      animation-name: rotate-3;
      animation-delay: .2s;
    }

    .chart-skills li:nth-child(4) {
      z-index: 16;
      border-color: #58FF00;
      animation-name: rotate-4;
      animation-delay: .3s;

    }

    .chart-skills li:nth-child(5) {
      z-index: 15;
      border-color: #6AFF00;
      animation-name: rotate-5;
      animation-delay: .4s;
    }

    .chart-skills li:nth-child(6) {
      z-index: 14;
      border-color: #8DFF00;
      animation-name: rotate-6;
      animation-delay: .6s;

    }

    .chart-skills li:nth-child(7) {
      z-index: 13;
      border-color: #B0FF00;
      animation-name: rotate-7;
      animation-delay: .7s;

    }

    .chart-skills li:nth-child(8) {
      z-index: 12;
      border-color: #D4FF00;
      animation-name: rotate-8;
      animation-delay: .8s;

    }

    .chart-skills li:nth-child(9) {
      z-index: 11;
      border-color: #F7FF00;
      animation-name: rotate-9;
      animation-delay: .9s;

    }

    .chart-skills li:nth-child(10) {
      z-index: 10;
      border-color: #FFF600;
      animation-name: rotate-10;
      animation-delay: 1s;

    }

    .chart-skills li:nth-child(11) {
      z-index: 9;
      border-color: #FFE400;
      animation-name: rotate-11;
      animation-delay: 1.1s;

    }

    .chart-skills li:nth-child(12) {
      z-index: 8;
      border-color: #FFD300;
      animation-name: rotate-12;
      animation-delay: 1.2s;

    }

    .chart-skills li:nth-child(13) {
      z-index: 7;
      border-color: #FFAF00;
      animation-name: rotate-13;
      animation-delay: 1.3s;

    }

    .chart-skills li:nth-child(14) {
      z-index: 6;
      border-color: #FF8C00;
      animation-name: rotate-14;
      animation-delay: 1.4s;

    }

    .chart-skills li:nth-child(15) {
      z-index: 5;
      border-color: #FF6900;
      animation-name: rotate-15;
      animation-delay: 1.5s;

    }

    .chart-skills li:nth-child(16) {
      z-index: 4;
      border-color: #FF4600;
      animation-name: rotate-16;
      animation-delay: 1.6s;
    }

    .chart-skills li:nth-child(17) {
      z-index: 3;
      border-color: #FF2300;
      animation-name: rotate-17;
      animation-delay: 1.7s;
    }
    .chart-skills li:nth-child(18) {
      z-index: 2;
      border-color: #FF1100;
      animation-name: rotate-18;
      animation-delay: 1.8s;
    }

    .chart-skills li:nth-child(19) {
      z-index: 1;
      border-color: #FF0000;
      animation-name: rotate-19;
      animation-delay: 1.9s;
    }

    /*----------------------------------------------------------------------------------------------------------------------------------*/
    @keyframes rotate-1{
      100% {
        transform: rotate(9.5deg);
      }
    }

    @keyframes rotate-2{
      0% {
        transform: rotate(9.5deg);
      }
      100% {
        transform: rotate(19deg);
      }
    }

    @keyframes rotate-3{
      0% {
        transform: rotate(19deg);
      }
      100% {
        transform: rotate(28.5deg);
      }
    }

    @keyframes rotate-4{
      0% {
        transform: rotate(28.5deg);
      }
      100% {
        transform: rotate(38deg);
      }
    }
    @keyframes rotate-5{
      0% {
        transform: rotate(38deg);
      }
      100% {
        transform: rotate(47.5deg);
      }
    }

    @keyframes rotate-6{
      0% {
        transform: rotate(47.5deg);
      }
      100% {
        transform: rotate(57deg);
      }
    }

    @keyframes rotate-7{
      0% {
        transform: rotate(57deg);
      }
      100% {
        transform: rotate(66.5deg);
      }
    }

    @keyframes rotate-8{
      0% {
        transform: rotate(66.5deg);
      }
      100% {
        transform: rotate(76deg);
      }
    }

    @keyframes rotate-9{
      0% {
        transform: rotate(76deg);
      }
      100% {
        transform: rotate(85.5deg);
      }
    }

    @keyframes rotate-10{
      0% {
        transform: rotate(85.5deg);
      }
      100% {
        transform: rotate(95deg);
      }
    }

    @keyframes rotate-11{
      0% {
        transform: rotate(95deg);
      }
      100% {
        transform: rotate(104.5deg);
      }
    }

    @keyframes rotate-12{
      0% {
        transform: rotate(104.5deg);
      }
      100% {
        transform: rotate(114deg);
      }
    }

    @keyframes rotate-13{
      0% {
        transform: rotate(114deg);
      }
      100% {
        transform: rotate(123.5deg);
      }
    }

    @keyframes rotate-14{
      0% {
        transform: rotate(123.5deg);
      }
      100% {
        transform: rotate(133deg);
      }
    }

    @keyframes rotate-15{
      0% {
        transform: rotate(133deg);
      }
      100% {
        transform: rotate(142.5deg);
      }
    }

    @keyframes rotate-16{
      0% {
        transform: rotate(142.5deg);
      }
      100% {
        transform: rotate(152deg);
      }
    }

    @keyframes rotate-17{
      0% {
        transform: rotate(152deg);
      }
      100% {
        transform: rotate(161.5deg);
      }
    }

    @keyframes rotate-18{
      0% {
        transform: rotate(161.5deg);
      }
      100% {
        transform: rotate(171deg);
      }
    }

    @keyframes rotate-19{
      0% {
        transform: rotate(171deg);
      }
      100% {
        transform: rotate(180deg);
      }
    }

    .chart-skills span {
      position: absolute;
      font-size: .85rem;
    }

    /*-------------------------------------------------------------------------------------------------------------------*/
    .chart-skills li:nth-child(1) span {
      top: 20px;
      left: 10px;
      transform: rotate(-9.5deg);
    }

    .chart-skills li:nth-child(2) span {
      top: -5px;
      left: 2px;
      transform: rotate(-19deg);
    }

    .chart-skills li:nth-child(3) span {
      top: 10px;
      left: 0px;
      transform: rotate(-28.5deg);
    }

    .chart-skills li:nth-child(4) span {
      top: 60px;
      left: 10px;
      transform: rotate(-38deg);
    }

    .chart-skills li:nth-child(5) span {
      top: 45px;
      left: 0px;
      transform: rotate(-47.5deg);
    }

    .chart-skills li:nth-child(6) span {
      top: 50px;
      left:  0px;
      transform: rotate(-57deg);
    }

    .chart-skills li:nth-child(7) span {
      top: 55px;
      left: -5px;
      transform: rotate(-66.5deg);
    }

    .chart-skills li:nth-child(8) span {
      top: 5px;
      left: -10px;
      transform: rotate(-76deg);
    }

    .chart-skills li:nth-child(9) span {
      top: 105px;
      left: 5px;
      transform: rotate(-85.5deg);
    }

    .chart-skills li:nth-child(10) span {
      top: 15px;
      left: -35px;
      transform: rotate(-95deg);
    }

    .chart-skills li:nth-child(11) span {
      top: -25px;
      left: -25px;
      transform: rotate(-104.5deg);
    }

    .chart-skills li:nth-child(12) span {
      top: -40px;
      left: -10px;
      transform: rotate(-114deg);
    }

    .chart-skills li:nth-child(13) span {
      top: -75px;
      left: 10px;
      transform: rotate(-123.5deg);
    }

    .chart-skills li:nth-child(14) span {
      top: 35px;
      left: -5px;
      transform: rotate(-133deg);
    }
    .chart-skills li:nth-child(15) span {
      top: -25px;
      left: -5px;
      transform: rotate(-142.5deg);
    }

    .chart-skills li:nth-child(16) span {
      top: -15px;
      left: 10px;
      transform: rotate(-152deg);
    }

    .chart-skills li:nth-child(17) span {
      top: -10px;
      left: 10px;
      transform: rotate(-161.5deg);
    }

    .chart-skills li:nth-child(18) span {
      top: 0px;
      left: 10px;
      transform: rotate(-171deg);
    }

    .chart-skills li:nth-child(19) span {
      top: 10px;
      left: 10px;
      transform: rotate(-180deg);
    }
    @keyframes fade-in {
      0%,
      90% {
        opacity: 0;
      }
      100% {
        opacity: 1;
      }

US savings bonds

Savings accounts, money market accounts and CDs

US Treasury bills, notes and bonds

Annuities

Money market funds

Municipal bonds

Corporate bonds

High-yield

REITs and MLPs

Rental real estate

Preferred stock

Index funds

Mutual funds

Large-cap stocks

Mid-cap stocks

Small-cap stocks

Commodities

Options

Futures

Body:
I find the easiest solution in a case like this, is to use a different sizing unit like rem. Rem is a relative unit based on the root font size instead of the parent size like em. So whatever is defined as the Body font size will impact all rem sizes.

What's cool is that, you can also use rem based sizes for width, height, padding, box-shadow, border and so on. This means when you change the base size EVERYTHING using rem units will resize.

A typical setup looks like this:

This is important to get an easily understood base size

body {
  font-size: 62.5%;
  /* uses browser base size (16px) to make 1rem = 10px for easy math! */
}

Then in your other CSS change everything you want to scale to be rem based. (I'm simplifying quite a bit here)

.chart-skills {

      width: 80rem;
      height: 40rem;
    }
.chart-skills::before {
      border: 4.5rem solid rgba(211, 211, 211, .3);
      border-top-left-radius: 40rem;
      border-top-right-radius: 40rem;
    }

.chart-skills::after {
      bottom: 1rem;
    }

    .chart-skills li {
      border-bottom-left-radius: 40rem;
      border-bottom-right-radius: 40rem;
      /* I might make the border radius 50% instead if that's easier */
    }

Then in the media query simply change the body{ font-size: xx%} to something that scales correctly.


问:
I am using Azure Devops to build and push my Docker image. How can I pass arguments while doing buildAndPush using Docker task?
I have created a pipeline to build a Docker image and push it to my container registry. I am using Docker task for doing this (buildAndPush command). Here is a YAML snippet of the 'Build and Push' step:

```<code>- task: Docker@2
  displayName: Build and Push
  inputs:
    command: buildAndPush
    containerRegistry: dockerRegistryServiceConnection1
    repository: contosoRepository
    tags: latest
    arguments: --label buildtype=nightly
</code>```

The arguments input is ignored by the task. How can I pass arguments to the Docker command?

答:
When using buildAndPush command in Docker task, the arguments are ignored. Since this is a combination of two Docker commands, the arguments input becomes ambiguous.

If you want to add some arguments to your build command, you can split build and push into two separate steps like this:

```<code>- task: Docker@2
  displayName: Build
  inputs:
    command: build
    containerRegistry: dockerRegistryServiceConnection1
    repository: contosoRepository
    tags: latest
    arguments: --label buildtype=nightly

- task: Docker@2
  displayName: Push
  inputs:
    command: push
    containerRegistry: dockerRegistryServiceConnection1
    repository: contosoRepository
    tags: latest
</code>```

Body:
I have created a pipeline to build a Docker image and push it to my container registry. I am using Docker task for doing this (buildAndPush command). Here is a YAML snippet of the 'Build and Push' step:

- task: Docker@2
  displayName: Build and Push
  inputs:
    command: buildAndPush
    containerRegistry: dockerRegistryServiceConnection1
    repository: contosoRepository
    tags: latest
    arguments: --label buildtype=nightly

The arguments input is ignored by the task. How can I pass arguments to the Docker command?

Body:
When using buildAndPush command in Docker task, the arguments are ignored. Since this is a combination of two Docker commands, the arguments input becomes ambiguous.

If you want to add some arguments to your build command, you can split build and push into two separate steps like this:

- task: Docker@2
  displayName: Build
  inputs:
    command: build
    containerRegistry: dockerRegistryServiceConnection1
    repository: contosoRepository
    tags: latest
    arguments: --label buildtype=nightly

- task: Docker@2
  displayName: Push
  inputs:
    command: push
    containerRegistry: dockerRegistryServiceConnection1
    repository: contosoRepository
    tags: latest


问:
How to inject NestJS config into TypeORM entity?
Let's have simplified TypeORM entity User:

```<code>@Entity()
export class User extends BaseDatabaseEntity {
  @Column({
    length: 255,
  })
  public firstName!: string;

  @Column({ length: 60 })
  @Exclude()
  public password: string;

  @BeforeUpdate()
  @BeforeInsert()
  private hashPassword(): void {
    const tmpPassword = hashSync(
      this.password + 'config.auth.password.secret',
      genSaltSync(),
    );
    this.password = tmpPassword;
  }
}

}
</code>```

I need to replace config.auth.password.secret with NestJS's config (namespace from ConfigService):

```<code>export default registerAs('app', () => {
   return {
    password: {
      secret: process.env.AUTH_PASSWORD_SECRET,
    }
  };
});
</code>```

, but entities are not part of NestJS structure so I cannot just inject it as usual.

How to achieve NestJS configs in TypeORM entities?

答: Entities are not a part of the injectable providers in NestJS so inherently this isn't possible. You can make it a part of your service code, however, and do the password hashing there before insert/update.</p>

Body:
Let's have simplified TypeORM entity User:

@Entity()
export class User extends BaseDatabaseEntity {
  @Column({
    length: 255,
  })
  public firstName!: string;

  @Column({ length: 60 })
  @Exclude()
  public password: string;

  @BeforeUpdate()
  @BeforeInsert()
  private hashPassword(): void {
    const tmpPassword = hashSync(
      this.password + 'config.auth.password.secret',
      genSaltSync(),
    );
    this.password = tmpPassword;
  }
}

}

I need to replace config.auth.password.secret with NestJS's config (namespace from ConfigService):

export default registerAs('app', () => {
   return {
    password: {
      secret: process.env.AUTH_PASSWORD_SECRET,
    }
  };
});

, but entities are not part of NestJS structure so I cannot just inject it as usual.

How to achieve NestJS configs in TypeORM entities?


问:
What effect does optimsing for cluster size have in appfabric
We have an appfabric cache where "small 1-5" is selected as the cluster size.

We are now adding extra machines, which will bring the number of machines over 5.

Should we recreate the cluster to select the correct size? Or does it not make that much of a difference?

答:
There's some detail here on what effect setting the cluster size has internally to AppFabric. I think the effect of this in practice will be that as your cluster grows in size, accessing cached data may become less efficient/performant.

I've not looked into this too closely - the clusters I've used for playing around with and getting a feel for AppFabric have only ever had a couple of servers in them - so I can't say how much of an effect this might have on your code. You'd have to try it and see what the impact is like (and then come back here and tell us so we preserve the knowledge!). If the impact is small, then you may be able to live with it, if not then you'll need to look at recreating the cluster.


问:
I need to create a .Net Web API project that my .Net Core project can connect to, but I'm on a Mac
I have a Angular/.NetCoreWebApi app running in Visual Studio Code on my Mac and I need to run some older WCF/SOAP calls. I can't do this with .Net Core (doesn't support WCP/Soap protocols) so I was told the best solution is to create a .Net Web API project and have my .Net Core project call it to make the web service calls.

I'm on a Mac! So is this even possible knowing that .Net doesn't run on a Mac??
If I can create a project to make these calls on my Mac, which project type do I select to create in the terminal/command prompt, when doing a >dotnet new -h?

If what I want isn't possible, is it possible to run the .Net app inside a docker on my Mac?

If these are all a NO I can use my windows machine at work instead, but I'm looking at the types of projects to create on my Win machine on the command prompt and I still don't see a .Net Web Api app. Only .Net Core projects. I have the .Net framework 4.8 packages installed! And I can create the .Net project in Visual Studio, so is this the only way to create it?

答:
.Net Core supports WCF clients, so there shouldn't be any reason for you not to use the ASP.NET Core Web API project type, assuming you mean you need to call a WCF service external to your project as a client, and not to host a WCF service.

This user showed that it was possible by manually adding and invoking the svcutil tool.


问:
grid-template-columns in Chrome 80 inconsistently computed
I have a page with four forms. Each form's layout is defined using the following CSS grid configuration, which is shared between all of the forms:

.base-grid-wrapper {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    grid-row-gap: 1em;
    grid-column-gap: 1em;
    width: 75%;
}
```

Since Chrome 80 was released, the styling for the first of these forms has been (sort of) broken. The computed values for grid-template-columns is non-uniform, but only for the first of the four forms. For the following three forms--which use the same base grid definition--the grid's columns are uniformly sized, which is what I expect when using repeat(12, 1fr) as I have. Before Chrome 80, this was not the case: all of the form's grids had uniformly-sized columns.

In other browsers (Safari and Firefox), the columns render as expected. Is there something that changed in Chrome 80 that would have caused this? Searching through the Chrome changelog, I can't seem to find anything relevant.

I've tried to see if there are any wider-scoped CSS rules that might be causing this, but I can't find anything. I admit I'm not the most advanced CSS user, so I definitely could have configured the grid incorrectly, or something, but look at the Stackblitz linked below to see if this is the case.

I saw a couple of other similar Stackoverflow questions, but none of them seem to quite fit the problem I'm seeing:

CSS grid behaviour different in Chrome and Firefox

--> perhaps most similar to my problem, but doesn't have any relevant solutions, but it does have confirmation of the problem

Has anybody faced issue working with Chrome 80 and CSS Grid

--> similar to my problem, but it doesn't have a good working example of the problem, and thus it doesn't have any useful responses

Why does Chrome 80 cause this grid-template-rows: auto problem

--> very different configuration than in my case, so not super relevant to what I'm seeing

For what it's worth, this is an Angular 8 application using Angular Material, but I'm pretty certain that that's not the source of this problem, especially considering it works as intended in other browsers.

Here's a Stackblitz that replicates the problem (be sure to open in Chrome 80+): editable & (inspectable) hosted app.

Here are some screenshots, as well:

First form

Chrome Devtools - grid outline

Firefox Devtools - grid outline

Chrome Devtools - non-uniformly-computed grid column widths

Later form, using the same base grid definition

Chrome Devtools - grid outline

Chrome Devtools - uniformly-computed grid column widths

答:
I had the same problem this morning. I had the bug reported on one of the pages I am responsible for, for the latest chrome version at that time.
I made sure I had the latest chrome installed and went to check the issues this morning and 1fr was really not being respected. Maybe 15 minutes ago I went on ahead to report the chrome bug and there it was new update pending, so I've updated the chrome again, second time today, and problem was fixed.

I did some digging and I am pretty sure they did change how css grid is handled, more specifically:

[css-grid] Accommodate spanning items crossing flexible tracks

But since it caused breakage across the web they reverted the change.
I think it's referenced here https://chromium.googlesource.com/chromium/src/+/b1738fb61215bb8610e08f65de4d01681e250f7f.

Edit: There is also this answer that goes into more details for others having this issue
https://stackoverflow.com/a/60284361/12285468

Body:
I have a page with four forms. Each form's layout is defined using the following CSS grid configuration, which is shared between all of the forms:

.base-grid-wrapper {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    grid-row-gap: 1em;
    grid-column-gap: 1em;
    width: 75%;
}

Since Chrome 80 was released, the styling for the first of these forms has been (sort of) broken. The computed values for grid-template-columns is non-uniform, but only for the first of the four forms. For the following three forms--which use the same base grid definition--the grid's columns are uniformly sized, which is what I expect when using repeat(12, 1fr) as I have. Before Chrome 80, this was not the case: all of the form's grids had uniformly-sized columns.

In other browsers (Safari and Firefox), the columns render as expected. Is there something that changed in Chrome 80 that would have caused this? Searching through the Chrome changelog, I can't seem to find anything relevant.

I've tried to see if there are any wider-scoped CSS rules that might be causing this, but I can't find anything. I admit I'm not the most advanced CSS user, so I definitely could have configured the grid incorrectly, or something, but look at the Stackblitz linked below to see if this is the case.

I saw a couple of other similar Stackoverflow questions, but none of them seem to quite fit the problem I'm seeing:

CSS grid behaviour different in Chrome and Firefox

--> perhaps most similar to my problem, but doesn't have any relevant solutions, but it does have confirmation of the problem

Has anybody faced issue working with Chrome 80 and CSS Grid

--> similar to my problem, but it doesn't have a good working example of the problem, and thus it doesn't have any useful responses

Why does Chrome 80 cause this grid-template-rows: auto problem

--> very different configuration than in my case, so not super relevant to what I'm seeing

For what it's worth, this is an Angular 8 application using Angular Material, but I'm pretty certain that that's not the source of this problem, especially considering it works as intended in other browsers.

Here's a Stackblitz that replicates the problem (be sure to open in Chrome 80+): editable & (inspectable) hosted app.

Here are some screenshots, as well:

First form

Chrome Devtools - grid outline

Firefox Devtools - grid outline

Chrome Devtools - non-uniformly-computed grid column widths

Later form, using the same base grid definition

Chrome Devtools - grid outline

Chrome Devtools - uniformly-computed grid column widths


问:
How to run Edge (Chromium) in Selenium with Python?
Microsoft recently released a blog where they talk about the new Edge browser coming out and how to test it with Selenium: https://blogs.windows.com/msedgedev/2019/11/04/edge-chromium-release-candidate-get-ready/
However the example is using C#, which uses different libraries than Python. I'm simply trying to get Selenium to open a webpage. Edge Beta version I have is 79.0.309.54

Here's what I've tried:

```<code>browser_options = Options()
browser_options.binary_location = '{PATH_TO_MISCROSOFT_EDGE_BETA_BINARY}'

driver = Chrome(executible_path='{PATH_TO_EDGE_DRIVER}', options=browser_options)
driver.get('https://blogs.windows.com')
</code>```

But that results in:

```<code>session not created: from tab crashed (Session info:Microsoft Edge=79.0.309.54)
</code>```

I've also tried:

```<code>driver = Edge(executible_path='{PATH_TO_EDGE_DRIVER}')
driver.get('https://blogs.windows.com')
</code>```

But that results in:

```<code>session not created: No matching capabilities found
</code>```

答:
My "Edge Chromimum" is the "beta 80.0.361.53"; I downloaded the related WebDriver from Microsoft at https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/
which I stored in a folder that I added permanently to PATH (and by the way, I also downloaded the Internet Explorer WebDriver from https://selenium.dev/downloads/ to run parallel IE / Edge tests).

I use the Python binding which is he latest stable version at time of writing "3.141.0".

The Edge binary (msedge.exe) was installed in non-Administrator mode (this was possible but not anymore with final version) and is located in "C:\Users\\AppData\Local\Microsoft\Edge Beta\Application" and as this location is not on the PATH, I created a small .cmd wrapper to launch my Python test code (I did not want to add this extra folder on the PATH permanently) adding temporarily this folder to PATH.

The very first example proposed by selenium requires one small modification as illustrated below:

```<code>from selenium import webdriver
# Using Internet Explorer
# browser = webdriver.Ie()
# Using Edge Chromium
# needs "msedgedriver.exe" otherwize expects "MicrosoftWebDriver.exe"
browser = webdriver.Edge("msedgedriver.exe")
browser.get('http://seleniumhq.org/')
</code>```

It then works very well for me, for both IE and Edge Chromium - snapshot below from Edge Chromium:

Body:
Microsoft recently released a blog where they talk about the new Edge browser coming out and how to test it with Selenium: https://blogs.windows.com/msedgedev/2019/11/04/edge-chromium-release-candidate-get-ready/
However the example is using C#, which uses different libraries than Python. I'm simply trying to get Selenium to open a webpage. Edge Beta version I have is 79.0.309.54

Here's what I've tried:

browser_options = Options()
browser_options.binary_location = '{PATH_TO_MISCROSOFT_EDGE_BETA_BINARY}'

driver = Chrome(executible_path='{PATH_TO_EDGE_DRIVER}', options=browser_options)
driver.get('https://blogs.windows.com')

But that results in:

session not created: from tab crashed (Session info:Microsoft Edge=79.0.309.54)

I've also tried:

driver = Edge(executible_path='{PATH_TO_EDGE_DRIVER}')
driver.get('https://blogs.windows.com')

But that results in:

session not created: No matching capabilities found

Body:
My "Edge Chromimum" is the "beta 80.0.361.53"; I downloaded the related WebDriver from Microsoft at https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/
which I stored in a folder that I added permanently to PATH (and by the way, I also downloaded the Internet Explorer WebDriver from https://selenium.dev/downloads/ to run parallel IE / Edge tests).

I use the Python binding which is he latest stable version at time of writing "3.141.0".

The Edge binary (msedge.exe) was installed in non-Administrator mode (this was possible but not anymore with final version) and is located in "C:\Users\\AppData\Local\Microsoft\Edge Beta\Application" and as this location is not on the PATH, I created a small .cmd wrapper to launch my Python test code (I did not want to add this extra folder on the PATH permanently) adding temporarily this folder to PATH.

The very first example proposed by selenium requires one small modification as illustrated below:

from selenium import webdriver
# Using Internet Explorer
# browser = webdriver.Ie()
# Using Edge Chromium
# needs "msedgedriver.exe" otherwize expects "MicrosoftWebDriver.exe"
browser = webdriver.Edge("msedgedriver.exe")
browser.get('http://seleniumhq.org/')

It then works very well for me, for both IE and Edge Chromium - snapshot below from Edge Chromium:


问:
Google Drive API - We're sorry...... but your computer or network may be sending automated queries
We have a Google Drive Oauth2 App integration. We are using Google Drive API export and get endpoints in order to read data from our customers within their Google Drive Folder.
Our app was published by the Google Oauth Verification Team, but we are unable to read files that are not(csv, xls, xlsx) a Google Docs file.

This is an API request sample:
URL:

```<code>"https://www.googleapis.com/drive/v3/files/1874uz4MTNer4IszgWG_3pH6VEH2AWJPd?alt=media&access_token=ACCESS_TOKEN"
</code>```

Response:

```<code>"<html><head><meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\"/><title>Sorry...</title><style> body { font-family: verdana, arial, sans-serif; background-color: #fff; color: #000; }</style></head><body><div><table><tr><td><b><font face=sans-serif size=10><font color=#4285f4>G</font><font color=#ea4335>o</font><font color=#fbbc05>o</font><font color=#4285f4>g</font><font color=#34a853>l</font><font color=#ea4335>e</font></font></b></td><td style=\"text-align: left; vertical-align: bottom; padding-bottom: 15px; width: 50%\"><div style=\"border-bottom: 1px solid #dfdfdf;\">Sorry...</div></td></tr></table></div><div style=\"margin-left: 4em;\"><h1>We're sorry...</h1><p>... but your computer or network may be sending automated queries. To protect our users, we can't process your request right now.</p></div><div style=\"margin-left: 4em;\">See <a href=\"https://support.google.com/websearch/answer/86640\">Google Help</a> for more information.<br/><br/></div><div style=\"text-align: center; border-top: 1px solid #dfdfdf;\"><a href=\"https://www.google.com\">Google Home</a></div></body></html>"
</code>```

This same kind of request was working fine until Feb 7, 2020.

Using the export endpoint that exports the Google Doc file, works fine.

In the first moment, we found this link describing some changes: https://support.google.com/cloud/answer/9110914
We applied for Oauth Verification, we have passed but we still see the same issue, even if we redo the Oauth2 authentication flow generating new Access/Refresh Token.
We already tried to reach out to Google about this on Both Issue Tracker and Oauth Team but both couldn't help.
We do not have any kind of malware, VPN on the production server, or anything like that we could find in some related questions.

Does anyone have any suggestions on how to solve this problem?

Thank you.

答:
We're having the same problem and after some testing, we've found Google appears to be checking more thoroughly the origin of the tokens.

According to https://developers.google.com/drive/api/v3/about-auth

If the user approves, then Google gives your application a short-lived access token.

Your application requests user data, attaching the access token to the request.

If Google determines that your request and the token are valid, it returns the requested data.

We're using a JS file picker and after receiving the object data, when we attempted to $.get it, the file was downloaded correctly but that same URL anywhere else was returning an error.

UPDATE

We got it working again with https://developers.google.com/drive/api/v3/manage-downloads:

To download a file stored on Google Drive, use the files.get method with the ID of the file to download and the alt=media URL parameter. The alt=media URL parameter tells the server that a download of content is being requested.

Body:
We have a Google Drive Oauth2 App integration. We are using Google Drive API export and get endpoints in order to read data from our customers within their Google Drive Folder.
Our app was published by the Google Oauth Verification Team, but we are unable to read files that are not(csv, xls, xlsx) a Google Docs file.

This is an API request sample:
URL:

"https://www.googleapis.com/drive/v3/files/1874uz4MTNer4IszgWG_3pH6VEH2AWJPd?alt=media&access_token=ACCESS_TOKEN"

Response:

"<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\"/><title>Sorry...</title>

Google
Sorry...

We're sorry...

... but your computer or network may be sending automated queries. To protect our users, we can't process your request right now.

See Google Help for more information.

Google Home
"

This same kind of request was working fine until Feb 7, 2020.

Using the export endpoint that exports the Google Doc file, works fine.

In the first moment, we found this link describing some changes: https://support.google.com/cloud/answer/9110914
We applied for Oauth Verification, we have passed but we still see the same issue, even if we redo the Oauth2 authentication flow generating new Access/Refresh Token.
We already tried to reach out to Google about this on Both Issue Tracker and Oauth Team but both couldn't help.
We do not have any kind of malware, VPN on the production server, or anything like that we could find in some related questions.

Does anyone have any suggestions on how to solve this problem?

Thank you.


问:
What does the term mean --"ForkJoinPool is not a part of the public contract" in java
while going thru this article:
https://4comprehension.com/parallel-collection-processing-1/
I saw the sentence -- ForkJoinPool is not a part of the public contract -- What does this mean exactly.
As per my understanding ForkJoinPool is a public class with public methods in it.so it is a part of the public contract. But the above article says that ForkJoinPool is not a part of the public contract. Please clarify

答: The word "public" which you seem to be focusing on is not really concerned with the public keyword from the Java language. In the context of the post you are referring to it means that Java streams internally depend on ForkJoin pool. However, it is an implementation detail and there is no guarantee that it will continue to be like that. In other words it is not part of the contract made between the language users (genral public like you) and language implementers.


问:
Crash when SVG is used as small Icon for notification
I've set a small icon to my notificaton builder using

```<code>NotificationCompat.Builder builder = new NotificationCompat.Builder(mContext)
.setSmallIcon(R.drawable.location_off_24dp);
</code>```

location_off_24dp is actually a SVG file in my project.

Issue is that I get crash with this code on pre-lollipop devices.

Crash report:

```<code>  android.app.RemoteServiceException: Bad notification posted from package com.com.example.app: Couldn't create icon: StatusBarIcon(pkg=com.example.app.clientuser=0 id=0x7f02010e level=0 visible=true num=0 )
                                                  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1410)
                                                  at android.os.Handler.dispatchMessage(Handler.java:102)
                                                  at android.os.Looper.loop(Looper.java:136)
                                                  at android.app.ActivityThread.main(ActivityThread.java:5426)
                                                  at java.lang.reflect.Method.invokeNative(Native Method)
                                                  at java.lang.reflect.Method.invoke(Method.java:515)
                                                  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1268)
                                                  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1084)
                                                  at dalvik.system.NativeStart.main(Native Method)
</code>```

I know we can use app:srcCompat="@drawable/vector_file" in the layouts. But when we pass the SVG drawable resource ID to PendingIntent, will the system use something of srcCompat kind of version so it could apply to pre-lollipop too or it expects drawable to be a direct image ?

How do I use SVG as small Icon in Notification for pre-lollipop devices?

答:
Put the PNG's in drawable resource to reference them.
SVG crash in kitkat devices.</p>

Body:
I've set a small icon to my notificaton builder using

NotificationCompat.Builder builder = new NotificationCompat.Builder(mContext)
.setSmallIcon(R.drawable.location_off_24dp);

location_off_24dp is actually a SVG file in my project.

Issue is that I get crash with this code on pre-lollipop devices.

Crash report:

  android.app.RemoteServiceException: Bad notification posted from package com.com.example.app: Couldn't create icon: StatusBarIcon(pkg=com.example.app.clientuser=0 id=0x7f02010e level=0 visible=true num=0 )
                                                  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1410)
                                                  at android.os.Handler.dispatchMessage(Handler.java:102)
                                                  at android.os.Looper.loop(Looper.java:136)
                                                  at android.app.ActivityThread.main(ActivityThread.java:5426)
                                                  at java.lang.reflect.Method.invokeNative(Native Method)
                                                  at java.lang.reflect.Method.invoke(Method.java:515)
                                                  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1268)
                                                  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1084)
                                                  at dalvik.system.NativeStart.main(Native Method)

I know we can use app:srcCompat="@drawable/vector_file" in the layouts. But when we pass the SVG drawable resource ID to PendingIntent, will the system use something of srcCompat kind of version so it could apply to pre-lollipop too or it expects drawable to be a direct image ?

How do I use SVG as small Icon in Notification for pre-lollipop devices?


问:
Xcode errors related to IPC
I have the following errors in Xcode console:

[IPC] 0x1047e7a80 - Connection::dispatchIncomingMessages: IPC throttling was triggered (has 689 pending incoming messages, will only process 600 before yielding)
[IPC] 0x1047e7a80 - Connection::dispatchIncomingMessages: first IPC message in queue is WebProcessProxy::TakeAllMessagesForPort

I am using WKWebView in my app, what does it mean?

答:
This has just happened to me and I believe that the javascript in your WKWebView is generating messages too fast for the comms channel between the WKWebView and your Swift/Objective C code to handle.
I did think about trying to slow the message generation rate down, but on investigation all of the messages do get processed eventually and reasonably quickly, just not instantaneously, so in the end I left the error messages alone.</p>

Title: Xcode errors related to IPC


问:
fscanf() in C, format for varying length line
So I have a file which contains data in the form:

```<code>...
5,25,15,16,1,3,Dwyfor_Meirionnydd
5,34,33,26,12,22,Gower
5,7,28,35,4,23,Islwyn
2,20,12,Llanelli
5,4,5,17,7,21,Merthyr_Tydfil_and_Rhymney
5,5,4,35,28,27,Monmouth
4,5,14,19,15,Montgomeryshire
7,0,32,17,5,12,20,33,Neath
2,38,24,Newport_East
...
</code>```

And I need to read each line and put it in the structure such that the first unsigned integer is stored, the next n unsigned integers are stored in an array and then the string at the end is stored. So as an example the second line would be:

```<code>number-of-elements: 5
array: {34,33,26,12,22}
name: "Gower"
</code>```

The number tells us howmany items are in the array. I have a struct for this data. How would I go about creating a format for this?

答:
Usually you'd just use separate calls to fscanf in a loop to read elements:</p>

```<code>struct entry {
    int   data_size;
    int   *data;
    char  *name;
};

while (fscanf(input, "%d", &num) == 1) {
    struct entry *e = malloc(sizeof *e);
    e->data_size = num;
    e->data = malloc(num * sizeof e->data[0]);
    for (int i = 0; i < num; ++i) {
        if (fscanf(input, " ,%d", &e->data[i]) != 1) {
            fprintf(stderr, "Data format error\n");
            exit(1); } }
    if (fscanf(input, " ,%ms", &e->name) != 1) {
        fprintf(stderr, "Data format error\n");
        exit(1); }
    // read a record into 'e' -- store it into a data structure somewhere
}
</code>```

Body:
So I have a file which contains data in the form:

...
5,25,15,16,1,3,Dwyfor_Meirionnydd
5,34,33,26,12,22,Gower
5,7,28,35,4,23,Islwyn
2,20,12,Llanelli
5,4,5,17,7,21,Merthyr_Tydfil_and_Rhymney
5,5,4,35,28,27,Monmouth
4,5,14,19,15,Montgomeryshire
7,0,32,17,5,12,20,33,Neath
2,38,24,Newport_East
...

And I need to read each line and put it in the structure such that the first unsigned integer is stored, the next n unsigned integers are stored in an array and then the string at the end is stored. So as an example the second line would be:

number-of-elements: 5
array: {34,33,26,12,22}
name: "Gower"

The number tells us howmany items are in the array. I have a struct for this data. How would I go about creating a format for this?

Body:
Usually you'd just use separate calls to fscanf in a loop to read elements:

struct entry {
    int   data_size;
    int   *data;
    char  *name;
};

while (fscanf(input, "%d", &num) == 1) {
    struct entry *e = malloc(sizeof *e);
    e->data_size = num;
    e->data = malloc(num * sizeof e->data[0]);
    for (int i = 0; i < num; ++i) {
        if (fscanf(input, " ,%d", &e->data[i]) != 1) {
            fprintf(stderr, "Data format error\n");
            exit(1); } }
    if (fscanf(input, " ,%ms", &e->name) != 1) {
        fprintf(stderr, "Data format error\n");
        exit(1); }
    // read a record into 'e' -- store it into a data structure somewhere
}


问:
display all 4 options each time in the select menu
I'm new to bash. I want to have a select menu in bash. It has four options. Here is the code:

```<code>PS3='Please enter your choice: '
options=("Option 1" "Option 2" "Option 3" "Option 4")
select opt in "${options[@]}"
do
    case $opt in
        "Option 1")
            echo "you chose choice $REPLY which is $opt"
            ;;
        "Option 2")
            echo "you chose choice $REPLY which is $opt"
            ;;
        "Option 3")
            echo "you chose choice $REPLY which is $opt"
            ;;
        "Exit")
            break
            ;;
        *) echo "invalid option $REPLY";;
    esac
done
</code>```

When I execute this code, the first time full menu with 4 options appears, but later times (2nd, 3rd and ... times) only "Please enter your choice:" appears. I want each time all 4 options appear like the first time.

As another problem, I want each time that the program is executed and 4 options are re-appeared, the previous commands and terminal content to be cleared. I did this by putting a "clear" before:

```<code>select opt in "${options[@]}"
</code>```

but this way only the first time the terminal content was cleared.

What can I do to solve these problems?

答:
If the user hits enter without making any selection, the menu will be redisplayed. As far as I know, the only way to programmatically force the menu to be drawn again would be to wrap the select statement in another loop, and re-execute the select statement. You'll use break to exit the select and return to the top of the wrapper loop, and break 2 to exit from both the select and the wrapper.

```<code>PS3='Please enter your choice: '
options=("Option 1" "Option 2" "Option 3" "Option 4")
<b>while :; do</b>
  select opt in "${options[@]}"
  do
    case $opt in
        "Option 1")
            echo "you chose choice $REPLY which is $opt"
            ;;
        "Find Subdomain")
            echo "you chose choice $REPLY which is $opt"
            ;;
        "Option 3")
            echo "you chose choice $REPLY which is $opt"
            ;;
        "Option 4")
            <b>break 2</b>
            ;;
        *) echo "invalid option $REPLY";;
    esac
    <b>break</b>
  done
<b>done</b></code>```

Body:
I'm new to bash. I want to have a select menu in bash. It has four options. Here is the code:

PS3='Please enter your choice: '
options=("Option 1" "Option 2" "Option 3" "Option 4")
select opt in "${options[@]}"
do
    case $opt in
        "Option 1")
            echo "you chose choice $REPLY which is $opt"
            ;;
        "Option 2")
            echo "you chose choice $REPLY which is $opt"
            ;;
        "Option 3")
            echo "you chose choice $REPLY which is $opt"
            ;;
        "Exit")
            break
            ;;
        *) echo "invalid option $REPLY";;
    esac
done

When I execute this code, the first time full menu with 4 options appears, but later times (2nd, 3rd and ... times) only "Please enter your choice:" appears. I want each time all 4 options appear like the first time.

As another problem, I want each time that the program is executed and 4 options are re-appeared, the previous commands and terminal content to be cleared. I did this by putting a "clear" before:

select opt in "${options[@]}"

but this way only the first time the terminal content was cleared.

What can I do to solve these problems?

Body:
If the user hits enter without making any selection, the menu will be redisplayed. As far as I know, the only way to programmatically force the menu to be drawn again would be to wrap the select statement in another loop, and re-execute the select statement. You'll use break to exit the select and return to the top of the wrapper loop, and break 2 to exit from both the select and the wrapper.

PS3='Please enter your choice: '
options=("Option 1" "Option 2" "Option 3" "Option 4")
while :; do
  select opt in "${options[@]}"
  do
    case $opt in
        "Option 1")
            echo "you chose choice $REPLY which is $opt"
            ;;
        "Find Subdomain")
            echo "you chose choice $REPLY which is $opt"
            ;;
        "Option 3")
            echo "you chose choice $REPLY which is $opt"
            ;;
        "Option 4")
            break 2
            ;;
        *) echo "invalid option $REPLY";;
    esac
    break
  done
done


问:
Trouble Including / Using GLM library
I am having trouble properly including / using the glm math library (http://glm.g-truc.net/ ) in my c++ project. Since glm is a "header only" library, I thought I could just include it with this line:

```<code>#include "glm/glm.hpp"
</code>```

At first this seemed to be working, as I could create and use matrices and vectors. However when I tried to use the glm::translate(...) function I got this error:

```<code>error: ‘translate’ is not a member of ‘glm’
</code>```

On the GLM website, they recommend including the library with triangle brackets, like so:

```<code>#include <glm/glm.hpp>
</code>```

...but isn't it correct to think that I can include it the other way, given that it is inside the project directory structure?

I have set up the test below to illustrate the problem I am having. The glm folder is sitting next to the testglm.cpp file.

```<code>#include <iostream>

#include "glm/glm.hpp"

using namespace std;

int main(void) {

    // works:
    glm::mat4 testMatrix1 = glm::mat4(5.0f) * glm::mat4(2.0f);

    cout << testMatrix1[0][0] << endl; // output: 10

    // doesn't work - (error: ‘translate’ is not a member of ‘glm’):
    glm::mat4 testMatrix2 = glm::translate(glm::mat4(1.0f), glm::vec3(1.0f));

}
</code>```

I am building this test with this build command from the terminal, on osx:

```<code>g++ -o bin/glm_test src/testglm.cpp
</code>```

I'm not sure if my problem relates to how I'm including the library, how I'm using it, or how I'm building the project. Google does not give me any hits for that error message, so I wonder if I am doing something fundamentally wrong. Advice would be much appreciated. Thanks.

答:
Write in the terminal: </p>

```<code>sudo apt install libglm-dev
</code>```

<p>This worked for me. </p>

Title: Trouble Including / Using GLM library

Body:
I am having trouble properly including / using the glm math library (http://glm.g-truc.net/ ) in my c++ project. Since glm is a "header only" library, I thought I could just include it with this line:

#include "glm/glm.hpp"

At first this seemed to be working, as I could create and use matrices and vectors. However when I tried to use the glm::translate(...) function I got this error:

error: ‘translate’ is not a member of ‘glm’

On the GLM website, they recommend including the library with triangle brackets, like so:

#include <glm/glm.hpp>

...but isn't it correct to think that I can include it the other way, given that it is inside the project directory structure?

I have set up the test below to illustrate the problem I am having. The glm folder is sitting next to the testglm.cpp file.

#include <iostream>

#include "glm/glm.hpp"

using namespace std;

int main(void) {

    // works:
    glm::mat4 testMatrix1 = glm::mat4(5.0f) * glm::mat4(2.0f);

    cout << testMatrix1[0][0] << endl; // output: 10

    // doesn't work - (error: ‘translate’ is not a member of ‘glm’):
    glm::mat4 testMatrix2 = glm::translate(glm::mat4(1.0f), glm::vec3(1.0f));

}

I am building this test with this build command from the terminal, on osx:

g++ -o bin/glm_test src/testglm.cpp

I'm not sure if my problem relates to how I'm including the library, how I'm using it, or how I'm building the project. Google does not give me any hits for that error message, so I wonder if I am doing something fundamentally wrong. Advice would be much appreciated. Thanks.

Body:
Write in the terminal:

sudo apt install libglm-dev

This worked for me.


问:
Pass through folder with any specific pattern
I have a batch script that would only copy pdf file, based on the user inputted code. As soon as they hit enter it will look for a folder that has same filename with the inputted code.. then if exist it will copy the pdf inside..

Now I'm having a problem because in one sub-folder, it's file name doesn't have standard filename.

Like for ex : sometimes its filename is UV DATA others is UV-DATA , UV

example folder structure storage for the pdf file :

```<code>server
'----22050-022
     '----Folder1
               22050-022-DATA.pdf
</code>```

example folder destination :

```<code>server2
'----Folder
     '----22050-022
          '----UV DATA
               '----DOCUMENTS
</code>```

The UV DATA folder is the only one is changing..
How can I set only only UV and second word is any specific pattern?

Sample XCopy if it is a static code and make default file name is UV DATA:

```<code>set /p code=Input Control Number:

xcopy "%MySetPath%\Folder\%code%\%code%-DATA.pdf" "%MySetDestination%\Folder1\%code%\UV DATA\DOCUMENTS\" /D /E /C /I /Y /H
</code>```

I only tried something like this but doesn't work:

```<code>set /p code=Input Control Number:

xcopy "%MySetPath%\Folder\%code%\%code%-DATA.pdf" "%MySetDestination%\Folder1\%code%\UV*.*\DOCUMENTS\" /D /E /C /I /Y /H
</code>```

答:
```<code>@echo off
setlocal

rem Change current directory to HOMEDRIVE.
cd /d "%HOMEDRIVE%" || (
    >&2 echo Failed to change directory to "%HOMEDRIVE%"
    exit /b 1
)

rem Get the control number i.e. 22050-022.
set /p "code=Input Control Number: " || exit /b 0

rem Set initial source path and destination path here.
@rem Note: destination path without trailing "\UV*\DOCUMENTS".
set "source=%HOMEPATH%\%code%\Folder1\%code%-DATA.pdf"
set "destination=%HOMEPATH%\Folder\%code%"

rem Check initial source path.
if not exist "%source%" (
    >&2 echo Initial source path "%source%" not exist.
    exit /b 1
)

rem Check initial destination path.
if not exist "%destination%" (
    >&2 echo Initial destination path "%destination%" not exist.
    exit /b 1
)

rem Get "%%destination%%\UV*\DOCUMENTS\" path.
(
    set "destination="

    for /d %%A in ("%destination%\UV*") do if not defined destination (
        @rem Force an echo on line break.
        if exist "%%~A\DOCUMENTS\" set "destination=%%~A\DOCUMENTS\"
    )

    if not defined destination (
        >&2 echo Failed to get destination from "%destination%".
        exit /b 1
    )
)

rem Copy file from source to destination if file date is newer.
xcopy /d /y "%source%" "%destination%"
exit /b 0
</code>```

This will try to find the destination path with
UV* in the path as specified in the OP and
comments as to my understanding.

Change directory to %HOMEDRIVE% else a path
starting with %HOMEPATH% can be invalid if
the the current directory is on another drive.
If you use a drive which mirrors the %HOMEPATH%
then you can disable the change of directory to
remain on that drive.

The destination path is resolved to the
DOCUMENTS folder, else the destination
variable will be detected as undefined.

Checks are done to ensure initial source
and destination paths exist.

Since only 1 file is being copied, using
xcopy arguments that apply for 1 file.
Check to see if I am correct.

To understand what the code is doing, set
the line @echo off to @echo on to test.

Body:
I have a batch script that would only copy pdf file, based on the user inputted code. As soon as they hit enter it will look for a folder that has same filename with the inputted code.. then if exist it will copy the pdf inside..

Now I'm having a problem because in one sub-folder, it's file name doesn't have standard filename.

Like for ex : sometimes its filename is UV DATA others is UV-DATA , UV

example folder structure storage for the pdf file :

server
'----22050-022
     '----Folder1
               22050-022-DATA.pdf

example folder destination :

server2
'----Folder
     '----22050-022
          '----UV DATA
               '----DOCUMENTS

The UV DATA folder is the only one is changing..
How can I set only only UV and second word is any specific pattern?

Sample XCopy if it is a static code and make default file name is UV DATA:

set /p code=Input Control Number:

xcopy "%MySetPath%\Folder\%code%\%code%-DATA.pdf" "%MySetDestination%\Folder1\%code%\UV DATA\DOCUMENTS\" /D /E /C /I /Y /H

I only tried something like this but doesn't work:

set /p code=Input Control Number:

xcopy "%MySetPath%\Folder\%code%\%code%-DATA.pdf" "%MySetDestination%\Folder1\%code%\UV*.*\DOCUMENTS\" /D /E /C /I /Y /H

Body:
@echo off
setlocal

rem Change current directory to HOMEDRIVE.
cd /d "%HOMEDRIVE%" || (
    >&2 echo Failed to change directory to "%HOMEDRIVE%"
    exit /b 1
)

rem Get the control number i.e. 22050-022.
set /p "code=Input Control Number: " || exit /b 0

rem Set initial source path and destination path here.
@rem Note: destination path without trailing "\UV*\DOCUMENTS".
set "source=%HOMEPATH%\%code%\Folder1\%code%-DATA.pdf"
set "destination=%HOMEPATH%\Folder\%code%"

rem Check initial source path.
if not exist "%source%" (
    >&2 echo Initial source path "%source%" not exist.
    exit /b 1
)

rem Check initial destination path.
if not exist "%destination%" (
    >&2 echo Initial destination path "%destination%" not exist.
    exit /b 1
)

rem Get "%%destination%%\UV*\DOCUMENTS\" path.
(
    set "destination="

    for /d %%A in ("%destination%\UV*") do if not defined destination (
        @rem Force an echo on line break.
        if exist "%%~A\DOCUMENTS\" set "destination=%%~A\DOCUMENTS\"
    )

    if not defined destination (
        >&2 echo Failed to get destination from "%destination%".
        exit /b 1
    )
)

rem Copy file from source to destination if file date is newer.
xcopy /d /y "%source%" "%destination%"
exit /b 0

This will try to find the destination path with
UV* in the path as specified in the OP and
comments as to my understanding.

Change directory to %HOMEDRIVE% else a path
starting with %HOMEPATH% can be invalid if
the the current directory is on another drive.
If you use a drive which mirrors the %HOMEPATH%
then you can disable the change of directory to
remain on that drive.

The destination path is resolved to the
DOCUMENTS folder, else the destination
variable will be detected as undefined.

Checks are done to ensure initial source
and destination paths exist.

Since only 1 file is being copied, using
xcopy arguments that apply for 1 file.
Check to see if I am correct.

To understand what the code is doing, set
the line @echo off to @echo on to test.


问:
VBA Excel save .xlsx file with the flexible name
I would like to save my file with the flexible name, which will change as the cell value changes.

The one answer is here:

Save a file with a name that corresponds to a cell value

however, I want also some fixed part of the name, which won't change unlike the part described in the query above.

Basing on this solution I tried to write something as follows:

```<code>Sub Save ()
Dim name As String, Custom_Name As String

name = Range("A2").Value
Custom_Name = "NBU" & name & "- Opportunity list.xlsx"
ActiveWorkbook.SaveAs Filename:=Custom_Name
</code>```

In the effect, I am getting an error:

This extension cannot be used with the selected file type. Change the file extension in the File name text box or select a different type file by changing the Save as type.

I would like to have this file in the .xlsx extension.

Excel VBA - save as with .xlsx extension

The answer above doesn't really match to my situation.
It will be vital to remove all form control buttons in the newly saved file, when possible.

Thanks & Regards,

```<code>End Sub
</code>```

答: You said the file name is 'Opportunity v1.0.xslm'.  Would it have macros?  My version of Excel complains about using .xlsx if there is code in the workbook.</p>

Body:
I would like to save my file with the flexible name, which will change as the cell value changes.

The one answer is here:

Save a file with a name that corresponds to a cell value

however, I want also some fixed part of the name, which won't change unlike the part described in the query above.

Basing on this solution I tried to write something as follows:

Sub Save ()
Dim name As String, Custom_Name As String

name = Range("A2").Value
Custom_Name = "NBU" & name & "- Opportunity list.xlsx"
ActiveWorkbook.SaveAs Filename:=Custom_Name

In the effect, I am getting an error:

This extension cannot be used with the selected file type. Change the file extension in the File name text box or select a different type file by changing the Save as type.

I would like to have this file in the .xlsx extension.

Excel VBA - save as with .xlsx extension

The answer above doesn't really match to my situation.
It will be vital to remove all form control buttons in the newly saved file, when possible.

Thanks & Regards,

End Sub


问:
new xib in xcode4
I develped an iPhone app. Now i would like to do it in iPad. To do this I have to create the new .XIB files and linked to his Class.

I don't know how to create a new .xib in xcode4. Could somebody help me?

Now, to solve this problem, I create a new file with his .XIB, delete the .m & .h and link the .XIB with my class.

Thanyou.

答:
In order to create a XIB file in XCode 4, just go to the main menu, File->New->New File..., and from there choose User Interface from the iOS section. Then choose View (if that's what you want), device family and finally save.

Hope it helps.

Title: new xib in xcode4


问:
Generating shell scripts using python
Hi I'm currently working on a python script that generates shell scripts to install agents on a linux server. The .sh files that the python scripts output keeps ending up with a "syntax error: unexpected end of file" but when i manually type in the exact output in vi, there seems to be no issue. Is there any issue with how I'm writing it in python or is it feasible to do it through python?

python script

```<code>import csv

def menu():
    print("type of scripts")
    print("1. Install + Generation")
    print("2. Unregister + Reregister")
    print("3. Unregister + Uninstall")

#Converts numeral choice into type for script naming
def choicename(choice):
    choice = int(choice)
    if choice==1:
        return "install"
    elif choice == 2 :
        return "rereg"
    else:
        return "uninstall"

#Generates the install agent scripts
def installScript(agentname,agentfile,mgrfile,prigw,secgw,ostype):
    #Generates the script for Linux agents (.sh)
    if ostype=="Linux":
        agentpath = 'agent="/opt/test/ragent/bin/racli"'
        installerpath = '\ninstaller="/opt/test/installer/bin/racli"'

        checkAgent = '\nif [ ! -e "$agent" ]; then' +"\n" + "./" + agentfile + " -n -d /opt/test" + '\nelse\necho "Agent is already installed"\nfi'
        checkInstaller = '\nif [ ! -e "$installer" ]; then' + "\n" +"./" + mgrfile + " -n -d /opt/test"+ '\nelse\necho "Manager is already installed"\nfi'

        regAgent = "\n/opt/test/ragent/bin/cli registration advanced-register registration-type=Primary ragent-name="+ agentname+ " gw-ip="+ prigw+ " gw-port=443 manual-settings-activation=Automatic monitor-networkchannels=Both password=$1"
        if secgw!="":
            regAgent+="\n/opt/test/ragent/bin/cli registration advanced-register registration-type=Secondary ragent-name="+ agentname+ " gw-ip="+ secgw+ " gw-port=443 manual-settings-activation=Automatic monitor-networkchannels=Both password=$1"
        startAgent="\n/opt/test/ragent/bin/rainit start"

        regInstaller="\n/opt/test/installer/bin/cliinstaller registration register-use-existing package-folder-path=\".\" package-folder-size=1024"
        startInstaller="\n/opt/test/installer/bin/rainstallerinit start"

        sf = open(agentname+ "_install.sh","w")
        sf.write(agentpath+installerpath+checkAgent+checkInstaller+regAgent+startAgent+regInstaller+startInstaller)
        sf.close()

def scriptSplit(option,agentname,agentfile,mgrfile,prigw,secgw,ostype):
    if option=="install":
        installScript(agentname,agentfile,mgrfile,prigw,secgw,ostype)
    elif option =="rereg":
        reregScript(agentname,agentfile,mgrfile,prigw,secgw,ostype)
    elif option =="uninstall":
        uninstallScript()

#Collects user input for function type
def main():
    menu()
    choice = input("Please choose the type of script you would like to generate: ")
    option = choicename(choice)
    filename = input("Please enter the name of the csv file: ")

    with open(filename) as csv_file:
        creader = csv.reader(csv_file, delimiter=",")
        line_count = 0
        for row in creader:
            if line_count!=0:
                agentname=row[0]
                agentfile=row[1]
                mgrfile=row[2]
                prigw=row[3]
                secgw=row[4]
                installtype=row[5]
                scriptSplit(option,agentname,agentfile,mgrfile,prigw,secgw,installtype)
            line_count += 1
#### END OF FUNCTIONS ###

main()
</code>```

output from above script

```<code>agent="/opt/test/ragent/bin/racli"
installer="/opt/test/installer/bin/racli"
if [ ! -e "$agent" ]; then
./agent1.bsx -n -d /opt/test
else
echo "Agent is already installed"
fi
if [ ! -e "$installer" ]; then
./installer1.bsx -n -d /opt/test
else
echo "Manager is already installed"
fi
/opt/test/ragent/bin/cli registration advanced-register registration-type=Primary ragent-name=agent1 gw-ip=10.255.0.80 gw-port=443 manual-settings-activation=Automatic monitor-networkchannels=Both password=$1
/opt/test/ragent/bin/cli registration advanced-register registration-type=Secondary ragent-name=agent1 gw-ip=10.255.0.81 gw-port=443 manual-settings-activation=Automatic monitor-networkchannels=Both password=$1
/opt/test/ragent/bin/rainit start
/opt/test/installer/bin/cliinstaller registration register-use-existing package-folder-path="." package-folder-size=1024
/opt/test/installer/bin/rainstallerinit start
</code>```

csv file it reads from

```<code>Agent Name,Agent File,Installer File,Primary IP,Secondary IP,Type
agent1,agent1.bsx,installer1.bsx,10.255.0.80,10.255.0.81,Linux
agent2,agent2.bsx,installer2.bsx,10.255.0.81,,Linux
</code>```

答:
The newline convention is \r\n on windows. Bash interprets newline character as... newline character, and the \r is a normal character for bash.

Fix:

```<code>sf = open(agentname+ "_install.sh", "w", newline='\n')
</code>```

Title: Generating shell scripts using python

Body:
Hi I'm currently working on a python script that generates shell scripts to install agents on a linux server. The .sh files that the python scripts output keeps ending up with a "syntax error: unexpected end of file" but when i manually type in the exact output in vi, there seems to be no issue. Is there any issue with how I'm writing it in python or is it feasible to do it through python?

python script

import csv

def menu():
    print("type of scripts")
    print("1. Install + Generation")
    print("2. Unregister + Reregister")
    print("3. Unregister + Uninstall")

#Converts numeral choice into type for script naming
def choicename(choice):
    choice = int(choice)
    if choice==1:
        return "install"
    elif choice == 2 :
        return "rereg"
    else:
        return "uninstall"

#Generates the install agent scripts
def installScript(agentname,agentfile,mgrfile,prigw,secgw,ostype):
    #Generates the script for Linux agents (.sh)
    if ostype=="Linux":
        agentpath = 'agent="/opt/test/ragent/bin/racli"'
        installerpath = '\ninstaller="/opt/test/installer/bin/racli"'

        checkAgent = '\nif [ ! -e "$agent" ]; then' +"\n" + "./" + agentfile + " -n -d /opt/test" + '\nelse\necho "Agent is already installed"\nfi'
        checkInstaller = '\nif [ ! -e "$installer" ]; then' + "\n" +"./" + mgrfile + " -n -d /opt/test"+ '\nelse\necho "Manager is already installed"\nfi'

        regAgent = "\n/opt/test/ragent/bin/cli registration advanced-register registration-type=Primary ragent-name="+ agentname+ " gw-ip="+ prigw+ " gw-port=443 manual-settings-activation=Automatic monitor-networkchannels=Both password=$1"
        if secgw!="":
            regAgent+="\n/opt/test/ragent/bin/cli registration advanced-register registration-type=Secondary ragent-name="+ agentname+ " gw-ip="+ secgw+ " gw-port=443 manual-settings-activation=Automatic monitor-networkchannels=Both password=$1"
        startAgent="\n/opt/test/ragent/bin/rainit start"

        regInstaller="\n/opt/test/installer/bin/cliinstaller registration register-use-existing package-folder-path=\".\" package-folder-size=1024"
        startInstaller="\n/opt/test/installer/bin/rainstallerinit start"

        sf = open(agentname+ "_install.sh","w")
        sf.write(agentpath+installerpath+checkAgent+checkInstaller+regAgent+startAgent+regInstaller+startInstaller)
        sf.close()

def scriptSplit(option,agentname,agentfile,mgrfile,prigw,secgw,ostype):
    if option=="install":
        installScript(agentname,agentfile,mgrfile,prigw,secgw,ostype)
    elif option =="rereg":
        reregScript(agentname,agentfile,mgrfile,prigw,secgw,ostype)
    elif option =="uninstall":
        uninstallScript()

#Collects user input for function type
def main():
    menu()
    choice = input("Please choose the type of script you would like to generate: ")
    option = choicename(choice)
    filename = input("Please enter the name of the csv file: ")

    with open(filename) as csv_file:
        creader = csv.reader(csv_file, delimiter=",")
        line_count = 0
        for row in creader:
            if line_count!=0:
                agentname=row[0]
                agentfile=row[1]
                mgrfile=row[2]
                prigw=row[3]
                secgw=row[4]
                installtype=row[5]
                scriptSplit(option,agentname,agentfile,mgrfile,prigw,secgw,installtype)
            line_count += 1
#### END OF FUNCTIONS ###

main()

output from above script

agent="/opt/test/ragent/bin/racli"
installer="/opt/test/installer/bin/racli"
if [ ! -e "$agent" ]; then
./agent1.bsx -n -d /opt/test
else
echo "Agent is already installed"
fi
if [ ! -e "$installer" ]; then
./installer1.bsx -n -d /opt/test
else
echo "Manager is already installed"
fi
/opt/test/ragent/bin/cli registration advanced-register registration-type=Primary ragent-name=agent1 gw-ip=10.255.0.80 gw-port=443 manual-settings-activation=Automatic monitor-networkchannels=Both password=$1
/opt/test/ragent/bin/cli registration advanced-register registration-type=Secondary ragent-name=agent1 gw-ip=10.255.0.81 gw-port=443 manual-settings-activation=Automatic monitor-networkchannels=Both password=$1
/opt/test/ragent/bin/rainit start
/opt/test/installer/bin/cliinstaller registration register-use-existing package-folder-path="." package-folder-size=1024
/opt/test/installer/bin/rainstallerinit start

csv file it reads from

Agent Name,Agent File,Installer File,Primary IP,Secondary IP,Type
agent1,agent1.bsx,installer1.bsx,10.255.0.80,10.255.0.81,Linux
agent2,agent2.bsx,installer2.bsx,10.255.0.81,,Linux

Body:
The newline convention is \r\n on windows. Bash interprets newline character as... newline character, and the \r is a normal character for bash.

Fix:

sf = open(agentname+ "_install.sh", "w", newline='\n')


问:
RegEx with notepad++: Remove two groups of text
i have this string on a line:

('some text', 'some text', 'some text', '{\n  {\n  {\n .
Some text
Some text
Some text

 \n} \n} \n}', 'some text' , 'some text')

and i would to have this result using RegEx with notepad++:

('some text', 'some text', 'some text', '
Some text
Some text
Some text

', 'some text' , 'some text')

Is it possible? Someone can help me?
Thank you

答:
Yes, you can simply use the OR(|) operator between the two groups you want to remove, and cancel out the backslashes with a backslash

```<code>({\\n  {\\n  {\\n .)|( \\n} \\n} \\n})
</code>```

in the replace tab, and select the regular expressions search mode

Body:
Yes, you can simply use the OR(|) operator between the two groups you want to remove, and cancel out the backslashes with a backslash

({\\n  {\\n  {\\n .)|( \\n} \\n} \\n})

in the replace tab, and select the regular expressions search mode


问:
Sudoku Recursive Backtracking in Go
I am trying to solve a sudoku puzzle in Go using a recursive backtracking algorithm. I created helper functions that check if a certain row, column, or block are valid (i.e no repeated values), as well as a function to print out the current state. I have tested all of these many times so I don't think they are causing the issue. I created the following function to test if a potential game board would be possible.

```<code>func cellValid(gameBoard *[9][9]int, value int, y int, x int) bool {
    oldVal := gameBoard[y-1][x-1]
    gameBoard[y-1][x-1] = value
    row := getRow(gameBoard, y)
    col := getCol(gameBoard, x)
    block := getBlock(gameBoard, x, y)
    possible := unitValid(row) && unitValid(col) && unitValid(block)
    gameBoard[y-1][x-1] = oldVal
    return possible
}
</code>```

It makes a change to the gameboard, checks if it is possible and stores that bool in the variable possible. It changes the board back to what it was then returns the bool. This function is being called from the following solveBoard function.

```<code>func solveBoard(gameBoard *[9][9]int) {
    for row := 1; row <= 9; row++ {
        for col := 1; col <= 9; col++ {
            if gameBoard[row-1][col-1] == 0 {
                for value := 1; value <= 9; value++ {
                    if cellValid(gameBoard, value, row, col) {
                        gameBoard[row-1][col-1] = value
                        solveBoard(gameBoard)
                        gameBoard[row-1][col-1] = 0
                    }
                }
                return
            }
        }
    }
    printBoard(gameBoard)
    return
}
</code>```

Upon running the file I get no output.

```<code>func main() {
    var gameBoard = [9][9]int{
        {5, 3, 0, 0, 7, 0, 0, 0, 0},
        {6, 0, 0, 1, 9, 5, 0, 0, 0},
        {0, 9, 8, 0, 0, 0, 0, 6, 0},
        {8, 0, 0, 0, 6, 0, 0, 0, 3},
        {4, 0, 0, 8, 0, 3, 0, 0, 1},
        {7, 0, 0, 0, 2, 0, 0, 0, 6},
        {0, 6, 0, 0, 0, 0, 2, 8, 0},
        {0, 0, 0, 4, 1, 9, 0, 0, 5},
        {0, 0, 0, 0, 8, 0, 0, 7, 9}}

    solveBoard(&gameBoard)
}
</code>```

Here is a link to a go playground containing all my code.
Go Playground

The following video demonstrates what I am trying to accomplish in python.

Computerphile Video

Solution to puzzle:
Puzzle solution

答:
The final working code is.</p>

```<code>package main

import (
    "fmt"
)

func printBoard(gameBoard *[9][9]int) {
    for y := 0; y < 9; y++ {
        if y == 3 || y == 6 {
            fmt.Println("\n---------")
        } else {
            fmt.Println("")
        }
        for x := 0; x < 9; x++ {
            if x == 3 || x == 6 {
                fmt.Print("|", gameBoard[y][x])
            } else {
                fmt.Print("", gameBoard[y][x])
            }
        }
    }
    fmt.Println("")
}

func unitValid(unit [9]int) bool {
    for value := 1; value <= 9; value++ {
        count := 0
        for index := 0; index < 9; index++ {
            if unit[index] == value {
                count++
            }
        }
        if count > 1 {
            return false
        }
    }
    return true
}

func getRow(gameBoard *[9][9]int, row int) [9]int {
    return gameBoard[row-1]
}

func getCol(gameBoard *[9][9]int, col int) [9]int {
    var column [9]int
    for row := 0; row < 9; row++ {
        column[row] = gameBoard[row][col-1]
    }
    return column
}

func getBlock(gameBoard *[9][9]int, row, col int) [9]int {
    i := whatBlock(col)*3 - 2
    j := whatBlock(row)*3 - 2
    var block [9]int
    block[0] = gameBoard[j-1][i-1]
    block[1] = gameBoard[j-1][i]
    block[2] = gameBoard[j-1][i+1]
    block[3] = gameBoard[j][i-1]
    block[4] = gameBoard[j][i]
    block[5] = gameBoard[j][i+1]
    block[6] = gameBoard[j+1][i-1]
    block[7] = gameBoard[j+1][i]
    block[8] = gameBoard[j+1][i+1]
    return block
}

func whatBlock(val int) int {
    if val >= 1 && val <= 3 {
        return 1
    } else if val >= 4 && val <= 6 {
        return 2
    } else if val >= 7 && val <= 9 {
        return 3
    }
    return 0
}

func cellValid(gameBoard *[9][9]int, value int, y int, x int) bool {
    oldVal := gameBoard[y-1][x-1]
    gameBoard[y-1][x-1] = value
    row := getRow(gameBoard, y)
    col := getCol(gameBoard, x)
    block := getBlock(gameBoard, y, x)
    possible := unitValid(row) && unitValid(col) && unitValid(block)
    gameBoard[y-1][x-1] = oldVal
    return possible
}

func solveBoard(gameBoard *[9][9]int) {
    for row := 1; row <= 9; row++ {
        for col := 1; col <= 9; col++ {
            if gameBoard[row-1][col-1] == 0 {
                for value := 1; value <= 9; value++ {
                    if cellValid(gameBoard, value, row, col) {
                        gameBoard[row-1][col-1] = value
                        solveBoard(gameBoard)
                        gameBoard[row-1][col-1] = 0
                    }
                }
                return
            }
        }
    }
    printBoard(gameBoard)
    return
}

func main() {
    var gameBoard = [9][9]int{
        {5, 3, 0, 0, 7, 0, 0, 0, 0},
        {6, 0, 0, 1, 9, 5, 0, 0, 0},
        {0, 9, 8, 0, 0, 0, 0, 6, 0},
        {8, 0, 0, 0, 6, 0, 0, 0, 3},
        {4, 0, 0, 8, 0, 3, 0, 0, 1},
        {7, 0, 0, 0, 2, 0, 0, 0, 6},
        {0, 6, 0, 0, 0, 0, 2, 8, 0},
        {0, 0, 0, 4, 1, 9, 0, 0, 5},
        {0, 0, 0, 0, 8, 0, 0, 7, 9}}

    solveBoard(&gameBoard)
}
</code>```

Title: Sudoku Recursive Backtracking in Go

Body:
I am trying to solve a sudoku puzzle in Go using a recursive backtracking algorithm. I created helper functions that check if a certain row, column, or block are valid (i.e no repeated values), as well as a function to print out the current state. I have tested all of these many times so I don't think they are causing the issue. I created the following function to test if a potential game board would be possible.

func cellValid(gameBoard *[9][9]int, value int, y int, x int) bool {
    oldVal := gameBoard[y-1][x-1]
    gameBoard[y-1][x-1] = value
    row := getRow(gameBoard, y)
    col := getCol(gameBoard, x)
    block := getBlock(gameBoard, x, y)
    possible := unitValid(row) && unitValid(col) && unitValid(block)
    gameBoard[y-1][x-1] = oldVal
    return possible
}

It makes a change to the gameboard, checks if it is possible and stores that bool in the variable possible. It changes the board back to what it was then returns the bool. This function is being called from the following solveBoard function.

func solveBoard(gameBoard *[9][9]int) {
    for row := 1; row <= 9; row++ {
        for col := 1; col <= 9; col++ {
            if gameBoard[row-1][col-1] == 0 {
                for value := 1; value <= 9; value++ {
                    if cellValid(gameBoard, value, row, col) {
                        gameBoard[row-1][col-1] = value
                        solveBoard(gameBoard)
                        gameBoard[row-1][col-1] = 0
                    }
                }
                return
            }
        }
    }
    printBoard(gameBoard)
    return
}

Upon running the file I get no output.

func main() {
    var gameBoard = [9][9]int{
        {5, 3, 0, 0, 7, 0, 0, 0, 0},
        {6, 0, 0, 1, 9, 5, 0, 0, 0},
        {0, 9, 8, 0, 0, 0, 0, 6, 0},
        {8, 0, 0, 0, 6, 0, 0, 0, 3},
        {4, 0, 0, 8, 0, 3, 0, 0, 1},
        {7, 0, 0, 0, 2, 0, 0, 0, 6},
        {0, 6, 0, 0, 0, 0, 2, 8, 0},
        {0, 0, 0, 4, 1, 9, 0, 0, 5},
        {0, 0, 0, 0, 8, 0, 0, 7, 9}}

    solveBoard(&gameBoard)
}

Here is a link to a go playground containing all my code.
Go Playground

The following video demonstrates what I am trying to accomplish in python.

Computerphile Video

Solution to puzzle:
Puzzle solution

Body:
The final working code is.

package main

import (
    "fmt"
)

func printBoard(gameBoard *[9][9]int) {
    for y := 0; y < 9; y++ {
        if y == 3 || y == 6 {
            fmt.Println("\n---------")
        } else {
            fmt.Println("")
        }
        for x := 0; x < 9; x++ {
            if x == 3 || x == 6 {
                fmt.Print("|", gameBoard[y][x])
            } else {
                fmt.Print("", gameBoard[y][x])
            }
        }
    }
    fmt.Println("")
}

func unitValid(unit [9]int) bool {
    for value := 1; value <= 9; value++ {
        count := 0
        for index := 0; index < 9; index++ {
            if unit[index] == value {
                count++
            }
        }
        if count > 1 {
            return false
        }
    }
    return true
}

func getRow(gameBoard *[9][9]int, row int) [9]int {
    return gameBoard[row-1]
}

func getCol(gameBoard *[9][9]int, col int) [9]int {
    var column [9]int
    for row := 0; row < 9; row++ {
        column[row] = gameBoard[row][col-1]
    }
    return column
}

func getBlock(gameBoard *[9][9]int, row, col int) [9]int {
    i := whatBlock(col)*3 - 2
    j := whatBlock(row)*3 - 2
    var block [9]int
    block[0] = gameBoard[j-1][i-1]
    block[1] = gameBoard[j-1][i]
    block[2] = gameBoard[j-1][i+1]
    block[3] = gameBoard[j][i-1]
    block[4] = gameBoard[j][i]
    block[5] = gameBoard[j][i+1]
    block[6] = gameBoard[j+1][i-1]
    block[7] = gameBoard[j+1][i]
    block[8] = gameBoard[j+1][i+1]
    return block
}

func whatBlock(val int) int {
    if val >= 1 && val <= 3 {
        return 1
    } else if val >= 4 && val <= 6 {
        return 2
    } else if val >= 7 && val <= 9 {
        return 3
    }
    return 0
}

func cellValid(gameBoard *[9][9]int, value int, y int, x int) bool {
    oldVal := gameBoard[y-1][x-1]
    gameBoard[y-1][x-1] = value
    row := getRow(gameBoard, y)
    col := getCol(gameBoard, x)
    block := getBlock(gameBoard, y, x)
    possible := unitValid(row) && unitValid(col) && unitValid(block)
    gameBoard[y-1][x-1] = oldVal
    return possible
}

func solveBoard(gameBoard *[9][9]int) {
    for row := 1; row <= 9; row++ {
        for col := 1; col <= 9; col++ {
            if gameBoard[row-1][col-1] == 0 {
                for value := 1; value <= 9; value++ {
                    if cellValid(gameBoard, value, row, col) {
                        gameBoard[row-1][col-1] = value
                        solveBoard(gameBoard)
                        gameBoard[row-1][col-1] = 0
                    }
                }
                return
            }
        }
    }
    printBoard(gameBoard)
    return
}

func main() {
    var gameBoard = [9][9]int{
        {5, 3, 0, 0, 7, 0, 0, 0, 0},
        {6, 0, 0, 1, 9, 5, 0, 0, 0},
        {0, 9, 8, 0, 0, 0, 0, 6, 0},
        {8, 0, 0, 0, 6, 0, 0, 0, 3},
        {4, 0, 0, 8, 0, 3, 0, 0, 1},
        {7, 0, 0, 0, 2, 0, 0, 0, 6},
        {0, 6, 0, 0, 0, 0, 2, 8, 0},
        {0, 0, 0, 4, 1, 9, 0, 0, 5},
        {0, 0, 0, 0, 8, 0, 0, 7, 9}}

    solveBoard(&gameBoard)
}