问:
Generic Method with Rest Template on List Return Type?
I'm trying to create a generic rest template method. The goal is to deserialize to a generic type, even if the type is parameterized. Unfortunately, when I try and deserialize, I get a list of hash maps or something similar. The type gets lost. Here's our code:

```<code>public List<UserValueDTO> getUserDetails() throws Exception {
    return getResponse("/user/details");
}

private <T> T getResponse(String endpoint) throws Exception {
    String token = authenticationService.getToken();
    LinkedMultiValueMap<String, String> headers = new LinkedMultiValueMap<>();
    headers.add("Authorization",  "Bearer " + token);
    HttpEntity<?> httpEntity = new HttpEntity<>(null, headers);
    try {
        ResponseEntity<T> response = restTemplate.exchange(baseUrl + endpoint,
                HttpMethod.GET, httpEntity, new ParameterizedTypeReference<T> {});
        return response.getBody();
    } catch (HttpClientErrorException ex) {
        throw new Exception("Unable to get a response from service");
    }
}
</code>```

We also wrote an automated test that reveals the problem. Here's the test.

```<code>@Test
public void requestUserDetails_getsUserDetailsFromExternalService() throws Exception {
    doReturn("abcdefg-123456").when(mockAuthenticationService).getToken();

    server.expect(requestTo("http://localhost:8090/user/details"))
            .andExpect(method(HttpMethod.GET))
            .andExpect(header("Authorization", "Bearer abcdefg-123456"))
            .andRespond(withSuccess("[\n" +
                    "  {\n" +
                    "    \"userId\": 12345,\n" +
                    "    \"value\": 500.0\n" +
                    "  },\n" +
                    "  {\n" +
                    "    \"userId\": 5555,\n" +
                    "    \"value\": 300.0\n" +
                    "  }\n" +
                    "]", MediaType.APPLICATION_JSON));

    List<UserValueDTO> userValueDTOs = accountServiceClient.getUserDetails();

    assertThat(userValueDTOs).containsExactlyInAnyOrder(
            new UserValueDTO.Builder().userId(12345).value(500.0).build(),
            new UserValueDTO.Builder().userId(5555).value(300.0).build()
    );
}
</code>```

And the result of this test when run against this code is:

```<code>java.lang.AssertionError:
Expecting:
   <[{"userId"=12345, "value"=500.0}, {"userId"=5555, "value"=300.0}]>
to contain exactly in any order:
   <[com.project.dto.UserValueDTO@408516e7,
     com.project.dto.UserValueDTO@407560ad]>
elements not found:
  <[com.project.dto.UserValueDTO@408516e7,
    com.project.dto.UserValueDTO@407560ad]>
and elements not expected:
  <[{"userId"=12345, "value"=500.0}, {"userId"=5555, "value"=300.0}]>
</code>```

Is there a way to not lose the parameterized type on the list when deserializing? Thanks!

答:
Based on our exchange in the comments, the issue is the use of new ParameterizedTypeReference<T>() {}. The reason this doesn't work has to do with how these type token/type reference/etc. objects work. (This was originally described in Neal Gafter's blog post here.)

```<code>abstract class TypeRefExample<T> {
    final Type typeOfT;

    TypeRefExample() {
        // Get the extending subclass.
        // (Usually an anonymous class like TypeRefExample<String>() {}.)
        Class<?> subclass = getClass();
        // Get the generic superclass, which is the type
        // in the extends clause.
        // This can be explicit like:
        //  class FooTypeRef extends TypeRefExample<Foo> {}
        // or implicit as in the case of an anonymous class:
        //  new TypeRefExample<Foo>() {}
        // which declares a class something like:
        //  class OuterClass$1 extends TypeRefExample<Foo> {}
        Type superclass = subclass.getGenericSuperclass();
        // Then if the superclass is a ParameterizedType
        // its type argument can be retrieved.
        typeOfT = ((ParameterizedType) superclass)
                    .getActualTypeArguments()[0];
        // A real implementation should do some more
        // work but that's the basic idea.
    }
}
</code>```

So if you have a new ParameterizedTypeReference<T>() {} then getClass().getGenericSuperclass() returns the type in the implicit extends clause, which is ParameterizedTypeReference<T> and whose type argument is the type variable T.

If the use of this ParameterizedTypeReference is critical to getting the test to work, then you have to pass it in as an argument, unfortunately. It has to be created with an actual type argument new ParameterizedTypeReference<List<UserValueDTO>>() {}.

Guava TypeToken has some bells and whistles for resolving type variables which are declared on a class, but doing the same for type variables declared on a method is actually impossible because there's no way to reify the type argument to a method at the call site.

Body:
I'm trying to create a generic rest template method. The goal is to deserialize to a generic type, even if the type is parameterized. Unfortunately, when I try and deserialize, I get a list of hash maps or something similar. The type gets lost. Here's our code:

public List<UserValueDTO> getUserDetails() throws Exception {
    return getResponse("/user/details");
}

private <T> T getResponse(String endpoint) throws Exception {
    String token = authenticationService.getToken();
    LinkedMultiValueMap<String, String> headers = new LinkedMultiValueMap<>();
    headers.add("Authorization",  "Bearer " + token);
    HttpEntity<?> httpEntity = new HttpEntity<>(null, headers);
    try {
        ResponseEntity<T> response = restTemplate.exchange(baseUrl + endpoint,
                HttpMethod.GET, httpEntity, new ParameterizedTypeReference<T> {});
        return response.getBody();
    } catch (HttpClientErrorException ex) {
        throw new Exception("Unable to get a response from service");
    }
}

We also wrote an automated test that reveals the problem. Here's the test.

@Test
public void requestUserDetails_getsUserDetailsFromExternalService() throws Exception {
    doReturn("abcdefg-123456").when(mockAuthenticationService).getToken();

    server.expect(requestTo("http://localhost:8090/user/details"))
            .andExpect(method(HttpMethod.GET))
            .andExpect(header("Authorization", "Bearer abcdefg-123456"))
            .andRespond(withSuccess("[\n" +
                    "  {\n" +
                    "    \"userId\": 12345,\n" +
                    "    \"value\": 500.0\n" +
                    "  },\n" +
                    "  {\n" +
                    "    \"userId\": 5555,\n" +
                    "    \"value\": 300.0\n" +
                    "  }\n" +
                    "]", MediaType.APPLICATION_JSON));

    List<UserValueDTO> userValueDTOs = accountServiceClient.getUserDetails();

    assertThat(userValueDTOs).containsExactlyInAnyOrder(
            new UserValueDTO.Builder().userId(12345).value(500.0).build(),
            new UserValueDTO.Builder().userId(5555).value(300.0).build()
    );
}

And the result of this test when run against this code is:

java.lang.AssertionError:
Expecting:
   <[{"userId"=12345, "value"=500.0}, {"userId"=5555, "value"=300.0}]>
to contain exactly in any order:
   <[com.project.dto.UserValueDTO@408516e7,
     com.project.dto.UserValueDTO@407560ad]>
elements not found:
  <[com.project.dto.UserValueDTO@408516e7,
    com.project.dto.UserValueDTO@407560ad]>
and elements not expected:
  <[{"userId"=12345, "value"=500.0}, {"userId"=5555, "value"=300.0}]>

Is there a way to not lose the parameterized type on the list when deserializing? Thanks!

Body:
Based on our exchange in the comments, the issue is the use of new ParameterizedTypeReference<T>() {}. The reason this doesn't work has to do with how these type token/type reference/etc. objects work. (This was originally described in Neal Gafter's blog post here.)

abstract class TypeRefExample<T> {
    final Type typeOfT;

    TypeRefExample() {
        // Get the extending subclass.
        // (Usually an anonymous class like TypeRefExample<String>() {}.)
        Class<?> subclass = getClass();
        // Get the generic superclass, which is the type
        // in the extends clause.
        // This can be explicit like:
        //  class FooTypeRef extends TypeRefExample<Foo> {}
        // or implicit as in the case of an anonymous class:
        //  new TypeRefExample<Foo>() {}
        // which declares a class something like:
        //  class OuterClass$1 extends TypeRefExample<Foo> {}
        Type superclass = subclass.getGenericSuperclass();
        // Then if the superclass is a ParameterizedType
        // its type argument can be retrieved.
        typeOfT = ((ParameterizedType) superclass)
                    .getActualTypeArguments()[0];
        // A real implementation should do some more
        // work but that's the basic idea.
    }
}

So if you have a new ParameterizedTypeReference<T>() {} then getClass().getGenericSuperclass() returns the type in the implicit extends clause, which is ParameterizedTypeReference<T> and whose type argument is the type variable T.

If the use of this ParameterizedTypeReference is critical to getting the test to work, then you have to pass it in as an argument, unfortunately. It has to be created with an actual type argument new ParameterizedTypeReference<List<UserValueDTO>>() {}.

Guava TypeToken has some bells and whistles for resolving type variables which are declared on a class, but doing the same for type variables declared on a method is actually impossible because there's no way to reify the type argument to a method at the call site.


来源: stackexchange

问:
Find loops in LLVM bytecode
I want to find simple loops in LLVM bytecode, and extract the basic
information of the loop.

For example:

```<code> for (i=0; i<1000; i++)
    sum += i;
</code>```

I want to extract the bound [0, 1000), the loop variable "i" and the
loop body (sum += i).

What should I do?

I read the LLVM API document, and find some useful classes like "Loop",
"LoopInfo".

But I do not know how to use them in detail.

Could you please give me some help? A detailed usage may be more helpful.

答:
Just an update on Junxzm answer, some references, pointers, and methods have changed in LLVM 3.5.

```<code>for(llvm::Module::iterator f = m->begin(), fe=m->end(); f!=fe; ++f){
        llvm::DominatorTree DT = llvm::DominatorTree();
        DT.recalculate(*f);
        llvm::LoopInfoBase<llvm::BasicBlock, llvm::Loop>* LoopInfo = new llvm::LoopInfoBase<llvm::BasicBlock, llvm::Loop>();
        LoopInfo->releaseMemory();
        LoopInfo->Analyze(DT);
      }
</code>```

ContentLicense: CC BY-SA 3.0

Title: Find loops in LLVM bytecode

Body:
I want to find simple loops in LLVM bytecode, and extract the basic
information of the loop.

For example:

 for (i=0; i<1000; i++)
    sum += i;

I want to extract the bound [0, 1000), the loop variable "i" and the
loop body (sum += i).

What should I do?

I read the LLVM API document, and find some useful classes like "Loop",
"LoopInfo".

But I do not know how to use them in detail.

Could you please give me some help? A detailed usage may be more helpful.

Body:
Just an update on Junxzm answer, some references, pointers, and methods have changed in LLVM 3.5.

for(llvm::Module::iterator f = m->begin(), fe=m->end(); f!=fe; ++f){
        llvm::DominatorTree DT = llvm::DominatorTree();
        DT.recalculate(*f);
        llvm::LoopInfoBase<llvm::BasicBlock, llvm::Loop>* LoopInfo = new llvm::LoopInfoBase<llvm::BasicBlock, llvm::Loop>();
        LoopInfo->releaseMemory();
        LoopInfo->Analyze(DT);
      }


问:
Deploying unity 3d app to hololens apps fails with code -2147483645
I recently upgraded my unity 3d app from unity version 5.6.0 to 5.6.1 and holotoolkit-unity from 1.5.6 to 1.5.7.

Now, whenever I build the app and attempt to deploy it to the device via Visual Studio 2017, I get the following error:

```<code>'LabanotationAR.exe' (CoreCLR: DefaultDomain): Loaded 'c:\data\Programs\WindowsApps\Microsoft.NET.CoreRuntime.2.1_1.1.25129.1_x86__8wekyb3d8bbwe\System.Private.CoreLib.ni.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'LabanotationAR.exe' (CoreCLR: CoreCLR_UWP_Domain): Loaded 'C:\Data\Users\DefaultAccount\AppData\Local\DevelopmentFiles\LabanotationARVS.Debug_x86.kurtr\entrypoint\LabanotationAR.exe'. Symbols loaded.
'LabanotationAR.exe' (CoreCLR: CoreCLR_UWP_Domain): Loaded 'C:\Data\Users\DefaultAccount\AppData\Local\DevelopmentFiles\LabanotationARVS.Debug_x86.kurtr\System.Runtime.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'LabanotationAR.exe' (CoreCLR: CoreCLR_UWP_Domain): Loaded 'c:\data\Programs\WindowsApps\Microsoft.NET.CoreRuntime.3.1_1.1.25129.1_x86__8wekyb3d8bbwe\mscorlib.ni.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'LabanotationAR.exe' (CoreCLR: CoreCLR_UWP_Domain): Loaded 'C:\Data\Users\DefaultAccount\AppData\Local\DevelopmentFiles\LabanotationARVS.Debug_x86.kurtr\WinMetadata\Windows.winmd'. Module was built without symbols.
'LabanotationAR.exe' (CoreCLR: CoreCLR_UWP_Domain): Loaded 'C:\Data\Users\DefaultAccount\AppData\Local\DevelopmentFiles\LabanotationARVS.Debug_x86.kurtr\UnityPlayer.winmd'. Module was built without symbols.
'LabanotationAR.exe' (CoreCLR: CoreCLR_UWP_Domain): Loaded 'C:\Data\Users\DefaultAccount\AppData\Local\DevelopmentFiles\LabanotationARVS.Debug_x86.kurtr\System.Runtime.InteropServices.WindowsRuntime.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'LabanotationAR.exe' (CoreCLR: CoreCLR_UWP_Domain): Loaded 'C:\Data\Users\DefaultAccount\AppData\Local\DevelopmentFiles\LabanotationARVS.Debug_x86.kurtr\System.Runtime.WindowsRuntime.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'LabanotationAR.exe' (CoreCLR: CoreCLR_UWP_Domain): Loaded 'C:\Data\Users\DefaultAccount\AppData\Local\DevelopmentFiles\LabanotationARVS.Debug_x86.kurtr\WinRTBridge.winmd'. Cannot find or open the PDB file.
'LabanotationAR.exe' (CoreCLR: CoreCLR_UWP_Domain): Loaded 'C:\Data\Users\DefaultAccount\AppData\Local\DevelopmentFiles\LabanotationARVS.Debug_x86.kurtr\BridgeInterface.winmd'. Module was built without symbols.
'LabanotationAR.exe' (CoreCLR: CoreCLR_UWP_Domain): Loaded 'C:\Data\Users\DefaultAccount\AppData\Local\DevelopmentFiles\LabanotationARVS.Debug_x86.kurtr\System.Collections.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'LabanotationAR.exe' (CoreCLR: CoreCLR_UWP_Domain): Loaded 'C:\Data\Users\DefaultAccount\AppData\Local\DevelopmentFiles\LabanotationARVS.Debug_x86.kurtr\UnityEngine.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'LabanotationAR.exe' (CoreCLR: CoreCLR_UWP_Domain): Loaded 'C:\Data\Users\DefaultAccount\AppData\Local\DevelopmentFiles\LabanotationARVS.Debug_x86.kurtr\Assembly-CSharp.dll'. Symbols loaded.
'LabanotationAR.exe' (CoreCLR: CoreCLR_UWP_Domain): Loaded 'C:\Data\Users\DefaultAccount\AppData\Local\DevelopmentFiles\LabanotationARVS.Debug_x86.kurtr\System.Threading.Tasks.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'LabanotationAR.exe' (CoreCLR: CoreCLR_UWP_Domain): Loaded 'C:\Data\Users\DefaultAccount\AppData\Local\DevelopmentFiles\LabanotationARVS.Debug_x86.kurtr\System.IO.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'LabanotationAR.exe' (CoreCLR: CoreCLR_UWP_Domain): Loaded 'C:\Data\Users\DefaultAccount\AppData\Local\DevelopmentFiles\LabanotationARVS.Debug_x86.kurtr\WinRTLegacy.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'LabanotationAR.exe' (CoreCLR: CoreCLR_UWP_Domain): Loaded 'C:\Data\Users\DefaultAccount\AppData\Local\DevelopmentFiles\LabanotationARVS.Debug_x86.kurtr\UnityEngine.UI.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'LabanotationAR.exe' (CoreCLR: CoreCLR_UWP_Domain): Loaded 'C:\Data\Users\DefaultAccount\AppData\Local\DevelopmentFiles\LabanotationARVS.Debug_x86.kurtr\System.ObjectModel.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'LabanotationAR.exe' (CoreCLR: CoreCLR_UWP_Domain): Loaded 'C:\Data\Users\DefaultAccount\AppData\Local\DevelopmentFiles\LabanotationARVS.Debug_x86.kurtr\UnityEngine.Networking.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'LabanotationAR.exe' (CoreCLR: CoreCLR_UWP_Domain): Loaded 'C:\Data\Users\DefaultAccount\AppData\Local\DevelopmentFiles\LabanotationARVS.Debug_x86.kurtr\UnityEngine.HoloLens.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'LabanotationAR.exe' (CoreCLR: CoreCLR_UWP_Domain): Loaded 'C:\Data\Users\DefaultAccount\AppData\Local\DevelopmentFiles\LabanotationARVS.Debug_x86.kurtr\nunit.framework.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'LabanotationAR.exe' (CoreCLR: CoreCLR_UWP_Domain): Loaded 'C:\Data\Users\DefaultAccount\AppData\Local\DevelopmentFiles\LabanotationARVS.Debug_x86.kurtr\System.Reflection.dll'. Module was built without symbols.
'LabanotationAR.exe' (CoreCLR: CoreCLR_UWP_Domain): Loaded 'C:\Data\Users\DefaultAccount\AppData\Local\DevelopmentFiles\LabanotationARVS.Debug_x86.kurtr\UnityEngine.Analytics.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'LabanotationAR.exe' (CoreCLR: CoreCLR_UWP_Domain): Loaded 'C:\Data\Users\DefaultAccount\AppData\Local\DevelopmentFiles\LabanotationARVS.Debug_x86.kurtr\System.Globalization.dll'. Module was built without symbols.
'LabanotationAR.exe' (CoreCLR: CoreCLR_UWP_Domain): Loaded 'C:\Data\Users\DefaultAccount\AppData\Local\DevelopmentFiles\LabanotationARVS.Debug_x86.kurtr\System.Net.Primitives.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'LabanotationAR.exe' (CoreCLR: CoreCLR_UWP_Domain): Loaded 'C:\Data\Users\DefaultAccount\AppData\Local\DevelopmentFiles\LabanotationARVS.Debug_x86.kurtr\System.Private.Networking.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'LabanotationAR.exe' (CoreCLR: CoreCLR_UWP_Domain): Loaded 'C:\Data\Users\DefaultAccount\AppData\Local\DevelopmentFiles\LabanotationARVS.Debug_x86.kurtr\Microsoft.Win32.Primitives.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'LabanotationAR.exe' (CoreCLR: CoreCLR_UWP_Domain): Loaded 'C:\Data\Users\DefaultAccount\AppData\Local\DevelopmentFiles\LabanotationARVS.Debug_x86.kurtr\System.Reflection.Primitives.dll'. Module was built without symbols.
'LabanotationAR.exe' (CoreCLR: CoreCLR_UWP_Domain): Loaded 'C:\Data\Users\DefaultAccount\AppData\Local\DevelopmentFiles\LabanotationARVS.Debug_x86.kurtr\System.Reflection.TypeExtensions.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'LabanotationAR.exe' (CoreCLR: CoreCLR_UWP_Domain): Loaded 'C:\Data\Users\DefaultAccount\AppData\Local\DevelopmentFiles\LabanotationARVS.Debug_x86.kurtr\System.Runtime.Extensions.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'LabanotationAR.exe' (CoreCLR: CoreCLR_UWP_Domain): Loaded 'C:\Data\Users\DefaultAccount\AppData\Local\DevelopmentFiles\LabanotationARVS.Debug_x86.kurtr\System.Xml.XDocument.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'LabanotationAR.exe' (CoreCLR: CoreCLR_UWP_Domain): Loaded 'C:\Data\Users\DefaultAccount\AppData\Local\DevelopmentFiles\LabanotationARVS.Debug_x86.kurtr\System.Private.Uri.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'LabanotationAR.exe' (CoreCLR: CoreCLR_UWP_Domain): Loaded 'C:\Data\Users\DefaultAccount\AppData\Local\DevelopmentFiles\LabanotationARVS.Debug_x86.kurtr\System.Xml.ReaderWriter.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'LabanotationAR.exe' (CoreCLR: CoreCLR_UWP_Domain): Loaded 'C:\Data\Users\DefaultAccount\AppData\Local\DevelopmentFiles\LabanotationARVS.Debug_x86.kurtr\System.Text.Encoding.dll'. Module was built without symbols.
'LabanotationAR.exe' (CoreCLR: CoreCLR_UWP_Domain): Loaded 'C:\Data\Users\DefaultAccount\AppData\Local\DevelopmentFiles\LabanotationARVS.Debug_x86.kurtr\System.Text.RegularExpressions.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'LabanotationAR.exe' (CoreCLR: CoreCLR_UWP_Domain): Loaded 'C:\Data\Users\DefaultAccount\AppData\Local\DevelopmentFiles\LabanotationARVS.Debug_x86.kurtr\UnityEngine.VR.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'LabanotationAR.exe' (CoreCLR: CoreCLR_UWP_Domain): Loaded 'C:\Data\Users\DefaultAccount\AppData\Local\DevelopmentFiles\LabanotationARVS.Debug_x86.kurtr\System.Runtime.InteropServices.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'LabanotationAR.exe' (CoreCLR: CoreCLR_UWP_Domain): Loaded 'C:\Data\Users\DefaultAccount\AppData\Local\DevelopmentFiles\LabanotationARVS.Debug_x86.kurtr\System.Threading.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'LabanotationAR.exe' (CoreCLR: CoreCLR_UWP_Domain): Loaded 'C:\Data\Users\DefaultAccount\AppData\Local\DevelopmentFiles\LabanotationARVS.Debug_x86.kurtr\System.Diagnostics.Debug.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
Loading native plugins

  Loading MicStreamSelector.dll

  Loading SharingClient.dll

  Loading SpatialUnderstanding.dll

  Loading PlaneFinding.dll

Module information:
 Built with Compiler Ver '190023918'
 Built from '5.6/release' branch
 Version is '5.6.1f1 (2860b30f0b54)'
 Debug build
 Application type 'D3D11'
 Used 'UWP'

 OS 'Windows 10 (10.0.14393)'

PlayerConnection initialized from C:/Data/Users/DefaultAccount/AppData/Local/DevelopmentFiles/LabanotationARVS.Debug_x86.kurtr/Data (debug = 0)

PlayerConnection initialized network socket : 0.0.0.0 55008

Multi-casting "[IP] 172.30.0.203 [Port] 55008 [Flags] 2 [Guid] 2978211851 [EditorId] 4294967295 [Version] 1048832 [Id] MetroPlayerX86(HoloLens-UAO3C) [Debug] 0" to [225.0.0.222:54997]...

Started listening to [0.0.0.0:55008]

Player data archive not found at `C:/Data/Users/DefaultAccount/AppData/Local/DevelopmentFiles/LabanotationARVS.Debug_x86.kurtr/Data/data.unity3d`, using local filesystem
GfxDevice: creating device client; threaded=1

Direct3D:

    Version:  Direct3D 11.0 [level 11.1]

    Renderer: HoloLens Graphics (ID=0x22b0)

    Vendor:   Intel

    VRAM:     604 MB

Initialize engine version: 5.6.1f1 (2860b30f0b54)

'LabanotationAR.exe' (CoreCLR: CoreCLR_UWP_Domain): Loaded 'C:\Data\Users\DefaultAccount\AppData\Local\DevelopmentFiles\LabanotationARVS.Debug_x86.kurtr\UnityEngineProxy.dll'. Cannot find or open the PDB file.
'LabanotationAR.exe' (CoreCLR: CoreCLR_UWP_Domain): Loaded 'C:\Data\Users\DefaultAccount\AppData\Local\DevelopmentFiles\LabanotationARVS.Debug_x86.kurtr\System.Linq.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'LabanotationAR.exe' (CoreCLR: CoreCLR_UWP_Domain): Loaded 'C:\Data\Users\DefaultAccount\AppData\Local\DevelopmentFiles\LabanotationARVS.Debug_x86.kurtr\System.Reflection.Extensions.dll'. Module was built without symbols.
The following GlobalManagers were stripped from the build (Either because they're not used or not supported on this platform):
  NetworkManager
  MasterServerInterface
  UnityAdsManager
  ClusterInputManager
  CrashReportManager

If your machine has multiple graphics adapters, Unity may have created a WindowContext on the wrong adapter. If you experience a black screen when playing, please restart the Editor.

(Filename: C:/buildslave/unity/build/Runtime/VR/VRDevice.cpp Line: 184)

UnloadTime: 25.033651 ms

WinRTScriptingObjectWrapper::InternalAddRef Reference Count cannot be zero

(Filename: C:\buildslave\unity\build\Runtime/ScriptingBackend/DotNet/ScriptingApi_DotNet.cpp Line: 661)

The program '[3492] LabanotationAR.exe' has exited with code -2147483645 (0x80000003).
</code>```

