问:
How can I do this custom Select All function to work?
I have two connected classes: the Smartphone and the Model. The Smartphone contains a collection of Model that looks like this:

```<code>public class Smartphone
{
    public string BrandName { get; set; }
    public ObservableCollection<Model> Models { get; set; } = new ObservableCollection<Model>();
}
</code>```

while the Model:

```<code>public class Smartphone
{
    public string ModelName { get; set; }
}
</code>```

Then I added another property in the Model class:

```<code>public const string IsSelectPropertyName = "IsSelect";

private bool _isSelect = false;

public bool IsSelect
{
    get
    {
        return _isSelect ;
    }
    set
    {
        Set(IsSelectPropertyName, ref _isSelect , value);
    }
}
</code>```

Then the SelectAll in the Smartphone class:

```<code>private bool _selectAll;

public bool SelectAll
{
    get
    {
        return _selectAll;
    }
    set
    {
        _selectAll = value;
        foreach (var item in Models)
        {
            item.IsSelect = value;
        }
        Set(() => SelectAll, ref _selectAll, value);
    }
}
</code>```

The problem here is if one item is unchecked, the SelectAll is still checked. What I tried so far is having this function in Smartphone class :

```<code>public void CheckSelected()
{
    bool isUnchecked = Models.Select(item => item.IsSelect).AsQueryable().All(value => value == false);

    if (isUnchecked)
    {
        SelectAll = false;
    } else
    {
        SelectAll = true;
    }
}
</code>```

However, if added into the IsSelect property in the Model class like this:

```<code>public const string IsSelectPropertyName = "IsSelect";

private bool _isSelect = false;

public bool IsSelect
{
    get
    {
        return _isSelect ;
    }
    set
    {
        Set(IsSelectPropertyName, ref _isSelect , value);
        if (Smartphone != null)
        {
            Smartphone.CheckSelected();
        }
    }
}
</code>```

I got error like:

StackoverflowException

答:
The problem is that you get in your SelectAll and IsSelect setters all the time, as you call CheckSelect() -> SelectAll -> IsSelect -> CheckSelect() in a loop.

One possible solution is to react in the setter of a property only when the value has actually be changed. The code might look like this:

```<code>get
{
    return _isSelect ;
}
set
{
    if (_isSelect == value)
        return; // don't do anything, nothing has been changed
    Set(IsSelectPropertyName, ref _isSelect , value);
    if (Smartphone != null)
    {
        Smartphone.CheckSelected();
    }
}
</code>```

You will get inside the setter for the first time, but at the second time the field _isSelect has already been changed and you exit the setter with the return statement in the if() body. This also means that the following Smartphone.CheckSelected(); call is not executed, "breaking" the loop.

Body:
I have two connected classes: the Smartphone and the Model. The Smartphone contains a collection of Model that looks like this:

public class Smartphone
{
    public string BrandName { get; set; }
    public ObservableCollection<Model> Models { get; set; } = new ObservableCollection<Model>();
}

while the Model:

public class Smartphone
{
    public string ModelName { get; set; }
}

Then I added another property in the Model class:

public const string IsSelectPropertyName = "IsSelect";

private bool _isSelect = false;

public bool IsSelect
{
    get
    {
        return _isSelect ;
    }
    set
    {
        Set(IsSelectPropertyName, ref _isSelect , value);
    }
}

Then the SelectAll in the Smartphone class:

private bool _selectAll;

public bool SelectAll
{
    get
    {
        return _selectAll;
    }
    set
    {
        _selectAll = value;
        foreach (var item in Models)
        {
            item.IsSelect = value;
        }
        Set(() => SelectAll, ref _selectAll, value);
    }
}

The problem here is if one item is unchecked, the SelectAll is still checked. What I tried so far is having this function in Smartphone class :

public void CheckSelected()
{
    bool isUnchecked = Models.Select(item => item.IsSelect).AsQueryable().All(value => value == false);

    if (isUnchecked)
    {
        SelectAll = false;
    } else
    {
        SelectAll = true;
    }
}

However, if added into the IsSelect property in the Model class like this:

public const string IsSelectPropertyName = "IsSelect";

private bool _isSelect = false;

public bool IsSelect
{
    get
    {
        return _isSelect ;
    }
    set
    {
        Set(IsSelectPropertyName, ref _isSelect , value);
        if (Smartphone != null)
        {
            Smartphone.CheckSelected();
        }
    }
}

I got error like:

StackoverflowException

Body:
The problem is that you get in your SelectAll and IsSelect setters all the time, as you call CheckSelect() -> SelectAll -> IsSelect -> CheckSelect() in a loop.

One possible solution is to react in the setter of a property only when the value has actually be changed. The code might look like this:

get
{
    return _isSelect ;
}
set
{
    if (_isSelect == value)
        return; // don't do anything, nothing has been changed
    Set(IsSelectPropertyName, ref _isSelect , value);
    if (Smartphone != null)
    {
        Smartphone.CheckSelected();
    }
}

You will get inside the setter for the first time, but at the second time the field _isSelect has already been changed and you exit the setter with the return statement in the if() body. This also means that the following Smartphone.CheckSelected(); call is not executed, "breaking" the loop.


来源: stackexchange

问:
java.security.NoSuchAlgorithmException: SSL_TLSv2 SSLContext not available
I have problems while connecting IBM MQ from JBoss with SSL on JRE 1.8 (jdk1.8.0_101)

I comment below line on java.security but nothing changes:

```<code>jdk.certpath.disabledAlgorithms=MD2, MD5, RSA keySize < 1024
</code>```

```<code>Caused by: com.ibm.msg.client.jms.DetailedJMSException: JMSWMQ0018: Failed to connect to queue manager 'xxxxx' with connection mode 'Client' and host name 'xxxx'.Check the queue manager is started and if running in client mode, check there is a listener running. Please see the linked exception for more information.
at com.ibm.msg.client.wmq.common.internal.Reason.reasonToException(Reason.java:580)
at com.ibm.msg.client.wmq.common.internal.Reason.createException(Reason.java:216)
at com.ibm.msg.client.wmq.internal.WMQConnection.<init>(WMQConnection.java:431)
at com.ibm.msg.client.wmq.internal.WMQXAConnection.<init>(WMQXAConnection.java:70)
at com.ibm.msg.client.wmq.factories.WMQXAConnectionFactory.createV7ProviderConnection(WMQXAConnectionFactory.java:190)
at com.ibm.msg.client.wmq.factories.WMQConnectionFactory.createProviderConnection(WMQConnectionFactory.java:6157)
at com.ibm.msg.client.wmq.factories.WMQXAConnectionFactory.createProviderXAConnection(WMQXAConnectionFactory.java:102)
at com.ibm.msg.client.jms.admin.JmsConnectionFactoryImpl.createXAConnectionInternal(JmsConnectionFactoryImpl.java:364)
at com.ibm.mq.jms.MQXAConnectionFactory.createXAConnection(MQXAConnectionFactory.java:124)
at com.ibm.mq.connector.ConnectionBuilder.createConnection(ConnectionBuilder.java:167)
... 22 more **Caused by: com.ibm.mq.MQException: JMSCMQ0001: WebSphere MQ call failed with compcode '2' ('MQCC_FAILED') reason '2393' ('MQRC_SSL_INITIALIZATION_ERROR')**.
at com.ibm.msg.client.wmq.common.internal.Reason.createException(Reason.java:204)
... 30 more Caused by: com.ibm.mq.jmqi.JmqiException: CC=2;RC=2393;AMQ9204: Connection to host 'xxxxx' rejected. [1=com.ibm.mq.jmqi.JmqiException[CC=2;RC=2393],3=xxxxx(1428),5=RemoteTCPConnection.buildTLSV1_2SocketFactory]
at com.ibm.mq.jmqi.remote.api.RemoteFAP.jmqiConnect(RemoteFAP.java:2098)
at com.ibm.mq.jmqi.remote.api.RemoteFAP.jmqiConnect(RemoteFAP.java:1347)
at com.ibm.msg.client.wmq.internal.WMQConnection.<init>(WMQConnection.java:350)
... 29 more  Caused by: com.ibm.mq.jmqi.JmqiException: CC=2;RC=2393
at com.ibm.mq.jmqi.remote.impl.RemoteTCPConnection.buildTLSV1_2SocketFactory(RemoteTCPConnection.java:2480)
at com.ibm.mq.jmqi.remote.impl.RemoteTCPConnection.chooseSocketFactory(RemoteTCPConnection.java:2130)
at com.ibm.mq.jmqi.remote.impl.RemoteTCPConnection.makeSocketSecure(RemoteTCPConnection.java:1945)
at com.ibm.mq.jmqi.remote.impl.RemoteTCPConnection.connnectUsingLocalAddress(RemoteTCPConnection.java:855)
at com.ibm.mq.jmqi.remote.impl.RemoteTCPConnection.protocolConnect(RemoteTCPConnection.java:1262)
at com.ibm.mq.jmqi.remote.impl.RemoteConnection.connect(RemoteConnection.java:714)
at com.ibm.mq.jmqi.remote.impl.RemoteConnectionSpecification.getSessionFromNewConnection(RemoteConnectionSpecification.java:356)
at com.ibm.mq.jmqi.remote.impl.RemoteConnectionSpecification.getSession(RemoteConnectionSpecification.java:265)
at com.ibm.mq.jmqi.remote.impl.RemoteConnectionPool.getSession(RemoteConnectionPool.java:144)
at com.ibm.mq.jmqi.remote.api.RemoteFAP.jmqiConnect(RemoteFAP.java:1709)
... 31 more **Caused by: java.security.NoSuchAlgorithmException: SSL_TLSv2 SSLContext not available**
at sun.security.jca.GetInstance.getInstance(GetInstance.java:159) [rt.jar:1.8.0_101]
at javax.net.ssl.SSLContext.getInstance(SSLContext.java:156) [rt.jar:1.8.0_101]
at com.ibm.mq.jmqi.remote.impl.RemoteTCPConnection.buildTLSV1_2SocketFactory(RemoteTCPConnection.java:2461)
... 40 more
</code>```

UPDATED: After below changes, new error like this:
TLS_RSA_WITH_AES_128_CBC_SHA256
JVM Arguments added: -Dcom.ibm.mq.cfg.useIBMCipherMappings=false

```<code>Caused by: com.ibm.msg.client.jms.DetailedIllegalStateException: JMSWMQ0018: Failed to connect to queue manager 'mqtap.uyg.uat11' with connection mode 'Client' and host name 'xxx'. Check the queue manager is started and if running in client mode, check there is a listener running. Please see the linked exception for more information.
at com.ibm.msg.client.wmq.common.internal.Reason.reasonToException(Reason.java:474)
at com.ibm.msg.client.wmq.common.internal.Reason.createException(Reason.java:216)
at com.ibm.msg.client.wmq.internal.WMQConnection.<init>(WMQConnection.java:431)
at com.ibm.msg.client.wmq.internal.WMQXAConnection.<init>(WMQXAConnection.java:70)
at com.ibm.msg.client.wmq.factories.WMQXAConnectionFactory.createV7ProviderConnection(WMQXAConnectionFactory.java:190)
at com.ibm.msg.client.wmq.factories.WMQConnectionFactory.createProviderConnection(WMQConnectionFactory.java:6157)
at com.ibm.msg.client.wmq.factories.WMQXAConnectionFactory.createProviderXAConnection(WMQXAConnectionFactory.java:102)
at com.ibm.msg.client.jms.admin.JmsConnectionFactoryImpl.createXAConnectionInternal(JmsConnectionFactoryImpl.java:364)
at com.ibm.mq.jms.MQXAConnectionFactory.createXAConnection(MQXAConnectionFactory.java:124)
at com.ibm.mq.connector.ConnectionBuilder.createConnection(ConnectionBuilder.java:167)
... 22 more Caused by: com.ibm.mq.MQException: JMSCMQ0001: WebSphere MQ call failed with compcode '2' ('MQCC_FAILED') reason '2059' ('MQRC_Q_MGR_NOT_AVAILABLE').
at com.ibm.msg.client.wmq.common.internal.Reason.createException(Reason.java:204)
... 30 more Caused by: com.ibm.mq.jmqi.JmqiException: CC=2;RC=2059;AMQ9204: Connection to host 'xxx' rejected. [1=com.ibm.mq.jmqi.JmqiException[CC=2;RC=2059;AMQ9503: Channel negotiation failed. [3=xxx]],3=xxx,5=RemoteConnection.analyseErrorSegment]
at com.ibm.mq.jmqi.remote.api.RemoteFAP.jmqiConnect(RemoteFAP.java:2098)
at com.ibm.mq.jmqi.remote.api.RemoteFAP.jmqiConnect(RemoteFAP.java:1347)
at com.ibm.msg.client.wmq.internal.WMQConnection.<init>(WMQConnection.java:350)
... 29 more Caused by: com.ibm.mq.jmqi.JmqiException: CC=2;RC=2059;AMQ9503: Channel negotiation failed. [3=xxx]
at com.ibm.mq.jmqi.remote.impl.RemoteConnection.analyseErrorSegment(RemoteConnection.java:3850)
at com.ibm.mq.jmqi.remote.impl.RemoteConnection.receiveTSH(RemoteConnection.java:2749)
at com.ibm.mq.jmqi.remote.impl.RemoteConnection.initSess(RemoteConnection.java:1024)
at com.ibm.mq.jmqi.remote.impl.RemoteConnection.connect(RemoteConnection.java:717)
at com.ibm.mq.jmqi.remote.impl.RemoteConnectionSpecification.getSessionFromNewConnection(RemoteConnectionSpecification.java:356)
at com.ibm.mq.jmqi.remote.impl.RemoteConnectionSpecification.getSession(RemoteConnectionSpecification.java:265)
at com.ibm.mq.jmqi.remote.impl.RemoteConnectionPool.getSession(RemoteConnectionPool.java:144)
at com.ibm.mq.jmqi.remote.api.RemoteFAP.jmqiConnect(RemoteFAP.java:1709)
... 31 more
</code>```

