问:
Gremlin query on Cosmos DB: Unable to cast object of type StringField to Compose1Field
We have the issue with Gremlin query on Azure Cosmos DB
The query works in Gremlin Console on TinkerPop but Cosmos DB is complaining about it.

It seems to be an issue with the last group().by(...) step

Not sure if this is a bug or there is some workaround specific for Cosmos

The error is as follows:

Error

```<code>ExceptionType : InvalidCastException ExceptionMessage : Unable to cast object of type 'Microsoft.Azure.Cosmos.Gremlin.Core.Runtime.StringField' to type 'Microsoft.Azure.Cosmos.Gremlin.Core.Runtime.Compose1Field'. Source : Microsoft.Azure.Cosmos.Gremlin.Core HResult : 0x80004002
</code>```

The query is as follows:

```<code>g.V().hasLabel('user').as('u').
           out('userGeneratedEvent').
           outE('eventRelatedTo').as('w').inV().
           out('itemVersionOf').as('i').
           select('u','i','w').
             by('userId').
             by('itemId').
             by('weight').
           unfold().
           group().
             by(keys).
             by(select(values).fold()).
           unfold()
</code>```

It should produce the following result:

```<code>==>u=[1, 2, 2, 2, 2, 3, 3]
==>w=[5, 4, 1, 2, 3, 4, 1]
==>i=[1, 1, 2, 1, 3, 1, 2]
</code>```

The  graph example is as follows:

```<code>g.addV('user').property('userId', 1)
g.addV('user').property('userId', 2)
g.addV('user').property('userId', 3)
g.addV('event').property('eventId', 1)
g.addV('event').property('eventId', 2)
g.addV('event').property('eventId', 3)
g.addV('event').property('eventId', 4)
g.addV('event').property('eventId', 5)
g.addV('itemVersion').property('itemVersionId', 1)
g.addV('itemVersion').property('itemVersionId', 2)
g.addV('itemVersion').property('itemVersionId', 3)
g.addV('itemVersion').property('itemVersionId', 4)
g.addV('itemVersion').property('itemVersionId', 5)
g.addV('itemVersion').property('itemVersionId', 6)
g.addV('itemVersion').property('itemVersionId', 7)
g.addV('item').property('itemId', 1)
g.addV('item').property('itemId', 2)
g.addV('item').property('itemId', 3)
g.addV('item').property('itemId', 4)
g.V().hasLabel('user').has('userId',1).addE('userGeneratedEvent').to(g.V().hasLabel('event').has('eventId',1))
g.V().hasLabel('user').has('userId',2).addE('userGeneratedEvent').to(g.V().hasLabel('event').has('eventId',2))
g.V().hasLabel('user').has('userId',2).addE('userGeneratedEvent').to(g.V().hasLabel('event').has('eventId',3))
g.V().hasLabel('user').has('userId',3).addE('userGeneratedEvent').to(g.V().hasLabel('event').has('eventId',4))
g.V().hasLabel('user').has('userId',3).addE('userGeneratedEvent').to(g.V().hasLabel('event').has('eventId',5))
g.V().hasLabel('event').has('eventId',1).addE('eventRelatedTo').to(g.V().hasLabel('itemVersion').has('itemVersionId',1)).property('weight', 5)
g.V().hasLabel('event').has('eventId',2).addE('eventRelatedTo').to(g.V().hasLabel('itemVersion').has('itemVersionId',1)).property('weight', 4)
g.V().hasLabel('event').has('eventId',2).addE('eventRelatedTo').to(g.V().hasLabel('itemVersion').has('itemVersionId',2)).property('weight', 1)
g.V().hasLabel('event').has('eventId',3).addE('eventRelatedTo').to(g.V().hasLabel('itemVersion').has('itemVersionId',1)).property('weight', 2)
g.V().hasLabel('event').has('eventId',3).addE('eventRelatedTo').to(g.V().hasLabel('itemVersion').has('itemVersionId',3)).property('weight', 3)
g.V().hasLabel('event').has('eventId',4).addE('eventRelatedTo').to(g.V().hasLabel('itemVersion').has('itemVersionId',4)).property('weight', 4)
g.V().hasLabel('event').has('eventId',5).addE('eventRelatedTo').to(g.V().hasLabel('itemVersion').has('itemVersionId',5)).property('weight', 1)
g.V().hasLabel('itemVersion').has('itemVersionId',1).addE('itemVersionOf').to(g.V().hasLabel('item').has('itemId',1))
g.V().hasLabel('itemVersion').has('itemVersionId',2).addE('itemVersionOf').to(g.V().hasLabel('item').has('itemId',2))
g.V().hasLabel('itemVersion').has('itemVersionId',3).addE('itemVersionOf').to(g.V().hasLabel('item').has('itemId',3))
g.V().hasLabel('itemVersion').has('itemVersionId',4).addE('itemVersionOf').to(g.V().hasLabel('item').has('itemId',1))
g.V().hasLabel('itemVersion').has('itemVersionId',5).addE('itemVersionOf').to(g.V().hasLabel('item').has('itemId',2))
g.V().hasLabel('itemVersion').has('itemVersionId',6).addE('itemVersionOf').to(g.V().hasLabel('item').has('itemId',3))
g.V().hasLabel('itemVersion').has('itemVersionId',7).addE('itemVersionOf').to(g.V().hasLabel('item').has('itemId',4))
</code>```

答:
Thanks for your feedback. Currently, the Data Explorer does not support all functionality as does the Gremlin Console on Tinkerpop, which supports all Groovy language expressions.

You can refer the MSDN Thread for more details.

Hope it helps.

Body:
We have the issue with Gremlin query on Azure Cosmos DB
The query works in Gremlin Console on TinkerPop but Cosmos DB is complaining about it.

It seems to be an issue with the last group().by(...) step

Not sure if this is a bug or there is some workaround specific for Cosmos

The error is as follows:

Error

ExceptionType : InvalidCastException ExceptionMessage : Unable to cast object of type 'Microsoft.Azure.Cosmos.Gremlin.Core.Runtime.StringField' to type 'Microsoft.Azure.Cosmos.Gremlin.Core.Runtime.Compose1Field'. Source : Microsoft.Azure.Cosmos.Gremlin.Core HResult : 0x80004002

The query is as follows:

g.V().hasLabel('user').as('u').
           out('userGeneratedEvent').
           outE('eventRelatedTo').as('w').inV().
           out('itemVersionOf').as('i').
           select('u','i','w').
             by('userId').
             by('itemId').
             by('weight').
           unfold().
           group().
             by(keys).
             by(select(values).fold()).
           unfold()

It should produce the following result:

==>u=[1, 2, 2, 2, 2, 3, 3]
==>w=[5, 4, 1, 2, 3, 4, 1]
==>i=[1, 1, 2, 1, 3, 1, 2]

The  graph example is as follows:

g.addV('user').property('userId', 1)
g.addV('user').property('userId', 2)
g.addV('user').property('userId', 3)
g.addV('event').property('eventId', 1)
g.addV('event').property('eventId', 2)
g.addV('event').property('eventId', 3)
g.addV('event').property('eventId', 4)
g.addV('event').property('eventId', 5)
g.addV('itemVersion').property('itemVersionId', 1)
g.addV('itemVersion').property('itemVersionId', 2)
g.addV('itemVersion').property('itemVersionId', 3)
g.addV('itemVersion').property('itemVersionId', 4)
g.addV('itemVersion').property('itemVersionId', 5)
g.addV('itemVersion').property('itemVersionId', 6)
g.addV('itemVersion').property('itemVersionId', 7)
g.addV('item').property('itemId', 1)
g.addV('item').property('itemId', 2)
g.addV('item').property('itemId', 3)
g.addV('item').property('itemId', 4)
g.V().hasLabel('user').has('userId',1).addE('userGeneratedEvent').to(g.V().hasLabel('event').has('eventId',1))
g.V().hasLabel('user').has('userId',2).addE('userGeneratedEvent').to(g.V().hasLabel('event').has('eventId',2))
g.V().hasLabel('user').has('userId',2).addE('userGeneratedEvent').to(g.V().hasLabel('event').has('eventId',3))
g.V().hasLabel('user').has('userId',3).addE('userGeneratedEvent').to(g.V().hasLabel('event').has('eventId',4))
g.V().hasLabel('user').has('userId',3).addE('userGeneratedEvent').to(g.V().hasLabel('event').has('eventId',5))
g.V().hasLabel('event').has('eventId',1).addE('eventRelatedTo').to(g.V().hasLabel('itemVersion').has('itemVersionId',1)).property('weight', 5)
g.V().hasLabel('event').has('eventId',2).addE('eventRelatedTo').to(g.V().hasLabel('itemVersion').has('itemVersionId',1)).property('weight', 4)
g.V().hasLabel('event').has('eventId',2).addE('eventRelatedTo').to(g.V().hasLabel('itemVersion').has('itemVersionId',2)).property('weight', 1)
g.V().hasLabel('event').has('eventId',3).addE('eventRelatedTo').to(g.V().hasLabel('itemVersion').has('itemVersionId',1)).property('weight', 2)
g.V().hasLabel('event').has('eventId',3).addE('eventRelatedTo').to(g.V().hasLabel('itemVersion').has('itemVersionId',3)).property('weight', 3)
g.V().hasLabel('event').has('eventId',4).addE('eventRelatedTo').to(g.V().hasLabel('itemVersion').has('itemVersionId',4)).property('weight', 4)
g.V().hasLabel('event').has('eventId',5).addE('eventRelatedTo').to(g.V().hasLabel('itemVersion').has('itemVersionId',5)).property('weight', 1)
g.V().hasLabel('itemVersion').has('itemVersionId',1).addE('itemVersionOf').to(g.V().hasLabel('item').has('itemId',1))
g.V().hasLabel('itemVersion').has('itemVersionId',2).addE('itemVersionOf').to(g.V().hasLabel('item').has('itemId',2))
g.V().hasLabel('itemVersion').has('itemVersionId',3).addE('itemVersionOf').to(g.V().hasLabel('item').has('itemId',3))
g.V().hasLabel('itemVersion').has('itemVersionId',4).addE('itemVersionOf').to(g.V().hasLabel('item').has('itemId',1))
g.V().hasLabel('itemVersion').has('itemVersionId',5).addE('itemVersionOf').to(g.V().hasLabel('item').has('itemId',2))
g.V().hasLabel('itemVersion').has('itemVersionId',6).addE('itemVersionOf').to(g.V().hasLabel('item').has('itemId',3))
g.V().hasLabel('itemVersion').has('itemVersionId',7).addE('itemVersionOf').to(g.V().hasLabel('item').has('itemId',4))


来源: stackexchange

问:
Google Chrome's empty Cache and Hard Reload does not empty text
On chrome, the text on our wordpress contact form page does not update when I do the following:

Enter developer mode f12

In developer mode, select network and click disable cache

Right click reload and select Empty Cache and Hard Reload

If I go to firefox, the changes can be seen, so it is not a hosting issue.  Our host is namecheap.

This is really annoying, does anyone know how I can force chrome to discover the new text?

答: You could try to open the page in a private tab. This is not actually a solution, but for testing purposes it could do the trick. </p>

ContentLicense: CC BY-SA 4.0


问:
can't access inner class's public variable... which is inherited from parent
Java Q: I can't access a public variable in my parent's class' inner class called foo. Why? setup is next(pseudo coded for brevity):</p>

