问:
What is the equivalent pg SQL for this Mysql statement (inner join in UPDATE statement)?
Mysql:

UPDATE a INNER JOIN b on a.b_id = b.id SET n=1 WHERE b.n > 2

Postgresql (I know):

UPDATE a SET n=1 FROM b WHERE b.n > 2 AND a.b_id = b.id

But what are the equivalent pg statements for:

UPDATE a OUTER JOIN b on a.b_id = b.id SET n=1 WHERE b.n > 2

UPDATE a LEFT JOIN b on a.b_id = b.id SET n=1 WHERE b.n > 2

More generally, what's the equivalent pg statement if I have several inner join tables (e.g. 3 tables)in Mysql like:

```<code>UPDATE a
INNER JOIN b on a.b_id = b.id
INNER JOIN c on b.c_id = c.id
INNER JOIN d on c.d_id = d.id
SET n=1 WHERE d.n > 2
</code>```

答:
Generally, you can create a subQuery like this (which is very flexible and clear):</p>

```<code>UPDATE  tblA
SET     colA = subQuery.colA
FROM    (
        SELECT  tblA.id, tblA.colA
        FROM    tblA
                INNER JOIN tblB AS b    ON b.id = tblA.b_id
                INNER JOIN tblC AS c    ON c.id = b.c_id
        WHERE   c.someData > 100
        ) AS subQuery
WHERE   tblA.id = subQuery.id
</code>```

Body:
Mysql:

UPDATE a INNER JOIN b on a.b_id = b.id SET n=1 WHERE b.n > 2

Postgresql (I know):

UPDATE a SET n=1 FROM b WHERE b.n > 2 AND a.b_id = b.id

But what are the equivalent pg statements for:

UPDATE a OUTER JOIN b on a.b_id = b.id SET n=1 WHERE b.n > 2

UPDATE a LEFT JOIN b on a.b_id = b.id SET n=1 WHERE b.n > 2

More generally, what's the equivalent pg statement if I have several inner join tables (e.g. 3 tables)in Mysql like:

UPDATE a
INNER JOIN b on a.b_id = b.id
INNER JOIN c on b.c_id = c.id
INNER JOIN d on c.d_id = d.id
SET n=1 WHERE d.n > 2

Body:
Generally, you can create a subQuery like this (which is very flexible and clear):

UPDATE  tblA
SET     colA = subQuery.colA
FROM    (
        SELECT  tblA.id, tblA.colA
        FROM    tblA
                INNER JOIN tblB AS b    ON b.id = tblA.b_id
                INNER JOIN tblC AS c    ON c.id = b.c_id
        WHERE   c.someData > 100
        ) AS subQuery
WHERE   tblA.id = subQuery.id


来源: stackexchange

问:
transition from Val to Val using Decaying Sine wave
I'm struggling to construct the formula which would allow me to transition from a start value, to a targeted end value while decaying over the specified time using a Sin or Cos wave?

I'm trying to mimic a bouncing effect as seen in my sample below using CSS and jsfiddle. I made this sample just for visuals. The final formula can be written in plain math, not language specific.

My goal is create a function which I can pass these core variables and have it return an array of all the positions.

```<code>start = 0.0
end = 200.0
duration = 1000
bounces = 10
</code>```

https://jsfiddle.net/JokerMartini/bkw8vqyc/3/

答:
You are working with animation-target inside of result. Let's suppose you have an interval of [a, b] to animate. If we suppose that P1 and P2 are inside this interval and |P1.x - P2.x| ~ 0, but |P1.x - P2.x| <> 0, then you can calculate their x by their sine and cosine, respectively. If you think of the interval of [a, b] as of a successive set of points very close in each-other, then your global animation algorithm will look like this:

```<code>p1 <- a - step
p2 <- a
while p1 <= b
    p1 <- p2
    p2 <- p2 + step
    animate(p1, sin(p1), p2, sin(p2))
end while
</code>```

Now, if you are working with Javascript, you will be able to do this by very close events, like setInterval(yourfunction, 10); If this is not smooth-enough, then you will be able to improve this with CSS styling for transition, specifying the time it will take for each step, in this case, 10 milliseconds. You can use the sin and the cos functions of the Math object in Javascript.

ContentLicense: CC BY-SA 3.0

Body:
I'm struggling to construct the formula which would allow me to transition from a start value, to a targeted end value while decaying over the specified time using a Sin or Cos wave?

I'm trying to mimic a bouncing effect as seen in my sample below using CSS and jsfiddle. I made this sample just for visuals. The final formula can be written in plain math, not language specific.

My goal is create a function which I can pass these core variables and have it return an array of all the positions.

start = 0.0
end = 200.0
duration = 1000
bounces = 10

https://jsfiddle.net/JokerMartini/bkw8vqyc/3/

Body:
You are working with animation-target inside of result. Let's suppose you have an interval of [a, b] to animate. If we suppose that P1 and P2 are inside this interval and |P1.x - P2.x| ~ 0, but |P1.x - P2.x| <> 0, then you can calculate their x by their sine and cosine, respectively. If you think of the interval of [a, b] as of a successive set of points very close in each-other, then your global animation algorithm will look like this:

p1 <- a - step
p2 <- a
while p1 <= b
    p1 <- p2
    p2 <- p2 + step
    animate(p1, sin(p1), p2, sin(p2))
end while

Now, if you are working with Javascript, you will be able to do this by very close events, like setInterval(yourfunction, 10); If this is not smooth-enough, then you will be able to improve this with CSS styling for transition, specifying the time it will take for each step, in this case, 10 milliseconds. You can use the sin and the cos functions of the Math object in Javascript.


问:
How to open link in new window without _blank page?
I have a webpage with an url to PHP file which displays picture. I want to open this picture in new window without blank page.

For now with code below, when I click on URL, blank page and new window open (which I have to close each time). I do not want this blank page, only window with picture

```<code>window.open('image.PNG', 'image', 'toolbar,menubar,scrollbars,resizable,height=800,width=400,left=600,top=400');
</code>```

How to do it?

//edit
Prevent default does not work if I have

```<code><a href="file.php">Link</a> //URL to PHP with script above
</code>```

答:
If you paste this in your console:

```<code>open('image.png');
</code>```

And a new tab opens with the picture you want, than try:

```<code><a href = 'image.png' id = 'image'>
</code>```

and

```<code>document.getElementById('image').onclick = funciton(e){
    e.preventDefault();
    open('image.PNG', 'image', 'toolbar,menubar,scrollbars,resizable,height=800,width=400,left=600,top=400');
};
</code>```

If that doesn't work, paste this in your console:

```<code>open('file.php');
</code>```

And a new tab opens with the picture you want, than try:

```<code><a href = 'file.php' id = 'file'>
</code>```

and

```<code>document.getElementById('file').onclick = funciton(e){
    e.preventDefault();
    open('file.php', 'image', 'toolbar,menubar,scrollbars,resizable,height=800,width=400,left=600,top=400');
};
</code>```

If none of that works, comment below.

Body:
I have a webpage with an url to PHP file which displays picture. I want to open this picture in new window without blank page.

For now with code below, when I click on URL, blank page and new window open (which I have to close each time). I do not want this blank page, only window with picture

window.open('image.PNG', 'image', 'toolbar,menubar,scrollbars,resizable,height=800,width=400,left=600,top=400');

How to do it?

//edit
Prevent default does not work if I have

Link //URL to PHP with script above

Body:
If you paste this in your console:

open('image.png');

And a new tab opens with the picture you want, than try:

<a href = 'image.png' id = 'image'>

and

document.getElementById('image').onclick = funciton(e){
    e.preventDefault();
    open('image.PNG', 'image', 'toolbar,menubar,scrollbars,resizable,height=800,width=400,left=600,top=400');
};

If that doesn't work, paste this in your console:

open('file.php');

And a new tab opens with the picture you want, than try:

<a href = 'file.php' id = 'file'>

and

document.getElementById('file').onclick = funciton(e){
    e.preventDefault();
    open('file.php', 'image', 'toolbar,menubar,scrollbars,resizable,height=800,width=400,left=600,top=400');
};

If none of that works, comment below.


问:
Transfer Microsoft SQL Server data to Oracle tables on daily basis
I want to transfer SQL Server data to Oracle tables on a daily basis.

What's the best way to do it? I am using Windows 7 as OS and SQL Developer as a tool.

Please suggest.

Thanks.

答:
You can use the built in Export Data command to generate an SSIS package that you can then run on a daily basis.

```<code>1) Right click on the data base in SSMS on the Object Explorer Window.
2) Select 'Tasks' from the pop-up window.
3) Click on Export Data.
4) Choose a data source (SQL Server Data Base)
5) Choose data destination as Oracle
</code>```

At the end of the GUI you can save it as a SSIS package. Please do so and you can then run it either as a SQL Server Agent job or at the Windows level by  using the DTEXEC command. My biggest challange when doing this is getting credentials on Oracle that allows writing and finding the correct ORA file.

Body:
You can use the built in Export Data command to generate an SSIS package that you can then run on a daily basis.

1) Right click on the data base in SSMS on the Object Explorer Window.
2) Select 'Tasks' from the pop-up window.
3) Click on Export Data.
4) Choose a data source (SQL Server Data Base)
5) Choose data destination as Oracle

At the end of the GUI you can save it as a SSIS package. Please do so and you can then run it either as a SQL Server Agent job or at the Windows level by  using the DTEXEC command. My biggest challange when doing this is getting credentials on Oracle that allows writing and finding the correct ORA file.


问:
Instagram API: I get no access_token
I am using this PHP Instagram Client to try to access the API of Instagram, but every time I try to access it, I get this message in return:

```<code>object(stdClass)#4 (1) {
  ["meta"]=>
  object(stdClass)#2 (3) {
    ["code"]=>
    int(400)
    ["error_type"]=>
    string(25) "OAuthAccessTokenException"
    ["error_message"]=>
    string(37) "The access_token provided is invalid."
  }
}
</code>```

and I cannot figure out what I am doing wrong.

This is my code so far:

```<code>$instagram = new MetzWeb\Instagram\Instagram('......');
$result = $instagram->getPopularMedia();
var_dump($result);
</code>```

When I check my $instagram object, the data inside does not seem right, as there seems to be no access token.

```<code>object(MetzWeb\Instagram\Instagram)#3 (7) {
  ["_apikey":"MetzWeb\Instagram\Instagram":private]=>
  string(32) "...."
  ["_apisecret":"MetzWeb\Instagram\Instagram":private]=>
  NULL
  ["_callbackurl":"MetzWeb\Instagram\Instagram":private]=>
  NULL
  ["_accesstoken":"MetzWeb\Instagram\Instagram":private]=>
  NULL
  ["_signedheader":"MetzWeb\Instagram\Instagram":private]=>
  bool(false)
</code>```

What is it that I am missing?

答:
As you can see on the github repo:

Note: On the 17 Nov 2015 Instagram made changes to their API . Apps
  created before Nov 17, 2015 wont be affected until Jun 2016. Apps
  created on or after Nov 17 2015 will require to use their updated API.
  Please note that this library doesn't yet support their new updates.
  For more information, please see #182.

Meaning the library does not yet support the latest Instagram API.

UPDATE:
Instagram only allows authenticated API calls, no public calls anymore.

The only way to bypass public calls is by 'scraping' data from Instagram. There are a couple of scrapers out there.

A nicer scraper is: https://github.com/vinkla/instagram

It basically fetches: https://www.instagram.com/jerryseinfeld/media/ and parses the JSON. You can fetch all tags by getting the #tags from the message.

Title: Instagram API: I get no access_token

