text:
Q: Is there a class of Bell inequalities that are violated by certain mixtures of known orthogonal entangled states? Is there a class of Bell inequalities that are violated by certain mixtures of known orthogonal entangled states?
There exist a multitude of classes of Bell inequalities that can be used in conjunction with the corresponding experimental designs.
Bell inequalities from no-signalling distributions.
All the Bell inequalities.
We will consider the  following entangled states (Bell states):
$\Phi^+=\frac{1}{\sqrt{2}}(\vert 00\rangle+\vert 11\rangle)$
$\Phi^-=\frac{1}{\sqrt{2}}(\vert 00\rangle-\vert 11\rangle)$
$\Psi^+=\frac{1}{\sqrt{2}}(\vert 01\rangle+\vert 10\rangle)$
$\Psi^-=\frac{1}{\sqrt{2}}(\vert 01\rangle-\vert 10\rangle)$
Alice and Bob measure their photons using coincidence circuits and can perform a statistical analysis on the outcome of their measurements. They choose a class of Bell inequalities to analyze as well as the corresponding experimental setup (the Bell test experiment ) in order to assess whether the chosen inequalities are violated (in order to prove the presence of quantum entanglement ).
Case 1. The source sends Alice and Bob only entangled pairs in the state $\Phi^+$ . In this case  it is known that there is a class of Bell inequalities and Bell test experiments that shows the violation of these inequalities.  That goes back to Bell's work. Similar results are valid if the source sends only entangled pairs in any of the other Bell states  $\Phi^-$ , $\Psi^+$ , or  $\Psi^-$ .
Case 2. The source sends Alice and Bob entangled pairs in the state $\Phi^+$  with probability $\alpha$, or in the state  $\Phi^-$  with probability  $\beta$ ,  or in the state $\Psi^+$  with probability  $  \gamma$, or in the state  $\Psi^-$  with probability  $\delta$  , where $\alpha + \beta + \gamma + \delta  = 1$.  In this case  is there a class of Bell inequalities and Bell test experiments that shows the violation of these inequalities ?  Also for what range of the parameters $\alpha$ , $\beta$ , $\gamma$  , and  $\delta$  is this possible?
Question. In other words, can Alice and Bob prove the presence of quantum entanglement (correlations ) when they receive a mixture of known orthogonal entangled states? And for what range of the parameters?
Clearly for $\alpha = 1$  and $\beta = \gamma = \delta = 0$ this is possible  (this is case 1).
........................................
Justification for this question. In the following  I will describe the reason/motivation  behind this question.  This part is independent of the question itself but it is worth mentioning. It doesn't obscure the clarity of the question above.
Delayed choice entanglement swapping.
Two pairs of entangled photons are produced, and one photon from each pair is sent to a party called Victor. Of the two remaining photons, one photon is sent to the party Alice and one is sent to the party Bob. Victor can now choose between two kinds of measurements. If he decides to measure his two photons in a way such that they are forced to be in an entangled state, then also Alice's and Bob's photon pair becomes entangled.
If Victor chooses to measure his particles individually, Alice's and Bob's photon pair ends up in a separable state. Modern quantum optics technology allows to delay Victor's choice and measurement with respect to the measurements which Alice and Bob perform on their photons.  Whether Alice's and Bob's photons are entangled and show quantum correlations or are separable and show classical correlations can be decided after they have been measured.
We follow the calculations in the reference.
Two pairs of entangled photons (1&2 and 3&4) are each produced in the antisymmetric polarization entangled Bell singlet state such that the total four photon state has the form:
$$\vert \Psi\rangle_{1234}=\vert \Psi^-\rangle_{12}\otimes\vert\Psi^-\rangle_{34}$$
In short, we write:
$$\vert \Psi\rangle_{1234}=\Psi^-_{12}\otimes\Psi^-_{34}$$
If Victor subjects his photons 2 and 3 to a Bell state measurement, they become entangled. Consequently photons 1 (Alice) and 4 (Bob) also become entangled, and entanglement swapping is achieved. This can be seen by writing $\vert \Psi\rangle_{1234}$ in the basis of Bell states of photons 2 and 3.
$$\vert\Psi\rangle_{1234}=\frac{1}{2}(\Psi^+_{14}\otimes\Psi^+_{23}-\Psi^-_{14}\otimes\Psi^-_{23}-\Phi^+_{14}\otimes\Phi^+_{23}+\Phi^-_{14}\otimes\Phi^-_{23})$$
This is relation (2) in the paper linked above.
In order to see the correlations between their particles, Alice and Bob must compare their coincidence records with Victor. Without comparing with Victor's records, they only see a perfect mixture of anti-correlated (the  Ψ's) and correlated (the Φ's) photons, no pattern whatsoever.
There is though another way based on statistics and a reliable entanglement witness.
When Victor entangles his photons 2 and 3,  photons 1 and 4 are in a mixture of entangled states. We consider the transmitter (Victor) and the receiver (Alice and Bob) follow an agreed protocol. For each bit of information transferred (0/1),  a certain number  KN of pairs of photons are measured by both Victor and  corespondingly by Alice/Bob. When he wants to send a 0, Victor does not entangle his photons. When he wants to send a 1, Victor entangles his photons. In order to decode the message Alice and Bob need a reliable procedure of entanglement detection . And they don't need to compare their records with Victor.
In the paper above it is discussed witnessing entanglement without entanglement witness operators.  The method  involves measuring the statistical response of a quantum system to an arbitrary nonlocal  parametric evolution. The witness of entanglement is solely based on the visibility of an interference signal. If followed closely, this method never gives false positives.
In the protocol described , when Victor (the transmitter) and Alice and Bob (the receiver) measure N pairs of photons, then  with probability $\frac{1}{4^N}$  all the N photon pairs measured by Alice and Bob will be in the same Bell state. So the transmitter and receiver can repeat measuring N pairs of photons (lets say K times) until the entanglement detection method described above will give a positive. At this point Alice and Bob know that Victor must be entangling his photons.  When Victor does not entangle his photons, since the method of entanglement detection  mentioned above does not give false positives, Alice and Bob will know that Victor does not entangle his photons for all the KN pairs of photons processed. For large N and K, the probability of error can be made arbitrarily small.  Basically, without comparing records, Alice and Bob know what Victor is doing. That's signalling,  and the no - signalling theorem can be circumvented due to the method of entanglement detection described above, which does not rely on witness operators.
In principle the problem seems to allow a solution.  Reliable entanglement detection seems to circumvent the no - signalling theorem.
Secondary question. Could a reliable entanglement detection procedure (as described above,  and the associated protocol ) be used for signalling in delayed choice entanglement swapping ?

A: Figure 1 of
https://iopscience.iop.org/article/10.1088/1751-8121/aa5dfd/meta
has a nice visualization of all Wely states. All mixed states generated by randomly choosing a bell state are Wely states.
The figure shows the region which can violate the CHSH-Bell inequality and the region of separable states, where no Bell inequality can be violated.
I'm aware that this is not the full solution, but gives you at least some bounds on the full solution.


text:
Q: CKFinder 3 - browser is blank Im using CKFinder 3 integrated with CKEditor 4.
I can upload an image without issue, but when clicking 'browse' I see a blank pop up. I have turned error reporting on but nothing is shown.

Code
<script>
CKEDITOR.replace( 'editor',
{

filebrowserImageBrowseUrl : 'ckeditor/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Files',
filebrowserFlashBrowseUrl : 'ckeditor/ckfinder/ckfinder.html?type=Flash',
});
</script>

A: What do you mean by integrated with CKE4?
The sample below shows the configuration code that can be used to insert a CKEditor 4 instance with CKFinder integrated. The browse and upload paths for images are configured separately from CKFinder default paths.
CKEDITOR.replace('editor1',
{
    filebrowserBrowseUrl: '/ckfinder/ckfinder.html',
    filebrowserImageBrowseUrl: '/ckfinder/ckfinder.html?type=Images',
    filebrowserUploadUrl: '/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Files',
    filebrowserImageUploadUrl: '/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Images'
});

Remember to change the /ckfinder/ path in the above URLs if you installed CKFinder in a different location.
Note: The filebrowser*UploadUrl paths in CKFinder 2.x and CKFinder 3.x are different.
What are the plugins that you are using?
Open your browser console to see if there is any error in there. You can press F12 in your browser and click on the console tab.
Also enable

redpajama_set_name: RedPajamaStackExchange


text:
Q: mathematica, picking our linear terms from an equation so I'm trying to pick out the linear terms in an expression - for example if I say

eqn = dy/dt + y == y^2

, dy/dt+y is linear and y^2 is non linear.
I know in this case I can just use
eqn[[1]] to pull out the lhs and have that be my linear terms, but is there some way I can use a string pattern or something to get the linear parts of any entered equation?

A: This is some quick solution I came up with. You may need to change this for your purposes, but maybe it is a possibility. First the terms are converted into a string. This is then searched for "+" or "-" and separated. The individual terms are tested for linearity.
terms = y + y^2 - Sqrt[y];
string = ToString[terms, InputForm];
split = StringSplit[string, {"+", "-"}];

Do[
 (*Take term i and convert the string to an expression*)

 exp = ToExpression[split[[i]]];
 Print[exp];

 (*Test for Additivity: f(x+y)= f(x)+f(y)*)

 pexp = exp /. {y -> y + c};(*f(x+y)*)
 cexp = exp /. {y -> c};(*f(y)*)
 test1 = pexp - (exp + cexp) // Simplify;(*f(x+y)-(f(x)+f(y))*)

 (*Test for Homogeneity: f(a*x) = a*f(x)*)

 aexp = exp /. {y -> a*y};(*f(a*x)*)
 test2 = a*exp - aexp // Simplify;(*a*f(x)-f(a*x)*)

 If[test1 == 0 && test2 == 0,
  Print["linear"]]
 , {i, 1, Length[split]}]


text:
Q: Whitespace in filenames in shell script I have a shell script that processes some files.  The problem is that there might be white spaces in file names, I did:
#!/bin/sh
FILE=`echo $FILE | sed -e 's/[[:space:]]/\\ /g'`
cat $FILE

So the variable FILE is a file name which is passed in from some other program.  It may contain white spaces.  I used sed to escape white space with \ in order to make the command line utilities be able to process it.
The problem is that it doesn't work.  echo $FILE | sed -e 's/[[:space:]]/\\ /g' itself works as expected, but when assigned to FILE, the escape char \ disappeared again. As a result, cat will interpret it as more than 1 arguments.  I wonder why it behaves like this?  Is there anyway to avoid it?  And what if there're multiple white spaces, say some   terrible  file.txt, which should be replaced by some\ \ \ terrible\ \ file.txt. Thanks.

A: Don't try to put escape characters inside your data -- they're only honored as syntax (that is, backslashes have meaning when found in your source code, not your data).
That is to say, the following works perfectly, exactly as given:
file='some   terrible  file.txt'
cat "$file"

...likewise if the name comes from a glob result or similar:
# this operates in a temporary directory to not change the filesystem you're running it in
tempdir=$(mktemp -d "${TMPDIR:-/tmp}/testdir.XXXXXX") && (
  cd "$tempdir" || exit
  echo 'example' >'some  terrible  file.txt'
  for file in *.txt; do
    printf 'Found file %q with the following contents:\n' "$file"
    cat "$file"
  done
  rm -rf "$tempdir"
)

A: Don't make it more complicated than it is.
cat "$FILE"

That's all you need. Note the quotes around the variable. They prevent the variable from being expanded and split at whitespace. You should always write your shell programs like that. Always put quotes around all your variables, unless you really want the shell to expand them.
for i in $pattern; do

That would be ok.


text:
Q: how do you download your repo as a file directory I am trying to download a private git repo.
when I do git clone https://<DEV_USER>:<DEV_PWD>@github.<corpName>.net/Svcs/repo.git
it works!
But I dont really need all the git history. I just need the repo as a file directory. Hence I was trying to archive.
git archive --remote=<DEV_USR>:<DEV_PWD>@github.<corpName>.net:Svcs/repo.git
I get the following error
Could not resolve hostname <DEV_USER>: nodename nor servname provided, or not known
fatal: The remote end hung up unexpectedly

A: The URL is incorrect:

*

*if you use an SSH one, you would not use your GitHub Enterprise login pasword, but git@github.<corpName>.net:Svcs/repo.git (and your SSH keys would be enough to authenticate you)

*if you use your credentials (login/password <DEV_USR>:<DEV_PWD>) then use an HTTPS URL https://<DEV_USR>:<DEV_PWD>@github.<corpName>.net/Svcs/repo.git


text:
Q: Cannot use requests library when external proxy is enabled I am try to access a site that is restricted to region using a VPN. The proxy works fine in browser but when proxy is enabled and I try to send request using
headers = {
        'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36 Edg/100.0.1185.50',
    }

data = {
        'courtType': '',
        'countyCode': '',
        'cortCode': 'SW',
        'caseNumber': '22SL-PR00157',
    }

res = requests.post('https://www.courts.mo.gov/cnet/caseNoSearch.do', data=data, headers=headers)

I get following error
requests.exceptions.ProxyError: HTTPSConnectionPool(host='www.courts.mo.gov', port=443): Max retries exceeded with url: /cnet/caseNoSearch.do (Caused by ProxyError('Your proxy appears to only use HTTP and not HTTPS, try changing your proxy URL to be HTTP. See: https://urllib3.readthedocs.io/en/1.26.x/advanced-usage.html#https-proxy-error-http-proxy', SSLError(SSLError(1, '[SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1124)'))))

Is there any way I can send requests enabling VPN?


text:
Q: Display an arraylist as a String I have created an arraylist that is filled with records from a database table. When I go to display the contents of the arraylist, the output is not readable. How could I correct this? Thanks in advance.
Output

[arraylistTest.Main@6433a2, arraylistTest.Main@110e440]

package arraylistTest;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.Arrays;

public class Main {

 public static void main(String[] args) throws SQLException, ClassNotFoundException {
   Connection con = null;
         Class.forName("com.mysql.jdbc.Driver");
    con = DriverManager.getConnection("jdbc:mysql://localhost/books", "user", "peter");
      Statement stm;
      stm = con.createStatement();
      String sql = "Select Date from abooked";
      ResultSet rst;
      rst = stm.executeQuery(sql);
      ArrayList<Main> dates = new ArrayList<>();
      while (rst.next()) {
          Main list = new Main();
          dates.add(list);
      }

      System.out.println(dates);

 }
}

UPDATE. COMPLETED.
Main.java

package query;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import org.json.simple.JSONObject;
import object.Dates;

public class ReadQuery {
  // static StudentPojo sPojo;
  /**
   * @param args
   */
  public static void main(String[] args) {
    Connection con = null;
    Statement st = null;
    ResultSet rs = null;
    String dbName = "Booking";
    String uname = "";
    String pwd = "";
    String url = "jdbc:mysql://localhost:3306/" + dbName;

    try {
      Class.forName("com.mysql.jdbc.Driver").newInstance();
      con = DriverManager.getConnection(url, uname, pwd);
      System.out.println("Connection Established: " + con);
      String qry = "select bookedDate from appointment_booked";

      st = con.createStatement();
      rs = st.executeQuery(qry);

      JSONObject jObj = new JSONObject();
      ArrayList < Dates > list = new ArrayList < Dates > ();
      Map < String, String > map = new HashMap < String, String > ();
      Dates sPojo = null;
      while (rs.next()) {
        sPojo = new Dates();

        sPojo.setDates(rs.getString("booked"));
        list.add(sPojo);

      }
      System.out.println(list);

      jObj.put("dates", list);

      System.out.println(jObj.toString());

    } catch (Exception e) {
      e.printStackTrace();
    }

  }

}

Dates.java

package object;

public class Dates {

 private String dates;

 public Dates() {

 }

 public String getDates() {
  return dates;
 }

 public void setDates(String dates) {
  this.dates = dates;
 }

 @Override
   public String toString() {
     return dates;
   }

}

A: The list you are printing has two Main objects, however you haven't overridden the toString() for this class so you get the default implementation which is the class name + '@' + the hashCode() of the object.
If you want a different toString() you need to provide an overridden method.
e.g
public String toString() {
    return /* how I want Main to be printed */;
}

My guess is you dodn't actually want to add Main objects to the list, but instead you should be adding the Dates you get back from the database. e.g.
dates.add(rst.getTimestamp(1));

A: Overriding toString method will help. For example:
public String toString(){
    return "Main"; //Give some useful value here
}

A: Lets say in your Main class you have 2 fields and getters and setters for fields:
public class Main{

private String name;
private int number;

public String getName() {
    return name;
}
public void setName(String name) {
    this.name = name;
}
public int getNumber() {
    return number;
}
public void setNumber(int number) {
    this.number = number;
}
}

Now you just need to override toString() method inside the same class:
@Override
public String toString() {
    return "Main [name=" + name + ", number=" + number + "]";
}


text:
Q: How can this Ruby code be translated to Redis command line? results=$redis.zrevrangebyscore(key(:feed), "(#{max}", "-inf", :limit => [0, limit], :with_scores => scores)

and
results=$redis.zrevrange key(:feed), 0, count

What would these look like in redis-cli command line?

A: ZREVRANGEBYSCORE 'key(feed)' 'max' -inf WITHSCORES limit 0 'limit'
ZREVRANGE 'key(feed)' 0 'count'


text:
Q: Use Python string repr for object type check in decorator? I've written a logging decorator that logs the time a specific function takes to execute, along with some other information. I'd like to add to that specific information some things based upon input arguments.  So I've written this little chunk of code:
for var in args:
    if repr(type(var)) == '<class \'django.contrib.auth.models.User\'>':
        user_id = var.id
    elif repr(type(var)) == '<class \'someclass.models.Widget\'>':
        event_name = method.__name__ + ':' + var.key

It seems clunky, but the other option is to inherit django.contrib.auth.models.user and  someclass.models.Widget into the file.  My question is whether the way I've done it is right, the inheritance approach is right, or if I've missed something.

A: This is the dumb way to do this.  The smart way is:
for var in args:
    if type(var) == models.User:
        user_id = var.id
    elif type(var) == models.Widget:
        event_name = method.__name__ + ':' + var.key

And to inherit the appropriate sources for the models.
If you want your decorator to be more efficient and end up inheriting a ton of classes, it would make sense to instead have a primary abstract class and several subclasses.


text:
Q: Invalid attempt to destruction non-iterable instance with useState for conditional rendering Been banging on this for about 4 hours, literally. I keep getting the error:
Invalid attempt to destructure non-iterable instance. In order to be iterable, non-array objects must have a [Symbol.iterator]() method.

I am trying to conditionally render components based on whether or not a user is logged in. Here is my code
const App = () => {
  const [isLoggedIn, setIsLoggedIn] = React.useState(false);
  const AppBody = () => {
    return (
      <NavigationContainer>
        <Stack.Navigator>
          {isLoggedIn ? (
            <Stack.Screen
              name="Initiation"
              component={Initiation}
              options={{headerShown: false}}
            />
          ) : (
            <>
              <Stack.Screen
                name="Activities"
                component={Activities}
                options={{headerShown: false}}
              />
              <Stack.Screen
                name="Messages"
                component={Messages}
                options={{headerShown: false}}
              />
              <Stack.Screen
                name="Persona"
                component={Persona}
                options={{headerShown: false}}
              />
            </>
          )}
        </Stack.Navigator>
      </NavigationContainer>
    );
  };

  React.useEffect(() => {
    AppBody();
  }, [isLoggedIn]);

  return <AppBody />;
};

export default App;

This logic was rendering fine until today when I started getting the error above. I have tried several different solutions, including returning the conditional logic straight in App.js body instead of the AppBody.js body, and I have also tried reordering the code several times over.
At this point, I know I am missing something in plain sight. I am just at a loss for what it is.
EXTRA
xCode 12.4
React-Native 0.63
ERROR STACK
This error is located at:
    in Activities (at SceneView.tsx:122)
    in StaticContainer
    in StaticContainer (at SceneView.tsx:115)
    in EnsureSingleNavigator (at SceneView.tsx:114)
    in SceneView (at useDescriptors.tsx:153)
    in RCTView (at View.js:34)
    in View (at CardContainer.tsx:245)
    in RCTView (at View.js:34)
    in View (at CardContainer.tsx:244)
    in RCTView (at View.js:34)
    in View (at CardSheet.tsx:33)
    in ForwardRef(CardSheet) (at Card.tsx:573)
    in RCTView (at View.js:34)
    in View (at createAnimatedComponent.js:165)
    in AnimatedComponent (at createAnimatedComponent.js:215)
    in ForwardRef(AnimatedComponentWrapper) (at Card.tsx:555)
    in PanGestureHandler (at GestureHandlerNative.tsx:13)
    in PanGestureHandler (at Card.tsx:549)
    in RCTView (at View.js:34)
    in View (at createAnimatedComponent.js:165)
    in AnimatedComponent (at createAnimatedComponent.js:215)
    in ForwardRef(AnimatedComponentWrapper) (at Card.tsx:544)
    in RCTView (at View.js:34)
    in View (at Card.tsx:538)
    in Card (at CardContainer.tsx:206)
    in CardContainer (at CardStack.tsx:620)
    in RCTView (at View.js:34)
    in View (at Screens.tsx:84)
    in MaybeScreen (at CardStack.tsx:613)
    in RCTView (at View.js:34)
    in View (at Screens.tsx:54)
    in MaybeScreenContainer (at CardStack.tsx:495)
    in CardStack (at StackView.tsx:462)
    in KeyboardManager (at StackView.tsx:458)
    in RNCSafeAreaProvider (at SafeAreaContext.tsx:74)
    in SafeAreaProvider (at SafeAreaProviderCompat.tsx:42)
    in SafeAreaProviderCompat (at StackView.tsx:455)
    in RCTView (at View.js:34)
    in View (at StackView.tsx:454)
    in StackView (at createStackNavigator.tsx:87)
    in StackNavigator (at App.js:24)
    in EnsureSingleNavigator (at BaseNavigationContainer.tsx:409)
    in ForwardRef(BaseNavigationContainer) (at NavigationContainer.tsx:91)
    in ThemeProvider (at NavigationContainer.tsx:90)
    in ForwardRef(NavigationContainer) (at App.js:23)
    in AppBody (at App.js:59)
    in App (at renderApplication.js:45)
    in RCTView (at View.js:34)
    in View (at AppContainer.js:106)
    in RCTView (at View.js:34)
    in View (at AppContainer.js:132)
    in AppContainer (at renderApplication.js:39)

A: The error was in my activities file. I had an object I was destructuring that looked like:
const [var1, var2] = {
    key: value
};

I stupidly left this code unfinished and did not know it was causing the error because I did not read the error stack. I spent 4 hours tweaking the wrong file. Lesson - always read the error stack.

A: The error you are mentioning is not happening in this component, could you please paste the error stack?


text:
Q: How to open a new tab in a browser using robot framework How to open a new tab in a browser using robot framework
Open Browser    https://www.google.com/    chrome
Press Key    id=identifierId    \\20
Maximize Browser Window

my code trying to press Ctrl+T.
the test is passing but the new tab is not opening.


text:
Q: Adding Delay to looping in CSS animation I have been trying (how make a looped animation wait using css3 and CSS Animation Delay in Between Loop ) to have some delay before my css animation restarting and yet to have any result.
I am new to CSS and hope you can suggest me some pointers.
The following is some CSS code (for my website, you may go to http://iwaterhealth.com/)
i {
    font-style: normal;
    padding: 0 0.25em;
    -webkit-transform: scale(0) translate3d(0, -2000px, 0);
       -moz-transform: scale(0) translate3d(0, -2000px, 0);
        -ms-transform: scale(0) translate3d(0, -2000px, 0);
         -o-transform: scale(0) translate3d(0, -2000px, 0);
            transform: scale(0) translate3d(0, -2000px, 0);
    background: rgba(255, 255, 255, 0.3);
    border-radius: 50%;
}
i.fly-in-out {
    -webkit-animation: fly-in-out 3s infinite ease-in-out 4s;
       -moz-animation: fly-in-out 3s infinite ease-in-out 4s;
         -o-animation: fly-in-out 3s infinite ease-in-out 4s;
            animation: fly-in-out 3s infinite ease-in-out 4s;
}

@keyframes fly-in-out {
    0% {
        transform: scale(0) translate3d(0, -2000px, 0);
        background: rgba(255, 255, 255, 0.3);
        box-shadow: 0 0 100px 100px rgba(255, 255, 255, 0.2);
        border-radius: 50%;
    }
    15%, 85% {
        color: rgba(255, 255, 255, 0.8);
        text-shadow: 0 0 5px rgba(255, 255, 255, 0.5);
        transform: scale(1) translate3d(0, 0, 0);
        background: transparent;
        box-shadow: none;
    }
    100% {
        color: transparent;
        transform: scale(0) translate3d(0, 2000px, 0);
        background: rgba(255, 255, 255, 0.3);
        box-shadow: 0 0 100px 100px rgba(255, 255, 255, 0.2);
        border-radius: 50%;
    }
}

A: try it as this syntax of animation
i {
        font-style: normal;
        padding: 0 0.25em;
        -webkit-transform: scale(0) translate3d(0, -2000px, 0);
           -moz-transform: scale(0) translate3d(0, -2000px, 0);
            -ms-transform: scale(0) translate3d(0, -2000px, 0);
             -o-transform: scale(0) translate3d(0, -2000px, 0);
                transform: scale(0) translate3d(0, -2000px, 0);
        background: rgba(255, 255, 255, 0.3);
        border-radius: 50%;
    }
    i.fly-in-out {
        -webkit-animation: fly-in-out 3s ease-in-out 8s infinite;
           -moz-animation: fly-in-out 3s ease-in-out 8s infinite;
             -o-animation: fly-in-out 3s ease-in-out 8s infinite;
                animation: fly-in-out 3s ease-in-out 8s infinite;
    }

    @keyframes fly-in-out {
        0% {
            transform: scale(0) translate3d(0, -2000px, 0);
            background: rgba(255, 255, 255, 0.3);
            box-shadow: 0 0 100px 100px rgba(255, 255, 255, 0.2);
            border-radius: 50%;
        }
        15%, 85% {
            color: rgba(255, 255, 255, 0.8);
            text-shadow: 0 0 5px rgba(255, 255, 255, 0.5);
            transform: scale(1) translate3d(0, 0, 0);
            background: transparent;
            box-shadow: none;
        }
        100% {
            color: transparent;
            transform: scale(0) translate3d(0, 2000px, 0);
            background: rgba(255, 255, 255, 0.3);
            box-shadow: 0 0 100px 100px rgba(255, 255, 255, 0.2);
            border-radius: 50%;
        }
    }


text:
Q: Can't store posted values to vector I'm creating a client-server chat-like app in C++ and I'm doing UI in ncurses.
I want to store all messages to vector<char *> msgVector to be able to redraw the whole screen regularly.
Nevertheless when I want to print the values out, all items have the same value - the last accepted message.
void acceptMessages() {
char buffer[256];
fd = c->createClient2Fd("localhost", 12345);
while (true) {
    memset(buffer, 0, sizeof ( buffer));
    int l = recv(fd, buffer, sizeof ( buffer), 0);
    msgVector.push_back(buffer);
    redrawScreen();
}

void redrawScreen() {
    erase();
    mvhline(0, 0, ACS_HLINE, COLS);
    mvhline(LINES - 2, 0, ACS_HLINE, COLS);
    mvaddstr(LINES - 1, 0, "MESSAGE:");
    move(LINES - 1, 9);

    // prints right count of messages
    // but on every line is printed only the last message
    for (int i = 0; i != msgVector.size(); i++)
        cout<<msgVector[i]<<endl;
    move(LINES - 1, 9);
    refresh();
}

So lets say, that accepted messages were:
1) Hello world!
2) My name is John
3) John Doe
4) Test message

