问:
sccm 2012 r2 msi packages failing with error 0x643(1603)
I have a question with sccm 2012 r2 and failed packages. For every package I try to deploy there is the odd one that always returns a generic error message  0x643(1603).

I know that this is a generic msi package message, but something has me confused. When i tried to deploy adobe flash.msi it would download the package, seem to install it but will give an error past due - will be retried.

I have set the time for the package to expire 6 hours ahead of the deployment, so a timeout isn't an issue.

When i looked at the appenforce.log on the client machine ( located at c:\windows\CCM\logs\Appenforce.log) I found the following in the log

```<code>[LOG[++++++ App enforcement completed (11 seconds) for App DT "Adobe Flash Player 21 ActiveX - Windows Installer (*.msi file)" [ScopeId_C8F1F365-A3C5-47CB-BD87-DB1E3BCFB76D/DeploymentType_a629d54a-d453-49a1-84c1-0192f983f1e4], Revision: 1, User SID: ] ++++++]LOG]!><time="15:45:20.777+420" date="05-27-2016" component="AppEnforce" context="" type="1" thread="29796" file="appprovider.cpp:2448">

[LOG[+++ Starting Install enforcement for App DT "Adobe Flash Player 21 ActiveX - Windows Installer (*.msi file)" ApplicationDeliveryType - ScopeId_C8F1F365-A3C5-47CB-BD87-DB1E3BCFB76D/DeploymentType_a629d54a-d453-49a1-84c1-0192f983f1e4, Revision - 1, ContentPath - C:\WINDOWS\ccmcache\13, Execution Context - System]LOG]!><time="15:49:09.871+420" date="05-27-2016" component="AppEnforce" context="" type="1" thread="31144" file="appprovider.cpp:1702">

[LOG[    A user is logged on to the system.]LOG]!><time="15:49:09.872+420" date="05-27-2016" component="AppEnforce" context="" type="1" thread="31144" file="appprovider.cpp:2083">

[LOG[    Performing detection of app deployment type Adobe Flash Player 21 ActiveX - Windows Installer (*.msi file)(ScopeId_C8F1F365-A3C5-47CB-BD87-DB1E3BCFB76D/DeploymentType_a629d54a-d453-49a1-84c1-0192f983f1e4, revision 1) for system.]LOG<time="15:49:09.874+420" date="05-27-2016" component="AppEnforce" context="" type="1" thread="31144" file="appprovider.cpp:2148">

[LOG[+++ MSI application not discovered [MSI Product Code: {FA944726-00F8-43B5-BB97-33E6FF409C22}, MSI Product version: ]]LOG]!>
<time="15:49:09.875+420" date="05-27-2016" component="AppEnforce" context="" type="1" thread="31144" file="msihandler.cpp:131">

[LOG[    App enforcement environment:
    Context: Machine
    Command line: msiexec /i "install_flash_player_21_active_x.msi" /q
    Allow user interaction: No
    UI mode: 0
    User token: null
    Session Id: 3
    Content path: C:\WINDOWS\ccmcache\13
    Working directory: ]LOG]!><time="15:49:09.875+420" date="05-27-2016" component="AppEnforce" context="" type="1" thread="31144" file="appcontext.cpp:85">

[LOG[    Prepared working directory: C:\WINDOWS\ccmcache\13]LOG]!><time="15:49:09.876+420" date="05-27-2016" component="AppEnforce" context="" type="1" thread="31144" file="appcontext.cpp:189">
<![LOG[Found executable file msiexec with complete path C:\WINDOWS\system32\msiexec.exe]LOG]!><time="15:49:09.878+420" date="05-27-2016" component="AppEnforce" context="" type="1" thread="31144" file="executility.cpp:188">

[LOG[    Prepared command line: "C:\WINDOWS\system32\msiexec.exe" /i "install_flash_player_21_active_x.msi" /q /qn]LOG]!><time="15:49:09.879+420" date="05-27-2016" component="AppEnforce" context="" type="1" thread="31144" file="appcontext.cpp:338">

[LOG[Valid MSI Package path = C:\WINDOWS\ccmcache\13\install_flash_player_21_active_x.msi]LOG]!><time="15:49:09.880+420" date="05-27-2016" component="AppEnforce" context="" type="1" thread="31144" file="appcontext.cpp:765">

[LOG[    Advertising MSI package [C:\WINDOWS\ccmcache\13\install_flash_player_21_active_x.msi] to the system.]LOG]!><time="15:49:09.881+420" date="05-27-2016" component="AppEnforce" context="" type="1" thread="31144" file="appcommon.cpp:125">

[LOG[    Executing Command line: "C:\WINDOWS\system32\msiexec.exe" /i "install_flash_player_21_active_x.msi" /q /qn with user context]LOG]!><time="15:49:10.268+420" date="05-27-2016" component="AppEnforce" context="" type="1" thread="31144" file="appexcnlib.cpp:201">

[LOG[    Working directory C:\WINDOWS\ccmcache\13]LOG]!><time="15:49:10.269+420" date="05-27-2016" component="AppEnforce" context="" type="1" thread="31144" file="appexcnlib.cpp:215">

[LOG[    Post install behavior is BasedOnExitCode]LOG]!><time="15:49:10.272+420" date="05-27-2016" component="AppEnforce" context="" type="1" thread="31144" file="appcommon.cpp:1094">

[LOG[    Waiting for process 27844 to finish.  Timeout = 120 minutes.]LOG]!><time="15:49:10.273+420" date="05-27-2016" component="AppEnforce" context="" type="1" thread="31144" file="appexcnlib.cpp:1958">

[LOG[    Process 27844 terminated with exitcode: 1603]LOG]!><time="15:49:21.074+420" date="05-27-2016" component="AppEnforce" context="" type="1" thread="31144" file="appexcnlib.cpp:1967">

[LOG[    Looking for exit code 1603 in exit codes table...]LOG]!><time="15:49:21.075+420" date="05-27-2016" component="AppEnforce" context="" type="1" thread="31144" file="appexcnlib.cpp:505">

[LOG[    Unmatched exit code (1603) is considered an execution failure.]LOG]!><time="15:49:21.075+420" date="05-27-2016" component="AppEnforce" context="" type="2" thread="31144" file="appexcnlib.cpp:591">

[LOG[++++++ App enforcement completed (11 seconds) for App DT "Adobe Flash Player 21 ActiveX - Windows Installer (*.msi file)" [ScopeId_C8F1F365-A3C5-47CB-BD87-DB1E3BCFB76D/DeploymentType_a629d54a-d453-49a1-84c1-0192f983f1e4], Revision: 1, User SID: ] ++++++]LOG]!><time="15:49:21.076+420" date="05-27-2016" component="AppEnforce" context="" type="1" thread="31144" file="appprovider.cpp:2448">

[LOG[+++ Starting Install enforcement for App DT "Adobe Flash Player 21 ActiveX - Windows Installer (*.msi file)" ApplicationDeliveryType - ScopeId_C8F1F365-A3C5-47CB-BD87-DB1E3BCFB76D/DeploymentType_a629d54a-d453-49a1-84c1-0192f983f1e4, Revision - 1, ContentPath - C:\WINDOWS\ccmcache\13, Execution Context - System]LOG]!><time="15:49:27.388+420" date="05-27-2016" component="AppEnforce" context="" type="1" thread="31144" file="appprovider.cpp:1702">

[LOG[    A user is logged on to the system.]LOG]!><time="15:49:27.388+420" date="05-27-2016" component="AppEnforce" context="" type="1" thread="31144" file="appprovider.cpp:2083">

[LOG[    Performing detection of app deployment type Adobe Flash Player 21 ActiveX - Windows Installer (*.msi file)(ScopeId_C8F1F365-A3C5-47CB-BD87-DB1E3BCFB76D/DeploymentType_a629d54a-d453-49a1-84c1-0192f983f1e4, revision 1) for system.]LOG]!><time="15:49:27.391+420" date="05-27-2016" component="AppEnforce" context="" type="1" thread="31144" file="appprovider.cpp:2148">

[LOG[+++ MSI application not discovered [MSI Product Code: {FA944726-00F8-43B5-BB97-33E6FF409C22}, MSI Product version: ]]LOG]!><time="15:49:27.391+420" date="05-27-2016" component="AppEnforce" context="" type="1" thread="31144" file="msihandler.cpp:131">

[LOG[    App enforcement environment:
    Context: Machine
    Command line: msiexec /i "install_flash_player_21_active_x.msi" /q
    Allow user interaction: No
    UI mode: 0
    User token: null
    Session Id: 3
    Content path: C:\WINDOWS\ccmcache\13
    Working directory: ]LOG]!><time="15:49:27.392+420" date="05-27-2016" component="AppEnforce" context="" type="1" thread="31144" file="appcontext.cpp:85">

[LOG[    Prepared working directory: C:\WINDOWS\ccmcache\13]LOG]!><time="15:49:27.393+420" date="05-27-2016" component="AppEnforce" context="" type="1" thread="31144" file="appcontext.cpp:189">

[LOG[Found executable file msiexec with complete path C:\WINDOWS\system32\msiexec.exe]LOG]!><time="15:49:27.394+420" date="05-27-2016" component="AppEnforce" context="" type="1" thread="31144" file="executility.cpp:188">

[LOG[    Prepared command line: "C:\WINDOWS\system32\msiexec.exe" /i "install_flash_player_21_active_x.msi" /q /qn]LOG]!><time="15:49:27.395+420" date="05-27-2016" component="AppEnforce" context="" type="1" thread="31144" file="appcontext.cpp:338">

[LOG[Valid MSI Package path = C:\WINDOWS\ccmcache\13\install_flash_player_21_active_x.msi]LOG]!><time="15:49:27.395+420" date="05-27-2016" component="AppEnforce" context="" type="1" thread="31144" file="appcontext.cpp:765">

[LOG[    Advertising MSI package [C:\WINDOWS\ccmcache\13\install_flash_player_21_active_x.msi] to the system.]LOG]!><time="15:49:27.396+420" date="05-27-2016" component="AppEnforce" context="" type="1" thread="31144" file="appcommon.cpp:125">

[LOG[    Executing Command line: "C:\WINDOWS\system32\msiexec.exe" /i "install_flash_player_21_active_x.msi" /q /qn with user context]LOG]!><time="15:49:27.800+420" date="05-27-2016" component="AppEnforce" context="" type="1" thread="31144" file="appexcnlib.cpp:201">

[LOG[    Working directory C:\WINDOWS\ccmcache\13]LOG]!><time="15:49:27.801+420" date="05-27-2016" component="AppEnforce" context="" type="1" thread="31144" file="appexcnlib.cpp:215">

[LOG[    Post install behavior is BasedOnExitCode]LOG]!><time="15:49:27.803+420" date="05-27-2016" component="AppEnforce" context="" type="1" thread="31144" file="appcommon.cpp:1094">

[LOG[    Waiting for process 29956 to finish.  Timeout = 120 minutes.]LOG]!><time="15:49:27.805+420" date="05-27-2016" component="AppEnforce" context="" type="1" thread="31144" file="appexcnlib.cpp:1958">

[LOG[    Process 29956 terminated with exitcode: 1603]LOG]!><time="15:49:38.441+420" date="05-27-2016" component="AppEnforce" context="" type="1" thread="31144" file="appexcnlib.cpp:1967">

[LOG[    Looking for exit code 1603 in exit codes table...]LOG]!><time="15:49:38.441+420" date="05-27-2016" component="AppEnforce" context="" type="1" thread="31144" file="appexcnlib.cpp:505">

[LOG[    Unmatched exit code (1603) is considered an execution failure.]LOG]!><time="15:49:38.442+420" date="05-27-2016" component="AppEnforce" context="" type="2" thread="31144" file="appexcnlib.cpp:591">

[LOG[++++++ App enforcement completed (11 seconds) for App DT "Adobe Flash Player 21 ActiveX - Windows Installer (*.msi file)" [ScopeId_C8F1F365-A3C5-47CB-BD87-DB1E3BCFB76D/DeploymentType_a629d54a-d453-49a1-84c1-0192f983f1e4], Revision: 1, User SID: ] ++++++]LOG]!><time="15:49:38.443+420" date="05-27-2016" component="AppEnforce" context="" type="1" thread="31144" file="appprovider.cpp:2448">
</code>```