IF anybody could give some pointers in how to go about debugging this error message, I'd really appreciate it.

答:
This was a Unity issue fixed for a future release. This should be releasing in the next Beta update.

Source

Body:
I recently upgraded my unity 3d app from unity version 5.6.0 to 5.6.1 and holotoolkit-unity from 1.5.6 to 1.5.7.

Now, whenever I build the app and attempt to deploy it to the device via Visual Studio 2017, I get the following error:

'LabanotationAR.exe' (CoreCLR: DefaultDomain): Loaded 'c:\data\Programs\WindowsApps\Microsoft.NET.CoreRuntime.2.1_1.1.25129.1_x86__8wekyb3d8bbwe\System.Private.CoreLib.ni.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'LabanotationAR.exe' (CoreCLR: CoreCLR_UWP_Domain): Loaded 'C:\Data\Users\DefaultAccount\AppData\Local\DevelopmentFiles\LabanotationARVS.Debug_x86.kurtr\entrypoint\LabanotationAR.exe'. Symbols loaded.
'LabanotationAR.exe' (CoreCLR: CoreCLR_UWP_Domain): Loaded 'C:\Data\Users\DefaultAccount\AppData\Local\DevelopmentFiles\LabanotationARVS.Debug_x86.kurtr\System.Runtime.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'LabanotationAR.exe' (CoreCLR: CoreCLR_UWP_Domain): Loaded 'c:\data\Programs\WindowsApps\Microsoft.NET.CoreRuntime.3.1_1.1.25129.1_x86__8wekyb3d8bbwe\mscorlib.ni.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'LabanotationAR.exe' (CoreCLR: CoreCLR_UWP_Domain): Loaded 'C:\Data\Users\DefaultAccount\AppData\Local\DevelopmentFiles\LabanotationARVS.Debug_x86.kurtr\WinMetadata\Windows.winmd'. Module was built without symbols.
'LabanotationAR.exe' (CoreCLR: CoreCLR_UWP_Domain): Loaded 'C:\Data\Users\DefaultAccount\AppData\Local\DevelopmentFiles\LabanotationARVS.Debug_x86.kurtr\UnityPlayer.winmd'. Module was built without symbols.
'LabanotationAR.exe' (CoreCLR: CoreCLR_UWP_Domain): Loaded 'C:\Data\Users\DefaultAccount\AppData\Local\DevelopmentFiles\LabanotationARVS.Debug_x86.kurtr\System.Runtime.InteropServices.WindowsRuntime.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'LabanotationAR.exe' (CoreCLR: CoreCLR_UWP_Domain): Loaded 'C:\Data\Users\DefaultAccount\AppData\Local\DevelopmentFiles\LabanotationARVS.Debug_x86.kurtr\System.Runtime.WindowsRuntime.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'LabanotationAR.exe' (CoreCLR: CoreCLR_UWP_Domain): Loaded 'C:\Data\Users\DefaultAccount\AppData\Local\DevelopmentFiles\LabanotationARVS.Debug_x86.kurtr\WinRTBridge.winmd'. Cannot find or open the PDB file.
'LabanotationAR.exe' (CoreCLR: CoreCLR_UWP_Domain): Loaded 'C:\Data\Users\DefaultAccount\AppData\Local\DevelopmentFiles\LabanotationARVS.Debug_x86.kurtr\BridgeInterface.winmd'. Module was built without symbols.
'LabanotationAR.exe' (CoreCLR: CoreCLR_UWP_Domain): Loaded 'C:\Data\Users\DefaultAccount\AppData\Local\DevelopmentFiles\LabanotationARVS.Debug_x86.kurtr\System.Collections.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'LabanotationAR.exe' (CoreCLR: CoreCLR_UWP_Domain): Loaded 'C:\Data\Users\DefaultAccount\AppData\Local\DevelopmentFiles\LabanotationARVS.Debug_x86.kurtr\UnityEngine.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'LabanotationAR.exe' (CoreCLR: CoreCLR_UWP_Domain): Loaded 'C:\Data\Users\DefaultAccount\AppData\Local\DevelopmentFiles\LabanotationARVS.Debug_x86.kurtr\Assembly-CSharp.dll'. Symbols loaded.
'LabanotationAR.exe' (CoreCLR: CoreCLR_UWP_Domain): Loaded 'C:\Data\Users\DefaultAccount\AppData\Local\DevelopmentFiles\LabanotationARVS.Debug_x86.kurtr\System.Threading.Tasks.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'LabanotationAR.exe' (CoreCLR: CoreCLR_UWP_Domain): Loaded 'C:\Data\Users\DefaultAccount\AppData\Local\DevelopmentFiles\LabanotationARVS.Debug_x86.kurtr\System.IO.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'LabanotationAR.exe' (CoreCLR: CoreCLR_UWP_Domain): Loaded 'C:\Data\Users\DefaultAccount\AppData\Local\DevelopmentFiles\LabanotationARVS.Debug_x86.kurtr\WinRTLegacy.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'LabanotationAR.exe' (CoreCLR: CoreCLR_UWP_Domain): Loaded 'C:\Data\Users\DefaultAccount\AppData\Local\DevelopmentFiles\LabanotationARVS.Debug_x86.kurtr\UnityEngine.UI.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'LabanotationAR.exe' (CoreCLR: CoreCLR_UWP_Domain): Loaded 'C:\Data\Users\DefaultAccount\AppData\Local\DevelopmentFiles\LabanotationARVS.Debug_x86.kurtr\System.ObjectModel.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'LabanotationAR.exe' (CoreCLR: CoreCLR_UWP_Domain): Loaded 'C:\Data\Users\DefaultAccount\AppData\Local\DevelopmentFiles\LabanotationARVS.Debug_x86.kurtr\UnityEngine.Networking.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'LabanotationAR.exe' (CoreCLR: CoreCLR_UWP_Domain): Loaded 'C:\Data\Users\DefaultAccount\AppData\Local\DevelopmentFiles\LabanotationARVS.Debug_x86.kurtr\UnityEngine.HoloLens.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'LabanotationAR.exe' (CoreCLR: CoreCLR_UWP_Domain): Loaded 'C:\Data\Users\DefaultAccount\AppData\Local\DevelopmentFiles\LabanotationARVS.Debug_x86.kurtr\nunit.framework.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'LabanotationAR.exe' (CoreCLR: CoreCLR_UWP_Domain): Loaded 'C:\Data\Users\DefaultAccount\AppData\Local\DevelopmentFiles\LabanotationARVS.Debug_x86.kurtr\System.Reflection.dll'. Module was built without symbols.
'LabanotationAR.exe' (CoreCLR: CoreCLR_UWP_Domain): Loaded 'C:\Data\Users\DefaultAccount\AppData\Local\DevelopmentFiles\LabanotationARVS.Debug_x86.kurtr\UnityEngine.Analytics.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'LabanotationAR.exe' (CoreCLR: CoreCLR_UWP_Domain): Loaded 'C:\Data\Users\DefaultAccount\AppData\Local\DevelopmentFiles\LabanotationARVS.Debug_x86.kurtr\System.Globalization.dll'. Module was built without symbols.
'LabanotationAR.exe' (CoreCLR: CoreCLR_UWP_Domain): Loaded 'C:\Data\Users\DefaultAccount\AppData\Local\DevelopmentFiles\LabanotationARVS.Debug_x86.kurtr\System.Net.Primitives.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'LabanotationAR.exe' (CoreCLR: CoreCLR_UWP_Domain): Loaded 'C:\Data\Users\DefaultAccount\AppData\Local\DevelopmentFiles\LabanotationARVS.Debug_x86.kurtr\System.Private.Networking.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'LabanotationAR.exe' (CoreCLR: CoreCLR_UWP_Domain): Loaded 'C:\Data\Users\DefaultAccount\AppData\Local\DevelopmentFiles\LabanotationARVS.Debug_x86.kurtr\Microsoft.Win32.Primitives.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'LabanotationAR.exe' (CoreCLR: CoreCLR_UWP_Domain): Loaded 'C:\Data\Users\DefaultAccount\AppData\Local\DevelopmentFiles\LabanotationARVS.Debug_x86.kurtr\System.Reflection.Primitives.dll'. Module was built without symbols.
'LabanotationAR.exe' (CoreCLR: CoreCLR_UWP_Domain): Loaded 'C:\Data\Users\DefaultAccount\AppData\Local\DevelopmentFiles\LabanotationARVS.Debug_x86.kurtr\System.Reflection.TypeExtensions.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'LabanotationAR.exe' (CoreCLR: CoreCLR_UWP_Domain): Loaded 'C:\Data\Users\DefaultAccount\AppData\Local\DevelopmentFiles\LabanotationARVS.Debug_x86.kurtr\System.Runtime.Extensions.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'LabanotationAR.exe' (CoreCLR: CoreCLR_UWP_Domain): Loaded 'C:\Data\Users\DefaultAccount\AppData\Local\DevelopmentFiles\LabanotationARVS.Debug_x86.kurtr\System.Xml.XDocument.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'LabanotationAR.exe' (CoreCLR: CoreCLR_UWP_Domain): Loaded 'C:\Data\Users\DefaultAccount\AppData\Local\DevelopmentFiles\LabanotationARVS.Debug_x86.kurtr\System.Private.Uri.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'LabanotationAR.exe' (CoreCLR: CoreCLR_UWP_Domain): Loaded 'C:\Data\Users\DefaultAccount\AppData\Local\DevelopmentFiles\LabanotationARVS.Debug_x86.kurtr\System.Xml.ReaderWriter.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'LabanotationAR.exe' (CoreCLR: CoreCLR_UWP_Domain): Loaded 'C:\Data\Users\DefaultAccount\AppData\Local\DevelopmentFiles\LabanotationARVS.Debug_x86.kurtr\System.Text.Encoding.dll'. Module was built without symbols.
'LabanotationAR.exe' (CoreCLR: CoreCLR_UWP_Domain): Loaded 'C:\Data\Users\DefaultAccount\AppData\Local\DevelopmentFiles\LabanotationARVS.Debug_x86.kurtr\System.Text.RegularExpressions.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'LabanotationAR.exe' (CoreCLR: CoreCLR_UWP_Domain): Loaded 'C:\Data\Users\DefaultAccount\AppData\Local\DevelopmentFiles\LabanotationARVS.Debug_x86.kurtr\UnityEngine.VR.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'LabanotationAR.exe' (CoreCLR: CoreCLR_UWP_Domain): Loaded 'C:\Data\Users\DefaultAccount\AppData\Local\DevelopmentFiles\LabanotationARVS.Debug_x86.kurtr\System.Runtime.InteropServices.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'LabanotationAR.exe' (CoreCLR: CoreCLR_UWP_Domain): Loaded 'C:\Data\Users\DefaultAccount\AppData\Local\DevelopmentFiles\LabanotationARVS.Debug_x86.kurtr\System.Threading.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'LabanotationAR.exe' (CoreCLR: CoreCLR_UWP_Domain): Loaded 'C:\Data\Users\DefaultAccount\AppData\Local\DevelopmentFiles\LabanotationARVS.Debug_x86.kurtr\System.Diagnostics.Debug.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
Loading native plugins

  Loading MicStreamSelector.dll

  Loading SharingClient.dll

  Loading SpatialUnderstanding.dll

  Loading PlaneFinding.dll