```<code>public class PageObject
{
    public class Button
    {
        public String foo ="I want this string."  //can't access....
    }
    ....other stuff I can access here...
}

public class worker
    {
    public PageObject p = new PageObject();
    }

public class workerchild extends worker
{
    p.Buttons.    <---don't have access to Buttons public variables, only .class, etc.
}
</code>```

答: First off, your inner class is called Button (singular), not Buttons (plural). Second, make the inner class static and the foo member a constant and you will be able to access the foo member as simply Button.foo, you just won't be able to change its value.

ContentLicense: CC BY-SA 3.0

Body:
Java Q: I can't access a public variable in my parent's class' inner class called foo. Why? setup is next(pseudo coded for brevity):

public class PageObject
{
    public class Button
    {
        public String foo ="I want this string."  //can't access....
    }
    ....other stuff I can access here...
}

public class worker
    {
    public PageObject p = new PageObject();
    }

public class workerchild extends worker
{
    p.Buttons.    <---don't have access to Buttons public variables, only .class, etc.
}


问:
Serialize/Deserialize dynamic property name using JSON.NET
I have the following class:

```<code>public class MyRequest
{
    public string Type {get;set;}
    public string Source {get;set;}
}
</code>```

I would like to serialize/deserialize the value for Source from the JSON field named the value of Type, for example:

```<code>{
    "type": "bank",
    "bank": "Some value"
}
</code>```

or

```<code>{
    "type": "card",
    "card": "Some value"
}
</code>```

Where both bind to the Source property.

答:
My solution is:
First create APIResultModel class:

```<code>public class APIResultModel<T> where T: APIModel, new()
{

    public string ImmutableProperty { get; set; }

    public T Result { get; set; }

    public APIResultModel<T> Deserialize(string json)
    {
        var jObj = JObject.Parse(json);
        T t = new T();
        var result = jObj[t.TypeName()];
        jObj.Remove(t.TypeName());
        jObj["Result"] = result;
        return jObj.ToObject<APIResultModel<T>>();
    }
}
</code>```

Second create APIModel abstract Class:

```<code>public abstract class APIModel
{
    public abstract string TypeName();
}
</code>```

Third create dynamic content Model class:

```<code>public class MyContentModel: APIModel
{
    public string Property {get; set;}
    public override string TypeName()
    {
        return "JsonKey";
    }
}
</code>```

When you need to deserialize a json string:

```<code>var jsonModel = new APIResultModel<MyContentModel>();
jsonModel = jsonModel.Deserialize(json);
MyContentModel dynimacModel = jsonModel.Result;
</code>```

The Deserialize function is come from @Eser

Body:
I have the following class:

public class MyRequest
{
    public string Type {get;set;}
    public string Source {get;set;}
}

I would like to serialize/deserialize the value for Source from the JSON field named the value of Type, for example:

{
    "type": "bank",
    "bank": "Some value"
}

or

{
    "type": "card",
    "card": "Some value"
}

Where both bind to the Source property.

Body:
My solution is:
First create APIResultModel class:

public class APIResultModel<T> where T: APIModel, new()
{

    public string ImmutableProperty { get; set; }

    public T Result { get; set; }

    public APIResultModel<T> Deserialize(string json)
    {
        var jObj = JObject.Parse(json);
        T t = new T();
        var result = jObj[t.TypeName()];
        jObj.Remove(t.TypeName());
        jObj["Result"] = result;
        return jObj.ToObject<APIResultModel<T>>();
    }
}

Second create APIModel abstract Class:

public abstract class APIModel
{
    public abstract string TypeName();
}

Third create dynamic content Model class:

public class MyContentModel: APIModel
{
    public string Property {get; set;}
    public override string TypeName()
    {
        return "JsonKey";
    }
}

When you need to deserialize a json string:

var jsonModel = new APIResultModel<MyContentModel>();
jsonModel = jsonModel.Deserialize(json);
MyContentModel dynimacModel = jsonModel.Result;

The Deserialize function is come from @Eser


问:
Javascript function prevent to execute if already executing
I have a function which job is to fetch the record from third party and this function is executing after each 10 seconds.

The problem is since this function is executing after very short time so when I debug through firefox it's showing a long queue of ajax. I am thinking why not to add a statement which can give the signal to next about ajax executions. Because I am executing same function and which job is same so if previous one still doing the same then there is not point to execute another one for the same job. I am trying following

```<code>function someThingPrecessing(){
    if(sessionStorage.do == true){
        $.ajax(function(){
            continue...
        });
     }

    sessionStorage.do = true;
    sessionStorage.do = false;
}

setInterval(someThingPrecessing,10000);
</code>```

But above one does not working, can someone guide me how can I do that. I would like to appreciate.

答:
You should check if the ajax request is done before calling the next one. Below is an example:</p>

```<code>var ajax_ongoing=false;
function someThingPrecessing(){
    if(!ajax_ongoing){
    ajax_ongoing=true;
        $.ajax(function(){
            success : function(data) {
                    ajax_ongoing=false;
                },
                error : function(data, textStatus, errorThrown) {
                    ajax_ongoing=false;
                }
        });
     }
  }

setInterval(someThingPrecessing,10000);
</code>```

Body:
I have a function which job is to fetch the record from third party and this function is executing after each 10 seconds.

The problem is since this function is executing after very short time so when I debug through firefox it's showing a long queue of ajax. I am thinking why not to add a statement which can give the signal to next about ajax executions. Because I am executing same function and which job is same so if previous one still doing the same then there is not point to execute another one for the same job. I am trying following

function someThingPrecessing(){
    if(sessionStorage.do == true){
        $.ajax(function(){
            continue...
        });
     }

    sessionStorage.do = true;
    sessionStorage.do = false;
}

setInterval(someThingPrecessing,10000);

But above one does not working, can someone guide me how can I do that. I would like to appreciate.

Body:
You should check if the ajax request is done before calling the next one. Below is an example:

var ajax_ongoing=false;
function someThingPrecessing(){
    if(!ajax_ongoing){
    ajax_ongoing=true;
        $.ajax(function(){
            success : function(data) {
                    ajax_ongoing=false;
                },
                error : function(data, textStatus, errorThrown) {
                    ajax_ongoing=false;
                }
        });
     }
  }

setInterval(someThingPrecessing,10000);


问:
How to verify ACK packet with write function in TCP client?
I'm trying to write a TCP client with write function following this: guide.

I shut down my network and try to send a PING package with 2 bytes of data.

Since it's a TCP client, I expect some kind of error returned because there is no network at all and the server won't be able to receive the message, hence no ACK packet will be returned. However, write function returns 2 bytes were written, seem like it doesn't verify ACK packet from server side at all.

How could I check for ACK to make sure whether my message is sent successfully and server receive it?

答:
If you run both client and server on the same machine they'll communicate through the loopback interface, so unplugging or deactivating the outbound network interface will not change anything. Your server and client communicate happily with each other. If there truly isn't any connection between server and client the connect() should've failed with errno set to ENETUNREACH or ECONNREFUSED if the server refuses the connection. So what you probably want is to run the client on your machine and the server either another computer or in a VM with a bridged network. Note that write() successfully returning only means that the bytes are buffered to be send. It may even return fewer bytes than your message contains, indicating the buffer is currently full and you need to try sending the remaining bytes later.

The best way to analyze protocol implementations is using a tool like wireshark to see what packages are actually sent over the wire (or through the loopback interface).


问:
Should I share gRPC Stubs or Channels?
The gRPC C++ API for creating channels returns a shared_ptr. The generated function NewStub returns a unique_ptr. However I've seen reports of people having issues trying to create multiple instances of a stub type, sharing a channel. Their solution was to share the stub.

It is not clear from the documentation or API if a client is meant to create multiple stub instances sharing the channel or share a single stub. Please clarify the conceptual relationship between stubs, channels, and unique client connections.

Diving a little deeper:
A server can serve more than one service and a client endpoint can use a single channel to connect corresponding stub types to each of those services. For that purpose, it is clear the different stub types share the single channel to talk to the server endpoint. Does gRPC expect only one client per channel for a given service or can I have multiple clients on the client endpoint talking to a single service? If allowed, how do I achieve multiple clients for a given service on a client endpoint? How does the server distinguish these as independent clients?