Then I get the output:
Test message
Test message
Test message
Test message

Could anybody explain me, what can cause this and how to fix it?

A: The pointer which buffer decays into is always the same (since it's the same variable), so you're always pushing the same pointer onto the vector. That will, after the loop has completed, point to buffer (obviously), which will contain the last message only.
To solve this, consider using std::vector<std::string> instead and pushing back std::string(buffer) during each iteration.

A: As H2CO3 mentioned every element in the vector points to the same block of memory. Even worse buffer is a local variable that is destroyed once you return from acceptMessages. This results in undefined behavior and text you output to the screen can be anything, not just the last line of text you added.
You should switch to using std::vector<std::string> so that a copy of buffer is made and the memory is properly managed for you.


text:
Q: How to create CellTable based on the response from the server
*

*I want to create a CellTable. But Columns of the celltable should be based on the response from the server. I'm getting the server response as List.
No of Columns = Size of the list.

*CellTable column header should be the value from the server.
For ex. Server response: List<Contacts> contacts
Header should be contacts.getName().

A: I achieved it by the following code.
          for (Contacts contact : contacts) {
               final String city = contact.getCity();
               final TextColumn<String> addressColumn = new TextColumn<String>() {

                @Override
                public String getValue(Contacts object) {
                    return city;
                }
            };

            cellTable.addColumn(addressColumn, contact.getAddress());
            }

Regards,
Gnik

A: Use CellList with an AsyncDataProvider:
//Create a cellList
@UiField
CellList<Contact> cellList;

//Creating dataProvider and completion of the cellList
@UiFactory
CellList<Contact> makeCellList() {
private AsyncDataProvider<Contact> provider = new AsyncDataProvider<Contact>() {
    @Override
    public void onRangeChanged(final HasData<Contact> display) {
        rpcService.getContact(new AsyncCallback<List<Contact>>() {
               @Override
               public void onSuccess(List<Contact> result) {
                   display.setRowData(0, result);
               }
               @Override
               public void onFailure(Exception ex) {
                    //TODO
               }
        });
    }
};

//Adding the cellList to the provider in a constructor
provider.addDataDisplay(cellList);

Here's full example and docs.


text:
Q: How to find 3 triangles passing through every dot of a 5x5 grid in z3
I am trying to learn to use Z3 in the old smt solver variant, as thats what I will be studying in school in the near future. Having said this, a solution or clues in Z3 python would also be appreciated.

A: Here is my attempt:
    from z3 import *

    # https://stackoverflow.com/questions/70565942/how-to-find-3-triangles-passing-through-every-dot-of-a-5x5-grid-in-z3

    s = Solver()
    n = 7
    triangles = 4
    Cells = range(n * n)
    N = range(n)
    Triangles = range(triangles)
    corners = 3
    Corners = range(corners)

    #  triangles have three grid points each;
    #  row and column values are kept in two vectors
    Trow = [IntVector("tr" + str(t+1), corners) for t in Triangles]
    Tcol = [IntVector("tc" + str(t+1), corners) for t in Triangles]

    #  save some [] typing
    def Row(t, c):
        return Trow[t][c]

    def Col(t, c):
        return Tcol[t][c]

    def ShowTriangle(model, t):
        print()
        print("Triangle " + str(t+1))
        for e in Corners:
            row = model.eval(simplify(Row(t, e)+1))
            col = model.eval(simplify(Col(t, e)+1))
            s = "col " + str(col).ljust(4) + "; row " + str(row).ljust(4)
            print(s)
        for row in N:
            s = ""
            for col in N:
                if model.eval(IsOnTriangle(n-1-row, col, t)):
                    s = s + str(t+1)
                else:
                    s = s + "."
            print(s)

    def InInterval(x, a, b):
        return And(x >= a, x <= b)

    #  a grid point is covered by a given triangle, if it is located
    #  on an edge of the triangle
    def IsOnTriangle(row, col, t):
        return Or(IsOnEdge(row, col, t, 0, 1),
                  IsOnEdge(row, col, t, 1, 2),
                  IsOnEdge(row, col, t, 0, 2))

    def IsOnEdge(row, col, t, c0, c1):
        row0 = Row(t, c0)
        row1 = Row(t, c1)
        col0 = Col(t, c0)
        col1 = Col(t, c1)
        #  for the time being, we disregard skewed edges
        return Or(IsOnHorizontalEdge(row, col, row0, col0, row1, col1),
                  IsOnVerticalEdge(row, col, row0, col0, row1, col1),
                  IsOnMainDiagonalEdge(row, col, row0, col0, row1, col1),
                  IsOnSecondaryDiagonalEdge(row, col, row0, col0, row1, col1))

    def Equal3(x, a, b):
        return And(x == a, x == b)

    def IsOnHorizontalEdge(row, col, row0, col0, row1, col1):
        return And(Equal3(row, row0, row1),
                   InInterval(col, col0, col1))

    def IsOnVerticalEdge(row, col, row0, col0, row1, col1):
        return And(Equal3(col, col0, col1),
                   InInterval(row, row0, row1))

    def IsOnMainDiagonalEdge(row, col, row0, col0, row1, col1):
        return Or(And(row0 < row1,
                      col0 < col1,
                      (row - row0) == (col - col0),
                      (row1 - row) == (col1 - col),
                      InInterval(row, row0, row1),
                      InInterval(col, col0, col1)),
                  And(row0 > row1,
                      col0 > col1,
                      (row - row1) == (col - col1),
                      (row0 - row) == (col0 - col),
                      InInterval(row, row1, row0),
                      InInterval(col, col1, col0)))

    def IsOnSecondaryDiagonalEdge(row, col, row0, col0, row1, col1):
        return Or(And(row0 < row1,
                      col0 > col1,
                      (row - row0) == (col0 - col),
                      (row1 - row) == (col - col1),
                      InInterval(row, row0, row1),
                      InInterval(col, col1, col0)),
                  And(row0 > row1,
                      col0 < col1,
                      (row - row1) == (col1 - col),
                      (row0 - row) == (col - col0),
                      InInterval(row, row1, row0),
                      InInterval(col, col0, col1)))

    #  every grid position has to be visited by at least one triangle
    for row in N:
        for col in N:
            s.add(Or([IsOnTriangle(row, col, t) for t in Triangles]))

    # delimit triangles to grid
    for t in Triangles:
        for e in Corners:
            s.add(Row(t, e) >= 0,
                  Row(t, e) < n,
                  Col(t, e) >= 0,
                  Col(t, e) < n)

    #  enforce order of corners
    #  to reduce symmetries
    for t in Triangles:
        for e in range(corners-1):
            s.add(Row(t, e) <= Row(t, e+1))

    #  enforce order of triangles
    #  to reduce symmetries
    for t in range(triangles-1):
        s.add(Row(t, 0) <= Row(t+1, 0))

    if sat == s.check():
        print("sat")
        for t in Triangles:
            ShowTriangle(s.model(), t)
    else:
        print("no solution found!")

Resulting output for 4 triangles in a 7x7 grid:
sat

Triangle 1
col 1   ; row 1
col 7   ; row 1
col 1   ; row 7
1......
11.....
1.1....
1..1...
1...1..
1....1.
1111111

Triangle 2
col 2   ; row 2
col 7   ; row 2
col 2   ; row 7
.2.....
.22....
.2.2...
.2..2..
.2...2.
.222222
.......

Triangle 3
col 7   ; row 3
col 3   ; row 7
col 7   ; row 7
..33333
...3..3
....3.3
.....33
......3
.......
.......

Triangle 4
col 2   ; row 3
col 6   ; row 3
col 6   ; row 7
.....4.
....44.
...4.4.
..4..4.
.44444.
.......
.......

As commented by @alias, this is probably not suitable for a first Z3 exercise.
My model won't find solutions with triangles where the edges are skewed (neither horizontal, nor vertical, nor diagonal).
Adding symmetry breaking constraints helped to speed-up the search for the 7x7 case.

A similar model written for MiniZinc:
int: n = 5;  %  grid dimension
set of int: N = 1..n;
int: triangles = 3;
int: corners = 3;
set of int: Triangles = 1..triangles;
set of int: Corners = 1..corners;

%  triangles have three row/column grid points each.
array[Triangles, Corners] of var 1..n: Row;
array[Triangles, Corners] of var 1..n: Col;

%  a grid point is covered by a given triangle, if it located
%  on an edge of the triangle
function var bool: IsOnTriangle(N: row, N: col, Triangles: t) =
    IsOnEdge(row, col, Row[t, 1], Col[t, 1], Row[t, 2], Col[t, 2]) \/
    IsOnEdge(row, col, Row[t, 1], Col[t, 1], Row[t, 3], Col[t, 3]) \/
    IsOnEdge(row, col, Row[t, 2], Col[t, 2], Row[t, 3], Col[t, 3]);

function var bool: Equal3(N: x, var N: a, var N: b) =
    (x == a) /\ (x == b);

function var bool: IsOnEdge(N: row, N: col, var N: aRow, var N: aCol, var N: bRow, var N: bCol) =
    IsOnHorizontalEdge(row, col, aRow, aCol, bRow, bCol) \/
    IsOnVerticalEdge(row, col, aRow, aCol, bRow, bCol) \/
    IsOnDiagonalEdge(row, col, aRow, aCol, bRow, bCol);

function var bool: InInterval(N: x, var N: a, var N: b) =
    if x >= a then x <= b else x >= b endif;

function var bool: IsOnHorizontalEdge(N: row, N: col,
                                      var N: aRow, var N: aCol,
                                      var N: bRow, var N: bCol) =
    Equal3(row, aRow, bRow) /\
    InInterval(col, aCol, bCol);

function var bool: IsOnVerticalEdge(N: row, N: col,
                                    var N: aRow, var N: aCol,
                                    var N: bRow, var N: bCol) =
    Equal3(col, aCol, bCol) /\
    InInterval(row, aRow, bRow);

function var bool: IsOnDiagonalEdge(N: row, N: col,
                                    var N: aRow, var N: aCol,
                                    var N: bRow, var N: bCol) =
    InInterval(row, aRow, aCol) /\
    InInterval(col, aCol, bCol) /\
    (IsOnMainDiagonalEdge(row, col, aRow, aCol, bRow, bCol) \/
     IsOnSecondaryDiagonalEdge(row, col, aRow, aCol, bRow, bCol));

function var bool: IsOnMainDiagonalEdge(N: row, N: col,
                                        var N: aRow, var N: aCol,
                                        var N: bRow, var N: bCol) =
    ((aRow < bRow) /\ (aCol < bCol) /\
    ((row - aRow) == (col - aCol)) /\
    ((bRow - row) == (bCol - col))) \/
    ((aRow > bRow) /\ (aCol > bCol) /\
    ((row - bRow) == (col - bCol)) /\
    ((aRow - row) == (aCol - col)));

function var bool: IsOnSecondaryDiagonalEdge(N: row, N: col,
                                             var N: aRow, var N: aCol,
                                             var N: bRow, var N: bCol) =
    ((aRow < bRow) /\ (aCol > bCol) /\
    ((row - aRow) == (aCol - col)) /\
    ((bRow - row) == (col - bCol))) \/
    ((aRow > bRow) /\ (aCol < bCol) /\
    ((row - bRow) == (bCol - col)) /\
    ((aRow - row) == (col - aCol)));

%  every grid position has to be visited by at least one triangle
constraint forall(row in N, col in N) (
    exists([IsOnTriangle(row, col, t) | t in Triangles])
    );

%  prune symmetries to speed-up the search

constraint forall(t in Triangles) (
    forall(e in 1..corners-1) (
        Row[t, e] <= Row[t, e+1]
    )
);

constraint forall(t in 1..triangles-1) (
    Row[t, 1] <= Row[t+1, 1]
);

output [ "\nTriangle \(t): \(Col[t, c]);\(Row[t, c])" | t in Triangles, c in Corners];


text:
Q: Android. How to get scaled bitmap? I'm using custom zoomable image view. Here is example of such a view: https://github.com/jsibbold/zoomage/blob/master/zoomage/src/main/java/com/jsibbold/zoomage/ZoomageView.java.
Everything works well, but I need to get a new bitmap when changing the scale. That is, I need to get a scaled bitmap.
To do this, I added to the method onScale listener. But I don't understand how to get scaled bitmap.
Please help me.


text:
Q: PHP multiQuery issue I'm having a bit of an issue regarding multi-querying with PHP. My database has the following tables, with their schema shown below:
First table - Users
(PK) UserID,
UserFullName

UserID      FullName

1000        Arthur Whitney

 2000       Alex Schwartz

 3000       Eva Kilpatrick

Second table - Invites
(PK) RowID,
InvName, InvSender, InvSenderTotal, InvReceiver, InvReceiverTotal, InvStatus

RowID  InvName InvSenderID InvSenderTotal InvReceiverID InvReceiverTotal InvStatus

  1     Fair     1000       10             2000          10            Sent

  2     Party    2000       45             1000          45            Sent

  3     Cinema   2000       12             1000          12            Sent

  4    Vacation  3000       15             1000          5            Expired

Say for example when user Alex Schwartz, with unique ID 2000, is logged in, I would like to have it that he can see the name of the invite, the invite sender's name (if he is the invite receiver), the invite receiver's name (if he is the invite sender) and both the invite sender and receiver's totals.
I have devised the following two queries, which yield the results that I intended:
QUERY1
select i.InvName, i.InvSenderTotal, i.InvReceiverTotal, u.FullName FROM Invites as i INNER JOIN Users as u ON u.UserID = i.InvReceiverID
WHERE i.InvStatus = 'Sent' AND i.InvSenderID = 2000

This shows me the Invite Name, Invite Sender and Receivers' totals and the Invite Receiver's name when Alex Schwartz was sending the invite. Expected output here would be specific details of Row IDs 2 and 3.
The following query shows the inverse:
QUERY2
select i.InvName, i.InvSenderTotal, i.InvReceiverTotal, u.FullName FROM Invites as i INNER JOIN Users as u ON u.UserID = i.InvSenderID
WHERE i.InvStatus = 'Sent' AND i.InvReceiverID = 2000

So this enables Alex Schwartz to see the name of the person who sent the invite, along with the same data. Expected output here would be specific details of Row ID 1.
Hence, I am able to get the data I want, but I require two different queries in order to get it. This has presented problems in PHP whereby only one query seems to carry out. So my question is essentially, does anyone know how I could combine these two queries into one? I am also aware of multiQuerying and have tried to implement this, but have not had much success with that either.
Thanks in advance of your help.

A: Why not use UNION.
select i.InvName, i.InvSenderTotal, i.InvReceiverTotal, u.FullName FROM Invites as i INNER JOIN Users as u ON u.UserID = i.InvReceiverID
WHERE i.InvStatus = 'Sent' AND i.InvSenderID = 2000
UNION
select i.InvName, i.InvSenderTotal, i.InvReceiverTotal, u.FullName FROM Invites as i INNER JOIN Users as u ON u.UserID = i.InvSenderID
WHERE i.InvStatus = 'Sent' AND i.InvReceiverID = 2000

A: As a note, you can do this without union all (which is preferred over union unless you intentionally need to remove duplicates):
select i.InvName, i.InvSenderTotal, i.InvReceiverTotal, u.FullName
FROM Invites i INNER JOIN
     Users u
     ON u.UserID IN (i.InvReceiverID, i.InvSenderID)
WHERE i.InvStatus = 'Sent' AND i.InvSenderID = 2000;


text:
Q: What is the `filter` call for in this string split operation? I have a line of legacy code to split a string on semi-colons:
var adds = emailString.split(/;+/).filter(Boolean);

What could the filter(Boolean) part do?

A: filter(Boolean) will only keep the truthy values in the array.
filter expects a callback function, by providing Boolean as reference, it'll be called as Boolean(e) for each element e in the array and the result of the operation will be returned to filter.
If the returned value is true the element e will be kept in array, otherwise it is not included in the array.
Example

var arr = [0, 'A', true, false, 'tushar', '', undefined, null, 'Say My Name'];
arr = arr.filter(Boolean);
console.log(arr); // ["A", true, "tushar", "Say My Name"]

In the code
var adds = emailString.split(/;+/).filter(Boolean);

My guess is that the string emailString contains values separated by ; where semicolon can appear multiple times.
> str = 'a@b.com;;;;c@d.com;;;;dd@dd.com;'
> str.split(/;+/)
< ["a@b.com", "c@d.com", "dd@dd.com", ""]

> str.split(/;+/).filter(Boolean)
< ["a@b.com", "c@d.com", "dd@dd.com"]

Here split on this will return ["a@b.com", "c@d.com", "dd@dd.com", ""].


text:
Q: Texturing WebGL with "autoplay" video element — not working on iOS I'm a contributor to MDN, where there's an issue that was raised about a code demo in the Animating textures in WebGL article.
In order to have a self-contained MRE in this question, I've copied the demo code from that article into a runnable snippet here (below).
The demo creates a video element, sets the autoplay attribute on it, and then layers that video over a 3D rotating cube as a texture.
My question is: How can we make that demo code work as expected on iOS?
Expected behavior
The expected behavior is for the browser to display a 3D rotating cube, with the video from https://mdn.github.io/dom-examples/webgl-examples/tutorial/sample8/Firefox.mp4 layered over the rotating cube as a texture — like this:

…and in all current browsers on all platforms except for iOS, that is the actual behavior.
Actual behavior on iOS
On iOS, in Safari (mobile) — and I think in any other browsers running on iOS (since they all use WebKit as their engine) — a 3D rotating cube is displayed as expected; however, the video is not layered over the rotating cube as expected but instead the browser just displays a plain blue rotating cube, with no texture at all layered over it — like this:

Troubleshooting steps taken, and error messages seen
I don't have iOS browser debugging tools myself, but an issue comment from an MDN user says the browser logs this:

setupVideo webgl-demo.js:141 — Unhandled Promise Rejection: NotAllowedError: The request is not allowed by the user agent or the platform in the current context, possibly because the user denied permission.

Because the line numbers don't match up directly, I'm not sure what's a line 141 in the code as the iOS browser sees it — but https://github.com/mdn/dom-examples/blob/master/webgl-examples/tutorial/sample8/webgl-demo.js#L154 is my best guess — the video.play() call.
So the same issue comment which quotes the above message also references Browser denying javascript play() as a related SO question.
…and that SO question cites a similar "not allowed by the user agent or the platform in the current context, possibly because the user denied permission" error message.

Runnable code snippet that doesn't work as expected on iOS

var cubeRotation = 0.0;
var copyVideo = false;

main();

function main() {
  const canvas = document.querySelector("#glcanvas");
  const gl = canvas.getContext("webgl");
  if (!gl) {
    alert(
      "Unable to initialize WebGL. Your browser or machine may not support it."
    );
    return;
  }
  const vsSource = `
    attribute vec4 aVertexPosition;
    attribute vec3 aVertexNormal;
    attribute vec2 aTextureCoord;

    uniform mat4 uNormalMatrix;
    uniform mat4 uModelViewMatrix;
    uniform mat4 uProjectionMatrix;

    varying highp vec2 vTextureCoord;
    varying highp vec3 vLighting;

    void main(void) {
      gl_Position = uProjectionMatrix * uModelViewMatrix * aVertexPosition;
      vTextureCoord = aTextureCoord;

      // Apply lighting effect

      highp vec3 ambientLight = vec3(0.3, 0.3, 0.3);
      highp vec3 directionalLightColor = vec3(1, 1, 1);
      highp vec3 directionalVector = normalize(vec3(0.85, 0.8, 0.75));

      highp vec4 transformedNormal = uNormalMatrix * vec4(aVertexNormal, 1.0);

      highp float directional = max(dot(transformedNormal.xyz, directionalVector), 0.0);
      vLighting = ambientLight + (directionalLightColor * directional);
    }
  `;
  const fsSource = `
    varying highp vec2 vTextureCoord;
    varying highp vec3 vLighting;

    uniform sampler2D uSampler;

    void main(void) {
      highp vec4 texelColor = texture2D(uSampler, vTextureCoord);

      gl_FragColor = vec4(texelColor.rgb * vLighting, texelColor.a);
    }
  `;

  const shaderProgram = initShaderProgram(gl, vsSource, fsSource);
  const programInfo = {
    program: shaderProgram,
    attribLocations: {
      vertexPosition: gl.getAttribLocation(shaderProgram, "aVertexPosition"),
      vertexNormal: gl.getAttribLocation(shaderProgram, "aVertexNormal"),
      textureCoord: gl.getAttribLocation(shaderProgram, "aTextureCoord"),
    },
    uniformLocations: {
      projectionMatrix: gl.getUniformLocation(
        shaderProgram,
        "uProjectionMatrix"
      ),
      modelViewMatrix: gl.getUniformLocation(shaderProgram, "uModelViewMatrix"),
      normalMatrix: gl.getUniformLocation(shaderProgram, "uNormalMatrix"),
      uSampler: gl.getUniformLocation(shaderProgram, "uSampler"),
    },
  };

  const buffers = initBuffers(gl);
  const texture = initTexture(gl);
  const video = setupVideo("https://mdn.github.io/dom-examples/webgl-examples/tutorial/sample8/Firefox.mp4");
  var then = 0;

  function render(now) {
    now *= 0.001; // convert to seconds
    const deltaTime = now - then;
    then = now;
    if (copyVideo) {
      updateTexture(gl, texture, video);
    }
    drawScene(gl, programInfo, buffers, texture, deltaTime);
    requestAnimationFrame(render);
  }
  requestAnimationFrame(render);
}

function setupVideo(url) {
  const video = document.createElement("video");
  var playing = false;
  var timeupdate = false;
  video.muted = true;
  video.autoplay = true;
  video.loop = true;
  video.crossOrigin = "anonymous";
  video.addEventListener(
    "playing",
    function () {
      playing = true;
      checkReady();
    },
    true
  );
  video.addEventListener(
    "timeupdate",
    function () {
      timeupdate = true;
      checkReady();
    },
    true
  );
  video.src = url;
  video.play();
  function checkReady() {
    if (playing && timeupdate) {
      copyVideo = true;
    }
  }
  return video;
}

function initBuffers(gl) {
  const positionBuffer = gl.createBuffer();
  gl.bindBuffer(gl.ARRAY_BUFFER, positionBuffer);
  const positions = [
    -1.0, -1.0, 1.0, 1.0, -1.0, 1.0, 1.0, 1.0, 1.0, -1.0, 1.0, 1.0,
    -1.0, -1.0, -1.0, -1.0, 1.0, -1.0, 1.0, 1.0, -1.0, 1.0, -1.0, -1.0,
    -1.0, 1.0, -1.0, -1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, -1.0,
    -1.0, -1.0, -1.0, 1.0, -1.0, -1.0, 1.0, -1.0, 1.0, -1.0, -1.0, 1.0,
    1.0, -1.0, -1.0, 1.0, 1.0, -1.0, 1.0, 1.0, 1.0, 1.0, -1.0, 1.0,
    -1.0, -1.0, -1.0, -1.0, -1.0, 1.0, -1.0, 1.0, 1.0, -1.0, 1.0, -1.0,
  ];
  gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(positions), gl.STATIC_DRAW);
  const normalBuffer = gl.createBuffer();
  gl.bindBuffer(gl.ARRAY_BUFFER, normalBuffer);

  const vertexNormals = [
    0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0,
    0.0, 0.0, -1.0, 0.0, 0.0, -1.0, 0.0, 0.0, -1.0, 0.0, 0.0, -1.0,
    0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0,
    0.0, -1.0, 0.0, 0.0, -1.0, 0.0, 0.0, -1.0, 0.0, 0.0, -1.0, 0.0,
    1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0,
    -1.0, 0.0, 0.0, -1.0, 0.0, 0.0, -1.0, 0.0, 0.0, -1.0, 0.0, 0.0,
  ];

  gl.bufferData(
    gl.ARRAY_BUFFER,
    new Float32Array(vertexNormals),
    gl.STATIC_DRAW
  );
  const textureCoordBuffer = gl.createBuffer();
  gl.bindBuffer(gl.ARRAY_BUFFER, textureCoordBuffer);
  const textureCoordinates = [
    0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 0.0, 1.0,
    0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 0.0, 1.0,
    0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 0.0, 1.0,
    0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 0.0, 1.0,
    0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 0.0, 1.0,
    0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 0.0, 1.0,
  ];
  gl.bufferData(
    gl.ARRAY_BUFFER,
    new Float32Array(textureCoordinates),
    gl.STATIC_DRAW
  );
  const indexBuffer = gl.createBuffer();
  gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, indexBuffer);
  const indices = [
    0,
    1,
    2,
    0,
    2,
    3, // front
    4,
    5,
    6,
    4,
    6,
    7, // back
    8,
    9,
    10,
    8,
    10,
    11, // top
    12,
    13,
    14,
    12,
    14,
    15, // bottom
    16,
    17,
    18,
    16,
    18,
    19, // right
    20,
    21,
    22,
    20,
    22,
    23, // left
  ];
  gl.bufferData(
    gl.ELEMENT_ARRAY_BUFFER,
    new Uint16Array(indices),
    gl.STATIC_DRAW
  );
  return {
    position: positionBuffer,
    normal: normalBuffer,
    textureCoord: textureCoordBuffer,
    indices: indexBuffer,
  };
}