Body:
I am using this PHP Instagram Client to try to access the API of Instagram, but every time I try to access it, I get this message in return:

object(stdClass)#4 (1) {
  ["meta"]=>
  object(stdClass)#2 (3) {
    ["code"]=>
    int(400)
    ["error_type"]=>
    string(25) "OAuthAccessTokenException"
    ["error_message"]=>
    string(37) "The access_token provided is invalid."
  }
}

and I cannot figure out what I am doing wrong.

This is my code so far:

$instagram = new MetzWeb\Instagram\Instagram('......');
$result = $instagram->getPopularMedia();
var_dump($result);

When I check my $instagram object, the data inside does not seem right, as there seems to be no access token.

object(MetzWeb\Instagram\Instagram)#3 (7) {
  ["_apikey":"MetzWeb\Instagram\Instagram":private]=>
  string(32) "...."
  ["_apisecret":"MetzWeb\Instagram\Instagram":private]=>
  NULL
  ["_callbackurl":"MetzWeb\Instagram\Instagram":private]=>
  NULL
  ["_accesstoken":"MetzWeb\Instagram\Instagram":private]=>
  NULL
  ["_signedheader":"MetzWeb\Instagram\Instagram":private]=>
  bool(false)

What is it that I am missing?


问:
IE version 8.07 Session Lost on Hyperlink click within authenticated session (asp.net)
After logging in (authorization) within my application a session is created and I am being redirected to correct location (SSL page).  However, after clicking on a hyperlink (non SSL page within same application) I am being logged out automatically (authenticated session lost).  I tested the same in FireFox 3.6 and the application is working as expected.

The above is only happening if i clear the chache from IE and log in.  However, if I login for second time after just closing the browser the above does not occur.

Thanks,

Lihnid

答:
Do you have the <forms requireSSL="" /> property set to true in your web.config?

If so, you may need to set it to false if you want the Forms Authentication cookie to be sent for SSL and non-SSL encrypted pages.

http://msdn.microsoft.com/en-us/library/system.web.security.formsauthentication.requiressl.aspx

ContentLicense: CC BY-SA 2.5


问:
Docusign document did not appear in the order expected
I have an envelope with 6 documents. The sequence is: Canyonlands-ViewOnly.docx is 1, EightDocument.docx is 2, FifthDocument.docx is 3, FirstDocument.docx is 4, screenshots.docx is 5 and
Obama-ViewOnly.docx is 6. Here is the envelope definition

```<code>"compositeTemplates": [
    {
      "compositeTemplateId": "1",
      "serverTemplates": [
        {
          "sequence": "1",
          "templateId": "61323293-7f78-4e2b-a296-0c084db16f19"
        }
      ],
      "inlineTemplates": [
        {
          "sequence": "2",
          "documents": [],
          "recipients": {
            "signers": [
              {
                "name": "Kathy Lori",
                "email": "kathylori@xxx.com",
                "recipientId": "1",
                "accessCode": "12345",
                "customFields": [],
                "routingOrder": "1",
                "note": "",
                "roleName": "Customer_SellerName",

              }
            ],
            "certifiedDeliveries": []
          },
          "customFields": {
            "textCustomFields": [
              {
                "name": "EnvelopeInfo",
                "value": "my data"
              }
            ]
          }
        }
      ],
      "document": {
        "documentId": "4",
        "name": "C:\\Temp\\Docusign\\Package\\Canyonlands-ViewOnly.docx",
        "fileExtension": ".docx",
        "order": "1",
        "documentFields": [
          {
            "name": "DMSID",
            "value": "1"
          }
        ],
        "documentBase64": "[Document:Base64Array]"
      }
    },
    {
      "compositeTemplateId": "2",
      "inlineTemplates": [
        {
          "sequence": "3",
          "documents": [
            {
              "documentId": "5",
              "name": "C:\\Temp\\Docusign\\Package\\EightDocument.docx",
              "fileExtension": ".docx",
              "order": "2",
              "documentFields": [
                {
                  "name": "DMSID",
                  "value": "2"
                }
              ],
              "documentBase64": "[Document:Base64Array]"
            },
            {
              "documentId": "6",
              "name": "C:\\Temp\\Docusign\\Package\\FifthDocument.docx",
              "fileExtension": ".docx",
              "order": "3",
              "documentFields": [
                {
                  "name": "DMSID",
                  "value": "3"
                }
              ],
              "documentBase64": "[Document:Base64Array]"
            },
            {
              "documentId": "7",
              "name": "C:\\Temp\\Docusign\\Package\\FirstDocument.docx",
              "fileExtension": ".docx",
              "order": "4",
              "documentFields": [
                {
                  "name": "DMSID",
                  "value": "4"
                }
              ],
              "documentBase64": "[Document:Base64Array]"
            },
            {
              "documentId": "9",
              "name": "C:\\Temp\\Docusign\\Package\\Obama-ViewOnly.docx",
              "fileExtension": ".docx",
              "order": "6",
              "documentFields": [
                {
                  "name": "DMSID",
                  "value": "6"
                }
              ],
              "documentBase64": "[Document:Base64Array]"
            }
          ],
          "recipients": {
            "signers": [
              {
                "name": "Kathy Lori",
                "email": "kathylori@hotmail.com",
                "recipientId": "1",
                "accessCode": "12345",
                "customFields": [],
                "routingOrder": "1",
                "note": "",
                "roleName": "Customer_SellerName",

              }
            ],
            "certifiedDeliveries": []
          },
          "customFields": {
            "textCustomFields": [
              {
                "name": "EnvelopeInfo",
                "value": "my data"
              }
            ]
          }
        }
      ]
    },
    {
      "compositeTemplateId": "2",
      "serverTemplates": [
        {
          "sequence": "2",
          "templateId": "f0f1832a-9595-40ef-b40d-c5f384f299e3"
        }
      ],
      "inlineTemplates": [
        {
          "sequence": "3",
          "documents": [],
          "recipients": {
            "signers": [
              {
                "name": "Kathy Lori",
                "email": "kathylori@xxx.com",
                "recipientId": "1",
                "accessCode": "12345",
                "customFields": [],
                "routingOrder": "1",
                "note": "",
                "roleName": "Customer_SellerName",

              }
            ],
            "certifiedDeliveries": []
          },
          "customFields": {
            "textCustomFields": [
              {
                "name": "EnvelopeInfo",
                "value": "my data"
              }
            ]
          }
        }
      ],
      "document": {
        "documentId": "10837977",
        "name": "C:\\Temp\\Docusign\\Package\\screenshots.docx",
        "fileExtension": ".docx",
        "order": "5",
        "documentFields": [
          {
            "name": "DMSID",
            "value": "5"
          }
        ],
        "documentBase64": "[Document:Base64Array]"
      }
    }
  ],
  "status": "sent",
  "emailSubject": "Here is the subject"
}
</code>```

The last two documents have appeared out of order. How can this be corrected?

答:
Use the listEnvelopeDocuments to retrieve the exact document ID's in the envelope

Once you have the documentID's use the putEnvelopeDocuments api
to update the order of the documents.

```<code>{
  "documents": [
    {
     "documentId": "4567899",
     "order": "1",
    },
    {
     "documentId": "3245678",
     "order": "2",
    }
  ]
}
</code>```

Body:
I have an envelope with 6 documents. The sequence is: Canyonlands-ViewOnly.docx is 1, EightDocument.docx is 2, FifthDocument.docx is 3, FirstDocument.docx is 4, screenshots.docx is 5 and
Obama-ViewOnly.docx is 6. Here is the envelope definition

"compositeTemplates": [
    {
      "compositeTemplateId": "1",
      "serverTemplates": [
        {
          "sequence": "1",
          "templateId": "61323293-7f78-4e2b-a296-0c084db16f19"
        }
      ],
      "inlineTemplates": [
        {
          "sequence": "2",
          "documents": [],
          "recipients": {
            "signers": [
              {
                "name": "Kathy Lori",
                "email": "kathylori@xxx.com",
                "recipientId": "1",
                "accessCode": "12345",
                "customFields": [],
                "routingOrder": "1",
                "note": "",
                "roleName": "Customer_SellerName",

              }
            ],
            "certifiedDeliveries": []
          },
          "customFields": {
            "textCustomFields": [
              {
                "name": "EnvelopeInfo",
                "value": "my data"
              }
            ]
          }
        }
      ],
      "document": {
        "documentId": "4",
        "name": "C:\\Temp\\Docusign\\Package\\Canyonlands-ViewOnly.docx",
        "fileExtension": ".docx",
        "order": "1",
        "documentFields": [
          {
            "name": "DMSID",
            "value": "1"
          }
        ],
        "documentBase64": "[Document:Base64Array]"
      }
    },
    {
      "compositeTemplateId": "2",
      "inlineTemplates": [
        {
          "sequence": "3",
          "documents": [
            {
              "documentId": "5",
              "name": "C:\\Temp\\Docusign\\Package\\EightDocument.docx",
              "fileExtension": ".docx",
              "order": "2",
              "documentFields": [
                {
                  "name": "DMSID",
                  "value": "2"
                }
              ],
              "documentBase64": "[Document:Base64Array]"
            },
            {
              "documentId": "6",
              "name": "C:\\Temp\\Docusign\\Package\\FifthDocument.docx",
              "fileExtension": ".docx",
              "order": "3",
              "documentFields": [
                {
                  "name": "DMSID",
                  "value": "3"
                }
              ],
              "documentBase64": "[Document:Base64Array]"
            },
            {
              "documentId": "7",
              "name": "C:\\Temp\\Docusign\\Package\\FirstDocument.docx",
              "fileExtension": ".docx",
              "order": "4",
              "documentFields": [
                {
                  "name": "DMSID",
                  "value": "4"
                }
              ],
              "documentBase64": "[Document:Base64Array]"
            },
            {
              "documentId": "9",
              "name": "C:\\Temp\\Docusign\\Package\\Obama-ViewOnly.docx",
              "fileExtension": ".docx",
              "order": "6",
              "documentFields": [
                {
                  "name": "DMSID",
                  "value": "6"
                }
              ],
              "documentBase64": "[Document:Base64Array]"
            }
          ],
          "recipients": {
            "signers": [
              {
                "name": "Kathy Lori",
                "email": "kathylori@hotmail.com",
                "recipientId": "1",
                "accessCode": "12345",
                "customFields": [],
                "routingOrder": "1",
                "note": "",
                "roleName": "Customer_SellerName",

              }
            ],
            "certifiedDeliveries": []
          },
          "customFields": {
            "textCustomFields": [
              {
                "name": "EnvelopeInfo",
                "value": "my data"
              }
            ]
          }
        }
      ]
    },
    {
      "compositeTemplateId": "2",
      "serverTemplates": [
        {
          "sequence": "2",
          "templateId": "f0f1832a-9595-40ef-b40d-c5f384f299e3"
        }
      ],
      "inlineTemplates": [
        {
          "sequence": "3",
          "documents": [],
          "recipients": {
            "signers": [
              {
                "name": "Kathy Lori",
                "email": "kathylori@xxx.com",
                "recipientId": "1",
                "accessCode": "12345",
                "customFields": [],
                "routingOrder": "1",
                "note": "",
                "roleName": "Customer_SellerName",

              }
            ],
            "certifiedDeliveries": []
          },
          "customFields": {
            "textCustomFields": [
              {
                "name": "EnvelopeInfo",
                "value": "my data"
              }
            ]
          }
        }
      ],
      "document": {
        "documentId": "10837977",
        "name": "C:\\Temp\\Docusign\\Package\\screenshots.docx",
        "fileExtension": ".docx",
        "order": "5",
        "documentFields": [
          {
            "name": "DMSID",
            "value": "5"
          }
        ],
        "documentBase64": "[Document:Base64Array]"
      }
    }
  ],
  "status": "sent",
  "emailSubject": "Here is the subject"
}