As an aside, This SO post indicates both Channels and Stubs are thread-safe. (The post is specifically for Java, but I'm assuming it carries over to C++).

答:
I think first we need to clarify the definitions for channel and stub, according to the official documents :

channel :

A gRPC channel provides a connection to a gRPC server on a specified host and port...

Conclude : A channel represents a single TCP connection.

stub :

On the client side, the client has a local object known as stub (for some languages, the preferred term is client) that implements the same methods as the service.

Conclude : A stub represents a single client.

From reading many other materials, I'm sure that a single channel(tcp connection) can be multiplexed, and now we get two options to achieve it:

one channel <--> one stub

one stub <--> multiple streams

one channel <--> multiple stubs

one stub <--> multiple streams

the only difference is that whether to share a channel among the stubs or not. My answer is: Yes, you can, for the reasons:

your reports of people having issues example is written in ruby, but I can also find python examples standing on the opposite side. So the behavior may depends on language implementations.

the synchronous cpp client examples use one stub object to issue a rpc, and it doesn't have any stream objects associated with, then the only way for multiplexing purpose is just share one single channel object among the stubs.

Combining the above two reasons, I conclude that: sharing a channel among the stubs is valid in C++.

Now, back to you questions:

Does gRPC expect only one client per channel for a given service or can I have multiple clients on the client endpoint talking to a single service?

Sure, you can have multiple clients talking to a single service.

If allowed, how do I achieve multiple clients for a given service on a client endpoint?

You can just have multiple stubs generated either from one single channel or from multiple channels, former is a better choice for connection overhead considerations.

How does the server distinguish these as independent clients?

This is due to http2, it can be multiplexed and has its own rules to achieve this, what grpc need to do is just follow thoes rules.

Hope this helps!

Title: Should I share gRPC Stubs or Channels?


问:
How to optimize Oracle create table function for a table having over 30 million rows and 250 columns
I need to create a table which has over 30 million rows and about 250 columns from another table which has same row number and about 230 columns. It is like ETL process. I use SPSS Modeler to run a stream which has  algorithms of the process. I need to make faster the this process.

In IBM Netezza, this process took about 20-25 mins with in-database caching in SPSS Modeler and DISTRIBUTE ON HASH function for both input and output tables.

In Oracle, same process took about 1.5-2 hours. I cannot optimize the code. I have tried so many ways, creating both input and output table with PARALLEL function, tried to indexing input table, tried to partitioning and etc.

At last, I have used the syntax in the below for  input and output tables, however I cannot make any progress.

COLUMN STORE COMPRESS FOR QUERY HIGH NO ROW LEVEL LOCKING  NOLOGGING
PARTITION BY HASH ("COLUMN 1") PARALLEL 16
```

答: I would try to create the new table using hash partitioning and parallel processing. This here centroid article seems to be a good discussion to get you started on how to implement it.</p>


问:
How do I upload a Word Add-in to AppSource from the Seller Dashboard?
We've spent a week or two trying to get the ability to use the SellerDashboard to upload a Word Addin, but no luck. We've also been on the phone, live chat, screen share, and have support tickets with Microsoft - but still no luck. So, looking to the community for help.

I've already read this post, but that user was trying to upload in the wrong place - whereas I have all the correct permissions, but am stuck in an infinite loop.

1: Go to Partner Center >> click on "Office Store" >> click on "Overview"/"Client IDs"/"Office Profile"

2: Get re-directed to https://sellerdashboard.microsoft.com/Registration

3: Click "Continue" under Office

4: Get re-directed to https://partner.microsoft.com/en-US/dashboard/Office/signup

5: Click "Sign up now"

6: Get re-directed to https://partner.microsoft.com/en-us/dashboard/Account/Management?accountProgram=Office

7: Twiddle thumbs

So, basically, I can keep doing this ad-infinitum, and there is no way out. I've added our company as a tenant, I've added our Microsoft users as users, everything I can link up - is linked up.

Here's the craziest part. The "owner" of this Partner Center account doesn't get caught in this loop.

After step 1, he is re-directed to https://sellerdashboard.microsoft.com/Application/Summary and has the option to start creation of an Add-In (but I'm the developer of the add-in, so I need to upload the manifest and fill in everything, make tweaks, etc).

I've tried using Chrome, Incognito Chrome (no Chrome extensions), and Safari - but no luck.

I'm not blocking any cookies, but still no luck.

I see in Chrome Dev Tools that there are a lot of errors when I go to the Seller Dashboard, but there's nothing I can do about that.

Has anyone run into anything like this, and are there any suggestions? It's hard enough even getting the correct support team on the phone, without getting re-directed all over the place.

UPDATE MAY 28:

After 2.5 weeks of waiting for Microsoft Support, the closest thing to an "answer" I received about this problem was that only the Owner of the account (e.g. the first person to create an account, using their PERSONAL Microsoft credentials) can create apps, upload them, etc etc...

"but once directed to the actual seller dashboard, only the owner of
  the Microsoft account can access these features. This is by design"

This is so thoroughly insane that I don't even believe this is really the answer, and that there must be a misunderstanding somewhere. Because, it basically means that if the person who created the Seller Dashboard account leaves a company, then you no longer have access to your product in the Office Store.

答:
I've both released add-ins through my personal account also work for a company where multiple people has access to Office store.

You have to use an MSA when signing up. (Outlook.com / hotmail.com accounts). Organizational IDs won't work.

We have a shared account, which we use to publish / unpublish add-ins. Credential of this account is generally stored with whoever(s) is / are coordinating the release of the add-in and not the development team. It's fine though because we have multiple people with the sign-in credentials.

In terms of steps, you are not that far off. Basically head off to https://sellerdashboard.microsoft.com/Registration and follow the steps on (which should lead you to link below). When you're signed-in, make sure from the top right window that you're actually signed in with the personal account and not your organizational account. I find the organizational accounts to be very sticky in terms of sign-in.

https://partner.microsoft.com/en-us/dashboard/registration/AccountInfo?accountProgram=Office go through this experience. Once created the account, the validation of it should take a few days. Then you should be good to go.


问:
How do I call different values of each columns in my Mysql table with same invoice nº?
I have a table named purchase_details with some values which has the same invoice_no. Now I need each of the data with the same invoice_no and output them in a input field which will the same amount of the invoice_no length.

As i am new to PHP I have tried to use an array but it's showing the letters of the last row.

```<code><table align="center" style="width:800px;">
      <thead>
             <tr>
                  <th>#</th>
                  <th style="text-align:center;">Item Name</th>
                  <th style="text-align:center;">Total Quantity</th>
                  <th style="text-align:center;">Quantity</th>
                  <th style="text-align:center;">Buy Price</th>
                  <th>Total</th>
             </tr>
       </thead>
       <tbody id="invoice_item">
       <?php
           $query1="select * from purchase_details where invoice_no=$id";
           $query1_run=mysqli_query($connect , $query1);
           while($row=mysqli_fetch_array($query1_run)){
               $product_name = $row['product_name'];
           }
           echo $product_name[0];
       ?>
           <tr>
               <td><b id="number"></b></td>
               <td>
                   <select name="pid[]" class="form-control form-control-sm" required>
                       <option selected=""></option>
                   </select>
               </td>
               <td><input name="tqty[]" readonly type="text" class="form-control form-control-sm" ></td>
               <td><input name="qty[]" type="text" class="form-control form-control-sm" required value=""></td>
               <td><input name="price[]" type="text" class="form-control form-control-sm" readonly value=""></td>
               <td></td>
           </tr>
        </tbody>
     </table>
</code>```

答:
You should end the while loop after the table data</p>

```<code><table align="center" style="width:800px;">
      <thead>
             <tr>
                  <th>#</th>
                  <th style="text-align:center;">Item Name</th>
                  <th style="text-align:center;">Total Quantity</th>
                  <th style="text-align:center;">Quantity</th>
                  <th style="text-align:center;">Buy Price</th>
                  <th>Total</th>
             </tr>
       </thead>
       <tbody id="invoice_item">
       <?php
           $query1="select * from purchase_details where invoice_no=$id";
           $query1_run=mysqli_query($connect , $query1);
           while($row=mysqli_fetch_array($query1_run)){
               $product_name = $row['product_name'];

           echo $product_name[0];
       ?>
           <tr>
               <td><b id="number"></b></td>
               <td>
                   <select name="pid[]" class="form-control form-control-sm" required>
                       <option selected=""></option>
                   </select>
               </td>
               <td><input name="tqty[]" readonly type="text" class="form-control form-control-sm" ></td>
               <td><input name="qty[]" type="text" class="form-control form-control-sm" required value=""></td>
               <td><input name="price[]" type="text" class="form-control form-control-sm" readonly value=""></td>
               <td></td>
           </tr>
           <?php } ?>
        </tbody>
     </table>
</code>```

Body:
I have a table named purchase_details with some values which has the same invoice_no. Now I need each of the data with the same invoice_no and output them in a input field which will the same amount of the invoice_no length.

As i am new to PHP I have tried to use an array but it's showing the letters of the last row.

                  #
                  Item Name
                  Total Quantity
                  Quantity
                  Buy Price
                  Total

       <?php
           $query1="select * from purchase_details where invoice_no=$id";
           $query1_run=mysqli_query($connect , $query1);
           while($row=mysqli_fetch_array($query1_run)){
               $product_name = $row['product_name'];
           }
           echo $product_name[0];
       ?>

                   <select name="pid[]" class="form-control form-control-sm" required>
                       <option selected=""></option>
                   </select>

               <input name="tqty[]" readonly type="text" class="form-control form-control-sm" >
               <input name="qty[]" type="text" class="form-control form-control-sm" required value="">
               <input name="price[]" type="text" class="form-control form-control-sm" readonly value="">

Body:
You should end the while loop after the table data

<table align="center" style="width:800px;">
      <thead>
             <tr>
                  <th>#</th>
                  <th style="text-align:center;">Item Name</th>
                  <th style="text-align:center;">Total Quantity</th>
                  <th style="text-align:center;">Quantity</th>
                  <th style="text-align:center;">Buy Price</th>
                  <th>Total</th>
             </tr>
       </thead>
       <tbody id="invoice_item">
       <?php
           $query1="select * from purchase_details where invoice_no=$id";
           $query1_run=mysqli_query($connect , $query1);
           while($row=mysqli_fetch_array($query1_run)){
               $product_name = $row['product_name'];

           echo $product_name[0];
       ?>
           <tr>
               <td><b id="number"></b></td>
               <td>
                   <select name="pid[]" class="form-control form-control-sm" required>
                       <option selected=""></option>
                   </select>
               </td>
               <td><input name="tqty[]" readonly type="text" class="form-control form-control-sm" ></td>
               <td><input name="qty[]" type="text" class="form-control form-control-sm" required value=""></td>
               <td><input name="price[]" type="text" class="form-control form-control-sm" readonly value=""></td>
               <td></td>
           </tr>
           <?php } ?>
        </tbody>
     </table>


问:
Create responsive table using flexbox
How can I create a responsive table?

The table I want is similar to this one:

The table must be responsive, so what have to change is the width of the columns.

I think the best solution is to use Flexbox but how?

I try this code:

.container {
  display: flex;
  border: 1px solid black;
}

.column {
  display: flex;
  flex-direction: column;
  border: 1px solid black;
}

.cell {
  border: 1px solid black;
  padding: 5px;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="container">
  <div class="column">
    <div class="cell"></div> <!-- empty cell -->
    <div class="cell">something</div>
    <div class="cell">dog</div>
    <div class="cell">more dogs</div>
  </div>

  <div class="column">
    <div class="cell">column2 long title</div>
    <div class="cell">abc</div>
    <div class="cell">a</div>
    <div class="cell">aaaaaaa</div>
  </div>

  <div class="column">
    <div class="cell">column 3 tilew</div>
    <div class="cell">bbbb</div>
    <div class="cell">da</div>
    <div class="cell">f</div>
  </div>

  <div class="column">
    <div class="cell">something</div>
    <div class="cell">ggggg</div>
    <div class="cell">f</div>
    <div class="cell">cats</div>
  </div>
</div></code>```

I simply create 4 columns, and each column has the same number of row but, of course, they will not be of the same height.
How can I fix it?

Then, the first cell must be empty

Thanks a lot!

答:
I don't see why you need to use flexbox rather than a table. Anyway you can use CSS Grid layout here just for the sake of not using tables - it is easy to set up for the code in the question.

Also using display: contents here - note that it is supported in newer browsers - full support explanation here.

.container {
  display: grid; /* grid containers */
  grid-template-columns: repeat(4, 1fr); /* four columns */
  grid-template-rows: repeat(4, 1fr); /* four rows */
  grid-auto-flow: column; /* in column direction */
  border: 1px solid black;
}

.column {
  display: contents; /* the child elements would be grid items */
  border: 1px solid black;
}

.cell {
  border: 1px solid black;
  padding: 5px;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="container">
  <div class="column">
    <div class="cell"></div> <!-- empty cell -->
    <div class="cell">something</div>
    <div class="cell">dog</div>
    <div class="cell">more dogs</div>
  </div>

  <div class="column">
    <div class="cell">column2 long title</div>
    <div class="cell">abc</div>
    <div class="cell">a</div>
    <div class="cell">aaaaaaa</div>
  </div>

  <div class="column">
    <div class="cell">column 3 tilew</div>
    <div class="cell">bbbb</div>
    <div class="cell">da</div>
    <div class="cell">f</div>
  </div>

  <div class="column">
    <div class="cell">something</div>
    <div class="cell">ggggg</div>
    <div class="cell">f</div>
    <div class="cell">cats</div>
  </div>
</div></code>```

Title: Create responsive table using flexbox

Body:
How can I create a responsive table?

The table I want is similar to this one:

The table must be responsive, so what have to change is the width of the columns.

I think the best solution is to use Flexbox but how?

I try this code:

.container {
  display: flex;
  border: 1px solid black;
}

.column {
  display: flex;
  flex-direction: column;
  border: 1px solid black;
}

.cell {
  border: 1px solid black;
  padding: 5px;
}

something

dog

more dogs

column2 long title

abc

a

aaaaaaa

column 3 tilew

bbbb

da

f

something

ggggg

f

cats

I simply create 4 columns, and each column has the same number of row but, of course, they will not be of the same height.
How can I fix it?

Then, the first cell must be empty

Thanks a lot!

Body:
I don't see why you need to use flexbox rather than a table. Anyway you can use CSS Grid layout here just for the sake of not using tables - it is easy to set up for the code in the question.

Also using display: contents here - note that it is supported in newer browsers - full support explanation here.

.container {
  display: grid; /* grid containers */
  grid-template-columns: repeat(4, 1fr); /* four columns */
  grid-template-rows: repeat(4, 1fr); /* four rows */
  grid-auto-flow: column; /* in column direction */
  border: 1px solid black;
}

.column {
  display: contents; /* the child elements would be grid items */
  border: 1px solid black;
}

.cell {
  border: 1px solid black;
  padding: 5px;
}

<div class="container">
  <div class="column">
    <div class="cell"></div> <!-- empty cell -->
    <div class="cell">something</div>
    <div class="cell">dog</div>
    <div class="cell">more dogs</div>
  </div>

  <div class="column">
    <div class="cell">column2 long title</div>
    <div class="cell">abc</div>
    <div class="cell">a</div>
    <div class="cell">aaaaaaa</div>
  </div>

  <div class="column">
    <div class="cell">column 3 tilew</div>
    <div class="cell">bbbb</div>
    <div class="cell">da</div>
    <div class="cell">f</div>
  </div>

  <div class="column">
    <div class="cell">something</div>
    <div class="cell">ggggg</div>
    <div class="cell">f</div>
    <div class="cell">cats</div>
  </div>
</div>


问:
How do I get elements from an array without repetition?
How do I get 5 elements from an array without repetition?

I'm trying to create an online version of story dice using Tumult Hype. All that I need to do is choose 5 image names from an array without repetition. But I just can't get it to work.

I've tried borrowing code from other stackoverflow answers and I can't get them working.

The code below is currently working but gives me repeats. How do I tinker with it to eliminate the repeats?

(You can see it in action here: https://davebirss.com/storydice/)

I know that it's probably verbose and inelegant. I only speak pidgin javascript, I'm afraid. And what I'm trying to do is currently beyond my ability.

Thank you so much in advance for your help.

```<code>var diceRoll = ['${resourcesFolderName}/story_dice1.png',
        '${resourcesFolderName}/story_dice2.png',
        '${resourcesFolderName}/story_dice3.png',
        ...,
        '${resourcesFolderName}/story_dice51.png']

function choose(n, arr) {
    while (arr.length > n) {
        var del = Math.floor(Math.random() * arr.length);
        arr = arr.filter(function(item, i) {
            return i !== del;
        });
    }
    return arr;}

var result1 = [choose(1, diceRoll)];
var result2 = [choose(1, diceRoll)];
var result3 = [choose(1, diceRoll)];
var result4 = [choose(1, diceRoll)];
var result5 = [choose(1, diceRoll)];

hypeDocument.getElementById("dice1").innerHTML = "<img src='"+result1+" 'height='125' width='125'>";
hypeDocument.getElementById("dice2").innerHTML = "<img src='"+result2+" 'height='125' width='125'>";
hypeDocument.getElementById("dice3").innerHTML = "<img src='"+result3+" 'height='125' width='125'>";
hypeDocument.getElementById("dice4").innerHTML = "<img src='"+result4+" 'height='125' width='125'>";
hypeDocument.getElementById("dice5").innerHTML = "<img src='"+result5+" 'height='125' width='125'>";
</code>```

Update

Thank you all for your help. I'm sure all the answers were great but the snippet from U25lYWt5IEJhc3RhcmQg is the code that I managed to successfully incorporate. For the record, this is how I did it:

```<code>const rollTheDice = (arr, n) => {
  const randomN = [];
  while(randomN.length < n){
    const randomIndex = Math.floor(Math.random()*arr.length);
    randomN.push(arr[randomIndex]);
    arr.splice(randomIndex, 1);
  }
  return randomN;}

var result1 = (rollTheDice(images,1));
var result2 = (rollTheDice(images,1));
var result3 = (rollTheDice(images,1));
var result4 = (rollTheDice(images,1));
var result5 = (rollTheDice(images,1));
</code>```

I've been repeatedly reloading the page and haven't seen any repeats yet. Perfect!

答:
You want a random permutation which all elements is uniq and from one dataset, here is my implementation:

var array = [1, 2, 3, 4, 5, 6];

/**
 * uniqGet
 * @param {*} array source array
 * @param {*} num how many elements to get
 */
function uniqGet(array, num) {
  if (array.length < num) {
    throw new Error("num should less than options");
  }
  let res = [];
  while (num > 0) {
    let index = Math.floor(Math.random() * array.length);
    res.push(array[index]);
    array.splice(index, 1);
    num--;
  }
  return res;
}

let result = uniqGet(array, 3); // [x, y, z]
```

Body:
How do I get 5 elements from an array without repetition?

I'm trying to create an online version of story dice using Tumult Hype. All that I need to do is choose 5 image names from an array without repetition. But I just can't get it to work.

I've tried borrowing code from other stackoverflow answers and I can't get them working.

The code below is currently working but gives me repeats. How do I tinker with it to eliminate the repeats?

(You can see it in action here: https://davebirss.com/storydice/)

I know that it's probably verbose and inelegant. I only speak pidgin javascript, I'm afraid. And what I'm trying to do is currently beyond my ability.

Thank you so much in advance for your help.

var diceRoll = ['${resourcesFolderName}/story_dice1.png',
        '${resourcesFolderName}/story_dice2.png',
        '${resourcesFolderName}/story_dice3.png',
        ...,
        '${resourcesFolderName}/story_dice51.png']

function choose(n, arr) {
    while (arr.length > n) {
        var del = Math.floor(Math.random() * arr.length);
        arr = arr.filter(function(item, i) {
            return i !== del;
        });
    }
    return arr;}

var result1 = [choose(1, diceRoll)];
var result2 = [choose(1, diceRoll)];
var result3 = [choose(1, diceRoll)];
var result4 = [choose(1, diceRoll)];
var result5 = [choose(1, diceRoll)];

hypeDocument.getElementById("dice1").innerHTML = "";
hypeDocument.getElementById("dice2").innerHTML = "";
hypeDocument.getElementById("dice3").innerHTML = "";
hypeDocument.getElementById("dice4").innerHTML = "";
hypeDocument.getElementById("dice5").innerHTML = "";

Update

Thank you all for your help. I'm sure all the answers were great but the snippet from U25lYWt5IEJhc3RhcmQg is the code that I managed to successfully incorporate. For the record, this is how I did it:

const rollTheDice = (arr, n) => {
  const randomN = [];
  while(randomN.length < n){
    const randomIndex = Math.floor(Math.random()*arr.length);
    randomN.push(arr[randomIndex]);
    arr.splice(randomIndex, 1);
  }
  return randomN;}

var result1 = (rollTheDice(images,1));
var result2 = (rollTheDice(images,1));
var result3 = (rollTheDice(images,1));
var result4 = (rollTheDice(images,1));
var result5 = (rollTheDice(images,1));

I've been repeatedly reloading the page and haven't seen any repeats yet. Perfect!


问:
Count the number of overlapping substrings within a string
example:

```<code>s <- "aaabaabaa"
p <- "aa"
</code>```

I want to return 4, not 3 (i.e. counting the number of "aa" instances in the initial "aaa" as 2, not 1).

Is there any package to solve it? Or is there any way to count in R?

答:
A tidy, and I think more readable solution  is</p>

```<code>library(tidyverse)
PatternCount <- function(text, pattern) {
    #Generate all sliding substrings
    map(seq_len(nchar(text) - nchar(pattern) + 1),
        function(x) str_sub(text, x, x + nchar(pattern) - 1)) %>%
    #Test them against the pattern
    map_lgl(function(x) x == pattern) %>%
    #Count the number of matches
    sum
}

PatternCount("aaabaabaa", "aa")
# 4
</code>```

Body:
example:

s <- "aaabaabaa"
p <- "aa"

I want to return 4, not 3 (i.e. counting the number of "aa" instances in the initial "aaa" as 2, not 1).

Is there any package to solve it? Or is there any way to count in R?

Body:
A tidy, and I think more readable solution  is

library(tidyverse)
PatternCount <- function(text, pattern) {
    #Generate all sliding substrings
    map(seq_len(nchar(text) - nchar(pattern) + 1),
        function(x) str_sub(text, x, x + nchar(pattern) - 1)) %>%
    #Test them against the pattern
    map_lgl(function(x) x == pattern) %>%
    #Count the number of matches
    sum
}

PatternCount("aaabaabaa", "aa")
# 4


问:
N-curses within Python : how to catch and print non ascii character?
I want to make a small program with ncurses/python and to be able to use/type in french and japanese. I understand that I should set the locale and use unicode standard.

But how to deal with the result from screen.getch() ? I would like to display the typed character within the ncurses window regardless of the language.

I understand that some unicode conversion is necessary but can't find what to do (and i've searched quite a bit : this character conversion bussiness isnt easy to understand for amateurs).

Additional question : it seems that for non ascii characters we must used addstr() instead of addch(). Similarly should I use getstr() instead of getch() ?

#!/usr/bin/python3
# -*- coding: utf-8 -*-
import curses
from curses import wrapper
import locale

locale.setlocale(locale.LC_ALL, '')

def main(scr):
    # Following lines are some sort of "proof of concept"
    # Indeed it print latin or japanese characters allright
    scr.addstr(0, 0, u'\u3042'.encode('utf-8')) # print あ
    scr.addstr(1, 0, 'é'.encode('utf-8'))       # print é

    # But here I would like to type in a character and have it displayed onscreen
    while (True):
        car = scr.getch()
        if car == 27: # = Escape key
            break
        else:
        # What should I put between those parenthesis to
        # print the typed character on the third line of the screen
            scr.addstr(3, 0, ???? )

wrapper(main)
```

答:
unctrl is the function to use, for results from getch:

curses.unctrl(ch)

Return a string which is a printable representation of the character ch. Control characters are displayed as a caret followed by the character, for example as ^C. Printing characters are left as they are.

If you want to read UTF-8 directly, use get_wch (which was not available in the python2 wrapper):

window.get_wch([y, x])

Get a wide character. Return a character for most keys, or an integer for function keys, keypad keys, and other special keys. In no-delay mode, raise an exception if there is no input.

New in version 3.3.

even with that, you still must ensure that the locale is initialized.  The Python documentation assumes that you have access to the ncurses documentation:

Initialization, in the ncurses manual page

get_wch, wget_wch, mvget_wch, mvwget_wch, unget_wch- get (or push
back) a wide character from curses terminal keyboard


问:
losing image quality while converting base 64

I have one pdf and I am converting pdf to image and displaying in UIImageView and then after I am converting that image to base 64 but while converting base 64 I am losing the image quality so is there any way to prevent from losing quality while converting to base 64

please tell me is there any solution for that

here is my code for convert

```<code>let previewImage1 = convertedImageView.getImage()
let btnImg = UIButton()
btnImg.setImage(previewImage1, for: .normal)
let btn1Imggg2 = btnImg.image(for: .normal)
let imageData2 = btnImg?.jpegData(compressionQuality: 0.0)
let imgString2 = imageData2!.base64EncodedString(options: .init(rawValue: 0))
</code>```

Even if i set compress quality to 0.0 still its compressing image

i have UIView Inside that i have ScrollView inside that i have ImageView and i am converting whole UIView as image and then convert into base64 the is the scenario hope this help you to understand

Code For UIView To UIImage

```<code> func getImage(scale: CGFloat? = nil) -> UIImage {
        let newScale = scale ?? UIScreen.main.scale
        self.scale(by: newScale)

        let format = UIGraphicsImageRendererFormat()
        format.scale = newScale

        let renderer = UIGraphicsImageRenderer(size: self.bounds.size, format: format)

        let image = renderer.image { rendererContext in
            self.layer.render(in: rendererContext.cgContext)
        }

        return image
    }
</code>```

答:
By doing this

```<code>   let imageData2 = btnImg?.jpegData(compressionQuality: 0.0)
</code>```

you are compressing the image with the maximum value possible. Change this code to

```<code>   let imageData2 = btnImg?.jpegData(compressionQuality: 1.0)
</code>```

and you will be good to go.

As you are converting the UIView to UIImage below function can be useful to you :

```<code>func image(with view: UIView) -> UIImage? {
    UIGraphicsBeginImageContextWithOptions(view.bounds.size, view.isOpaque, 0.0)
    defer { UIGraphicsEndImageContext() }
    if let context = UIGraphicsGetCurrentContext() {
        view.layer.render(in: context)
        let image = UIGraphicsGetImageFromCurrentImageContext()
        return image
    }
    return nil
}
</code>```

If the jpeg data does not suffice your requirement the user pngData like this

```<code>let imageData2 = btnImg?.pngData()
</code>```

After getting the conversion to Image apply the base64 conversion as you are doing right now.

Body:
I have one pdf and I am converting pdf to image and displaying in UIImageView and then after I am converting that image to base 64 but while converting base 64 I am losing the image quality so is there any way to prevent from losing quality while converting to base 64

please tell me is there any solution for that

here is my code for convert

let previewImage1 = convertedImageView.getImage()
let btnImg = UIButton()
btnImg.setImage(previewImage1, for: .normal)
let btn1Imggg2 = btnImg.image(for: .normal)
let imageData2 = btnImg?.jpegData(compressionQuality: 0.0)
let imgString2 = imageData2!.base64EncodedString(options: .init(rawValue: 0))

Even if i set compress quality to 0.0 still its compressing image

i have UIView Inside that i have ScrollView inside that i have ImageView and i am converting whole UIView as image and then convert into base64 the is the scenario hope this help you to understand

Code For UIView To UIImage

 func getImage(scale: CGFloat? = nil) -> UIImage {
        let newScale = scale ?? UIScreen.main.scale
        self.scale(by: newScale)

        let format = UIGraphicsImageRendererFormat()
        format.scale = newScale

        let renderer = UIGraphicsImageRenderer(size: self.bounds.size, format: format)

        let image = renderer.image { rendererContext in
            self.layer.render(in: rendererContext.cgContext)
        }

        return image
    }

Body:
By doing this

   let imageData2 = btnImg?.jpegData(compressionQuality: 0.0)

you are compressing the image with the maximum value possible. Change this code to

   let imageData2 = btnImg?.jpegData(compressionQuality: 1.0)

and you will be good to go.

As you are converting the UIView to UIImage below function can be useful to you :

func image(with view: UIView) -> UIImage? {
    UIGraphicsBeginImageContextWithOptions(view.bounds.size, view.isOpaque, 0.0)
    defer { UIGraphicsEndImageContext() }
    if let context = UIGraphicsGetCurrentContext() {
        view.layer.render(in: context)
        let image = UIGraphicsGetImageFromCurrentImageContext()
        return image
    }
    return nil
}

If the jpeg data does not suffice your requirement the user pngData like this

let imageData2 = btnImg?.pngData()

After getting the conversion to Image apply the base64 conversion as you are doing right now.


问:
Selecting Only The Latest Version Of A Field
I have a table schema with ID, Title, Date

and data looks something like this:

```<code>1  The title1    2011-04-05 00:00:00.000
2  Another title 2011-04-11 00:00:00.000
3  The title1    2011-04-11 16:49:23.633
4  The title1    2011-04-11 00:00:00.000
</code>```

I need help with sql to give me the latest date of each title.
So the output for the above data is

```<code>2  Another title 2011-04-11 00:00:00.000
3  The title1    2011-04-11 16:49:23.633
</code>```

答:
Assuming your table name is mytable:

```<code>select
  tbl.ID, tbl.Title, tbl.Date
from
  mytable tbl join
  (select Title, max(Date) Date
   from mytable) maxes on tbl.Date = maxes.Date and tbl.Title = maxes.Title
</code>```

Body:
I have a table schema with ID, Title, Date

and data looks something like this:

1  The title1    2011-04-05 00:00:00.000
2  Another title 2011-04-11 00:00:00.000
3  The title1    2011-04-11 16:49:23.633
4  The title1    2011-04-11 00:00:00.000

I need help with sql to give me the latest date of each title.
So the output for the above data is

2  Another title 2011-04-11 00:00:00.000
3  The title1    2011-04-11 16:49:23.633

Body:
Assuming your table name is mytable:

select
  tbl.ID, tbl.Title, tbl.Date
from
  mytable tbl join
  (select Title, max(Date) Date
   from mytable) maxes on tbl.Date = maxes.Date and tbl.Title = maxes.Title


问:
update column table with value of column from table b if it contains substring from another column from table b
There are 2 table like below:

```<code>Table a                        Table b

country_name                   id | string_bone   | country_name
------------------------       ---+---------------+---------------
usa                            1  | usa           | united states
u s a                          2  | u s a         | united states
united states of america       3  | america       | united states
america                        4  | ...           | ...
</code>```

I need to update table_a.country_name with table_b.country_name if table_b.string_bone is contained in table_a.country_name.

I tried this:

```<code>UPDATE table_a a
SET country_name = b.country_name
WHERE EXISTS (SELECT country_name
              FROM table_b
              WHERE a.country_name LIKE '%' || string_bone || '%') b;
</code>```

I would like table_a to look like this after the update:

```<code>Table a

country_name
------------------------
united states
united states
united states
united states
</code>```

Here the dbfiddle link.

答:
Try the following:</p>

```<code>UPDATE table_a a
    SET country_name = b.country_name
    from table_a t
    inner join table_b b
    on t.country_name LIKE '%' || b.string_bone || '%';
</code>```

Body:
There are 2 table like below:

Table a                        Table b

country_name                   id | string_bone   | country_name
------------------------       ---+---------------+---------------
usa                            1  | usa           | united states
u s a                          2  | u s a         | united states
united states of america       3  | america       | united states
america                        4  | ...           | ...

I need to update table_a.country_name with table_b.country_name if table_b.string_bone is contained in table_a.country_name.

I tried this:

UPDATE table_a a
SET country_name = b.country_name
WHERE EXISTS (SELECT country_name
              FROM table_b
              WHERE a.country_name LIKE '%' || string_bone || '%') b;

I would like table_a to look like this after the update:

Table a

country_name
------------------------
united states
united states
united states
united states

Here the dbfiddle link.

Body:
Try the following:

UPDATE table_a a
    SET country_name = b.country_name
    from table_a t
    inner join table_b b
    on t.country_name LIKE '%' || b.string_bone || '%';


问:
Making onClickListener a static method
```<code>View.OnClickListener ocl = new View.OnClickListener(){
    public void onClick(View v) {
        this.ocl_action();
    }

    public void ocl_action() {
        // TODO Auto-generated method stub
        for(int i=0; i<5;i++){                               }
            Toast.makeText(ControllerProjMain.this,"hi",Toast.LENGTH_LONG).show();
        }
    }
};
</code>```

It does not work if I just call ocl.ocl_action();

答:
See for changes at your code. You need to define the method ocl_action outside the listener.

```<code>View.OnClickListener ocl = new View.OnClickListener(){
    public void onClick(View v) {
        this.ocl_action();
    }};

public void ocl_action() {
 // TODO Auto-generated method stub
  for(int i=0; i<5;i++){
  Toast.makeText(getApplicationContext(), "HI", Toast.LENGTH_LONG).show();
  }
}
</code>```

Title: Making onClickListener a static method

Body:
View.OnClickListener ocl = new View.OnClickListener(){
    public void onClick(View v) {
        this.ocl_action();
    }

    public void ocl_action() {
        // TODO Auto-generated method stub
        for(int i=0; i<5;i++){                               }
            Toast.makeText(ControllerProjMain.this,"hi",Toast.LENGTH_LONG).show();
        }
    }
};

It does not work if I just call ocl.ocl_action();

Body:
See for changes at your code. You need to define the method ocl_action outside the listener.

View.OnClickListener ocl = new View.OnClickListener(){
    public void onClick(View v) {
        this.ocl_action();
    }};

public void ocl_action() {
 // TODO Auto-generated method stub
  for(int i=0; i<5;i++){
  Toast.makeText(getApplicationContext(), "HI", Toast.LENGTH_LONG).show();
  }
}


答:
Here it is!

/*
Generic Styling, for Desktops/Laptops
*/
table {
  width: 100%;
  border-collapse: collapse;
}
/* Zebra striping */
tr:nth-of-type(odd) {
  background: #eee;
}
th {
  background: #333;
  color: white;
  font-weight: bold;
}
td, th {
  padding: 6px;
  border: 1px solid #ccc;
  text-align: left;
}

/*
Max width before this PARTICULAR table gets nasty
This query will take effect for any screen smaller than 760px
and also iPads specifically.
*/
@media
only screen and (max-width: 760px),
(min-device-width: 768px) and (max-device-width: 1024px)  {

 .responsive-table-input-matrix {
  display: block;
  position: relative;
  width: 100%;

  &:after {
   clear: both;
   content: '';
   display: block;
   font-size: 0;
   height: 0;
   visibility: hidden;
  }

  tbody {
   display: block;
   overflow-x: auto;
   position: relative;
   white-space: nowrap;
   width: auto;

   tr {
    display: inline-block;
    vertical-align: top;

    td {
     display: block;
     text-align: center;

     &:first-child {
      text-align: left;
     }
    }
   }
  }

  thead {
   display: block;
   float: left;
   margin-right: 10px;

   &:after {
    clear: both;
    content: "";
    display: block;
    font-size: 0;
    height: 0;
    visibility: hidden;
   }

   th:first-of-type {
    height: 1.4em;
   }

   th {
    display: block;
    text-align: right;

    &:first-child {
     text-align: right;
    }
   }
  }
 }
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><table class="responsive-table-input-matrix">
  <thead>
  <tr>
   <th></th>
   <th>Owner</th>
   <th>Group</th>
   <th>Others</th>
   <th>Administrators</th>
   <th>Managers</th>
   <th>Engineers</th>
   <th>Sales</th>
   <th>Employees</th>
   <th>Customers</th>
   <th>Community</th>
  </tr>
  </thead>
  <tbody>

  <tr>
   <td>Add</td>
   <td></td>
   <td></td>
   <td></td>
   <td></td>
   <td></td>
   <td></td>
   <td></td>
   <td></td>
   <td></td>
   <td></td>
  </tr>
  <tr>
   <td>Edit</td>
   <td></td>
   <td></td>
   <td></td>
   <td></td>
   <td></td>
   <td></td>
   <td></td>
   <td></td>
   <td></td>
   <td></td>
  </tr>
  <tr>
  <td>Delete</td>
   <td></td>
   <td></td>
   <td></td>
   <td></td>
   <td></td>
   <td></td>
   <td></td>
   <td></td>
   <td></td>
   <td></td>
  </tr>
  <tr>
   <td>Rename</td>
   <td></td>
   <td></td>
   <td></td>
   <td></td>
   <td></td>
   <td></td>
   <td></td>
   <td></td>
   <td></td>
   <td></td>
  </tr>
  <tr>
   <td>Move</td>
   <td></td>
   <td></td>
   <td></td>
   <td></td>
   <td></td>
   <td></td>
   <td></td>
   <td></td>
   <td></td>
   <td></td>
  </tr>
  </tbody>
 </table></code>```

Title: Create responsive table using flexbox

Body:
Here it is!

/*
Generic Styling, for Desktops/Laptops
*/
table {
  width: 100%;
  border-collapse: collapse;
}
/* Zebra striping */
tr:nth-of-type(odd) {
  background: #eee;
}
th {
  background: #333;
  color: white;
  font-weight: bold;
}
td, th {
  padding: 6px;
  border: 1px solid #ccc;
  text-align: left;
}

/*
Max width before this PARTICULAR table gets nasty
This query will take effect for any screen smaller than 760px
and also iPads specifically.
*/
@media
only screen and (max-width: 760px),
(min-device-width: 768px) and (max-device-width: 1024px)  {

 .responsive-table-input-matrix {
  display: block;
  position: relative;
  width: 100%;

  &:after {
   clear: both;
   content: '';
   display: block;
   font-size: 0;
   height: 0;
   visibility: hidden;
  }

  tbody {
   display: block;
   overflow-x: auto;
   position: relative;
   white-space: nowrap;
   width: auto;

   tr {
    display: inline-block;
    vertical-align: top;

    td {
     display: block;
     text-align: center;

     &:first-child {
      text-align: left;
     }
    }
   }
  }

  thead {
   display: block;
   float: left;
   margin-right: 10px;

   &:after {
    clear: both;
    content: "";
    display: block;
    font-size: 0;
    height: 0;
    visibility: hidden;
   }

   th:first-of-type {
    height: 1.4em;
   }

   th {
    display: block;
    text-align: right;

    &:first-child {
     text-align: right;
    }
   }
  }
 }
}

<table class="responsive-table-input-matrix">
  <thead>
  <tr>
   <th></th>
   <th>Owner</th>
   <th>Group</th>
   <th>Others</th>
   <th>Administrators</th>
   <th>Managers</th>
   <th>Engineers</th>
   <th>Sales</th>
   <th>Employees</th>
   <th>Customers</th>
   <th>Community</th>
  </tr>
  </thead>
  <tbody>

  <tr>
   <td>Add</td>
   <td></td>
   <td></td>
   <td></td>
   <td></td>
   <td></td>
   <td></td>
   <td></td>
   <td></td>
   <td></td>
   <td></td>
  </tr>
  <tr>
   <td>Edit</td>
   <td></td>
   <td></td>
   <td></td>
   <td></td>
   <td></td>
   <td></td>
   <td></td>
   <td></td>
   <td></td>
   <td></td>
  </tr>
  <tr>
  <td>Delete</td>
   <td></td>
   <td></td>
   <td></td>
   <td></td>
   <td></td>
   <td></td>
   <td></td>
   <td></td>
   <td></td>
   <td></td>
  </tr>
  <tr>
   <td>Rename</td>
   <td></td>
   <td></td>
   <td></td>
   <td></td>
   <td></td>
   <td></td>
   <td></td>
   <td></td>
   <td></td>
   <td></td>
  </tr>
  <tr>
   <td>Move</td>
   <td></td>
   <td></td>
   <td></td>
   <td></td>
   <td></td>
   <td></td>
   <td></td>
   <td></td>
   <td></td>
   <td></td>
  </tr>
  </tbody>
 </table>


问:
Import js from script tag in HTML file. Possible?
I want to access data from script tag in html file, produced by cms.
Is it possible to do this without polluting global namespace?
I've tried to use es6 modules but I've failed and I couldn't find any info about it.

```

<pre class="lang-js prettyprint-override"><code>    //test.js
    import list from './index.html'
</code>```

Error:
'http://localhost:8080/index.html net::ERR_ABORTED 404'
or:
'Failed to load module script: The server responded with a non-JavaScript MIME type of "text/html". Strict MIME type checking is enforced for module scripts per HTML spec.'

答:
No, doing that isn't covered by the HTML specification yet¹ (and I suspect it never will be²). (If it were, you'd still need type="module" on your first script tag.) There's no module specifier that specifies a script element in an HTML page. At the moment, the only module specifiers are URLs for JavaScript files. Details in the spec.

