问:
How do I make these three aligning divs responsive?
On my website home page (https://abbaproperty.000webhostapp.com/) I have three divs inline that look like this:

But when viewed on a slightly smaller scree (not mobile), it looks like this:

They're no longer the same height. Although I have added some responsive CSS so it does look like this on a smaller mobile device.

So my question here is that there is a sweet spot where these divs are not displayed very well responsively and I can't think of even the logical CSS to get around this.

HTML:

```<code><div class="container" style="width:100%; background-color:#205ba0; padding:30px;">

    <div class="col-md-offset-3 col-md-2" align="center" style="color:white; border:2px solid white; font-size:12px; padding:10px;">
        <div class="trip" style="background-color:white; margin-bottom:10px; padding-bottom:5px;">
            <img src="https://abbaproperty.000webhostapp.com/wp-content/uploads/2017/05/rent.png" style="height:100px;">
        </div>
        <h2 style="font-weight:bold;">Renting? Landlords welcome.</h2>
        A swift liason between landlords and tenants as a fair, independeant party, is just one of our services.<br><br>
        <a href="https://abbaproperty.000webhostapp.com/index.php/property-management/" style="color:white;">Find out more ></a>
    </div>

    <div class="col-md-2" align="center" style="color:white; border:2px solid white; font-size:12px; padding:10px;">
        <div class="trip" style="background-color:white; margin-bottom:15px;">
            <img src="https://abbaproperty.000webhostapp.com/wp-content/uploads/2017/05/val.png" style="height:100px;">
        </div>
        <h2 style="font-weight:bold;">Valuation? Sorted quickly.</h2>
        Providing some of the most effecient valuations in town, we're here to help you sort out an important step.<br><br>
        <a href="https://abbaproperty.000webhostapp.com/index.php/valuations/" style="color:white;">Find out more ></a>
    </div>

    <div class="col-md-2" align="center" style="color:white; border:2px solid white; font-size:12px; padding:10px;">
        <div class="trip" style="background-color:white; margin-bottom:10px; padding-bottom:5px;">
            <img src="https://abbaproperty.000webhostapp.com/wp-content/uploads/2017/05/sale.png" style="height:100px;">
        </div>
        <h2 style="font-weight:bold;">Selling? Now uncomplicated.</h2>
        We aim to make selling easy. Our trained estate agents are constantly available to help.<br><br>
        <a href="https://abbaproperty.000webhostapp.com/index.php/sell/" style="color:white;">Find out more ></a>
    </div>

</div>
</code>```

答:
You would need to use flexbox for this!

On your container, add another class called flexbox and add the following:

```<code>.flexbox {
    display: flex;
}
</code>```

Heres a fiddle!

https://jsfiddle.net/d6xfu1yz/

Body:
On my website home page (https://abbaproperty.000webhostapp.com/) I have three divs inline that look like this:

But when viewed on a slightly smaller scree (not mobile), it looks like this:

They're no longer the same height. Although I have added some responsive CSS so it does look like this on a smaller mobile device.

So my question here is that there is a sweet spot where these divs are not displayed very well responsively and I can't think of even the logical CSS to get around this.

HTML:

Renting? Landlords welcome.

        A swift liason between landlords and tenants as a fair, independeant party, is just one of our services.

        Find out more >

Valuation? Sorted quickly.

        Providing some of the most effecient valuations in town, we're here to help you sort out an important step.

        Find out more >

Selling? Now uncomplicated.

        We aim to make selling easy. Our trained estate agents are constantly available to help.

        Find out more >

Body:
You would need to use flexbox for this!

On your container, add another class called flexbox and add the following:

.flexbox {
    display: flex;
}

Heres a fiddle!

https://jsfiddle.net/d6xfu1yz/


来源: stackexchange

问:
java.net.URISyntaxException: Expected authority at index 7: http://
I am getting error:

Caused by: java.net.URISyntaxException: Expected authority at index 7:
  http://

For below code:

```<code>try
{
    return new RemoteWebDriver(new URL("http://" + username + ":" + authkey +"@hub.crossbrowsertesting.com:80/wd/hub"), caps);
}
catch (MalformedURLException e)
{
    // TODO Auto-generated catch block
    e.printStackTrace();
    return null;
 }
</code>```

Stack trace:

Driver info: driver.version: RemoteWebDriver
        at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:622)
        at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:241)
        at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:128)
        at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:155)
        at abc.testcase.LoginForm2.main(LoginForm2.java:45)
      Caused by: org.apache.http.client.ClientProtocolException
        at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:186)
        at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:71)
        at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:55)
        at org.openqa.selenium.remote.internal.ApacheHttpClient.fallBackExecute(ApacheHttpClient.java:142)
        at org.openqa.selenium.remote.internal.ApacheHttpClient.execute(ApacheHttpClient.java:88)
        at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:108)
        at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:64)
        at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:141)
        at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:601)
        ... 4 more
      Caused by: org.apache.http.HttpException: Cannot convert host to URI: http://
        at org.apache.http.impl.conn.SystemDefaultRoutePlanner.determineProxy(SystemDefaultRoutePlanner.java:77)
        at org.apache.http.impl.conn.DefaultRoutePlanner.determineRoute(DefaultRoutePlanner.java:77)
        at org.apache.http.impl.client.InternalHttpClient.determineRoute(InternalHttpClient.java:124)
        at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:183)
        ... 12 more
      Caused by: java.net.URISyntaxException: Expected authority at index 7: http://
        at java.net.URI$Parser.fail(URI.java:2848)
        at java.net.URI$Parser.failExpecting(URI.java:2854)
        at java.net.URI$Parser.parseHierarchical(URI.java:3102)
        at java.net.URI$Parser.parse(URI.java:3053)
        at java.net.URI.(URI.java:588)
        at org.apache.http.impl.conn.SystemDefaultRoutePlanner.determineProxy(SystemDefaultRoutePlanner.java:75)
        ... 15 more

Please help!

答: Error got resolved just by encoding @ by %40</p>

ContentLicense: CC BY-SA 3.0

Body:
I am getting error:

Caused by: java.net.URISyntaxException: Expected authority at index 7:
  http://

For below code:

try
{
    return new RemoteWebDriver(new URL("http://" + username + ":" + authkey +"@hub.crossbrowsertesting.com:80/wd/hub"), caps);
}
catch (MalformedURLException e)
{
    // TODO Auto-generated catch block
    e.printStackTrace();
    return null;
 }

Stack trace:

Driver info: driver.version: RemoteWebDriver
        at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:622)
        at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:241)
        at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:128)
        at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:155)
        at abc.testcase.LoginForm2.main(LoginForm2.java:45)
      Caused by: org.apache.http.client.ClientProtocolException
        at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:186)
        at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:71)
        at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:55)
        at org.openqa.selenium.remote.internal.ApacheHttpClient.fallBackExecute(ApacheHttpClient.java:142)
        at org.openqa.selenium.remote.internal.ApacheHttpClient.execute(ApacheHttpClient.java:88)
        at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:108)
        at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:64)
        at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:141)
        at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:601)
        ... 4 more
      Caused by: org.apache.http.HttpException: Cannot convert host to URI: http://
        at org.apache.http.impl.conn.SystemDefaultRoutePlanner.determineProxy(SystemDefaultRoutePlanner.java:77)
        at org.apache.http.impl.conn.DefaultRoutePlanner.determineRoute(DefaultRoutePlanner.java:77)
        at org.apache.http.impl.client.InternalHttpClient.determineRoute(InternalHttpClient.java:124)
        at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:183)
        ... 12 more
      Caused by: java.net.URISyntaxException: Expected authority at index 7: http://
        at java.net.URI$Parser.fail(URI.java:2848)
        at java.net.URI$Parser.failExpecting(URI.java:2854)
        at java.net.URI$Parser.parseHierarchical(URI.java:3102)
        at java.net.URI$Parser.parse(URI.java:3053)
        at java.net.URI.(URI.java:588)
        at org.apache.http.impl.conn.SystemDefaultRoutePlanner.determineProxy(SystemDefaultRoutePlanner.java:75)
        ... 15 more

Please help!


问:
Convert to List<dynamic> records gets null
enter image description hereI am trying to convert my List to DataTable but while converting the records count gets 0.

Here is my code:

```<code>DataAccessProvider dap = new DataAccessProvider(
    Settings.Default.SQLServerConnection,
    DatabaseType.MSSql);
var employees = dap.SelectAll("Employees").AsEnumerable().ToList();
DataTable Employees = new DataTable();
Employees = ToDataTable(employees);

public DataTable ToDataTable<T>(List<T> items)
{
    DataTable dataTable = new DataTable(typeof(T).Name);
    //Get all the properties
    PropertyInfo[] Props = typeof(T).GetProperties(
        BindingFlags.Public | BindingFlags.Instance);
    foreach (PropertyInfo prop in Props)
    {
        //Setting column names as Property names
        dataTable.Columns.Add(prop.Name);
    }
    foreach (T item in items)
    {
        var values = new object[Props.Length];
        for (int i = 0; i < Props.Length; i++)
        {
            //inserting property values to datatable rows
            values[i] = Props[i].GetValue(item, null);
        }
        dataTable.Rows.Add(values);
    }
    //put a breakpoint here and check datatable
    return dataTable;
}

public List<dynamic> SelectAll(string tableName)
{
    List<dynamic> result = new List<dynamic>();

    using (IDataReader reader = ExecuteReader("Select * From " + tableName))
    {
        while (reader.Read())
        {
            dynamic expando = new ExpandoObject();
            for (int i = 0; i < reader.FieldCount; i++)
            {
                string columnName = reader.GetName(i);
                ((IDictionary<String, Object>)expando).Add(
                    columnName,
                    reader[columnName]);
            }
            result.Add(expando);
        }
    }

    return result;
}
</code>```

All above are my code. When I debugged I found that in ToDataTable function the Props count gets 0. So what is wrong here?

答:
dynamic objects do not have any properties, let alone public instance ones.

This code outputs zero:

```<code>dynamic expando = new ExpandoObject();
((IDictionary<String, Object>)expando).Add(
                    "col",
                   "val");
Console.WriteLine(expando.GetType().GetProperties().Length);
</code>```