The last two documents have appeared out of order. How can this be corrected?

Body:
Use the listEnvelopeDocuments to retrieve the exact document ID's in the envelope

Once you have the documentID's use the putEnvelopeDocuments api
to update the order of the documents.

{
  "documents": [
    {
     "documentId": "4567899",
     "order": "1",
    },
    {
     "documentId": "3245678",
     "order": "2",
    }
  ]
}


问:
Get programmingLanguage and topic for Github repo via API
How can I get the repo-language and topic for a Github Repo through the REST API. I looked at the documentation under - https://developer.github.com/v3/ , but could not get an answer.

答:
Just found one way to do the search for topics as follows. Of course it needs a custom media type at moment.

From the documentation:

```<code>curl -H "Authentication: token TOKEN" \
-H "Accept: application/vnd.github.mercy-preview+json" \
https://api.github.com/search/repositories?q=topic:ruby+topic:rails
</code>```

For the language, it is simply the URL like :

https://api.github.com/repos/postgres/pgadmin4/languages

Body:
Just found one way to do the search for topics as follows. Of course it needs a custom media type at moment.

From the documentation:

curl -H "Authentication: token TOKEN" \
-H "Accept: application/vnd.github.mercy-preview+json" \
https://api.github.com/search/repositories?q=topic:ruby+topic:rails

For the language, it is simply the URL like :

https://api.github.com/repos/postgres/pgadmin4/languages


问:
Setting individual color for each part of Box Plot in Highchart
I would like to have top of the box and bottom of the box in different colors, and also top of the whisker and bottoom of the whisker in different color for each box (region).
But all of the lines in the box are in the same color (red) and top and bottom of the whisker are in the same color (green)

Live demo with steps to reproduce

 Highcharts.chart('container', {

        chart: {
            type: 'boxplot'
        },

        title: {
            text: 'All Patients'
        },

        legend: {
            enabled: true
        },

        xAxis: {
            categories: ['Asia Pacific', 'Europe', 'Latin America', 'North America', 'SWAC'],
            title: {
                text: '      '
            }
        },

        yAxis: {
            title: {
                text: 'Annual Center Volume 2016'
            },
            tickInterval: 5,
            min: 0,
            max: 75
            //plotLines: [{
            //    value: 932,
            //    color: 'red',
            //    width: 1,
            //    label: {
            //        text: 'Theoretical mean: 932',
            //        align: 'center',
            //        style: {
            //            color: 'gray'
            //        }
            //    }
            //}]
        },
        plotOptions: {
            boxplot: {
                fillColor: '#F0F0E0',
                lineWidth: 2,
                upperQuartileColor: 'green',
                lowerQuartileColor: 'green',
                medianColor: '#0C5DA5',
                medianWidth: 3,
                stemColor: '#A63400',
                stemDashStyle: 'solid',
                stemWidth: 1,
                whiskerColor: '#3D9200',
                whiskerLength: '20%',
                whiskerWidth: 3
            }
        },
        series: [{
            name: 'Region Runs',
            showInLegend: false,
            color: 'red',
            data: [
                [2, 4, 18, 43, 53],
                [5, 9, 16.5, 32, 52],
                [1, 3, 6, 11.5, 21],
                [3, 9, 20, 38, 73],
                [1, 2, 8, 16, 20]
            ],
            tooltip: {
                headerFormat: 'Experiment No {point.key}
'
            }
        },
        {
            name: '75th Percentile',
            type: 'line',
            color: 'red',
            marker: {
                symbol: 'square'
            },

        },
        {
            name: 'Median',
            type: 'line',
            color:'#0C5DA5',
            marker: {
                symbol: 'square'
            },

        },
        {
            name: '25th Percentile',
            type: 'line',
            color: 'red',
            marker: {
                symbol: 'square'
            },

        },
        {
            name: '90th percentile',
            type: 'line',
            color: '#3D9200',
            marker: {
                symbol: 'square'
            },

        },{
            name: '10th percentile',
            type: 'line',
            color: '#3D9200',
            marker: {
                symbol: 'square'
            },

        }
        ]

    });```
<pre class="snippet-code-html lang-html prettyprint-override"><code> <script src="https://code.highcharts.com/highcharts.js"></script>
        <script src="https://code.highcharts.com/highcharts-3d.js"></script>
        <script src="https://code.highcharts.com/modules/exporting.js"></script>
        <script src="https://code.highcharts.com/highcharts-more.js"></script>
        <script src="https://code.highcharts.com/modules/exporting.js"></script>

Box Plot Charts -->
  <div id="pdfContentHolder" style="margin:auto; width: 720px; height: 800px;">
       <div id="container" style="min-width: 310px; height: 400px; max-width: 800px; margin: 0 auto" >

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

https://jsfiddle.net/hew8nq5u/

Thanks in advance guys!

答:
Currently it's not possible in Highcharts to have box bottom and top in different colors. Same with top and bottom whiskers. Here is an explanation and enhancement proposition from github issue (https://github.com/highcharts/highcharts/issues/6796):

Currently each box is a single SVG shape and a border is applied by
  stroke parameter which cannot be "separated" for smaller edges. As a
  result, you can apply only single color.

Your goal requires a rebuild core of boxplot, so we cannot threat it
  as a bug, but feature request.

Body:
I would like to have top of the box and bottom of the box in different colors, and also top of the whisker and bottoom of the whisker in different color for each box (region).
But all of the lines in the box are in the same color (red) and top and bottom of the whisker are in the same color (green)

Live demo with steps to reproduce

 Highcharts.chart('container', {

        chart: {
            type: 'boxplot'
        },

        title: {
            text: 'All Patients'
        },

        legend: {
            enabled: true
        },

        xAxis: {
            categories: ['Asia Pacific', 'Europe', 'Latin America', 'North America', 'SWAC'],
            title: {
                text: '      '
            }
        },

        yAxis: {
            title: {
                text: 'Annual Center Volume 2016'
            },
            tickInterval: 5,
            min: 0,
            max: 75
            //plotLines: [{
            //    value: 932,
            //    color: 'red',
            //    width: 1,
            //    label: {
            //        text: 'Theoretical mean: 932',
            //        align: 'center',
            //        style: {
            //            color: 'gray'
            //        }
            //    }
            //}]
        },
        plotOptions: {
            boxplot: {
                fillColor: '#F0F0E0',
                lineWidth: 2,
                upperQuartileColor: 'green',
                lowerQuartileColor: 'green',
                medianColor: '#0C5DA5',
                medianWidth: 3,
                stemColor: '#A63400',
                stemDashStyle: 'solid',
                stemWidth: 1,
                whiskerColor: '#3D9200',
                whiskerLength: '20%',
                whiskerWidth: 3
            }
        },
        series: [{
            name: 'Region Runs',
            showInLegend: false,
            color: 'red',
            data: [
                [2, 4, 18, 43, 53],
                [5, 9, 16.5, 32, 52],
                [1, 3, 6, 11.5, 21],
                [3, 9, 20, 38, 73],
                [1, 2, 8, 16, 20]
            ],
            tooltip: {
                headerFormat: 'Experiment No {point.key}
'
            }
        },
        {
            name: '75th Percentile',
            type: 'line',
            color: 'red',
            marker: {
                symbol: 'square'
            },

        },
        {
            name: 'Median',
            type: 'line',
            color:'#0C5DA5',
            marker: {
                symbol: 'square'
            },

        },
        {
            name: '25th Percentile',
            type: 'line',
            color: 'red',
            marker: {
                symbol: 'square'
            },

        },
        {
            name: '90th percentile',
            type: 'line',
            color: '#3D9200',
            marker: {
                symbol: 'square'
            },

        },{
            name: '10th percentile',
            type: 'line',
            color: '#3D9200',
            marker: {
                symbol: 'square'
            },

        }
        ]

    });

Box Plot Charts -->

https://jsfiddle.net/hew8nq5u/

Thanks in advance guys!


问:
Hide gridlines in chartjs without the drawTicks
I am creating a chart using chart.js. I would like to remove the gridlines, but I want to keep the little pieces(drawTicks: true), marked yellow in the image below.

Is this be possible?

I have tried:

```<code>gridLines: {
   display: false,
   drawTicks: true
}
</code>```

But that is hiding all of the gridlines.

答:
Yes you can,
to hide the gridlines without removing the little ticks you can do this :</p>

```<code> gridLines: {
     drawOnChartArea: false
 }