UPDATED output of javax.net.debug=ssl:

```<code>trustStore is: C:\dev\eclipse\workspace\XXX\src\main\application\config\XXX\keystore.jks
trustStore type is : jks
trustStore provider is :
init truststore

adding as trusted cert:
  Subject: CN=mqClientmqtap.uyg.uat, OU=XXX BT, O=XXX TAS, L=XXX, C=TR
  Issuer:  CN=mqClientmqtap.uyg.uat, OU=XXX BT, O=XXX TAS, L=XXX, C=TR
  Algorithm: RSA; Serial number: 0x5889a408
  Valid from Thu Jan 26 10:23:52 EET 2017 until Sun Jan 24 10:23:52 EET 2027

adding as trusted cert:
  Subject: CN=mqServermqtap.uyg.uat11, OU=XXX BT, O=XXX TAS, L=XXX, C=TR
  Issuer:  CN=mqServermqtap.uyg.uat11, OU=XXX BT, O=XXX TAS, L=XXX, C=TR
  Algorithm: RSA; Serial number: 0x588996d3
  Valid from Thu Jan 26 09:27:31 EET 2017 until Sun Jan 24 09:27:31 EET 2027

adding as trusted cert:
  Subject: CN=mqServermqtap.uyg.uat12, OU=XXX BT, O=XXX TAS, L=XXX, C=TR
  Issuer:  CN=mqServermqtap.uyg.uat12, OU=XXX BT, O=XXX TAS, L=XXX, C=TR
  Algorithm: RSA; Serial number: 0x5889994c
  Valid from Thu Jan 26 09:38:04 EET 2017 until Sun Jan 24 09:38:04 EET 2027

trigger seeding of SecureRandom
done seeding SecureRandom

Allow unsafe renegotiation: falseAllow legacy hello messages: XXXueIs initial handshake: XXXueIs secure renegotiation: false
    %% No cached client session
    *** ClientHello, TLSv1.2
    RandomCookie:  GMT: 1573949056 bytes = { 248, 4, 131, 18, 179, 77, 58, 163, 213, 86, 162, 39, 153, 233, 66, 82, 68, 140, 162, 144, 245, 223, 148, 131, 41, 17, 182, 13 }
    Session ID:  {}
    Cipher Suites: [TLS_RSA_WITH_AES_128_CBC_SHA256]
    Compression Methods:  { 0 }
    Extension signature_algorithms, signature_algorithms: SHA512withECDSA, SHA512withRSA, SHA384withECDSA, SHA384withRSA, SHA256withECDSA, SHA256withRSA, SHA1withECDSA, SHA1withRSA, SHA1withDSA
    Extension server_name, server_name: [type=host_name (0), value=mqkont1.XXX.com.XXX]
    Extension renegotiation_info, renegotiated_connection: <empty>
    ***
    jmsContainerBean_DEVOPS_DEVOPS_CONSUME_MESSAGE-1, WRITE: TLSv1.2 Handshake, length = 106
    jmsContainerBean_DEVOPS_DEVOPS_CONSUME_MESSAGE-1, READ: TLSv1.2 Handshake, length = 1247
    *** ServerHello, TLSv1.2
    RandomCookie:  GMT: 710208142 bytes = { 152, 40, 119, 253, 151, 47, 206, 243, 81, 108, 25, 227, 196, 180, 235, 231, 180, 213, 136, 245, 68, 79, 87, 78, 71, 82, 68, 1 }
    Session ID:  {233, 220, 107, 227, 28, 86, 6, 240, 170, 113, 171, 164, 93, 132, 7, 120, 51, 79, 103, 215, 78, 157, 179, 176, 103, 14, 128, 68, 104, 28, 158, 75}
    Cipher Suite: TLS_RSA_WITH_AES_128_CBC_SHA256
    Compression Method: 0
    Extension renegotiation_info, renegotiated_connection: <empty>
    ***
    %% Initialized:  [Session-2, TLS_RSA_WITH_AES_128_CBC_SHA256]
    ** TLS_RSA_WITH_AES_128_CBC_SHA256
    *** Certificate chain
    chain [0] = [[  Version: V3  Subject: CN=mqServermqtap.uyg.uat11, OU=XXX BT, O=XXX TAS, L=XXX, C=XXX  Signature Algorithm: SHA256withRSA, OID = 1.2.840.113549.1.1.11  Key:  Sun RSA public key, 2048 bits  modulus: 16868959742511831543539228188322318728282173929458725924838613545208147879023122029920833782971719231363516671703224653599860963934312081835272320238812022534477095634694802627860269361713438182846321229058529392716608829685708314508449574441166109812419649123445875905638934406872091742574829759871314621197235350998579563031139677192512639546904745848670104988385994626620908449612658040233325854445643585926360496269974991459750688880211123355953429519072414353674373705386071983844550354941821794692371907044593903275788892906274112049209437573188855729556317970379842595602177784867998565702046085858658609856373  public exponent: 65537  Validity: [From: Thu Jan 26 09:27:31 EET 2017,               To: Sun Jan 24 09:27:31 EET 2027]  Issuer: CN=mqServermqtap.uyg.uat11, OU=XXX BT, O=XXX TAS, L=XXX, C=XXX  SerialNumber: [    588996d3]Certificate Extensions: 2[1]: ObjectId: 2.5.29.35 Criticality=falseAuthorityKeyIdentifier [KeyIdentifier [0000: 04 62 9C B2 40 5E E0 C7                            .b..@^..
    ]][2]: ObjectId: 2.5.29.14 Criticality=falseSubjectKeyIdentifier [KeyIdentifier [0000: 04 62 9C B2 40 5E E0 C7                            .b..@^..
    ]]]  Algorithm: [SHA256withRSA]  Signature:0000: 27 23 9A F1 20 45 4E 98   2C A7 38 83 CE 99 7A 41  '#.. EN.,.8...zA
    0010: 0A 3A 57 02 E9 0F DE 73   73 01 07 B0 D8 19 C7 E2  .:W....ss.......
    0020: F2 2D 16 85 31 37 19 37   E4 2D B1 2C 4A F1 79 E4  .-..17.7.-.,J.y.
    0030: 09 99 E0 3A 47 B3 E2 4F   F4 EE 01 C3 D4 52 D4 94  ...:G..O.....R..
    0040: 38 49 09 59 3E 63 C1 44   48 B1 1F E3 B3 16 69 38  8I.Y>c.DH.....i8
    0050: E1 FA 5A 73 6F D1 F4 64   B3 0F 2E FD 49 72 87 F2  ..Zso..d....Ir..
    0060: 7E 59 76 87 C2 97 1C 8A   69 ED 92 52 D6 A4 3A 88  .Yv.....i..R..:.
    0070: 84 43 20 4B C7 4B C8 42   18 A0 E5 BF A6 C8 A7 32  .C K.K.B.......2
    0080: F2 E4 AA A3 F0 08 1F DF   F2 5E EE 1E 9F 84 4A CB  .........^....J.
    0090: 80 A8 9D 83 ED 6D 2A 5F   A2 C1 9E FC 89 D1 08 C0  .....m*_........
    00A0: 82 DA 4D D1 97 3B AB AB   1A 8B 35 D9 1C C0 DF B4  ..M..;....5.....
    00B0: 67 E3 39 A4 C8 73 2C F0   2A 70 2B 14 F7 F1 9C E8  g.9..s,.*p+.....
    00C0: 71 89 99 93 AB AE D6 4B   A0 46 1A 13 54 4E 6B 3B  q......K.F..TNk;
    00D0: E9 CE 97 92 4D 64 25 0C   D9 4F 3B A6 CC 78 36 C0  ....Md%..O;..x6.
    00E0: AE 75 0F A9 C1 3D D8 B2   AF 5F 68 9F FB EB 31 2F  .u...=..._h...1/
    00F0: 41 16 83 04 7B F2 0D 8E   07 47 47 8F 55 F7 33 29  A........GG.U.3)
    ]
    ***
    Found XXXusted certificate:
    [[  Version: V3  Subject: CN=mqServermqtap.uyg.uat11, OU=XXX BT, O=XXX TAS, L=XXX, C=XXX  Signature Algorithm: SHA256withRSA, OID = 1.2.840.113549.1.1.11  Key:  Sun RSA public key, 2048 bits  modulus: 16868959742511831543539228188322318728282173929458725924838613545208147879023122029920833782971719231363516671703224653599860963934312081835272320238812022534477095634694802627860269361713438182846321229058529392716608829685708314508449574441166109812419649123445875905638934406872091742574829759871314621197235350998579563031139677192512639546904745848670104988385994626620908449612658040233325854445643585926360496269974991459750688880211123355953429519072414353674373705386071983844550354941821794692371907044593903275788892906274112049209437573188855729556317970379842595602177784867998565702046085858658609856373  public exponent: 65537  Validity: [From: Thu Jan 26 09:27:31 EET 2017,               To: Sun Jan 24 09:27:31 EET 2027]  Issuer: CN=mqServermqtap.uyg.uat11, OU=XXX BT, O=XXX TAS, L=XXX, C=XXX  SerialNumber: [    588996d3]Certificate Extensions: 2[1]: ObjectId: 2.5.29.35 Criticality=falseAuthorityKeyIdentifier [KeyIdentifier [0000: 04 62 9C B2 40 5E E0 C7                            .b..@^..
    ]][2]: ObjectId: 2.5.29.14 Criticality=falseSubjectKeyIdentifier [KeyIdentifier [0000: 04 62 9C B2 40 5E E0 C7                            .b..@^..
    ]]]  Algorithm: [SHA256withRSA]  Signature:0000: 27 23 9A F1 20 45 4E 98   2C A7 38 83 CE 99 7A 41  '#.. EN.,.8...zA
    0010: 0A 3A 57 02 E9 0F DE 73   73 01 07 B0 D8 19 C7 E2  .:W....ss.......
    0020: F2 2D 16 85 31 37 19 37   E4 2D B1 2C 4A F1 79 E4  .-..17.7.-.,J.y.
    0030: 09 99 E0 3A 47 B3 E2 4F   F4 EE 01 C3 D4 52 D4 94  ...:G..O.....R..
    0040: 38 49 09 59 3E 63 C1 44   48 B1 1F E3 B3 16 69 38  8I.Y>c.DH.....i8
    0050: E1 FA 5A 73 6F D1 F4 64   B3 0F 2E FD 49 72 87 F2  ..Zso..d....Ir..
    0060: 7E 59 76 87 C2 97 1C 8A   69 ED 92 52 D6 A4 3A 88  .Yv.....i..R..:.
    0070: 84 43 20 4B C7 4B C8 42   18 A0 E5 BF A6 C8 A7 32  .C K.K.B.......2
    0080: F2 E4 AA A3 F0 08 1F DF   F2 5E EE 1E 9F 84 4A CB  .........^....J.
    0090: 80 A8 9D 83 ED 6D 2A 5F   A2 C1 9E FC 89 D1 08 C0  .....m*_........
    00A0: 82 DA 4D D1 97 3B AB AB   1A 8B 35 D9 1C C0 DF B4  ..M..;....5.....
    00B0: 67 E3 39 A4 C8 73 2C F0   2A 70 2B 14 F7 F1 9C E8  g.9..s,.*p+.....
    00C0: 71 89 99 93 AB AE D6 4B   A0 46 1A 13 54 4E 6B 3B  q......K.F..TNk;
    00D0: E9 CE 97 92 4D 64 25 0C   D9 4F 3B A6 CC 78 36 C0  ....Md%..O;..x6.
    00E0: AE 75 0F A9 C1 3D D8 B2   AF 5F 68 9F FB EB 31 2F  .u...=..._h...1/
    00F0: 41 16 83 04 7B F2 0D 8E   07 47 47 8F 55 F7 33 29  A........GG.U.3)
    ]
    *** CertificateRequest
    Cert Types: RSA, DSS, ECDSA
    Supported Signature Algorithms: SHA512withRSA, SHA384withRSA, SHA256withRSA, Unknown (hash:0x3, signature:0x1), SHA1withRSA, SHA512withECDSA, SHA384withECDSA, SHA256withECDSA, Unknown (hash:0x3, signature:0x3), SHA1withECDSA, SHA1withDSA
    Cert Authorities:
    <CN=mqClientmqtap.uyg.uat, OU=XXX BT, O=XXX TAS, L=XXX, C=XXX>
    <CN=mqServermqtap.uyg.uat11, OU=XXX BT, O=XXX TAS, L=XXX, C=XXX>
    *** ServerHelloDone
    Warning: no suitable certificate found - continuing without client authentication
    *** Certificate chain
    <Empty>
    ***
    *** ClientKeyExchange, RSA PreMasterSecret, TLSv1.2
    jmsContainerBean_DEVOPS_DEVOPS_CONSUME_MESSAGE-1, WRITE: TLSv1.2 Handshake, length = 269
    SESSION KEYGEN:
    PreMaster Secret:
    0000: 03 03 B7 63 CA 3F 6F F4   A3 C8 68 5F 4E D4 84 9A  ...c.?o...h_N...
    0010: 17 03 40 12 66 C2 C3 D0   67 EE 64 54 50 5D AF ED  ..@.f...g.dTP]..
    0020: CD 8E 45 A9 6F CF 91 E1   60 6A 63 0D 9B CB AF D7  ..E.o...`jc.....
    CONNECTION KEYGEN:
    Client Nonce:
    0000: 5E D1 8F 80 F8 04 83 12   B3 4D 3A A3 D5 56 A2 27  ^........M:..V.'
    0010: 99 E9 42 52 44 8C A2 90   F5 DF 94 83 29 11 B6 0D  ..BRD.......)...
    Server Nonce:
    0000: 2A 55 EB 8E 98 28 77 FD   97 2F CE F3 51 6C 19 E3  *U...(w../..Ql..
    0010: C4 B4 EB E7 B4 D5 88 F5   44 4F 57 4E 47 52 44 01  ........DOWNGRD.
    Master Secret:
    0000: D9 0B 10 DB B5 9A 64 0C   56 2E 70 89 93 E4 52 6A  ......d.V.p...Rj
    0010: F7 C2 A9 9F 0D 6E 47 82   84 A0 6F D9 58 C0 E8 FF  .....nG...o.X...
    0020: E1 BB 6D 74 76 B0 D6 E5   83 FA 6F 89 D2 C1 BC 06  ..mtv.....o.....
    Client MAC write Secret:
    0000: 2E C0 A1 1A 6B 63 40 13   C9 2F 96 29 29 6B 46 3C  ....kc@../.))kF<
    0010: 61 48 69 06 66 9A 20 45   3C F4 63 BB 80 AE 95 84  aHi.f. E<.c.....
    Server MAC write Secret:
    0000: 64 5D 2F F0 C3 76 E7 53   61 0A D6 9A 23 80 7E 29  d]/..v.Sa...#..)
    0010: C9 15 CC 4A 1A 6A 0C F8   5D A6 2F C3 CE F8 04 88  ...J.j..]./.....
    Client write key:
    0000: A1 3C 3A F9 81 3E 4A F4   D5 30 EB 7C FB 10 AF 1B  .<:..>J..0......
    Server write key:
    0000: 0F 0C 65 F8 C5 6B C1 8B   C4 51 36 35 2E 9F ED D6  ..e..k...Q65....
    ... no IV derived for this protocol
    jmsContainerBean_DEVOPS_DEVOPS_CONSUME_MESSAGE-1, WRITE: TLSv1.2 Change Cipher Spec, length = 1
    *** Finished
    verify_data:  { 101, 32, 15, 187, 98, 153, 21, 159, 88, 122, 119, 59 }
    ***
    jmsContainerBean_DEVOPS_DEVOPS_CONSUME_MESSAGE-1, WRITE: TLSv1.2 Handshake, length = 80
    jmsContainerBean_DEVOPS_DEVOPS_CONSUME_MESSAGE-1, READ: TLSv1.2 Change Cipher Spec, length = 1
    jmsContainerBean_DEVOPS_DEVOPS_CONSUME_MESSAGE-1, READ: TLSv1.2 Handshake, length = 80
    *** Finished
    verify_data:  { 80, 170, 1, 54, 80, 55, 237, 31, 125, 189, 221, 180 }
    ***
    %% Cached client session: [Session-2, TLS_RSA_WITH_AES_128_CBC_SHA256]
    jmsContainerBean_DEVOPS_DEVOPS_CONSUME_MESSAGE-1, WRITE: TLSv1.2 Application Data, length = 288
    jmsContainerBean_DEVOPS_DEVOPS_CONSUME_MESSAGE-1, setSoTimeout(5000) called
    jmsContainerBean_DEVOPS_DEVOPS_CONSUME_MESSAGE-1, READ: TLSv1.2 Application Data, length = 96
    jmsContainerBean_DEVOPS_DEVOPS_CONSUME_MESSAGE-1, setSoTimeout(0) called
    jmsContainerBean_DEVOPS_DEVOPS_CONSUME_MESSAGE-1, called close()
    jmsContainerBean_DEVOPS_DEVOPS_CONSUME_MESSAGE-1, called closeInternal(XXXue)
    jmsContainerBean_DEVOPS_DEVOPS_CONSUME_MESSAGE-1, SEND TLSv1.2 ALERT:  warning, description = close_notify
    jmsContainerBean_DEVOPS_DEVOPS_CONSUME_MESSAGE-1, WRITE: TLSv1.2 Alert, length = 64
    jmsContainerBean_DEVOPS_DEVOPS_CONSUME_MESSAGE-1, called closeSocket(XXXue)
    01:41:04,148 WARN  [org.jboss.jca.core.connectionmanager.pool.sXXXategy.OnePool
</code>```

答:
After getting IBM MQ Client jar, I connect to IBM MQ from Oracle JRE succeffully
https://mvnrepository.com/artifact/com.ibm.mq/wmq.jmsra/9.1.5.0</p>

ContentLicense: CC BY-SA 4.0

Body:
I have problems while connecting IBM MQ from JBoss with SSL on JRE 1.8 (jdk1.8.0_101)

I comment below line on java.security but nothing changes:

jdk.certpath.disabledAlgorithms=MD2, MD5, RSA keySize < 1024

Caused by: com.ibm.msg.client.jms.DetailedJMSException: JMSWMQ0018: Failed to connect to queue manager 'xxxxx' with connection mode 'Client' and host name 'xxxx'.Check the queue manager is started and if running in client mode, check there is a listener running. Please see the linked exception for more information.
at com.ibm.msg.client.wmq.common.internal.Reason.reasonToException(Reason.java:580)
at com.ibm.msg.client.wmq.common.internal.Reason.createException(Reason.java:216)
at com.ibm.msg.client.wmq.internal.WMQConnection.<init>(WMQConnection.java:431)
at com.ibm.msg.client.wmq.internal.WMQXAConnection.<init>(WMQXAConnection.java:70)
at com.ibm.msg.client.wmq.factories.WMQXAConnectionFactory.createV7ProviderConnection(WMQXAConnectionFactory.java:190)
at com.ibm.msg.client.wmq.factories.WMQConnectionFactory.createProviderConnection(WMQConnectionFactory.java:6157)
at com.ibm.msg.client.wmq.factories.WMQXAConnectionFactory.createProviderXAConnection(WMQXAConnectionFactory.java:102)
at com.ibm.msg.client.jms.admin.JmsConnectionFactoryImpl.createXAConnectionInternal(JmsConnectionFactoryImpl.java:364)
at com.ibm.mq.jms.MQXAConnectionFactory.createXAConnection(MQXAConnectionFactory.java:124)
at com.ibm.mq.connector.ConnectionBuilder.createConnection(ConnectionBuilder.java:167)
... 22 more **Caused by: com.ibm.mq.MQException: JMSCMQ0001: WebSphere MQ call failed with compcode '2' ('MQCC_FAILED') reason '2393' ('MQRC_SSL_INITIALIZATION_ERROR')**.
at com.ibm.msg.client.wmq.common.internal.Reason.createException(Reason.java:204)
... 30 more Caused by: com.ibm.mq.jmqi.JmqiException: CC=2;RC=2393;AMQ9204: Connection to host 'xxxxx' rejected. [1=com.ibm.mq.jmqi.JmqiException[CC=2;RC=2393],3=xxxxx(1428),5=RemoteTCPConnection.buildTLSV1_2SocketFactory]
at com.ibm.mq.jmqi.remote.api.RemoteFAP.jmqiConnect(RemoteFAP.java:2098)
at com.ibm.mq.jmqi.remote.api.RemoteFAP.jmqiConnect(RemoteFAP.java:1347)
at com.ibm.msg.client.wmq.internal.WMQConnection.<init>(WMQConnection.java:350)
... 29 more  Caused by: com.ibm.mq.jmqi.JmqiException: CC=2;RC=2393
at com.ibm.mq.jmqi.remote.impl.RemoteTCPConnection.buildTLSV1_2SocketFactory(RemoteTCPConnection.java:2480)
at com.ibm.mq.jmqi.remote.impl.RemoteTCPConnection.chooseSocketFactory(RemoteTCPConnection.java:2130)
at com.ibm.mq.jmqi.remote.impl.RemoteTCPConnection.makeSocketSecure(RemoteTCPConnection.java:1945)
at com.ibm.mq.jmqi.remote.impl.RemoteTCPConnection.connnectUsingLocalAddress(RemoteTCPConnection.java:855)
at com.ibm.mq.jmqi.remote.impl.RemoteTCPConnection.protocolConnect(RemoteTCPConnection.java:1262)
at com.ibm.mq.jmqi.remote.impl.RemoteConnection.connect(RemoteConnection.java:714)
at com.ibm.mq.jmqi.remote.impl.RemoteConnectionSpecification.getSessionFromNewConnection(RemoteConnectionSpecification.java:356)
at com.ibm.mq.jmqi.remote.impl.RemoteConnectionSpecification.getSession(RemoteConnectionSpecification.java:265)
at com.ibm.mq.jmqi.remote.impl.RemoteConnectionPool.getSession(RemoteConnectionPool.java:144)
at com.ibm.mq.jmqi.remote.api.RemoteFAP.jmqiConnect(RemoteFAP.java:1709)
... 31 more **Caused by: java.security.NoSuchAlgorithmException: SSL_TLSv2 SSLContext not available**
at sun.security.jca.GetInstance.getInstance(GetInstance.java:159) [rt.jar:1.8.0_101]
at javax.net.ssl.SSLContext.getInstance(SSLContext.java:156) [rt.jar:1.8.0_101]
at com.ibm.mq.jmqi.remote.impl.RemoteTCPConnection.buildTLSV1_2SocketFactory(RemoteTCPConnection.java:2461)
... 40 more

UPDATED: After below changes, new error like this:
TLS_RSA_WITH_AES_128_CBC_SHA256
JVM Arguments added: -Dcom.ibm.mq.cfg.useIBMCipherMappings=false

Caused by: com.ibm.msg.client.jms.DetailedIllegalStateException: JMSWMQ0018: Failed to connect to queue manager 'mqtap.uyg.uat11' with connection mode 'Client' and host name 'xxx'. Check the queue manager is started and if running in client mode, check there is a listener running. Please see the linked exception for more information.
at com.ibm.msg.client.wmq.common.internal.Reason.reasonToException(Reason.java:474)
at com.ibm.msg.client.wmq.common.internal.Reason.createException(Reason.java:216)
at com.ibm.msg.client.wmq.internal.WMQConnection.<init>(WMQConnection.java:431)
at com.ibm.msg.client.wmq.internal.WMQXAConnection.<init>(WMQXAConnection.java:70)
at com.ibm.msg.client.wmq.factories.WMQXAConnectionFactory.createV7ProviderConnection(WMQXAConnectionFactory.java:190)
at com.ibm.msg.client.wmq.factories.WMQConnectionFactory.createProviderConnection(WMQConnectionFactory.java:6157)
at com.ibm.msg.client.wmq.factories.WMQXAConnectionFactory.createProviderXAConnection(WMQXAConnectionFactory.java:102)
at com.ibm.msg.client.jms.admin.JmsConnectionFactoryImpl.createXAConnectionInternal(JmsConnectionFactoryImpl.java:364)
at com.ibm.mq.jms.MQXAConnectionFactory.createXAConnection(MQXAConnectionFactory.java:124)
at com.ibm.mq.connector.ConnectionBuilder.createConnection(ConnectionBuilder.java:167)
... 22 more Caused by: com.ibm.mq.MQException: JMSCMQ0001: WebSphere MQ call failed with compcode '2' ('MQCC_FAILED') reason '2059' ('MQRC_Q_MGR_NOT_AVAILABLE').
at com.ibm.msg.client.wmq.common.internal.Reason.createException(Reason.java:204)
... 30 more Caused by: com.ibm.mq.jmqi.JmqiException: CC=2;RC=2059;AMQ9204: Connection to host 'xxx' rejected. [1=com.ibm.mq.jmqi.JmqiException[CC=2;RC=2059;AMQ9503: Channel negotiation failed. [3=xxx]],3=xxx,5=RemoteConnection.analyseErrorSegment]
at com.ibm.mq.jmqi.remote.api.RemoteFAP.jmqiConnect(RemoteFAP.java:2098)
at com.ibm.mq.jmqi.remote.api.RemoteFAP.jmqiConnect(RemoteFAP.java:1347)
at com.ibm.msg.client.wmq.internal.WMQConnection.<init>(WMQConnection.java:350)
... 29 more Caused by: com.ibm.mq.jmqi.JmqiException: CC=2;RC=2059;AMQ9503: Channel negotiation failed. [3=xxx]
at com.ibm.mq.jmqi.remote.impl.RemoteConnection.analyseErrorSegment(RemoteConnection.java:3850)
at com.ibm.mq.jmqi.remote.impl.RemoteConnection.receiveTSH(RemoteConnection.java:2749)
at com.ibm.mq.jmqi.remote.impl.RemoteConnection.initSess(RemoteConnection.java:1024)
at com.ibm.mq.jmqi.remote.impl.RemoteConnection.connect(RemoteConnection.java:717)
at com.ibm.mq.jmqi.remote.impl.RemoteConnectionSpecification.getSessionFromNewConnection(RemoteConnectionSpecification.java:356)
at com.ibm.mq.jmqi.remote.impl.RemoteConnectionSpecification.getSession(RemoteConnectionSpecification.java:265)
at com.ibm.mq.jmqi.remote.impl.RemoteConnectionPool.getSession(RemoteConnectionPool.java:144)
at com.ibm.mq.jmqi.remote.api.RemoteFAP.jmqiConnect(RemoteFAP.java:1709)
... 31 more

UPDATED output of javax.net.debug=ssl:

trustStore is: C:\dev\eclipse\workspace\XXX\src\main\application\config\XXX\keystore.jks
trustStore type is : jks
trustStore provider is :
init truststore

adding as trusted cert:
  Subject: CN=mqClientmqtap.uyg.uat, OU=XXX BT, O=XXX TAS, L=XXX, C=TR
  Issuer:  CN=mqClientmqtap.uyg.uat, OU=XXX BT, O=XXX TAS, L=XXX, C=TR
  Algorithm: RSA; Serial number: 0x5889a408
  Valid from Thu Jan 26 10:23:52 EET 2017 until Sun Jan 24 10:23:52 EET 2027

adding as trusted cert:
  Subject: CN=mqServermqtap.uyg.uat11, OU=XXX BT, O=XXX TAS, L=XXX, C=TR
  Issuer:  CN=mqServermqtap.uyg.uat11, OU=XXX BT, O=XXX TAS, L=XXX, C=TR
  Algorithm: RSA; Serial number: 0x588996d3
  Valid from Thu Jan 26 09:27:31 EET 2017 until Sun Jan 24 09:27:31 EET 2027

adding as trusted cert:
  Subject: CN=mqServermqtap.uyg.uat12, OU=XXX BT, O=XXX TAS, L=XXX, C=TR
  Issuer:  CN=mqServermqtap.uyg.uat12, OU=XXX BT, O=XXX TAS, L=XXX, C=TR
  Algorithm: RSA; Serial number: 0x5889994c
  Valid from Thu Jan 26 09:38:04 EET 2017 until Sun Jan 24 09:38:04 EET 2027

trigger seeding of SecureRandom
done seeding SecureRandom

Allow unsafe renegotiation: falseAllow legacy hello messages: XXXueIs initial handshake: XXXueIs secure renegotiation: false
    %% No cached client session
    *** ClientHello, TLSv1.2
    RandomCookie:  GMT: 1573949056 bytes = { 248, 4, 131, 18, 179, 77, 58, 163, 213, 86, 162, 39, 153, 233, 66, 82, 68, 140, 162, 144, 245, 223, 148, 131, 41, 17, 182, 13 }
    Session ID:  {}
    Cipher Suites: [TLS_RSA_WITH_AES_128_CBC_SHA256]
    Compression Methods:  { 0 }
    Extension signature_algorithms, signature_algorithms: SHA512withECDSA, SHA512withRSA, SHA384withECDSA, SHA384withRSA, SHA256withECDSA, SHA256withRSA, SHA1withECDSA, SHA1withRSA, SHA1withDSA
    Extension server_name, server_name: [type=host_name (0), value=mqkont1.XXX.com.XXX]
    Extension renegotiation_info, renegotiated_connection: <empty>
    ***
    jmsContainerBean_DEVOPS_DEVOPS_CONSUME_MESSAGE-1, WRITE: TLSv1.2 Handshake, length = 106
    jmsContainerBean_DEVOPS_DEVOPS_CONSUME_MESSAGE-1, READ: TLSv1.2 Handshake, length = 1247
    *** ServerHello, TLSv1.2
    RandomCookie:  GMT: 710208142 bytes = { 152, 40, 119, 253, 151, 47, 206, 243, 81, 108, 25, 227, 196, 180, 235, 231, 180, 213, 136, 245, 68, 79, 87, 78, 71, 82, 68, 1 }
    Session ID:  {233, 220, 107, 227, 28, 86, 6, 240, 170, 113, 171, 164, 93, 132, 7, 120, 51, 79, 103, 215, 78, 157, 179, 176, 103, 14, 128, 68, 104, 28, 158, 75}
    Cipher Suite: TLS_RSA_WITH_AES_128_CBC_SHA256
    Compression Method: 0
    Extension renegotiation_info, renegotiated_connection: <empty>
    ***
    %% Initialized:  [Session-2, TLS_RSA_WITH_AES_128_CBC_SHA256]
    ** TLS_RSA_WITH_AES_128_CBC_SHA256
    *** Certificate chain
    chain [0] = [[  Version: V3  Subject: CN=mqServermqtap.uyg.uat11, OU=XXX BT, O=XXX TAS, L=XXX, C=XXX  Signature Algorithm: SHA256withRSA, OID = 1.2.840.113549.1.1.11  Key:  Sun RSA public key, 2048 bits  modulus: 16868959742511831543539228188322318728282173929458725924838613545208147879023122029920833782971719231363516671703224653599860963934312081835272320238812022534477095634694802627860269361713438182846321229058529392716608829685708314508449574441166109812419649123445875905638934406872091742574829759871314621197235350998579563031139677192512639546904745848670104988385994626620908449612658040233325854445643585926360496269974991459750688880211123355953429519072414353674373705386071983844550354941821794692371907044593903275788892906274112049209437573188855729556317970379842595602177784867998565702046085858658609856373  public exponent: 65537  Validity: [From: Thu Jan 26 09:27:31 EET 2017,               To: Sun Jan 24 09:27:31 EET 2027]  Issuer: CN=mqServermqtap.uyg.uat11, OU=XXX BT, O=XXX TAS, L=XXX, C=XXX  SerialNumber: [    588996d3]Certificate Extensions: 2[1]: ObjectId: 2.5.29.35 Criticality=falseAuthorityKeyIdentifier [KeyIdentifier [0000: 04 62 9C B2 40 5E E0 C7                            .b..@^..
    ]][2]: ObjectId: 2.5.29.14 Criticality=falseSubjectKeyIdentifier [KeyIdentifier [0000: 04 62 9C B2 40 5E E0 C7                            .b..@^..
    ]]]  Algorithm: [SHA256withRSA]  Signature:0000: 27 23 9A F1 20 45 4E 98   2C A7 38 83 CE 99 7A 41  '#.. EN.,.8...zA
    0010: 0A 3A 57 02 E9 0F DE 73   73 01 07 B0 D8 19 C7 E2  .:W....ss.......
    0020: F2 2D 16 85 31 37 19 37   E4 2D B1 2C 4A F1 79 E4  .-..17.7.-.,J.y.
    0030: 09 99 E0 3A 47 B3 E2 4F   F4 EE 01 C3 D4 52 D4 94  ...:G..O.....R..
    0040: 38 49 09 59 3E 63 C1 44   48 B1 1F E3 B3 16 69 38  8I.Y>c.DH.....i8
    0050: E1 FA 5A 73 6F D1 F4 64   B3 0F 2E FD 49 72 87 F2  ..Zso..d....Ir..
    0060: 7E 59 76 87 C2 97 1C 8A   69 ED 92 52 D6 A4 3A 88  .Yv.....i..R..:.
    0070: 84 43 20 4B C7 4B C8 42   18 A0 E5 BF A6 C8 A7 32  .C K.K.B.......2
    0080: F2 E4 AA A3 F0 08 1F DF   F2 5E EE 1E 9F 84 4A CB  .........^....J.
    0090: 80 A8 9D 83 ED 6D 2A 5F   A2 C1 9E FC 89 D1 08 C0  .....m*_........
    00A0: 82 DA 4D D1 97 3B AB AB   1A 8B 35 D9 1C C0 DF B4  ..M..;....5.....
    00B0: 67 E3 39 A4 C8 73 2C F0   2A 70 2B 14 F7 F1 9C E8  g.9..s,.*p+.....
    00C0: 71 89 99 93 AB AE D6 4B   A0 46 1A 13 54 4E 6B 3B  q......K.F..TNk;
    00D0: E9 CE 97 92 4D 64 25 0C   D9 4F 3B A6 CC 78 36 C0  ....Md%..O;..x6.
    00E0: AE 75 0F A9 C1 3D D8 B2   AF 5F 68 9F FB EB 31 2F  .u...=..._h...1/
    00F0: 41 16 83 04 7B F2 0D 8E   07 47 47 8F 55 F7 33 29  A........GG.U.3)
    ]
    ***
    Found XXXusted certificate:
    [[  Version: V3  Subject: CN=mqServermqtap.uyg.uat11, OU=XXX BT, O=XXX TAS, L=XXX, C=XXX  Signature Algorithm: SHA256withRSA, OID = 1.2.840.113549.1.1.11  Key:  Sun RSA public key, 2048 bits  modulus: 16868959742511831543539228188322318728282173929458725924838613545208147879023122029920833782971719231363516671703224653599860963934312081835272320238812022534477095634694802627860269361713438182846321229058529392716608829685708314508449574441166109812419649123445875905638934406872091742574829759871314621197235350998579563031139677192512639546904745848670104988385994626620908449612658040233325854445643585926360496269974991459750688880211123355953429519072414353674373705386071983844550354941821794692371907044593903275788892906274112049209437573188855729556317970379842595602177784867998565702046085858658609856373  public exponent: 65537  Validity: [From: Thu Jan 26 09:27:31 EET 2017,               To: Sun Jan 24 09:27:31 EET 2027]  Issuer: CN=mqServermqtap.uyg.uat11, OU=XXX BT, O=XXX TAS, L=XXX, C=XXX  SerialNumber: [    588996d3]Certificate Extensions: 2[1]: ObjectId: 2.5.29.35 Criticality=falseAuthorityKeyIdentifier [KeyIdentifier [0000: 04 62 9C B2 40 5E E0 C7                            .b..@^..
    ]][2]: ObjectId: 2.5.29.14 Criticality=falseSubjectKeyIdentifier [KeyIdentifier [0000: 04 62 9C B2 40 5E E0 C7                            .b..@^..
    ]]]  Algorithm: [SHA256withRSA]  Signature:0000: 27 23 9A F1 20 45 4E 98   2C A7 38 83 CE 99 7A 41  '#.. EN.,.8...zA
    0010: 0A 3A 57 02 E9 0F DE 73   73 01 07 B0 D8 19 C7 E2  .:W....ss.......
    0020: F2 2D 16 85 31 37 19 37   E4 2D B1 2C 4A F1 79 E4  .-..17.7.-.,J.y.
    0030: 09 99 E0 3A 47 B3 E2 4F   F4 EE 01 C3 D4 52 D4 94  ...:G..O.....R..
    0040: 38 49 09 59 3E 63 C1 44   48 B1 1F E3 B3 16 69 38  8I.Y>c.DH.....i8
    0050: E1 FA 5A 73 6F D1 F4 64   B3 0F 2E FD 49 72 87 F2  ..Zso..d....Ir..
    0060: 7E 59 76 87 C2 97 1C 8A   69 ED 92 52 D6 A4 3A 88  .Yv.....i..R..:.
    0070: 84 43 20 4B C7 4B C8 42   18 A0 E5 BF A6 C8 A7 32  .C K.K.B.......2
    0080: F2 E4 AA A3 F0 08 1F DF   F2 5E EE 1E 9F 84 4A CB  .........^....J.
    0090: 80 A8 9D 83 ED 6D 2A 5F   A2 C1 9E FC 89 D1 08 C0  .....m*_........
    00A0: 82 DA 4D D1 97 3B AB AB   1A 8B 35 D9 1C C0 DF B4  ..M..;....5.....
    00B0: 67 E3 39 A4 C8 73 2C F0   2A 70 2B 14 F7 F1 9C E8  g.9..s,.*p+.....
    00C0: 71 89 99 93 AB AE D6 4B   A0 46 1A 13 54 4E 6B 3B  q......K.F..TNk;
    00D0: E9 CE 97 92 4D 64 25 0C   D9 4F 3B A6 CC 78 36 C0  ....Md%..O;..x6.
    00E0: AE 75 0F A9 C1 3D D8 B2   AF 5F 68 9F FB EB 31 2F  .u...=..._h...1/
    00F0: 41 16 83 04 7B F2 0D 8E   07 47 47 8F 55 F7 33 29  A........GG.U.3)
    ]
    *** CertificateRequest
    Cert Types: RSA, DSS, ECDSA
    Supported Signature Algorithms: SHA512withRSA, SHA384withRSA, SHA256withRSA, Unknown (hash:0x3, signature:0x1), SHA1withRSA, SHA512withECDSA, SHA384withECDSA, SHA256withECDSA, Unknown (hash:0x3, signature:0x3), SHA1withECDSA, SHA1withDSA
    Cert Authorities:
    <CN=mqClientmqtap.uyg.uat, OU=XXX BT, O=XXX TAS, L=XXX, C=XXX>
    <CN=mqServermqtap.uyg.uat11, OU=XXX BT, O=XXX TAS, L=XXX, C=XXX>
    *** ServerHelloDone
    Warning: no suitable certificate found - continuing without client authentication
    *** Certificate chain
    <Empty>
    ***
    *** ClientKeyExchange, RSA PreMasterSecret, TLSv1.2
    jmsContainerBean_DEVOPS_DEVOPS_CONSUME_MESSAGE-1, WRITE: TLSv1.2 Handshake, length = 269
    SESSION KEYGEN:
    PreMaster Secret:
    0000: 03 03 B7 63 CA 3F 6F F4   A3 C8 68 5F 4E D4 84 9A  ...c.?o...h_N...
    0010: 17 03 40 12 66 C2 C3 D0   67 EE 64 54 50 5D AF ED  ..@.f...g.dTP]..
    0020: CD 8E 45 A9 6F CF 91 E1   60 6A 63 0D 9B CB AF D7  ..E.o...`jc.....
    CONNECTION KEYGEN:
    Client Nonce:
    0000: 5E D1 8F 80 F8 04 83 12   B3 4D 3A A3 D5 56 A2 27  ^........M:..V.'
    0010: 99 E9 42 52 44 8C A2 90   F5 DF 94 83 29 11 B6 0D  ..BRD.......)...
    Server Nonce:
    0000: 2A 55 EB 8E 98 28 77 FD   97 2F CE F3 51 6C 19 E3  *U...(w../..Ql..
    0010: C4 B4 EB E7 B4 D5 88 F5   44 4F 57 4E 47 52 44 01  ........DOWNGRD.
    Master Secret:
    0000: D9 0B 10 DB B5 9A 64 0C   56 2E 70 89 93 E4 52 6A  ......d.V.p...Rj
    0010: F7 C2 A9 9F 0D 6E 47 82   84 A0 6F D9 58 C0 E8 FF  .....nG...o.X...
    0020: E1 BB 6D 74 76 B0 D6 E5   83 FA 6F 89 D2 C1 BC 06  ..mtv.....o.....
    Client MAC write Secret:
    0000: 2E C0 A1 1A 6B 63 40 13   C9 2F 96 29 29 6B 46 3C  ....kc@../.))kF<
    0010: 61 48 69 06 66 9A 20 45   3C F4 63 BB 80 AE 95 84  aHi.f. E<.c.....
    Server MAC write Secret:
    0000: 64 5D 2F F0 C3 76 E7 53   61 0A D6 9A 23 80 7E 29  d]/..v.Sa...#..)
    0010: C9 15 CC 4A 1A 6A 0C F8   5D A6 2F C3 CE F8 04 88  ...J.j..]./.....
    Client write key:
    0000: A1 3C 3A F9 81 3E 4A F4   D5 30 EB 7C FB 10 AF 1B  .<:..>J..0......
    Server write key:
    0000: 0F 0C 65 F8 C5 6B C1 8B   C4 51 36 35 2E 9F ED D6  ..e..k...Q65....
    ... no IV derived for this protocol
    jmsContainerBean_DEVOPS_DEVOPS_CONSUME_MESSAGE-1, WRITE: TLSv1.2 Change Cipher Spec, length = 1
    *** Finished
    verify_data:  { 101, 32, 15, 187, 98, 153, 21, 159, 88, 122, 119, 59 }
    ***
    jmsContainerBean_DEVOPS_DEVOPS_CONSUME_MESSAGE-1, WRITE: TLSv1.2 Handshake, length = 80
    jmsContainerBean_DEVOPS_DEVOPS_CONSUME_MESSAGE-1, READ: TLSv1.2 Change Cipher Spec, length = 1
    jmsContainerBean_DEVOPS_DEVOPS_CONSUME_MESSAGE-1, READ: TLSv1.2 Handshake, length = 80
    *** Finished
    verify_data:  { 80, 170, 1, 54, 80, 55, 237, 31, 125, 189, 221, 180 }
    ***
    %% Cached client session: [Session-2, TLS_RSA_WITH_AES_128_CBC_SHA256]
    jmsContainerBean_DEVOPS_DEVOPS_CONSUME_MESSAGE-1, WRITE: TLSv1.2 Application Data, length = 288
    jmsContainerBean_DEVOPS_DEVOPS_CONSUME_MESSAGE-1, setSoTimeout(5000) called
    jmsContainerBean_DEVOPS_DEVOPS_CONSUME_MESSAGE-1, READ: TLSv1.2 Application Data, length = 96
    jmsContainerBean_DEVOPS_DEVOPS_CONSUME_MESSAGE-1, setSoTimeout(0) called
    jmsContainerBean_DEVOPS_DEVOPS_CONSUME_MESSAGE-1, called close()
    jmsContainerBean_DEVOPS_DEVOPS_CONSUME_MESSAGE-1, called closeInternal(XXXue)
    jmsContainerBean_DEVOPS_DEVOPS_CONSUME_MESSAGE-1, SEND TLSv1.2 ALERT:  warning, description = close_notify
    jmsContainerBean_DEVOPS_DEVOPS_CONSUME_MESSAGE-1, WRITE: TLSv1.2 Alert, length = 64
    jmsContainerBean_DEVOPS_DEVOPS_CONSUME_MESSAGE-1, called closeSocket(XXXue)
    01:41:04,148 WARN  [org.jboss.jca.core.connectionmanager.pool.sXXXategy.OnePool


问:
How many connections/subscriptions can handle Kafka KSQL?
We are trying to migrate Kafka KSQL to our system and would like to share some problems that we could not solve during the process.
We have 3 Kafka nodes in our cluster, each of the servers has:

```<code>8 CORE
50G+ RAM
100G ssd
</code>```

On each server we have zookeeper to manage the cluster.
All the OS limits are increased so the nodes could use more resources than it needs:

```<code>Xmx: 10G
Xms: 10G
nofiles: 500000
</code>```

For now, the traffic to the cluster from producer is minor (~ 10 messages per second). Right now we have only one producer and the message format is:

```<code>{"user_id": <id|INT>, "action_id": <id|INT>, "amount": <amount|FLOAT>}
</code>```

Topic in Kafka is divided onto 6 partitions with 1 replication:

```<code>Topic:<some_topic>   PartitionCount:6        ReplicationFactor:1     Configs:
        Topic: <some_topic>  Partition: 0    Leader: 0       Replicas: 0     Isr: 0
        Topic: <some_topic>  Partition: 1    Leader: 1       Replicas: 1     Isr: 1
        Topic: <some_topic>  Partition: 2    Leader: 2       Replicas: 2     Isr: 2
        Topic: <some_topic>  Partition: 3    Leader: 0       Replicas: 0     Isr: 0
        Topic: <some_topic>  Partition: 4    Leader: 1       Replicas: 1     Isr: 1
        Topic: <some_topic>  Partition: 5    Leader: 2       Replicas: 2     Isr: 2
</code>```

Now, of course, the nodes are underutilized and in kafka side everything is more than ok )