Module information:
 Built with Compiler Ver '190023918'
 Built from '5.6/release' branch
 Version is '5.6.1f1 (2860b30f0b54)'
 Debug build
 Application type 'D3D11'
 Used 'UWP'

 OS 'Windows 10 (10.0.14393)'

PlayerConnection initialized from C:/Data/Users/DefaultAccount/AppData/Local/DevelopmentFiles/LabanotationARVS.Debug_x86.kurtr/Data (debug = 0)

PlayerConnection initialized network socket : 0.0.0.0 55008

Multi-casting "[IP] 172.30.0.203 [Port] 55008 [Flags] 2 [Guid] 2978211851 [EditorId] 4294967295 [Version] 1048832 [Id] MetroPlayerX86(HoloLens-UAO3C) [Debug] 0" to [225.0.0.222:54997]...

Started listening to [0.0.0.0:55008]

Player data archive not found at `C:/Data/Users/DefaultAccount/AppData/Local/DevelopmentFiles/LabanotationARVS.Debug_x86.kurtr/Data/data.unity3d`, using local filesystem
GfxDevice: creating device client; threaded=1

Direct3D:

    Version:  Direct3D 11.0 [level 11.1]

    Renderer: HoloLens Graphics (ID=0x22b0)

    Vendor:   Intel

    VRAM:     604 MB

Initialize engine version: 5.6.1f1 (2860b30f0b54)