</code>```

Body:
I am creating a chart using chart.js. I would like to remove the gridlines, but I want to keep the little pieces(drawTicks: true), marked yellow in the image below.

Is this be possible?

I have tried:

gridLines: {
   display: false,
   drawTicks: true
}

But that is hiding all of the gridlines.

Body:
Yes you can,
to hide the gridlines without removing the little ticks you can do this :

 gridLines: {
     drawOnChartArea: false
 }


问:
ForEach() : Why can't use break/continue inside
Since ForEach() method loop through all list members, Why can't I use a break/continue clause while I can use them inside a normal foreach loop

```<code>lstTemp.ForEach(i=>
 {
   if (i == 3)
   break;
   //do sth
 }
);
</code>```

Error:

"No enclosing loop out of which to
break or continue"

答:
rather than using a break, perform a filter first like this (it may not be the exact filter you need, but illustrates the point)</p>

```<code>lstTemp.Where(i => i!= 3).ForEach(i=> // do sth);
</code>```

ContentLicense: CC BY-SA 4.0

Body:
Since ForEach() method loop through all list members, Why can't I use a break/continue clause while I can use them inside a normal foreach loop

lstTemp.ForEach(i=>
 {
   if (i == 3)
   break;
   //do sth
 }
);

Error:

"No enclosing loop out of which to
break or continue"

Body:
rather than using a break, perform a filter first like this (it may not be the exact filter you need, but illustrates the point)

lstTemp.Where(i => i!= 3).ForEach(i=> // do sth);


问:
command 'cmake.build' not found
I am using Visual Studio Code for C++ development with Cmake. Normally, the build command, F7, runs uses cmake to build the project, but now when I run the build task, I get a warning command 'cmake.build' not found and nothing happens after that, so the project never gets built.

I am running on Ubuntu nad have the CMake dependency and Cmake tools, as well as the command line cmake, ccmake, and cmake-gui already installed. I have already uninstalled and reinstalled with an apt-get purge code and I reinstalled my $HOME/.vscode extensions.

答:
Here is the github issue: #163

It appears that there is a bug with CMake Server. A workaround is to go into the Visual Studio Code Settings.json and set cmake.useCMakeServer to false. This worked for me and appears to have worked for others having a similar problem.

Title: command 'cmake.build' not found


问:
Why Visual studio 2017 is publishing entire solution?
Installed VS2017 from scratch and moved existing vb.net, c# webform solutions to the new laptop.
First issue was related to "The target GatherAllFilesToPublish does not exist" error which I fixed by opening vbproj (or csproj on another project) and add this line:

```<code><Target Name="GatherAllFilesToPublish">
</Target>
</code>```

Now I was able to publish with no errors but the output in the destination folder is the entire solution including .aspx.vb or .aspx.cs files, .Global.asax.vb, .aspx.designer.vb files etc.

Checked the project Package/Publish Web settings and Items to deploy is set to "Only files needed to run this application".

Still the publishing copies the entire solution instead only the aspx, dll and only what is needed. Any idea what I am doing wrong ?

答: Edit csprojfile,in that file change vs version of your old project to vs 2015 in property group.save the file and rebuild .it will work properly.</p>

Body:
Installed VS2017 from scratch and moved existing vb.net, c# webform solutions to the new laptop.
First issue was related to "The target GatherAllFilesToPublish does not exist" error which I fixed by opening vbproj (or csproj on another project) and add this line:

<Target Name="GatherAllFilesToPublish">
</Target>

Now I was able to publish with no errors but the output in the destination folder is the entire solution including .aspx.vb or .aspx.cs files, .Global.asax.vb, .aspx.designer.vb files etc.

Checked the project Package/Publish Web settings and Items to deploy is set to "Only files needed to run this application".

Still the publishing copies the entire solution instead only the aspx, dll and only what is needed. Any idea what I am doing wrong ?


问:
std::this_thread::sleep_for() and GCC
When I try to compile this simple program:

```<code>#include<thread>

void f() {
  std::this_thread::sleep_for(std::chrono::seconds(3));
}

int main() {
  std::thread t(f);
  t.join();
}
</code>```

with gcc version 4.4.3 on Ubuntu 10.04 (32 bit):

```<code>$ g++ -std=c++0x -pthread a.cpp -o a
</code>```

I get:

```<code>error: ‘sleep_for’ is not a member of ‘std::this_thread’
</code>```

I looked in header 'thread'.

sleep_for() is protected with _GLIBCXX_USE_NANOSLEEP

```<code>#ifdef _GLIBCXX_USE_NANOSLEEP
...
/// sleep_for
template<typename _Rep, typename _Period>
  inline void
  sleep_for(const chrono::duration<_Rep, _Period>& __rtime)
...
</code>```

Why is _GLIBCXX_USE_NANOSLEEP not defined?

How do I get this example to compile?

Update 17 Sep 2012 (jogojapan): I ran into this same problem today, using GCC 4.7.1. I wonder if there is any news on how to avoid it, other than by defining _GLIBCXX_USE_NANOSLEEP. I tried using -std=gnu11, but to no avail.

There is also an old, unresolved bug report for GCC 4.4: https://bugs.launchpad.net/ubuntu/+source/gcc-4.4/+bug/608145

Update 19 Oct 2012 (jogojapan): The issue has now been explained and resolved by Jonathan Wakely as an anwer to this question: What is _GLIBCXX_USE_NANOSLEEP all about?
This is particularly relevant for anyone who builds GCC himself instead of using a ready-made package.

答:
Confirmed that it doesn't work here as well. (Recent GCC 4.6 snapshot).

You could do the obvious and simply define it before you include any std:: headers. A bit dirty but will work until GCC fixes it (unless this is intended behavior). The #define shouldn't break anything anyways. Either in source or -D_GLIBCXX_USE_NANOSLEEP flag to GCC.

You might want to try using -std=gnu++0x rather than -std=c++0x, since gnu++0x often pulls in stuff like this.

Title: std::this_thread::sleep_for() and GCC

Body:
When I try to compile this simple program:

#include<thread>

void f() {
  std::this_thread::sleep_for(std::chrono::seconds(3));
}

int main() {
  std::thread t(f);
  t.join();
}

with gcc version 4.4.3 on Ubuntu 10.04 (32 bit):

$ g++ -std=c++0x -pthread a.cpp -o a

I get:

error: ‘sleep_for’ is not a member of ‘std::this_thread’

I looked in header 'thread'.

sleep_for() is protected with _GLIBCXX_USE_NANOSLEEP

#ifdef _GLIBCXX_USE_NANOSLEEP
...
/// sleep_for
template<typename _Rep, typename _Period>
  inline void
  sleep_for(const chrono::duration<_Rep, _Period>& __rtime)
...

Why is _GLIBCXX_USE_NANOSLEEP not defined?

How do I get this example to compile?

Update 17 Sep 2012 (jogojapan): I ran into this same problem today, using GCC 4.7.1. I wonder if there is any news on how to avoid it, other than by defining _GLIBCXX_USE_NANOSLEEP. I tried using -std=gnu11, but to no avail.

There is also an old, unresolved bug report for GCC 4.4: https://bugs.launchpad.net/ubuntu/+source/gcc-4.4/+bug/608145

Update 19 Oct 2012 (jogojapan): The issue has now been explained and resolved by Jonathan Wakely as an anwer to this question: What is _GLIBCXX_USE_NANOSLEEP all about?
This is particularly relevant for anyone who builds GCC himself instead of using a ready-made package.


问:
Holding a first value in a column while another column equals a value?
I would like to hold the first value in a column while another column does not equal zero. For Column B, values alternate between -1, 0, 1. For Column C, values equal any integer. The objective is holding the first value of Column C while Column B equals zero. The current DataFrame is as follows:

```<code>   A  B C
1  8  1 9
2  2  1 1
3  3  0 7
4  9  0 8
5  5  0 9
6  6  0 1
7  1  1 9
8  6  1 10
9  3  0 4
10 8  0 8
11 5  0 9
12 6  0 10
</code>```

The resulting DataFrame should be as follows:

```<code>   A  B C
1  8  1 9
2  2  1 1
3  3  0 7
4  9  0 7
5  5  0 7
6  6  0 7
7  1  1 9
8  6  1 10
9  3  0 4
10 8  0 4
11 5  0 4
12 6  0 4
13 3  1 9
</code>```

答:
You need first create NaNs by condition in column C and then add values by ffill:

```<code>mask = (df['B'].shift().fillna(False)).astype(bool) | (df['B'])
df['C'] = df.loc[mask, 'C']
df['C'] = df['C'].ffill().astype(int)
print (df)
    A  B   C
1   8  1   9
2   2  1   1
3   3  0   7
4   9  0   7
5   5  0   7
6   6  0   7
7   1  1   9
8   6  1  10
9   3  0   4
10  8  0   4
11  5  0   4
12  6  0   4
13  3  1   9
</code>```

Or use where and if type of all values is integer, add astype:

```<code>mask = (df['B'].shift().fillna(False)).astype(bool) | (df['B'])
df['C'] = df['C'].where(mask).ffill().astype(int)
print (df)
    A  B   C
1   8  1   9
2   2  1   1
3   3  0   7
4   9  0   7
5   5  0   7
6   6  0   7
7   1  1   9
8   6  1  10
9   3  0   4
10  8  0   4
11  5  0   4
12  6  0   4
13  3  1   9
</code>```

Body:
I would like to hold the first value in a column while another column does not equal zero. For Column B, values alternate between -1, 0, 1. For Column C, values equal any integer. The objective is holding the first value of Column C while Column B equals zero. The current DataFrame is as follows:

   A  B C
1  8  1 9
2  2  1 1
3  3  0 7
4  9  0 8
5  5  0 9
6  6  0 1
7  1  1 9
8  6  1 10
9  3  0 4
10 8  0 8
11 5  0 9
12 6  0 10

The resulting DataFrame should be as follows:

   A  B C
1  8  1 9
2  2  1 1
3  3  0 7
4  9  0 7
5  5  0 7
6  6  0 7
7  1  1 9
8  6  1 10
9  3  0 4
10 8  0 4
11 5  0 4
12 6  0 4
13 3  1 9

Body:
You need first create NaNs by condition in column C and then add values by ffill:

mask = (df['B'].shift().fillna(False)).astype(bool) | (df['B'])
df['C'] = df.loc[mask, 'C']
df['C'] = df['C'].ffill().astype(int)
print (df)
    A  B   C
1   8  1   9
2   2  1   1
3   3  0   7
4   9  0   7
5   5  0   7
6   6  0   7
7   1  1   9
8   6  1  10
9   3  0   4
10  8  0   4
11  5  0   4
12  6  0   4
13  3  1   9

Or use where and if type of all values is integer, add astype:

mask = (df['B'].shift().fillna(False)).astype(bool) | (df['B'])
df['C'] = df['C'].where(mask).ffill().astype(int)
print (df)
    A  B   C
1   8  1   9
2   2  1   1
3   3  0   7
4   9  0   7
5   5  0   7
6   6  0   7
7   1  1   9
8   6  1  10
9   3  0   4
10  8  0   4
11  5  0   4
12  6  0   4
13  3  1   9


问:
How to clean cache and cookies in Selenium using PhantomJS in Python?
I am using Selenium with the PhantomJS Webdriver on Python 2.7 and I don't see any references in the documentation about cleaning the cache. Is there a way to clean the cache and cookies? I have seen functions in PhantomJS that can do it, but how to use them in Selenium ?</p>

答:
Try this:

```<code>driver.get("about:blank")
driver.delete_all_cookies()
driver.execute_script('localStorage.clear();')
</code>```

I put the driver.get("about:blank") in there just in case the current site has changed the Javascript environment in unexpected ways.

You could also just destroy the driver and create a new one, but that might be slightly less efficient (you'd have to measure it on your setup to know for sure).

Body:
Try this:

driver.get("about:blank")
driver.delete_all_cookies()
driver.execute_script('localStorage.clear();')

I put the driver.get("about:blank") in there just in case the current site has changed the Javascript environment in unexpected ways.

You could also just destroy the driver and create a new one, but that might be slightly less efficient (you'd have to measure it on your setup to know for sure).


问:
Why does my array not have the right length after initializing it?
I want to initialize an array of variable length with random zeros and ones. My problem is that the array I created seems to only have a length of 4 elements.
Why is that?</p>

```<code>int main()
{
    int i, j;
    int length = 20;
    int *array = (int *) calloc(length, sizeof(int));
    for (i = 1; i < length; i++) {
        array[i] = 1;
        printf("%d", array[i]);
    }
    printf("\n");
    for (j = 0; j < sizeof(array); j++) {
        printf("%d", array[j]);
    }
    getchar();
}
</code>```

答: You issue is that sizeof(array) returns you the size of int *, which on your systems evaluates to 4. Simply use j < length as stop criterion in the second iteration.

Body:
I want to initialize an array of variable length with random zeros and ones. My problem is that the array I created seems to only have a length of 4 elements.
Why is that?

int main()
{
    int i, j;
    int length = 20;
    int *array = (int *) calloc(length, sizeof(int));
    for (i = 1; i < length; i++) {
        array[i] = 1;
        printf("%d", array[i]);
    }
    printf("\n");
    for (j = 0; j < sizeof(array); j++) {
        printf("%d", array[j]);
    }
    getchar();
}


问:
C++ date parsing with single digits
I am trying to parse a date which contains a single digit for each of the month and the day. The following parses correctly:

```<code>std::istringstream ss("2015/05/01");
std::tm tmb = { 0, 0, 0, 0, 0, 0, 0, 0, 0 };

ss >> std::get_time(&tmb, "%Y/%m/%d");
</code>```

But when I try to parse

```<code>std::istringstream ss("2015/5/1");
</code>```

I get a failed state in the stream and the time has not been read into the struct properly. Is there a clean (and efficient) way I can parse this?

EDIT: I am developing on Ubuntu 12.04 and the compiler g++ 5.4.1.

答:
You don't say which platform you are on.

I would advise against writing your own parser. Take a look at strftime/strptime or Boost.Date_Time.

Title: C++ date parsing with single digits

Body:
I am trying to parse a date which contains a single digit for each of the month and the day. The following parses correctly:

std::istringstream ss("2015/05/01");
std::tm tmb = { 0, 0, 0, 0, 0, 0, 0, 0, 0 };

ss >> std::get_time(&tmb, "%Y/%m/%d");

But when I try to parse

std::istringstream ss("2015/5/1");

I get a failed state in the stream and the time has not been read into the struct properly. Is there a clean (and efficient) way I can parse this?

EDIT: I am developing on Ubuntu 12.04 and the compiler g++ 5.4.1.


问:
Converting an array of hashes to ONE hash in Ruby
I have an array of hashes with arrays that look something like this:

```<code>result = [
  {"id_t"=>["1"], "transcript_t"=>["I am a transcript ONE"]},
  {"id_t"=>["2"], "transcript_t"=>["I am a transcript TWO"]},
  {"id_t"=>["3"], "transcript_t"=>["I am a transcript THREE"]}
]
</code>```

What I would LIKE to do, if possible, is transform it such that it becomes ONE hash where each key=>value pair is taken from the values of each hash. I don't think I'm explaining that well, so here's what I mean:

```<code>end_result = {
  "1"=>"I am a transcript ONE",
  "2"=>"I am a transcript TWO",
  "3"=>"I am a transcript THREE"
}
</code>```

I've been scouring Stack Overflow and Google for various methods, but I've gotten myself confused in the process. Any ideas on how to achieve this?

答:
Try this</p>

```<code>result.inject({}){|acc, hash| acc[hash.values[0][0]] = hash.values[1][0]; acc }

=> { "1"=>"I am a transcript ONE",
     "2"=>"I am a transcript TWO",
     "3"=>"I am a transcript THREE" }
</code>```

Body:
I have an array of hashes with arrays that look something like this:

result = [
  {"id_t"=>["1"], "transcript_t"=>["I am a transcript ONE"]},
  {"id_t"=>["2"], "transcript_t"=>["I am a transcript TWO"]},
  {"id_t"=>["3"], "transcript_t"=>["I am a transcript THREE"]}
]

What I would LIKE to do, if possible, is transform it such that it becomes ONE hash where each key=>value pair is taken from the values of each hash. I don't think I'm explaining that well, so here's what I mean:

end_result = {
  "1"=>"I am a transcript ONE",
  "2"=>"I am a transcript TWO",
  "3"=>"I am a transcript THREE"
}

I've been scouring Stack Overflow and Google for various methods, but I've gotten myself confused in the process. Any ideas on how to achieve this?

Body:
Try this

result.inject({}){|acc, hash| acc[hash.values[0][0]] = hash.values[1][0]; acc }

=> { "1"=>"I am a transcript ONE",
     "2"=>"I am a transcript TWO",
     "3"=>"I am a transcript THREE" }


问:
How to display number after clicking button multiple times in Android?
So I have this little code where I'm trying to display a number after clicking on on particular buttons for specified times. I have done this through if conditions but I'm pretty sure that this isn't the most efficient way of doing it. In my code All I've done is display a number each and everytime a button is clicked. What I want for example is to display a the number 1 after pressing the button 33 times and display the number 2 when another 33 clicks are registered and so on.

```<code>package engineers.android.com.azkar;

import android.app.Activity;
import android.app.NotificationManager;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

public class Sebh extends Activity {
TextView textView;
TextView textView_sum;
TextView textView1;
TextView textView_sum1;
TextView textView2;
TextView textView_sum2;
Context context = this;
int coun1=0;
int coun2=0;
int coun3=0;
int sum1=0;
int sum2=0;
int sum3=0;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.sebhah);

    Button bhome = (Button) findViewById(R.id.bh);
    bhome.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            finish();
        }
    });

    textView = (TextView)findViewById(R.id.c1);
    textView_sum = (TextView)findViewById(R.id.s1);
    textView1 = (TextView) findViewById(R.id.c2);
    textView_sum1 = (TextView) findViewById(R.id.s2);
    textView2 = (TextView) findViewById(R.id.c3);
    textView_sum2 = (TextView) findViewById(R.id.s3);

}