We would like to use KSQL on top of Kafka to be able to filter data coming to our system with SQL.
Here are KSQL server resources:

```<code>32 CORE
100G+ RAM
50G+ ssd
</code>```

We have only one table:

```<code> Field   | Type
-------------------------------------
 ROWTIME   | BIGINT           (system)
 ROWKEY    | VARCHAR(STRING)  (system)
 ACTION_ID | INTEGER
 USER_ID   | INTEGER
 AMOUNT    | DOUBLE
</code>```

Here is the command the table was created with:

```<code>create table <some_table> (action_id INT, user_Id INT, amount DOUBLE) with (KAFKA_TOPIC='<some_topic>', VALUE_FORMAT='JSON', KEY = 'user_id');
</code>```

In our application, we need to subscribe to the table by user_id, like this:

```<code>SELECT * FROM <some_table> WHERE USER_ID=<some_user_id>;
</code>```

For the production KSQL server configuration, we use the official recommendation from confluent:
https://docs.confluent.io/current/ksql/docs/installation/server-config/config-reference.html#recommended-ksql-production-settings

The OS and software limits are also increased for the KSQL server:

```<code>Xmx: 10G  (we have tried till 50G)
Xms: 10G  (we have tried till 50G)
nofiles: 500000
</code>```

In case we use only one subscription, we don't get any issues (everything is fine in this case).