In the error codes for the package i have:

```<code> 0 - success (no reboot)
1707- success (no reboot)
3010 - soft reboot
1641 - hard reboot
1618 - fast retry
</code>```

I guess my main question is why does this package keep failing? This has me scratching my head. I am sorry for the formatting of the log files, I tried to clear it up as best as i could.

Thanks!

答: Delete Hkcu/installer/produits/"active x container" and try again</p>

Body:
I have a question with sccm 2012 r2 and failed packages. For every package I try to deploy there is the odd one that always returns a generic error message  0x643(1603).

I know that this is a generic msi package message, but something has me confused. When i tried to deploy adobe flash.msi it would download the package, seem to install it but will give an error past due - will be retried.

I have set the time for the package to expire 6 hours ahead of the deployment, so a timeout isn't an issue.

When i looked at the appenforce.log on the client machine ( located at c:\windows\CCM\logs\Appenforce.log) I found the following in the log

[LOG[++++++ App enforcement completed (11 seconds) for App DT "Adobe Flash Player 21 ActiveX - Windows Installer (*.msi file)" [ScopeId_C8F1F365-A3C5-47CB-BD87-DB1E3BCFB76D/DeploymentType_a629d54a-d453-49a1-84c1-0192f983f1e4], Revision: 1, User SID: ] ++++++]LOG]!><time="15:45:20.777+420" date="05-27-2016" component="AppEnforce" context="" type="1" thread="29796" file="appprovider.cpp:2448">

[LOG[+++ Starting Install enforcement for App DT "Adobe Flash Player 21 ActiveX - Windows Installer (*.msi file)" ApplicationDeliveryType - ScopeId_C8F1F365-A3C5-47CB-BD87-DB1E3BCFB76D/DeploymentType_a629d54a-d453-49a1-84c1-0192f983f1e4, Revision - 1, ContentPath - C:\WINDOWS\ccmcache\13, Execution Context - System]LOG]!><time="15:49:09.871+420" date="05-27-2016" component="AppEnforce" context="" type="1" thread="31144" file="appprovider.cpp:1702">

[LOG[    A user is logged on to the system.]LOG]!><time="15:49:09.872+420" date="05-27-2016" component="AppEnforce" context="" type="1" thread="31144" file="appprovider.cpp:2083">

[LOG[    Performing detection of app deployment type Adobe Flash Player 21 ActiveX - Windows Installer (*.msi file)(ScopeId_C8F1F365-A3C5-47CB-BD87-DB1E3BCFB76D/DeploymentType_a629d54a-d453-49a1-84c1-0192f983f1e4, revision 1) for system.]LOG<time="15:49:09.874+420" date="05-27-2016" component="AppEnforce" context="" type="1" thread="31144" file="appprovider.cpp:2148">

[LOG[+++ MSI application not discovered [MSI Product Code: {FA944726-00F8-43B5-BB97-33E6FF409C22}, MSI Product version: ]]LOG]!>
<time="15:49:09.875+420" date="05-27-2016" component="AppEnforce" context="" type="1" thread="31144" file="msihandler.cpp:131">

[LOG[    App enforcement environment:
    Context: Machine
    Command line: msiexec /i "install_flash_player_21_active_x.msi" /q
    Allow user interaction: No
    UI mode: 0
    User token: null
    Session Id: 3
    Content path: C:\WINDOWS\ccmcache\13
    Working directory: ]LOG]!><time="15:49:09.875+420" date="05-27-2016" component="AppEnforce" context="" type="1" thread="31144" file="appcontext.cpp:85">

[LOG[    Prepared working directory: C:\WINDOWS\ccmcache\13]LOG]!><time="15:49:09.876+420" date="05-27-2016" component="AppEnforce" context="" type="1" thread="31144" file="appcontext.cpp:189">
<![LOG[Found executable file msiexec with complete path C:\WINDOWS\system32\msiexec.exe]LOG]!><time="15:49:09.878+420" date="05-27-2016" component="AppEnforce" context="" type="1" thread="31144" file="executility.cpp:188">

[LOG[    Prepared command line: "C:\WINDOWS\system32\msiexec.exe" /i "install_flash_player_21_active_x.msi" /q /qn]LOG]!><time="15:49:09.879+420" date="05-27-2016" component="AppEnforce" context="" type="1" thread="31144" file="appcontext.cpp:338">

[LOG[Valid MSI Package path = C:\WINDOWS\ccmcache\13\install_flash_player_21_active_x.msi]LOG]!><time="15:49:09.880+420" date="05-27-2016" component="AppEnforce" context="" type="1" thread="31144" file="appcontext.cpp:765">

[LOG[    Advertising MSI package [C:\WINDOWS\ccmcache\13\install_flash_player_21_active_x.msi] to the system.]LOG]!><time="15:49:09.881+420" date="05-27-2016" component="AppEnforce" context="" type="1" thread="31144" file="appcommon.cpp:125">

[LOG[    Executing Command line: "C:\WINDOWS\system32\msiexec.exe" /i "install_flash_player_21_active_x.msi" /q /qn with user context]LOG]!><time="15:49:10.268+420" date="05-27-2016" component="AppEnforce" context="" type="1" thread="31144" file="appexcnlib.cpp:201">

[LOG[    Working directory C:\WINDOWS\ccmcache\13]LOG]!><time="15:49:10.269+420" date="05-27-2016" component="AppEnforce" context="" type="1" thread="31144" file="appexcnlib.cpp:215">

[LOG[    Post install behavior is BasedOnExitCode]LOG]!><time="15:49:10.272+420" date="05-27-2016" component="AppEnforce" context="" type="1" thread="31144" file="appcommon.cpp:1094">

[LOG[    Waiting for process 27844 to finish.  Timeout = 120 minutes.]LOG]!><time="15:49:10.273+420" date="05-27-2016" component="AppEnforce" context="" type="1" thread="31144" file="appexcnlib.cpp:1958">

[LOG[    Process 27844 terminated with exitcode: 1603]LOG]!><time="15:49:21.074+420" date="05-27-2016" component="AppEnforce" context="" type="1" thread="31144" file="appexcnlib.cpp:1967">

[LOG[    Looking for exit code 1603 in exit codes table...]LOG]!><time="15:49:21.075+420" date="05-27-2016" component="AppEnforce" context="" type="1" thread="31144" file="appexcnlib.cpp:505">

[LOG[    Unmatched exit code (1603) is considered an execution failure.]LOG]!><time="15:49:21.075+420" date="05-27-2016" component="AppEnforce" context="" type="2" thread="31144" file="appexcnlib.cpp:591">

[LOG[++++++ App enforcement completed (11 seconds) for App DT "Adobe Flash Player 21 ActiveX - Windows Installer (*.msi file)" [ScopeId_C8F1F365-A3C5-47CB-BD87-DB1E3BCFB76D/DeploymentType_a629d54a-d453-49a1-84c1-0192f983f1e4], Revision: 1, User SID: ] ++++++]LOG]!><time="15:49:21.076+420" date="05-27-2016" component="AppEnforce" context="" type="1" thread="31144" file="appprovider.cpp:2448">

[LOG[+++ Starting Install enforcement for App DT "Adobe Flash Player 21 ActiveX - Windows Installer (*.msi file)" ApplicationDeliveryType - ScopeId_C8F1F365-A3C5-47CB-BD87-DB1E3BCFB76D/DeploymentType_a629d54a-d453-49a1-84c1-0192f983f1e4, Revision - 1, ContentPath - C:\WINDOWS\ccmcache\13, Execution Context - System]LOG]!><time="15:49:27.388+420" date="05-27-2016" component="AppEnforce" context="" type="1" thread="31144" file="appprovider.cpp:1702">

[LOG[    A user is logged on to the system.]LOG]!><time="15:49:27.388+420" date="05-27-2016" component="AppEnforce" context="" type="1" thread="31144" file="appprovider.cpp:2083">

[LOG[    Performing detection of app deployment type Adobe Flash Player 21 ActiveX - Windows Installer (*.msi file)(ScopeId_C8F1F365-A3C5-47CB-BD87-DB1E3BCFB76D/DeploymentType_a629d54a-d453-49a1-84c1-0192f983f1e4, revision 1) for system.]LOG]!><time="15:49:27.391+420" date="05-27-2016" component="AppEnforce" context="" type="1" thread="31144" file="appprovider.cpp:2148">

[LOG[+++ MSI application not discovered [MSI Product Code: {FA944726-00F8-43B5-BB97-33E6FF409C22}, MSI Product version: ]]LOG]!><time="15:49:27.391+420" date="05-27-2016" component="AppEnforce" context="" type="1" thread="31144" file="msihandler.cpp:131">

[LOG[    App enforcement environment:
    Context: Machine
    Command line: msiexec /i "install_flash_player_21_active_x.msi" /q
    Allow user interaction: No
    UI mode: 0
    User token: null
    Session Id: 3
    Content path: C:\WINDOWS\ccmcache\13
    Working directory: ]LOG]!><time="15:49:27.392+420" date="05-27-2016" component="AppEnforce" context="" type="1" thread="31144" file="appcontext.cpp:85">

[LOG[    Prepared working directory: C:\WINDOWS\ccmcache\13]LOG]!><time="15:49:27.393+420" date="05-27-2016" component="AppEnforce" context="" type="1" thread="31144" file="appcontext.cpp:189">

[LOG[Found executable file msiexec with complete path C:\WINDOWS\system32\msiexec.exe]LOG]!><time="15:49:27.394+420" date="05-27-2016" component="AppEnforce" context="" type="1" thread="31144" file="executility.cpp:188">

[LOG[    Prepared command line: "C:\WINDOWS\system32\msiexec.exe" /i "install_flash_player_21_active_x.msi" /q /qn]LOG]!><time="15:49:27.395+420" date="05-27-2016" component="AppEnforce" context="" type="1" thread="31144" file="appcontext.cpp:338">

[LOG[Valid MSI Package path = C:\WINDOWS\ccmcache\13\install_flash_player_21_active_x.msi]LOG]!><time="15:49:27.395+420" date="05-27-2016" component="AppEnforce" context="" type="1" thread="31144" file="appcontext.cpp:765">