function initTexture(gl, url) {
  const texture = gl.createTexture();
  gl.bindTexture(gl.TEXTURE_2D, texture);
  const level = 0;
  const internalFormat = gl.RGBA;
  const width = 1;
  const height = 1;
  const border = 0;
  const srcFormat = gl.RGBA;
  const srcType = gl.UNSIGNED_BYTE;
  const pixel = new Uint8Array([0, 0, 255, 255]); // opaque blue
  gl.texImage2D(
    gl.TEXTURE_2D,
    level,
    internalFormat,
    width,
    height,
    border,
    srcFormat,
    srcType,
    pixel
  );
  gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);

  return texture;
}

function updateTexture(gl, texture, video) {
  const level = 0;
  const internalFormat = gl.RGBA;
  const srcFormat = gl.RGBA;
  const srcType = gl.UNSIGNED_BYTE;
  gl.bindTexture(gl.TEXTURE_2D, texture);
  gl.texImage2D(
    gl.TEXTURE_2D,
    level,
    internalFormat,
    srcFormat,
    srcType,
    video
  );
}

function isPowerOf2(value) {
  return (value & (value - 1)) == 0;
}

function drawScene(gl, programInfo, buffers, texture, deltaTime) {
  gl.clearColor(0.0, 0.0, 0.0, 1.0); // Clear to black, fully opaque
  gl.clearDepth(1.0); // Clear everything
  gl.enable(gl.DEPTH_TEST); // Enable depth testing
  gl.depthFunc(gl.LEQUAL); // Near things obscure far things
  gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
  const fieldOfView = (45 * Math.PI) / 180; // in radians
  const aspect = gl.canvas.clientWidth / gl.canvas.clientHeight;
  const zNear = 0.1;
  const zFar = 100.0;
  const projectionMatrix = mat4.create();
  mat4.perspective(projectionMatrix, fieldOfView, aspect, zNear, zFar);
  const modelViewMatrix = mat4.create();
  mat4.translate(
    modelViewMatrix, // destination matrix
    modelViewMatrix, // matrix to translate
    [-0.0, 0.0, -6.0]
  ); // amount to translate
  mat4.rotate(
    modelViewMatrix, // destination matrix
    modelViewMatrix, // matrix to rotate
    cubeRotation, // amount to rotate in radians
    [0, 0, 1]
  ); // axis to rotate around (Z)
  mat4.rotate(
    modelViewMatrix, // destination matrix
    modelViewMatrix, // matrix to rotate
    cubeRotation * 0.7, // amount to rotate in radians
    [0, 1, 0]
  ); // axis to rotate around (X)

  const normalMatrix = mat4.create();
  mat4.invert(normalMatrix, modelViewMatrix);
  mat4.transpose(normalMatrix, normalMatrix);
  {
    const numComponents = 3;
    const type = gl.FLOAT;
    const normalize = false;
    const stride = 0;
    const offset = 0;
    gl.bindBuffer(gl.ARRAY_BUFFER, buffers.position);
    gl.vertexAttribPointer(
      programInfo.attribLocations.vertexPosition,
      numComponents,
      type,
      normalize,
      stride,
      offset
    );
    gl.enableVertexAttribArray(programInfo.attribLocations.vertexPosition);
  }
  {
    const numComponents = 2;
    const type = gl.FLOAT;
    const normalize = false;
    const stride = 0;
    const offset = 0;
    gl.bindBuffer(gl.ARRAY_BUFFER, buffers.textureCoord);
    gl.vertexAttribPointer(
      programInfo.attribLocations.textureCoord,
      numComponents,
      type,
      normalize,
      stride,
      offset
    );
    gl.enableVertexAttribArray(programInfo.attribLocations.textureCoord);
  }
  {
    const numComponents = 3;
    const type = gl.FLOAT;
    const normalize = false;
    const stride = 0;
    const offset = 0;
    gl.bindBuffer(gl.ARRAY_BUFFER, buffers.normal);
    gl.vertexAttribPointer(
      programInfo.attribLocations.vertexNormal,
      numComponents,
      type,
      normalize,
      stride,
      offset
    );
    gl.enableVertexAttribArray(programInfo.attribLocations.vertexNormal);
  }

  gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, buffers.indices);
  gl.useProgram(programInfo.program);
  gl.uniformMatrix4fv(
    programInfo.uniformLocations.projectionMatrix,
    false,
    projectionMatrix
  );
  gl.uniformMatrix4fv(
    programInfo.uniformLocations.modelViewMatrix,
    false,
    modelViewMatrix
  );
  gl.uniformMatrix4fv(
    programInfo.uniformLocations.normalMatrix,
    false,
    normalMatrix
  );
  gl.activeTexture(gl.TEXTURE0);
  gl.bindTexture(gl.TEXTURE_2D, texture);
  gl.uniform1i(programInfo.uniformLocations.uSampler, 0);
  {
    const vertexCount = 36;
    const type = gl.UNSIGNED_SHORT;
    const offset = 0;
    gl.drawElements(gl.TRIANGLES, vertexCount, type, offset);
  }
  cubeRotation += deltaTime;
}