But we need more than 200000+ subscriptions overall. So when we try to get 100-200 parallel subscriptions, we are getting "read timeouts" in our client. In the server, we do not see any abnormal load that could affect KSQL.

We suppose that the issue is related only with KSQL because when we try to use another KSQL server(in a different machine), at the same time we can see that the second server is working fine and can handle some 1-20 subscriptions.

I could not find any benchmark on internet connected with KSQL server, and in the documentation, as well I could not find any mention of the use cases of the KSQL, maybe it's designed only to serve few connections with huge data, or maybe our system is misconfigured so we should fixed it to use the software for our goals.

Any suggestion would be helpful.

Thanks in advance )

答:
The reason you're running into scalability issues with ksqlDB is that you're using push queries in a way they were not designed to be used.... yet!

The push query:

```<code>SELECT * FROM <some_table> WHERE USER_ID=<some_user_id>;
</code>```

Which you're using to subscribe to updates for a specific user seems a totally sensible thing to do.

However, in the version of ksql you're using such push queries we only intended for use by humans executing commands at the CLI.  Each such query will, internally, consume a chunk of server resources and consume ALL rows from the source topic.

Basically, push queries do not scale.

The ksqlDB team are actively working on enhancing ksql to support this exact style of use case as we recognise this is a common thing to want to do.  (See https://github.com/confluentinc/ksql/issues/5517).

In the meantime, the way to achieve this would be to consume the data directly from Kafka using your own consumers and do the filtering locally.

Body:
We are trying to migrate Kafka KSQL to our system and would like to share some problems that we could not solve during the process.
We have 3 Kafka nodes in our cluster, each of the servers has:

8 CORE
50G+ RAM
100G ssd

On each server we have zookeeper to manage the cluster.
All the OS limits are increased so the nodes could use more resources than it needs:

Xmx: 10G
Xms: 10G
nofiles: 500000

For now, the traffic to the cluster from producer is minor (~ 10 messages per second). Right now we have only one producer and the message format is:

{"user_id": <id|INT>, "action_id": <id|INT>, "amount": <amount|FLOAT>}

Topic in Kafka is divided onto 6 partitions with 1 replication:

Topic:<some_topic>   PartitionCount:6        ReplicationFactor:1     Configs:
        Topic: <some_topic>  Partition: 0    Leader: 0       Replicas: 0     Isr: 0
        Topic: <some_topic>  Partition: 1    Leader: 1       Replicas: 1     Isr: 1
        Topic: <some_topic>  Partition: 2    Leader: 2       Replicas: 2     Isr: 2
        Topic: <some_topic>  Partition: 3    Leader: 0       Replicas: 0     Isr: 0
        Topic: <some_topic>  Partition: 4    Leader: 1       Replicas: 1     Isr: 1
        Topic: <some_topic>  Partition: 5    Leader: 2       Replicas: 2     Isr: 2

Now, of course, the nodes are underutilized and in kafka side everything is more than ok )