[LOG[    Advertising MSI package [C:\WINDOWS\ccmcache\13\install_flash_player_21_active_x.msi] to the system.]LOG]!><time="15:49:27.396+420" date="05-27-2016" component="AppEnforce" context="" type="1" thread="31144" file="appcommon.cpp:125">

[LOG[    Executing Command line: "C:\WINDOWS\system32\msiexec.exe" /i "install_flash_player_21_active_x.msi" /q /qn with user context]LOG]!><time="15:49:27.800+420" date="05-27-2016" component="AppEnforce" context="" type="1" thread="31144" file="appexcnlib.cpp:201">

[LOG[    Working directory C:\WINDOWS\ccmcache\13]LOG]!><time="15:49:27.801+420" date="05-27-2016" component="AppEnforce" context="" type="1" thread="31144" file="appexcnlib.cpp:215">

[LOG[    Post install behavior is BasedOnExitCode]LOG]!><time="15:49:27.803+420" date="05-27-2016" component="AppEnforce" context="" type="1" thread="31144" file="appcommon.cpp:1094">

[LOG[    Waiting for process 29956 to finish.  Timeout = 120 minutes.]LOG]!><time="15:49:27.805+420" date="05-27-2016" component="AppEnforce" context="" type="1" thread="31144" file="appexcnlib.cpp:1958">

[LOG[    Process 29956 terminated with exitcode: 1603]LOG]!><time="15:49:38.441+420" date="05-27-2016" component="AppEnforce" context="" type="1" thread="31144" file="appexcnlib.cpp:1967">

[LOG[    Looking for exit code 1603 in exit codes table...]LOG]!><time="15:49:38.441+420" date="05-27-2016" component="AppEnforce" context="" type="1" thread="31144" file="appexcnlib.cpp:505">

[LOG[    Unmatched exit code (1603) is considered an execution failure.]LOG]!><time="15:49:38.442+420" date="05-27-2016" component="AppEnforce" context="" type="2" thread="31144" file="appexcnlib.cpp:591">

[LOG[++++++ App enforcement completed (11 seconds) for App DT "Adobe Flash Player 21 ActiveX - Windows Installer (*.msi file)" [ScopeId_C8F1F365-A3C5-47CB-BD87-DB1E3BCFB76D/DeploymentType_a629d54a-d453-49a1-84c1-0192f983f1e4], Revision: 1, User SID: ] ++++++]LOG]!><time="15:49:38.443+420" date="05-27-2016" component="AppEnforce" context="" type="1" thread="31144" file="appprovider.cpp:2448">

In the error codes for the package i have:

 0 - success (no reboot)
1707- success (no reboot)
3010 - soft reboot
1641 - hard reboot
1618 - fast retry

I guess my main question is why does this package keep failing? This has me scratching my head. I am sorry for the formatting of the log files, I tried to clear it up as best as i could.

Thanks!


来源: stackexchange

问:
Get value of comboboxitem contentcontrol in wpf
I am new to WPF.
I want to know how can i get the selectedtext if the text that i want is placed inside a control inside comboboxitem and not directly inside comboboxitem.
I know this is very basic,but would appreciate if someone could provide me a simple and quick solution

My simple combobox code is as follows:

```<code><ComboBox x:Name="cmdTest">
    <ComboBoxItem>
        <TextBlock Text="RED" Background="RED" Foreground="White" FontFamily="Sans Serif" FontSize="14"/>
    </ComboBoxItem>
    <ComboBoxItem>
        <Grid Width="250">
            <TextBlock Text="GREEN" Background="GREEN" Foreground="White" FontFamily="Sans Serif" FontSize="14" Height="15"/>
        </Grid>
    </ComboBoxItem>
    <ComboBoxItem>
        <TextBlock Text="BLUE" Background="Blue" Foreground="White" FontFamily="Sans Serif" FontSize="14"/>
    </ComboBoxItem>
</ComboBox>
</code>```

答:
XAML:

```<code><ComboBox Name="anyname" SelectionChanged="cmbColors_SelectionChanged">
</code>```

C#:

```<code>private void cmbColors_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
{
    MessageBox.Show(string.Format("Selected Item: {0}", anyname.Text));
}
</code>```

ContentLicense: CC BY-SA 3.0

Body:
I am new to WPF.
I want to know how can i get the selectedtext if the text that i want is placed inside a control inside comboboxitem and not directly inside comboboxitem.
I know this is very basic,but would appreciate if someone could provide me a simple and quick solution

My simple combobox code is as follows:

<ComboBox x:Name="cmdTest">
    <ComboBoxItem>
        <TextBlock Text="RED" Background="RED" Foreground="White" FontFamily="Sans Serif" FontSize="14"/>
    </ComboBoxItem>
    <ComboBoxItem>
        <Grid Width="250">
            <TextBlock Text="GREEN" Background="GREEN" Foreground="White" FontFamily="Sans Serif" FontSize="14" Height="15"/>
        </Grid>
    </ComboBoxItem>
    <ComboBoxItem>
        <TextBlock Text="BLUE" Background="Blue" Foreground="White" FontFamily="Sans Serif" FontSize="14"/>
    </ComboBoxItem>
</ComboBox>

Body:
XAML:

<ComboBox Name="anyname" SelectionChanged="cmbColors_SelectionChanged">

C#:

private void cmbColors_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
{
    MessageBox.Show(string.Format("Selected Item: {0}", anyname.Text));
}


问:
when the Intent startActivity, how to stop the timer on android?
when I app start, start A timer.

Timer execute every 5 second.

Question is:

how to stop timer, when I start new Activity?

Here is what I have tried so far -

```<code> public boolean isDevDetect;

 Timer timer = new Timer();
 final TimerTask devTimertask = new TimerTask() {
        @Override
        public void run() {
            if (//device detect) {
                Intent intent = new Intent(A.this, B.class);
                startActivity(intent);
                isDevDetect = true;
            }
            else {
                Log.d(TAG, "timer timer timer");
            }
        }
    };
    if (!isDevDetect) {
        Log.d(TAG, "repetition timer");

        devTimer.schedule(devTimertask, 3000, 5000);
    } else if (isDevDetect) {
        devTimertask.cancel();
        devTimer.cancel();
        Log.d(TAG, "stop timer");
    }
</code>```

this source when connected device. start B class.
but timer not stop.

how to when start activity, stop timer?

thanks.

答:
```<code> public boolean isDevDetect;

 Timer timer = new Timer();
 final TimerTask devTimertask = new TimerTask() {
        @Override
        public void run() {
            if (//device detect) {
                Intent intent = new Intent(A.this, B.class);
                startActivity(intent);
                devTimertask.cancel();
                devTimer.cancel();
            }
            else {
                Log.d(TAG, "timer timer timer");
            }
        }
    };
    devTimer.schedule(devTimertask, 3000, 5000);
</code>```

According to what you stated let me rewrite the problem statement , bascially you are trying to stop the timeTask as soon as the startActivity is called.The above code will suffice your problem statement.basically you need to stop timer when startActivity is called.Hope this solved your problem.

------------------- **

UPDATE

** -----------------

Please read the below blog , your Timertask is initialized .onRun() would be called only after  devTimer.schedule(devTimertask, 3000, 5000); after which your Timertask is initialized .
http://android-er.blogspot.in/2013/12/example-of-using-timer-and-timertask-on.html

Body:
when I app start, start A timer.

Timer execute every 5 second.

Question is:

how to stop timer, when I start new Activity?

Here is what I have tried so far -

 public boolean isDevDetect;

 Timer timer = new Timer();
 final TimerTask devTimertask = new TimerTask() {
        @Override
        public void run() {
            if (//device detect) {
                Intent intent = new Intent(A.this, B.class);
                startActivity(intent);
                isDevDetect = true;
            }
            else {
                Log.d(TAG, "timer timer timer");
            }
        }
    };
    if (!isDevDetect) {
        Log.d(TAG, "repetition timer");

        devTimer.schedule(devTimertask, 3000, 5000);
    } else if (isDevDetect) {
        devTimertask.cancel();
        devTimer.cancel();
        Log.d(TAG, "stop timer");
    }

this source when connected device. start B class.
but timer not stop.

how to when start activity, stop timer?

thanks.

Body:
 public boolean isDevDetect;

 Timer timer = new Timer();
 final TimerTask devTimertask = new TimerTask() {
        @Override
        public void run() {
            if (//device detect) {
                Intent intent = new Intent(A.this, B.class);
                startActivity(intent);
                devTimertask.cancel();
                devTimer.cancel();
            }
            else {
                Log.d(TAG, "timer timer timer");
            }
        }
    };
    devTimer.schedule(devTimertask, 3000, 5000);

According to what you stated let me rewrite the problem statement , bascially you are trying to stop the timeTask as soon as the startActivity is called.The above code will suffice your problem statement.basically you need to stop timer when startActivity is called.Hope this solved your problem.

------------------- **

UPDATE

** -----------------

Please read the below blog , your Timertask is initialized .onRun() would be called only after  devTimer.schedule(devTimertask, 3000, 5000); after which your Timertask is initialized .
http://android-er.blogspot.in/2013/12/example-of-using-timer-and-timertask-on.html


问:
How can I test $rootScope.$emit event?
I have below code in abc controller:

```<code>   $rootScope.$on('selectedItem', function (event, data) {
       vm.selectedItem = data;
   });
</code>```

And the caller function is in xyz controller:

```<code>  function doThis(){
     $rootScope.$emit('selectedItem', 'somedata');
  }
</code>```

How can I reproduce or mock this scenario in karma test?

答:
Using Jasmine, it could look like this:</p>

```<code>var rootScope;
beforeEach(inject(function($injector) {
    rootScope = $injector.get('$rootScope');
    spyOn(rootScope, '$emit');
}));

describe("$rootScope event testing", function() {
    it("should $emit selectedItem", function() {
        expect(rootScope.$emit).toHaveBeenCalledWith('selectedItem');
    });
});
</code>```

Title: How can I test $rootScope.$emit event?

Body:
I have below code in abc controller:

   $rootScope.$on('selectedItem', function (event, data) {
       vm.selectedItem = data;
   });

And the caller function is in xyz controller:

  function doThis(){
     $rootScope.$emit('selectedItem', 'somedata');
  }

How can I reproduce or mock this scenario in karma test?

Body:
Using Jasmine, it could look like this:

var rootScope;
beforeEach(inject(function($injector) {
    rootScope = $injector.get('$rootScope');
    spyOn(rootScope, '$emit');
}));

describe("$rootScope event testing", function() {
    it("should $emit selectedItem", function() {
        expect(rootScope.$emit).toHaveBeenCalledWith('selectedItem');
    });
});


问:
soapUI tests reports are not visible in jenkins
I am using maven-soapui-extension-plugin:test-multi to run tests splitted in multiple soapUI projects.

I see that a lot of TEST-*.xml are generated in target/surefire-reports but I don't see them on the jenkins build page like I do with other projects containing regular junit tests. It seems that jenkins does not detect those reports.

My plugin is configured as such:

```<code><plugin>
    <groupId>com.github.redfish4ktc.soapui</groupId>
    <artifactId>maven-soapui-extension-plugin</artifactId>
    <version>4.6.4.2</version>
    <executions>
        <execution>
            <phase>test</phase>
            <goals>
                <goal>test-multi</goal>
            </goals>
            <configuration>
                <projectFiles>
                    <scan>
                        <baseDirectory>${soapui.folder}</baseDirectory>
                        <includes>
                            <include>**/*-soapui-project.xml</include>
                        </includes>
                    </scan>
                </projectFiles>
                <host>${soapui.endpoint}</host>
                <outputFolder>${basedir}/target/surefire-reports</outputFolder>
                <junitReport>true</junitReport>
                <exportAll>true</exportAll>
                <testFailIgnore>true</testFailIgnore>
                <useOutputFolderPerProject>false</useOutputFolderPerProject>
            </configuration>
        </execution>
    </executions>
</plugin>
</code>```

Do I need something else in my configuration or in jenkins?

答: It seems to be a problem with Jenkins which does not publish surefire reports generated outside the surefire-plugin for maven (non-freestyle) projects.</p>

Body:
I am using maven-soapui-extension-plugin:test-multi to run tests splitted in multiple soapUI projects.

I see that a lot of TEST-*.xml are generated in target/surefire-reports but I don't see them on the jenkins build page like I do with other projects containing regular junit tests. It seems that jenkins does not detect those reports.

My plugin is configured as such:

<plugin>
    <groupId>com.github.redfish4ktc.soapui</groupId>
    <artifactId>maven-soapui-extension-plugin</artifactId>
    <version>4.6.4.2</version>
    <executions>
        <execution>
            <phase>test</phase>
            <goals>
                <goal>test-multi</goal>
            </goals>
            <configuration>
                <projectFiles>
                    <scan>
                        <baseDirectory>${soapui.folder}</baseDirectory>
                        <includes>
                            <include>**/*-soapui-project.xml</include>
                        </includes>
                    </scan>
                </projectFiles>
                <host>${soapui.endpoint}</host>
                <outputFolder>${basedir}/target/surefire-reports</outputFolder>
                <junitReport>true</junitReport>
                <exportAll>true</exportAll>
                <testFailIgnore>true</testFailIgnore>
                <useOutputFolderPerProject>false</useOutputFolderPerProject>
            </configuration>
        </execution>
    </executions>
</plugin>

Do I need something else in my configuration or in jenkins?


问:
JavaScript append array to array from loop
I have the below Table TDs that I need to get the values.

```<code>     <table style="border: 1px solid blue;margin: 15px;">
        <tr>
            <td class="drdsclient">DSCDS201020101</td>
        </tr>
        <tr class="drcheck">
            <td>Maximum online generations:</td>
            <td id="drcheckval" class="notopborder">30</td>
            <td id="drchecknotes" class="notopborder">notes</td>
        </tr>
        <tr class="drcheck">
            <td>Default Retention Rule set:</td>
            <td id="drcheckval" class="notopborder">No default Retention rule set</td>
            <td id="drchecknotes" class="notopborder">notes</td>
        </tr>
        <tr class="drcheck">
            <td>Default Backup Schedule set:</td>
            <td id="drcheckval" class="notopborder">No default Schedule set</td>
            <td id="drchecknotes" class="notopborder">notes</td>
        </tr>
        <tr class="drcheck">
            <td class="drdsclient">DSCDS901999102</td>
        </tr>
        <tr class="drcheck">
            <td>Maximum online generations:</td>
            <td id="drcheckval"  class="notopborder">29</td>
            <td id="drchecknotes" class="notopborder">notes</td>
        </tr>
        <tr class="drcheck">
            <td>Default Retention Rule set:</td>
            <td id="drcheckval"  class="notopborder">30 days</td>
            <td id="drchecknotes" class="notopborder">notes</td>
        </tr>
        <tr class="drcheck">
            <td>Default Backup Schedule set:</td>
            <td id="drcheckval"  class="notopborder">Monday to Friday @ 21:00</td>
            <td id="drchecknotes" class="notopborder">notes</td>
        </tr>
    </table>
</code>```

I keep using IDs and Classes with the below JS code:

```<code>    var array1 = [];
        $(' .drdsclient ').each(function(){
            var obj = {
                drdsc: $(" .drdsclient ").text(),
                drcheck1: $(" #drcheck1 " ).text(),
                drcheckval1: $(" #drcheckval1 ").text(),
                drchecknotes1: $(" #drchecknotes1 ").text(),
                drcheck2: $(" #drcheck2 " ).text(),
                drcheckval2: $(" #drcheckval2 ").text(),
                drchecknotes2: $(" #drchecknotes2 ").text(),
                drcheck3: $(" #drcheck3 " ).text(),
                drcheckval3: $(" #drcheckval3 ").text(),
                drchecknotes3: $(" #drchecknotes3 ").text()
            };
            var arr2 = array1.push(obj);
        });
</code>```

But instead of appending to the array, it doubles the values and I get the below result:

```<code>[0]
    [drdsc] => "DSCDS201020101DSCDS901999102"
    [drcheck1] => "Maximum online generations:Maximum online generations:"
    [drcheckval1] => "30999"
    [drchecknotes1] => "notesnotes"
    [drcheck2] => "Default Retention Rule set:Default Retention Rule set:"
    [drcheckval2] => "No default Retention rule set30 days"
    [drchecknotes2] => "notesnotes"
    [drcheck3] => "Default Backup Schedule set:Default Backup Schedule set:"
    [drcheckval3] => "No default Schedule setMonday to Friday @ 21:00"
    [drchecknotes3] => "notesnotes"
[1]
    [drdsc] => "DSCDS201020101DSCDS901999102"
    [drcheck1] => "Maximum online generations:Maximum online generations:"
    [drcheckval1] => "30999"
    [drchecknotes1] => "notesnotes"
    [drcheck2] => "Default Retention Rule set:Default Retention Rule set:"
    [drcheckval2] => "No default Retention rule set30 days"
    [drchecknotes2] => "notesnotes"
    [drcheck3] => "Default Backup Schedule set:Default Backup Schedule set:"
    [drcheckval3] => "No default Schedule setMonday to Friday @ 21:00"
    [drchecknotes3] => "notesnotes"
</code>```

Any way I can get an array like the below?

```<code>[0]
    [drdsc] => "DSCDS201020101"
    [drcheck1] => Maximum online generations:"
    [drcheckval1] => "30"
    [drchecknotes1] => "notes"
    [drcheck2] => "Default Retention Rule set:"
    [drcheckval2] => "No default Retention rule set"
    [drchecknotes2] => "notes"
    [drcheck3] => "Default Backup Schedule set:"
    [drcheckval3] => "No default Schedule set"
    [drchecknotes3] => "notes"
[1]
    [drdsc] => "DSCDS901999102"
    [drcheck1] => "Maximum online generations:"
    [drcheckval1] => "999"
    [drchecknotes1] => "notes"
    [drcheck2] => "Default Retention Rule set:"
    [drcheckval2] => "30 days"
    [drchecknotes2] => "notes"
    [drcheck3] => "Default Backup Schedule set:"
    [drcheckval3] => "Monday to Friday @ 21:00"
    [drchecknotes3] => "notes"
</code>```

答:
There's a few issues in your code. First you've repeated the same id attribute in multiple places which is invalid. You need to change them to classes. Secondly in the JS code you're trying to read id that don't exist. It seems you're getting confused between id and the index of the element.

To actually achieve what you need you'll need to loop through the .drdsclient elements and retrieve all the following tr elements until the next .drdsclient. From there you can loop over those rows and build the object as required, like this:

var array1 = $('.drdsclient').map(function() {
  var $client = $(this);
  var $rows = $client.closest('tr').nextUntil('tr:has(.drdsclient)');
  var obj = {
    drdsc: $client.text()
  };

  $rows.each(function(i) {
    var rowNum = i + 1;
    obj['drcheck' + rowNum] = $(this).find('td:first').text();
    obj['drcheckval' + rowNum] = $(this).find('td.drcheckval').text();
    obj['drchecknotes' + rowNum] = $(this).find('td.drchecknotes').text();
  });

  return obj;
}).get();

console.log(array1);```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<table style="border: 1px solid blue;margin: 15px;">
  <tr>
    <td class="drdsclient">DSCDS201020101</td>
  </tr>
  <tr class="drcheck">
    <td>Maximum online generations:</td>
    <td class="drcheckval notopborder">30</td>
    <td class="drchecknotes notopborder">notes</td>
  </tr>
  <tr class="drcheck">
    <td>Default Retention Rule set:</td>
    <td class="drcheckval notopborder">No default Retention rule set</td>
    <td class="drchecknotes notopborder">notes</td>
  </tr>
  <tr class="drcheck">
    <td>Default Backup Schedule set:</td>
    <td class="drcheckval notopborder">No default Schedule set</td>
    <td class="drchecknotes notopborder">notes</td>
  </tr>
  <tr class="drcheck">
    <td class="drdsclient">DSCDS901999102</td>
  </tr>
  <tr class="drcheck">
    <td>Maximum online generations:</td>
    <td class="drcheckval notopborder">29</td>
    <td class="drchecknotes notopborder">notes</td>
  </tr>
  <tr class="drcheck">
    <td>Default Retention Rule set:</td>
    <td class="drcheckval notopborder">30 days</td>
    <td class="drchecknotes notopborder">notes</td>
  </tr>
  <tr class="drcheck">
    <td>Default Backup Schedule set:</td>
    <td class="drcheckval notopborder">Monday to Friday @ 21:00</td>
    <td class="drchecknotes notopborder">notes</td>
  </tr>
</table></code>```

Also note that having incremental object properties isn't a very good idea. A better solution would be to build arrays of the values and place those in the properties of the object. This makes looping over the result much simpler.

Body:
I have the below Table TDs that I need to get the values.

            DSCDS201020101

            Maximum online generations:
            30
            notes

            Default Retention Rule set:
            No default Retention rule set
            notes

            Default Backup Schedule set:
            No default Schedule set
            notes

            DSCDS901999102

            Maximum online generations:
            29
            notes

            Default Retention Rule set:
            30 days
            notes

            Default Backup Schedule set:
            Monday to Friday @ 21:00
            notes

I keep using IDs and Classes with the below JS code:

    var array1 = [];
        $(' .drdsclient ').each(function(){
            var obj = {
                drdsc: $(" .drdsclient ").text(),
                drcheck1: $(" #drcheck1 " ).text(),
                drcheckval1: $(" #drcheckval1 ").text(),
                drchecknotes1: $(" #drchecknotes1 ").text(),
                drcheck2: $(" #drcheck2 " ).text(),
                drcheckval2: $(" #drcheckval2 ").text(),
                drchecknotes2: $(" #drchecknotes2 ").text(),
                drcheck3: $(" #drcheck3 " ).text(),
                drcheckval3: $(" #drcheckval3 ").text(),
                drchecknotes3: $(" #drchecknotes3 ").text()
            };
            var arr2 = array1.push(obj);
        });

But instead of appending to the array, it doubles the values and I get the below result:

[0]
    [drdsc] => "DSCDS201020101DSCDS901999102"
    [drcheck1] => "Maximum online generations:Maximum online generations:"
    [drcheckval1] => "30999"
    [drchecknotes1] => "notesnotes"
    [drcheck2] => "Default Retention Rule set:Default Retention Rule set:"
    [drcheckval2] => "No default Retention rule set30 days"
    [drchecknotes2] => "notesnotes"
    [drcheck3] => "Default Backup Schedule set:Default Backup Schedule set:"
    [drcheckval3] => "No default Schedule setMonday to Friday @ 21:00"
    [drchecknotes3] => "notesnotes"
[1]
    [drdsc] => "DSCDS201020101DSCDS901999102"
    [drcheck1] => "Maximum online generations:Maximum online generations:"
    [drcheckval1] => "30999"
    [drchecknotes1] => "notesnotes"
    [drcheck2] => "Default Retention Rule set:Default Retention Rule set:"
    [drcheckval2] => "No default Retention rule set30 days"
    [drchecknotes2] => "notesnotes"
    [drcheck3] => "Default Backup Schedule set:Default Backup Schedule set:"
    [drcheckval3] => "No default Schedule setMonday to Friday @ 21:00"
    [drchecknotes3] => "notesnotes"

Any way I can get an array like the below?

[0]
    [drdsc] => "DSCDS201020101"
    [drcheck1] => Maximum online generations:"
    [drcheckval1] => "30"
    [drchecknotes1] => "notes"
    [drcheck2] => "Default Retention Rule set:"
    [drcheckval2] => "No default Retention rule set"
    [drchecknotes2] => "notes"
    [drcheck3] => "Default Backup Schedule set:"
    [drcheckval3] => "No default Schedule set"
    [drchecknotes3] => "notes"
[1]
    [drdsc] => "DSCDS901999102"
    [drcheck1] => "Maximum online generations:"
    [drcheckval1] => "999"
    [drchecknotes1] => "notes"
    [drcheck2] => "Default Retention Rule set:"
    [drcheckval2] => "30 days"
    [drchecknotes2] => "notes"
    [drcheck3] => "Default Backup Schedule set:"
    [drcheckval3] => "Monday to Friday @ 21:00"
    [drchecknotes3] => "notes"

Body:
There's a few issues in your code. First you've repeated the same id attribute in multiple places which is invalid. You need to change them to classes. Secondly in the JS code you're trying to read id that don't exist. It seems you're getting confused between id and the index of the element.

To actually achieve what you need you'll need to loop through the .drdsclient elements and retrieve all the following tr elements until the next .drdsclient. From there you can loop over those rows and build the object as required, like this:

var array1 = $('.drdsclient').map(function() {
  var $client = $(this);
  var $rows = $client.closest('tr').nextUntil('tr:has(.drdsclient)');
  var obj = {
    drdsc: $client.text()
  };

  $rows.each(function(i) {
    var rowNum = i + 1;
    obj['drcheck' + rowNum] = $(this).find('td:first').text();
    obj['drcheckval' + rowNum] = $(this).find('td.drcheckval').text();
    obj['drchecknotes' + rowNum] = $(this).find('td.drchecknotes').text();
  });

  return obj;
}).get();

console.log(array1);

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<table style="border: 1px solid blue;margin: 15px;">
  <tr>
    <td class="drdsclient">DSCDS201020101</td>
  </tr>
  <tr class="drcheck">
    <td>Maximum online generations:</td>
    <td class="drcheckval notopborder">30</td>
    <td class="drchecknotes notopborder">notes</td>
  </tr>
  <tr class="drcheck">
    <td>Default Retention Rule set:</td>
    <td class="drcheckval notopborder">No default Retention rule set</td>
    <td class="drchecknotes notopborder">notes</td>
  </tr>
  <tr class="drcheck">
    <td>Default Backup Schedule set:</td>
    <td class="drcheckval notopborder">No default Schedule set</td>
    <td class="drchecknotes notopborder">notes</td>
  </tr>
  <tr class="drcheck">
    <td class="drdsclient">DSCDS901999102</td>
  </tr>
  <tr class="drcheck">
    <td>Maximum online generations:</td>
    <td class="drcheckval notopborder">29</td>
    <td class="drchecknotes notopborder">notes</td>
  </tr>
  <tr class="drcheck">
    <td>Default Retention Rule set:</td>
    <td class="drcheckval notopborder">30 days</td>
    <td class="drchecknotes notopborder">notes</td>
  </tr>
  <tr class="drcheck">
    <td>Default Backup Schedule set:</td>
    <td class="drcheckval notopborder">Monday to Friday @ 21:00</td>
    <td class="drchecknotes notopborder">notes</td>
  </tr>
</table>

Also note that having incremental object properties isn't a very good idea. A better solution would be to build arrays of the values and place those in the properties of the object. This makes looping over the result much simpler.


问:
Generate log file on app crash android
I am working on a project which will not be published in google play. My client is running it on beta. They says it crashes sometimes, but I was never able to reproduce the scenarios.

So I just want to generate a LOG file when the app crashes. Is it possible to get such events?

i.e When the app forces to close I need to generate a log file with the last few actions ( logcat items) .

答: The best and easiest way to log error to a the phone's storage device I found is this which refers to a tutorial here </p>

Title: Generate log file on app crash android


问:
JSON to XML class conversions
I cannot seem to line up the class of the Json into Linq XML.

The c.first, c.second and the c.third are highlighted and states:

"Are you missing a using directive or assembly reference."

```<code>var serializer = new JavaScriptSerializer();
var json1 = "[count:[place:{first:1,second:2,third:3}],[place:{first:11,second:22,third:33}],[place:{first:111,second:222,third:333}]]]";
var jsons = serializer.Serialize(json1);
var jsona = serializer.Deserialize<List<jClass>>(jsons);
var xmld = new XDocument(
    new XElement("count", jsona.Select(c =>
        new XElement("place",
            new XElement("first", c.first),
            new XElement("second", c.second),
            new XElement("third", c.third)
        )
    ))
);
</code>```

Class.cs

```<code>public class jClass
{
    public jNumber[] count { get; set; }
}
public class jNumber
{
    public jTopThree[] place { get; set; }
}
public class jTopThree
{
    public int first { get; set; }
    public int second { get; set; }
    public int third { get; set; }
}
</code>```

答:
Your problem is that your object structure is essentially an array of array of arrays and you're only doing one Select. Where you're building your xml, your c variable is at the jClass level, so you're trying to read the first, second and third properties from that.

It's unclear what your xml structure should be, but you're either going to need to use a couple more .Select calls to drill down further to the jTopThree instances, use .SelectMany to flatten it out, or change your object definitions up a bit.

Title: JSON to XML class conversions

Body:
I cannot seem to line up the class of the Json into Linq XML.

The c.first, c.second and the c.third are highlighted and states:

"Are you missing a using directive or assembly reference."

var serializer = new JavaScriptSerializer();
var json1 = "[count:[place:{first:1,second:2,third:3}],[place:{first:11,second:22,third:33}],[place:{first:111,second:222,third:333}]]]";
var jsons = serializer.Serialize(json1);
var jsona = serializer.Deserialize<List<jClass>>(jsons);
var xmld = new XDocument(
    new XElement("count", jsona.Select(c =>
        new XElement("place",
            new XElement("first", c.first),
            new XElement("second", c.second),
            new XElement("third", c.third)
        )
    ))
);

Class.cs

public class jClass
{
    public jNumber[] count { get; set; }
}
public class jNumber
{
    public jTopThree[] place { get; set; }
}
public class jTopThree
{
    public int first { get; set; }
    public int second { get; set; }
    public int third { get; set; }
}


问:
android google maps app running on galaxy s, but not on galaxy tab - getting grey tiles
i have developed an android application using google maps. when i deploy the application to a samsung galaxy s handset (runnning on Android 2.1) and also on other handsets running on Android 2.1 everything works fine.
when i change my project to support Android 2.2 i can still deploy the application to the galaxy tablet  (running on Android 2.2). all functionality works there like on the galaxy s (Android 2.1) except the maps integration. when i open the maps on the android 2.2 device i only get grey tiles.

thanks in advance for your help.

br,
martin

答: Create a new map API key for android 2.2 galaxy tablet.</p>

ContentLicense: CC BY-SA 2.5


问:
Mouse Wheel Zooming
so i'm working on a canvas that you can only drag a image from side to side and use the mouse wheel to re size the image by zooming in and out on it here is the code i have so far please feel free to ask any more details. I'm trying to find a way that's compact to do this and require minimum code.</p>

```<code><!DOCTYPE HTML>
<html>
  <head>
    <style>
      body {
        margin: 0px;
        padding: 0px;
      }
    </style>
    <script src="kinetic-v5.1.0.min.js" type="text/javascript"></script>
  </head>
  <body>
    <div id="container"></div>

    <script type="text/javascript">
      function drawImage(imageObj) {
        var stage = new Kinetic.Stage({
          container: "container",
          width: 1800,
          height: 800
        });
        var layer = new Kinetic.Layer();

        // image
        var image1 = new Kinetic.Image({
          image: imageObj,
          x: stage.getWidth() / 2 - 896 / 1,
          y: stage.getHeight() / 2 - 255 / 2,
          width: 200,
          height: 157,
          draggable: true,
          dragBoundFunc: function (pos) {
            if (pos.x < this.minX) { }
            this.minX = pos.x;
            return {
              x: pos.x,
              y: this.getAbsolutePosition().y
            }
          }
        });

        // add cursor styling
        image1.on('mouseover', function() {
          document.body.style.cursor = 'pointer';
        });
        image1.on('mouseout', function() {
          document.body.style.cursor = 'default';
        });

        layer.add(image1);
        stage.add(layer);
      }
      var imageObj = new Image();
      imageObj.onload = function() {
        drawImage(this);
      };
      imageObj.src = 'image1.png';

    </script>
  </body>
</html>
</code>```

答: Try using this full javascript library.</p>

Title: Mouse Wheel Zooming

Body:
so i'm working on a canvas that you can only drag a image from side to side and use the mouse wheel to re size the image by zooming in and out on it here is the code i have so far please feel free to ask any more details. I'm trying to find a way that's compact to do this and require minimum code.

<!DOCTYPE HTML>

Body: Try using this full javascript library.


问:
Read .doc file with python
I got a test for job application, my deal is read some .doc files. Does anyone know a library to do this? I had started with a raw python code:

```<code>f = open('test.doc', 'r')
f.read()
</code>```

but this does not return a friendly string I need to convert it to utf-8

Edit: I just want get the text from this file

答:
One can use the textract library.
It take care of both "doc" as well as "docx"

```<code>import textract
text = textract.process("path/to/file.extension")
</code>```

You can even use 'antiword' (sudo apt-get install antiword) and then convert doc to first into docx and then read through docx2txt.

```<code>antiword filename.doc > filename.docx
</code>```

Ultimately, textract in the backend is using antiword.

Title: Read .doc file with python

Body:
I got a test for job application, my deal is read some .doc files. Does anyone know a library to do this? I had started with a raw python code:

f = open('test.doc', 'r')
f.read()

but this does not return a friendly string I need to convert it to utf-8

Edit: I just want get the text from this file

Body:
One can use the textract library.
It take care of both "doc" as well as "docx"

import textract
text = textract.process("path/to/file.extension")

You can even use 'antiword' (sudo apt-get install antiword) and then convert doc to first into docx and then read through docx2txt.

antiword filename.doc > filename.docx

Ultimately, textract in the backend is using antiword.


问:
Listing all the child nodes of document element
I have a very huge XML file and i want to list down all the child nodes for document element.
I am using the below code which is working fine but it is taking very long time to process the file and also it is getting data from the document element which is not required:

```<code>use XML::Simple;
my $xml = XML::Simple->new();
my $d = $xml->XMLin("sample.xml");
my @arr = keys %$d;
print "@arr\n";
</code>```

Example XML:

```<code>    <?xml version="1.0" encoding="ISO-8859-15"?>
<document version="1.0" createdAt="2017-03-31T11:41:34">
   <TITLE>Computer Parts</TITLE>
   <PART001>
      <ITEM>Motherboard</ITEM>
      <MANUFACTURER>ASUS</MANUFACTURER>
      <MODEL>P3B-F</MODEL>
      <COST> 123.00</COST>
   </PART001>
   <PART002>
      <ITEM>Video Card</ITEM>
      <MANUFACTURER>ATI</MANUFACTURER>
      <MODEL>All-in-Wonder Pro</MODEL>
      <COST> 160.00</COST>
   </PART002>
   <PART003>
      <ITEM>Sound Card</ITEM>
      <MANUFACTURER>Creative Labs</MANUFACTURER>
      <MODEL>Sound Blaster Live</MODEL>
      <COST> 80.00</COST>
   </PART003>
   <PART004>
      <ITEM>14 inch Monitor</ITEM>
      <MANUFACTURER>LG Electronics</MANUFACTURER>
      <MODEL> 995E</MODEL>
      <COST> 290.00</COST>
   </PART004>
</document>
</code>```

Expected Output:
TITLE,
PART001,
PART002,
PART003,
PART004

Can anyone please suggest a faster and better way to get the required output?

答:
You can use XML::Twig which, according to its documentation, is a perl module for processing huge XML documents in tree mode.

Here's an example fitting your use case:

```<code>use feature qw(say);
use XML::Twig;

XML::Twig->new(twig_handlers => {
    'document/*' => sub {
        say $_->name; # print out the element name
        $_->purge; # remove the entire element from memory
    }
})->parsefile('sample.xml');
</code>```

When used with your sample document, this prints out:

```<code>TITLE
PART001
PART002
PART003
PART004
</code>```

Using a streaming parser might be even faster.

Body:
I have a very huge XML file and i want to list down all the child nodes for document element.
I am using the below code which is working fine but it is taking very long time to process the file and also it is getting data from the document element which is not required:

use XML::Simple;
my $xml = XML::Simple->new();
my $d = $xml->XMLin("sample.xml");
my @arr = keys %$d;
print "@arr\n";

Example XML:

    <?xml version="1.0" encoding="ISO-8859-15"?>
<document version="1.0" createdAt="2017-03-31T11:41:34">
   <TITLE>Computer Parts</TITLE>
   <PART001>
      <ITEM>Motherboard</ITEM>
      <MANUFACTURER>ASUS</MANUFACTURER>
      <MODEL>P3B-F</MODEL>
      <COST> 123.00</COST>
   </PART001>
   <PART002>
      <ITEM>Video Card</ITEM>
      <MANUFACTURER>ATI</MANUFACTURER>
      <MODEL>All-in-Wonder Pro</MODEL>
      <COST> 160.00</COST>
   </PART002>
   <PART003>
      <ITEM>Sound Card</ITEM>
      <MANUFACTURER>Creative Labs</MANUFACTURER>
      <MODEL>Sound Blaster Live</MODEL>
      <COST> 80.00</COST>
   </PART003>
   <PART004>
      <ITEM>14 inch Monitor</ITEM>
      <MANUFACTURER>LG Electronics</MANUFACTURER>
      <MODEL> 995E</MODEL>
      <COST> 290.00</COST>
   </PART004>
</document>

Expected Output:
TITLE,
PART001,
PART002,
PART003,
PART004

Can anyone please suggest a faster and better way to get the required output?

Body:
You can use XML::Twig which, according to its documentation, is a perl module for processing huge XML documents in tree mode.

Here's an example fitting your use case:

use feature qw(say);
use XML::Twig;

XML::Twig->new(twig_handlers => {
    'document/*' => sub {
        say $_->name; # print out the element name
        $_->purge; # remove the entire element from memory
    }
})->parsefile('sample.xml');

When used with your sample document, this prints out:

TITLE
PART001
PART002
PART003
PART004

Using a streaming parser might be even faster.


问:
Providing custom filename is not working in table2excel jquery?
i have used jquery code to export table data into excel file, got code from here

but providing custome file name is not working it is taking random filename.

how to provide custom file name from code.

```<code><script>
$(function() {
        $("button").click(function(){
        $("#example").table2excel({
                exclude: ".noExl",
        name: "Employee"
        });
         });
});
</script>
</code>```

答:
1.Open jquery.table2excel.js

2.Find function getFileName(settings)

3.Change it to

```<code>function getFileName(settings) {
        return ( settings.filename ? settings.filename : settings.name ) +
               ( settings.fileext ? settings.fileext : ".xls" );
}
</code>```

settings.name is variable from your custom js scripts when u call jquery2excel
In my example it looks like

```<code>$(".generateXLS").click(function(){
    var idOfTable = $(this).attr("data-rel");
    var tableName = $(this).attr("data-table-name");
    $("#tableN"+idOfTable).table2excel({
        name: tableName
    });
});
</code>```

Body:
1.Open jquery.table2excel.js

2.Find function getFileName(settings)

3.Change it to

function getFileName(settings) {
        return ( settings.filename ? settings.filename : settings.name ) +
               ( settings.fileext ? settings.fileext : ".xls" );
}

settings.name is variable from your custom js scripts when u call jquery2excel
In my example it looks like

$(".generateXLS").click(function(){
    var idOfTable = $(this).attr("data-rel");
    var tableName = $(this).attr("data-table-name");
    $("#tableN"+idOfTable).table2excel({
        name: tableName
    });
});


问:
Subclassing foreign Service does not work
I'm trying to subclassing the FileCollectionService class from third party extension. But it takes not place.

ext_typoscript_setup.txt:

```<code>config.tx_extbase{
persistence{
    classes{
        SKYFILLERS\SfFilecollectionGallery\Service\FileCollectionService {
            subclasses {
                TxFileCollectionService = FalkRoeder\MyExt\Service\FileCollectionService
            }
        }

    }
}
</code>```

}

my FileCollectionService.php put in Classes/Service

```<code><?php
namespace FalkRoeder\MyExt\Service;

/**
 * FileCollectionService
 */