(Live example: http://rextester.com/IOTK71323)

If you want to access the dynamic properties, you need to cast it to the same dictionary you do for writing to it, and read the keys/values:

```<code>dynamic expando = new ExpandoObject();
((IDictionary<String, Object>)expando).Add(
                    "col",
                   "val");

var dict =  ((IDictionary<String, Object>)expando);
foreach(var kv in dict)
    Console.WriteLine("{0} = {1}", kv.Key,kv.Value);
</code>```

(Live example: http://rextester.com/RMAW17261)

Body:
enter image description hereI am trying to convert my List to DataTable but while converting the records count gets 0.

Here is my code:

DataAccessProvider dap = new DataAccessProvider(
    Settings.Default.SQLServerConnection,
    DatabaseType.MSSql);
var employees = dap.SelectAll("Employees").AsEnumerable().ToList();
DataTable Employees = new DataTable();
Employees = ToDataTable(employees);

public DataTable ToDataTable<T>(List<T> items)
{
    DataTable dataTable = new DataTable(typeof(T).Name);
    //Get all the properties
    PropertyInfo[] Props = typeof(T).GetProperties(
        BindingFlags.Public | BindingFlags.Instance);
    foreach (PropertyInfo prop in Props)
    {
        //Setting column names as Property names
        dataTable.Columns.Add(prop.Name);
    }
    foreach (T item in items)
    {
        var values = new object[Props.Length];
        for (int i = 0; i < Props.Length; i++)
        {
            //inserting property values to datatable rows
            values[i] = Props[i].GetValue(item, null);
        }
        dataTable.Rows.Add(values);
    }
    //put a breakpoint here and check datatable
    return dataTable;
}

public List<dynamic> SelectAll(string tableName)
{
    List<dynamic> result = new List<dynamic>();

    using (IDataReader reader = ExecuteReader("Select * From " + tableName))
    {
        while (reader.Read())
        {
            dynamic expando = new ExpandoObject();
            for (int i = 0; i < reader.FieldCount; i++)
            {
                string columnName = reader.GetName(i);
                ((IDictionary<String, Object>)expando).Add(
                    columnName,
                    reader[columnName]);
            }
            result.Add(expando);
        }
    }

    return result;
}

All above are my code. When I debugged I found that in ToDataTable function the Props count gets 0. So what is wrong here?

Body:
dynamic objects do not have any properties, let alone public instance ones.

This code outputs zero:

dynamic expando = new ExpandoObject();
((IDictionary<String, Object>)expando).Add(
                    "col",
                   "val");
Console.WriteLine(expando.GetType().GetProperties().Length);

(Live example: http://rextester.com/IOTK71323)

If you want to access the dynamic properties, you need to cast it to the same dictionary you do for writing to it, and read the keys/values:

dynamic expando = new ExpandoObject();
((IDictionary<String, Object>)expando).Add(
                    "col",
                   "val");

var dict =  ((IDictionary<String, Object>)expando);
foreach(var kv in dict)
    Console.WriteLine("{0} = {1}", kv.Key,kv.Value);

(Live example: http://rextester.com/RMAW17261)


问:
.Net fail to connect to Apple Push Notification service
I'm using .NET 4.5 c# to connect to a server that supports only TLS 1.2. (Apple Push Notification Server).

My code fails here:

```<code>sslStream.AuthenticateAsClient(server, myAppleCertificates, SslProtocols.Tls12, true);
</code>```

I did a lot of testing and Googling and found the following:

1) This code works fine if i use a window 10 pc, but doesn't if I run this on my development server or production server. Windows Server 2008 R2.

2) All the pc's and servers are running .net 4.6+

3) I can add the line "ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;" - its still behaves exactly the same.

4) I can replicate the issue on Windows 10, buy simply changing it to:
sslStream.AuthenticateAsClient(server, myAppleCertificates, SslProtocols.Tls11, true);

5) I have added the following registry entries and rebooted the server will no effect:

```<code>[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2\Client]
"Enabled"=dword:00000001

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2\Client]
"DisabledByDefault"=dword:00000000

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2\Server]
"Enabled"=dword:00000001

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2\Server]
"DisabledByDefault"=dword:00000000
</code>```

5) Server is up to date with windows updates. (actually... im not 100% on this one)

6) IISCrypto, says the protocols are there, and set as defaults correctly.

7) I can use Chrome to connect to APN, no problems, on my PC, and both the servers.

8) If i use Fiddler to test, it behaves exactly the same as my application, after i enable the TLS12 setting in the fiddler settings. I guess this is because Fiddler is build in .net 4.

Its as though even if you force .NET to use TLS1.2, it simply doesn't, and reverts back to 1.1. Does anyone have any more idea's here.

Thanks

Here is my test code:

```<code>public class SslTcpClient
    {
        private static Hashtable certificateErrors = new Hashtable();

        public static bool ValidateServerCertificate(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
        {
            if (sslPolicyErrors == SslPolicyErrors.None) return true;

            Console.WriteLine("Certificate error: {0}", sslPolicyErrors);
            return false;
        }
        public static X509Certificate SelectLocalCertificate(object sender, string targetHost, X509CertificateCollection localCertificates, X509Certificate remoteCertificate, string[] acceptableIssuers)
        {
            Console.WriteLine("Client is selecting a local certificate.");
            if (acceptableIssuers != null && acceptableIssuers.Length > 0 && localCertificates != null && localCertificates.Count > 0)
            {
                // Use the first certificate that is from an acceptable issuer.
                foreach (X509Certificate certificate in localCertificates)
                {
                    string issuer = certificate.Issuer;
                    if (Array.IndexOf(acceptableIssuers, issuer) != -1) return certificate;
                }
            }
            if (localCertificates != null && localCertificates.Count > 0)  return localCertificates[0];

            return null;
        }

        public static void RunClient(string server)
        {
            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

            TcpClient client = new TcpClient(server, 443);
            Console.WriteLine("Client connected.");
            SslStream sslStream = new SslStream(client.GetStream(), false, new RemoteCertificateValidationCallback(ValidateServerCertificate), null);
            Console.WriteLine("SSL stream obtained");

            try
            {
                X509Certificate localCertificate = new X509Certificate("VOIPPush.p12", "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");

                Console.WriteLine("Local Certificte features");
                Console.WriteLine("=========================");

                Console.WriteLine("Issuer: " + localCertificate.Issuer);
                Console.WriteLine("Subject: " + localCertificate.Subject);

                Console.WriteLine("CertHash: " + localCertificate.GetCertHashString());
                Console.WriteLine("EffectiveDate: " + localCertificate.GetEffectiveDateString());
                Console.WriteLine("ExpirationDate: " + localCertificate.GetExpirationDateString());
                Console.WriteLine("Format: " + localCertificate.GetFormat());
                Console.WriteLine("HashCode: " + localCertificate.GetHashCode().ToString());
                Console.WriteLine("KeyAlgorithm: " + localCertificate.GetKeyAlgorithm());
                Console.WriteLine("KeyAlgorithmParameters: " + localCertificate.GetKeyAlgorithmParametersString());
                Console.WriteLine("PublicKey: " + localCertificate.GetPublicKeyString());
                Console.WriteLine("SerialNumber: " + localCertificate.GetSerialNumberString());
                X509CertificateCollection localCertificates = new X509CertificateCollection();
                localCertificates.Add(localCertificate);

                sslStream.AuthenticateAsClient(server, localCertificates, SslProtocols.Tls12, true);
                Console.WriteLine("Authenticated as client");

                X509Certificate remoteCertificate = sslStream.RemoteCertificate;

                Console.WriteLine("Remote Certificte features");
                Console.WriteLine("==========================");

                Console.WriteLine("Issuer: " + remoteCertificate.Issuer);
                Console.WriteLine("Subject: " + remoteCertificate.Subject);

                Console.WriteLine("CertHash: " + remoteCertificate.GetCertHashString());
                Console.WriteLine("EffectiveDate: " + remoteCertificate.GetEffectiveDateString());
                Console.WriteLine("ExpirationDate: " + remoteCertificate.GetExpirationDateString());
                Console.WriteLine("Format: " + remoteCertificate.GetFormat());
                Console.WriteLine("HashCode: " + remoteCertificate.GetHashCode().ToString());
                Console.WriteLine("KeyAlgorithm: " + remoteCertificate.GetKeyAlgorithm());
                Console.WriteLine("KeyAlgorithmParameters: " + remoteCertificate.GetKeyAlgorithmParametersString());
                Console.WriteLine("PublicKey: " + remoteCertificate.GetPublicKeyString());
                Console.WriteLine("SerialNumber: " + remoteCertificate.GetSerialNumberString());

            }
            catch (AuthenticationException e)
            {
                Console.WriteLine("Exception: {0}", e.ToString());
                client.Close();
                return;
            }
            byte[] messsage = Encoding.UTF8.GetBytes(@"PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n");

            // no use in writing more, this is just a test...

            Console.WriteLine("Writing to sslStream...");
            sslStream.Write(messsage);
            Console.WriteLine("Writing done");
            sslStream.Flush();

            Console.WriteLine("Reading Response...");
            string serverMessage = ReadMessage(sslStream);
            Console.WriteLine("Server says: {0}", serverMessage);

            client.Close();
            Console.WriteLine("Client closed.");
        }
        static string ReadMessage(SslStream sslStream)
        {
            // Read the  message sent by the server.
            // The end of the message is signaled using the
            // "<EOF>" marker.
            byte[] buffer = new byte[2048];
            StringBuilder messageData = new StringBuilder();
            int bytes = -1;
            do
            {
                bytes = sslStream.Read(buffer, 0, buffer.Length);

                // Use Decoder class to convert from bytes to UTF8
                // in case a character spans two buffers.
                Decoder decoder = Encoding.UTF8.GetDecoder();
                char[] chars = new char[decoder.GetCharCount(buffer, 0, bytes)];
                decoder.GetChars(buffer, 0, bytes, chars, 0);
                messageData.Append(chars);
                // Check for EOF.
                if (messageData.ToString().IndexOf("<EOF>") != -1)
                {
                    break;
                }
            } while (bytes != 0);

            return messageData.ToString();
        }

        public static void Main(string[] args)
        {
            SslTcpClient.RunClient("api.push.apple.com");
            Console.ReadLine();
        }
    }
</code>```

答:
"Currently, in the standard .NET framework, HTTP/2 is not supported in HttpClient. However, in the .NET Core framework, it is.. but it requires to be run on Windows 10 (or, I assume Windows Server 2016)"

Ref: Is there any way to use the new http/2 api to send push notifications in C#?

Body:
I'm using .NET 4.5 c# to connect to a server that supports only TLS 1.2. (Apple Push Notification Server).

My code fails here:

sslStream.AuthenticateAsClient(server, myAppleCertificates, SslProtocols.Tls12, true);

I did a lot of testing and Googling and found the following:

1) This code works fine if i use a window 10 pc, but doesn't if I run this on my development server or production server. Windows Server 2008 R2.

2) All the pc's and servers are running .net 4.6+

3) I can add the line "ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;" - its still behaves exactly the same.

4) I can replicate the issue on Windows 10, buy simply changing it to:
sslStream.AuthenticateAsClient(server, myAppleCertificates, SslProtocols.Tls11, true);

5) I have added the following registry entries and rebooted the server will no effect:

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2\Client]
"Enabled"=dword:00000001

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2\Client]
"DisabledByDefault"=dword:00000000

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2\Server]
"Enabled"=dword:00000001

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2\Server]
"DisabledByDefault"=dword:00000000

5) Server is up to date with windows updates. (actually... im not 100% on this one)

6) IISCrypto, says the protocols are there, and set as defaults correctly.

7) I can use Chrome to connect to APN, no problems, on my PC, and both the servers.

8) If i use Fiddler to test, it behaves exactly the same as my application, after i enable the TLS12 setting in the fiddler settings. I guess this is because Fiddler is build in .net 4.

Its as though even if you force .NET to use TLS1.2, it simply doesn't, and reverts back to 1.1. Does anyone have any more idea's here.

Thanks

Here is my test code:

public class SslTcpClient
    {
        private static Hashtable certificateErrors = new Hashtable();

        public static bool ValidateServerCertificate(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
        {
            if (sslPolicyErrors == SslPolicyErrors.None) return true;

            Console.WriteLine("Certificate error: {0}", sslPolicyErrors);
            return false;
        }
        public static X509Certificate SelectLocalCertificate(object sender, string targetHost, X509CertificateCollection localCertificates, X509Certificate remoteCertificate, string[] acceptableIssuers)
        {
            Console.WriteLine("Client is selecting a local certificate.");
            if (acceptableIssuers != null && acceptableIssuers.Length > 0 && localCertificates != null && localCertificates.Count > 0)
            {
                // Use the first certificate that is from an acceptable issuer.
                foreach (X509Certificate certificate in localCertificates)
                {
                    string issuer = certificate.Issuer;
                    if (Array.IndexOf(acceptableIssuers, issuer) != -1) return certificate;
                }
            }
            if (localCertificates != null && localCertificates.Count > 0)  return localCertificates[0];

            return null;
        }

        public static void RunClient(string server)
        {
            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

            TcpClient client = new TcpClient(server, 443);
            Console.WriteLine("Client connected.");
            SslStream sslStream = new SslStream(client.GetStream(), false, new RemoteCertificateValidationCallback(ValidateServerCertificate), null);
            Console.WriteLine("SSL stream obtained");

            try
            {
                X509Certificate localCertificate = new X509Certificate("VOIPPush.p12", "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");

                Console.WriteLine("Local Certificte features");
                Console.WriteLine("=========================");

                Console.WriteLine("Issuer: " + localCertificate.Issuer);
                Console.WriteLine("Subject: " + localCertificate.Subject);

                Console.WriteLine("CertHash: " + localCertificate.GetCertHashString());
                Console.WriteLine("EffectiveDate: " + localCertificate.GetEffectiveDateString());
                Console.WriteLine("ExpirationDate: " + localCertificate.GetExpirationDateString());
                Console.WriteLine("Format: " + localCertificate.GetFormat());
                Console.WriteLine("HashCode: " + localCertificate.GetHashCode().ToString());
                Console.WriteLine("KeyAlgorithm: " + localCertificate.GetKeyAlgorithm());
                Console.WriteLine("KeyAlgorithmParameters: " + localCertificate.GetKeyAlgorithmParametersString());
                Console.WriteLine("PublicKey: " + localCertificate.GetPublicKeyString());
                Console.WriteLine("SerialNumber: " + localCertificate.GetSerialNumberString());
                X509CertificateCollection localCertificates = new X509CertificateCollection();
                localCertificates.Add(localCertificate);

                sslStream.AuthenticateAsClient(server, localCertificates, SslProtocols.Tls12, true);
                Console.WriteLine("Authenticated as client");

                X509Certificate remoteCertificate = sslStream.RemoteCertificate;

                Console.WriteLine("Remote Certificte features");
                Console.WriteLine("==========================");

                Console.WriteLine("Issuer: " + remoteCertificate.Issuer);
                Console.WriteLine("Subject: " + remoteCertificate.Subject);

                Console.WriteLine("CertHash: " + remoteCertificate.GetCertHashString());
                Console.WriteLine("EffectiveDate: " + remoteCertificate.GetEffectiveDateString());
                Console.WriteLine("ExpirationDate: " + remoteCertificate.GetExpirationDateString());
                Console.WriteLine("Format: " + remoteCertificate.GetFormat());
                Console.WriteLine("HashCode: " + remoteCertificate.GetHashCode().ToString());
                Console.WriteLine("KeyAlgorithm: " + remoteCertificate.GetKeyAlgorithm());
                Console.WriteLine("KeyAlgorithmParameters: " + remoteCertificate.GetKeyAlgorithmParametersString());
                Console.WriteLine("PublicKey: " + remoteCertificate.GetPublicKeyString());
                Console.WriteLine("SerialNumber: " + remoteCertificate.GetSerialNumberString());

            }
            catch (AuthenticationException e)
            {
                Console.WriteLine("Exception: {0}", e.ToString());
                client.Close();
                return;
            }
            byte[] messsage = Encoding.UTF8.GetBytes(@"PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n");

            // no use in writing more, this is just a test...

            Console.WriteLine("Writing to sslStream...");
            sslStream.Write(messsage);
            Console.WriteLine("Writing done");
            sslStream.Flush();

            Console.WriteLine("Reading Response...");
            string serverMessage = ReadMessage(sslStream);
            Console.WriteLine("Server says: {0}", serverMessage);

            client.Close();
            Console.WriteLine("Client closed.");
        }
        static string ReadMessage(SslStream sslStream)
        {
            // Read the  message sent by the server.
            // The end of the message is signaled using the
            // "<EOF>" marker.
            byte[] buffer = new byte[2048];
            StringBuilder messageData = new StringBuilder();
            int bytes = -1;
            do
            {
                bytes = sslStream.Read(buffer, 0, buffer.Length);

                // Use Decoder class to convert from bytes to UTF8
                // in case a character spans two buffers.
                Decoder decoder = Encoding.UTF8.GetDecoder();
                char[] chars = new char[decoder.GetCharCount(buffer, 0, bytes)];
                decoder.GetChars(buffer, 0, bytes, chars, 0);
                messageData.Append(chars);
                // Check for EOF.
                if (messageData.ToString().IndexOf("<EOF>") != -1)
                {
                    break;
                }
            } while (bytes != 0);

            return messageData.ToString();
        }

        public static void Main(string[] args)
        {
            SslTcpClient.RunClient("api.push.apple.com");
            Console.ReadLine();
        }
    }


问:
c++ How could I properly predefined array of char*?
I am doing it that way:

```<code>int argc = 9;
char* argv[argc];

argv[0] = "c:/prog.exe";
</code>```

but I get notice, that it is deprecated. What is better way?

答:
Try using const to indicate that the strings won't be modified.

```<code>const char* argv[] = { "c:/prog.exe" };
const int argc = sizeof(argv) / sizeof(argv[0]);

int main()
{
    for(int i = 0; i < argc; ++i)
    {
        ::printf("%s\n", argv[i]);
    }
}
</code>```

Here, argc will also be calculated at compile time automatically so there's a lesser chance of error (thanks to Goz for the suggestion).

Body:
I am doing it that way:

int argc = 9;
char* argv[argc];

argv[0] = "c:/prog.exe";

but I get notice, that it is deprecated. What is better way?

Body:
Try using const to indicate that the strings won't be modified.

const char* argv[] = { "c:/prog.exe" };
const int argc = sizeof(argv) / sizeof(argv[0]);

int main()
{
    for(int i = 0; i < argc; ++i)
    {
        ::printf("%s\n", argv[i]);
    }
}

Here, argc will also be calculated at compile time automatically so there's a lesser chance of error (thanks to Goz for the suggestion).

ContentLicense: CC BY-SA 2.5


问:
ng-repeat and collapse table
I am trying to display information inside a table using a button to show and hide the data in each row using the row's id, but since I have 2 ng-repeat, the first loop is completed before the second and therefore all the data is displayed in the same row : here is my code :

```<code> <div class="table-responsive">
   <table class="table table-bordered table-hover table-striped">
    <thead>
     <tr>
     <th></th>
     <th>Projet</th>
     <th>Responsable Apitech</th>
     <th>Temps Passé</th>
     </tr>
    </thead>
    <tbody>
     <tr ng-repeat-start="p in projetsListe" >
       <td>
       <button class="btn btn-xs" ng-click="expanded = !expanded" expand data-toggle="collapse" id="{{p.IdProjet}}" data-target=".{{p.IdProjet}}">
       <span ng-bind="expanded ? '-' : '+'"></span>
       </button>
       </td>
       <td>{{p.NomProjet}}</td>
       <td>{{p.ResponsableApitech}}</td>
       <td>Temps Passé</td>
      </tr>
      <tr ng-repeat-end ng-show="expanded">
         <td></td>
         <td colspan="6">
         <table class="table table-condensed table-bordered">
            <thead>
             <th></th>
             <th>Tache</th>
             <th>Collaborateur</th>
             <th>Date</th>
             <th>Temps Passé</th>
            </thead>
            <tbody>
             <tr ng-repeat= "ft in ftListesorted" ng-show="expanded" class="collapse {{ft.IdProjet}}">
             <td><i class="glyphicon glyphicon-plus"></i></td>
             <td>{{ft.NomTache}}</td>
             <td>{{ft.NomCollaborateur}}</td>
             <td>{{ft.Datefeuillestemps |  date : 'dd/MM/yyyy' }}</td>
             <td>{{ft.TempsPasse}}</td>
             </tr>
           </tbody>
        </table>
        </td>
   </tr>
 </tbody>
</table>
</code>```

This is what im trying to achieve : http://embed.plnkr.co/qqNGSbw6oLUZbKqVQVpG/?show=preview

In my case :

This is what I get instead :

If you noticed in the second image get the information of the first and the second row while i want the information of each row seperatly.

Here is a plunker with an example of the problem : https://plnkr.co/edit/pPcPipLK0TltnOC60SSf

答:
create expanded property for each row. Change this lines

```<code> <button class="btn btn-xs" ng-click="p.expanded = !p.expanded" expand data-
  toggle="collapse" id="{{p.IdProjet}}" data-target=".{{p.IdProjet}}">
</code>```

and

```<code>  <tr ng-repeat-end ng-show="p.expanded">
</code>```

Title: ng-repeat and collapse table

Body:
I am trying to display information inside a table using a button to show and hide the data in each row using the row's id, but since I have 2 ng-repeat, the first loop is completed before the second and therefore all the data is displayed in the same row : here is my code :

     Projet
     Responsable Apitech
     Temps Passé

       <button class="btn btn-xs" ng-click="expanded = !expanded" expand data-toggle="collapse" id="{{p.IdProjet}}" data-target=".{{p.IdProjet}}">

       </button>

       {{p.NomProjet}}
       {{p.ResponsableApitech}}
       Temps Passé

             Tache
             Collaborateur
             Date
             Temps Passé

             {{ft.NomTache}}
             {{ft.NomCollaborateur}}
             {{ft.Datefeuillestemps |  date : 'dd/MM/yyyy' }}
             {{ft.TempsPasse}}

This is what im trying to achieve : http://embed.plnkr.co/qqNGSbw6oLUZbKqVQVpG/?show=preview

In my case :

This is what I get instead :

If you noticed in the second image get the information of the first and the second row while i want the information of each row seperatly.

Here is a plunker with an example of the problem : https://plnkr.co/edit/pPcPipLK0TltnOC60SSf

Body:
create expanded property for each row. Change this lines

 <button class="btn btn-xs" ng-click="p.expanded = !p.expanded" expand data-
  toggle="collapse" id="{{p.IdProjet}}" data-target=".{{p.IdProjet}}">

and

  <tr ng-repeat-end ng-show="p.expanded">


答:
Consider using ((IDictionary<String, object>)expando).Keys and passing them in to a new implementation of ToDataTable that uses those keys ('property names').

This is necessary, vs your current Reflection solution, to look up the property names (since as https://stackoverflow.com/a/32312740/34092 states, that won't work).

Convert dynamic list to datatable c# may be worth a read as well.

Title: Convert to List<dynamic> records gets null


问:
Get checked checkbox MVC5
I have searched some articles but none of them fits with my problem. i have this code in my cshtml

```<code>@model IEnumerable<MonitoreoIntegrado.Models.Sensores>
@using (Html.BeginForm("Graphics", "Datos_extensometro", FormMethod.Post, new { @class = "form-horizontal", role = "form" }))
{
    @Html.AntiForgeryToken()
    <div style="margin:0; padding:0; border:none; position:absolute; bottom:5px; right:25px;"><input type="submit" id="enviar" class="btn btn-primary" value="Consultar"></div>
    <div style="float:left; width:428px; height:105px; padding:5px; overflow-y: scroll;">
        <h4 style="margin-top:0px;">Consultar multiples sensores</h4>
            @foreach (var item in Model)
            {
                @Html.CheckBox("sensoresCB", false, new { value = @item.idSensor.ToString() }) @item.nombre <a class="moverse" objetivo="@(item.idSensor)" href=""><span class="glyphicon glyphicon-map-marker" title="Ir al marcador"></span></a><br />
            }
    </div>
}
</code>```

and this in my controller:

```<code>[HttpPost]
[ValidateAntiForgeryToken]
[Authorize(Roles = RolesSistema.Administrador + "," + RolesSistema.Lectura)]
public ActionResult Graphics()
{
    return View();
}
</code>```

I need help to receive that checkboxes in my controller and check which of them are checked

答:
You could extend the model of item with a Checked property or similar.

```<code>public class GraphicsViewModel {
   public GraphicsItemViewModel[] Items { get; set; }
}

public class GraphicsItemViewModel {
   public bool Checked { get; set; }
   public long IdSensor { get; set; }
}
</code>```

Then you can render the checkbox with a binding to this Checked property.

```<code>@model GraphicsViewModel
@using (Html.BeginForm(/* ....*/) {
    // use a for loop so the array is bound correctly
    @for (int i = 0; i < Model.Items.Length; i++) {
       @Html.CheckBoxFor(m => m.Items[i].Checked)
       // post back IdSensor value so we can access it in the controller
       @Html.HiddenFor(m => m.Items[i].IdSensor)
    }
}
</code>```

Your controller should accept a model for the POST data, you can reuse the ViewModel:

```<code>[HttpPost]
public ActionResult Graphics(GraphicsViewModel postData) {
  bool areAllChecked = postData.Items.All(i => i.Checked);
  bool isFirstChecked = postData.Items.First().Checked;
  bool isCertainIdChecked = postData.Items.Single(i => i.IdSensor == 1337).Checked;
  // ...
}
</code>```

Title: Get checked checkbox MVC5

Body:
I have searched some articles but none of them fits with my problem. i have this code in my cshtml

@model IEnumerable<MonitoreoIntegrado.Models.Sensores>
@using (Html.BeginForm("Graphics", "Datos_extensometro", FormMethod.Post, new { @class = "form-horizontal", role = "form" }))
{
    @Html.AntiForgeryToken()

<input type="submit" id="enviar" class="btn btn-primary" value="Consultar">

Consultar multiples sensores

            @foreach (var item in Model)
            {
                @Html.CheckBox("sensoresCB", false, new { value = @item.idSensor.ToString() }) @item.nombre

            }

}

and this in my controller:

[HttpPost]
[ValidateAntiForgeryToken]
[Authorize(Roles = RolesSistema.Administrador + "," + RolesSistema.Lectura)]
public ActionResult Graphics()
{
    return View();
}

I need help to receive that checkboxes in my controller and check which of them are checked

Body:
You could extend the model of item with a Checked property or similar.

public class GraphicsViewModel {
   public GraphicsItemViewModel[] Items { get; set; }
}

public class GraphicsItemViewModel {
   public bool Checked { get; set; }
   public long IdSensor { get; set; }
}

Then you can render the checkbox with a binding to this Checked property.

@model GraphicsViewModel
@using (Html.BeginForm(/* ....*/) {
    // use a for loop so the array is bound correctly
    @for (int i = 0; i < Model.Items.Length; i++) {
       @Html.CheckBoxFor(m => m.Items[i].Checked)
       // post back IdSensor value so we can access it in the controller
       @Html.HiddenFor(m => m.Items[i].IdSensor)
    }
}

Your controller should accept a model for the POST data, you can reuse the ViewModel:

[HttpPost]
public ActionResult Graphics(GraphicsViewModel postData) {
  bool areAllChecked = postData.Items.All(i => i.Checked);
  bool isFirstChecked = postData.Items.First().Checked;
  bool isCertainIdChecked = postData.Items.Single(i => i.IdSensor == 1337).Checked;
  // ...
}


问:
How to make an array with random numbers, with one condition repeated n number of times?
I have an array which I fill with random floating numbers from 0 to 1.

```<code>x = np.random.random((20,20))
</code>```

Later on, I will extract the items in the array (x[row][column]) which are larger than 0.2,with this:

```<code>loc = np.argwhere(x > 0.2)
</code>```

However,I cannot control the size of the loc. I have to have maximum 80 elements which are providing the condition of being larger than 0.2.

```<code>maxnum = 80
len(loc) == maxnum
</code>```

And the [row][column] combinations of the items which provide being larger than 0.2 should be different each time, as it should be a random array.
To be more specific, if I would make an array :

```<code>y = np.random.random((4,4))
</code>```

which yields:

```<code>array([[ 0.90282391,  0.11295454,  0.22650744,  0.31376307],
       [ 0.44553798,  0.19264588,  0.8944689 ,  0.77730786],
       [ 0.17462983,  0.79806749,  0.02074193,  0.3545992 ],
       [ 0.60130149,  0.5982725 ,  0.20522246,  0.99080217]])
</code>```

I need only random 3 of them to be larger than 0.2.
Therefore, the expected output should look like:

```<code>array([[ **0.90282391**,  0.11295454,  0.12650744,  0.11376307],
       [ 0.14553798,  0.19264588,  0.1944689 ,  0.17730786],
       [ 0.17462983,  0.19806749,  0.02074193,  **0.3545992** ],
       [ 0.10130149,  **0.5982725** ,  0.10522246,  0.19080217]])
</code>```

and the bold ones(larger than 0.2) their location should change in every run.

Do you know how to achieve that output?

答:
This would help

```<code>l=np.random.random((20,20))
loc= np.argwhere(l>.2) if len(np.argwhere(l>.2))<=80 else np.argwhere(l>.2)[:80]
</code>```

There if will data loss off course

Body:
I have an array which I fill with random floating numbers from 0 to 1.

x = np.random.random((20,20))

Later on, I will extract the items in the array (x[row][column]) which are larger than 0.2,with this:

loc = np.argwhere(x > 0.2)

However,I cannot control the size of the loc. I have to have maximum 80 elements which are providing the condition of being larger than 0.2.

maxnum = 80
len(loc) == maxnum

And the [row][column] combinations of the items which provide being larger than 0.2 should be different each time, as it should be a random array.
To be more specific, if I would make an array :

y = np.random.random((4,4))

which yields:

array([[ 0.90282391,  0.11295454,  0.22650744,  0.31376307],
       [ 0.44553798,  0.19264588,  0.8944689 ,  0.77730786],
       [ 0.17462983,  0.79806749,  0.02074193,  0.3545992 ],
       [ 0.60130149,  0.5982725 ,  0.20522246,  0.99080217]])

I need only random 3 of them to be larger than 0.2.
Therefore, the expected output should look like:

array([[ **0.90282391**,  0.11295454,  0.12650744,  0.11376307],
       [ 0.14553798,  0.19264588,  0.1944689 ,  0.17730786],
       [ 0.17462983,  0.19806749,  0.02074193,  **0.3545992** ],
       [ 0.10130149,  **0.5982725** ,  0.10522246,  0.19080217]])

and the bold ones(larger than 0.2) their location should change in every run.

Do you know how to achieve that output?

Body:
This would help

l=np.random.random((20,20))
loc= np.argwhere(l>.2) if len(np.argwhere(l>.2))<=80 else np.argwhere(l>.2)[:80]

There if will data loss off course


问:
How to Identify Tapped UIImage in UIImage array in Swift
I am populating UIImage array with code and adding them into UIScrollView successfully. I would like to identify the image tapped so I can run an action accordingly.

I appreciate your guidance and time.

Here is the code I have so far:

```<code>    override func viewDidLoad() {
        super.viewDidLoad()

        let tapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(self.imageTapped(_:)))
    }

    func loadImagePicker(){

    var contentWidth: CGFloat = 0.0
    let imageWidth: CGFloat = 100.0
    let imageHeight: CGFloat = 100.0

    for x in 0...2 {
        let image = UIImage(named: "item\(x).png")
        let imageView = UIImageView(image: image)
        imageView.isUserInteractionEnabled = true
        myData.images1.append(imageView)

        var newX: CGFloat = 0.0

        newX = 10 + imageWidth * CGFloat(x) + (10 * CGFloat(x))

        contentWidth += newX

        scrollView.addSubview(imageView)

        imageView.frame = CGRect(x: newX, y: scrollView.frame.size.height, width: imageWidth, height: imageHeight)
        imageView.contentMode = .scaleToFill
    }

    print(myData.images1.count)

    scrollView.clipsToBounds = false
    scrollView.contentSize = CGSize(width: contentWidth, height: scrollView.frame.size.height)

    imagePickerView.isHidden = false
}
</code>```

答:
Make your tapGestureRecognizer global or move it to your loadImagePicker function.

After setting isUserInteractionEnabled to true, add the gesture
recogniser to the imageView by calling
imageView.addGestureRecognizer(tapGestureRecognizer).

Then implement the imageTapped function which accepts a sender of type UITapGestureRecognizer

Finally in the imageTapped function, access the UIImageView that was tapped by calling sender as? UIImageView

Body:
I am populating UIImage array with code and adding them into UIScrollView successfully. I would like to identify the image tapped so I can run an action accordingly.

I appreciate your guidance and time.

Here is the code I have so far:

    override func viewDidLoad() {
        super.viewDidLoad()

        let tapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(self.imageTapped(_:)))
    }

    func loadImagePicker(){

    var contentWidth: CGFloat = 0.0
    let imageWidth: CGFloat = 100.0
    let imageHeight: CGFloat = 100.0

    for x in 0...2 {
        let image = UIImage(named: "item\(x).png")
        let imageView = UIImageView(image: image)
        imageView.isUserInteractionEnabled = true
        myData.images1.append(imageView)

        var newX: CGFloat = 0.0

        newX = 10 + imageWidth * CGFloat(x) + (10 * CGFloat(x))

        contentWidth += newX

        scrollView.addSubview(imageView)

        imageView.frame = CGRect(x: newX, y: scrollView.frame.size.height, width: imageWidth, height: imageHeight)
        imageView.contentMode = .scaleToFill
    }

    print(myData.images1.count)

    scrollView.clipsToBounds = false
    scrollView.contentSize = CGSize(width: contentWidth, height: scrollView.frame.size.height)

    imagePickerView.isHidden = false
}


问:
SQL Server Group By with Multiplication
I have this SQL Server 2005 Query

```<code>SELECT OI.BILL_NO,OI.ITEM_NAME,ODS.QUANTITY
FROM ORDER_ITEMS OI
INNER JOIN ORDER_ASSIGNMENTS OAS ON OI.BILL_NO=OAS.BILL_NO
INNER JOIN ORDERS ODS ON OI.BILL_NO = ODS.BILL_NO
INNER JOIN ORDERS OD ON OD.BILL_NO = OI.BILL_NO
WHERE OAS.ASSIGNMENT_TYPE= 'TO_STICHING' AND OAS.EMPLOYEE_NAME = 'AMIT'
</code>```

I am getting this result :

Now my requirement is to to get the total Quantity of Every Distinct ITEM_NAME, Example:

```<code>CHURIDER           5
CHURI PA           4
LACHA              1
ASTRA              1
ASTRA LACHA DOUBLE 1
</code>```

like this,all Distinct ITEM_NAME and their Total Quantity

答:
You need to use aggregate function SUM().

```<code>SELECT OI.BILL_NO,OI.ITEM_NAME, SUM(ODS.QUANTITY) AS Qty
</code>```

AS used to add column name when displaying result because when you use aggregation function column name for that shows as (no column name).

One last thing, you need to add other columns that you are selecting to GROUP BY clause because you are getting sum of each and every quantity so you need to group the other columns. read more and this.

Add after WHERE clause

```<code>GROUP BY OI.BILL_NO,OI.ITEM_NAME
</code>```

Title: SQL Server Group By with Multiplication

Body:
I have this SQL Server 2005 Query

SELECT OI.BILL_NO,OI.ITEM_NAME,ODS.QUANTITY
FROM ORDER_ITEMS OI
INNER JOIN ORDER_ASSIGNMENTS OAS ON OI.BILL_NO=OAS.BILL_NO
INNER JOIN ORDERS ODS ON OI.BILL_NO = ODS.BILL_NO
INNER JOIN ORDERS OD ON OD.BILL_NO = OI.BILL_NO
WHERE OAS.ASSIGNMENT_TYPE= 'TO_STICHING' AND OAS.EMPLOYEE_NAME = 'AMIT'

I am getting this result :

Now my requirement is to to get the total Quantity of Every Distinct ITEM_NAME, Example:

CHURIDER           5
CHURI PA           4
LACHA              1
ASTRA              1
ASTRA LACHA DOUBLE 1

like this,all Distinct ITEM_NAME and their Total Quantity

Body:
You need to use aggregate function SUM().

SELECT OI.BILL_NO,OI.ITEM_NAME, SUM(ODS.QUANTITY) AS Qty

AS used to add column name when displaying result because when you use aggregation function column name for that shows as (no column name).

One last thing, you need to add other columns that you are selecting to GROUP BY clause because you are getting sum of each and every quantity so you need to group the other columns. read more and this.

Add after WHERE clause

GROUP BY OI.BILL_NO,OI.ITEM_NAME


问:
RDLC report exporting to pdf with Page number in footer
I am rendering an rdlc report to the client directly, tried adding the page number using the code below in the footer

```<code>=Globals.PageNumber & " of " & Globals.TotalPages
</code>```

I am getting #Error when the report is rendered as pdf on the client. Need assitance to resolve the error.

答:
Late answer, but for me it was a security issue.

I checked the warnings received from render method.

```<code>Warning[] warnings; //<-- Check these errors

var reportData = localReport.Render("PDF", null, out mimeType, out encoding,
    out fileNameExtension, out streamIds, out warnings);
</code>```

Found the following error:

```<code>The Value expression for the textrun ‘PageNumber.Paragraphs[0].TextRuns[2]’ contains an error: Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
</code>```

Solution was to add the following line before rendering:

```<code>localReport.SetBasePermissionsForSandboxAppDomain(AppDomain.CurrentDomain.PermissionSet.Copy());
</code>```

Body:
I am rendering an rdlc report to the client directly, tried adding the page number using the code below in the footer

=Globals.PageNumber & " of " & Globals.TotalPages

I am getting #Error when the report is rendered as pdf on the client. Need assitance to resolve the error.

Body:
Late answer, but for me it was a security issue.

I checked the warnings received from render method.

Warning[] warnings; //<-- Check these errors

var reportData = localReport.Render("PDF", null, out mimeType, out encoding,
    out fileNameExtension, out streamIds, out warnings);

Found the following error:

The Value expression for the textrun ‘PageNumber.Paragraphs[0].TextRuns[2]’ contains an error: Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

Solution was to add the following line before rendering:

localReport.SetBasePermissionsForSandboxAppDomain(AppDomain.CurrentDomain.PermissionSet.Copy());


问:
Clean master branch but also detailed record of intermediary commits
Goal: keep a clean history of master, whilst also keeping the intermediary commits.

For instance, let's start with a master branch:

```<code>M1 --- M2 --- M3
              ^
              master
</code>```

I work on a feature/bug/whatever on a new branch:

```<code>M1 --- M2 --- M3
              ^  \
              |   \- F1 --- F2 -- F3
              |                   ^
              master              feature
</code>```

And when I merge into master, I want M3 to be the parent, but also keep the "iterations" you took to reach from M3 to the new commit. This can be done with merge --no-ff:

```<code>M1 --- M2 --- M3 ----------------------- M4
                 \                    /  ^
                  \- F1 --- F2 -- F3-/   master
                                  ^
                                 feature
</code>```

Which is almost what I had in mind. The problem I have is that for git, as far as I can tell, both M3 and F3 are "equal" parents of M4, now both part of branch master.

What I want is to be able the show (with git log) the master branch without the feature branch (F1-F3) to have a cleaner view over the branch. ideally this would be default. But also be able to show the F1 F3 commits to view the more "detailed" history when needed.

Is there a way to have this, or something close to this in git?

答:
How about

```<code>git log --first-parent master
</code>```

To quote the manual

Follow only the first parent commit upon seeing a merge commit. This option can give a better overview when viewing the evolution of a particular topic branch, because merges into a topic branch tend to be only about adjusting to updated upstream from time to time, and this option allows you to ignore the individual commits brought in to your history by such a merge.

Body:
Goal: keep a clean history of master, whilst also keeping the intermediary commits.

For instance, let's start with a master branch:

M1 --- M2 --- M3
              ^
              master

I work on a feature/bug/whatever on a new branch:

M1 --- M2 --- M3
              ^  \
              |   \- F1 --- F2 -- F3
              |                   ^
              master              feature

And when I merge into master, I want M3 to be the parent, but also keep the "iterations" you took to reach from M3 to the new commit. This can be done with merge --no-ff:

M1 --- M2 --- M3 ----------------------- M4
                 \                    /  ^
                  \- F1 --- F2 -- F3-/   master
                                  ^
                                 feature

Which is almost what I had in mind. The problem I have is that for git, as far as I can tell, both M3 and F3 are "equal" parents of M4, now both part of branch master.

What I want is to be able the show (with git log) the master branch without the feature branch (F1-F3) to have a cleaner view over the branch. ideally this would be default. But also be able to show the F1 F3 commits to view the more "detailed" history when needed.

Is there a way to have this, or something close to this in git?

Body:
How about

git log --first-parent master

To quote the manual

Follow only the first parent commit upon seeing a merge commit. This option can give a better overview when viewing the evolution of a particular topic branch, because merges into a topic branch tend to be only about adjusting to updated upstream from time to time, and this option allows you to ignore the individual commits brought in to your history by such a merge.


问:
Meaning of "*" and "/" in SPARQL
I want to know the meaning of * and / in SPARQL.

If you check this example from Wikidata, you will see that a / and a * are used in here:

```<code>?item wdt:P361* wd:Q362 .
?item wdt:P31/wdt:P279* wd:Q178561 .
</code>```

What are they for? Why are they used?

Thank you in advance!

答: They are Property Paths. The first one selects subjects connected to the object wd:Q362 by any number of wdt:P361 properties. The second selects subject connected by wdt:P31 followed by zero-or-more wdt:P279 properties. There are some examples in the SPARQL 1.1 Query Language recommendation.

Title: Meaning of "*" and "/" in SPARQL

Body:
I want to know the meaning of * and / in SPARQL.

If you check this <a href="https://query.wikidata.org/#%23added%20before%202016-10%0A%0A%23defaultView%3ABubbleChart%0ASELECT%20DISTINCT%20%3Fitem%20%3FitemLabel%20%28%3Fend%20-%20%3Fstart%20AS%20%3Fkk%29%0AWHERE%0A%7B%0A%09%3Fitem%20wdt%3AP361%2A%20wd%3AQ362%20.%0A%09%3Fitem%20wdt%3AP31%2Fwdt%3AP279%2A%20wd%3AQ178561%20.%0A%09%3Fitem%20wdt%3AP580%20%3Fstart%20.%0A%09%3Fitem%20wdt%3AP582%20%3Fend%20.%0A%0A%09SERVICE%20wikibase%3Alabel%20%7B%20bd%3AserviceParam%20wikibase%3Alanguage%20%22en%22%20%7D%0A%7D" rel="nofollow noreferrer">example from Wikidata, you will see that a / and a * are used in here:

?item wdt:P361* wd:Q362 .
?item wdt:P31/wdt:P279* wd:Q178561 .

What are they for? Why are they used?

Thank you in advance!


问:
VBS run Excel macro argument not optional
I'm trying to write a VBScript code that runs an Excel macro.

My VBA code:

```<code>Sub MyMacro(Name As String)

   'do something

End Sub
</code>```

My VBScript code:

```<code>Set objExcel = CreateObject("Excel.Application")

objExcel.Application.Run "'C:\MyFile.xlsm'!MyMacro", "MyName"

objExcel.Application.Quit

Set objExcel = Nothing
</code>```

The error I get:

Compile error: Argument not optional

How come I get this error if I do pass an argument?
What am I doing wrong?

Thanks!

答:
You need to specify the module in which the macro resides, e.g.

```<code>"'C:\MyFile.xlsm'.Module1.MyMacro"
</code>```

The following link doesn't explicitly say the macro must reside in a VBA module within Excel but I believe it must.

See the example code here

Body:
I'm trying to write a VBScript code that runs an Excel macro.

My VBA code:

Sub MyMacro(Name As String)

   'do something

End Sub

My VBScript code:

Set objExcel = CreateObject("Excel.Application")

objExcel.Application.Run "'C:\MyFile.xlsm'!MyMacro", "MyName"

objExcel.Application.Quit

Set objExcel = Nothing

The error I get:

Compile error: Argument not optional

How come I get this error if I do pass an argument?
What am I doing wrong?

Thanks!

Body:
You need to specify the module in which the macro resides, e.g.

"'C:\MyFile.xlsm'.Module1.MyMacro"

The following link doesn't explicitly say the macro must reside in a VBA module within Excel but I believe it must.

See the example code here


问:
How to query on multiple date using TABLE_QUERY() in Big Query
I want to query on these tables using table_query(). How can I query on all the tables with date range from 2017-03-22 to 2017-03-24.

Format of my BQ tables is (auctions_other_YYYYMMDDHHM)

BQ tables are listed below:

1.auctions_other_20170322104

  2.auctions_other_20170322105

  3.auctions_other_20170323206

  4.auctions_other_20170323207

  5.auctions_other_20170324108

  6.auctions_other_20170324209

I am using query:

```<code>SELECT  * FROM
TABLE_QUERY(chocolate_raw, "table_id contains 'auctions_others_' and
table_id contains '20170322104' and  table_id contains '20170324209'
")
WHERE
  id='f3667fd6-8329-4124-a4a2-737e637a5e7d'
</code>```

Getting Error:

FROM clause with table wildcards matches no table

答:
You should definitelly consider using BigQuery Standard SQL as Graham suggesting

If for some reason you still are bound to BigQuery Legacy SQL - try below

#legacySQL
SELECT *
FROM TABLE_QUERY(chocolate_raw,
  "table_id CONTAINS 'auctions_others_'
  AND SUBSTR(table_id, 1 + LENGTH('auctions_others_'), 8)
  BETWEEN '20170322' AND '20170324'")
WHERE id='f3667fd6-8329-4124-a4a2-737e637a5e7d'
```

<p>Similar version in BigQuery Standard SQL will looks like below    </p>

<pre class="lang-sql prettyprint-override"><code>#standardSQL
SELECT *
FROM `chocolate_raw.auctions_others_*`
WHERE SUBSTR(_TABLE_SUFFIX, 1, 8) BETWEEN '20170322' AND '20170324'
AND id='f3667fd6-8329-4124-a4a2-737e637a5e7d'
</code>```

Body:
I want to query on these tables using table_query(). How can I query on all the tables with date range from 2017-03-22 to 2017-03-24.

Format of my BQ tables is (auctions_other_YYYYMMDDHHM)

BQ tables are listed below:

1.auctions_other_20170322104

  2.auctions_other_20170322105

  3.auctions_other_20170323206

  4.auctions_other_20170323207

  5.auctions_other_20170324108

  6.auctions_other_20170324209

I am using query:

SELECT  * FROM
TABLE_QUERY(chocolate_raw, "table_id contains 'auctions_others_' and
table_id contains '20170322104' and  table_id contains '20170324209'
")
WHERE
  id='f3667fd6-8329-4124-a4a2-737e637a5e7d'

Getting Error:

FROM clause with table wildcards matches no table

Body:
You should definitelly consider using BigQuery Standard SQL as Graham suggesting

If for some reason you still are bound to BigQuery Legacy SQL - try below

#legacySQL
SELECT *
FROM TABLE_QUERY(chocolate_raw,
  "table_id CONTAINS 'auctions_others_'
  AND SUBSTR(table_id, 1 + LENGTH('auctions_others_'), 8)
  BETWEEN '20170322' AND '20170324'")
WHERE id='f3667fd6-8329-4124-a4a2-737e637a5e7d'

Similar version in BigQuery Standard SQL will looks like below

#standardSQL
SELECT *
FROM `chocolate_raw.auctions_others_*`
WHERE SUBSTR(_TABLE_SUFFIX, 1, 8) BETWEEN '20170322' AND '20170324'
AND id='f3667fd6-8329-4124-a4a2-737e637a5e7d'


问:
Change color if repeated record
What formula can I use to change the color of the font when the sames value already appears previously in the document?</p>

答:
Try first making a running total that keeps a Distinct Count of the field. Place this in your details section. Then write a whileprintingrecords formula to check whether or not your distinct count matches the Previous one. (Except for the first record, of course. You might need to make a special case for that.)

In theory, every time this second formula evaluates to false, a repeated record is added.

If that doesn't work, you could always declare an array that adds each new type of record to its ranks, and sets a shared boolean to false/true based on whether or not the current record already exists in the array.

Title: Change color if repeated record


问:
How to build periodically on Jenkins?
I want to know how to build periodically on Jenkins. For now, I have H 17 * * 1-5. My job builds at 17h every weekday, but I want it to build 3-4 times in the same night. For example : 1. 17h 2. 18h 3. 19h ... I'm not sure to understand the syntax of cron. Can someone help me ? Thx.

答:
I am not know why you want it but the following should work:</p>

```<code>H 17,18,19 * * 1-5
</code>```

Title: How to build periodically on Jenkins?

Body:
I am not know why you want it but the following should work:

H 17,18,19 * * 1-5


问:
Sublime Text plugin can’t find my default browser
TL;DR: Sublime Text gets a different response from webbrowser._browsers than my terminal.

This has been driving me nuts. I use a plugin, GitLink which will open a GitHub link from your current file. It relies on Python’s webbrowser tool to open the url. The problem is my default browser is Chrome, but it keeps opening Firefox.

In my terminal, if I launch into python or python3, webbrowser.open_new_tab('https://stackoverflow.com') will correctly launch in Chrome. webbrowser._browsers will correctly list 'chrome' as one of my browsers.

However, in the Sublime Text console, webbrowser._browsers is missing Chrome. It lists all the other browser save for the one I actually want. What gives? How is Sublime Text getting a different list than when I run python in my terminal? How do I get it to match?

答:
There are several things you could try.

1. Set the BROWSER environment variable:

As Keith Hall implied this problem might be solved by setting your BROWSER environment variable. If you don't know how look it up for your version - OSX changed how environment variables get set at some point so there are different ways of doing this for different versions of OSX. However, I am on Linux, and my BROWSER environment variable is not set and ST always opens urls in my default browser, this includes calls to webbrowser.open_new_tab() which (as I assume you saw) is what GitLink uses to open urls, so this may not solve the problem.

2. Modify GitLink (your installed version):

First test if this will work - works fine on Linux.

Copy and paste the following 2 lines into the ST console:

```<code>import webbrowser
webbrowser.get("chrome").open_new_tab("http://www.google.com")
</code>```

If that does not open Chrome with Google.com try:

```<code># google-chrome: Chrome variant.
webbrowser.get("google-chrome").open_new_tab("http://www.google.com")
# macosx: uses the OSX default browser.
webbrowser.get("macosx").open_new_tab("http://www.google.com")
# links: generic; doubtful but worth trying at this stage.
webbrowser.get("links").open_new_tab("http://www.google.com")
</code>```

The full list of possible values may be helpful.

Another possibility is to use the full path instead, see this StackOverflow answer or try:

```<code># Replace path with your path to Chrome if necessary.
webbrowser.register('chrome_path', None, webbrowser.BackgroundBrowser("/Applications/Google Chrome.app"))
webbrowser.get('chrome_path').open_new_tab(url)
</code>```

Once that is working:

Install the PackageResourceViewer plugin; after it is installed...

Open the Command Palette and select: PackageResourceViewer: Open Resource

In the list of packages select: GitLink

In the list of files select: GitLink.py

The file GitLink.py will open...

If you save this file (nothing will happen at all if you close it without saving) then a copy of GitLink.py will get saved on your system in this location: ST_CONFIG/Packages/GitLink/GitLink.py - this version of the file will override the version of GitLink.py which is stored in the Gitlink.sublime-package file which Package Control would have installed in the Installed Packages folder. Even if the GitLink package gets updated the version in the .sublime-package file will still get overridden. Not a problem, all you need to do to get rid of the changes made is to delete the folder ST_CONFIG/Packages/GitLink/ which contains the GitLink.py file and ST will start using the version from the .sublime-package file again.

The modification is easy:

Scroll down to the bottom of GitLink.py where you will see the lines:

```<code>if(args['web']):
    webbrowser.open_new_tab(url)
</code>```

Just change the webbrowser.open_new_tab(url) line to the following (replacing "chrome" if necessary with the value which worked in the console):

```<code>if(args['web']):
    webbrowser.get("chrome").open_new_tab(url)
</code>```

Save the file, the plugin should be updated immediately by ST (check the console for the "reloading plugin" message to be sure if you want). The plugin should now open your urls in Chrome.

3. Open an issue on GitLink's GitHub page:

The issue page is here. State your problem and request a setting be added so that users can specify which browser Python's webbrowser module should use.

I suggest you do this anyway and add a link to this StackOverflow page to your issue for reference.

Body:
There are several things you could try.

1. Set the BROWSER environment variable:

As Keith Hall implied this problem might be solved by setting your BROWSER environment variable. If you don't know how look it up for your version - OSX changed how environment variables get set at some point so there are different ways of doing this for different versions of OSX. However, I am on Linux, and my BROWSER environment variable is not set and ST always opens urls in my default browser, this includes calls to webbrowser.open_new_tab() which (as I assume you saw) is what GitLink uses to open urls, so this may not solve the problem.

2. Modify GitLink (your installed version):

First test if this will work - works fine on Linux.

Copy and paste the following 2 lines into the ST console:

import webbrowser
webbrowser.get("chrome").open_new_tab("http://www.google.com")

If that does not open Chrome with Google.com try:

# google-chrome: Chrome variant.
webbrowser.get("google-chrome").open_new_tab("http://www.google.com")
# macosx: uses the OSX default browser.
webbrowser.get("macosx").open_new_tab("http://www.google.com")
# links: generic; doubtful but worth trying at this stage.
webbrowser.get("links").open_new_tab("http://www.google.com")

The full list of possible values may be helpful.

Another possibility is to use the full path instead, see this StackOverflow answer or try:

# Replace path with your path to Chrome if necessary.
webbrowser.register('chrome_path', None, webbrowser.BackgroundBrowser("/Applications/Google Chrome.app"))
webbrowser.get('chrome_path').open_new_tab(url)

Once that is working:

Install the PackageResourceViewer plugin; after it is installed...

Open the Command Palette and select: PackageResourceViewer: Open Resource

In the list of packages select: GitLink

In the list of files select: GitLink.py

The file GitLink.py will open...

If you save this file (nothing will happen at all if you close it without saving) then a copy of GitLink.py will get saved on your system in this location: ST_CONFIG/Packages/GitLink/GitLink.py - this version of the file will override the version of GitLink.py which is stored in the Gitlink.sublime-package file which Package Control would have installed in the Installed Packages folder. Even if the GitLink package gets updated the version in the .sublime-package file will still get overridden. Not a problem, all you need to do to get rid of the changes made is to delete the folder ST_CONFIG/Packages/GitLink/ which contains the GitLink.py file and ST will start using the version from the .sublime-package file again.

The modification is easy:

Scroll down to the bottom of GitLink.py where you will see the lines:

if(args['web']):
    webbrowser.open_new_tab(url)

Just change the webbrowser.open_new_tab(url) line to the following (replacing "chrome" if necessary with the value which worked in the console):

if(args['web']):
    webbrowser.get("chrome").open_new_tab(url)

Save the file, the plugin should be updated immediately by ST (check the console for the "reloading plugin" message to be sure if you want). The plugin should now open your urls in Chrome.

3. Open an issue on GitLink's GitHub page:

The issue page is here. State your problem and request a setting be added so that users can specify which browser Python's webbrowser module should use.

I suggest you do this anyway and add a link to this StackOverflow page to your issue for reference.


问:
Plotting Real Time Data in Python
I wrote a script that generates random coordinates and writes them into a text file with no formatting.

Is there a way to format this list so it is easier to read? Like (x, y) per line? Right now it is a list with a single space between them.

Is there an easier way to generate random coordinates in one python file without the use of a text file? Or is it easier to use a text file?

Below is the working code for this and an example of the text file: (Revised based on commentary and working)

```<code>import random
import threading

def main():

    #Open a file named numbersmake.txt.
    outfile = open('new.txt', 'w')

    for count in range(12000):
        x = random.randint(0,10000)
        y = random.randint(0,10000)
        outfile.write("{},{}\n".format(x, y))

    #Close the file.
    outfile.close()
    print('The data is now the the new.txt file')

def coordinate():
    threading.Timer(0.0000000000001, coordinate).start ()

coordinate()

#Call the main function
main()
</code>```

I have tried split and does not work. I know I don't need the threading option. I would rather have the threading over the range but the range is okay for now...

Example of the text in text file:
  [4308][1461][1163][846][1532][318]... and so on

I wrote a python script that reads the text file of coordinates and places them on a graph, however, no points are being plotted. The graph itself does show. Below is the code: (Revised based on commentary)

```<code>import matplotlib.pyplot as plt
import matplotlib.animation as animation
from matplotlib import style
from numpy import loadtxt

style.use('dark_background')

fig = plt.figure()
ax1 = fig.add_subplot(1,1,1)

with open('new.txt') as graph_data:
    for line in graph_data:
        x, y = line.split(',')

def animate(i):
    xs = []
    ys = []
    for line in graph_data:
        if len(line)>1:
            x,y = line.split(',')
            xs.append(x)
            ys.append(y)

    ax1.clear()
    ax1.plot(xs,ys)

lines = loadtxt("C:\\Users\\591756\\new.txt", comments="#", delimiter=",", unpack="false")
ani = animation.FuncAnimation(fig, animate, interval=1000) # 1 second- 10000 milliseconds
plt.show()
</code>```

答:
In order for the logic of your plotting to even work, the file should be written like so

```<code>with open('new.txt', 'w') as out_file:
    for count in range(12000):
        x = random.randint(0,10000)
        y = random.randint(0,10000)
        outfile.write("{},{}\n".format(x, y))
</code>```

Also, you read lines like this

```<code>def animate(i):
    xs = []
    ys = []
    with open('filename') as graph_data:
        for line in graph_data:
            x, y = line.split(',')
            xs.append(x)
            ys.append(y)
    ax1.clear()
    ax1.plot(xs,ys)
</code>```

Title: Plotting Real Time Data in Python

Body:
I wrote a script that generates random coordinates and writes them into a text file with no formatting.

Is there a way to format this list so it is easier to read? Like (x, y) per line? Right now it is a list with a single space between them.

Is there an easier way to generate random coordinates in one python file without the use of a text file? Or is it easier to use a text file?

Below is the working code for this and an example of the text file: (Revised based on commentary and working)

import random
import threading

def main():

    #Open a file named numbersmake.txt.
    outfile = open('new.txt', 'w')

    for count in range(12000):
        x = random.randint(0,10000)
        y = random.randint(0,10000)
        outfile.write("{},{}\n".format(x, y))

    #Close the file.
    outfile.close()
    print('The data is now the the new.txt file')

def coordinate():
    threading.Timer(0.0000000000001, coordinate).start ()

coordinate()

#Call the main function
main()

I have tried split and does not work. I know I don't need the threading option. I would rather have the threading over the range but the range is okay for now...

Example of the text in text file:
  [4308][1461][1163][846][1532][318]... and so on

I wrote a python script that reads the text file of coordinates and places them on a graph, however, no points are being plotted. The graph itself does show. Below is the code: (Revised based on commentary)

import matplotlib.pyplot as plt
import matplotlib.animation as animation
from matplotlib import style
from numpy import loadtxt

style.use('dark_background')

fig = plt.figure()
ax1 = fig.add_subplot(1,1,1)

with open('new.txt') as graph_data:
    for line in graph_data:
        x, y = line.split(',')

def animate(i):
    xs = []
    ys = []
    for line in graph_data:
        if len(line)>1:
            x,y = line.split(',')
            xs.append(x)
            ys.append(y)

    ax1.clear()
    ax1.plot(xs,ys)

lines = loadtxt("C:\\Users\\591756\\new.txt", comments="#", delimiter=",", unpack="false")
ani = animation.FuncAnimation(fig, animate, interval=1000) # 1 second- 10000 milliseconds
plt.show()

Body:
In order for the logic of your plotting to even work, the file should be written like so

with open('new.txt', 'w') as out_file:
    for count in range(12000):
        x = random.randint(0,10000)
        y = random.randint(0,10000)
        outfile.write("{},{}\n".format(x, y))

Also, you read lines like this

def animate(i):
    xs = []
    ys = []
    with open('filename') as graph_data:
        for line in graph_data:
            x, y = line.split(',')
            xs.append(x)
            ys.append(y)
    ax1.clear()
    ax1.plot(xs,ys)


问:
Which hosting provider supports Haskell?
I have a hosting account with GoDaddy, but it does not support Haskell.</p>

答: GHC compiles Haskell code to a UNIX executable, so anything that can run an arbitrary executable file and has some kind of front-facing server (e.g. nginx with mod_proxy) capable of proxying to your Haskell process is all you need.</p>


问:
'PostgreSQL' component is not operational in Work Fusion RPA Express
I have installed Work Fusion RPA express. No issues during installation.
Recorded series of action, But cannot play any recording in RPA Recorder.

Then:
I checked the Platform Monitor and found 'PostgreSQL' component is not operational.
How can I resolve this?

答:
Check that your port 15423 is open

Check Firewall inbound rules (Firewall → Advanced settings). It should be enabled for RPAExpress Postgres

If this does not help, create a post on https://forum.workfusion.com


问:
when parent addclass css animation works but when remove they still do nothing?

$(document).on("scroll",function(){
  if( window.pageYOffset > 0 ) {
    $("body").addClass("scroll");
  }else{
    $("body").removeClass("scroll");
  }
})```
<pre class="snippet-code-css lang-css prettyprint-override"><code>@keyframes fade {
  0%,100% { opacity: 1 }
  30%,70% { opacity: 0 }
}

.logo{
  animation: fade 0.7s linear;
}

div{
  height: 1000px;
}
span{
  position: fixed;
  padding: 20px;
}
body.scroll span{
  animation: fade 0.7s linear;
}

@keyframes fade {
  0%,100% { opacity: 1 }
  30%,70% { opacity: 0 }
}</code>```

testhier
```

see that "hier" fade out and in again, but if you scroll to top they stand still. I want if scroll already to top the animation again. ever if body becomes the class scroll and if they remove.

how can i do this only in css?

codepen

答:
Edit: i think i misunderstood your question, sorry about that! So you want the span to fade while scrolling down AND up? but only once?

the problem lies in your fade animation keyframe, try:

```<code> @keyframes fade {
   0% { opacity: 1 }
   100%{ opacity: 0 }
  }
</code>```

I also added the scroll class to the span (you shouldn't add it to the body tag) , and added a small transition to the span, so that the reappearing doesn't seem so abrupt. and if you see in the commented part, i added a "forwards" so that your animation stops at the last "image".

```<code>span{
  position: fixed;
  padding: 20px;
  transition: opacity .4s linear;
}
span.scroll{
  animation: fade 0.7s linear forwards;  // <---- HERE
}
</code>```

Body:
$(document).on("scroll",function(){
  if( window.pageYOffset > 0 ) {
    $("body").addClass("scroll");
  }else{
    $("body").removeClass("scroll");
  }
})

@keyframes fade {
  0%,100% { opacity: 1 }
  30%,70% { opacity: 0 }
}

.logo{
  animation: fade 0.7s linear;
}

div{
  height: 1000px;
}
span{
  position: fixed;
  padding: 20px;
}
body.scroll span{
  animation: fade 0.7s linear;
}

@keyframes fade {
  0%,100% { opacity: 1 }
  30%,70% { opacity: 0 }
}

testhier

see that "hier" fade out and in again, but if you scroll to top they stand still. I want if scroll already to top the animation again. ever if body becomes the class scroll and if they remove.

how can i do this only in css?

codepen

Body:
Edit: i think i misunderstood your question, sorry about that! So you want the span to fade while scrolling down AND up? but only once?

the problem lies in your fade animation keyframe, try:

 @keyframes fade {
   0% { opacity: 1 }
   100%{ opacity: 0 }
  }

I also added the scroll class to the span (you shouldn't add it to the body tag) , and added a small transition to the span, so that the reappearing doesn't seem so abrupt. and if you see in the commented part, i added a "forwards" so that your animation stops at the last "image".

span{
  position: fixed;
  padding: 20px;
  transition: opacity .4s linear;
}
span.scroll{
  animation: fade 0.7s linear forwards;  // <---- HERE
}


问:
How does one remove a file from a FlashAir card using the API?
On the basis of the documentation for command.cgi and upload.cgi, I have a simple sync application that first retrieves a list of files and then tries to delete them from the device.

However, the delete operation always fails with a 404 error.

The request being issued is like

```<code>GET /upload.cgi?DEL=/DCIM/109___06/IMG_0611.JPG HTTP/1.1
Host: 192.168.0.1
User-Agent: ...
</code>```

The file given as argument to DEL certainly exists on the device since the value is taken directly from a file list response immediately prior.

The full response from the FlashAir API is:

```<code><!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<HTML><HEAD><TITLE>404 Not Found</TITLE></HEAD>
<BODY><H1>404 Not Found</H1>
The requested URL was not found on this server.
</BODY></HTML>
</code>```

答: Does http://192.168.0.1/upload.cgi certainly exist? Since 404 Not Found is displayed, there is a possibility that you can not access the API URL in the first place.

Body:
On the basis of the documentation for command.cgi and upload.cgi, I have a simple sync application that first retrieves a list of files and then tries to delete them from the device.

However, the delete operation always fails with a 404 error.

The request being issued is like

GET /upload.cgi?DEL=/DCIM/109___06/IMG_0611.JPG HTTP/1.1
Host: 192.168.0.1
User-Agent: ...

The file given as argument to DEL certainly exists on the device since the value is taken directly from a file list response immediately prior.

The full response from the FlashAir API is:

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<TITLE>404 Not Found</TITLE>

404 Not Found

The requested URL was not found on this server.


问:
Alert Dialog crashes Android test - "Can't create handler inside thread that has not called Looper.prepare()"
```<code>    AlertDialog.Builder builder = new AlertDialog.Builder(activity);
    builder.setMessage(message)
            .setCancelable(false)
            .setPositiveButton("Yes", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    login(activity);
                }
            })
            .setNegativeButton("No", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {

                    dialog.cancel();
                    activity.finish();
                }
            });
    AlertDialog alert = builder.create(); // Crash
    alert.show();
</code>```

The app runs fine and shows the alert dialog when I run it normally, but when I run it in an instrumented test, it crashes in builder.create at the first line:

```<code>        final AlertDialog dialog = new AlertDialog(P.mContext, mTheme);
</code>```

with this exception:

```<code>java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
</code>```

This closes the app and then the test fails because there isn't any activity:

```<code>android.support.test.espresso.NoActivityResumedException: No activities in stage RESUMED. Did you forget to launch the activity. (test.getActivity() or similar)?
</code>```

This is a thread problem, but that's not what I expected based on an answer here:

To verify if dialog appears you can simply check if View with a text that present inside the dialog is shown:

onView(withText("dialogText")).check(matches(isDisplayed()));

I don't understand how I'm supposed to check if the text is displayed if the app crashes before the dialog is created.

EDIT:

```<code>    mActivityRule.launchActivity(intent);

    mActivityRule.getActivity().showOptionDialog();

    onView(withText(mActivityRule.getActivity().getString(R.string.dialogText))).check(matches(isDisplayed()));
</code>```

答:
A couple things that will likely help you...

Calling mActivityRule.getActivity().showOptionDialog(); in an Espresso test is not the 'Espresso' way.  Unless your test is properly annotated, it's not running on the UI Thread, so this is a case where you are calling something that should be done on the UI Thread from the Instrumentation Thread.  You can get around this by doing something like:

rule.runOnUiThread(new Runnable() {
    @Override
    public void run() {
        mActivityRule.getActivity().showOptionDialog();
    }
});

Doing this may require you to build out your own synchronization logic to make sure that future Espresso statements are not run before this occurs.

The better way to test this using Espresso is to use an onView(XXX).perform(click()) on the UI control that would normally invoke showOptionsDialog().

Additionally, you don't need to resolve the string that you pass to withText() yourself, you can just use the string resource id, but this isn't the cause of the issue that you are seeing.

Body:
    AlertDialog.Builder builder = new AlertDialog.Builder(activity);
    builder.setMessage(message)
            .setCancelable(false)
            .setPositiveButton("Yes", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    login(activity);
                }
            })
            .setNegativeButton("No", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {

                    dialog.cancel();
                    activity.finish();
                }
            });
    AlertDialog alert = builder.create(); // Crash
    alert.show();

The app runs fine and shows the alert dialog when I run it normally, but when I run it in an instrumented test, it crashes in builder.create at the first line:

        final AlertDialog dialog = new AlertDialog(P.mContext, mTheme);

with this exception:

java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()

This closes the app and then the test fails because there isn't any activity:

android.support.test.espresso.NoActivityResumedException: No activities in stage RESUMED. Did you forget to launch the activity. (test.getActivity() or similar)?

This is a thread problem, but that's not what I expected based on an answer here:

To verify if dialog appears you can simply check if View with a text that present inside the dialog is shown:

onView(withText("dialogText")).check(matches(isDisplayed()));

I don't understand how I'm supposed to check if the text is displayed if the app crashes before the dialog is created.

EDIT:

    mActivityRule.launchActivity(intent);

    mActivityRule.getActivity().showOptionDialog();

    onView(withText(mActivityRule.getActivity().getString(R.string.dialogText))).check(matches(isDisplayed()));


问:
get the most two recent dates for each customer
basically, I need to retrieve the last two dates for customers who purchased in at least two different dates, implying there are some customer who had purchased only in one date, the data has the following form

```<code>client_id  date
1          2016-07-02
1          2016-07-02
1          2016-06-01
2          2015-06-01
</code>```

and I would like to get it in the following form

```<code>client_id      previous_date     last_date
1              2016-06-01        2016-07-02
</code>```

remarques:

a client can have multiple entries for the same date

a client can have entries only for one date, such customer should be discarded

答:
Rank your dates with DENSE_RANK. Then group by client_id and show the last dates (ranked #1 and #2).

```<code>select
  client_id,
  max(case when rn = 2 then date end) as previous_date,
  max(case when rn = 1 then date end) as last_date
from
(
  select
    client_id,
    date,
    dense_rank() over (partition by client_id order by date desc) as rn
  from mytable
)
group by client_id
having max(rn) > 1;
</code>```

Body:
basically, I need to retrieve the last two dates for customers who purchased in at least two different dates, implying there are some customer who had purchased only in one date, the data has the following form

client_id  date
1          2016-07-02
1          2016-07-02
1          2016-06-01
2          2015-06-01

and I would like to get it in the following form

client_id      previous_date     last_date
1              2016-06-01        2016-07-02

remarques:

a client can have multiple entries for the same date

a client can have entries only for one date, such customer should be discarded

Body:
Rank your dates with DENSE_RANK. Then group by client_id and show the last dates (ranked #1 and #2).

select
  client_id,
  max(case when rn = 2 then date end) as previous_date,
  max(case when rn = 1 then date end) as last_date
from
(
  select
    client_id,
    date,
    dense_rank() over (partition by client_id order by date desc) as rn
  from mytable
)
group by client_id
having max(rn) > 1;


问:
what's the max size of a url word in a URL?
i was wondering, in order to get a good SEO you have to use natural language in your URLs.
Do you know the max size for a word or phrase in characters?
ex:

```<code>www.me.com/this-is-a-really-long-url.htm
</code>```

i ask this, because once i've checked out that google was banning some of my URLs because they were too long.
thanks a lot :D

答:
Could you link to that information because I guess the SEO limit is more on the total length than the individual parts.

When generating friendly URLs, try to keep below 15 chars for sections, 40 chars for article and a couple more for id.

Also, try to use subdomains if available, you can link them in your Google panel anyway

That is:
http://forums.en.mycompany.com/general/annoucements/5142-today-is-a-big-day.html

Body:
i was wondering, in order to get a good SEO you have to use natural language in your URLs.
Do you know the max size for a word or phrase in characters?
ex:

www.me.com/this-is-a-really-long-url.htm

i ask this, because once i've checked out that google was banning some of my URLs because they were too long.
thanks a lot :D


问:
windows form keyup event is not working c#
This code is not working in my main form</p>

```<code>void main_KeyUp(object sender, System.Windows.Forms.KeyEventArgs e)
    {
        if (e.KeyCode == Keys.Enter)
        {
            MessageBox.Show("Enter key pressed");

             e.SuppressKeyPress = true;
        }
    }
</code>```

答: Try to set Form property: main.KeyPreview = true;

Body:
This code is not working in my main form

void main_KeyUp(object sender, System.Windows.Forms.KeyEventArgs e)
    {
        if (e.KeyCode == Keys.Enter)
        {
            MessageBox.Show("Enter key pressed");

             e.SuppressKeyPress = true;
        }
    }


问:
Rxjs: shorthand of create observable from value or observable
I'm using rxjs with typescript. I wrote following two simple functions. But I guess rxjs already has such functionality. Does rxjs?

```<code>export function isObservable(value: any): value is Observable<any> {
  return value instanceof Observable;
}

export function createObservable<T>(value: T | Observable<T>): Observable < T > {
  return isObservable(value) ? value : Observable.of(value);
}
</code>```

答: No it doesn't, probably because it's not very useful. Which use cases would you need it for?</p>

Body:
I'm using rxjs with typescript. I wrote following two simple functions. But I guess rxjs already has such functionality. Does rxjs?

export function isObservable(value: any): value is Observable<any> {
  return value instanceof Observable;
}

export function createObservable<T>(value: T | Observable<T>): Observable < T > {
  return isObservable(value) ? value : Observable.of(value);
}


问:
Need a better understanding of these operations with const pointers in C
As a follow up to this question: How do you specify variables to be final in C?, I've been playing around with const variables. In particular, I've written and compiled the following program:

```<code>#include<stdio.h>

int main(void) {
    const int i = 5;
    int* i_ptr = &i;

    *i_ptr = *i_ptr + 1;      // (1)

    printf("%d %d\n", *i_ptr, i);

    int j = 10;
    const int* j_ptr = &j;

    j_ptr = i_ptr;       // (2)

    printf("%d %d\n", *j_ptr, j);

    return 0;
}
</code>```

I'm working with the following gcc compiler:

```<code>$ gcc --version
Apple LLVM version 8.1.0 (clang-802.0.42)
Target: x86_64-apple-darwin16.5.0
Thread model: posix
</code>```

In the code listing, I've marked two lines of code that behave differently than I'd expect:

(1)  I would expect the compiler to spit at me for trying to modify the const variable i that i_ptr but to my surprise it does not.

(2)  I would expect another error to be generated here because j_ptr has just been declared const and now modifying it is perfectly okay.

Further more, here is the output I get:

```<code>6 5
6 10
</code>```

What's surprising here is that, in the first line out output, i_ptr and i do not have the same values here. What gives? I certainly didn't call malloc and assign i_ptr to new memory.

So how is it pointing to something besides i?

What's even more puzzling is that, if I replace line (2) with this:

```<code>*j_ptr = *j_ptr + 1;
</code>```

I get

error: read-only variable is not assignable

I'd expect that, since j_ptr is pointing to non-const variable j, it should increment j. But that doesn't happen.

I'd really appreciate if someone could explain my observations, as I can't seem to come up with any reasons for why these const pointers should behave this counter-intuitively.

答:
Also note the place you put const to.

If you do:

```<code>int i = 0;
const int * ptr_to_const_value = &i;
int * const const_ptr = &i;
ptr_to_const_value = &j // this is ok
const_ptr = &j; // this does not compile
</code>```

To ptr_to_const_value you can assign pointer at any time, but you cannot modify value this pointer points to.

On the other hand, const_ptr cannot be reassigned, but you can modify the value it points to.

ContentLicense: CC BY-SA 4.0

Body:
As a follow up to this question: How do you specify variables to be final in C?, I've been playing around with const variables. In particular, I've written and compiled the following program:

#include<stdio.h>

int main(void) {
    const int i = 5;
    int* i_ptr = &i;

    *i_ptr = *i_ptr + 1;      // (1)

    printf("%d %d\n", *i_ptr, i);

    int j = 10;
    const int* j_ptr = &j;

    j_ptr = i_ptr;       // (2)

    printf("%d %d\n", *j_ptr, j);

    return 0;
}

I'm working with the following gcc compiler:

$ gcc --version
Apple LLVM version 8.1.0 (clang-802.0.42)
Target: x86_64-apple-darwin16.5.0
Thread model: posix

In the code listing, I've marked two lines of code that behave differently than I'd expect:

(1)  I would expect the compiler to spit at me for trying to modify the const variable i that i_ptr but to my surprise it does not.

(2)  I would expect another error to be generated here because j_ptr has just been declared const and now modifying it is perfectly okay.

Further more, here is the output I get:

6 5
6 10

What's surprising here is that, in the first line out output, i_ptr and i do not have the same values here. What gives? I certainly didn't call malloc and assign i_ptr to new memory.

So how is it pointing to something besides i?

What's even more puzzling is that, if I replace line (2) with this:

*j_ptr = *j_ptr + 1;

I get

error: read-only variable is not assignable

I'd expect that, since j_ptr is pointing to non-const variable j, it should increment j. But that doesn't happen.

I'd really appreciate if someone could explain my observations, as I can't seem to come up with any reasons for why these const pointers should behave this counter-intuitively.

Body:
Also note the place you put const to.

If you do:

int i = 0;
const int * ptr_to_const_value = &i;
int * const const_ptr = &i;
ptr_to_const_value = &j // this is ok
const_ptr = &j; // this does not compile

To ptr_to_const_value you can assign pointer at any time, but you cannot modify value this pointer points to.

On the other hand, const_ptr cannot be reassigned, but you can modify the value it points to.