Instead, you probably want something like this:

```<code><script type="module">
import { setList } from "./test.js";
setList(['a', 'b', 'c']);
</script>
</code>```

...where test.js exports a named export that lets you tell it what list to use.

(Or of course, it could be a default export.)

Inline script type="module" tags can import, but while they can use export, nothing can make use of the exports they create because they have no useful module specifier.

¹ It's the HTML spec because the form and semantics of module specifiers are left to the host environment by the JavaScript spec (details here). All that the JavaScript spec says about them is that they're string literals.

² It certainly could be, for instance using fragment identifiers. But with HTTP/2 multiplexing making discrete resource loading so fast compared with HTTP/1.1 (and esp. vs. HTTP/1.0), the impetus to make everything contained in a single resource is dramatically lower now than it was some years ago.

Body:
I want to access data from script tag in html file, produced by cms.
Is it possible to do this without polluting global namespace?
I've tried to use es6 modules but I've failed and I couldn't find any info about it.

    //test.js
    import list from './index.html'

Error:
'http://localhost:8080/index.html net::ERR_ABORTED 404'
or:
'Failed to load module script: The server responded with a non-JavaScript MIME type of "text/html". Strict MIME type checking is enforced for module scripts per HTML spec.'

Body:
No, doing that isn't covered by the HTML specification yet¹ (and I suspect it never will be²). (If it were, you'd still need type="module" on your first script tag.) There's no module specifier that specifies a script element in an HTML page. At the moment, the only module specifiers are URLs for JavaScript files. Details in the spec.