function initShaderProgram(gl, vsSource, fsSource) {
  const vertexShader = loadShader(gl, gl.VERTEX_SHADER, vsSource);
  const fragmentShader = loadShader(gl, gl.FRAGMENT_SHADER, fsSource);
  const shaderProgram = gl.createProgram();
  gl.attachShader(shaderProgram, vertexShader);
  gl.attachShader(shaderProgram, fragmentShader);
  gl.linkProgram(shaderProgram);
  if (!gl.getProgramParameter(shaderProgram, gl.LINK_STATUS)) {
    alert(
      "Unable to initialize the shader program: " +
        gl.getProgramInfoLog(shaderProgram)
    );
    return null;
  }

  return shaderProgram;
}

function loadShader(gl, type, source) {
  const shader = gl.createShader(type);
  gl.shaderSource(shader, source);
  gl.compileShader(shader);
  if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
    alert(
      "An error occurred compiling the shaders: " + gl.getShaderInfoLog(shader)
    );
    gl.deleteShader(shader);
    return null;
  }
  return shader;
}
canvas { border: 2px solid black; background-color: black; }
video { display: none; }
<!doctype html><meta charset="utf-8"><title>WebGL Demo</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/gl-matrix/2.8.1/gl-matrix-min.js"></script>
<canvas id="glcanvas" width="640" height="480"></canvas>