class FileCollectionService extends \SKYFILLERS\SfFilecollectionGallery\Service\FileCollectionService {

    /**
     * @return array
     */
    public function methodToOverwrite() {
    ...
    }
}
</code>```

答:
to get it work, I needed to add the following code to ext_typoscript_setup.txt:</p>

```<code>config.tx_extbase {
    objects {
        SKYFILLERS\SfFilecollectionGallery\Service\FileCollectionService.className = FalkRoeder\MyExt\Service\FileCollectionService
    }
}
</code>```

Body:
I'm trying to subclassing the FileCollectionService class from third party extension. But it takes not place.

ext_typoscript_setup.txt:

config.tx_extbase{
persistence{
    classes{
        SKYFILLERS\SfFilecollectionGallery\Service\FileCollectionService {
            subclasses {
                TxFileCollectionService = FalkRoeder\MyExt\Service\FileCollectionService
            }
        }

    }
}

}

my FileCollectionService.php put in Classes/Service

<?php
namespace FalkRoeder\MyExt\Service;

/**
 * FileCollectionService
 */
class FileCollectionService extends \SKYFILLERS\SfFilecollectionGallery\Service\FileCollectionService {

    /**
     * @return array
     */
    public function methodToOverwrite() {
    ...
    }
}

Body:
to get it work, I needed to add the following code to ext_typoscript_setup.txt:

config.tx_extbase {
    objects {
        SKYFILLERS\SfFilecollectionGallery\Service\FileCollectionService.className = FalkRoeder\MyExt\Service\FileCollectionService
    }
}


问:
What is a steam trade URL
I am new to steam API. I have been tasked to create a trade bot for a website which will use this to do steam trades, for example accept trade, offer, reject etc. Due to lack of good documentation of Steam, I am struggling to gather basic information actually.

So I want to understand these things:-

What is a trade URL?

How can the bot be able to do transaction on a user's behalf, i mean it's expected to make the transaction from bot's steam account for let's say accepting a trade offer made to a steam user with steamid 111 from another steam user with steamid 222? How it can be done?

Any information will be really helpful!

答:
I found realy nice documentation for Steam API.
You can find it here.

Also, nice resouce SteamDatabase/SteamTracking.

You can check Steam Service status using this service.

NodeJs library Tewki/CSGO-Item-Floats-From-Inspect-Links to work with Steam API.

Hopefully, this information will be usefull.

Good luck.

Title: What is a steam trade URL


问:
office access substrac values from each row in one field
Please help, how to substract values in one field from one row to another, for example:

I want it become like this:

答:
The way you have data stored could make this impossible because there is no way to distinguish which records should be subtracted from which records. That is assuming there will be more than one record considered a positive (increase) entry. Options:

Another field that identifies record as either Increase or Decrease

Enter the values to be subtracted as negatives

Regardless of which you choose, a report is the easiest way to show a running balance because textbox on report has RunningSum property.

But if these records are not incoming and outgoing transactions and what you really want is for each record to get value from previous and subtract, then review Stackoverlow - get previous value

Why do you name fields with Kmh/mph, those values are obviously not Kmh/mph, they look like odometer readings. Better field names may be OldOdometer, NewOdometer. However odometer readings would increase, not decrease. Why do you need to add new to old? Just what is this data?


问:
how to prevent  background overlapping other text
i need to create a text withs some markings that need to look a bit customized ( using an image )

i used the background-property and padding like so:

```<code>mark{
    padding:10px;
    background:url(http://www.fillmurray.com/200/300);
    background-repeat: no-repeat;
}
</code>```

which works as planned, but the backgroundimage is obscuring the previous text-line.
adding a z-index also did not work.
see fiddle:
fiddlelyfidd

any ideas on how to send it to the back?

thanks

答:
You can use css declaration background-clip: content-box.

Moreover, padding and z-index may be useless.
Please see below.

body{
  background-color:#666666;
  color:white;
}

mark{
  /*z-index:-10;*/
  /*padding:10px;*/
  background:url('http://www.fillmurray.com/200/300');
  background-repeat: no-repeat;
  background-clip: content-box;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><p>
“Higher up now we mark the gony, or gray albatross, anomalously so called, an unsightly, <mark>unpoetic bird, unlike its storied kinsman, which is the snow-white ghost</mark> of the haunted Capes of Hope and Horn.”

Excerpt From: Melville, Herman. “Billy Budd and Other Stories.” iBooks.
</p></code>```

Title: how to prevent <mark> background overlapping other text

Body:
i need to create a text withs some markings that need to look a bit customized ( using an image )

i used the background-property and padding like so:

mark{
    padding:10px;
    background:url(http://www.fillmurray.com/200/300);
    background-repeat: no-repeat;
}

which works as planned, but the backgroundimage is obscuring the previous text-line.
adding a z-index also did not work.
see fiddle:
fiddlelyfidd

any ideas on how to send it to the back?

thanks

Body:
You can use css declaration background-clip: content-box.

Moreover, padding and z-index may be useless.
Please see below.

body{
  background-color:#666666;
  color:white;
}

mark{
  /*z-index:-10;*/
  /*padding:10px;*/
  background:url('http://www.fillmurray.com/200/300');
  background-repeat: no-repeat;
  background-clip: content-box;
}

<p>
“Higher up now we mark the gony, or gray albatross, anomalously so called, an unsightly, <mark>unpoetic bird, unlike its storied kinsman, which is the snow-white ghost</mark> of the haunted Capes of Hope and Horn.”

Excerpt From: Melville, Herman. “Billy Budd and Other Stories.” iBooks.
</p>


问:
Fancybox - ASP.NET button not working
I've just determined using Firebug that when Fancybox window is created it actually takes all of my ASP.NET controls (contained in DIV tag) and puts them outside FORM tag. So I guess this is the reason why then ASP.NET button doesn't do anything - it is placed outside form.

So, do you have any suggestions how I can prevent this (or make that ASP.NET button work), other than using completely different modal dialog?

EDIT: OK, people are reporting that some of the proposed fixes are working for them on certain versions. So, be sure to read all of the answers / scroll to the bottom for how to fix this issue on different Fancybox versions.

答:
You don't need to change any code or any library... Just try this..</p>

```<code>$('.fancybox').fancybox({
     parent: "form:first", // jQuery selector
});
</code>```

Title: Fancybox - ASP.NET button not working

Body:
You don't need to change any code or any library... Just try this..

$('.fancybox').fancybox({
     parent: "form:first", // jQuery selector
});


问:
using Highcharters in R with Shiny, control highstock chart height failed
I called highchart with height parameter to make a taller chart successfully in RStudio:

```<code>chart <- highchart(type = "stock", height=800, ...)
</code>```

When in Shiny, the chart shown up but ignore the height parameter. Is there any way to fix it ?

答:
Try this:

```<code>library(quantmod)
library(highcharter)
x <- getSymbols("GOOG", auto.assign = FALSE)

a <- hchart(x)
a$width <- 450
a$height <- 300
a
</code>```

Body:
I called highchart with height parameter to make a taller chart successfully in RStudio:

chart <- highchart(type = "stock", height=800, ...)

When in Shiny, the chart shown up but ignore the height parameter. Is there any way to fix it ?

Body:
Try this:

library(quantmod)
library(highcharter)
x <- getSymbols("GOOG", auto.assign = FALSE)

a <- hchart(x)
a$width <- 450
a$height <- 300
a


问:
Sending mail with Rails 3 in development environment
I'm sure this has been asked a million times before but I can't find anything that works for me so I'm asking again!

I just need a way of sending emails using ActionMailer in rails 3.  I have followed numerous tutorials including the Railscasts tutorial on the new ActionMailer and I can see the mails being generated but I don't receive them.

I have tried a bunch of different ways but they generally amount to configuring the following settings

```<code>ActionMailer::Base.delivery_method = :smtp

ActionMailer::Base.smtp_settings = {
  :address              => "smtp.gmail.com",
  :port                 => "587",
  :domain               => "gmail.com",
  :user_name            => "xxx@gmail.com",
  :password             => "yyy",
  :authentication       => "plain",
  :enable_starttls_auto => true
}
</code>```

I have tried the above code (with valid gmail details of course) in my config/environment.rb, config/environments/development.rb and currently have it in its own initialiser config/initialisers/setup_mail.rb

I have also tried with a few different smtp servers including Gmail and Sendgrid, adjusting the smtp settings accordingly but still nothing.  I can see the mail in the terminal and the development log and that's it.

Does anyone know of any other gotcha's that I may have missed that need to be setup for ActionMailer to work?  Failing that is there a way of getting more information about why the mails aren't being sent? I have

```<code>config.action_mailer.raise_delivery_errors = true
</code>```

set in my config/development.rb but the development log still just shows the same as I see in the terminal.

For what it's worth, I am developing on a Ubuntu 10.04 laptop just in case there's any specific setup needed for that.

Many thanks

答:
Try using 'sendmail' instead of 'smtp'.</p>

```<code>ActionMailer::Base.delivery_method = :sendmail
ActionMailer::Base.sendmail_settings = {
  :address              => "smtp.gmail.com",
  :port                 => "587",
  :domain               => "gmail.com",
  :user_name            => "xxx@gmail.com",
  :password             => "yyy",
  :authentication       => "plain",
  :enable_starttls_auto => true
}
</code>```

Body:
I'm sure this has been asked a million times before but I can't find anything that works for me so I'm asking again!

I just need a way of sending emails using ActionMailer in rails 3.  I have followed numerous tutorials including the Railscasts tutorial on the new ActionMailer and I can see the mails being generated but I don't receive them.

I have tried a bunch of different ways but they generally amount to configuring the following settings

ActionMailer::Base.delivery_method = :smtp

ActionMailer::Base.smtp_settings = {
  :address              => "smtp.gmail.com",
  :port                 => "587",
  :domain               => "gmail.com",
  :user_name            => "xxx@gmail.com",
  :password             => "yyy",
  :authentication       => "plain",
  :enable_starttls_auto => true
}

I have tried the above code (with valid gmail details of course) in my config/environment.rb, config/environments/development.rb and currently have it in its own initialiser config/initialisers/setup_mail.rb

I have also tried with a few different smtp servers including Gmail and Sendgrid, adjusting the smtp settings accordingly but still nothing.  I can see the mail in the terminal and the development log and that's it.

Does anyone know of any other gotcha's that I may have missed that need to be setup for ActionMailer to work?  Failing that is there a way of getting more information about why the mails aren't being sent? I have

config.action_mailer.raise_delivery_errors = true

set in my config/development.rb but the development log still just shows the same as I see in the terminal.

For what it's worth, I am developing on a Ubuntu 10.04 laptop just in case there's any specific setup needed for that.

Many thanks

Body:
Try using 'sendmail' instead of 'smtp'.

ActionMailer::Base.delivery_method = :sendmail
ActionMailer::Base.sendmail_settings = {
  :address              => "smtp.gmail.com",
  :port                 => "587",
  :domain               => "gmail.com",
  :user_name            => "xxx@gmail.com",
  :password             => "yyy",
  :authentication       => "plain",
  :enable_starttls_auto => true
}


问:
How to avoid memory leaks when MATLAB function inside parfor generates warning?
I use matlab R2015b for Win Server 2012 OS with local parpool. I have memory leaks on local workers when function inside parfor-loop generate warning. Also memory is not released after parfor-loop ends. Example:

```<code>x = rand(78, 1);
for j = 1:100
    parfor i = 1:1000
        [~, z] = kpsstest(x);
    end
end
</code>```

function kpsstest generates warning:

Warning: Test statistic #1 below tabulated critical values:
maximum p-value = 0.100 reported.
 In kpsstest>getStat (line 632)
 In kpsstest (line 291)

Memory leaks on workers even when i use constructions:

```<code>   warning('off', 'econ:kpsstest:StatTooSmall');
   pctRunOnAll warning('off', 'econ:kpsstest:StatTooSmall')
</code>```

Memory on start workers:

Memory on after executing code:

How to avoid memory leaks when function inside parfor generates warning?

Thank you.

答: This problem is the subject of this  bug report. If you are able to upgrade to R2017a, that's the simplest workaround.</p>

Body:
I use matlab R2015b for Win Server 2012 OS with local parpool. I have memory leaks on local workers when function inside parfor-loop generate warning. Also memory is not released after parfor-loop ends. Example:

x = rand(78, 1);
for j = 1:100
    parfor i = 1:1000
        [~, z] = kpsstest(x);
    end
end

function kpsstest generates warning:

Warning: Test statistic #1 below tabulated critical values:
maximum p-value = 0.100 reported.
 In kpsstest>getStat (line 632)
 In kpsstest (line 291)

Memory leaks on workers even when i use constructions:

   warning('off', 'econ:kpsstest:StatTooSmall');
   pctRunOnAll warning('off', 'econ:kpsstest:StatTooSmall')

Memory on start workers:

Memory on after executing code:

How to avoid memory leaks when function inside parfor generates warning?

Thank you.


问:
XCode Target Duplication via Code
Does anyone know a tried and tested way of duplicating XCode targets programatically?

I've tried this Gist based on the xcodeproj Ruby gem but it doesn't copy all the settings (like it would do if doing it through the XCode UI)

https://gist.github.com/ratazzi/f6d9217654d6605450a0

答:
For anyone reading I've actually taken a different approach with this.

Rather than duplicating targets and changing specific values I've utilised fastlane an in particular the 'set_info_plist' function to change values at build time that are specific to a target.

https://docs.fastlane.tools/actions/#set_info_plist_value

This is useful for things like theming changes as per the build or Free/Paid applications environments where you want one single code base that behaves differently depending on the theme or nature of the application.

Title: XCode Target Duplication via Code


问:
VS 2017 does not allow scrolling of the Error List
Visual Studio 2017 seems to have a new "Feature" where you can not use the scroll bars to scroll through errors, warnings and/or messages, unless you click on one and use the the keyboard up/down arrow. The scroll bar will scroll, but wait a second or two and it will immediately scroll back to an error list line that is currently highlighted.

Does anyone know how to disable this "Feature"?

答:
Same problem here; I suppose this is a bug, not a feature. I reported the problem to the Visual Studio dev team:

https://developercommunity.visualstudio.com/content/problem/38280/vs-2017-does-not-allow-scrolling-of-the-error-list.html

Update (2017-04-06): According to the above link, the bug is fixed in an upcoming release.

Update (2017-11-10): For the record, the bug is fixed in the VS 2017.3 release.


问:
Matlab - Latex interpreter in array of strings
I need to make subplots with different values in the title strings, for that I use num2str and compose a new string.

So this is the function I use currently, however, I want Matlab to use the latex interpreter

```<code>title(['x_{c}(t) = cos(2\pi' num2str(f(j)) ')}'])
</code>```

When I try to use

```<code>title(['x_{c}(t) = cos(2\pi' num2str(f(j)) ')}'], 'Interpreter', 'Latex')
</code>```

It doesn't work either.

How do I use the interpreter in that manner ?

答:
Oh, its not the interpreter wrong, its just your Latex is wrong.

You have an extra }, there is no space between the \pi and the number and you are not using equation notation $ $

```<code>title(['$x_{c}(t) = cos(2\pi ' num2str(f(j)) ')$'], 'Interpreter', 'Latex')
</code>```

Body:
I need to make subplots with different values in the title strings, for that I use num2str and compose a new string.

So this is the function I use currently, however, I want Matlab to use the latex interpreter

title(['x_{c}(t) = cos(2\pi' num2str(f(j)) ')}'])

When I try to use

title(['x_{c}(t) = cos(2\pi' num2str(f(j)) ')}'], 'Interpreter', 'Latex')

It doesn't work either.

How do I use the interpreter in that manner ?

Body:
Oh, its not the interpreter wrong, its just your Latex is wrong.

You have an extra }, there is no space between the \pi and the number and you are not using equation notation $ $