Instead, you probably want something like this:

<script type="module">
import { setList } from "./test.js";
setList(['a', 'b', 'c']);
</script>

...where test.js exports a named export that lets you tell it what list to use.

(Or of course, it could be a default export.)

Inline script type="module" tags can import, but while they can use export, nothing can make use of the exports they create because they have no useful module specifier.

¹ It's the HTML spec because the form and semantics of module specifiers are left to the host environment by the JavaScript spec (details here). All that the JavaScript spec says about them is that they're string literals.

² It certainly could be, for instance using fragment identifiers. But with HTTP/2 multiplexing making discrete resource loading so fast compared with HTTP/1.1 (and esp. vs. HTTP/1.0), the impetus to make everything contained in a single resource is dramatically lower now than it was some years ago.


问:
Xcode project CMD-Click on symbol to 'Jump to Definition' does not work
I've been using Xcode 4.3.1 since it came out now and I've worked on many different projects since. Everything has always worked fine until this new project I'm working on.

The code completion/code sense never finds anything. When I 'Command+Click' a variable or class normally it would jump to that but now I'm just getting:

Symbol Not Found

The Jump to Definition action is not working.

If I open one of my older project while this bad one is open, the old ones still work for code sense and the new one doesn't.

My partner is working on the same project, we both get the files from our repository and the code sense works on his machine for this project...just not mine.