A: Solution: Drop the autoplay attribute, and add the playsInline attribute.
The clue on playsInline came from https://stackoverflow.com/a/65965158/441757.
The realization on autoplay came from trial-and-error — by dropping it to see what'd happen.
And what happens is that without that attribute set, the demo still continues to work in all other browsers as expected — but then also works as expected on iOS too.
So it seems: when using a video as a WebGL texture, it's unnecessary to set autoplay to get the video to play — but it is necessary to set playsInline to make it work on iOS.

Runnable snippet that works in all browsers — including on iOS

var cubeRotation = 0.0;
var copyVideo = false;

main();

function main() {
  const canvas = document.querySelector("#glcanvas");
  const gl = canvas.getContext("webgl");
  if (!gl) {
    alert(
      "Unable to initialize WebGL. Your browser or machine may not support it."
    );
    return;
  }
  const vsSource = `
    attribute vec4 aVertexPosition;
    attribute vec3 aVertexNormal;
    attribute vec2 aTextureCoord;

    uniform mat4 uNormalMatrix;
    uniform mat4 uModelViewMatrix;
    uniform mat4 uProjectionMatrix;

    varying highp vec2 vTextureCoord;
    varying highp vec3 vLighting;

    void main(void) {
      gl_Position = uProjectionMatrix * uModelViewMatrix * aVertexPosition;
      vTextureCoord = aTextureCoord;

      // Apply lighting effect

      highp vec3 ambientLight = vec3(0.3, 0.3, 0.3);
      highp vec3 directionalLightColor = vec3(1, 1, 1);
      highp vec3 directionalVector = normalize(vec3(0.85, 0.8, 0.75));

      highp vec4 transformedNormal = uNormalMatrix * vec4(aVertexNormal, 1.0);

      highp float directional = max(dot(transformedNormal.xyz, directionalVector), 0.0);
      vLighting = ambientLight + (directionalLightColor * directional);
    }
  `;
  const fsSource = `
    varying highp vec2 vTextureCoord;
    varying highp vec3 vLighting;

    uniform sampler2D uSampler;

    void main(void) {
      highp vec4 texelColor = texture2D(uSampler, vTextureCoord);

      gl_FragColor = vec4(texelColor.rgb * vLighting, texelColor.a);
    }
  `;

  const shaderProgram = initShaderProgram(gl, vsSource, fsSource);
  const programInfo = {
    program: shaderProgram,
    attribLocations: {
      vertexPosition: gl.getAttribLocation(shaderProgram, "aVertexPosition"),
      vertexNormal: gl.getAttribLocation(shaderProgram, "aVertexNormal"),
      textureCoord: gl.getAttribLocation(shaderProgram, "aTextureCoord"),
    },
    uniformLocations: {
      projectionMatrix: gl.getUniformLocation(
        shaderProgram,
        "uProjectionMatrix"
      ),
      modelViewMatrix: gl.getUniformLocation(shaderProgram, "uModelViewMatrix"),
      normalMatrix: gl.getUniformLocation(shaderProgram, "uNormalMatrix"),
      uSampler: gl.getUniformLocation(shaderProgram, "uSampler"),
    },
  };

  const buffers = initBuffers(gl);
  const texture = initTexture(gl);
  const video = setupVideo("https://mdn.github.io/dom-examples/webgl-examples/tutorial/sample8/Firefox.mp4");
  var then = 0;

  function render(now) {
    now *= 0.001; // convert to seconds
    const deltaTime = now - then;
    then = now;
    if (copyVideo) {
      updateTexture(gl, texture, video);
    }
    drawScene(gl, programInfo, buffers, texture, deltaTime);
    requestAnimationFrame(render);
  }
  requestAnimationFrame(render);
}