public void s5(View view) {
    coun1++;
    textView.setText(String.valueOf(coun1));
    if (coun1 == 33 ) {
        sum1=1;
        textView_sum.setText(String.valueOf(sum1));
    }else if (coun1 == 66 ) {
        sum1=2;
        textView_sum.setText(String.valueOf(sum1));
    }else if (coun1 == 99 ) {
        sum1=3;
        textView_sum.setText(String.valueOf(sum1));
    }else if (coun1 == 132 ) {
        sum1=4;
        textView_sum.setText(String.valueOf(sum1));
    }else if (coun1 == 165 ) {
        sum1=5;
        textView_sum.setText(String.valueOf(sum1));
    }else if (coun1 == 198 ) {
        sum1=6;
        textView_sum.setText(String.valueOf(sum1));
    }else if (coun1 == 231 ) {
        sum1=7;
        textView_sum.setText(String.valueOf(sum1));
    }else if (coun1 == 264 ) {
        sum1=8;
        textView_sum.setText(String.valueOf(sum1));
    }else if (coun1 == 297 ) {
        sum1=9;
        textView_sum.setText(String.valueOf(sum1));
    }else if (coun1 == 330 ) {
        sum1=10;
        textView_sum.setText(String.valueOf(sum1));
    }
}

public void sb(View view) {
    coun2++;
    textView1.setText(String.valueOf(coun2));
    if (coun2 == 33 ) {
        sum2=1;
        textView_sum1.setText(String.valueOf(sum2));
    }else if (coun2 == 66 ) {
        sum2=2;
        textView_sum1.setText(String.valueOf(sum2));
    }else if (coun2 == 99 ) {
        sum2=3;
        textView_sum1.setText(String.valueOf(sum2));
    }else if (coun2 == 132 ) {
        sum2=4;
        textView_sum1.setText(String.valueOf(sum2));
    }else if (coun2 == 165 ) {
        sum2=5;
        textView_sum1.setText(String.valueOf(sum2));
    }else if (coun2 == 198 ) {
        sum2=6;
        textView_sum1.setText(String.valueOf(sum2));
    }else if (coun2 == 231 ) {
        sum2=7;
        textView_sum1.setText(String.valueOf(sum2));
    }else if (coun2 == 264 ) {
        sum2=8;
        textView_sum1.setText(String.valueOf(sum2));
    }else if (coun2 == 297 ) {
        sum2=9;
        textView_sum1.setText(String.valueOf(sum2));
    }else if (coun2 == 330 ) {
        sum2=10;
        textView_sum1.setText(String.valueOf(sum2));
    }
}

public void hm (View view) {
    coun3++;
    textView2.setText(String.valueOf(coun3));
    if (coun3 == 33 ) {
        sum3=1;
        textView_sum2.setText(String.valueOf(sum3));
    }else if (coun3 == 66 ) {
        sum3=2;
        textView_sum2.setText(String.valueOf(sum3));
    }else if (coun3 == 99 ) {
        sum3=3;
        textView_sum2.setText(String.valueOf(sum3));
    }else if (coun3 == 132 ) {
        sum3=4;
        textView_sum2.setText(String.valueOf(sum3));
    }else if (coun3 == 165 ) {
        sum3=5;
        textView_sum2.setText(String.valueOf(sum3));
    }else if (coun3 == 198 ) {
        sum3=6;
        textView_sum2.setText(String.valueOf(sum3));
    }else if (coun3 == 231 ) {
        sum3=7;
        textView_sum2.setText(String.valueOf(sum3));
    }else if (coun3 == 264 ) {
        sum3=8;
        textView_sum2.setText(String.valueOf(sum3));
    }else if (coun3 == 297 ) {
        sum3=9;
        textView_sum2.setText(String.valueOf(sum3));
    }else if (coun3 == 330 ) {
        sum3=10;
        textView_sum2.setText(String.valueOf(sum3));
    }
}
public void stop(View view) {
    coun1=0;
    coun2=0;
    coun3=0;
    textView.setText(String.valueOf(coun1));
    textView1.setText(String.valueOf(coun2));
    textView2.setText(String.valueOf(coun3));
}

public void stop_sum(View view) {
    sum1=0;
    sum2=0;
    sum3=0;
    textView_sum.setText(String.valueOf(sum1));
    textView_sum1.setText(String.valueOf(sum2));
    textView_sum2.setText(String.valueOf(sum3));
}
</code>```

}

答:
If you show me the code where you optain reference to the buttons I can come up with a better solution than this one</p>

```<code>public void s5(View view) {
    coun1++;
    coun1 %= 33;
    if (coun1 == 0) {
        sum1++;
        textView_sum.setText(String.valueOf(sum1));
    }
}

public void sb(View view) {
    coun2++;
    coun2 %= 33;
    if (coun2 == 0) {
        sum2++;
        textView1.setText(String.valueOf(coun2));
    }
}