答: Xcode 10.2.1 - simply closing Xcode entirely and reopening it solved it for me.


问:
How to filter greater than in GraphQL
```<code>type Person {
    firstName: String!,
    lastName: String!,
    age: Int!
}
</code>```

How to query all people what are older than 18?

答:
Graphql will not include these complex filters atleast for
DECADE as graphql is acting to be library.

And libraries become part of other libraries and framework.They don't
become framework

Right now to use graphql to full extend you can combine it with ORM'S
like Hasura Or Graphile Or Prisma

Hasura

```<code>query {
  article(
    where: {rating: {_gte: 4}}
  ) {
    id
    title
    rating
  }
}
</code>```

Prisma

```<code>query {
  posts(where: {
    AND: [{
      title_in: ["My biggest Adventure", "My latest Hobbies"]
    }]
  }) {
    id
    title
  }
}
</code>```

Advice
Do not use graphql directly/independently ,use it with above orm's

Title: How to filter greater than in GraphQL

Body:
type Person {
    firstName: String!,
    lastName: String!,
    age: Int!
}

How to query all people what are older than 18?

Body:
Graphql will not include these complex filters atleast for
DECADE as graphql is acting to be library.

And libraries become part of other libraries and framework.They don't
become framework

Right now to use graphql to full extend you can combine it with ORM'S
like Hasura Or Graphile Or Prisma

Hasura

query {
  article(
    where: {rating: {_gte: 4}}
  ) {
    id
    title
    rating
  }
}

Prisma

query {
  posts(where: {
    AND: [{
      title_in: ["My biggest Adventure", "My latest Hobbies"]
    }]
  }) {
    id
    title
  }
}

Advice
Do not use graphql directly/independently ,use it with above orm's


问:
How to compare otp number without reload page which send in sms?
I want to compare otp numbers, which i type in textbox and sms otp sent to the number through api calling controller in laravel.

i use laravel5.6 and php 7.2.3

```<code> public function otpverify(Request $req)
    {
        $otpenter=$req->txtotp;
        if ($otpenter==$otp)
        {
            return redirect()->action('JaincountController@create')
        }
        else
        {
            return view('jaincount_user/verification');
        }
    }
    public function makeRequest(Request $req)
    {
            $client = new Client();
            $otp=rand(10000,4);
            // $data=
            $data = array('adhar'=>$req->txtadharnumber,'drp'=>$req->drpcode,'mobilenumber'=>$req->txtnumber);

            $response = $client->request('POST','http://192.168.1.9/jaincountapi/public/api/otpsms',[
            'form_params'=>[
                'adharcardnumber'=>$req->txtadharnumber,
                'mobilecode'=>$req->drpcode,
                'mobilenumber'=>$req->txtnumber,
                'otp'=>$otp
            ]
            ]);
            $response = $response->getBody();
            return json_decode($response,true);
    }
</code>```

i want to compare textbox otp number and sms otp number sent through api calling and redirect with another controller in laravel5.6

答:
The thing is you must store your otp in database or in session variable.