'LabanotationAR.exe' (CoreCLR: CoreCLR_UWP_Domain): Loaded 'C:\Data\Users\DefaultAccount\AppData\Local\DevelopmentFiles\LabanotationARVS.Debug_x86.kurtr\UnityEngineProxy.dll'. Cannot find or open the PDB file.
'LabanotationAR.exe' (CoreCLR: CoreCLR_UWP_Domain): Loaded 'C:\Data\Users\DefaultAccount\AppData\Local\DevelopmentFiles\LabanotationARVS.Debug_x86.kurtr\System.Linq.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'LabanotationAR.exe' (CoreCLR: CoreCLR_UWP_Domain): Loaded 'C:\Data\Users\DefaultAccount\AppData\Local\DevelopmentFiles\LabanotationARVS.Debug_x86.kurtr\System.Reflection.Extensions.dll'. Module was built without symbols.
The following GlobalManagers were stripped from the build (Either because they're not used or not supported on this platform):
  NetworkManager
  MasterServerInterface
  UnityAdsManager
  ClusterInputManager
  CrashReportManager

If your machine has multiple graphics adapters, Unity may have created a WindowContext on the wrong adapter. If you experience a black screen when playing, please restart the Editor.

(Filename: C:/buildslave/unity/build/Runtime/VR/VRDevice.cpp Line: 184)

UnloadTime: 25.033651 ms

WinRTScriptingObjectWrapper::InternalAddRef Reference Count cannot be zero

(Filename: C:\buildslave\unity\build\Runtime/ScriptingBackend/DotNet/ScriptingApi_DotNet.cpp Line: 661)

The program '[3492] LabanotationAR.exe' has exited with code -2147483645 (0x80000003).

IF anybody could give some pointers in how to go about debugging this error message, I'd really appreciate it.


问:
JOptionPane.showInputDialog auto exit
With this,

```<code>JOptionPane.showInputDialog(null,"Enter Your Name");
</code>```

I'd like the user input dialog box to auto exit. I mean within 2 or 3 seconds only show that JOptionPane user input dialog and close after that. It should automatically close that input dialog box only, not the whole program. The System.exit(0) method causes the full program to exit, but I want only close that input dialog box not full program. Then I want only Swing input dialog not message box and confirm box.

答:
As shown in How to Make Dialogs, you can add intercept Automatic Dialog Closing in a PropertyChangeListener. Based on this example, the variation below adds a label, prompt,  and text field to the option pane. A Swing Timer counts down from TIME_OUT, updating the label each time. The  PropertyChangeListener dispatches a WINDOW_CLOSING event when the OK button is pressed or time runs out.

```<code>import java.awt.EventQueue;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowEvent;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
import javax.swing.Timer;

/**
 * @see https://stackoverflow.com/a/44417958/230513
 * @see https://stackoverflow.com/a/12451673/230513
 */

public class JOptionTimeTest implements ActionListener, PropertyChangeListener {

    private static final int TIME_OUT = 10;
    private int count = TIME_OUT;
    private final Timer timer = new Timer(1000, this);
    private final JDialog dialog = new JDialog();
    private final JOptionPane optPane = new JOptionPane();
    private final JLabel label = new JLabel(message());
    private final JLabel prompt = new JLabel("Enter Your Name:");
    private final JTextField text = new JTextField("Name");

    public static void main(String[] args) {
        EventQueue.invokeLater(new Runnable() {

            public void run() {
                new JOptionTimeTest().createGUI();
            }
        });
    }

    private void createGUI() {
        JFrame frame = new JFrame("Title");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setLocationRelativeTo(null);
        timer.setCoalesce(false);
        text.selectAll();
        Object[] array = {label, prompt, text};
        optPane.setMessage(array);
        optPane.setMessageType(JOptionPane.INFORMATION_MESSAGE);
        optPane.setOptionType(JOptionPane.DEFAULT_OPTION);
        optPane.addPropertyChangeListener(this);
        dialog.add(optPane);
        dialog.pack();
        frame.add(new JLabel(frame.getTitle(), JLabel.CENTER));
        frame.pack();
        frame.setVisible(true);
        dialog.setLocationRelativeTo(frame);
        dialog.setVisible(true);
        timer.start();
    }

    public void propertyChange(PropertyChangeEvent e) {
        String prop = e.getPropertyName();
        if (JOptionPane.VALUE_PROPERTY.equals(prop)) {
            thatsAllFolks();
        }
    }

    public void actionPerformed(ActionEvent e) {
        count--;
        label.setText(message());
        if (count == 0) {
            thatsAllFolks();
        }
        timer.restart();
    }

    private String message() {
        return "Closing in " + count + " seconds.";
    }

    private void thatsAllFolks() {
        dialog.setVisible(false);
        dialog.dispatchEvent(new WindowEvent(
            dialog, WindowEvent.WINDOW_CLOSING));
    }
}
</code>```

Title: JOptionPane.showInputDialog auto exit

Body:
With this,

JOptionPane.showInputDialog(null,"Enter Your Name");

I'd like the user input dialog box to auto exit. I mean within 2 or 3 seconds only show that JOptionPane user input dialog and close after that. It should automatically close that input dialog box only, not the whole program. The System.exit(0) method causes the full program to exit, but I want only close that input dialog box not full program. Then I want only Swing input dialog not message box and confirm box.

Body:
As shown in How to Make Dialogs, you can add intercept Automatic Dialog Closing in a PropertyChangeListener. Based on this example, the variation below adds a label, prompt,  and text field to the option pane. A Swing Timer counts down from TIME_OUT, updating the label each time. The  PropertyChangeListener dispatches a WINDOW_CLOSING event when the OK button is pressed or time runs out.

import java.awt.EventQueue;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowEvent;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
import javax.swing.Timer;

/**
 * @see https://stackoverflow.com/a/44417958/230513
 * @see https://stackoverflow.com/a/12451673/230513
 */

public class JOptionTimeTest implements ActionListener, PropertyChangeListener {

    private static final int TIME_OUT = 10;
    private int count = TIME_OUT;
    private final Timer timer = new Timer(1000, this);
    private final JDialog dialog = new JDialog();
    private final JOptionPane optPane = new JOptionPane();
    private final JLabel label = new JLabel(message());
    private final JLabel prompt = new JLabel("Enter Your Name:");
    private final JTextField text = new JTextField("Name");

    public static void main(String[] args) {
        EventQueue.invokeLater(new Runnable() {

            public void run() {
                new JOptionTimeTest().createGUI();
            }
        });
    }

    private void createGUI() {
        JFrame frame = new JFrame("Title");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setLocationRelativeTo(null);
        timer.setCoalesce(false);
        text.selectAll();
        Object[] array = {label, prompt, text};
        optPane.setMessage(array);
        optPane.setMessageType(JOptionPane.INFORMATION_MESSAGE);
        optPane.setOptionType(JOptionPane.DEFAULT_OPTION);
        optPane.addPropertyChangeListener(this);
        dialog.add(optPane);
        dialog.pack();
        frame.add(new JLabel(frame.getTitle(), JLabel.CENTER));
        frame.pack();
        frame.setVisible(true);
        dialog.setLocationRelativeTo(frame);
        dialog.setVisible(true);
        timer.start();
    }

    public void propertyChange(PropertyChangeEvent e) {
        String prop = e.getPropertyName();
        if (JOptionPane.VALUE_PROPERTY.equals(prop)) {
            thatsAllFolks();
        }
    }

    public void actionPerformed(ActionEvent e) {
        count--;
        label.setText(message());
        if (count == 0) {
            thatsAllFolks();
        }
        timer.restart();
    }

    private String message() {
        return "Closing in " + count + " seconds.";
    }

    private void thatsAllFolks() {
        dialog.setVisible(false);
        dialog.dispatchEvent(new WindowEvent(
            dialog, WindowEvent.WINDOW_CLOSING));
    }
}


问:
How can I initiate watch mode with ngc?
I would like to do the same, as I could in the good old tsc times: simply calling a tsc -w, and in the case of a changed file, it will be on the fly recompilated.

Unfortunately, ngc doesn't even seem to react anything to the -w flag, and even its possible command line arguments are completely undocumented.

But, ng build has a --watch flag, while it can create also AOT builds. Thus, probably a watch-mode ngc is possible.

But how?

答:
Version 5:

You can now use watch mode like this:

```<code>ngc -w
</code>```

See this comment by Tobias:

The command line ngc also has a -w option now that watches the file
  system and we see speedups for subsequent builds of up to 10x, as we
  have some logic in place to only compile components in node_modules
  1x.

Version prior to 4

At the moment ngc doesn't support watch mode. It's addition identified by the Tobias Bosch as priority features. Here is the video where he talks about that.

Title: How can I initiate watch mode with ngc?

Body:
Version 5:

You can now use watch mode like this:

ngc -w

See this comment by Tobias:

The command line ngc also has a -w option now that watches the file
  system and we see speedups for subsequent builds of up to 10x, as we
  have some logic in place to only compile components in node_modules
  1x.

Version prior to 4

At the moment ngc doesn't support watch mode. It's addition identified by the Tobias Bosch as priority features. Here is the video where he talks about that.


问:
How is a random number generated at runtime?
Since computers cannot pick random numbers(can they?) how is this random number actually generated. For example in C# we say,

```<code>Random.Next()
</code>```

What happens inside?

答:
I'll just add an answer to the first part of the question (the "can they?" part).h

Computers can generate (well, generate may not be an entirely accurate word) random numbers (as in, not pseudo-random). Specifically, by using environmental randomness which is gotten through specialized hardware devices (that generates randomness based on noise, for e.g.) or by using environmental inputs (e.g. hard disk timings, user input event timings).

However, that has no bearing on the second question (which was how Random.Next() works).

ContentLicense: CC BY-SA 2.5

Body:
Since computers cannot pick random numbers(can they?) how is this random number actually generated. For example in C# we say,

Random.Next()

What happens inside?


问:
How to get index of row when MouseHover in Radgridview
i want to get index of any row that my mouse is above and not necessarily from the selected row.

```<code> Private Sub RadGridView1_MouseHover(sender As Object, e As EventArgs) Handles RadGridView1.MouseHover
            Try
                toolidx = RadGridView1.CurrentCell.RowIndex
                strphone = dsOrders.Tables(0).Rows(toolidx)("DeliveryPhone")

            Catch ex As Exception
                RadMessageBox.Show(ex.Message, projectName, MessageBoxButtons.OK, RadMessageIcon.Error)
                errlog.WriteLog(ex.Message.ToString, Me.Name, System.Reflection.MethodBase.GetCurrentMethod().Name.ToString())
            End Try
        End Sub
</code>```

the code above does what i want but for the selected row i want to  get the index of row when my mouse is over this row. Can anyone help?

答:
You should be able to get the cell with the following instruction. Shouldn't be difficult to get the row and column index from it.

```<code>Dim cell As GridCellElement = TryCast(RadGridView1.ElementTree.GetElementAtPoint(e.Location), GridCellElement)
</code>```

As GetElementAtPoint could return element of GridView which are not necessarily Cells, DataCells to be more precise. Don't forget to check what is really under the cursor.

As the MouseHover event do not give information about coordinates, maybe you should use the MouseMove event instead or you could use the Cursor.Position Property.

Credit from
http://www.telerik.com/forums/determining-the-mouse-down-position-in-cell
and
mouse coordinates in MouseHover event?

Body:
i want to get index of any row that my mouse is above and not necessarily from the selected row.

 Private Sub RadGridView1_MouseHover(sender As Object, e As EventArgs) Handles RadGridView1.MouseHover
            Try
                toolidx = RadGridView1.CurrentCell.RowIndex
                strphone = dsOrders.Tables(0).Rows(toolidx)("DeliveryPhone")

            Catch ex As Exception
                RadMessageBox.Show(ex.Message, projectName, MessageBoxButtons.OK, RadMessageIcon.Error)
                errlog.WriteLog(ex.Message.ToString, Me.Name, System.Reflection.MethodBase.GetCurrentMethod().Name.ToString())
            End Try
        End Sub

the code above does what i want but for the selected row i want to  get the index of row when my mouse is over this row. Can anyone help?

Body:
You should be able to get the cell with the following instruction. Shouldn't be difficult to get the row and column index from it.

Dim cell As GridCellElement = TryCast(RadGridView1.ElementTree.GetElementAtPoint(e.Location), GridCellElement)

As GetElementAtPoint could return element of GridView which are not necessarily Cells, DataCells to be more precise. Don't forget to check what is really under the cursor.

As the MouseHover event do not give information about coordinates, maybe you should use the MouseMove event instead or you could use the Cursor.Position Property.

Credit from
http://www.telerik.com/forums/determining-the-mouse-down-position-in-cell
and
mouse coordinates in MouseHover event?


问:
Can't deploy Sql Database Project to Azure
I have a Sql Database Project and in deploying time, with appveyor, i get this error: Error publishing database: Could not deploy package. Unable to connect to master or target server 'ods-staging'. You must have a user with the same password in master or target server 'ods-staging'. I think that i get this error because the ip address it's not allowed in Azure Database Firework.

if this is correct how can i know what are the range of ip addresess that appveyor use?

or maybe this error is because something else?

答: Please check this part of Appveyor documentation: https://www.appveyor.com/docs/build-environment/#ip-addresses</p>


问:
how to make ckeditor stop removing empty divs
There are similar questions to this here on stackoverflow, but the answers in those questions do not work for me, so please don't flag this as a duplicate.

In my cms, I want people to be able to add content pages that are SPA (Single Page Applications). It is very common for these kinds of apps to have nothing but a div with some attributes and javascript is used to load the app into the div. So I want users to be able to create content that consists only of an empty div with some attributes like this:

```<code><div data-cscal-eventsource="default" data-cscal-height="550" id="eventCal" class="cs-eventcal"></div>
</code>```

However ckeditor (I'm using version 4.6.2 at the moment) always removes the empty div. From googling and finding similar questions here I have tried various things in config:

```<code>allowedContent : true
</code>```

is supposed to turn off all filtering but it still gets removed.

```<code>CKEDITOR.dtd.$removeEmpty['div'] = false;
</code>```

is also found in some answers but does not work for me.

before setting allowedContent to true I tried various things with extraAllowedContent like this:

```<code>extraAllowedContent: 'div(*){*}[*]; ol li span a(*){*}[*]'
</code>```

If the div has some text it works like this for example:

```<code><div data-cscal-eventsource="default" data-cscal-height="550" id="eventCal" class="cs-eventcal">hello</div>
</code>```

but I don't want that text and using a nbsp doesn't work either.

How can I make CKEditor leave my empty div alone? My div is the only content in the editor, the script and css for my SPA is added from outside the editor. I just need to be able to add the div without it being removed. I am trying to add the div using the sourcedialog.

I do not want to modify the ckeditor source code to solve this.

My complete code for clarity is like this, you can see in comments some of the things I have tried:

```<code>(function ($) {

var xsrfToken = $('[name="__RequestVerificationToken"]:first').val();
var dfUrl = $("#editorconfig").data("dropfileuploadurl") || '/filemanager/upload';
var fbUrl = $("#editorconfig").data("filebrowserurl") || '/filemanager/filedialog?type=file';
var ibUrl = $("#editorconfig").data("imagebrowseurl") || '/filemanager/filedialog?type=image';
var editorId = $("#editorconfig").data("editorid") || 'foo';
var datepickerid = $("#editorconfig").data("datepickerid") || 'foo';
var usingCdn = $("#editorconfig").data("usingcdn");

var editorConfig = {
    toolbar: [['Sourcedialog', 'Maximize'],
['SelectAll', 'RemoveFormat', 'Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord', '-', 'Print'],
['Undo', 'Redo', '-', 'Find', 'Replace', 'Bold', 'Italic', 'Underline', '-', 'Strike', 'Superscript'],
    '/',
    ['Blockquote', 'Format'], ['NumberedList', 'BulletedList'],
['Link', 'Unlink', 'Anchor'],
['Image', 'oembed', 'Table', 'HorizontalRule', 'Smiley', 'SpecialChar','CodeSnippet']],
    extraPlugins:'oembed,cloudscribe-filedrop,sourcedialog,codesnippet',
    removePlugins: 'scayt,wsc',
    format_tags: 'p;h1;h2;h3;h4;pre;address;div',
    dropFileUploadUrl: dfUrl,
    dropFileXsrfToken:xsrfToken,
    linkWebSizeToOriginal:true,
    forcePasteAsPlainText:true,
    filebrowserWindowHeight:'70%',
    filebrowserWindowWidth:'80%',
    filebrowserBrowseUrl:fbUrl,
    filebrowserImageBrowseUrl: ibUrl,
    allowedContent : true, //temporary trying to disable filtering
    extraAllowedContent: 'div(*){*}[*]; ol li span a(*){*}[*]', // allow all classes and attributes for these tags
    fillEmptyBlocks: false
};

if (usingCdn === true) {
    //alert('using cdn');
    CKEDITOR.plugins.addExternal('widget', '/ckjs/plugins/widget/', 'plugin.js');
    CKEDITOR.plugins.addExternal('widgetselection', '/ckjs/plugins/widgetselection/', 'plugin.js');
    CKEDITOR.plugins.addExternal('lineutils', '/ckjs/plugins/lineutils/', 'plugin.js');
    CKEDITOR.plugins.addExternal('oembed', '/ckjs/plugins/oembed/', 'plugin.js');
    CKEDITOR.plugins.addExternal('cloudscribe-filedrop', '/ckjs/plugins/cloudscribe-filedrop/', 'plugin.js');

}

//editorConfig.protectedSource.push(/<div[^>]*><\/div>/g);
//CKEDITOR.dtd.$removeEmpty['div'] = false;

//$.each(CKEDITOR.dtd.$removeEmpty, function (i, value) {
//    CKEDITOR.dtd.$removeEmpty[i] = 0;
//});

var ck = CKEDITOR.replace(editorId, editorConfig);

ck.on('instanceCreated', function (ev) {
    CKEDITOR.dtd.$removeEmpty['div'] = false;
});

var userLocale = $('#' + datepickerid).data("locale");
$('#' + datepickerid).datetimepicker({
    debug: false,
    widgetPositioning: { horizontal: 'left', vertical: 'bottom' },
    keepOpen: true,
    allowInputToggle: true,
    locale: userLocale
});

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

答:
config.basicEntities = false; //in your cke.editor config js file

Works for me.

UPDATE

Try this and see if it works, but i can have empty divs no problem.

```<code>for (var tag in CKEDITOR.dtd.$removeEmpty) {
    CKEDITOR.dtd.$removeEmpty[tag] = false;
}
</code>```

UPDATE 2

Also try this, I have this in my config that does not remove empty div's

config.htmlEncodeOutput = false;

Body:
There are similar questions to this here on stackoverflow, but the answers in those questions do not work for me, so please don't flag this as a duplicate.

In my cms, I want people to be able to add content pages that are SPA (Single Page Applications). It is very common for these kinds of apps to have nothing but a div with some attributes and javascript is used to load the app into the div. So I want users to be able to create content that consists only of an empty div with some attributes like this:

However ckeditor (I'm using version 4.6.2 at the moment) always removes the empty div. From googling and finding similar questions here I have tried various things in config:

allowedContent : true

is supposed to turn off all filtering but it still gets removed.

CKEDITOR.dtd.$removeEmpty['div'] = false;

is also found in some answers but does not work for me.

before setting allowedContent to true I tried various things with extraAllowedContent like this:

extraAllowedContent: 'div(*){*}[*]; ol li span a(*){*}[*]'

If the div has some text it works like this for example:

hello

but I don't want that text and using a nbsp doesn't work either.

How can I make CKEditor leave my empty div alone? My div is the only content in the editor, the script and css for my SPA is added from outside the editor. I just need to be able to add the div without it being removed. I am trying to add the div using the sourcedialog.

I do not want to modify the ckeditor source code to solve this.

My complete code for clarity is like this, you can see in comments some of the things I have tried:

(function ($) {

var xsrfToken = $('[name="__RequestVerificationToken"]:first').val();
var dfUrl = $("#editorconfig").data("dropfileuploadurl") || '/filemanager/upload';
var fbUrl = $("#editorconfig").data("filebrowserurl") || '/filemanager/filedialog?type=file';
var ibUrl = $("#editorconfig").data("imagebrowseurl") || '/filemanager/filedialog?type=image';
var editorId = $("#editorconfig").data("editorid") || 'foo';
var datepickerid = $("#editorconfig").data("datepickerid") || 'foo';
var usingCdn = $("#editorconfig").data("usingcdn");

var editorConfig = {
    toolbar: [['Sourcedialog', 'Maximize'],
['SelectAll', 'RemoveFormat', 'Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord', '-', 'Print'],
['Undo', 'Redo', '-', 'Find', 'Replace', 'Bold', 'Italic', 'Underline', '-', 'Strike', 'Superscript'],
    '/',
    ['Blockquote', 'Format'], ['NumberedList', 'BulletedList'],
['Link', 'Unlink', 'Anchor'],
['Image', 'oembed', 'Table', 'HorizontalRule', 'Smiley', 'SpecialChar','CodeSnippet']],
    extraPlugins:'oembed,cloudscribe-filedrop,sourcedialog,codesnippet',
    removePlugins: 'scayt,wsc',
    format_tags: 'p;h1;h2;h3;h4;pre;address;div',
    dropFileUploadUrl: dfUrl,
    dropFileXsrfToken:xsrfToken,
    linkWebSizeToOriginal:true,
    forcePasteAsPlainText:true,
    filebrowserWindowHeight:'70%',
    filebrowserWindowWidth:'80%',
    filebrowserBrowseUrl:fbUrl,
    filebrowserImageBrowseUrl: ibUrl,
    allowedContent : true, //temporary trying to disable filtering
    extraAllowedContent: 'div(*){*}[*]; ol li span a(*){*}[*]', // allow all classes and attributes for these tags
    fillEmptyBlocks: false
};

if (usingCdn === true) {
    //alert('using cdn');
    CKEDITOR.plugins.addExternal('widget', '/ckjs/plugins/widget/', 'plugin.js');
    CKEDITOR.plugins.addExternal('widgetselection', '/ckjs/plugins/widgetselection/', 'plugin.js');
    CKEDITOR.plugins.addExternal('lineutils', '/ckjs/plugins/lineutils/', 'plugin.js');
    CKEDITOR.plugins.addExternal('oembed', '/ckjs/plugins/oembed/', 'plugin.js');
    CKEDITOR.plugins.addExternal('cloudscribe-filedrop', '/ckjs/plugins/cloudscribe-filedrop/', 'plugin.js');

}

//editorConfig.protectedSource.push(/
]*><\/div>/g);
//CKEDITOR.dtd.$removeEmpty['div'] = false;

//$.each(CKEDITOR.dtd.$removeEmpty, function (i, value) {
//    CKEDITOR.dtd.$removeEmpty[i] = 0;
//});

var ck = CKEDITOR.replace(editorId, editorConfig);

ck.on('instanceCreated', function (ev) {
    CKEDITOR.dtd.$removeEmpty['div'] = false;
});

var userLocale = $('#' + datepickerid).data("locale");
$('#' + datepickerid).datetimepicker({
    debug: false,
    widgetPositioning: { horizontal: 'left', vertical: 'bottom' },
    keepOpen: true,
    allowInputToggle: true,
    locale: userLocale
});

})(jQuery);

Body:
config.basicEntities = false; //in your cke.editor config js file

Works for me.

UPDATE

Try this and see if it works, but i can have empty divs no problem.

for (var tag in CKEDITOR.dtd.$removeEmpty) {
    CKEDITOR.dtd.$removeEmpty[tag] = false;
}

UPDATE 2

Also try this, I have this in my config that does not remove empty div's

config.htmlEncodeOutput = false;


问:
TFS WorkItem Attachments can save but not load
I can save an Attachment to a WorkItem like this:

```<code>TfsTeamProjectCollection tfsTeamProjects = new TfsTeamProjectCollection(new Uri(tfsServerUrl));
WorkItemStore tfsWorkItemStore = tfsTeamProjects.GetService<WorkItemStore>();
WorkItem tfsWorkItem = tfsWorkItemStore.GetWorkItem(tfsWorkItemId);

FileInfo fi = new FileInfo(@"D:\\Docs\testfile.txt");
Attachment tfsAttachment = new Attachment(fi.FullName);
tfsWorkItem.Attachments.Add(tfsAttachment);
tfsWorkItem.Save();
</code>```

But when I try to get the list of Attachments for a WorkItem like this:

```<code>TfsTeamProjectCollection tfsTeamProjects = new TfsTeamProjectCollection(new Uri(tfsServerUrl));
WorkItemStore tfsWorkItemStore = tfsTeamProjects.GetService<WorkItemStore>();
WorkItem tfsWorkItem = tfsWorkItemStore.GetWorkItem(tfsWorkItemId);
foreach(Attachment tfsAttachment : tfsWorkItem.Attachments)
{
    // Do things here
}
</code>```

tfsWorkItem.Attachments is always empty, even though I can see four attachments in the Objects tab on the TFS Web UI. And the WorkItem object that I am getting is the correct one.

答:
I do not remember all details but the code I wrote a while ago use a wrapping class for enumeration that enables LINQ.

```
class AttachmentEnumerable : IEnumerable
{
    private AttachmentCollection underlyingCollection;</p>

```public AttachmentEnumerable(AttachmentCollection coll)
{ underlyingCollection = coll; }

public IEnumerator<Attachment> GetEnumerator()
{
    foreach (Attachment item in underlyingCollection)
    {
        yield return item;
    }
}

System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
{
    return this.GetEnumerator();
}
```

<p>}
```

Also the Attachment object contains only a URL that you have to download later on.

Body:
I can save an Attachment to a WorkItem like this:

TfsTeamProjectCollection tfsTeamProjects = new TfsTeamProjectCollection(new Uri(tfsServerUrl));
WorkItemStore tfsWorkItemStore = tfsTeamProjects.GetService<WorkItemStore>();
WorkItem tfsWorkItem = tfsWorkItemStore.GetWorkItem(tfsWorkItemId);

FileInfo fi = new FileInfo(@"D:\\Docs\testfile.txt");
Attachment tfsAttachment = new Attachment(fi.FullName);
tfsWorkItem.Attachments.Add(tfsAttachment);
tfsWorkItem.Save();

But when I try to get the list of Attachments for a WorkItem like this:

TfsTeamProjectCollection tfsTeamProjects = new TfsTeamProjectCollection(new Uri(tfsServerUrl));
WorkItemStore tfsWorkItemStore = tfsTeamProjects.GetService<WorkItemStore>();
WorkItem tfsWorkItem = tfsWorkItemStore.GetWorkItem(tfsWorkItemId);
foreach(Attachment tfsAttachment : tfsWorkItem.Attachments)
{
    // Do things here
}

tfsWorkItem.Attachments is always empty, even though I can see four attachments in the Objects tab on the TFS Web UI. And the WorkItem object that I am getting is the correct one.

Body:
I do not remember all details but the code I wrote a while ago use a wrapping class for enumeration that enables LINQ.

```
class AttachmentEnumerable : IEnumerable
{
    private AttachmentCollection underlyingCollection;</p>

<pre><code>public AttachmentEnumerable(AttachmentCollection coll)
{ underlyingCollection = coll; }

public IEnumerator<Attachment> GetEnumerator()
{
    foreach (Attachment item in underlyingCollection)
    {
        yield return item;
    }
}

System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
{
    return this.GetEnumerator();
}
</code></pre>

<p>}
```

Also the Attachment object contains only a URL that you have to download later on.


问:
Firebase Database.unitypackage is showing errors when imported into Unity
I imported the Firebase Database unity package into Unity and it is constantly showing me many errors.

```<code>Unable to find dependency com.google.android.gms:play-services-base:10.2.4 in paths ($SDK\extras\android\m2repository, $SDK\extras\google\m2repository).

com.google.android.gms:play-services-base:10.2.4 was referenced by:
   at System.Environment.get_StackTrace() in /Users/builduser/buildslave/mono/build/mcs/class/corlib/System/Environment.cs:line 227
   at Google.JarResolver.Dependency..ctor(System.String group, System.String artifact, System.String version, System.String[] packageIds, System.String[] repositories)
   at Google.JarResolver.PlayServicesSupport.DependOn(System.String group, System.String artifact, System.String version, System.String[] packageIds, System.String[] repositories)
   at System.Reflection.MonoMethod.InternalInvoke(System.Object , System.Object[] , System.Exception ByRef )
   at System.Reflection.MonoMethod.Invoke(System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) in /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:line 222
   at System.Reflection.MethodBase.Invoke(System.Object obj, System.Object[] parameters) in /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MethodBase.cs:line 115
   at Google.VersionHandler.InvokeMethod(System.Type type, System.Object objectInstance, System.String methodName, System.Object[] args, System.Collections.Generic.Dictionary`2 namedArgs)
   at Google.VersionHandler.InvokeInstanceMethod(System.Object objectInstance, System.String methodName, System.Object[] args, System.Collections.Generic.Dictionary`2 namedArgs)
   at FirebaseAppDeps.SetupDeps() in C:\Users\Public\Documents\Unity Projects\WHOT_2D\Assets\Firebase\Editor\AppDeps.cs:line 52
   at FirebaseAppDeps..cctor() in C:\Users\Public\Documents\Unity Projects\WHOT_2D\Assets\Firebase\Editor\AppDeps.cs:line 23
   at System.Runtime.CompilerServices.RuntimeHelpers.RunClassConstructor(IntPtr )
   at System.Runtime.CompilerServices.RuntimeHelpers.RunClassConstructor(RuntimeTypeHandle type) in /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Runtime.CompilerServices/RuntimeHelpers.cs:line 101
   at UnityEditor.EditorAssemblies.ProcessEditorInitializeOnLoad(System.Type type) in C:\buildslave\unity\build\Editor\Mono\EditorAssemblies.cs:line 136
   at UnityEditor.EditorAssemblies.ProcessInitializeOnLoadAttributes() in C:\buildslave\unity\build\Editor\Mono\EditorAssemblies.cs:line 162

UnityEngine.Debug:LogError(Object)
GooglePlayServices.PlayServicesResolver:<PlayServicesResolver>m__0(String, LogLevel)
Google.JarResolver.PlayServicesSupport:Log(String, LogLevel, Boolean)
Google.JarResolver.PlayServicesSupport:FindCandidate(Dependency, List`1)
Google.JarResolver.PlayServicesSupport:LoadDependencies(Dictionary`2, List`1, Boolean, Boolean)
Google.JarResolver.PlayServicesSupport:LoadDependencies(Boolean, Boolean, Boolean)
Google.JarResolver.PlayServicesSupport:FindMissingDependencyPaths(String, Dictionary`2&, ExplodeAar)
GooglePlayServices.ResolverVer1_1:DoResolution(PlayServicesSupport, String, OverwriteConfirmation, Action)
GooglePlayServices.PlayServicesResolver:Resolve(Action)
GooglePlayServices.PlayServicesResolver:MenuResolve()

Unable to find dependency com.google.firebase:firebase-common:10.2.4 in paths ($SDK\extras\android\m2repository, $SDK\extras\google\m2repository).
Unable to find dependency com.google.firebase:firebase-auth:10.2.4 in paths ($SDK\extras\android\m2repository, $SDK\extras\google\m2repository).
No compatible versions of com.google.android.gms:play-services-base:10.2.4 found given the set of required dependencies.
No compatible versions of com.google.firebase:firebase-common:10.2.4 found given the set of required dependencies.
</code>```

I tried Compiling the quick test sample database game like that for android, but i get "One or more Firebase dependencies are not present. Current dependency status: UnavailableOther".
So i tried using that Asserts > Play services Resolver > Android Resolver > Resolve Client Jars. It will print back this error lists instead. Please help me out.

答:
The Firebase plugin, like many other plugins, uses the Play services resolver to resolve required dependencies.

From the error message, looks like the resolver fails to find what it's looking for:

```<code>Unable to find dependency com.google.android.gms:play-services-base:10.2.4 in paths ($SDK\extras\android\m2repository, $SDK\extras\google\m2repository).
</code>```

Note that the path starts with $SDK, and not not an actual real folder.

You should make sure your Android SDK path is properly set in Unity under Preferences -> External Tools.

Also, make sure that you have the latest versions of Google play services (from SDK manager, make sure the stuff under "Extras" is up to date).

Body:
I imported the Firebase Database unity package into Unity and it is constantly showing me many errors.

Unable to find dependency com.google.android.gms:play-services-base:10.2.4 in paths ($SDK\extras\android\m2repository, $SDK\extras\google\m2repository).

com.google.android.gms:play-services-base:10.2.4 was referenced by:
   at System.Environment.get_StackTrace() in /Users/builduser/buildslave/mono/build/mcs/class/corlib/System/Environment.cs:line 227
   at Google.JarResolver.Dependency..ctor(System.String group, System.String artifact, System.String version, System.String[] packageIds, System.String[] repositories)
   at Google.JarResolver.PlayServicesSupport.DependOn(System.String group, System.String artifact, System.String version, System.String[] packageIds, System.String[] repositories)
   at System.Reflection.MonoMethod.InternalInvoke(System.Object , System.Object[] , System.Exception ByRef )
   at System.Reflection.MonoMethod.Invoke(System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) in /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:line 222
   at System.Reflection.MethodBase.Invoke(System.Object obj, System.Object[] parameters) in /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MethodBase.cs:line 115
   at Google.VersionHandler.InvokeMethod(System.Type type, System.Object objectInstance, System.String methodName, System.Object[] args, System.Collections.Generic.Dictionary`2 namedArgs)
   at Google.VersionHandler.InvokeInstanceMethod(System.Object objectInstance, System.String methodName, System.Object[] args, System.Collections.Generic.Dictionary`2 namedArgs)
   at FirebaseAppDeps.SetupDeps() in C:\Users\Public\Documents\Unity Projects\WHOT_2D\Assets\Firebase\Editor\AppDeps.cs:line 52
   at FirebaseAppDeps..cctor() in C:\Users\Public\Documents\Unity Projects\WHOT_2D\Assets\Firebase\Editor\AppDeps.cs:line 23
   at System.Runtime.CompilerServices.RuntimeHelpers.RunClassConstructor(IntPtr )
   at System.Runtime.CompilerServices.RuntimeHelpers.RunClassConstructor(RuntimeTypeHandle type) in /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Runtime.CompilerServices/RuntimeHelpers.cs:line 101
   at UnityEditor.EditorAssemblies.ProcessEditorInitializeOnLoad(System.Type type) in C:\buildslave\unity\build\Editor\Mono\EditorAssemblies.cs:line 136
   at UnityEditor.EditorAssemblies.ProcessInitializeOnLoadAttributes() in C:\buildslave\unity\build\Editor\Mono\EditorAssemblies.cs:line 162

UnityEngine.Debug:LogError(Object)
GooglePlayServices.PlayServicesResolver:<PlayServicesResolver>m__0(String, LogLevel)
Google.JarResolver.PlayServicesSupport:Log(String, LogLevel, Boolean)
Google.JarResolver.PlayServicesSupport:FindCandidate(Dependency, List`1)
Google.JarResolver.PlayServicesSupport:LoadDependencies(Dictionary`2, List`1, Boolean, Boolean)
Google.JarResolver.PlayServicesSupport:LoadDependencies(Boolean, Boolean, Boolean)
Google.JarResolver.PlayServicesSupport:FindMissingDependencyPaths(String, Dictionary`2&, ExplodeAar)
GooglePlayServices.ResolverVer1_1:DoResolution(PlayServicesSupport, String, OverwriteConfirmation, Action)
GooglePlayServices.PlayServicesResolver:Resolve(Action)
GooglePlayServices.PlayServicesResolver:MenuResolve()

Unable to find dependency com.google.firebase:firebase-common:10.2.4 in paths ($SDK\extras\android\m2repository, $SDK\extras\google\m2repository).
Unable to find dependency com.google.firebase:firebase-auth:10.2.4 in paths ($SDK\extras\android\m2repository, $SDK\extras\google\m2repository).
No compatible versions of com.google.android.gms:play-services-base:10.2.4 found given the set of required dependencies.
No compatible versions of com.google.firebase:firebase-common:10.2.4 found given the set of required dependencies.

I tried Compiling the quick test sample database game like that for android, but i get "One or more Firebase dependencies are not present. Current dependency status: UnavailableOther".
So i tried using that Asserts > Play services Resolver > Android Resolver > Resolve Client Jars. It will print back this error lists instead. Please help me out.

Body:
The Firebase plugin, like many other plugins, uses the Play services resolver to resolve required dependencies.

From the error message, looks like the resolver fails to find what it's looking for:

Unable to find dependency com.google.android.gms:play-services-base:10.2.4 in paths ($SDK\extras\android\m2repository, $SDK\extras\google\m2repository).

Note that the path starts with $SDK, and not not an actual real folder.

You should make sure your Android SDK path is properly set in Unity under Preferences -> External Tools.

Also, make sure that you have the latest versions of Google play services (from SDK manager, make sure the stuff under "Extras" is up to date).


问:
RxJava - fetch every item on the list
I have a method that returns an Observable<ArrayList<Long>>, which are ids of some Items. I'd like to go through this list and download every Item using another method that returns Observable<Item>.

How would I do this using RxJava operators?

答:
As an alternative to flatMapIterable you can do this with flatMap:

```<code>Observable.just(Arrays.asList(1, 2, 3)) //we create an Observable that emits a single array
            .flatMap(numberList -> Observable.fromIterable(numberList)) //map the list to an Observable that emits every item as an observable
            .flatMap(number -> downloadFoo(number)) //download smth on every number in the array
            .subscribe(...);

private ObservableSource<? extends Integer> downloadFoo(Integer number) {
   //TODO
}
</code>```

Personally I think .flatMap(numberList -> Observable.fromIterable(numberList)) is easier to read and understand than .flatMapIterable(numberList -> numberList ).

The difference seems to be the order (RxJava2):

Observable.fromIterable: Converts an Iterable sequence into an ObservableSource that emits the items in the sequence.

Observable.flatMapIterable: Returns an Observable that merges each item emitted by the source ObservableSource with the values in an Iterable corresponding to that item that is generated by a selector.

Using method references this looks like:

```<code>Observable.just(Arrays.asList(1, 2, 3))
            .flatMap(Observable::fromIterable)
            .flatMap(this::downloadFoo)
</code>```

Title: RxJava - fetch every item on the list

Body:
As an alternative to flatMapIterable you can do this with flatMap:

Observable.just(Arrays.asList(1, 2, 3)) //we create an Observable that emits a single array
            .flatMap(numberList -> Observable.fromIterable(numberList)) //map the list to an Observable that emits every item as an observable
            .flatMap(number -> downloadFoo(number)) //download smth on every number in the array
            .subscribe(...);

private ObservableSource<? extends Integer> downloadFoo(Integer number) {
   //TODO
}

Personally I think .flatMap(numberList -> Observable.fromIterable(numberList)) is easier to read and understand than .flatMapIterable(numberList -> numberList ).

The difference seems to be the order (RxJava2):

Observable.fromIterable: Converts an Iterable sequence into an ObservableSource that emits the items in the sequence.

Observable.flatMapIterable: Returns an Observable that merges each item emitted by the source ObservableSource with the values in an Iterable corresponding to that item that is generated by a selector.

Using method references this looks like:

Observable.just(Arrays.asList(1, 2, 3))
            .flatMap(Observable::fromIterable)
            .flatMap(this::downloadFoo)


问:
String delimiter is affecting some instances of its individual characters
So basically, I'm trying to print out a human readable list of file and directory sizes (without the current directory listed) with the following code

```<code>du -arh | sort -nr | tail -n +2 | awk -F"./" '{print $1 $2 $3}' | head -n $NUM
</code>```

The NUM variable is just an argument given for the amount of items listed.

The output of the above without the awk delimiter command is

4.0K  ./url-list

  4.0K  ./testurl.sh

  4.0K  ./diskhogger.sh

  4.0K  ./backup/url-list

  4.0K  ./backup.sh

However, adding the awk command outputs

4.0K  url-list

  4.0K    testurl.sh

  4.0K    diskhogger.sh

  4.0K    backuurl-list

  4.0K    backup.sh

A similar output occurs whenever there is a notable subdirectory.

./Library/Cache - LibrarCache, etc.

To be clear, I am attempting to cut out the "./" at the beginning of the file name without affecting the other forward slashes. My preferred output would be:

4.0K  url-list

  4.0K    testurl.sh

  4.0K    diskhogger.sh

  4.0K    backup/url-list

  4.0K    backup.sh

where the "backup/url-list" isn't affected.

Is the '.' in my delimiter a special character I don't know about? If not, what exactly is going on here?

I'm new to shell so any info on this would be great.

Thanks!

Edited for clarity.

答:
Yes. awk treats the delimiter as a regular expression. A "." in a regular expression matches any character. Hence awk will split your lines up everywhere there is a character preceding a "/".
If you wish to match a literal ".", the easiest way of doing it is to put it in square brackets, to make it a character class, matching only the character "."

You end up with

```<code>du -arh | sort -nr | tail -n +2 | awk -F"[.]/" '{print $1 $2}' | head -n $NUM
</code>```

However, note that this is not your only problem. If you have a directory whose name ends with a "." and that directory contains files, you will have more than one entry of "./" on some lines in the results from "du". (e.g. a file named "bar" in a directory named "foo." gives you "foo./bar".) A better solution is therefore to use the sub() function in awk to replace the first instance of "./" with "".

```<code>du -arh | sort -nr | tail -n +2 | awk '{sub("./",""); print}' | head -n $NUM
</code>```

Body:
So basically, I'm trying to print out a human readable list of file and directory sizes (without the current directory listed) with the following code

du -arh | sort -nr | tail -n +2 | awk -F"./" '{print $1 $2 $3}' | head -n $NUM

The NUM variable is just an argument given for the amount of items listed.

The output of the above without the awk delimiter command is

4.0K  ./url-list

  4.0K  ./testurl.sh

  4.0K  ./diskhogger.sh

  4.0K  ./backup/url-list

  4.0K  ./backup.sh

However, adding the awk command outputs

4.0K  url-list

  4.0K    testurl.sh

  4.0K    diskhogger.sh

  4.0K    backuurl-list

  4.0K    backup.sh

A similar output occurs whenever there is a notable subdirectory.

./Library/Cache - LibrarCache, etc.

To be clear, I am attempting to cut out the "./" at the beginning of the file name without affecting the other forward slashes. My preferred output would be:

4.0K  url-list

  4.0K    testurl.sh

  4.0K    diskhogger.sh

  4.0K    backup/url-list

  4.0K    backup.sh

where the "backup/url-list" isn't affected.

Is the '.' in my delimiter a special character I don't know about? If not, what exactly is going on here?

I'm new to shell so any info on this would be great.

Thanks!

Edited for clarity.

Body:
Yes. awk treats the delimiter as a regular expression. A "." in a regular expression matches any character. Hence awk will split your lines up everywhere there is a character preceding a "/".
If you wish to match a literal ".", the easiest way of doing it is to put it in square brackets, to make it a character class, matching only the character "."

You end up with

du -arh | sort -nr | tail -n +2 | awk -F"[.]/" '{print $1 $2}' | head -n $NUM

However, note that this is not your only problem. If you have a directory whose name ends with a "." and that directory contains files, you will have more than one entry of "./" on some lines in the results from "du". (e.g. a file named "bar" in a directory named "foo." gives you "foo./bar".) A better solution is therefore to use the sub() function in awk to replace the first instance of "./" with "".

du -arh | sort -nr | tail -n +2 | awk '{sub("./",""); print}' | head -n $NUM


问:
Convert RDD List to RDD of individual element in spark
I have a input rdd (JavaRDD<List<String>>) and i want to convert it to JavaRDD<String> as output.

Each element of input RDD list should become a individual element in output rdd.

how to achieve it in java?

```<code>JavaRDD<List<String>> input; //suppose rdd length is 2
input.saveAsTextFile(...)
</code>```

output:

[a,b]
 [c,d]

what i want:

a
 b
c
d

答:
If the rdd type is RDD[List[String]], you can just do this:

val newrdd = rdd.flatmap(line => line)

Each of the elements will be a new line in the new rdd.

Body:
I have a input rdd (JavaRDD<List<String>>) and i want to convert it to JavaRDD<String> as output.

Each element of input RDD list should become a individual element in output rdd.

how to achieve it in java?

JavaRDD<List<String>> input; //suppose rdd length is 2
input.saveAsTextFile(...)

output:

[a,b]
 [c,d]

what i want:

a
 b
c
d


问:
Javascript send string to python-script
I have an (html/js) application running on my localhost. I'd like to send some information (string) to a python script running in the background, which will just print the string, or save it as a .txt-file.

It seems websockets will do the job, but I cannot get around this (in my eyes a simple problem..?). All examples or libraries aims at specific usages or are depricated in the meanwhile. Also, maybe someone can point me to another principle like REST.?
 I'm not really into web/ip/internetthings, but I need this to let the webpage initiate some python programs.
Any tips on how to achieve this?

答:
I am doing something similar to have a web server (nodejs) control my raspberrypi (python).
I suggest you simply spawn your python script by your js server and make them communicate via stdin/stdout.

For example with nodejs:

```<code>var spawn = require('child_process').spawn;
var child = spawn(
    'python3',
    ['./py/pi-ctrl.py']
);
var child_emit = function (message) {
    child.stdin.write(message+"\n");
}
</code>```

Then your js can just 'emit' anything to your python script, which listens to stdin:

```<code>while True:
    line = input().split()
</code>```

Title: Javascript send string to python-script

Body:
I am doing something similar to have a web server (nodejs) control my raspberrypi (python).
I suggest you simply spawn your python script by your js server and make them communicate via stdin/stdout.

For example with nodejs:

var spawn = require('child_process').spawn;
var child = spawn(
    'python3',
    ['./py/pi-ctrl.py']
);
var child_emit = function (message) {
    child.stdin.write(message+"\n");
}

Then your js can just 'emit' anything to your python script, which listens to stdin:

while True:
    line = input().split()


问:
Log4j2 configuration - No log4j2 configuration file found
Lately I decided to learn how to use the log4j2 logger. I downloaded required jar files, created library, xml comfiguration file and tried to use it. Unfortunately i get this statement in console (Eclipse) :

```<code>ERROR StatusLogger No log4j2 configuration file found. Using default configuration:       logging only errors to the console.
</code>```

This is my testing class code:

```<code>package log4j.test;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

public class Log4jTest
{
    static final Logger logger = LogManager.getLogger(Logger.class.getName());

    public static void main(String[] args) {
        logger.trace("trace");
        logger.debug("debug");
        logger.info("info");
        logger.warn("warn");
        logger.error("error");
        logger.fatal("fatal");
    }
}
</code>```

And my xml config file:

```<code><?xml version="1.0" encoding="UTF-8"?>
<Configuration package="log4j.test"
               status="WARN">
    <Appenders>
        <Console name="Console" target="SYSTEM_OUT">
            <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
        </Console>
    </Appenders>
    <Loggers>
        <Logger name="log4j.test.Log4jTest" level="trace">
            <AppenderRef ref="Console"/>
        </Logger>
        <Root level="trace">
            <AppenderRef ref="Console"/>
        </Root>
    </Loggers>
</Configuration>
</code>```

I tried also with xml without <Logger> tags, and package specification and in various folders/packages directories, but it didn't help. Now my log4j2.xml file is located directly in project folder in eclipse.

答: In my case I had to put it in the bin folder of my project even the fact that my classpath is set to the src folder. I have no idea why, but it's worth a try.</p>

Body:
Lately I decided to learn how to use the log4j2 logger. I downloaded required jar files, created library, xml comfiguration file and tried to use it. Unfortunately i get this statement in console (Eclipse) :

ERROR StatusLogger No log4j2 configuration file found. Using default configuration:       logging only errors to the console.

This is my testing class code:

package log4j.test;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

public class Log4jTest
{
    static final Logger logger = LogManager.getLogger(Logger.class.getName());

    public static void main(String[] args) {
        logger.trace("trace");
        logger.debug("debug");
        logger.info("info");
        logger.warn("warn");
        logger.error("error");
        logger.fatal("fatal");
    }
}

And my xml config file:

<?xml version="1.0" encoding="UTF-8"?>
<Configuration package="log4j.test"
               status="WARN">
    <Appenders>
        <Console name="Console" target="SYSTEM_OUT">
            <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
        </Console>
    </Appenders>
    <Loggers>
        <Logger name="log4j.test.Log4jTest" level="trace">
            <AppenderRef ref="Console"/>
        </Logger>
        <Root level="trace">
            <AppenderRef ref="Console"/>
        </Root>
    </Loggers>
</Configuration>

I tried also with xml without <Logger> tags, and package specification and in various folders/packages directories, but it didn't help. Now my log4j2.xml file is located directly in project folder in eclipse.


问:
join strings in JS
I have an array A and array B:

```<code>A = ["1234","5678","4444"]
B = 7868,9090
</code>```

I want array C to be:

```<code>C = ["1234","5678","4444","7868","9090"]
</code>```

The length of array A and B can vary and array B should join the end of array A.

What is the best way to do this?

I tried using push() but I'm still having problems.

Thank you.

答:
What exactly do you mean with B = 7868,9090? That is incorrect JavaScript and produces a syntax error when trying to run it.

How to produce output ["1234", "5678", "4444", "7868", "9090"] depends on what is actually the correct input value for B. Depending on whether B is an array of integers, an array of strings or a comma separated string, you'll need to take a different approach.

If B is an array of integers

Can I assume you mean var B = [7868,9090];, meaning that B is an array of integers? In that case the simplest way to get the expected result, would be to do this :

```<code>var result = A.concat(B.map(function(x) {return "" + x;}));
</code>```

Explanation

var arr3 = arr1.concat(arr2) allows you to merge arr1 and arr2 and output the result to arr3

var arr2 = arr1.map(f(x)) allows you to loop through all elements x of arr1 and output the outcome of function f to arr2

var y = "" + x allows you to convert an integer value x and output it to y

Demo

var A = ["1234","5678","4444"];
var B = [7868,9090];

var result = A.concat(B.map(function(x) {return "" + x;}));

console.log(result);```
</div>
</div>
</p>

<p>See also <strong>this Fiddle</strong>.</p>

<hr>

<h1>If B is an array of strings</h1>

<p>If <code>var B = ["7868","9090"];</code> is actually the correct input, you don't need the <code>var arr2 = arr1.map(f(x))</code> and <code>var y = "" + x</code> bits and you can just do this :</p>

```var result = A.concat(B);
```

<hr>

<h1>If B is a comma separated string</h1>

<p>If <code>var B = "7868,9090";</code> is actually the correct input, you don't need the <code>var arr2 = arr1.map(f(x))</code> and <code>var y = "" + x</code> bits either, but you will need to split <code>B</code> into an array :</p>

```var result = A.concat(B.split(','));
```

Title: join strings in JS

Body:
I have an array A and array B:

A = ["1234","5678","4444"]
B = 7868,9090

I want array C to be:

C = ["1234","5678","4444","7868","9090"]

The length of array A and B can vary and array B should join the end of array A.

What is the best way to do this?

I tried using push() but I'm still having problems.

Thank you.

Body:
What exactly do you mean with B = 7868,9090? That is incorrect JavaScript and produces a syntax error when trying to run it.

How to produce output ["1234", "5678", "4444", "7868", "9090"] depends on what is actually the correct input value for B. Depending on whether B is an array of integers, an array of strings or a comma separated string, you'll need to take a different approach.

If B is an array of integers

Can I assume you mean var B = [7868,9090];, meaning that B is an array of integers? In that case the simplest way to get the expected result, would be to do this :

var result = A.concat(B.map(function(x) {return "" + x;}));

Explanation

var arr3 = arr1.concat(arr2) allows you to merge arr1 and arr2 and output the result to arr3

var arr2 = arr1.map(f(x)) allows you to loop through all elements x of arr1 and output the outcome of function f to arr2

var y = "" + x allows you to convert an integer value x and output it to y

Demo

var A = ["1234","5678","4444"];
var B = [7868,9090];

var result = A.concat(B.map(function(x) {return "" + x;}));

console.log(result);

See also this Fiddle.

If B is an array of strings

If var B = ["7868","9090"]; is actually the correct input, you don't need the var arr2 = arr1.map(f(x)) and var y = "" + x bits and you can just do this :

var result = A.concat(B);

If B is a comma separated string

If var B = "7868,9090"; is actually the correct input, you don't need the var arr2 = arr1.map(f(x)) and var y = "" + x bits either, but you will need to split B into an array :

var result = A.concat(B.split(','));


问:
how to render disabled button by if statement?
I want to disable a button in a react component when a state of checkedIds is empty, the code to disable button is just like this:

```<code><Button disabled> disabled </Button>
</code>```

But when I try this it don't work

```<code><Button {if(this.state.checkedIds.length===0) {
    return disabled;
  }}>
      Delete Selected
  </Button>
</code>```

Help?

答:
This should work.</p>

```<code><Button disabled={this.state.checkedIds.length===0} >
  Delete Selected
</Button>
</code>```

Body:
I want to disable a button in a react component when a state of checkedIds is empty, the code to disable button is just like this:

<Button disabled> disabled </Button>

But when I try this it don't work

<Button {if(this.state.checkedIds.length===0) {
    return disabled;
  }}>
      Delete Selected
  </Button>

Help?

Body:
This should work.

<Button disabled={this.state.checkedIds.length===0} >
  Delete Selected
</Button>


问:
Bootstrap - reversing my navbar to Right-to-Left
Im trying to make a navbar but I need it to be from Right to Left cause its in Hebrew.

I tried making a responsive Navbar Where all the linked buttons are on the Left and Going Right.
And a Brand on the Right side.
And they collapse on Small devices.

Well I cant get it to reverse and I also sometimes get an issue where on small devices the Brand and the Collapse button collide in the middle of the navbar.

答:
Well I fixed it by adding:

```<code>body{
    direction: rtl;
}
</code>```

to my css...

Thanks for the help and sorry for misleading you by my wrong title D:

Body:
Well I fixed it by adding:

body{
    direction: rtl;
}

to my css...

Thanks for the help and sorry for misleading you by my wrong title D:


问:
Java CSV Formatting Issues
I am reading a HashMap and creating a CSV file.
The below code accepts a HashMap and produce a CSV file. However the formatting is a problem. For a HashMap,

```<code>HashMap<String, Integer> hmap = new HashMap<String, Integer>();
hmap.put("Feature1", 1);
hmap.put("Feature2", 2);
</code>```

It produces

```<code>Feature2,Feature2,
2,1,Feature1,Feature1,
2,1,
</code>```

Expected Output (without comma at the end of each line):

```<code>Feature2,Feature1
2,1
</code>```

Which is  a wrong formatting

This is the code I use. How to fix it ?

```<code>public String appendCSV(Map featureset) throws IOException{
    StringBuilder csvReport = new StringBuilder();

    Map<String, Integer> map =featureset;
    Set<String> keys = map.keySet();

    String[] lsitofkeys = {};

    for(String elements:keys){
        for(int i =0 ; i< keys.size(); i++){
             csvReport.append(elements+",");
        }
        csvReport.append("\n");
        for(String key: keys){
            csvReport.append(map.get(key).toString()+",");
        }
    }

  return csvReport.toString();
}
</code>```

答:
seems you have issues with your loop

you need two separate loops (no inner loops);

Also to get rid of that comma at the end, you can use a simple check using a isFirst variable like below :)

```<code>public String appendCSV(Map featureset) throws IOException{
  StringBuilder csvReport = new StringBuilder();

  Map<String, Integer> map =featureset;
  Set<String> keys = map.keySet();

  String[] lsitofkeys = {};
  boolean isFirst=true;
  for(String elements : keys){
     if(!isFirst){
       csvReport.append(",");
     }
     csvReport.append(elements);
     isFirst=false;
  }

  csvReport.append("\n");

  isFirst=true;
  for(String elements : keys){
     if(!isFirst){
       csvReport.append(",");
     }
   csvReport.append(map.get(elements));
   isFirst=false;
  }

  return csvReport.toString();
}
</code>```

Title: Java CSV Formatting Issues

Body:
I am reading a HashMap and creating a CSV file.
The below code accepts a HashMap and produce a CSV file. However the formatting is a problem. For a HashMap,

HashMap<String, Integer> hmap = new HashMap<String, Integer>();
hmap.put("Feature1", 1);
hmap.put("Feature2", 2);

It produces

Feature2,Feature2,
2,1,Feature1,Feature1,
2,1,

Expected Output (without comma at the end of each line):

Feature2,Feature1
2,1

Which is  a wrong formatting

This is the code I use. How to fix it ?

public String appendCSV(Map featureset) throws IOException{
    StringBuilder csvReport = new StringBuilder();

    Map<String, Integer> map =featureset;
    Set<String> keys = map.keySet();

    String[] lsitofkeys = {};

    for(String elements:keys){
        for(int i =0 ; i< keys.size(); i++){
             csvReport.append(elements+",");
        }
        csvReport.append("\n");
        for(String key: keys){
            csvReport.append(map.get(key).toString()+",");
        }
    }

  return csvReport.toString();
}

Body:
seems you have issues with your loop

you need two separate loops (no inner loops);

Also to get rid of that comma at the end, you can use a simple check using a isFirst variable like below :)

public String appendCSV(Map featureset) throws IOException{
  StringBuilder csvReport = new StringBuilder();

  Map<String, Integer> map =featureset;
  Set<String> keys = map.keySet();

  String[] lsitofkeys = {};
  boolean isFirst=true;
  for(String elements : keys){
     if(!isFirst){
       csvReport.append(",");
     }
     csvReport.append(elements);
     isFirst=false;
  }

  csvReport.append("\n");

  isFirst=true;
  for(String elements : keys){
     if(!isFirst){
       csvReport.append(",");
     }
   csvReport.append(map.get(elements));
   isFirst=false;
  }

  return csvReport.toString();
}


问:
Use KONG as API Gateway to GraphQL/REST services
I'm trying to understand if it's possible to use KONG as API Gateway to microservices implementing REST and/or GraphQL interfaces

As API Gateway will expose a GraphQL API and will request to our microservices currently implemented in REST/GraphQL and grpc coming soon.

答: It can route the Graphql as any other HTTP request but it doesn't parse graphql to route each bit to a a specific service</p>