public void hm (View view) {
    coun3++;
    coun3 %= 33;
    if (coun3 == 0) {
        sum3++;
        textView2.setText(String.valueOf(sum3));
    }
}
</code>```

Body:
So I have this little code where I'm trying to display a number after clicking on on particular buttons for specified times. I have done this through if conditions but I'm pretty sure that this isn't the most efficient way of doing it. In my code All I've done is display a number each and everytime a button is clicked. What I want for example is to display a the number 1 after pressing the button 33 times and display the number 2 when another 33 clicks are registered and so on.

package engineers.android.com.azkar;

import android.app.Activity;
import android.app.NotificationManager;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

public class Sebh extends Activity {
TextView textView;
TextView textView_sum;
TextView textView1;
TextView textView_sum1;
TextView textView2;
TextView textView_sum2;
Context context = this;
int coun1=0;
int coun2=0;
int coun3=0;
int sum1=0;
int sum2=0;
int sum3=0;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.sebhah);

    Button bhome = (Button) findViewById(R.id.bh);
    bhome.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            finish();
        }
    });

    textView = (TextView)findViewById(R.id.c1);
    textView_sum = (TextView)findViewById(R.id.s1);
    textView1 = (TextView) findViewById(R.id.c2);
    textView_sum1 = (TextView) findViewById(R.id.s2);
    textView2 = (TextView) findViewById(R.id.c3);
    textView_sum2 = (TextView) findViewById(R.id.s3);

}

public void s5(View view) {
    coun1++;
    textView.setText(String.valueOf(coun1));
    if (coun1 == 33 ) {
        sum1=1;
        textView_sum.setText(String.valueOf(sum1));
    }else if (coun1 == 66 ) {
        sum1=2;
        textView_sum.setText(String.valueOf(sum1));
    }else if (coun1 == 99 ) {
        sum1=3;
        textView_sum.setText(String.valueOf(sum1));
    }else if (coun1 == 132 ) {
        sum1=4;
        textView_sum.setText(String.valueOf(sum1));
    }else if (coun1 == 165 ) {
        sum1=5;
        textView_sum.setText(String.valueOf(sum1));
    }else if (coun1 == 198 ) {
        sum1=6;
        textView_sum.setText(String.valueOf(sum1));
    }else if (coun1 == 231 ) {
        sum1=7;
        textView_sum.setText(String.valueOf(sum1));
    }else if (coun1 == 264 ) {
        sum1=8;
        textView_sum.setText(String.valueOf(sum1));
    }else if (coun1 == 297 ) {
        sum1=9;
        textView_sum.setText(String.valueOf(sum1));
    }else if (coun1 == 330 ) {
        sum1=10;
        textView_sum.setText(String.valueOf(sum1));
    }
}

public void sb(View view) {
    coun2++;
    textView1.setText(String.valueOf(coun2));
    if (coun2 == 33 ) {
        sum2=1;
        textView_sum1.setText(String.valueOf(sum2));
    }else if (coun2 == 66 ) {
        sum2=2;
        textView_sum1.setText(String.valueOf(sum2));
    }else if (coun2 == 99 ) {
        sum2=3;
        textView_sum1.setText(String.valueOf(sum2));
    }else if (coun2 == 132 ) {
        sum2=4;
        textView_sum1.setText(String.valueOf(sum2));
    }else if (coun2 == 165 ) {
        sum2=5;
        textView_sum1.setText(String.valueOf(sum2));
    }else if (coun2 == 198 ) {
        sum2=6;
        textView_sum1.setText(String.valueOf(sum2));
    }else if (coun2 == 231 ) {
        sum2=7;
        textView_sum1.setText(String.valueOf(sum2));
    }else if (coun2 == 264 ) {
        sum2=8;
        textView_sum1.setText(String.valueOf(sum2));
    }else if (coun2 == 297 ) {
        sum2=9;
        textView_sum1.setText(String.valueOf(sum2));
    }else if (coun2 == 330 ) {
        sum2=10;
        textView_sum1.setText(String.valueOf(sum2));
    }
}

public void hm (View view) {
    coun3++;
    textView2.setText(String.valueOf(coun3));
    if (coun3 == 33 ) {
        sum3=1;
        textView_sum2.setText(String.valueOf(sum3));
    }else if (coun3 == 66 ) {
        sum3=2;
        textView_sum2.setText(String.valueOf(sum3));
    }else if (coun3 == 99 ) {
        sum3=3;
        textView_sum2.setText(String.valueOf(sum3));
    }else if (coun3 == 132 ) {
        sum3=4;
        textView_sum2.setText(String.valueOf(sum3));
    }else if (coun3 == 165 ) {
        sum3=5;
        textView_sum2.setText(String.valueOf(sum3));
    }else if (coun3 == 198 ) {
        sum3=6;
        textView_sum2.setText(String.valueOf(sum3));
    }else if (coun3 == 231 ) {
        sum3=7;
        textView_sum2.setText(String.valueOf(sum3));
    }else if (coun3 == 264 ) {
        sum3=8;
        textView_sum2.setText(String.valueOf(sum3));
    }else if (coun3 == 297 ) {
        sum3=9;
        textView_sum2.setText(String.valueOf(sum3));
    }else if (coun3 == 330 ) {
        sum3=10;
        textView_sum2.setText(String.valueOf(sum3));
    }
}
public void stop(View view) {
    coun1=0;
    coun2=0;
    coun3=0;
    textView.setText(String.valueOf(coun1));
    textView1.setText(String.valueOf(coun2));
    textView2.setText(String.valueOf(coun3));
}

public void stop_sum(View view) {
    sum1=0;
    sum2=0;
    sum3=0;
    textView_sum.setText(String.valueOf(sum1));
    textView_sum1.setText(String.valueOf(sum2));
    textView_sum2.setText(String.valueOf(sum3));
}

}

Body:
If you show me the code where you optain reference to the buttons I can come up with a better solution than this one

public void s5(View view) {
    coun1++;
    coun1 %= 33;
    if (coun1 == 0) {
        sum1++;
        textView_sum.setText(String.valueOf(sum1));
    }
}

public void sb(View view) {
    coun2++;
    coun2 %= 33;
    if (coun2 == 0) {
        sum2++;
        textView1.setText(String.valueOf(coun2));
    }
}

public void hm (View view) {
    coun3++;
    coun3 %= 33;
    if (coun3 == 0) {
        sum3++;
        textView2.setText(String.valueOf(sum3));
    }
}


问:
unable to get JSON data from Restlet Client using Node Js
(I am totally new to Restlet client and Server scripting)

I am trying to get JSON Data from response body of the Restlet client using below code but I could not get that

```<code>var http = require('http');
var options = {
  host: 'staging.api.pearson.com',
  port: 80,
  path: '/sc-api/apis/content/urn:pearson:manifestation:db7eac5b-8f65-49dc-97bc-d0f5e824f135'
};

http.get(options, function(res) {
  console.log("Got response: " + res.statusCode);

  res.on("data", function(chunk) {
    console.log("BODY: " + chunk);
  });
}).on('error', function(e) {
  console.log("Got error: " + e.message);
});
</code>```

Getting the below output:

But when using the Restlet client GUI, can able download the response BODY Json

Adding Environments details:

Browser Snapshot:

Kindly anybody suggest any way to do

(I am totally new to Restlet client and Server scripting)

Thanks

答:
As said in the first comment, your URL is only accessible via https

I myself use the request.js package

Example:

```<code>var request = require('request');
var url = 'https://staging.api.pearson.com/sc-api/apis/content/urn:pearson:manifestation:db7eac5b-8f65-49dc-97bc-d0f5e824f135';

request.get(url,{},function(err,res,body){
  if(err)
    console.log("Got error: " + e.message);
  else {
    console.log("Status: ", res.statusCode);
    console.log("body: ", body);
  }
});
</code>```

Body:
(I am totally new to Restlet client and Server scripting)

I am trying to get JSON Data from response body of the Restlet client using below code but I could not get that

var http = require('http');
var options = {
  host: 'staging.api.pearson.com',
  port: 80,
  path: '/sc-api/apis/content/urn:pearson:manifestation:db7eac5b-8f65-49dc-97bc-d0f5e824f135'
};

http.get(options, function(res) {
  console.log("Got response: " + res.statusCode);

  res.on("data", function(chunk) {
    console.log("BODY: " + chunk);
  });
}).on('error', function(e) {
  console.log("Got error: " + e.message);
});

Getting the below output:

But when using the Restlet client GUI, can able download the response BODY Json

Adding Environments details:

Browser Snapshot:

Kindly anybody suggest any way to do

(I am totally new to Restlet client and Server scripting)

Thanks

Body:
As said in the first comment, your URL is only accessible via https

I myself use the request.js package

Example:

var request = require('request');
var url = 'https://staging.api.pearson.com/sc-api/apis/content/urn:pearson:manifestation:db7eac5b-8f65-49dc-97bc-d0f5e824f135';

request.get(url,{},function(err,res,body){
  if(err)
    console.log("Got error: " + e.message);
  else {
    console.log("Status: ", res.statusCode);
    console.log("body: ", body);
  }
});


问:
Concurrent writes for event sourcing on top of Kafka
I've been considering to use Apache Kafka as the event store in an event sourcing configuration. The published events will be associated to specific resources, delivered to a topic associated to the resource type and sharded into partitions by resource id. So for instance a creation of a resource of type Folder and id 1 would produce a FolderCreate event that would be delivered to the "folders" topic in a partition given by sharding the id 1 across the total number of partitions in the topic. Even though I don't know how to handle concurrent events that make the log inconsistent.

The simplest scenario would be having two concurrent actions that can invalidate each other such as one to update a folder and one to destroy that same folder. In that case the partition for that topic could end up containing the invalid sequence [FolderDestroy, FolderUpdate]. That situation is often fixed by versioning the events as explained here but Kafka does not support such feature.

What can be done to ensure the consistency of the Kafka log itself in those cases?

答:
I think it's probably possible to use Kafka for event sourcing of aggregates (in the DDD sense), or 'resources'. Some notes:

Serialise writes per partition, using a single process per partition (or partitions) to manage this. Ensure you send messages serially down the same Kafka connection, and use ack=all before reporting success to the command sender, if you can't afford rollbacks. Ensure the producer process keeps track of the current successful event offset/version for each resource, so it can do the optimistic check itself before sending the message.

Since a write failure might be returned even if the write actually succeeded, you need to retry writes and deal with deduplication by including an ID in each event, say, or reinitialize the producer by re-reading (recent messages in) the stream to see whether the write actually worked or not.

Writing multiple events atomically - just publish a composite event containing a list of events.

Lookup by resource id. This can be achieved by reading all events from a partition at startup (or all events from a particular cross-resource snapshot), and storing the current state either in RAM or cached in a DB.

https://issues.apache.org/jira/browse/KAFKA-2260 would solve 1 in a simpler way, but seems to be stalled.

Kafka Streams appears to provide a lot of this for you. For example, 4 is a KTable, which you can have your event producer use one to work out whether an event is valid for the current resource state before sending it.


问:
How can I detect if a grouped result of the mySQL database has any related value?
```<code>animal    food
cat
cat       mouse
cat
dog
dog
bird      carrot
bird      herb
bird
</code>```

I have some animals in my mysql database. My problem is that I need to know, if any animal of a animal-group got food.

```<code> $pdo = $db->query('SELECT * FROM list GROUP BY animal');
 while ($row = $pdo->fetch(PDO::FETCH_ASSOC)) {
    if($row["food"]){
       echo "Some ".$row["animal"]." got food.<br>";
    } else {
       echo "No " .$row["animal"]. " got food.<br>";
  }
}
</code>```

My result is:

```<code>No cat got food.
No dog got food.
No bird got food.
</code>```

But I expect:

```<code>Some cat got food.
No dog got food.
Some bird got food.
</code>```

答:
You could count all the records for the animal and compare that to a count of records where food='yes' and make you determination based on that:

```<code>SELECT
    animal,
    sum(CASE WHEN food IS NOT NULL THEN 1 ELSE 0 END)/COUNT(*) as percentage_fed
FROM list
GROUP BY animal
</code>```

The just test that: If percentage_fed < 1 then "Some" else if percentage_fed = 0 then "none" else "all"

Body:
animal    food
cat
cat       mouse
cat
dog
dog
bird      carrot
bird      herb
bird

I have some animals in my mysql database. My problem is that I need to know, if any animal of a animal-group got food.

 $pdo = $db->query('SELECT * FROM list GROUP BY animal');
 while ($row = $pdo->fetch(PDO::FETCH_ASSOC)) {
    if($row["food"]){
       echo "Some ".$row["animal"]." got food.
";
    } else {
       echo "No " .$row["animal"]. " got food.
";
  }
}

My result is:

No cat got food.
No dog got food.
No bird got food.

But I expect:

Some cat got food.
No dog got food.
Some bird got food.

Body:
You could count all the records for the animal and compare that to a count of records where food='yes' and make you determination based on that:

SELECT
    animal,
    sum(CASE WHEN food IS NOT NULL THEN 1 ELSE 0 END)/COUNT(*) as percentage_fed
FROM list
GROUP BY animal

The just test that: If percentage_fed < 1 then "Some" else if percentage_fed = 0 then "none" else "all"


问:
Not getting on Ajax Success from controller JsonResult method
```<code>function GetSort() {
    var url = '@Url.Action("GetSort", "CatMaster")';
    $.ajax({
        type: "POST",
        url: url,
        dataType: "json",
        data: null,
        success: function (data) {
            restrctTrans = false;
            $("#Order").data("kendoNumericTextBox").value(data.NxtSort);
        },
        error: function (data) {
            alert('error');
        }
    });
}
</code>```

This calls an controller method which returns JSON value:

```<code>public JsonResult GetSort()
{
    var response = _catMaster.GetNextSort();
    return Json(response.NxtSort, JsonRequestBehavior.AllowGet);
}
</code>```

Problem is the ajax success and error function is not called.
But controller returns a value.
Value of response.NxtSort is 1

答:
try this

```<code>[HttPost]
public JsonResult GetSort()
{
    var response = _catMaster.GetNextSort();
    return Json(response.NxtSort, JsonRequestBehavior.AllowGet);
}

 $("#Order").data("kendoNumericTextBox").value(data);