We would like to use KSQL on top of Kafka to be able to filter data coming to our system with SQL.
Here are KSQL server resources:

32 CORE
100G+ RAM
50G+ ssd

We have only one table:

 Field   | Type
-------------------------------------
 ROWTIME   | BIGINT           (system)
 ROWKEY    | VARCHAR(STRING)  (system)
 ACTION_ID | INTEGER
 USER_ID   | INTEGER
 AMOUNT    | DOUBLE

Here is the command the table was created with:

create table <some_table> (action_id INT, user_Id INT, amount DOUBLE) with (KAFKA_TOPIC='<some_topic>', VALUE_FORMAT='JSON', KEY = 'user_id');

In our application, we need to subscribe to the table by user_id, like this:

SELECT * FROM <some_table> WHERE USER_ID=<some_user_id>;

For the production KSQL server configuration, we use the official recommendation from confluent:
https://docs.confluent.io/current/ksql/docs/installation/server-config/config-reference.html#recommended-ksql-production-settings

The OS and software limits are also increased for the KSQL server:

Xmx: 10G  (we have tried till 50G)
Xms: 10G  (we have tried till 50G)
nofiles: 500000

In case we use only one subscription, we don't get any issues (everything is fine in this case).

But we need more than 200000+ subscriptions overall. So when we try to get 100-200 parallel subscriptions, we are getting "read timeouts" in our client. In the server, we do not see any abnormal load that could affect KSQL.

We suppose that the issue is related only with KSQL because when we try to use another KSQL server(in a different machine), at the same time we can see that the second server is working fine and can handle some 1-20 subscriptions.

I could not find any benchmark on internet connected with KSQL server, and in the documentation, as well I could not find any mention of the use cases of the KSQL, maybe it's designed only to serve few connections with huge data, or maybe our system is misconfigured so we should fixed it to use the software for our goals.

Any suggestion would be helpful.

Thanks in advance )

Body:
The reason you're running into scalability issues with ksqlDB is that you're using push queries in a way they were not designed to be used.... yet!

The push query:

SELECT * FROM <some_table> WHERE USER_ID=<some_user_id>;

Which you're using to subscribe to updates for a specific user seems a totally sensible thing to do.

However, in the version of ksql you're using such push queries we only intended for use by humans executing commands at the CLI.  Each such query will, internally, consume a chunk of server resources and consume ALL rows from the source topic.

Basically, push queries do not scale.