function setupVideo(url) {
  const video = document.createElement("video");
  var playing = false;
  var timeupdate = false;
  video.muted = true;
  video.playsInline = true;
  video.loop = true;
  video.crossOrigin = "anonymous";
  video.addEventListener(
    "playing",
    function () {
      playing = true;
      checkReady();
    },
    true
  );
  video.addEventListener(
    "timeupdate",
    function () {
      timeupdate = true;
      checkReady();
    },
    true
  );
  video.src = url;
  video.play();
  function checkReady() {
    if (playing && timeupdate) {
      copyVideo = true;
    }
  }
  return video;
}

function initBuffers(gl) {
  const positionBuffer = gl.createBuffer();
  gl.bindBuffer(gl.ARRAY_BUFFER, positionBuffer);
  const positions = [
    -1.0, -1.0, 1.0, 1.0, -1.0, 1.0, 1.0, 1.0, 1.0, -1.0, 1.0, 1.0,
    -1.0, -1.0, -1.0, -1.0, 1.0, -1.0, 1.0, 1.0, -1.0, 1.0, -1.0, -1.0,
    -1.0, 1.0, -1.0, -1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, -1.0,
    -1.0, -1.0, -1.0, 1.0, -1.0, -1.0, 1.0, -1.0, 1.0, -1.0, -1.0, 1.0,
    1.0, -1.0, -1.0, 1.0, 1.0, -1.0, 1.0, 1.0, 1.0, 1.0, -1.0, 1.0,
    -1.0, -1.0, -1.0, -1.0, -1.0, 1.0, -1.0, 1.0, 1.0, -1.0, 1.0, -1.0,
  ];
  gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(positions), gl.STATIC_DRAW);
  const normalBuffer = gl.createBuffer();
  gl.bindBuffer(gl.ARRAY_BUFFER, normalBuffer);

  const vertexNormals = [
    0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0,
    0.0, 0.0, -1.0, 0.0, 0.0, -1.0, 0.0, 0.0, -1.0, 0.0, 0.0, -1.0,
    0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0,
    0.0, -1.0, 0.0, 0.0, -1.0, 0.0, 0.0, -1.0, 0.0, 0.0, -1.0, 0.0,
    1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0,
    -1.0, 0.0, 0.0, -1.0, 0.0, 0.0, -1.0, 0.0, 0.0, -1.0, 0.0, 0.0,
  ];

  gl.bufferData(
    gl.ARRAY_BUFFER,
    new Float32Array(vertexNormals),
    gl.STATIC_DRAW
  );
  const textureCoordBuffer = gl.createBuffer();
  gl.bindBuffer(gl.ARRAY_BUFFER, textureCoordBuffer);
  const textureCoordinates = [
    0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 0.0, 1.0,
    0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 0.0, 1.0,
    0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 0.0, 1.0,
    0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 0.0, 1.0,
    0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 0.0, 1.0,
    0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 0.0, 1.0,
  ];
  gl.bufferData(
    gl.ARRAY_BUFFER,
    new Float32Array(textureCoordinates),
    gl.STATIC_DRAW
  );
  const indexBuffer = gl.createBuffer();
  gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, indexBuffer);
  const indices = [
    0,
    1,
    2,
    0,
    2,
    3, // front
    4,
    5,
    6,
    4,
    6,
    7, // back
    8,
    9,
    10,
    8,
    10,
    11, // top
    12,
    13,
    14,
    12,
    14,
    15, // bottom
    16,
    17,
    18,
    16,
    18,
    19, // right
    20,
    21,
    22,
    20,
    22,
    23, // left
  ];
  gl.bufferData(
    gl.ELEMENT_ARRAY_BUFFER,
    new Uint16Array(indices),
    gl.STATIC_DRAW
  );
  return {
    position: positionBuffer,
    normal: normalBuffer,
    textureCoord: textureCoordBuffer,
    indices: indexBuffer,
  };
}

function initTexture(gl, url) {
  const texture = gl.createTexture();
  gl.bindTexture(gl.TEXTURE_2D, texture);
  const level = 0;
  const internalFormat = gl.RGBA;
  const width = 1;
  const height = 1;
  const border = 0;
  const srcFormat = gl.RGBA;
  const srcType = gl.UNSIGNED_BYTE;
  const pixel = new Uint8Array([0, 0, 255, 255]); // opaque blue
  gl.texImage2D(
    gl.TEXTURE_2D,
    level,
    internalFormat,
    width,
    height,
    border,
    srcFormat,
    srcType,
    pixel
  );
  gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);

  return texture;
}

function updateTexture(gl, texture, video) {
  const level = 0;
  const internalFormat = gl.RGBA;
  const srcFormat = gl.RGBA;
  const srcType = gl.UNSIGNED_BYTE;
  gl.bindTexture(gl.TEXTURE_2D, texture);
  gl.texImage2D(
    gl.TEXTURE_2D,
    level,
    internalFormat,
    srcFormat,
    srcType,
    video
  );
}

function isPowerOf2(value) {
  return (value & (value - 1)) == 0;
}

function drawScene(gl, programInfo, buffers, texture, deltaTime) {
  gl.clearColor(0.0, 0.0, 0.0, 1.0); // Clear to black, fully opaque
  gl.clearDepth(1.0); // Clear everything
  gl.enable(gl.DEPTH_TEST); // Enable depth testing
  gl.depthFunc(gl.LEQUAL); // Near things obscure far things
  gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
  const fieldOfView = (45 * Math.PI) / 180; // in radians
  const aspect = gl.canvas.clientWidth / gl.canvas.clientHeight;
  const zNear = 0.1;
  const zFar = 100.0;
  const projectionMatrix = mat4.create();
  mat4.perspective(projectionMatrix, fieldOfView, aspect, zNear, zFar);
  const modelViewMatrix = mat4.create();
  mat4.translate(
    modelViewMatrix, // destination matrix
    modelViewMatrix, // matrix to translate
    [-0.0, 0.0, -6.0]
  ); // amount to translate
  mat4.rotate(
    modelViewMatrix, // destination matrix
    modelViewMatrix, // matrix to rotate
    cubeRotation, // amount to rotate in radians
    [0, 0, 1]
  ); // axis to rotate around (Z)
  mat4.rotate(
    modelViewMatrix, // destination matrix
    modelViewMatrix, // matrix to rotate
    cubeRotation * 0.7, // amount to rotate in radians
    [0, 1, 0]
  ); // axis to rotate around (X)

  const normalMatrix = mat4.create();
  mat4.invert(normalMatrix, modelViewMatrix);
  mat4.transpose(normalMatrix, normalMatrix);
  {
    const numComponents = 3;
    const type = gl.FLOAT;
    const normalize = false;
    const stride = 0;
    const offset = 0;
    gl.bindBuffer(gl.ARRAY_BUFFER, buffers.position);
    gl.vertexAttribPointer(
      programInfo.attribLocations.vertexPosition,
      numComponents,
      type,
      normalize,
      stride,
      offset
    );
    gl.enableVertexAttribArray(programInfo.attribLocations.vertexPosition);
  }
  {
    const numComponents = 2;
    const type = gl.FLOAT;
    const normalize = false;
    const stride = 0;
    const offset = 0;
    gl.bindBuffer(gl.ARRAY_BUFFER, buffers.textureCoord);
    gl.vertexAttribPointer(
      programInfo.attribLocations.textureCoord,
      numComponents,
      type,
      normalize,
      stride,
      offset
    );
    gl.enableVertexAttribArray(programInfo.attribLocations.textureCoord);
  }
  {
    const numComponents = 3;
    const type = gl.FLOAT;
    const normalize = false;
    const stride = 0;
    const offset = 0;
    gl.bindBuffer(gl.ARRAY_BUFFER, buffers.normal);
    gl.vertexAttribPointer(
      programInfo.attribLocations.vertexNormal,
      numComponents,
      type,
      normalize,
      stride,
      offset
    );
    gl.enableVertexAttribArray(programInfo.attribLocations.vertexNormal);
  }

  gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, buffers.indices);
  gl.useProgram(programInfo.program);
  gl.uniformMatrix4fv(
    programInfo.uniformLocations.projectionMatrix,
    false,
    projectionMatrix
  );
  gl.uniformMatrix4fv(
    programInfo.uniformLocations.modelViewMatrix,
    false,
    modelViewMatrix
  );
  gl.uniformMatrix4fv(
    programInfo.uniformLocations.normalMatrix,
    false,
    normalMatrix
  );
  gl.activeTexture(gl.TEXTURE0);
  gl.bindTexture(gl.TEXTURE_2D, texture);
  gl.uniform1i(programInfo.uniformLocations.uSampler, 0);
  {
    const vertexCount = 36;
    const type = gl.UNSIGNED_SHORT;
    const offset = 0;
    gl.drawElements(gl.TRIANGLES, vertexCount, type, offset);
  }
  cubeRotation += deltaTime;
}

function initShaderProgram(gl, vsSource, fsSource) {
  const vertexShader = loadShader(gl, gl.VERTEX_SHADER, vsSource);
  const fragmentShader = loadShader(gl, gl.FRAGMENT_SHADER, fsSource);
  const shaderProgram = gl.createProgram();
  gl.attachShader(shaderProgram, vertexShader);
  gl.attachShader(shaderProgram, fragmentShader);
  gl.linkProgram(shaderProgram);
  if (!gl.getProgramParameter(shaderProgram, gl.LINK_STATUS)) {
    alert(
      "Unable to initialize the shader program: " +
        gl.getProgramInfoLog(shaderProgram)
    );
    return null;
  }

  return shaderProgram;
}

function loadShader(gl, type, source) {
  const shader = gl.createShader(type);
  gl.shaderSource(shader, source);
  gl.compileShader(shader);
  if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
    alert(
      "An error occurred compiling the shaders: " + gl.getShaderInfoLog(shader)
    );
    gl.deleteShader(shader);
    return null;
  }
  return shader;
}
canvas { border: 2px solid black; background-color: black; }
video { display: none; }
<!doctype html><meta charset="utf-8"><title>WebGL Demo</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/gl-matrix/2.8.1/gl-matrix-min.js"></script>
<canvas id="glcanvas" width="640" height="480"></canvas>


text:
Q: Bind short json props to the long model properties It's a common thing that you have
public string FirstName { get; set; }
public string LastName { get; set; }