</code>```

Replace this with above

```<code> $("#Order").data("kendoNumericTextBox").value(data.NxtSort);
</code>```

Body:
function GetSort() {
    var url = '@Url.Action("GetSort", "CatMaster")';
    $.ajax({
        type: "POST",
        url: url,
        dataType: "json",
        data: null,
        success: function (data) {
            restrctTrans = false;
            $("#Order").data("kendoNumericTextBox").value(data.NxtSort);
        },
        error: function (data) {
            alert('error');
        }
    });
}

This calls an controller method which returns JSON value:

public JsonResult GetSort()
{
    var response = _catMaster.GetNextSort();
    return Json(response.NxtSort, JsonRequestBehavior.AllowGet);
}

Problem is the ajax success and error function is not called.
But controller returns a value.
Value of response.NxtSort is 1

Body:
try this

[HttPost]
public JsonResult GetSort()
{
    var response = _catMaster.GetNextSort();
    return Json(response.NxtSort, JsonRequestBehavior.AllowGet);
}

 $("#Order").data("kendoNumericTextBox").value(data);

Replace this with above

 $("#Order").data("kendoNumericTextBox").value(data.NxtSort);


问:
Web.config customisations lost using a Wix installer to perform an upgrade
I've created a WiX installer to deploy a set of websites on at a customer site and use xmlfile to plug correct values for hostnames and connectionStrings into our web.config files.  Since these values come from the installer UI I've run into a problem when doing an Upgrade install using:

```<code>msiexec /i Websites.msi  /l*vx Website.log REINSTALL=ALL REINSTALLMODE=vomus
</code>```

While the update performs correctly the xmlfile actions plug empty values in since the UI isn't run.

Is there a way of getting these values into the installer without parsing the XML or prompting the installation engineer for the values again?

Cheers,
Damien

答:
You need the Remember Property pattern only adapted for XML instead of Regisry.  WiX doesn't have an XML peek pattern yet so you'll have to write a custom action.

Another gotcha to watch out for is since you are modifying the XML future upgrades won't install newer versions of the XML by default since it now has user data.

Body:
I've created a WiX installer to deploy a set of websites on at a customer site and use xmlfile to plug correct values for hostnames and connectionStrings into our web.config files.  Since these values come from the installer UI I've run into a problem when doing an Upgrade install using:

msiexec /i Websites.msi  /l*vx Website.log REINSTALL=ALL REINSTALLMODE=vomus

While the update performs correctly the xmlfile actions plug empty values in since the UI isn't run.

Is there a way of getting these values into the installer without parsing the XML or prompting the installation engineer for the values again?

Cheers,
Damien


问:
Checking architecture with Bazel-Skylark
I'm trying to build Tensorflow in ppc64le from source on a fairly recent commit but I'm stumbling on some issues (https://github.com/tensorflow/tensorflow/issues/10306 and https://github.com/bazelbuild/rules_closure/issues/207) that come from bazebuild/rules_closure.

Mostly I need to check whether the target machine is ppc64le (is there any native Bazel way to run something like uname -m?). Then we shouldn't pass '-client' to the JVM calls - unfortunately, as of today there's no support to the C1 (client) compiler in openjdk8 for ppc64le.

Also there are some pre-built x64 binaries (nodejs and protoc) that are downloaded when building rules_closure - which predates portability. I want to know if there's a way to circumvent this issue such as adding links to a repository containing ppcle64 binaries or falling back to the system's binaries.

(I also asked this in the bazel-discuss mailing list)

答:
Why is the -client flag needed at all? Could it be removed for all architectures? Bazel's built-in way to adjust JDK configuration is the java_toolchain() rule (you can see the default java_toolchain Bazel uses in the source repository). If the flag really is needed on some platforms but not others, then a java_toolchain should be added the provides it, and platforms that do not support that flag can use a customized toolchain without the flag.

As far as binaries, the only choice available now to to use the select() rule, checking on the host_cpu setting, to choose a binary that will work on the local platform.

I am actively working on a new feature called Platforms for Bazel (the design doc is publically available). This will allow projects such as TensorFlow or rules_closure to define the platforms they support, and provide different toolchains and configurations, eventually including things like protoc binaries and JDK flags. Unfortunately, while development is going well, updating the native Java rules will take some time. You can track the progress on Github at issue #2219.


问:
How to bind frequent changing image data in Angular / Ionic?
I have a frequent change img src data, I bind it like this.

```<code><img [src]="previewImage" alt="Preview Image" />
</code>```

The previewImage keeps changing in component in a loop like,

```<code>for (let i=0;i<Anumber;i++){
  this.previewImage = "data:image/jpeg;base64,"+ this.hexToBase64(imageBytes) ;
}
</code>```

Say the image data could change 10 times per second.

Now here comes the issue. According to my experience with Angular 4's data binding, as long as the data changed, it should reflect in the view. But for me it didn't work as expected, it loads the first image correctly, then it updates around each 20 seconds, it should be 10 frames per seconds, not 20 seconds a frame !

Either such process is extreme slow, like 20 seconds an update, or there is some problem I didn't know about image binding. Maybe it doesn't work like this for image data. BTW, each image could contain around 100k data.

So how to bind a frequent change image data in Angular?

Possible direction:

Using canvas instead of image, drawing the image directly on html. Will it be faster?

Maybe it's the angular change detection issue, when image data changes, angular didn't react immediately.

Maybe it's the image loading scheme, since my image data is base64 string, browser may take more time to load the image, how to avoid the image loading time?

答:
I think I got a temp solution in my case.

Previously I got 20 seconds delay before loading one image, this was due to mainly 2 reasons.

First, it is the bad use of interval observable to process the image data, since it doesn't care if in one cycle, the data processing is completed or not. I changed it to repeatWhen to solve the problem.

Second, both  original JS and RxJS only use one thread, when image loading and image data processing (lots of loops) could be very slow, it doesn't catch up when the image data keeps coming in, causing delays when the tasks happen asynchronously. My solution is to move all the data processing into a separated web worker, to use another thread, in my case, probably the another core of the cell phone.

Please check my other questions on this, to figure out the whole thing I met. Hope it helps.

How to release memory of the responseText in an endless streaming request?

Endless HTTP Stream Observable not emitting anything but data transferred

How to display Motion JPEG binary data stream with Angular/Ionic/JS?

Body:
I have a frequent change img src data, I bind it like this.

The previewImage keeps changing in component in a loop like,

for (let i=0;i<Anumber;i++){
  this.previewImage = "data:image/jpeg;base64,"+ this.hexToBase64(imageBytes) ;
}

Say the image data could change 10 times per second.

Now here comes the issue. According to my experience with Angular 4's data binding, as long as the data changed, it should reflect in the view. But for me it didn't work as expected, it loads the first image correctly, then it updates around each 20 seconds, it should be 10 frames per seconds, not 20 seconds a frame !

Either such process is extreme slow, like 20 seconds an update, or there is some problem I didn't know about image binding. Maybe it doesn't work like this for image data. BTW, each image could contain around 100k data.

So how to bind a frequent change image data in Angular?

Possible direction:

Using canvas instead of image, drawing the image directly on html. Will it be faster?

Maybe it's the angular change detection issue, when image data changes, angular didn't react immediately.

Maybe it's the image loading scheme, since my image data is base64 string, browser may take more time to load the image, how to avoid the image loading time?


问:
What's really happening inside getchar() and printf()? Explain whole process
I was learning from geeksforgeeks and when i saw this, a thought came in my mind that as getchar() and other similar functions returns an int(whether due to failure of program or EOF) then why format specifier used is %c, why not %d(or %i).

```<code>// Example for getchar() in C
#include <stdio.h>
int main()
{
   printf("%c", getchar());
   return 0;
}
</code>```

I know that the character we input in is a character and it is taken by the function getchar() and we are displaying it using %c.

But my problem is what's actually happening inside getchar() and printf() during the whole process, where getchar() is returning that integer, where it is getting stored and how the character we inputted is getting displayed by printf() i.e.what's happening inside printf()?

I did some research on printf() implementation and get to know that printf is part of the C standard library (a.k.a. the libc) and is a variadic function(printf) but i didn't came to know that what is really happening inside this function and how it knows by format specifier that it has to print character or int?

Please help me learning the whole detailed process which is going on.

答:
The man page for getchar says the following:

fgetc() reads the next character from stream and returns it as an
  unsigned char cast to an int, or EOF on end of file or error.

getc() is equivalent to fgetc() except that it may be implemented as a
  macro which evaluates stream more than once.

getchar() is equivalent to getc(stdin).

So let's say you enter the character A.  Assuming your system uses ASCII representation of characters, this character has an ASCII value of 65.  So in this case getchar returns 65 as an int.

This int value of 65 returned by getchar is then passed to printf as the second argument.  The printf function first looks at the format string and sees the %c format specifier.  The man page for printf says the following regarding %c:

If no l modifier is present, the int argument is converted to an
                unsigned char, and the resulting character is written.

So printf reads the next argument as an int.  Since we passed in a int with value 65, that's what it reads.  That value is then cast to an unsigned char.  Since it is still in the rage of that type, the value is still 65.  printf then prints the character for that value.  And since 65 is the ASCII value for the character A, the character A is what appears.

Body:
I was learning from geeksforgeeks and when i saw this, a thought came in my mind that as getchar() and other similar functions returns an int(whether due to failure of program or EOF) then why format specifier used is %c, why not %d(or %i).

// Example for getchar() in C
#include <stdio.h>
int main()
{
   printf("%c", getchar());
   return 0;
}

I know that the character we input in is a character and it is taken by the function getchar() and we are displaying it using %c.

But my problem is what's actually happening inside getchar() and printf() during the whole process, where getchar() is returning that integer, where it is getting stored and how the character we inputted is getting displayed by printf() i.e.what's happening inside printf()?

I did some research on printf() implementation and get to know that printf is part of the C standard library (a.k.a. the libc) and is a variadic function(printf) but i didn't came to know that what is really happening inside this function and how it knows by format specifier that it has to print character or int?

Please help me learning the whole detailed process which is going on.


问:
JVM tuning for few and long GC runs
My server application generates many die-young objects, so I assume the eden and survivor spaces are filled up pretty fast, which causes frequent GC runs.

My goal is to have few/long runs, say once a day, even if they require a couple seconds.

How would you tune the JVM for this target?

Which GC should I use? (up to G1).

Available heap space is around 4Gb (-Xmx4G)

答:
In your case it is triggering for frequent minor gc's. You should use "-XX:NewRatio=ratio"

NewRatio this will decide the ratio between the old and young generatione.

For Example -XX:NewRatio=3 means that the ratio between the old and young generation is 1:3, the combined size of eden and the survivor spaces will be fourth of the heap.

Further you can finetune the Eden and Survivor spaces by using NewSize and MaxNewSize these parameters control the new generation’s minimum and maximum size.

By default NewRation=2 that means ratio between the old and young generation is 1:2.

You can read more details here

Title: JVM tuning for few and long GC runs


问:
Handle ordering of different records in different tables using Hibernate
Lets say that I have a database with the following tables:

```<code>CREATE TABLE user (
   user_id int NOT NULL AUTO_INCREMENT,
   ...
   PRIMARY KEY (user_id)
);
CREATE TABLE action_x (
   action_x_id int NOT NULL AUTO_INCREMENT,
   ...
   not_the_same_columns_as_for_action_y,
   user_id int,
   PRIMARY KEY (action_x_id)
);
CREATE TABLE action_y (
   action_y_id int NOT NULL AUTO_INCREMENT,
   ...
   not_the_same_columns_as_for_action_x,
   user_id int,
   PRIMARY KEY (action_y_id)
);
</code>```

The relationship is, user <=[1:M]=> action_x and user <=[1:M]=> action_y.

The 'user' table contains data of the user(s), such as login and password for example. The 'action_one' and 'action_two' tables contains data for two different actions. The actions is so unlike each other so they has to be separated into two tables.

To summarize, 1 user can have 0 or
MORE action_x records and 0 or MORE
action_y records.

My problem is that I would like to implement (by storing appropriate data in the database) a way to tell the user which action(s) she or he shall perform in a specific order.

For example, user_id=1 shall perform
action_x_id=2, after that,
action_y_id=1, then action_x_id=10,
and so on.

I'm using MySQL as database source, with Hibernate 3.6.x and Java.

Is there any standard way to handle problems like this? How would you solve the problem?

Thank you for you help and have a nice day! =)

答:
I would introduce one more table. Let's name it GeneralAction and set the user FKs to the table. So the filed should be

```<code>general_action_id
user_id
action_x_id
action_y_id
</code>```

For each record in the table action_x_id or action_y_id is null

Body:
Lets say that I have a database with the following tables:

CREATE TABLE user (
   user_id int NOT NULL AUTO_INCREMENT,
   ...
   PRIMARY KEY (user_id)
);
CREATE TABLE action_x (
   action_x_id int NOT NULL AUTO_INCREMENT,
   ...
   not_the_same_columns_as_for_action_y,
   user_id int,
   PRIMARY KEY (action_x_id)
);
CREATE TABLE action_y (
   action_y_id int NOT NULL AUTO_INCREMENT,
   ...
   not_the_same_columns_as_for_action_x,
   user_id int,
   PRIMARY KEY (action_y_id)
);

The relationship is, user <=[1:M]=> action_x and user <=[1:M]=> action_y.

The 'user' table contains data of the user(s), such as login and password for example. The 'action_one' and 'action_two' tables contains data for two different actions. The actions is so unlike each other so they has to be separated into two tables.

To summarize, 1 user can have 0 or
MORE action_x records and 0 or MORE
action_y records.

My problem is that I would like to implement (by storing appropriate data in the database) a way to tell the user which action(s) she or he shall perform in a specific order.

For example, user_id=1 shall perform
action_x_id=2, after that,
action_y_id=1, then action_x_id=10,
and so on.

I'm using MySQL as database source, with Hibernate 3.6.x and Java.

Is there any standard way to handle problems like this? How would you solve the problem?

Thank you for you help and have a nice day! =)

Body:
I would introduce one more table. Let's name it GeneralAction and set the user FKs to the table. So the filed should be

general_action_id
user_id
action_x_id
action_y_id

For each record in the table action_x_id or action_y_id is null


问:
Accessing Static variable from one class to another but getting incorrect value
This is my first question on stackoverflow,

I want to access static int variable of one class in another class but when i access this variable in another class it always gives me "zero".

This is First class:

```<code>package kk;