The ksqlDB team are actively working on enhancing ksql to support this exact style of use case as we recognise this is a common thing to want to do.  (See https://github.com/confluentinc/ksql/issues/5517).

In the meantime, the way to achieve this would be to consume the data directly from Kafka using your own consumers and do the filtering locally.


问:
How to delete rows from a DF until an empty row is found (Python)
I have built up a dictionary of dataframes containing similar data imported from many excel sheets. However, the data are a bit messy and for each DF I have a header of data I need to remove (like metadata). The problem is that this header of useless data is not always the same in terms of length so I cannot use always the same number of rows to drop while looping through these DFs.

The only common thing across all the DFs is that between this messy data and the data I need(tabular data) there is an empty excel row.
So my idea was to loop through all the DFs in this dictionary and ask starting from the first row to drop all of them until and empty row is met. Once you meet the empty row I still cancel this and then I exist the loop. I hope it is clear. Any help would be more than appreciated. BR Luigi

答:
In pandas, empty values are represented with np.nan. For a single dataframe, you can use pd.isnull with all(axis=1) to find a whole empty row. Then, you can use idxmax to get the first row where that is true (if you have more than 1 empty row, you'll want the first one, right?), and then loc with a : to get the "rest". Like so,

```<code>df = pd.DataFrame({
    'cola': [100, 99, 98, np.nan, 96, np.nan],
    'colb': [1, np.nan, 3, np.nan, 5, np.nan]
})

print(df)

    cola  colb
0  100.0   1.0
1   99.0   NaN
2   98.0   3.0
3    NaN   NaN <- This is the row we want
4   96.0   5.0
5    NaN   NaN <- Not thie one

rest = df.iloc[pd.isnull(df).all(axis=1).idxmax() + 1:, :]
print(rest)

   cola  colb
4  96.0   5.0
5   NaN   NaN
</code>```

In terms of doing it to mutiple dataframes in a dictionary, you can simply iterate over them and repeat the previous method.

```<code># Sample data
df1 = pd.DataFrame({
    'cola': [100, 99, 98, np.nan, 96, np.nan],
    'colb': [1, np.nan, 3, np.nan, 5, np.nan]
})
df2 = pd.DataFrame({
    'cola': [100, 99, 98, np.nan, 96, np.nan],
    'colb': [1, np.nan, 3, np.nan, 5, np.nan]
})
dct = {'first': df1, 'second': df2}

# Solution
out_dict = {}
for key, frame in dct.items():
    new_frame = frame.iloc[pd.isnull(frame).all(axis=1).idxmax() + 1:, :].reset_index(drop=True)
    out_dict[key] = new_frame
</code>```

out_dict now contains your desired dataframes.

Body:
In pandas, empty values are represented with np.nan. For a single dataframe, you can use pd.isnull with all(axis=1) to find a whole empty row. Then, you can use idxmax to get the first row where that is true (if you have more than 1 empty row, you'll want the first one, right?), and then loc with a : to get the "rest". Like so,

df = pd.DataFrame({
    'cola': [100, 99, 98, np.nan, 96, np.nan],
    'colb': [1, np.nan, 3, np.nan, 5, np.nan]
})

print(df)

    cola  colb
0  100.0   1.0
1   99.0   NaN
2   98.0   3.0
3    NaN   NaN <- This is the row we want
4   96.0   5.0
5    NaN   NaN <- Not thie one

rest = df.iloc[pd.isnull(df).all(axis=1).idxmax() + 1:, :]
print(rest)

   cola  colb
4  96.0   5.0
5   NaN   NaN

In terms of doing it to mutiple dataframes in a dictionary, you can simply iterate over them and repeat the previous method.

# Sample data
df1 = pd.DataFrame({
    'cola': [100, 99, 98, np.nan, 96, np.nan],
    'colb': [1, np.nan, 3, np.nan, 5, np.nan]
})
df2 = pd.DataFrame({
    'cola': [100, 99, 98, np.nan, 96, np.nan],
    'colb': [1, np.nan, 3, np.nan, 5, np.nan]
})
dct = {'first': df1, 'second': df2}

# Solution
out_dict = {}
for key, frame in dct.items():
    new_frame = frame.iloc[pd.isnull(frame).all(axis=1).idxmax() + 1:, :].reset_index(drop=True)
    out_dict[key] = new_frame

out_dict now contains your desired dataframes.


问:
How to find minimum sum of elements in a matrix python
How do I compute the minimum sum of elements in a matrix python?
for example:

```<code>z =
np.array([[1, 2, 3],

 [3, 2, 5],

 [2, 4, 4]])
</code>```

The minimum sum of the element is : 1+2+2 = 5

I tried:

```<code>def calculate(a):
    sum = 0
    for i in range(len(a)):
        sum += np.sum(a[i])

    return sum
</code>```

but it gives me 26 instead of 5

Body:
How do I compute the minimum sum of elements in a matrix python?
for example:

z =
np.array([[1, 2, 3],

 [3, 2, 5],

 [2, 4, 4]])

The minimum sum of the element is : 1+2+2 = 5

I tried:

def calculate(a):
    sum = 0
    for i in range(len(a)):
        sum += np.sum(a[i])

    return sum

but it gives me 26 instead of 5

Body:
You find np.min over axis 1.

z = np.array([[1, 2, 3], [3, 2, 5], [2, 4, 4]])
z.min(1).sum()
# 5


问:
Setting varibable to saved value always gets true
I am working on a desktop application with electron, which means, that I am using javascript and other web tools. In this bit of code, I am trying to read a boolean from localStorage and writing it to the checked attribute of an HTML-checkbox:
devtools = document.getElementById('dev-tools-checkbox');
console.log('The saved value: ' + localStorage.getItem('devtools'));
devtools.checked = localStorage.getItem('devtools');

The strange thing is, that no matter what the console shows the logged value as, the checkbox always gets set to true. When reversing the input like this
devtools.checked = !localStorage.getItem('devtools');
the value is always false. I have checked that the right value is set, and the logged value is correct.

When I set the following: devtools.checked = false; it correctly sets the value to false. Same with devtools.checked = true.

Any clue as to where the always true value is coming from would be greatly appreciated. If you need any more information, just ask.

Thanks in advance

答:
localStorage.getItem() returns a DOMString, so the test will always pass except when the item is not set (https://developer.mozilla.org/fr/docs/Web/API/Storage/getItem).

You should check if the item equals true instead:

devtools.checked = localStorage.getItem('devtools') == 'true';


问:
NULL pointer with boost::shared_ptr?
What's the equivalent to the following:

```<code>std::vector<Foo*> vec;
vec.push_back(NULL);
</code>```

when dealing with boost::shared_ptr? Is it the following code?

```<code>std::vector< boost::shared_ptr<Foo> > vec;
vec.push_back(boost::shared_ptr<Foo>());
</code>```

Note: I may push back a lot of such objects. Should I declare a global static nullPtr object somewhere? That way only one of them would have to be constructed:

```<code>boost::shared_ptr<Foo> nullPtr;
</code>```

答:
Your suggestion (calling the shared_ptr<T> constructor with no argument) is correct. (Calling the constructor with the value 0 is equivalent.)  I don't think that this would be any slower than calling vec.push_back() with a pre-existing shared_ptr<T>, since construction is required in both cases (either direct construction or copy-construction).

But if you want "nicer" syntax, you could try the following code:

```<code>class {
public:
    template<typename T>
    operator shared_ptr<T>() { return shared_ptr<T>(); }
} nullPtr;
</code>```

This declares a single global object nullPtr, which enables the following natural syntax:

```<code>shared_ptr<int> pi(new int(42));
shared_ptr<SomeArbitraryType> psat(new SomeArbitraryType("foonly"));

...

pi = nullPtr;
psat = nullPtr;
</code>```

Note that if you use this in multiple translation units (source files), you'll need to give the class a name (e.g. _shared_null_ptr_type), move the definition of the nullPtr object to a separate .cpp file, and add extern declarations in the header file where the class is defined.

OwnerDisplayName: Frank

ContentLicense: CC BY-SA 2.5

Title: NULL pointer with boost::shared_ptr?

Body:
What's the equivalent to the following:

std::vector<Foo*> vec;
vec.push_back(NULL);

when dealing with boost::shared_ptr? Is it the following code?

std::vector< boost::shared_ptr<Foo> > vec;
vec.push_back(boost::shared_ptr<Foo>());

Note: I may push back a lot of such objects. Should I declare a global static nullPtr object somewhere? That way only one of them would have to be constructed:

boost::shared_ptr<Foo> nullPtr;

Body:
Your suggestion (calling the shared_ptr<T> constructor with no argument) is correct. (Calling the constructor with the value 0 is equivalent.)  I don't think that this would be any slower than calling vec.push_back() with a pre-existing shared_ptr<T>, since construction is required in both cases (either direct construction or copy-construction).

But if you want "nicer" syntax, you could try the following code:

class {
public:
    template<typename T>
    operator shared_ptr<T>() { return shared_ptr<T>(); }
} nullPtr;

This declares a single global object nullPtr, which enables the following natural syntax:

shared_ptr<int> pi(new int(42));
shared_ptr<SomeArbitraryType> psat(new SomeArbitraryType("foonly"));

...

pi = nullPtr;
psat = nullPtr;

Note that if you use this in multiple translation units (source files), you'll need to give the class a name (e.g. _shared_null_ptr_type), move the definition of the nullPtr object to a separate .cpp file, and add extern declarations in the header file where the class is defined.


Title: How to find minimum sum of elements in a matrix python

Body:
You can use np.min():-

z = np.array([[1,2,3],[3,2,5],[2,4,4]])
res = sum(np.min(z, axis=1))
print(res)

Output:

5


答:
You shouldn't use for loops to perform operations with Numpy arrays. Numpy exists to provide optimized alternatives to loops, and using loops kind of defeats that purpose. You can take the minimum value of each row (collapsing the first axis), then sum up the resulting three values:</p>

```<code>np.sum(np.min(z, axis=1))
</code>```

```<code>Out[61]: 5
</code>```

Body:
You shouldn't use for loops to perform operations with Numpy arrays. Numpy exists to provide optimized alternatives to loops, and using loops kind of defeats that purpose. You can take the minimum value of each row (collapsing the first axis), then sum up the resulting three values:

np.sum(np.min(z, axis=1))

Out[61]: 5


问:
Rate Over Distance Particle System Not Showing - 2D Gameplay
I have bought a particle system pack from the Asset Store of Unity:
Epic Toon FX

Now within my project, I want to use object trail effects for my player spaceship.
So I have added my selected particle system object within the child of player spaceship object.
But I can't able to see any trail when I run my project within Unity editor.

Within the particle system, I have noticed that the emission rate is based on distance.

How to emission this particle system?
That is big question in the mind.
At present, its parent spaceship object is moving.

答:
Your space ship game object must be having a kinematic rigidbody. The problem with rate over distance is that they are not good to go with kinamatic rigidbody. Try setting the type of rigidbody to dynamic with gravity scale to 0. This should help .

Moreover, remember to move the rigidbody by changing its velocity and not the transform. Also set the simulation space to world.

https://answers.unity.com/questions/1291623/particles-rate-over-distance-emission-not-working.html

@Siddharth


问:
Register every table/class from an app in the Django admin page
I have an app named doors and my models.py for the app has 10 tables/class. Under my admin.py, how do I register every model in the file models.py?

For example, currently I have to hardcode it:

```<code>from django.contrib import admin
from doors.models import *

admin.site.register(Group)
admin.site.register(Item)
admin.site.register(ItemType)
admin.site.register(Location)
admin.site.register(Log)
admin.site.register(Order)
admin.site.register(Property)
admin.site.register(User)
admin.site.register(Vendor)
</code>```

Is there a way I perhaps find every class in models.py and loop through and register each class? Or is there some kind of wildcard I can use with Django?

答:
```<code>from django.apps import apps
from django.contrib.admin.sites import AlreadyRegistered

 app_models = apps.get_app_config('app-name').get_models()
 for model in app_models:
     try:
         admin.site.register(model)
     except AlreadyRegistered:
         pass
</code>```

ContentLicense: CC BY-SA 3.0

Body:
I have an app named doors and my models.py for the app has 10 tables/class. Under my admin.py, how do I register every model in the file models.py?

For example, currently I have to hardcode it:

from django.contrib import admin
from doors.models import *

admin.site.register(Group)
admin.site.register(Item)
admin.site.register(ItemType)
admin.site.register(Location)
admin.site.register(Log)
admin.site.register(Order)
admin.site.register(Property)
admin.site.register(User)
admin.site.register(Vendor)

Is there a way I perhaps find every class in models.py and loop through and register each class? Or is there some kind of wildcard I can use with Django?


问:
How to provide name of the Instance while creating aws ec2 using java aws sdk
I am finding it very hard to figure out how to provide the name of ec2 instance while creating ec2 instance using Aws Java SDK.

I am using following method to create ec2 Instance-

```<code>  RunInstancesRequest runInstancesRequest = new RunInstancesRequest();
            runInstancesRequest.withImageId(ec2Configuration.getImageId())
                    .withInstanceType(ec2Configuration.getInstanceType())
                    .withMinCount(ec2Configuration.getMincount())
                    .withMaxCount(ec2Configuration.getMaxcount())
                    .withKeyName(ec2Configuration.getKeyPairName())
                    .withSecurityGroupIds(Arrays.asList(ec2Configuration.getSgId()));
            if (ec2Configuration.isEbsOptimized())
                runInstancesRequest.withMonitoring(true);
            if (ec2Configuration.isEbsOptimized())
                runInstancesRequest.withEbsOptimized(true);
            try {
                RunInstancesResult result = amazonEC2Client.runInstances(
                        runInstancesRequest);
                } catch (Exception e) {
                // all exception stuffs
                }
</code>```

I could not find anything anywhere like .withName("myVmName").withInstanceType(...) or .define("myVmName").withInstanceType().

What is the way to set the name of Instance while creating an instance.

I want to give name given like the name 'cpanel' given in this image

答:
Instances do not have a name, they instead have tags which are MetaData key values that are attached to the instance.

You will have a tag with the key of "Name".

What you would want to be looking at is the withTagSpecifications argument.

Body:
I am finding it very hard to figure out how to provide the name of ec2 instance while creating ec2 instance using Aws Java SDK.

I am using following method to create ec2 Instance-

  RunInstancesRequest runInstancesRequest = new RunInstancesRequest();
            runInstancesRequest.withImageId(ec2Configuration.getImageId())
                    .withInstanceType(ec2Configuration.getInstanceType())
                    .withMinCount(ec2Configuration.getMincount())
                    .withMaxCount(ec2Configuration.getMaxcount())
                    .withKeyName(ec2Configuration.getKeyPairName())
                    .withSecurityGroupIds(Arrays.asList(ec2Configuration.getSgId()));
            if (ec2Configuration.isEbsOptimized())
                runInstancesRequest.withMonitoring(true);
            if (ec2Configuration.isEbsOptimized())
                runInstancesRequest.withEbsOptimized(true);
            try {
                RunInstancesResult result = amazonEC2Client.runInstances(
                        runInstancesRequest);
                } catch (Exception e) {
                // all exception stuffs
                }

I could not find anything anywhere like .withName("myVmName").withInstanceType(...) or .define("myVmName").withInstanceType().

What is the way to set the name of Instance while creating an instance.

I want to give name given like the name 'cpanel' given in this image


答:
Try:</p>

```<code>min_sum = sum(map(np.min,z))
print(min_sum) # output: 5
</code>```

Body:
Try:

min_sum = sum(map(np.min,z))
print(min_sum) # output: 5


问:
Python read next()
next() in python does not work. What is an alternative to reading next line in Python? Here is a sample:

```<code>filne = "D:/testtube/testdkanimfilternode.txt"
f = open(filne, 'r+')

while 1:
    lines = f.readlines()
    if not lines:
        break
    for line in lines:
        print line
        if (line[:5] == "anim "):
            print 'next() '
            ne = f.next()
            print ' ne ',ne,'\n'
            break

f.close()
</code>```

Running this on a file does not show 'ne '.

答:
```<code>lines = f.readlines()
</code>```

reads all the lines of the file f. So it makes sense that there aren't any more line to read in the file f.
If you want to read the file line by line, use readline().

Title: Python read next()

Body:
next() in python does not work. What is an alternative to reading next line in Python? Here is a sample:

filne = "D:/testtube/testdkanimfilternode.txt"
f = open(filne, 'r+')

while 1:
    lines = f.readlines()
    if not lines:
        break
    for line in lines:
        print line
        if (line[:5] == "anim "):
            print 'next() '
            ne = f.next()
            print ' ne ',ne,'\n'
            break

f.close()

Running this on a file does not show 'ne '.

Body:
lines = f.readlines()

reads all the lines of the file f. So it makes sense that there aren't any more line to read in the file f.
If you want to read the file line by line, use readline().


问:
How to fix the problem with decimal numbers in a factorial function?
I am writing a code for the factorial function. My code is as follows:

```<code>f <- function(n) {
  factorial <- 1
  if( n < 0 )
    print("Factorial of negative numbers is not possible")
  else if( n == 0 )
    print("Factorial of 0 is 1")
  else {
    for(i in 1:n)
      factorial <- factorial * i
    print(paste("Factorial of ",n," is ",factorial))
  }
}
</code>```

My problem with this code is for decimal numbers as input. For example for f(6.5) my code computes 720, but we know 6.5 ! does not exist. For decimal numbers like 6.5, 5/2, or sqrt(2) I would like to see a message like

```<code>"The factorial for this number does not exist".
</code>```

How can I fix this problem in my code?

答:
Something like this? This stops if n and as.integer(n) is not identical.

```<code>f <- function(n) {
  if (as.integer(n) != n) {
    stop("The factorial for this number does not exist")
  }
  factorial <- 1
  if( n < 0 )
    print("Factorial of negative numbers is not possible")
  else if( n == 0 )
    print("Factorial of 0 is 1")
  else {
    for(i in 1:n)
      factorial <- factorial * i
    print(paste("Factorial of ",n," is ",factorial))
  }
}

f(5)
# [1] "Factorial of  5  is  120"
f(6.5)
# Error in f(6.5) : The factorial for this number does not exist
f(5/2)
# Error in f(5/2) : The factorial for this number does not exist
f(sqrt(2))
# Error in f(sqrt(2)) : The factorial for this number does not exist
</code>```

Body:
I am writing a code for the factorial function. My code is as follows:

f <- function(n) {
  factorial <- 1
  if( n < 0 )
    print("Factorial of negative numbers is not possible")
  else if( n == 0 )
    print("Factorial of 0 is 1")
  else {
    for(i in 1:n)
      factorial <- factorial * i
    print(paste("Factorial of ",n," is ",factorial))
  }
}

My problem with this code is for decimal numbers as input. For example for f(6.5) my code computes 720, but we know 6.5 ! does not exist. For decimal numbers like 6.5, 5/2, or sqrt(2) I would like to see a message like

"The factorial for this number does not exist".

How can I fix this problem in my code?

Body:
Something like this? This stops if n and as.integer(n) is not identical.

f <- function(n) {
  if (as.integer(n) != n) {
    stop("The factorial for this number does not exist")
  }
  factorial <- 1
  if( n < 0 )
    print("Factorial of negative numbers is not possible")
  else if( n == 0 )
    print("Factorial of 0 is 1")
  else {
    for(i in 1:n)
      factorial <- factorial * i
    print(paste("Factorial of ",n," is ",factorial))
  }
}

f(5)
# [1] "Factorial of  5  is  120"
f(6.5)
# Error in f(6.5) : The factorial for this number does not exist
f(5/2)
# Error in f(5/2) : The factorial for this number does not exist
f(sqrt(2))
# Error in f(sqrt(2)) : The factorial for this number does not exist


问:
How to Fetch Month Part if Date is in mmYYY format(mm-->Month,YYYY--->Year)?
I need to fetch 'month'  from one column in which date stores in mmYYYY(032019) format.I need to fetch the month column and if months value is  in 01,02,03(Jan,Feb,march) then ,i need to generate new column as 2018-19.if value is 072019 then need to generate new value as 2019-20. Im trying below code but not getting desired result. Can someone please guide me how should i implement this.

```<code>    CASE WHEN month(to_date(from_unixtime(unix_timestamp(dt), 'dd-MM-yyyy'))) IN (01,02,03) THEN
    CONCAT(CONCAT(year(to_date(from_unixtime(unix_timestamp(dt), 'dd-MM-yyyy'))))-1,'-'),
    substr(year(to_date(from_unixtime(unix_timestamp(dt), 'dd-MM-yyyy')))),3,4))
    ELSE CONCAT(CONCAT(year(to_date(from_unixtime(unix_timestamp(dt), 'dd-MM-yyyy')))),'-'),
    SUBSTR(year(to_date(from_unixtime(unix_timestamp(dt), 'dd-MM-yyyy'))))+1,3,4)) end
</code>```

because of my dt column is not in 'dd-mm-yyyy' format so its not giving correct value due to some scenario i don't want to use direct sub-string function  to fetch month part from dt. I want to fetch it using month function or any other function which can fetch month part and then accordingly generate output column based on month part.

```<code>    Sample Data.
    dt=012019
    output : 2018-19

    dt=022019
    output : 2018-19

    dt=032019
    output : 2018-19

    dt=042019
    output : 2019-20

    dt=052019
    output : 2019-20

    dt=062019
    output : 2019-20
</code>```

答:
below code worked for me.</p>

```<code>    CASE WHEN month(to_date(from_unixtime(unix_timestamp(dt,'MMyyyy')))) IN (01,02,03)
    THEN concat(concat(year(to_date(substr(from_unixtime(unix_timestamp(dt, 'MMyyyy')),1,10)))-1,'-')
    ,substr(year(to_date(from_unixtime(unix_timestamp(dt, 'MMyyyy')))),3,4))
    ELSE concat(concat(year(to_date(from_unixtime(unix_timestamp(dt, 'MMyyyy')))),'-'),
    substr(year(to_date(substr(from_unixtime(unix_timestamp(dt, 'MMyyyy')),1,10)))+1,3,4)) END
</code>```

Body:
I need to fetch 'month'  from one column in which date stores in mmYYYY(032019) format.I need to fetch the month column and if months value is  in 01,02,03(Jan,Feb,march) then ,i need to generate new column as 2018-19.if value is 072019 then need to generate new value as 2019-20. Im trying below code but not getting desired result. Can someone please guide me how should i implement this.

    CASE WHEN month(to_date(from_unixtime(unix_timestamp(dt), 'dd-MM-yyyy'))) IN (01,02,03) THEN
    CONCAT(CONCAT(year(to_date(from_unixtime(unix_timestamp(dt), 'dd-MM-yyyy'))))-1,'-'),
    substr(year(to_date(from_unixtime(unix_timestamp(dt), 'dd-MM-yyyy')))),3,4))
    ELSE CONCAT(CONCAT(year(to_date(from_unixtime(unix_timestamp(dt), 'dd-MM-yyyy')))),'-'),
    SUBSTR(year(to_date(from_unixtime(unix_timestamp(dt), 'dd-MM-yyyy'))))+1,3,4)) end