title(['$x_{c}(t) = cos(2\pi ' num2str(f(j)) ')$'], 'Interpreter', 'Latex')


问:
Shell access to Persistent Volume in Google Cloud
I would like to get shell access to the Persistent Volume I created on the Google Cloud Platform.

I tried using Google Cloud Shell for this. But to be able to do that I need to attach the Persistent Volume through the gcloud commands, and the command requires the instance name. But I don't see the instance name of the Google Cloud Shell when I list the instance names (in gcloud).

Is it possible to get shell access over Google Cloud Shell to the persistent disks? If not how can I get access to the Persistent Volume that I created?

答:
Yes, all disks need to be attached to an instance to allow access to them - you will need to create a compute instance and mount the persistent disk with gcloud compute instances attach-disk [INSTANCE_NAME] --disk [DISK_NAME].

Once you create the new instance the instance name will become visible to you for usage by running gcloud compute instances list

You will then be able to access the disk by ssh'ing into the instance and mounting it.

The following will help with mounting:

https://cloud.google.com/compute/docs/disks/add-persistent-disk


问:
How to select irregular shapes in a image
Using python code we are able to create image segments as shown in the screenshot. our requirement is how to select specific segment in the image and apply different color to it ?

The following is our python snippet

```<code>from skimage.segmentation import felzenszwalb, slic,quickshift

from skimage.segmentation import mark_boundaries

from skimage.util import img_as_float

import matplotlib.pyplot as plt

from skimage import measure

from skimage import restoration

from skimage import img_as_float

image = img_as_float(io.imread("leaf.jpg"))
segments = quickshift(image, ratio=1.0, kernel_size=20, max_dist=10,return_tree=False, sigma=0, convert2lab=True, random_seed=42)

fig = plt.figure("Superpixels -- %d segments" % (500))
ax = fig.add_subplot(1, 1, 1)

ax.imshow(mark_boundaries(image, segments))

plt.axis("off")
plt.show()
</code>```