public class ag {
    public static int n=0;

    public static int as()
    {
        return n;
    }
    public static void main(String[] args) {
        // TODO Auto-generated method stub

        n=3;
        n=n*5;
        System.out.println(n);
    }

}
</code>```

Here the output is 15 i.e. n=15 here.

Second class:

```<code>package kk;

public class ah extends ag {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        //ag aa =new ag();
int k =ag.as();
System.out.println(k);
    }

}
</code>```

In this am trying to access the static variable n from First class but getting 0 as output but i want 15.

答:
@anju, One more thing to consider ...

When creating static variables, the compiler sometimes substitutes the value to save time. Especially when you use the keyword final. That means when you compile, it will substitute the current value in your secondary (or usage) classes. If you change that value, you need to recompile ALL usages or compile everything, otherwise, they will have the old value.

Body:
This is my first question on stackoverflow,

I want to access static int variable of one class in another class but when i access this variable in another class it always gives me "zero".

This is First class:

package kk;

public class ag {
    public static int n=0;

    public static int as()
    {
        return n;
    }
    public static void main(String[] args) {
        // TODO Auto-generated method stub

        n=3;
        n=n*5;
        System.out.println(n);
    }

}

Here the output is 15 i.e. n=15 here.

Second class:

package kk;

public class ah extends ag {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        //ag aa =new ag();
int k =ag.as();
System.out.println(k);
    }

}

In this am trying to access the static variable n from First class but getting 0 as output but i want 15.


问:
Modal window comment editing module (editable text)
I want to make, that during the ediditing comment action, I have modal window with comment text written inside textarea, and it is editable without deleting all text with clicking. I tried just to put value inside textarea or placing it in placeholder. But both options are wrong and doesnt work.
Can someone take a look on this code and give me an advice, how should I take for it.

editComment.html

```<code><div class="modal-header">
    <h3 class="modal-title" id="modal-title">Edytuj komentarz</h3>
</div>
<div class="modal-body" id="modal-body">
    <div class="row">
        <div class="col-sm-12">
            <div class="row">
                <div class="col-sm-12 form-group">
                    <label>Treść</label>

                    <textarea class="form-control input-sm"
                              name="description"
                              ng-maxlength="512"
                              ng-model="$ctrl.selected"
                              rows="6">{{comment.value()}}</textarea>
                </div>
            </div>
        </div>
    </div>
</div>
<div class="modal-footer">
    <button class="btn btn-raised btn-primary"
            type="button"
            ng-disabled="!$ctrl.selected"
            ng-click="$ctrl.ok()">Zapisz
    </button>
    <button class="btn btn-raised btn-warning"
            type="button"
            ng-click="$ctrl.cancel()">Anuluj
    </button>
</div>
</code>```

editComment.js

```<code>(function() {
    'use strict';

    angular.module('settlerApplication').controller('EditCommentCtrl', function($uibModalInstance) {

        var $ctrl = this;

        $ctrl.ok = function() {
            $uibModalInstance.close($ctrl.selected);
        };

        $ctrl.cancel = function() {
            $uibModalInstance.dismiss('cancel');
        };

    });

})();
</code>```

答:
Ok, so I am going to explain that a little.

I have modal window like that:

I want to edit existing comments in this window. And so I want my comment appears instead of text: "Komentarz" (under: "Treść" after clicking in there). And I want that comment text to be editable, so I dont have to write it down again (put the whole text to that area). Is it make it a little better explained about my goal?

Body:
I want to make, that during the ediditing comment action, I have modal window with comment text written inside textarea, and it is editable without deleting all text with clicking. I tried just to put value inside textarea or placing it in placeholder. But both options are wrong and doesnt work.
Can someone take a look on this code and give me an advice, how should I take for it.

editComment.html

Edytuj komentarz

                    Treść

                    <textarea class="form-control input-sm"
                              name="description"
                              ng-maxlength="512"
                              ng-model="$ctrl.selected"
                              rows="6">{{comment.value()}}</textarea>

    <button class="btn btn-raised btn-primary"
            type="button"
            ng-disabled="!$ctrl.selected"
            ng-click="$ctrl.ok()">Zapisz
    </button>
    <button class="btn btn-raised btn-warning"
            type="button"
            ng-click="$ctrl.cancel()">Anuluj
    </button>

editComment.js

(function() {
    'use strict';

    angular.module('settlerApplication').controller('EditCommentCtrl', function($uibModalInstance) {

        var $ctrl = this;

        $ctrl.ok = function() {
            $uibModalInstance.close($ctrl.selected);
        };

        $ctrl.cancel = function() {
            $uibModalInstance.dismiss('cancel');
        };

    });

})();


问:
Elif bad input on trinket.io
I'm making a simple Python Rock Paper Scissors game for a school project. I'm new to Python but I'm getting the error "ParseError: bad input on line 12 in main.py" here is my code:

```<code>import random

choice = input("Welcome to rock paper scissors! You go first.")
choice = choice.upper()
a = [1, 2, 3]

b = random.choice(a)

if b == 1:
print("My choice: ROCK")
elif b == 2:
  print("My choice: PAPER")
    elif b = 3:
      print("My choice: SCISSORS")

print("Your choice: " + choice)

if choice == b:

 print "Draw. Play again!"
</code>```

So it's the Elif statements that are giving me trouble, but I don't see how they could possibly be wrong, I've looked everywhere.

答:
Your indentation is wrong: the elif must be at the same level. Besides, you wrote elif b = 3, but it should be elif b == 3.

```<code>if b == 1:
    print("My choice: ROCK")
elif b == 2:
    print("My choice: PAPER")
elif b == 3:
    print("My choice: SCISSORS")
</code>```

Note that the code as you posted raises an IdentationError in a Python 3 interpreter.

Title: Elif bad input on trinket.io

Body:
I'm making a simple Python Rock Paper Scissors game for a school project. I'm new to Python but I'm getting the error "ParseError: bad input on line 12 in main.py" here is my code:

import random

choice = input("Welcome to rock paper scissors! You go first.")
choice = choice.upper()
a = [1, 2, 3]

b = random.choice(a)

if b == 1:
print("My choice: ROCK")
elif b == 2:
  print("My choice: PAPER")
    elif b = 3:
      print("My choice: SCISSORS")

print("Your choice: " + choice)

if choice == b:

 print "Draw. Play again!"

So it's the Elif statements that are giving me trouble, but I don't see how they could possibly be wrong, I've looked everywhere.

Body:
Your indentation is wrong: the elif must be at the same level. Besides, you wrote elif b = 3, but it should be elif b == 3.

if b == 1:
    print("My choice: ROCK")
elif b == 2:
    print("My choice: PAPER")
elif b == 3:
    print("My choice: SCISSORS")

Note that the code as you posted raises an IdentationError in a Python 3 interpreter.


问:
Delete directory with files in it?
I wonder, what's the easiest way to delete a directory with all its files in it?

I'm using rmdir(PATH . '/' . $value); to delete a folder, however, if there are files inside of it, I simply can't delete it.

答:
I want to expand on the answer by @alcuadrado with the comment by @Vijit for handling symlinks. Firstly, use getRealPath(). But then, if you have any symlinks that are folders it will fail as it will try and call rmdir on a link - so you need an extra check.</p>

```<code>$it = new RecursiveDirectoryIterator($dir, RecursiveDirectoryIterator::SKIP_DOTS);
$files = new RecursiveIteratorIterator($it, RecursiveIteratorIterator::CHILD_FIRST);
foreach($files as $file) {
    if ($file->isLink()) {
        unlink($file->getPathname());
    } else if ($file->isDir()){
        rmdir($file->getPathname());
    } else {
        unlink($file->getPathname());
    }
}
rmdir($dir);
</code>```

Title: Delete directory with files in it?

Body:
I want to expand on the answer by @alcuadrado with the comment by @Vijit for handling symlinks. Firstly, use getRealPath(). But then, if you have any symlinks that are folders it will fail as it will try and call rmdir on a link - so you need an extra check.

$it = new RecursiveDirectoryIterator($dir, RecursiveDirectoryIterator::SKIP_DOTS);
$files = new RecursiveIteratorIterator($it, RecursiveIteratorIterator::CHILD_FIRST);
foreach($files as $file) {
    if ($file->isLink()) {
        unlink($file->getPathname());
    } else if ($file->isDir()){
        rmdir($file->getPathname());
    } else {
        unlink($file->getPathname());
    }
}
rmdir($dir);


问:
How to stop the black screens when navigating from one activity to another in xamarin android mono
I am working in a project where many black screens are appearing while I am navigating from one activity to another activity in. our application is completely based on net so for every activity there is some API calling in background hope this is the problem of all and also implemented page loading but that did not solve the problem. I had not got the reason of the black screens during the navigation between the activities. Can help me with the reason of that and solution for solving the problem.</p>

答:
In this kind of scenarios the best solution it's to load only the indispensable in the onCreate/onResume events, and load the rest of the information in background.

Fortunately you are using xamarin and you have async methods to solve this.


问:
How many Non access modifiers are there in Java?
Can anyone tell how many Non-access Modifiers there are in Java? I have the list below, but I want to know if it is complete or if there's any other I need to add: </p>

```<code>final,
abstract,
static,
strictfp,
native,
synchronized,
transient
</code>```

答:
abstract

static

final

synchronized

native

strictfp

transient

volatile

Body:
Can anyone tell how many Non-access Modifiers there are in Java? I have the list below, but I want to know if it is complete or if there's any other I need to add:

final,
abstract,
static,
strictfp,
native,
synchronized,
transient