because of my dt column is not in 'dd-mm-yyyy' format so its not giving correct value due to some scenario i don't want to use direct sub-string function  to fetch month part from dt. I want to fetch it using month function or any other function which can fetch month part and then accordingly generate output column based on month part.

    Sample Data.
    dt=012019
    output : 2018-19

    dt=022019
    output : 2018-19

    dt=032019
    output : 2018-19

    dt=042019
    output : 2019-20

    dt=052019
    output : 2019-20

    dt=062019
    output : 2019-20

Body:
below code worked for me.

    CASE WHEN month(to_date(from_unixtime(unix_timestamp(dt,'MMyyyy')))) IN (01,02,03)
    THEN concat(concat(year(to_date(substr(from_unixtime(unix_timestamp(dt, 'MMyyyy')),1,10)))-1,'-')
    ,substr(year(to_date(from_unixtime(unix_timestamp(dt, 'MMyyyy')))),3,4))
    ELSE concat(concat(year(to_date(from_unixtime(unix_timestamp(dt, 'MMyyyy')))),'-'),
    substr(year(to_date(substr(from_unixtime(unix_timestamp(dt, 'MMyyyy')),1,10)))+1,3,4)) END


问:
Recaptcha v2 not validating in PHP
I am trying to validate google recaptcha V2 in my PHP application registration form. But its not getting validated. Its giving a success message and its redirecting to the login page. Can someone please help me on this.

The HTML is as follows:

```<code><div class="captcha_wrapper">
    <div class="g-recaptcha" data-sitekey="KEY"></div>
</div>
</code>```

The AJAX is as follows:

```<code> <script>
     $(document).ready(function() {
         jQuery.validator.addMethod("noSpace", function(value, element) {
             return value.indexOf(" ") < 0 && value != "";
         }, "Spaces are not allowed");

         $("#register_form").submit(function() {
             $("#register_form").validate({
                 rules: {
                     firstname: {
                         required: true
                     },
                     lastname: {
                         required: true
                     },
                     email: {
                         required: true,
                         email: true
                     },
                     username: {
                         required: true,
                         noSpace: true
                     },
                     password: {
                         required: true,
                         minlength: 6
                     },
                     retype_password: {
                         required: true,
                         equalTo: "#inputPassword"
                     },
                 },
                 messages: {
                     firstname: {
                         required: "Enter Firstname<br />",
                     },
                     lastname: {
                         required: "Enter Lastname<br />",
                     },
                     email: {
                         required: "Enter your email address",
                         email: "Enter valid email address"
                     },
                     username: {
                         required: "Enter Username<br />",
                     },
                     password: {
                         required: "Enter your password<br />",
                         minlength: "Password must be minimum 6 characters"
                     },
                     retype_password: {
                         required: "Enter confirm password",
                         equalTo: "Passwords must match"
                     },
                 },
                 errorPlacement: function(error, element) {
                     error.hide();
                     $('.messagebox').hide();
                     error.appendTo($('#alert-message'));
                     $('.messagebox').slideDown('slow');
                 },
             });

    if ($("#register_form").valid()) {
    var data1 = $('#register_form').serialize();
    $.ajax({
        type: "POST",
        url: "register.php",
        data: data1,captcha: grecaptcha.getResponse(),
        success: function(msg) {
            console.log(msg);
            //check if response is true
            if (msg == true) {
                $('.messagebox').hide();
                $('#alert-message').html(msg);
                $('.messagebox').slideDown('slow');
                $("#btn").text('Please Wait...'); // a
                top.location.href = "index.php?msg=login"; //redirection
            } else {
                $('#alert-message').html("CATCHA VALIDATION FAIL!");
            }

        }
    });

             }

             return false;
        });
    });

    $("form").submit(function() {
        console.log($(this).serializeArray());
        console.log('captcha response: ' + grecaptcha.getResponse()); // --> captcha response:
        return false;
    });
</script>
</code>```

This is the PHP Page where its Validating the POST.

```<code>    if (isset($_POST['g-recaptcha-response'])) {

    $secret = '';
    //get verify response data
    $verifyResponse = file_get_contents('https://www.google.com/recaptcha/api/siteverify?secret='.$secret.'&response='.$_POST['g-recaptcha-response']);

    $responseData = json_decode($verifyResponse);

            if($responseData->success == true) {
                //Success: do code to store your data...
                echo 'Robot Verfification SUCCESS';
                return true;
            } else {
                echo 'Robot verification failed, please try again.';
                return false;
            }
    }
</code>```

Now the issue is its validating correctly. But If the validation is correct then it has to redirect to "top.location.href = "index.php?msg=login";". But its not redirecting.

答:
Updated Code</p>

```<code>//check for the post param
if (isset($_POST["captcha"])) {
    //PHP Code
    $secret = "";
    $response = $_POST["captcha"];
    $verify = file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret={$secret}&response={$response}");
    $captcha_success = json_decode($verify);
    if ($captcha_success->success == true || $captcha_success->success == "true" || $captcha_success->success == 1) {
        return true;
    } else {
        return false;
    }
}

    //jQuery
    if ($("#register_form").valid()) {
        var data1 = $('#register_form').serialize();
        $.ajax({
            type: "POST",
            url: "register.php",
            data: {
                'data1': data1,
                'captcha': grecaptcha.getResponse()
            },
            beforeSend: function() {
                $('.messagebox').slideDown('slow');
                $("#btn").text('Please Wait...'); // a
            },
            //captcha: grecaptcha.getResponse(),
            success: function(msg) {
                console.log(msg);
                //check if response is true
                if (msg == true) {
                    $('.messagebox').hide();
                    $('#alert-message').html("Validation Successful");
                    // $('.messagebox').slideDown('slow');
                    // $("#btn").text('Please Wait...'); // a
                    window.location.replace("https://my-site.com/index.php?msg=login"); //redirect to any URL
                    // top.location.href = "index.php?msg=login"; //redirection
                } else {
                    //if validation fails then do stuffs here
                    $('#alert-message').html("Validation Failed !");
                }

            }
        });
</code>```

Title: Recaptcha v2 not validating in PHP

Body:
I am trying to validate google recaptcha V2 in my PHP application registration form. But its not getting validated. Its giving a success message and its redirecting to the login page. Can someone please help me on this.

The HTML is as follows:

The AJAX is as follows:

This is the PHP Page where its Validating the POST.

    if (isset($_POST['g-recaptcha-response'])) {

    $secret = '';
    //get verify response data
    $verifyResponse = file_get_contents('https://www.google.com/recaptcha/api/siteverify?secret='.$secret.'&response='.$_POST['g-recaptcha-response']);

    $responseData = json_decode($verifyResponse);

            if($responseData->success == true) {
                //Success: do code to store your data...
                echo 'Robot Verfification SUCCESS';
                return true;
            } else {
                echo 'Robot verification failed, please try again.';
                return false;
            }
    }

Now the issue is its validating correctly. But If the validation is correct then it has to redirect to "top.location.href = "index.php?msg=login";". But its not redirecting.

Body:
Updated Code

//check for the post param
if (isset($_POST["captcha"])) {
    //PHP Code
    $secret = "";
    $response = $_POST["captcha"];
    $verify = file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret={$secret}&response={$response}");
    $captcha_success = json_decode($verify);
    if ($captcha_success->success == true || $captcha_success->success == "true" || $captcha_success->success == 1) {
        return true;
    } else {
        return false;
    }
}

    //jQuery
    if ($("#register_form").valid()) {
        var data1 = $('#register_form').serialize();
        $.ajax({
            type: "POST",
            url: "register.php",
            data: {
                'data1': data1,
                'captcha': grecaptcha.getResponse()
            },
            beforeSend: function() {
                $('.messagebox').slideDown('slow');
                $("#btn").text('Please Wait...'); // a
            },
            //captcha: grecaptcha.getResponse(),
            success: function(msg) {
                console.log(msg);
                //check if response is true
                if (msg == true) {
                    $('.messagebox').hide();
                    $('#alert-message').html("Validation Successful");
                    // $('.messagebox').slideDown('slow');
                    // $("#btn").text('Please Wait...'); // a
                    window.location.replace("https://my-site.com/index.php?msg=login"); //redirect to any URL
                    // top.location.href = "index.php?msg=login"; //redirection
                } else {
                    //if validation fails then do stuffs here
                    $('#alert-message').html("Validation Failed !");
                }

            }
        });


答:
next() does not work in your case because you first call readlines() which basically sets the file iterator to point to the end of file.

Since you are reading in all the lines anyway you can refer to the next line using an index:

```<code>filne = "in"
with open(filne, 'r+') as f:
    lines = f.readlines()
    for i in range(0, len(lines)):
        line = lines[i]
        print line
        if line[:5] == "anim ":
            ne = lines[i + 1] # you may want to check that i < len(lines)
            print ' ne ',ne,'\n'
            break
</code>```

Title: Python read next()

Body:
next() does not work in your case because you first call readlines() which basically sets the file iterator to point to the end of file.

Since you are reading in all the lines anyway you can refer to the next line using an index:

filne = "in"
with open(filne, 'r+') as f:
    lines = f.readlines()
    for i in range(0, len(lines)):
        line = lines[i]
        print line
        if line[:5] == "anim ":
            ne = lines[i + 1] # you may want to check that i < len(lines)
            print ' ne ',ne,'\n'
            break


问:
how to keep randomUUID static
I generate the UUID but the problem is that when I close the app and run it again he generate another UUID, I want to generate UUID just for one time, and keep it always the same after installing the application.</p>

```<code>private final static String androidId = UUID.randomUUID().toString();
</code>```

答:
reference to Công Hải's comment ,I used SharedPreference and it work perfectly:</p>

```<code>private static String uuid;

SharedPreferences sPrefs = PreferenceManager.getDefaultSharedPreferences(this);
uuid = sPrefs.getString("uuid",null);
if (uuid == null){
      uuid = UUID.randomUUID().toString();
      SharedPreferences.Editor editor = sPrefs.edit();
      editor.putString("uuid",uuid);
      editor.apply();
}
</code>```

Title: how to keep randomUUID static

Body:
I generate the UUID but the problem is that when I close the app and run it again he generate another UUID, I want to generate UUID just for one time, and keep it always the same after installing the application.

private final static String androidId = UUID.randomUUID().toString();

Body:
reference to Công Hải's comment ,I used SharedPreference and it work perfectly:

private static String uuid;

SharedPreferences sPrefs = PreferenceManager.getDefaultSharedPreferences(this);
uuid = sPrefs.getString("uuid",null);
if (uuid == null){
      uuid = UUID.randomUUID().toString();
      SharedPreferences.Editor editor = sPrefs.edit();
      editor.putString("uuid",uuid);
      editor.apply();
}


问:
sklearn how to use saved model to predict new data
I use sklearn trained a SVM text classifier, used tf-idf(TfidfVectorizer) to extract the feature.
now I need to save the model and load it to predict the text unseen. I will load the model in another file,  what confuses me is how to extract the new text tf-idf feature</p>

答:
You need to save the model AND the tfidf transformer. You can either save them separately, or create a pipeline of the two and save the pipeline (this is the preferred option).

Example:

```<code>from sklearn.linear_model import LogisticRegression
from sklearn.feature_extraction.text import TfidfVectorizer
from sklearn.pipeline import Pipeline
import pickle

Tfidf = TfidfVectorizer()
LR = LogisticRegression()
pipe = Pipeline([("Tfidf", Tfidf), ("LR", LR)])
pipe.fit(X, y)

with open('pipe.pickle', 'wb') as picklefile:
    pickle.dump(pipe, picklefile)
</code>```

You can then load the whole pipeline which upon predict will first apply the vectorizer and then pass it to the model:

```<code>with open('pipe.pickle', 'rb') as picklefile:
    saved_pipe = pickle.load(picklefile)

saved_pipe.predict(X_test)
</code>```

Body:
You need to save the model AND the tfidf transformer. You can either save them separately, or create a pipeline of the two and save the pipeline (this is the preferred option).

Example:

from sklearn.linear_model import LogisticRegression
from sklearn.feature_extraction.text import TfidfVectorizer
from sklearn.pipeline import Pipeline
import pickle

Tfidf = TfidfVectorizer()
LR = LogisticRegression()
pipe = Pipeline([("Tfidf", Tfidf), ("LR", LR)])
pipe.fit(X, y)

with open('pipe.pickle', 'wb') as picklefile:
    pickle.dump(pipe, picklefile)

You can then load the whole pipeline which upon predict will first apply the vectorizer and then pass it to the model:

with open('pipe.pickle', 'rb') as picklefile:
    saved_pipe = pickle.load(picklefile)

saved_pipe.predict(X_test)


问:
how to insert multiple foreign key in DB Browser for SQLite (GUI)
I am using SQLite and DB Browser for SQLite. I know that if you want to insert a foreign key using the GUI, you just have to scroll to the right and double click to insert the foreign key to the corresponding field. The problem is when you want to use a multiple foreign key. How or where should i put the multiple foreign key constrain using the GUI ?
my actual sql is (returns an exception 'foreign key mismatch - "diseases" referencing "beehives"...'):

```<code>CREATE TABLE "diseases" (
"id"    INTEGER NOT NULL,
"id_beehive"    INTEGER NOT NULL,
"id_apiary" INTEGER NOT NULL,
"disease"   TEXT NOT NULL,
"treatment" TEXT NOT NULL,
"start_treat_date"  DATE NOT NULL,
"end_treat_date"    DATE,
PRIMARY KEY("id"),
FOREIGN KEY("id_beehive") REFERENCES "beehives"("number") ON UPDATE CASCADE,
FOREIGN KEY("id_apiary") REFERENCES "beehives"("id_apiary") ON UPDATE CASCADE
);
</code>```

what i want to do using the gui is:

```<code>CREATE TABLE "diseases" (
"id"    INTEGER NOT NULL,
"id_beehive"    INTEGER NOT NULL,
"id_apiary" INTEGER NOT NULL,
"disease"   TEXT NOT NULL,
"treatment" TEXT NOT NULL,
"start_treat_date"  DATE NOT NULL,
"end_treat_date"    DATE,
PRIMARY KEY("id"),
FOREIGN KEY("id_beehive","id_apiary") REFERENCES "beehives"("number","id_apiary") ON UPDATE CASCADE
);
</code>```

beehives sql:

```<code>CREATE TABLE "beehives" (
"number"    INTEGER NOT NULL,
"id_apiary" INTEGER NOT NULL DEFAULT -2,
"date"  DATE,
"type"  TEXT,
"favorite"  BOOLEAN DEFAULT 'false',
PRIMARY KEY("number","id_apiary"),
FOREIGN KEY("id_apiary") REFERENCES "apiaries"("id") ON DELETE SET NULL
);
</code>```

答:
After researching, it is not possible for the moment.
Everytime you modify the structure of the table, what DB Browser for SQLite do on the background is renaming the table, creating a new table with the updated structure, move the data to this new table and delete the old table. So in the GUI it looks like its only updating.
Unfortunatly, to create a composite foreign key or modify a simple FK to a composite FK , you can only do it manualy from the SQL window.

example :

```<code>FOREIGN KEY("id_beehive","id_apiary") REFERENCES "beehives"("number","id_apiary") ON
UPDATE CASCADE
</code>```

Body:
I am using SQLite and DB Browser for SQLite. I know that if you want to insert a foreign key using the GUI, you just have to scroll to the right and double click to insert the foreign key to the corresponding field. The problem is when you want to use a multiple foreign key. How or where should i put the multiple foreign key constrain using the GUI ?
my actual sql is (returns an exception 'foreign key mismatch - "diseases" referencing "beehives"...'):

CREATE TABLE "diseases" (
"id"    INTEGER NOT NULL,
"id_beehive"    INTEGER NOT NULL,
"id_apiary" INTEGER NOT NULL,
"disease"   TEXT NOT NULL,
"treatment" TEXT NOT NULL,
"start_treat_date"  DATE NOT NULL,
"end_treat_date"    DATE,
PRIMARY KEY("id"),
FOREIGN KEY("id_beehive") REFERENCES "beehives"("number") ON UPDATE CASCADE,
FOREIGN KEY("id_apiary") REFERENCES "beehives"("id_apiary") ON UPDATE CASCADE
);

what i want to do using the gui is:

CREATE TABLE "diseases" (
"id"    INTEGER NOT NULL,
"id_beehive"    INTEGER NOT NULL,
"id_apiary" INTEGER NOT NULL,
"disease"   TEXT NOT NULL,
"treatment" TEXT NOT NULL,
"start_treat_date"  DATE NOT NULL,
"end_treat_date"    DATE,
PRIMARY KEY("id"),
FOREIGN KEY("id_beehive","id_apiary") REFERENCES "beehives"("number","id_apiary") ON UPDATE CASCADE
);

beehives sql:

CREATE TABLE "beehives" (
"number"    INTEGER NOT NULL,
"id_apiary" INTEGER NOT NULL DEFAULT -2,
"date"  DATE,
"type"  TEXT,
"favorite"  BOOLEAN DEFAULT 'false',
PRIMARY KEY("number","id_apiary"),
FOREIGN KEY("id_apiary") REFERENCES "apiaries"("id") ON DELETE SET NULL
);

Body:
After researching, it is not possible for the moment.
Everytime you modify the structure of the table, what DB Browser for SQLite do on the background is renaming the table, creating a new table with the updated structure, move the data to this new table and delete the old table. So in the GUI it looks like its only updating.
Unfortunatly, to create a composite foreign key or modify a simple FK to a composite FK , you can only do it manualy from the SQL window.

example :

FOREIGN KEY("id_beehive","id_apiary") REFERENCES "beehives"("number","id_apiary") ON
UPDATE CASCADE


问:
Java Annotation for composite Range Keys in DDB
I have a my_table with a composite sort key made of two combined attributes id and model_name (i.e., id_model_name, similarly from what is done here here and here).

So I created this Java model:

```<code>@Builder
@Data
@AllArgsConstructor
@NoArgsConstructor
@DynamoDBTable(tableName = "my_table")
public class TableModel {

    private static final String COMPOSITE_KEY_SEPARATOR = "_";

    @DynamoDBAttribute(attributeName = "id")
    private String id;

    @DynamoDBAttribute(attributeName = "model_name")
    private String modelName;

    @DynamoDBRangeKey(attributeName = "id_model_name")
    public String getIdModelName() {
        return String.format("%s%s%s", id, COMPOSITE_KEY_SEPARATOR, modelName);
    }

    // more stuff...
}
</code>```

However I'm getting:

DynamoDBMappingException: DRTFacet[id_model_name]; could not unconvert attribute

Notice that there is no String idModelName field, because it could mess up with @AllArgsConstructor and @Builder (since it's a derived field). Is it because this field is missing (together with a setter method?). How can I overcome this?

答:
I found out that providing a dummy setter solved the problem:</p>

```<code>public void setIdModelName(final String idModelName) {}
</code>```

Body:
I have a my_table with a composite sort key made of two combined attributes id and model_name (i.e., id_model_name, similarly from what is done here here and here).

So I created this Java model:

@Builder
@Data
@AllArgsConstructor
@NoArgsConstructor
@DynamoDBTable(tableName = "my_table")
public class TableModel {

    private static final String COMPOSITE_KEY_SEPARATOR = "_";

    @DynamoDBAttribute(attributeName = "id")
    private String id;

    @DynamoDBAttribute(attributeName = "model_name")
    private String modelName;

    @DynamoDBRangeKey(attributeName = "id_model_name")
    public String getIdModelName() {
        return String.format("%s%s%s", id, COMPOSITE_KEY_SEPARATOR, modelName);
    }

    // more stuff...
}

However I'm getting:

DynamoDBMappingException: DRTFacet[id_model_name]; could not unconvert attribute

Notice that there is no String idModelName field, because it could mess up with @AllArgsConstructor and @Builder (since it's a derived field). Is it because this field is missing (together with a setter method?). How can I overcome this?

Body:
I found out that providing a dummy setter solved the problem:

public void setIdModelName(final String idModelName) {}