as a model's properties and want json to look like
{
  "fn":"jim",
  "ln":"The Sparrow"
}

When you send/receive large data via ajax, you don't want properties to take half of the request body, but at the same time need something understandable in the code.
The [JsonProperty()] attribute doesnt work on incoming data, the default MVC model binder has no idea what is it.
Any suggessions?

A: You can use ActionParameterAlias to essentially tell model binding which passed-in values to map to which method parameters.


text:
Q: Remove target="_blank" from an iframe after its loading I would like to remove the target="_blank" attribute from links inside the html loaded by an iframe.
How can i do this after the loading of all the sections?
this is the link https://nnd9wjqxzdcckxxewmrb6w-on.drv.tw/html/prova.html
this is the code of the page before the loading.

<iframe src="https://schneider-electric.app.box.com/embed/s/es48mnabibdc6rmdwr6ukanv36z0f3zo?
    sortColumn=date&view=list" width="500" height="400" frameborder="0" allowfullscreen webkitallowfullscreen msallowfullscreen></iframe>


text:
Q: How can I search the contents of .module files? I'm working  with Drupal at the moment and I'm having a real hard time searching the contents of various .module files. For example I want to search for something like "div style="border: 1px solid red;" and find out which file it's in.
All my code editors ignore the .module files in their search because it is a strange extension. Windows won't do it because it's on a networked location.
Any ideas?

A: ack can do that for you pretty happily. For more convenience, you can also add in your .ackrc file the following:
    --type-set=drupal=.php,.inc,.module,.install,.info,.engine
    --type=drupal
So that typing
$ ack string

will find string in all drupal files under the current directory.
(Yes, it runs on windows, see the link).

A: Install Cygwin, open a shell in your Drupal site's directory, and use grep --- a commandline utility to search files using regular expressions.
Something like this:
grep -r 'div style="border: 1px solid red;"' *

would recursively search every file for that string.
Or:
find . -name '*.module' -exec grep -H 'div style="border: 1px solid red;"' {} \;

would search only the .module files.

A: What I do:
Use firebug, it will tell you the exact file and then you can browse the system for that style. You'll want to turn off CSS caching for this temporarily.
Generally, there aren't too many (or shouldn't be any) CSS rules being defined in the .module files anyway.
If all else fails, you can use something like Agent Ransack or, for a more command line unixy feel, the king of command line search: grep.


text:
Q: Bluemix public - single region availability SLA Recent Bluemix terms of use document mentions availabilty only for applications deployed across at leas two regions. In the previous versions of Bluemix terms of use (e.g. here) there was so called service level objective which was not related to a specific deployment model.
What is Bluemix service availabilty in case I want to deploy my application only in one region?

A: Just for info, the answer was added at:
https://developer.ibm.com/answers/questions/246896/bluemix-public-single-region-availability-sla.html


text:
Q: Why I cannot see "Create an outgoing webhook" link? I follow the instruction on this page. Outgoing webhooks in Microsoft Teams
but I cannot see the link "Create an outgoing webhook". What should I do?

A: I think you could check 3 points:

*

*You should be in a "Member" role or an "Owner" role. The link does not show if you are a "Guest" in the team.

*If you are already a "Member", ask your team Owner to check if the permission is on. Assign roles and permissions

*As Wajeed - MSFT mentioned, Allow sideloading of external apps (Step #5)


text:
Q: Split a rod of unit length into two at a random position to get two pieces length x and y. Then split both pieces into two again at random positions. Suppose y>x.
What is the probability that the smaller segment of the piece initially split into length y is bigger than the bigger segment initially split into length x?
I ran a simulation and got roughly 47.7% chance but cannot show this analytically.

A: The length $x$ of the shorter piece of the original rod is unifomly distributed in $\bigl[0,{1\over2}\bigr]$. The length $u$ of the larger part of this piece is then uniformly distributed in $\bigl[{x\over2},x\bigr]$, and the length $v$ of the smaller part of the larger piece is uniformly distributed in the interval $\bigl[0,{1-x\over2}\bigr]$. It folows that the point $(u,v)$ is uniformly distributed in the rectangle $R_x:=\bigl[{x\over2},x\bigr]\times\bigl[0,{1-x\over2}\bigr]$ of area ${x(1-x)\over4}$.
We now have to consider the part  $T_x\subset R_x$ where $v\geq u$. If $0\leq x\leq{1\over3}$ the set $T_x$ is a trapezoid of area
$${\rm area}(T_x)={x\over2}\left({1-x\over2}-{3x\over4}\right)={x(2-5x)\over8}\qquad\bigl(0\leq x\leq{1\over3}\bigr)\ .$$
If ${1\over3}\leq x\leq{1\over2}$ then $T_x$ is a triangle of area
$${\rm area}(T_x)={1\over2}\left({1-x\over2}-{x\over2}\right)^2={(1-2x)^2\over8}\qquad\bigl({1\over3}\leq x\leq{1\over2}\bigr)\ .$$
The probability we are after is then given by
$$p=\int_0^{1/2}{{\rm area}(T_x)\over{\rm area}(R_x)}\>2dx=\int_0^{1/3}{2-5x\over1-x}\>dx+\int_{1/3}^{1/2}{(1-2x)^2\over x(1-x)}\>dx=1-\log{27\over16}\ .$$

A: Let $A,B,C$ be independent random variable, uniformly distributed over $[0,1]$. We have $y=\max(A,1-A), x=\min(A,1-A)$ and we want to compute the probability that
$$\min(B,1-B)\cdot \max(A,1-A) \geq \max(C,1-C)\cdot \min(A,1-A).$$
The distribution of $M=\max(A,1-A)$ is constant and supported on $\left[\frac{1}{2},1\right]$. Similarly,the distribution of $\min(A,1-A)$ is constant and supported on $\left[0,\frac{1}{2}\right]$. For a given value of $M$, the probability that $M\min(B,1-B)\geq (1-M)\max(C,1-C)$ equals
$$ \frac{(2M-1)^2}{2M(1-M)} $$
if $M\leq\frac{2}{3}$ and $\frac{5}{2}-\frac{3}{2M}$ if $\frac{2}{3}\leq M\leq 1$. The wanted probability is so
$$ \color{red}{1-3\log 3+4\log 2}\approx 47.675\%.$$

A: We split the unit-length rod without bias and designate the smaller piece's length as $x$ and the larger piece's length as $y$.   We repeat the process on that larger piece and designate its smaller length as $z$.
We assert that since the break is made without bias, and the smaller piece will be less than half the length of the original rod, while the larger piece will be greater than half, therefore $x\sim\mathcal U(0;1/2)$ and $y\sim\mathcal U(1/2;1)$.   Further $x=1-y$.
Likewise and $z\mid y\sim\mathcal U(0;y/2)$.   (Note: if $y<2/3$, then $x>1/3$ while $z<1/3$, so $x>z$ most certainly.)
$$\begin{align}\mathsf P(z>x) ~&= \mathsf P(z>1-y) \\ &= \int_{1/2}^1 \int_{1-y}^{\max\{y/2,1-y\}} 4y^{-1}\mathrm d z\mathrm d y \\ &= 4\int_{2/3}^1 y^{-1}\int_{1-y}^{y/2} \mathrm d z\mathrm d y &~\because~& y/2>1-y \implies y>2/3\\&= 2-4\ln (3/2) \end{align}$$


text:
Q: Porque no puedo mostrar un Fragment desde otro Fragment tengo creado un menú horizontal, y uno de los Fragment que componen el menú me muestra un botón, que al pulsarlo tendría que mostrar otro Fragment, pero no se muestra, no muestra ningún error, simplemente no llega a mostrarse.
Este es el Fragment donde tengo puesto el botón para que se muestre el otro Fragment

MainActivity.java
public class MainActivity extends AppCompatActivity {

private ViewPager viewPager;
HorizontalScrollMenuView horizontal_menu;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    horizontal_menu = (HorizontalScrollMenuView) findViewById(R.id.horizontal_menu);
    viewPager = (ViewPager) findViewById(R.id.pager);

    horizontal_menu.addItem("Menu 1", R.drawable.home_icon, true);
    horizontal_menu.addItem("Boton", R.drawable.round_account);
    horizontal_menu.addItem("Esquema", R.drawable.notifications);

    horizontal_menu.showItems();//hacemos visible los items del menu

    PagerAdapter pagerAdapter = new PagerAdapter(getSupportFragmentManager());
    viewPager.setAdapter(pagerAdapter);
    viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
        }

        @Override
        public void onPageSelected(int position) {
            //cambiamos el elemento seleccionado del menu a la posicion actual del viewpager
            horizontal_menu.setItemSelected(position);
        }

        @Override
        public void onPageScrollStateChanged(int state) {

        }
    });

    //implementamos la interface para caputar los clic en el menu
    horizontal_menu.setOnHSMenuClickListener(new HorizontalScrollMenuView.OnHSMenuClickListener() {
        @Override
        public void onHSMClick(MenuItem menuItem, int position) {
            viewPager.setCurrentItem(position);
        }
    });
}

private class PagerAdapter extends FragmentPagerAdapter {

    //public PagerAdapter(FragmentManager fm) {
    PagerAdapter(FragmentManager fm) {
        super(fm);
    }

    @Override
    public Fragment getItem(int position) {

        switch (position) {
            case 0:
                return new Menu1();
            case 1:
                return new Boton();
            case 2:
                return new Esquema();
            default:
                return new Menu1();
        }
    }

    @Override
    public int getCount() {
        return 3;
    }
}
}

Fragment Boton.java
public class Boton extends Fragment {

private Button verEsquema;

public Boton() {
}

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {

    View rootView  = inflater.inflate( R.layout.boton, container, false );

    verEsquema = (Button) rootView.findViewById(R.id.btn_boton1);

    verEsquema.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Fragment nuevoFragmento = new Esquema();
            FragmentTransaction transaction = getFragmentManager().beginTransaction();
            //transaction.replace(R.id.frame_container, nuevoFragmento);
             transaction.replace(((ViewGroup)getView().getParent()).getId(), nuevoFragmento);
            transaction.addToBackStack(null);
            transaction.commit();
        }
    });

    return rootView;
}
}

boton.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/linearLayout"
android:layout_width="match_parent"
android:layout_height="match_parent">

<Button
    android:id="@+id/btn_boton1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginStart="8dp"
    android:layout_marginLeft="8dp"
    android:layout_marginTop="68dp"
    android:layout_marginEnd="8dp"
    android:layout_marginRight="8dp"
    android:layout_marginBottom="8dp"
    android:text="Boton 1"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintVertical_bias="0.0" />
 </android.support.constraint.ConstraintLayout>

Fragment Esquema.java
public class Esquema extends Fragment {

WebView mWebView;

public Esquema() {
}

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {

    View view = inflater.inflate( R.layout.esquema, container, false );

    mWebView = (WebView) view.findViewById( R.id.webView_esquema);
    mWebView.getSettings().setJavaScriptEnabled( true );
    mWebView.getSettings().setAppCacheEnabled( true );
    mWebView.getSettings().setBuiltInZoomControls( true );
    mWebView.getSettings().setDisplayZoomControls( false );
    mWebView.getSettings().setSupportZoom( true );
    mWebView.getSettings().setDefaultZoom( WebSettings.ZoomDensity.FAR );
    mWebView.getSettings().setLoadWithOverviewMode( true );
    mWebView.getSettings().setUseWideViewPort( true );
    mWebView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
    mWebView.setScrollbarFadingEnabled(false);

    mWebView.loadUrl("file:///android_asset/esquema.html");

    return view;
}
}

esquema.xml
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
android:layout_height="match_parent">

<WebView
    android:id="@+id/webView_esquema"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
</WebView>

</FrameLayout>

activity_main.xml

 <com.darwindeveloper.horizontalscrollmenulibrary.custom_views.HorizontalScrollMenuView
    android:id="@+id/horizontal_menu"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:backgroundMenuColor="#0099cc"
    app:backgroundNotifications="@color/colorAccent"
    app:icon_height="50dp"
    app:icon_width="50dp"
    app:item_backgroundColor="@color/colorPrimary"
    app:item_colorSelected="#ffffff"
    app:item_textColor="#ffffff" />

<android.support.v4.view.ViewPager
    android:id="@+id/pager"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >
</android.support.v4.view.ViewPager>

<FrameLayout
    android:id="@+id/frame_container"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >
</FrameLayout>

</LinearLayout>

¿Me podríais decir que estoy haciendo mal y porque no se muestra?
Gracias.


text:
Q: 3 different collision bodies? Swift3 + Spritekit Okay I've searched around and I cannot find an answer to this problem.
I have 3 different node types that I want to handle collisions with. A meteor, a shot, and a station. I have the code for the collision handling between the shots and the meteors working perfectly, but I cannot for the life of me figure out how to respond to collisions (yes the collision is being detected but the response code isn't executing) between the station and a meteor. Here's my didBegin func:
func didBegin(_ contact: SKPhysicsContact){
    print("contact")
    let shot = (contact.bodyA.categoryBitMask == shotCategory) ? contact.bodyA : contact.bodyB
    let stationBody = (contact.bodyA.categoryBitMask == stationCategory) ? contact.bodyA : contact.bodyB
    let otherObject = (shot == contact.bodyA) ? contact.bodyB : contact.bodyA

    if ((contact.bodyA == stationBody) && (contact.bodyB == otherObject)) {
        print("collision!")
    }
}

"contact" is being printed when a meteor collides with the station, but "collision!" is not being printed. I know its got something to do with the way the code is worded but i can't seem to get it to work no matter how I write/rewrite it

A: Try considering the order...
 if (contact.bodyA == stationBody && contact.bodyB == otherObject) || (contact.bodyB == stationBody && contact.bodyA == otherObject)

Also you are setting the other object according to shot, so if shot is not one of the objects in the collision it might be a problem
if bodyA is the other object and bodyB the station for example, shot would be set to bodyB (because the categoryBitMask != shotCategory) and then the otherObject would be set to bodyA. Therefore contact.bodyB won't equal otherObject.


text:
Q: passing var into objective c block I'm using the reverse geocoder and I want to save info into a SQLite database but I need the latitude and longitude set by the user but it's not being passed.
I've got two doubles var called latitude and longitude and when I execute this code below, it uses "random" doubles:
CLLocation *locate = [[CLLocation alloc] initWithLatitude:latitude longitude:longitude];

    CLGeocoder *geoCoderCL = [[CLGeocoder alloc] init];
    [geoCoderCL reverseGeocodeLocation: locate completionHandler:
     ^(NSArray *placemarks, NSError *error) {

         CLPlacemark *placemark = [placemarks objectAtIndex:0];

         Controller *mController = [[Controller alloc] init];
         MyObject *newposition = [[Meeting alloc]init];
         [newposition setLatitude:latitude];
         [newposition setLongitude:longitude];
         [newposition setMName:[NSString stringWithFormat:@"%@ %@",placemark.thoroughfare,placemark.subThoroughfare]];
         NSLog(@"%@ %@",placemark.thoroughfare,placemark.subThoroughfare);
         [mController createRecentPoint:newposition];
         [mController release];
         [newposition release];

     }];

How is supposed to do this? Thanks.

A: Use the following to derive the latitude and longitude from a CLPlacemark object.
CLLocationDegrees latitude = placemark.location.coordinate.latitude;
CLLocationDegrees longitude = placemark.location.coordinate.longitude;

location is a CLLocation object. coordinate is a CLLocationCoordinate2D struct and latitude and longitude are CLLocationDegrees (which is just a typdef'd double).


text:
Q: How to combine sql statements in ibatis? I have the following statement, which I need in  order to update an entry in my database:
<update id="setAsDefault" >
  START TRANSACTION;
    UPDATE cms_wall SET is_default = FALSE WHERE owner = #{ownerId} AND is_default= TRUE;
    UPDATE cms_wall SET is_default = TRUE  WHERE brand = #{brandId};
   COMMIT;
</update>

Both statements work individually. Also, they work when combined if I enter them manually in mysql. When I try to run this from ibatis however I get the following error:
### Error updating database.  Cause:com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UPDATE cms_wall SET is_default = FALSE WHERE owner = '123_test_user_' at line 2
### The error may involve defaultParameterMap
### The error occurred while setting parameters
### SQL: START TRANSACTION;         UPDATE cms_wall SET is_default = FALSE WHERE owner= ? AND is_default= TRUE;         UPDATE cms_wall SET is_default = TRUE  WHERE brand = ?;        COMMIT;
### Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UPDATE cms_wall SET is_default = FALSE WHERE owner = '123_test_user_' at line 2

A: Use if test statement is more clear:
<update id="setAsDefault" >
  START TRANSACTION;
  <if test="ownerId != null">
      UPDATE cms_wall SET is_default = FALSE WHERE owner = #{ownerId} AND is_default= TRUE;
  </if>
  <if test="brandId != null">
      UPDATE cms_wall SET is_default = TRUE  WHERE brand = #{brandId};
  </if>
   COMMIT;
</update>

A: This should work:
UPDATE cms_wall SET is_default = IF(owner = #{ownerId} AND is_default=TRUE,FALSE,IF(brand = #{brandId},TRUE,is_default));


text:
Q: How to add a record to a table using parameters from differents View in ASP MVC and SQL I am developing an ASP .Net MVC 3 application using C# and SQL Server 2005.
I am using also Entity Framework and Code First Method.
I want to add a record to the table 'Gamme' in my base.
The problem is that the parametres which used to fill out the table are taken from differents views.
This is the model Gamme:
namespace MvcApplication2.Models
{
    public class Gamme
    {
        [Key]
        [Column(Order = 0)]
        [ForeignKey("Profile_Ga")]
        public string ID_Gamme { get; set; }
        [Key]
        [Column(Order = 1)]
        [ForeignKey("Poste")]
        public string ID_Poste { get; set; }
        public int Position { get; set; }
        public int Nbr_Passage { get; set; }
        public string Last_Posts { get; set; }
        public string Next_Posts { get; set; }

        public virtual Poste Poste { get; set; }
        public virtual Profile_Ga Profile_Ga { get; set; }

    }

The ID_Gamme is taken from the view Index which the code is:

<%:Html.Label("Gamme :")%><%: Html.DropDownList("SelectedProfile_Ga", new SelectList(Model.Profile_GaItems, "ID_Gamme", "ID_Gamme"))%> <input type="button" value="Configurer" id="btnShowGestion" />

The other parameters are taken from the partial view Gestion.ascx:

<%:Html.Label("Poste :")%><%: Html.DropDownList("SelectedPoste", Model.PostesItems)%><input type="checkbox" name="option1" value="Poste Initial" id= "chkMain" onclick="test();"/>Poste Initial<input type="checkbox" name="option2" value="Poste Final" id= "chkFirst" onclick="test2();"/>Poste Final

<%:Html.Label("Nombre de Passage :")%><%: Html.EditorFor(x=>x.YourGammeModel.Nbr_Passage)%>

<%:Html.Label("Position :")%><%: Html.EditorFor(x=>x.YourGammeModel.Position)%>

<%:Html.Label("Poste Précédent :")%><%: Html.DropDownList("SelectedPoste", Model.PostesItems)%>

<%:Html.Label("Poste Suivant :")%><%: Html.DropDownList("SelectedPoste", Model.PostesItems)%>

<input type="button" value="Enregistrer" id="btnSave"  />

I tried to create a function Create in my Controller but that's not given correct result:
public ActionResult Gestion(FlowViewModel model)
{

     model.YourGammeModel = new Gamme();
     return PartialView(model);
}

[HttpPost]
public ActionResult Create(Gamme gamme)
{
    if (ModelState.IsValid)
    {

        db.Gammes.Add(gamme);
        db.SaveChanges();
        return RedirectToAction("Gestion");
    }

    return View(gamme);
}

A: Without seeing exact code it is hard to know how you are loading partial page etc. The button won't do anything because there is no action associated with it. If you change it to a submit then it will fire the same controller as the main view with HttpPost.
Following on from there I think the issue is because your HttpPost action is not named correctly or accepting the correct parameter. In your example you should just use the same action name and ViewModel in the HttpGet and HttpPost so you probably want something like this:
Let's assume your main view is called Index.aspx:
[HttpGet]
public ActionResult Index(FlowViewModel model)
{
    // ...
}

[HttpPost]
public ActionResult Index(FlowViewModel model)
{
    if (ModelState.IsValid)
    {
        db.Gammes.Add(model.YourGammeModel);
        db.SaveChanges();

        // ...
    }

    // ...
}

Then on your PartialView (Gestion.ascx) you need to change your button to something like this: <input type="submit" value="Enregistrer" />
Finally, if you want your submit button to go somewhere other than the main view you need to change your Html.BeginForm code. So, let's say you have an action named ExampleSave on your controller AnouarController you would do this:
<% using (Html.BeginForm("ExampleSave", "Anouar"))


text:
Q: Don't hide the "closed", "duplicate", or "migrated" state of questions on user question lists The redesign of the activity page of the user profile broke a lot of workflows for moderators. One important purpose of that page was to gain a quick overview about what kind of posts a particular user has been posting, especially whether they have low scores or are closed often.
The new activity page makes this impossible. The view is not compact enough to quickly scan questions, which is a problem that already has been mentioned. But one change that wasn't documented as far as I can tell is that the "[closed]", "[duplicate]", and "[migrated]" have been removed from question titles in the user activity page. A closed question is indistinguishable from any other on that page, which is different than pretty much every other page on the whole site.
The closed state must be visible in question lists on the user profile. Please fix this regression.

A: I agree, but in the meantime there's a decent workaround.
As a moderator
Use the search box from the user's page (which is autofilled with user:#####) and add deleted:all closed:1. This gives you all the user's posts that have been closed, or you could just use deleted:all is:q if you wanted to see what questions are closed in the context of all their other questions.
As a regular user
This can even be done on sites where you're not a moderator, except you can't see deleted posts unless you're looking at yourself and you have the ability to see deleted posts (awarded at 2k or 10k reputation, depending on the site).
So, when searching other users, use user:##### closed:1 or user:##### is:q.
Use other advanced search operators for many more options.

A: This is now status-completed.
See this screenshot of my question page:

As you can see, it now shows "[duplicate]" next to my questions closed as duplicates.

A: Purely for illustrative purposes, and to lend further support. Below is a screenshot of a user's activity page and a list of questions asked by that author:

It looks like all four questions are opened when in actual fact two have been closed as duplicates.
The information that a question is closed, for whatever reason, is missing.


text:
Q: How to get single value in php instead of $stmt->fetchObject(); This is my function.
public function getOrderValue($order_id) {
    $sql = "select SUM(OD.quantity * OD.product_sell_price) from table_order_details OD where OD.order_id= :order_id AND OD.is_delete = 0";
    try {
        $stmt = $this->db->prepare($sql);
        $stmt->bindParam("order_id", $order_id);
        $stmt->execute();
        $user = $stmt->fetchObject();
        return $user;

    } catch(PDOException $e) {
        return NULL;
        //echo '{"error":{"text":'. $e->getMessage() .'}}';
    }
}

As there is only single column in query, How to return that value? Basically i want how to fetch SUM alone instead of returning an object $stmt->fetchObject();

A: You can use fetchColumn, but there is nothing wrong with returning $user->total or something similar.
public function getOrderValue($order_id) {
$sql = "SELECT SUM(OD.quantity * OD.product_sell_price) AS total FROM table_order_details OD WHERE OD.order_id= :order_id AND OD.is_delete = 0";
try {
    $stmt = $this->db->prepare($sql);
    $stmt->bindParam("order_id", $order_id);
    $stmt->execute();
    $total = $stmt->fetchColumn();
    return $total;
} catch(PDOException $e) {
    return NULL;
}

}

A: Assuming you're using PDO, you could use fetchColumn
http://php.net/manual/en/pdostatement.fetchcolumn.php


text:
Q: Поменять значение Есть строка с парами ключ=значение; Как можно изменить значение определенного ключа? Например как мне поменять значение ключа KeyB на ValueBB?
KeyA=ValueA; KeyB=ValueB; KeyC=ValueC;

A: String key = "KeyB";
String value = "new_value";
System.out.println("KeyA=ValueA; KeyB=ValueB; KeyC=ValueC;".replaceAll(String.format("%s=.+?;", key),
                String.format("%s=%s;", key, value)));
// KeyA=ValueA; KeyB=new_value; KeyC=ValueC;