(Documentation: https://laravel.com/docs/5.8/eloquent)
You can store otp in database like

```<code>public function makeRequest(Request $req)
{
        $client = new Client();
        $otp=rand(10000,4);
        // $data=
        $data = array('adhar'=>$req->txtadharnumber,'drp'=>$req->drpcode,'mobilenumber'=>$req->txtnumber);

        //CHANGES
        User::where('phone_number',$req->txtnumber)->update(['otp'=>$otp]);

        $response = $client->request('POST','http://192.168.1.9/jaincountapi/public/api/otpsms',[
        'form_params'=>[
            'adharcardnumber'=>$req->txtadharnumber,
            'mobilecode'=>$req->drpcode,
            'mobilenumber'=>$req->txtnumber,
            'otp'=>$otp
        ]
        ]);
        $response = $response->getBody();
        return json_decode($response,true);
}
</code>```

you can retrieve it using eloquent in Laravel using

```<code>public function otpverify(Request $req)
 {
    $otpenter=$req->txtotp;
    //CHANGES
    $otp = User::where('phone_number', $phone_number)->first()->otp;

    if ($otpenter==$otp)
    {
        return redirect()->action('JaincountController@create')
    }
    else
    {
        return view('jaincount_user/verification');
    }
}
</code>```

after entering the correct otp clear that in database.

Or you can use session.you can use session in two ways

1.php default session
2.Laravel Session

let us see php default session
(documentation:https://www.php.net/manual/en/book.session.php)

```<code>public function makeRequest(Request $req)
   {
        $client = new Client();
        $otp=rand(10000,4);
        // $data=
        $data = array('adhar'=>$req->txtadharnumber,'drp'=>$req->drpcode,'mobilenumber'=>$req->txtnumber);

        //CHANGES
        session_start();
        $_SESSION['otp'] = $otp

        $response = $client->request('POST','http://192.168.1.9/jaincountapi/public/api/otpsms',[
        'form_params'=>[
            'adharcardnumber'=>$req->txtadharnumber,
            'mobilecode'=>$req->drpcode,
            'mobilenumber'=>$req->txtnumber,
            'otp'=>$otp
        ]
        ]);
        $response = $response->getBody();
        return json_decode($response,true);
}
</code>```

you can retrieve it by

```<code>public function otpverify(Request $req)
 {
    $otpenter=$req->txtotp;

    //CHANGES
    session_start();
    $otp = $_SESSION['otp']

    if ($otpenter==$otp)
    {
        return redirect()->action('JaincountController@create')
    }
    else
    {
        return view('jaincount_user/verification');
    }
}
</code>```

let us use laravel session
(documentation: https://laravel.com/docs/5.2/session)

```<code>//important
use Illuminate\Support\Facades\Session;

public function makeRequest(Request $req)
   {
        $client = new Client();
        $otp=rand(10000,4);
        // $data=
        $data = array('adhar'=>$req->txtadharnumber,'drp'=>$req->drpcode,'mobilenumber'=>$req->txtnumber);

        //CHANGES
        Session::put('otp',$otp)

        $response = $client->request('POST','http://192.168.1.9/jaincountapi/public/api/otpsms',[
        'form_params'=>[
            'adharcardnumber'=>$req->txtadharnumber,
            'mobilecode'=>$req->drpcode,
            'mobilenumber'=>$req->txtnumber,
            'otp'=>$otp
        ]
        ]);
        $response = $response->getBody();
        return json_decode($response,true);
}
</code>```

you can retrieve it by

```<code>//important
use Illuminate\Support\Facades\Session;

public function otpverify(Request $req)
 {
    $otpenter=$req->txtotp;

    //CHANGES
    $otp = Session::get('otp') //best way to use is flash. see the full documentation

    if ($otpenter==$otp)
    {
        return redirect()->action('JaincountController@create')
    }
    else
    {
        return view('jaincount_user/verification');
    }
}
</code>```

Body:
I want to compare otp numbers, which i type in textbox and sms otp sent to the number through api calling controller in laravel.

i use laravel5.6 and php 7.2.3

 public function otpverify(Request $req)
    {
        $otpenter=$req->txtotp;
        if ($otpenter==$otp)
        {
            return redirect()->action('JaincountController@create')
        }
        else
        {
            return view('jaincount_user/verification');
        }
    }
    public function makeRequest(Request $req)
    {
            $client = new Client();
            $otp=rand(10000,4);
            // $data=
            $data = array('adhar'=>$req->txtadharnumber,'drp'=>$req->drpcode,'mobilenumber'=>$req->txtnumber);

            $response = $client->request('POST','http://192.168.1.9/jaincountapi/public/api/otpsms',[
            'form_params'=>[
                'adharcardnumber'=>$req->txtadharnumber,
                'mobilecode'=>$req->drpcode,
                'mobilenumber'=>$req->txtnumber,
                'otp'=>$otp
            ]
            ]);
            $response = $response->getBody();
            return json_decode($response,true);
    }

i want to compare textbox otp number and sms otp number sent through api calling and redirect with another controller in laravel5.6

Body:
The thing is you must store your otp in database or in session variable.

(Documentation: https://laravel.com/docs/5.8/eloquent)
You can store otp in database like

public function makeRequest(Request $req)
{
        $client = new Client();
        $otp=rand(10000,4);
        // $data=
        $data = array('adhar'=>$req->txtadharnumber,'drp'=>$req->drpcode,'mobilenumber'=>$req->txtnumber);

        //CHANGES
        User::where('phone_number',$req->txtnumber)->update(['otp'=>$otp]);

        $response = $client->request('POST','http://192.168.1.9/jaincountapi/public/api/otpsms',[
        'form_params'=>[
            'adharcardnumber'=>$req->txtadharnumber,
            'mobilecode'=>$req->drpcode,
            'mobilenumber'=>$req->txtnumber,
            'otp'=>$otp
        ]
        ]);
        $response = $response->getBody();
        return json_decode($response,true);
}

you can retrieve it using eloquent in Laravel using

public function otpverify(Request $req)
 {
    $otpenter=$req->txtotp;
    //CHANGES
    $otp = User::where('phone_number', $phone_number)->first()->otp;

    if ($otpenter==$otp)
    {
        return redirect()->action('JaincountController@create')
    }
    else
    {
        return view('jaincount_user/verification');
    }
}

after entering the correct otp clear that in database.

Or you can use session.you can use session in two ways

1.php default session
2.Laravel Session

let us see php default session
(documentation:https://www.php.net/manual/en/book.session.php)

public function makeRequest(Request $req)
   {
        $client = new Client();
        $otp=rand(10000,4);
        // $data=
        $data = array('adhar'=>$req->txtadharnumber,'drp'=>$req->drpcode,'mobilenumber'=>$req->txtnumber);

        //CHANGES
        session_start();
        $_SESSION['otp'] = $otp

        $response = $client->request('POST','http://192.168.1.9/jaincountapi/public/api/otpsms',[
        'form_params'=>[
            'adharcardnumber'=>$req->txtadharnumber,
            'mobilecode'=>$req->drpcode,
            'mobilenumber'=>$req->txtnumber,
            'otp'=>$otp
        ]
        ]);
        $response = $response->getBody();
        return json_decode($response,true);
}

you can retrieve it by

public function otpverify(Request $req)
 {
    $otpenter=$req->txtotp;

    //CHANGES
    session_start();
    $otp = $_SESSION['otp']

    if ($otpenter==$otp)
    {
        return redirect()->action('JaincountController@create')
    }
    else
    {
        return view('jaincount_user/verification');
    }
}

let us use laravel session
(documentation: https://laravel.com/docs/5.2/session)

//important
use Illuminate\Support\Facades\Session;

public function makeRequest(Request $req)
   {
        $client = new Client();
        $otp=rand(10000,4);
        // $data=
        $data = array('adhar'=>$req->txtadharnumber,'drp'=>$req->drpcode,'mobilenumber'=>$req->txtnumber);

        //CHANGES
        Session::put('otp',$otp)

        $response = $client->request('POST','http://192.168.1.9/jaincountapi/public/api/otpsms',[
        'form_params'=>[
            'adharcardnumber'=>$req->txtadharnumber,
            'mobilecode'=>$req->drpcode,
            'mobilenumber'=>$req->txtnumber,
            'otp'=>$otp
        ]
        ]);
        $response = $response->getBody();
        return json_decode($response,true);
}

you can retrieve it by

//important
use Illuminate\Support\Facades\Session;

public function otpverify(Request $req)
 {
    $otpenter=$req->txtotp;

    //CHANGES
    $otp = Session::get('otp') //best way to use is flash. see the full documentation

    if ($otpenter==$otp)
    {
        return redirect()->action('JaincountController@create')
    }
    else
    {
        return view('jaincount_user/verification');
    }
}


问:
How to conditional format a range of cells with a trigger word in one cell?
All of the common answers to this question do not quite cover what I am asking.

I would like to have a row at the top of my spreadsheet where in one cell (eg. A3, B3, C3 etc..) so I can type something like 'Week 1' which will then highlight/fill the colour of the column below that - So I would like to type 'Week 1' in cell B3, which then triggers a colour change in cells B4:B12, regardless of the value in those cells for example.

The trigger has to be me typing something like 'Week 1' or 'Week 2' in a particular column to then highlight the range in that same column.

答:
Select the whole range (in our example A4:A10)

Go to Home - Styles tab - Conditional formatting - New Rule - Format only cells that contain

Change Cell Value to Specific Text

Next to containing write "Week1"

Press Format - Fill and select color - Press OK

Rule:

Results:


问:
Kittens - ambiguous imports (again)
This answer https://stackoverflow.com/a/56366311/2682459 shows how it is possible to use an object to provide a custom implementation of a typeclass when using Kitten. Applying the same principle to the following code though doesn't work:

```<code>package com.xxx.yyy.zzz

import cats._, cats.derived._, cats.implicits._

object Test extends App {

  case class Inner(double: Double)

  case class Outer(inner: Inner, s: String)

  implicit object doubleEq extends Eq[Double] {
    override def eqv(x: Double, y: Double): Boolean = Math.abs(x - y) < 0.1
  }

  implicit val outerEq: Eq[Outer] = {
    import derived.auto.eq._
    derived.semi.eq[Outer]
  }

  implicitly[Eq[Double]]

  val testCC1 = Outer(Inner(1.01d), "BlahBlahBlah")
  val testCC2 = Outer(Inner(1.00d), "BlahBlahBlah")

  println(testCC1 === testCC2)

}
</code>```

The implicitly[Eq[Double]] shows that once again I have ambiguous implicits:

```<code>Error:(20, 13) ambiguous implicit values:
 both value catsKernelStdOrderForDouble in trait DoubleInstances of type => cats.kernel.Order[Double] with cats.kernel.Hash[Double]
 and object doubleEq in object Test of type com.xxx.yyy.zzz.Test.doubleEq.type
 match expected type cats.Eq[Double]
  implicitly[Eq[Double]]
</code>```

How do I work round this one? I really don't want to have to cherry pick the cats implicits I import as this isn't very scalable!

答:
A bit more playing - this seems to give me what I want:</p>

```<code>import cats._
import cats.derived._
import cats.syntax.eq._
import derived.auto.eq._

object CustomImplicits extends cats.instances.AllInstances {
  implicit object doubleEq extends Eq[Double] {
    def eqv(x: Double, y: Double): Boolean = Math.abs(x - y) < 0.1
  }
}

object Test extends App {

  case class Inner(double: Double)

  case class Outer(inner: Inner, s: String)

  import CustomImplicits._

  implicitly[Eq[Double]]

  val testCC1 = Outer(Inner(1.01d), "BlahBlahBlah")
  val testCC2 = Outer(Inner(1.00d), "BlahBlahBlah")
  val testCC3= Outer(Inner(2.00d), "BlahBlahBlah")

  println(testCC1 === testCC2) //True
  println(testCC2 === testCC3) //False

}
</code>```

Title: Kittens - ambiguous imports (again)

Body:
This answer https://stackoverflow.com/a/56366311/2682459 shows how it is possible to use an object to provide a custom implementation of a typeclass when using Kitten. Applying the same principle to the following code though doesn't work:

package com.xxx.yyy.zzz

import cats._, cats.derived._, cats.implicits._

object Test extends App {

  case class Inner(double: Double)

  case class Outer(inner: Inner, s: String)

  implicit object doubleEq extends Eq[Double] {
    override def eqv(x: Double, y: Double): Boolean = Math.abs(x - y) < 0.1
  }

  implicit val outerEq: Eq[Outer] = {
    import derived.auto.eq._
    derived.semi.eq[Outer]
  }

  implicitly[Eq[Double]]

  val testCC1 = Outer(Inner(1.01d), "BlahBlahBlah")
  val testCC2 = Outer(Inner(1.00d), "BlahBlahBlah")

  println(testCC1 === testCC2)

}

The implicitly[Eq[Double]] shows that once again I have ambiguous implicits:

Error:(20, 13) ambiguous implicit values:
 both value catsKernelStdOrderForDouble in trait DoubleInstances of type => cats.kernel.Order[Double] with cats.kernel.Hash[Double]
 and object doubleEq in object Test of type com.xxx.yyy.zzz.Test.doubleEq.type
 match expected type cats.Eq[Double]
  implicitly[Eq[Double]]

How do I work round this one? I really don't want to have to cherry pick the cats implicits I import as this isn't very scalable!

Body:
A bit more playing - this seems to give me what I want:

import cats._
import cats.derived._
import cats.syntax.eq._
import derived.auto.eq._

object CustomImplicits extends cats.instances.AllInstances {
  implicit object doubleEq extends Eq[Double] {
    def eqv(x: Double, y: Double): Boolean = Math.abs(x - y) < 0.1
  }
}

object Test extends App {

  case class Inner(double: Double)

  case class Outer(inner: Inner, s: String)

  import CustomImplicits._

  implicitly[Eq[Double]]

  val testCC1 = Outer(Inner(1.01d), "BlahBlahBlah")
  val testCC2 = Outer(Inner(1.00d), "BlahBlahBlah")
  val testCC3= Outer(Inner(2.00d), "BlahBlahBlah")

  println(testCC1 === testCC2) //True
  println(testCC2 === testCC3) //False

}


问:
AWS Cloudformation creates task definition with no container definition
The following CloudFormation script creates a task definition but does not seem to create the container definition correctly. Can anyone tell me why?

```<code>{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "Test stack for troubleshooting task creation",
"Parameters": {
    "TaskFamily": {
        "Description": "The task family to associate the task definition with.",
        "Type": "String",
        "Default": "Dm-Testing"
    }
},
"Resources": {
    "TaskDefinition": {
        "Type": "AWS::ECS::TaskDefinition",
        "Properties": {
            "Family": {
                "Ref": "TaskFamily"
            },
            "RequiresCompatibilities": [
                "EC2"
            ],
            "ContainerDefinitions": [
                {
                    "Name": "sample-app",
                    "Image": "nginx",
                    "Memory": 200,
                    "Cpu": 10,
                    "Essential": true,
                    "Environment": [
                        {
                            "Name": "SOME_ENV_VARIABLE",
                            "Value": "SOME_VALUE"
                        }
                    ]
                }
            ]
        }
    }
}
}
</code>```

When I view the created task, there is no container listed in the builder view of task definition in aws.

The information is listed, however, under the json tab of the task definition:

Note that the above image is a subset of the info shown, not all of it.

The result of this is that, when the task is run in a cluster, it does run the image, but runs it without the environment variables applied. In addition, CF does not report any errors when creating this stack, or when running the created task.

Finally, the CloudFormation script is a cut down example of the 'real' script which has started exhibiting this same issue. That script has been working fine for around a year now, and, as far as I can see, there have been no changes to the script between it working and breaking.

I would greatly appreciate any thoughts or suggestions on this because my face is beginning to hurt from smashing it against this particular wall.

答: Turns out this was a bug in cloudformation that only occurred when creating a task definition using a script through the aws console. Amazon have now resolved this. </p>

Body:
The following CloudFormation script creates a task definition but does not seem to create the container definition correctly. Can anyone tell me why?

{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "Test stack for troubleshooting task creation",
"Parameters": {
    "TaskFamily": {
        "Description": "The task family to associate the task definition with.",
        "Type": "String",
        "Default": "Dm-Testing"
    }
},
"Resources": {
    "TaskDefinition": {
        "Type": "AWS::ECS::TaskDefinition",
        "Properties": {
            "Family": {
                "Ref": "TaskFamily"
            },
            "RequiresCompatibilities": [
                "EC2"
            ],
            "ContainerDefinitions": [
                {
                    "Name": "sample-app",
                    "Image": "nginx",
                    "Memory": 200,
                    "Cpu": 10,
                    "Essential": true,
                    "Environment": [
                        {
                            "Name": "SOME_ENV_VARIABLE",
                            "Value": "SOME_VALUE"
                        }
                    ]
                }
            ]
        }
    }
}
}

When I view the created task, there is no container listed in the builder view of task definition in aws.

The information is listed, however, under the json tab of the task definition:

Note that the above image is a subset of the info shown, not all of it.

The result of this is that, when the task is run in a cluster, it does run the image, but runs it without the environment variables applied. In addition, CF does not report any errors when creating this stack, or when running the created task.

Finally, the CloudFormation script is a cut down example of the 'real' script which has started exhibiting this same issue. That script has been working fine for around a year now, and, as far as I can see, there have been no changes to the script between it working and breaking.

I would greatly appreciate any thoughts or suggestions on this because my face is beginning to hurt from smashing it against this particular wall.


问:
Unable to get focus on Textbox when bootstrap modal popup opens
Hii I want to get focus on input textbox when the bootstrap modal popup opens

```<code><div class="modal fade nopading" id="myModalpop" role="dialog">
    <div class="model-area">

        <!-- Modal content-->
        <div class="modal-content">
            <div class="modal-head">
                <a class="navbar-brand" href="index.html"><img src="~/Content/images/logo.png" alt="Ova" style="float: left; padding-top: 10px;"></a>
                <form class="form-inline md-form form-sm mt-0" style="text-align: center;" method="get" action="@Url.Action("Review", "Product")">
                    <a href"#"><i class="fa fa-search" aria-hidden="true"></i></a>
                    <input name="id" class="form-contro form-control-sm ml-3 w-75 wow fadeInRight animated" id="txtsearch"  type="text" placeholder="Search" aria-label="Search">
                </form>
                <button type="button" class="close" data-dismiss="modal">×</button>

            </div>
            <div class="modal-body" style="padding: 0px;">
                @*<p class="links_p wow fadeInRight animated">QUICK LINKS</p>*@

            </div>

        </div>
    </div>

</div><!-- end navbar-cell -->
</code>```

I have applied javascript

```<code><script type="text/javascript">
$(document).ready(function () {

    $('#myModalpop').on('show.bs.modal', function () {

        $('#txtsearch').focus;
        //$(this).find('#txtsearch').focus();
     });
});
</script>
</code>```

Focus on textbox

答:
Called with selected popup id. </p>

```<code>$('#myModalpop #txtsearch').focus();
</code>```

Body:
Hii I want to get focus on input textbox when the bootstrap modal popup opens

                <form class="form-inline md-form form-sm mt-0" style="text-align: center;" method="get" action="@Url.Action("Review", "Product")">

                    <input name="id" class="form-contro form-control-sm ml-3 w-75 wow fadeInRight animated" id="txtsearch"  type="text" placeholder="Search" aria-label="Search">
                </form>
                <button type="button" class="close" data-dismiss="modal">×</button>

                @*
QUICK LINKS
*@

I have applied javascript

Focus on textbox

Body:
Called with selected popup id.

$('#myModalpop #txtsearch').focus();


问:
out = [item for t in lt for item in t] how this will get executed
out = [item for t in lt for item in t], how this loop will get executed, please elaborate this  as I am a beginner in python so I am having difficulty to understand this concept

```<code> lt = [('Geeks', 2), ('For', 4), ('geek', '6')]

 out = [item for t in lt for item in t]

 print(out)
</code>```

答:
Let's go step by step by order of the process:

It will first iterate through the list called lt

Then, iterate through the t which is every value in lt, it's a nested loop right now,

[('Geeks', 2), ('For', 4), ('geek', '6')]

```<code>       t             t            t

  item   item   item   item  item   item
</code>```

And then, we finally at the end return every item, which results into 6 elements in the list.

Body:
out = [item for t in lt for item in t], how this loop will get executed, please elaborate this  as I am a beginner in python so I am having difficulty to understand this concept

 lt = [('Geeks', 2), ('For', 4), ('geek', '6')]

 out = [item for t in lt for item in t]

 print(out)

Body:
Let's go step by step by order of the process:

It will first iterate through the list called lt

Then, iterate through the t which is every value in lt, it's a nested loop right now,

[('Geeks', 2), ('For', 4), ('geek', '6')]

       t             t            t

  item   item   item   item  item   item

And then, we finally at the end return every item, which results into 6 elements in the list.


问:
Changing diameter of Angular material spinner breaks it
This is my code

```<code><mat-progress-spinner  [diameter]="50" mode="indeterminate" ></mat-progress-spinner>
</code>```

If i remove the diameter it will work properly but if i add diameter it will just show up as a circle and not spin.

Is there a way to resize it to make it smaller?

答:
If you can't get the "[diameter]" property to function correctly, you can always alternative set the height and width separate</p>

```<code><mat-spinner style="width:40px; height: 40px" color="primary"> </mat-spinner>
</code>```

Body:
This is my code

<mat-progress-spinner  [diameter]="50" mode="indeterminate" ></mat-progress-spinner>

If i remove the diameter it will work properly but if i add diameter it will just show up as a circle and not spin.

Is there a way to resize it to make it smaller?

Body:
If you can't get the "[diameter]" property to function correctly, you can always alternative set the height and width separate

<mat-spinner style="width:40px; height: 40px" color="primary"> </mat-spinner>


问:
How to get the selected value of a select option?
I would like to get the selected value of a select option in Angular 7. Two-way data binding using ngModel and I also imported FormsModule in app.module.ts.

My HTML file:

```<code><select (change)="selectChangeHandler($event)"
[(ngModel)]="optSelected">
 <option *ngFor="let opt of options" [value]="opt.id">
{{opt.title}}
</option>
</select>
</code>```

My TS file:

```<code>optSelected = 'aaa';
selectChangeHandler(event: any) {
  this.optSelected = event.target.value;
  console.log('The selected option is: ' + this.optSelected);
}
</code>```

答:
Since you are using ngModel/two-way data binding, instead of using the change event, you can simply make use of the ngModelChange event binding. According to the documentation, it is the

Event emitter for producing the ngModelChange event after the view
  model updates.

```<code><select (ngModelChange)="selectChangeHandler($event)" [(ngModel)]="optSelected">
  <option *ngFor="let opt of options" [value]="opt.id">
    {{opt.title}}
  </option>
</select>
</code>```

And on your component.ts,

```<code>selectChangeHandler() {
  console.log(this.optSelected);
}
</code>```

Body:
I would like to get the selected value of a select option in Angular 7. Two-way data binding using ngModel and I also imported FormsModule in app.module.ts.

My HTML file:

<select (change)="selectChangeHandler($event)"
[(ngModel)]="optSelected">
 <option *ngFor="let opt of options" [value]="opt.id">
{{opt.title}}
</option>
</select>

My TS file:

optSelected = 'aaa';
selectChangeHandler(event: any) {
  this.optSelected = event.target.value;
  console.log('The selected option is: ' + this.optSelected);
}

Body:
Since you are using ngModel/two-way data binding, instead of using the change event, you can simply make use of the ngModelChange event binding. According to the documentation, it is the

Event emitter for producing the ngModelChange event after the view
  model updates.

<select (ngModelChange)="selectChangeHandler($event)" [(ngModel)]="optSelected">
  <option *ngFor="let opt of options" [value]="opt.id">
    {{opt.title}}
  </option>
</select>

And on your component.ts,

selectChangeHandler() {
  console.log(this.optSelected);
}


答:
You can't export JS from HTML. You can import it however, using the type="module" attribute on the
```

Title: Import js from script tag in HTML file. Possible?

Body:
I want to access data from script tag in html file, produced by cms.
Is it possible to do this without polluting global namespace?
I've tried to use es6 modules but I've failed and I couldn't find any info about it.

    //test.js
    import list from './index.html'

Error:
'http://localhost:8080/index.html net::ERR_ABORTED 404'
or:
'Failed to load module script: The server responded with a non-JavaScript MIME type of "text/html". Strict MIME type checking is enforced for module scripts per HTML spec.'

Body:
You can't export JS from HTML. You can import it however, using the type="module" attribute on the <script> tag:

<script type="module">
  import list from "./test.js";
  //Use list
</script>