答:
do this:</p>

```<code>seg_num = 64 # desired segment to be colored
color = float64([1,0,0]) # red color
image[segments == 64] = color # assign color to the segment
</code>```

Body:
Using python code we are able to create image segments as shown in the screenshot. our requirement is how to select specific segment in the image and apply different color to it ?

The following is our python snippet

from skimage.segmentation import felzenszwalb, slic,quickshift

from skimage.segmentation import mark_boundaries

from skimage.util import img_as_float

import matplotlib.pyplot as plt

from skimage import measure

from skimage import restoration

from skimage import img_as_float

image = img_as_float(io.imread("leaf.jpg"))
segments = quickshift(image, ratio=1.0, kernel_size=20, max_dist=10,return_tree=False, sigma=0, convert2lab=True, random_seed=42)

fig = plt.figure("Superpixels -- %d segments" % (500))
ax = fig.add_subplot(1, 1, 1)

ax.imshow(mark_boundaries(image, segments))

plt.axis("off")
plt.show()

Body:
do this:

seg_num = 64 # desired segment to be colored
color = float64([1,0,0]) # red color
image[segments == 64] = color # assign color to the segment


答:
You could squeeze the array, removing the single-entry dimension:

```<code>b = np.squeeze(b)
</code>```

Although, it's more efficient to just concatenate and take the transpose:

```<code>print(timeit.timeit(lambda: np.concatenate(arrays,axis=0).T, number=100))
print(timeit.timeit(lambda: np.squeeze(np.dstack(arrays)), number=100))

# 0.024745813333333335
# 0.07166506666666667
</code>```

Title: How to Stack arrays in sequence depth wise with only 2 dimention

Body:
I used np.dstack in Python for stack arrays in 3D but the shape will look like this

a = np.sin(np.cumsum((np.random.normal(scale=0.1, size=(len(x), 12))), axis=0))
b = np.dstack((nlead1,nlead2,nlead3,nlead4,nlead5,nlead6,nlead7,nlead8,nlead9,nlead10,nlead11,nlead12))

print a
print a.shape
print b
print b.shape

the output is look like

[[ 0.16172117 -0.06113749 -0.05279262 ..., -0.02493445  0.14569041
  -0.20455989]
 [ 0.12982533 -0.09941658  0.06052276 ...,  0.08941575  0.23417498
  -0.15513552]
 [ 0.21850132 -0.16716535  0.048252   ...,  0.00501475  0.16843843
  -0.15638653]
 ...,
 [ 0.6436674   0.04253489 -0.58825104 ..., -0.95674562  0.36004254
   0.41308711]
 [ 0.6193386  -0.00224555 -0.56129994 ..., -0.90884016  0.31269762
   0.26443869]
 [ 0.63100264 -0.03888419 -0.61395087 ..., -0.92910613  0.42215252
   0.1646122 ]]
(5500, 12)
[[[ -39   47   86 ..., -100  -77   -3]
  [ -34   50   85 ..., -101  -75   -1]
  [ -36   49   86 ..., -103  -77   -4]
  ...,
  [   0    0    0 ...,    0    0    0]
  [   0    0    0 ...,    0    0    0]
  [   0    0    0 ...,    0    0    0]]]
(1, 5500, 12)

I want to makes the shape of b like a, could you give me some suggestion thank you very much.

Body:
You could squeeze the array, removing the single-entry dimension:

b = np.squeeze(b)

Although, it's more efficient to just concatenate and take the transpose:

print(timeit.timeit(lambda: np.concatenate(arrays,axis=0).T, number=100))
print(timeit.timeit(lambda: np.squeeze(np.dstack(arrays)), number=100))

# 0.024745813333333335
# 0.07166506666666667


问:
Chrome extension not working after chrome update to Version 57.0.2987.133 (64-bit)
After recent update of chrome browser to Version 57.0.2987.133 (64-bit)
my extension stopped working.Following is the explanation of the working on extension:

Popup.js

document.addEventListener('DOMContentLoaded', function() {
    chrome.tabs.getSelected(null, function(tab) {
      d = document;
      var f = d.createElement('form');
      f.action = 'https://example.com/login';
      f.method = 'post';
      var i = d.createElement('input');
      i.type = 'hidden';
      i.name = 'url';
      i.value = tab.url;
      console.log(tab.url);
      f.appendChild(i);
      d.body.appendChild(f);
      f.submit();
    });
});```
</div>
</div>
</p>

<ul>
<li><strong>popup.html</strong></li>
</ul>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code><!doctype html>
<html>
  <head>

    <script type="text/javascript" src="jquery-2.1.1.js"></script>
    <script src="popup.js"></script>
    <style type="text/css">
    .image {
        display: block;
        margin-left: auto;
        margin-right: auto
    }
    </style>
  </head>
  <body style="width: 350px;height:340px;">

    <h3>Connecting to server please wait ...</h3>
    <br/>
    <br/>
    <br/>
    <img src="/loader.gif" alt="Please Wait" class="image" align="middle">
  </body>
</html></code>```

manifest.json

{
"update_url": "https://clients2.google.com/service/update2/crx",

  "manifest_version": 2,
  "name": "test name",
  "description": "test description",
  "version": "0.1.2",

  "browser_action": {
   "default_icon": "128.png",
   "default_popup": "popup.html"
  },
  "icons": {
      "16": "128.png",
      "32": "128.png",
      "64": "128.png",
      "128": "128.png"
  },
  "background": {
    "scripts": ["background.js"],
    "persistent": false
  },

  "web_accessible_resources": [ "128.png" ],

  "permissions": [
    "tabs"
   ]
}```

Before the chrome update, extension was working fine.

- I am submitting a form with post method.

- I am sending a key 'url' which I am checking on server site if the request is from extension and thus loading login form for extension.
 - Once the extension login loads into the popup, user logs in and is redirected to appropriate page within the popup.

This is the flow of extension. But after the update, Loading continues on popup. The form submit request is being cancelled by the browser. On googling about the problem, I found using ajax post method for submitting the form instead of direct form submit. This method was able to fetch the login form from but that without any css and js of the webpage as the urls were relative in the page and chrome extension id was prepended as the base url with all the links. So, I changed those urls to absolute but the submit functionality was not working again as it was again a form. Again I changed the form submit into ajax post submit request on server side. But the javascript written over the webpage is not working in chrome extension.
So question is how to make the extension work which was working earlier?

答:
chrome.tabs.getSelected() is deprecated since Chrome 33. try using chrome.tabs.query({ active: true }) like this:

```<code>document.addEventListener('DOMContentLoaded', function() {
    chrome.tabs.query({ active: true }, function(tabs) {
      var tab = tabs[ 0 ];
      d = document;
      var f = d.createElement('form');
      f.action = 'https://example.com/login';
      f.method = 'post';
      var i = d.createElement('input');
      i.type = 'hidden';
      i.name = 'url';
      i.value = tab.url;
      console.log(tab.url);
      f.appendChild(i);
      d.body.appendChild(f);
      f.submit();
    });
});
</code>```

Body:
After recent update of chrome browser to Version 57.0.2987.133 (64-bit)
my extension stopped working.Following is the explanation of the working on extension:

Popup.js

document.addEventListener('DOMContentLoaded', function() {
    chrome.tabs.getSelected(null, function(tab) {
      d = document;
      var f = d.createElement('form');
      f.action = 'https://example.com/login';
      f.method = 'post';
      var i = d.createElement('input');
      i.type = 'hidden';
      i.name = 'url';
      i.value = tab.url;
      console.log(tab.url);
      f.appendChild(i);
      d.body.appendChild(f);
      f.submit();
    });
});

popup.html

<!doctype html>

Connecting to server please wait ...

manifest.json

{
"update_url": "https://clients2.google.com/service/update2/crx",

  "manifest_version": 2,
  "name": "test name",
  "description": "test description",
  "version": "0.1.2",

  "browser_action": {
   "default_icon": "128.png",
   "default_popup": "popup.html"
  },
  "icons": {
      "16": "128.png",
      "32": "128.png",
      "64": "128.png",
      "128": "128.png"
  },
  "background": {
    "scripts": ["background.js"],
    "persistent": false
  },

  "web_accessible_resources": [ "128.png" ],

  "permissions": [
    "tabs"
   ]
}

Before the chrome update, extension was working fine.

- I am submitting a form with post method.

- I am sending a key 'url' which I am checking on server site if the request is from extension and thus loading login form for extension.
 - Once the extension login loads into the popup, user logs in and is redirected to appropriate page within the popup.

This is the flow of extension. But after the update, Loading continues on popup. The form submit request is being cancelled by the browser. On googling about the problem, I found using ajax post method for submitting the form instead of direct form submit. This method was able to fetch the login form from but that without any css and js of the webpage as the urls were relative in the page and chrome extension id was prepended as the base url with all the links. So, I changed those urls to absolute but the submit functionality was not working again as it was again a form. Again I changed the form submit into ajax post submit request on server side. But the javascript written over the webpage is not working in chrome extension.
So question is how to make the extension work which was working earlier?

Body:
chrome.tabs.getSelected() is deprecated since Chrome 33. try using chrome.tabs.query({ active: true }) like this:

document.addEventListener('DOMContentLoaded', function() {
    chrome.tabs.query({ active: true }, function(tabs) {
      var tab = tabs[ 0 ];
      d = document;
      var f = d.createElement('form');
      f.action = 'https://example.com/login';
      f.method = 'post';
      var i = d.createElement('input');
      i.type = 'hidden';
      i.name = 'url';
      i.value = tab.url;
      console.log(tab.url);
      f.appendChild(i);
      d.body.appendChild(f);
      f.submit();
    });
});