text:
Q: limit of a sum of a sequence Compute the following limit or prove that it doesn't exist:
$$
\lim _{n \rightarrow \infty}\left[\frac{1}{n} \sum_{k=1}^{n} \sin \left(\frac{\pi k}{2 n}\right)\right]
$$
Solution
Note that the function $f(x)=\sin \left(\frac{\pi x}{2}\right)$ is continuous and thus
integrable on $[0,1],$ and as it is increasing, then the limits is equal to the
upper sum, converges to the value of the integral
$$\lim _{n \rightarrow \infty}\left[\frac{1}{n} \sum_{k=1}^{n} \sin \left(\frac{\pi k}{2 n}\right)\right]$$
$$
=\lim _{n \rightarrow \infty} \sum_{k=1}^{n}\left[\sin \left(\frac{\pi k}{2 n}\right) \cdot \frac{1}{n}\right]$$
$$
=\int_{0}^{1} \sin \left(\frac{\pi x}{2}\right) d x$$
$$
=\frac{2}{\pi} \int_{0}^{\pi} \sin t d t$$
$$=\frac{2}{\pi}.$$
Can someone explain why it is equal to the upper sum?

A: You have done it right and it is a standard way. Otherwise you may do it as:
$$\sum_{k=1}^n \sin(ak)=\csc(a/2) \sin(an/2) \sin((1+n)a/2)\text{, where } a=\pi/(2n)$$
Then
$$L=\lim_{n \to \infty} \frac{1}{n}\sum_{k=1}^n \sin(\pi k/(2n))$$
So
$$L=\lim_{n \to \infty} \frac{1}{n}~{\csc(\pi/(4n))}~ \sin(\pi/4) ~\sin(\pi/4+\pi/(4n))$$
$$
=\sin^2(\pi/4) \lim_{t\to 0}~ \frac{t}{\sin(t\pi/4)}$$
$$=\frac{1}{2}\frac{4}{\pi}=\frac{2}{\pi}.$$


text:
Q: Docker build hangs. How can I see what is going on? This Dockerfile hangs after the download has completed:
FROM ubuntu:18.04
MAINTAINER Dean Schulze

ENV JS_CE_VERSION 7.1.0
ENV JS_CE_HOME /opt/jasperreports-server-cp-${JS_CE_VERSION}
ENV PATH $PATH:${JS_CE_HOME}

RUN apt-get update && apt-get install -y wget \
&& wget --progress=bar:force:noscroll -O TIB_js-jrs-cp_${JS_CE_VERSION}_linux_x86_64.run https://sourceforge.net/projects/jasperserver/files/JasperServer/JasperReports%20Server%20Community%20Edition%20${JS_CE_VERSION}/TIB_js-jrs-cp_${JS_CE_VERSION}_linux_x86_64.run \
&& chmod a+x TIB_js-jrs-cp_${JS_CE_VERSION}_linux_x86_64.run \
&& /TIB_js-jrs-cp_${JS_CE_VERSION}_linux_x86_64.run --mode unattended --jasperLicenseAccepted yes --postgres_password Postgres1 --prefix ${JS_CE_HOME} \
&& rm TIB_js-jrs-cp_${JS_CE_VERSION}_linux_x86_64.run \
&& rm -rf ${JS_CE_HOME}/apache-ant ${JS_CE_HOME}/buildomatic \
${JS_CE_HOME}/docs ${JS_CE_HOME}/samples ${JS_CE_HOME}/scripts \
&& apt-get clean

EXPOSE 8080

CMD ctlscript.sh start && tail -f /dev/null

The last few lines of output are
Resolving superb-dca2.dl.sourceforge.net (superb-dca2.dl.sourceforge.net)... 209.61.193.20
Connecting to superb-dca2.dl.sourceforge.net (superb-dca2.dl.sourceforge.net)|209.61.193.20|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 343517555 (328M) [application/x-makeself]
Saving to: 'TIB_js-jrs-cp_7.1.0_linux_x86_64.run'

TIB_js-jrs-cp_7.1.0 100%[===================>] 327.60M  1.60MB/s    in 3m 52s

2018-07-28 03:15:28 (1.41 MB/s) - 'TIB_js-jrs-cp_7.1.0_linux_x86_64.run' saved [343517555/343517555]

How do I diagnose a docker build that hangs like this?

Edit

Here's the requested output:
$ docker image history d5d47e51eafc
IMAGE               CREATED             CREATED BY                                      SIZE                COMMENT
d5d47e51eafc        23 minutes ago      /bin/sh -c #(nop)  ENV PATH=/usr/local/sbin:…   0B
831a3a551fa7        23 minutes ago      /bin/sh -c #(nop)  ENV JS_CE_HOME=/opt/jaspe…   0B
e8361426e492        23 minutes ago      /bin/sh -c #(nop)  ENV JS_CE_VERSION=6.3.0      0B
7af364f52b1b        23 minutes ago      /bin/sh -c #(nop)  MAINTAINER JS Minet          0B
735f80812f90        30 hours ago        /bin/sh -c #(nop)  CMD ["/bin/bash"]            0B
<missing>           30 hours ago        /bin/sh -c mkdir -p /run/systemd && echo 'do…   7B
<missing>           30 hours ago        /bin/sh -c sed -i 's/^#\s*\(deb.*universe\)$…   2.76kB
<missing>           30 hours ago        /bin/sh -c rm -rf /var/lib/apt/lists/*          0B
<missing>           30 hours ago        /bin/sh -c set -xe   && echo '#!/bin/sh' > /…   745B
<missing>           30 hours ago        /bin/sh -c #(nop) ADD file:4bb62bb0587406855…   83.5MB

It looks like the lines are in reverse order and the last one executed is the ENV PATH.  The next line would be the RUN line which has multiple commands separated by &&.
This is a modification of a Dockerfile on DockerHub.  I changed ubuntu versions and the version of the app being installed.  That shouldn't have broken anything.
Should I file a bug report?

A: At some point in the last couple of years, Buildkit has become the default Docker backend. Buildkit does not write out intermediate layers as images, as a performance optimization. Therefore, if you need to debug a hanging docker build, comment out the line that the build is hanging at and all subsequent lines. You now have a Dockerfile that you can execute $ docker build . with. Once the build is finished, you can launch the image, bash into the container, run the command that is causing the build to hang and then inspect the state of the container to debug the situation.

A: First list the "layers" of your finished or incomplete image. Each layer typically corresponds to an instruction in your Dockerfile.
Identify the image ID using
docker image ls

then list the layers inside the image using
docker image history <ID>

You will see something like this:
IMAGE               CREATED             CREATED BY                                      SIZE                COMMENT
6c32fe3da793        2 days ago          /bin/sh -c #(nop) COPY file:c25ef1dcc737cb59…   635B
4c1309db9b9c        2 days ago          /bin/sh -c #(nop) COPY dir:30506cf0fc0cdb096…   8.64kB
5f5ae40b5fd5        3 weeks ago         /bin/sh -c apk update && apk add --no-cache …   164MB
989d78741d0b        3 weeks ago         /bin/sh -c #(nop)  ENV DOCKER_VERSION=18.03.…   0B
6160911711fc        3 weeks ago         /bin/sh -c #(nop)  CMD ["python3"]              0B
... etc

Then create a container from any point inside your image. From there you can perform the next instruction that would cause a problem in your Dockerfile.
Eg:
docker run -it --rm 4c1309db9b9c sh

A: I got this to work by rolling back to ubuntu 16.04.  There must be some change in 18.04 that causes this Dockerfile to fail, or maybe the ubuntu 18.04 image omitted something.

redpajama_set_name: RedPajamaStackExchange


text:
Q: Solving the heat equation on the semi-infinite rod Cross posted in scicomp.SE.

I want to test the solution which is given below is right by Mathematica.
Please look the post in mathstackexhange
or
Please look below.
Question: Solve the following heat equation on the semi-infinite rod
$\qquad u_t=ku_{xx}$
where $x,t>0$ and
$\qquad u_x(0,t) =0$ and $u(x,0)=\begin{cases}
          1, & 0 < x <2 \\
          0, &  2\leq x
       \end{cases}$
with proper Fourier transform.
Answer
We found the following answer
$
\qquad u(x,t) = \frac{2}{\pi}\int_{0}^{\infty}e^{-s^2 t}\frac{1-\cos(2s)}{s}\cos(sx)ds.
$
Code
But I am not sure the solution is right. I am not capable of testing it in Mathematica.
Could you help me?

A: Personally I think the problem is interesting, so let me extend my comments to an answer. First of all, DSolve can solve OP's problem straightforwardly (in Mathematica 10.3 or higher, if I remember correctly):
With[{u = u[t, x]},
 eq = D[u, t] == k D[u, x, x];
 ic = u == Piecewise[{{1, 0 < x < 2}}] /. t -> 0;
 bc = D[u, x] == 0 /. x -> 0;]

asol = DSolveValue[{eq, ic, bc}, u, {t, x}, Assumptions -> {x > 0, k > 0}];
asol[t, x]
(* 1/2 (-Erf[(-2 + x)/(2 Sqrt[k] Sqrt[t])] + Erf[(2 + x)/(2 Sqrt[k] Sqrt[t])]) *)

Remark
There seems to be a bug in DSolve in v11.2.0.
DSolve[{eq, ic, bc}, u[t, x], {t, x}]

will return unevaluated.

As one can see, DSolve expresses the solution with Erf, so it's not immediately clear whether OP's solution is correct or not, and Mathematica's functions for simplifying also doesn't work well in this case, so let's obtain the analytic solution with another approach, that is, making use of Fourier cosine transform to eliminate the derivative of $x$:
fct = FourierCosTransform[#, x, s] &;

tset = Map[fct, {eq, ic}, {2}] /. Rule @@ bc /.
  HoldPattern@FourierCosTransform[a_, __] :> a

tsol = u[t, x] /. DSolve[tset, u[t, x], t][[1]]
(* (E^(-k s^2 t) Sqrt[2/π] Sin[2 s])/s *)

Remark
I've made the transform on the PDE in a quick way, for a more general
  approach, check this
  post.

InverseFourierCosTransform has difficulty in transforming tsol, but it doesn't matter because the integral form is just what we want. By checking the formula of inverse Fourier cosine transform, we find the solution should be
$$u(t,x)=\sqrt{\frac{2}{\pi }} \int_0^{\infty } \frac{e^{-k s^2 t} \sqrt{\frac{2}{\pi }} \cos (s x) \sin (2 s)}{s} \, ds$$
It's apparently different from the one in your question, and numeric calculation shows this solution is the same as the one given by DSolve, so the one in your question is wrong.
Finally, a illustration for the solution:
Plot3D[asol[t, x] /. k -> 1 // Evaluate, {x, 0, 4}, {t, 0, 10}]

Update
Inspired by Ars3nous' comment below, I noticed InverseFourierCosTransform can actually transform tsol. We just need a proper assumption:
InverseFourierCosTransform[tsol, s, x, Assumptions -> k > 0]
(* 1/2 (-Erf[(-2 + x)/(2 Sqrt[k t])] + Erf[(2 + x)/(2 Sqrt[k t])]) *)

Apparently it's the same as asol.


text:
Q: Remove over 100,000 rows from mysql table - server crashes I have a question when I try to remove over 100,000 rows from a mysql table the server freezes and non of its websites can be accessed anymore!
I waited 2 hours and then restarted the server and restored the account.
I used following query:
DELETE FROM `pligg_links` WHERE `link_id` > 10000

-
SELECT* FROM `pligg_links` WHERE `link_id` > 10000

works perfectly
Is there a better way to do this?

A: You could delete the rows in smaller sets. A quick script that deletes 1000 rows at a time should see you through.

A: "Delete from" can be very expensive for large data sets.
I recommend using partitioning.
This may be done slightly differently in PostgreSQL and MySQL, but in PostgreSQL you can create many tables that are "partitions" of the larger table or on a partition.  Queries and whatnot can be run on the larger table.  This can greatly increase the speed with which you can query given you partition correctly.  Also, you can delete a partition by simply dropping it.  This happens very very quickly because it is somewhat equivalent to dropping a table.
Documentation for table partitioning can be found here:
http://www.postgresql.org/docs/8.3/static/ddl-partitioning.html

A: Make sure you have an index on link_id column.
And try to delete with chunks like 10.000 in a time.
Deleting from table is very costy operation.


text:
Q: How can I input exactly a five character string on a single line and then out put the string with spaces between each character? Java I want a user to input five letters on a single line (for example the word "hello") and have the output be "h e l l o". I am able to do this with String.replace (as seen below) but I need to use printf and %s to do it.
Scanner scanner = new Scanner(System.in);
System.out.println("Enter five chatracters: ");
String charoutput = scanner.next();
String charoutput2 = charoutput.replace("", "       ");

System.out.println("You have entered: " +charoutput2);

A: You can use printf to print space for each character in string
String str = "hello";
    char[] ch =str.toCharArray();
    for (char c:ch) {
        System.out.printf("%2s", c);  // h e l l o
    }

or you can use Java 8 streams to do it in line
Arrays.stream(str.split("")).forEach(i->System.out.printf("%2s",i)); //h e l l o

A: There are multiple ways to solve this:
Using String.join:
String input = "Hello";
String result = String.join(" ", input.split(""));
// result now holds "H e l l o"

Using regex with replaceAll:
String input = "Hello";
String result = input.replaceAll(".","$0 ").trim();
// result now holds "H e l l o"

Using a loop:
String input = "Hello";
int length = input.length;
for(int i=0; i<length; i++)
  System.out.printf("%c%s", input.charAt(i), i<length ? " " : "");
// outputs "H e l l o"

Using printf:
String input = "Hello";
for(char c : input.toCharArray())
  System.out.printf("%2c", c);
// outputs " H e l l o" (NOTE the leading space!)

Try it online.
My preference would be the String.join, since it's basically a builtin of what you want to do.

A: Here is one of the ways you can do that:
Scanner scanner = new Scanner(System.in);
System.out.println("Enter five chatracters: ");
String charOutput = scanner.next();

String separatedChars = "";
for(char c: charOutput.toCharArray()) {
    separatedChars += c + " ";
}

System.out.printf("You have entered: %s", separatedChars);

Here you iterate through each char of the received string and add it to the separatedChars variable followed by a space. Then, the result is printed using printf.


text:
Q: Writing a shell emulator in C for Operating Systems: Shell not staying active after multiple commands given These are the requirements:

*

*Can execute a command with the accompanying arguments.

*Recognize multiple pipe requests and handle them.

*Recognize redirection requests and handle them.

*Type "exit" to quit the shhh shell.

Here are my issue:
Whenever I do more than one command (with command1 | command2), my shell terminates after executing the commands given, instead of waiting for another command line prompt inside my shell. The program is supposed to keep running, and allow a user to enter more commands, until the enter "exit."
Code:
        #include <stdio.h>
        #include <stdlib.h>
        #include <string.h>
        #include <unistd.h>
        #include <sys/types.h>
        #include <sys/stat.h>
        #include <fcntl.h>

    int main() {
        // professor-supplied variables for commands and command parsing
        char *path, *argv[20], buf[80], n, *p;
        int m, status, inword, continu;

        // flags for redirection (note: C does not have type bool; using integer value 0 or 1)
        int inputRedirectFlag, outputRedirectFlag, backgroundJobFlag;
        int numArguments, argIndex, argCount, pipes, openPipesCount, pid, directoryIndex;

        // pipes
        int p1[2], p2[2];

        // index for directory set prior to while(1)
        directoryIndex = 0;

        while (1) {

            inword = 0;
            p = buf;
            m = 0;
            continu = 0;
            numArguments = 0;
            argIndex = 0;
            argCount = 0;
            pipes = 0;
            openPipesCount = 0;
            pid = 0;

            // required containers
            int argumentContainer[20] = { 0 };
            char currentDirectory[80] = { 0 };

            // file variables
            char *outputFile = (char *)0;
            char *inputFile = (char *)0;

            // redirection flags
            inputRedirectFlag = 0;
            outputRedirectFlag = 0;
            backgroundJobFlag = 0;

            // SHELL PROMPT
            printf("\nshhh> ");

            // COMMAND PARSING
            while ((n = getchar()) != '\n' || continu)
            {
                /*************************************************
                 required addition to remediate segmentation fault
                *************************************************/
                 if (n == EOF){
                    exit(0);
                }

                if (n == ' ') {
                    if (inword)
                    {
                        inword = 0;
                        *p++ = 0;
                    }
                }
                else if (n == '\n')
                    continu = 0;
                else if (n == '\\' && !inword)
                    continu = 1;
                else {
                    if (!inword)
                    {
                        inword = 1;
                        argv[m++] = p;
                        *p++ = n;
                    }
                    else
                        *p++ = n;
                }
            }

            *p++ = 0;
            argv[m] = 0;

            // capture current working directory
            getcwd(currentDirectory, 80);

            // user wishes to terminate program
            if (strcmp(argv[0], "exit") == 0)
                exit(0);

            // managing input and output redirection and piping
            while (argv[argCount] != 0) {
                if (strcmp(argv[argCount], "<") == 0)
                {
                    inputFile = strdup(argv[argCount + 1]);
                    argv[argCount] = 0;
                    argv[argCount + 1] = 0;
                    inputRedirectFlag = 1;
                }
                else if (strcmp(argv[argCount], ">") == 0)
                {
                    outputFile = strdup(argv[argCount + 1]);
                    argv[argCount] = 0;
                    argv[argCount + 1] = 0;
                    outputRedirectFlag = 1;
                }
                else if (strcmp(argv[argCount], "&") == 0)
                {
                    argv[argCount] = 0;
                    backgroundJobFlag = 1;
                }
                else if (strcmp(argv[argCount], "|") == 0)
                {
                    argv[argCount] = 0;
                    argumentContainer[pipes + 1] = argCount + 1;
                    pipes++;
                }
                else
                    argumentContainer[argCount] = argCount;

                ++argCount;
            }

            // execute commands
            for (int i = 0; i <= pipes; ++i) {
                // pipe and track piping
                if (i < pipes) {
                    pipe(p1);
                    ++openPipesCount;
                }

                /*************************************
                 SWITCH STATEMENT FOR PIPE EXECUTION
                *************************************/

                /*******************************************************
                 Using file flags:
                 O_CREAT: creates file if file does not already exist
                 O_RDONLY: Access mode for file (read only)
                 00700(Mode): read/write/execute permission granted
                 From: http://man7.org/linux/man-pages/man2/open.2.html
                ********************************************************/

                // parent forks child for every exec()
                switch (pid = fork()) {
                    case -1: // process error
                            perror("fork failed");
                            break;

                    case 0: // child process
                            if ((i == 0) && (inputRedirectFlag == 1)) {
                                int input = open(inputFile, O_RDONLY | O_CREAT);
                                if (input == -1) {
                                printf("Input file failed to open\n");
                                return(EXIT_FAILURE);
                            }
                            close(0);
                            dup(input);
                            close(input);
                            }
                            else if ((i == pipes) && (outputRedirectFlag == 1)) {
                                int output = open(outputFile, O_WRONLY | O_CREAT, 00700);
                                if (output < 0) {
                                printf("Output file failed to open\n");
                                return(EXIT_FAILURE);
                            }
                            close(1);
                            dup(output);
                            close(output);
                        }
                        // EXECUTE COMMAND
                        execvp(argv[argumentContainer[argIndex]], &argv[argumentContainer[argIndex]]);
                        break;

                    default: // parent process
                            if (openPipesCount > 0) {
                                close(p2[0]);
                                close(p2[1]);
                            }
                            p2[0] = p1[0];
                            p2[1] = p1[1];
                            break;
                }
                /*************************************
                 END SWITCH STATEMENT FOR PIPE EXECUTION
                 *************************************/

                // if job is not a run-in-background process, wait for process to complete
                if (backgroundJobFlag == 0)
                    wait((int *)0);
            }

            // user wishes to terminate program
            if (strcmp(argv[0], "exit") == 0)
                exit(0);

            // clear all executed commands
            for (int i = 0; i < 20; ++i)
                argv[i] = 0;

            wait(&status);
        }
    }

First update/change. Multiple commands are working, but now my file redirection (for input) is not working, among other issues:
    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    #include <sys/types.h>
    #include <unistd.h>
    //#include <sys/stat.h>
    #include <fcntl.h>

    #ifndef READ
    #define READ 0
    #endif

    #ifndef WRITE
    #define WRITE 1
    #endif

    int main() {
        // professor-supplied variables for commands and command parsing
        char *path, *argv[20], buf[80], n, *p;
        int m, status, inword, continu;
        int inputRedirectFlag, outputRedirectFlag, backgroundJobFlag;
        int numArguments, argIndex, argCount, activeCommands, openPipesCount;
        pid_t pid;
        int directoryIndex, commandArchiveIndex;
        int oldFileDescriptor[2], newFileDescriptor[2];
        directoryIndex = 0;

        while (1) {
            inword = 0;
            p = buf;
            m = 0;
            continu = 0;
            numArguments = 0;
            argIndex = 0;
            argCount = 0;
            activeCommands = 0;
            openPipesCount = 0;
            pid = 0;
            path = (char*)0;

            // required containers
            int argumentContainer[20] = { 0 };
            char currentDirectory[80] = { 0 };

            // archive of all commands
            char *commandArchive[20] = { 0 };

            // redirection flags
            inputRedirectFlag = 0;
            outputRedirectFlag = 0;

            backgroundJobFlag = 0;

            // SHELL PROMPT
            printf("\nshhh> ");

            // COMMAND PARSING
            while ((n = getchar()) != '\n' || continu)
            {
                if (n == ' ') {
                    if (inword)
                    {
                        inword = 0;
                        *p++ = 0;
                    }
                }
                else if (n == '\n')
                    continu = 0;
                else if (n == '\\' && !inword)
                    continu = 1;
                else {
                    if (!inword)
                    {
                        inword = 1;
                        argv[m++] = p;
                        *p++ = n;
                    }
                    else
                        *p++ = n;
                }
            }

            *p++ = 0;
            argv[m] = 0;

            // capture all commands in command archive
            while (argv[argIndex] != 0)
            {
                commandArchive[numArguments] = strdup(argv[argIndex]);
                numArguments++;
                ++argIndex;
            }

            // capture current working directory
            getcwd(currentDirectory, 80);

            // user wishes to terminate program
            if (strcmp(argv[0], "exit") == 0)
                exit(0);

            /*************************
             MANAGE BUILT-IN FUNCTIONS
             **************************/
            // user command is "cd"
            if (strcmp(argv[0], "cd") == 0) {
                if (strcmp(argv[1], ".") == 0){ // this should do nothing as a command
                    // *path = ???
                    break;
                }
                else if (strcmp(argv[1], "..") == 0) { // this should move user up one directory
                    // *path = ???
                     // NEED TO PASS PATH HERE!
                    chdir(currentDirectory);
                }
                else {
                    while (argv[directoryIndex] != 0) {
                        getcwd(currentDirectory, 80);
                        // *path = ???
                        // NEED TO PASS PATH HERE!
                        chdir(argv[directoryIndex]);
                        ++directoryIndex;
                    }
                }
            }

            /********************************************
             MANAGE REDIRECTION AND BACKGROUND PROCESSING
            ********************************************/
            while (argv[argCount] != 0) {
                if (strcmp(argv[argCount], "|") == 0) {
                    argv[argCount] = 0;
                    argumentContainer[activeCommands + 1] = argCount + 1;
                    ++activeCommands;
                }
                else if (strcmp(argv[argCount], "<") == 0) {
                    path = strdup(argv[argCount + 1]);
                    argv[argCount] = 0;
                    argv[argCount + 1] = 0;
                    inputRedirectFlag = 1;
                }
                else if (strcmp(argv[argCount], ">") == 0) {
                    path = strdup(argv[argCount + 1]);
                    argv[argCount] = 0;
                    argv[argCount + 1] = 0;
                    outputRedirectFlag = 1;
                }
                else if (strcmp(argv[argCount], "&") == 0) {
                    argv[argCount] = 0;
                    backgroundJobFlag = 1;
                }
                else {
                    argumentContainer[argCount] = argCount;
                }

                ++argCount;
            }

            // execute commands
            for (int pipeIndex = 0; pipeIndex <= activeCommands; ++pipeIndex) {
                if (pipeIndex < activeCommands) { // if user has entered multiple commands with '|'
                    pipe(oldFileDescriptor);
                    pipe(newFileDescriptor);
                    ++openPipesCount;
                }

                /*************************************
                 SWITCH STATEMENT FOR PIPE EXECUTION
                 *************************************/

                // capture current path
                //path = getenv("PATH");

                /*******************************************************
                 Using file flags:
                 O_CREAT: creates file if file does not already exist
                 O_RDONLY: Access mode for file (read only)
                 0600(Mode): owner can read/write
                ddddddddddddd
                 ********************************************************/

                // parent forks child for every exec()
                switch (pid = fork()) {
                    case -1: // process error
                        perror("fork failed");
                        break;

                    case 0: // child process

                        /****************************************************
                         HAVE CHILD PROCESS MANAGE REDIRECTION
                         ****************************************************/
                        if ((pipeIndex == 0) && (inputRedirectFlag == 1)) {
                            int input = open(path, O_RDONLY | O_CREAT, 0600);
                            if (input == -1) {
                                printf("Input file failed to open\n");
                                return(EXIT_FAILURE);
                            }
                            //close(READ);
                            //dup(input);
                            //close(input);
                            dup2(input, READ);
                            close(input);
                        }
                        else if ((pipeIndex == activeCommands) && (outputRedirectFlag == 1)) {
                            int output = open(path, O_WRONLY | O_CREAT, 0600);
                            if (output < 0) {
                                printf("Output file failed to open\n");
                                return(EXIT_FAILURE);
                            }
                            //close(WRITE);
                            //dup(output);
                            //close(output);
                            dup2(output, WRITE);
                            close(output);
                        }
                        /****************************************************
                         REDIRECTION (IF APPLICABLE) EXECUTED BY CHILD PROCESS
                         ****************************************************/

                        /*******************************************************************************
                         CHILD EXECUTES COMMAND:
                         *******************************************************************************/
                        execvp(argv[argumentContainer[pipeIndex]], &argv[argumentContainer[pipeIndex]]);
                        /*******************************************************************************
                         EXECUTION COMPLETE
                         *******************************************************************************/
                        break;

                    default: // parent process
                        if (openPipesCount > 0) { // previous command
                            //close(READ);
                            //dup(newFileDescriptor[READ]);
                            close(newFileDescriptor[READ]);
                            close(newFileDescriptor[WRITE]);
                        }

                        if (openPipesCount < activeCommands) { // more commands need to be executed
                            close(newFileDescriptor[READ]);
                            dup(newFileDescriptor[WRITE]);
                            close(newFileDescriptor[WRITE]);
                        }

                        oldFileDescriptor[READ] = newFileDescriptor[READ];
                        oldFileDescriptor[WRITE] = newFileDescriptor[WRITE];
                        break;
                }
                /***************************************
                 END SWITCH STATEMENT FOR PIPE EXECUTION
                 **************************************/

                // if job is not a run-in-background process, wait for process to complete
                if (backgroundJobFlag == 0)
                    wait((int *)0);
            }

            // user wishes to terminate program
            if (strcmp(argv[0], "exit") == 0)
                exit(0);

            // clear all executed commands
            for (int i = 0; i < 20; ++i)
                argv[i] = 0;

            wait(&status);
        }
    }

I know I'm probably doing something wrong with argumentContainer[] or my piping. I'm just lost.
UPDATED VERSION (update 2):
I made quite a few changes after discussing my code with my professor. It's nearly working. I'm able to pipe multiple commands, etc. However, "wc" seems to freeze and wait for an EOF (ctrl+d), and cd isn't changing directories. Wonder if I need to make a special case/code for "cd."
CODE:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <unistd.h>
#include <sys/stat.h>
#include <fcntl.h>

#ifndef READ
#define READ 0
#endif

#ifndef WRITE
#define WRITE 1
#endif

int main() {
    /* professor-supplied variables for commands and command parsing */
    char *path, *argv[20], buf[80], n, *p;
    int m, status, inword, continu;

    /* flags for redirection (note: C does not have type bool; using integer value 0 or 1) */
    int inputRedirectFlag, outputRedirectFlag;

    /* variables for piping */
    int count, pipes;
    pid_t pid;

    /* pipes */
    int l_pipe[2], r_pipe[2];

    while (1) {
        inword = m = continu = count = pipes = pid = 0;
        p = buf;

        /* required container for handling arguments */
        int argumentContainer[20] = { 0 };

        /* redirection flags */
        inputRedirectFlag = 0;
        outputRedirectFlag = 0;

        /* shell prompt */
        printf("\nshhh> ");

        /* command parsing */
        while ((n = getchar()) != '\n' || continu)
        {
            if (n == ' ') {
                if (inword)
                {
                    inword = 0;
                    *p++ = 0;
                }
            }
            else if (n == '\n')
                continu = 0;
            else if (n == '\\' && !inword)
                continu = 1;
            else {
                if (!inword)
                {
                    inword = 1;
                    argv[m++] = p;
                    *p++ = n;
                }
                else
                    *p++ = n;
            }
        } /* end of command parsing */

        *p++ = 0;
        argv[m] = 0;

        /* user wishes to terminate program */
        if (strcmp(argv[0], "exit") == 0)
            exit(0);

        /* manage redirection */
        while (argv[count] != 0) {
            if (strcmp(argv[count], "|") == 0) {
                argv[count] = 0;
                argumentContainer[pipes + 1] = count + 1;
                ++pipes;
            }
            else if (strcmp(argv[count], "<") == 0) {
                path = strdup(argv[count + 1]); /* copy string argument (file string) */
                argv[count] = 0;
                argv[count + 1] = 0;
                inputRedirectFlag = 1;
            }
            else if (strcmp(argv[count], ">") == 0) {
                path = strdup(argv[count + 1]); /* copy string argument (file string) */
                argv[count] = 0;
                argv[count + 1] = 0;
                outputRedirectFlag = 1;
            }
            else {
                argumentContainer[count] = count;
            }

            ++count;
        } /* end of redirection management */

        /* execute commands */
        for (int index = 0; index <= pipes; ++index) {
            if (index < pipes) { /* if user has entered multiple commands with '|' */
                pipe(r_pipe); /* no pipe(l_pipe); r_pipe becomes next child's l_pipe */
            }

            /*************************************************************************
             FILE FLAG AND FILE MODE DESCRIPTION AND DETAILS:
             *************************************************************************
             Using file flags:
             O_CREAT: creates file if file does not already exist
             O_REDONLY: Acess mode for file (read only)
             O_WRONLY: Access mode for file (write only)
             0600(Mode): owner can read/write
             From:
             http://www.thinkplexx.com/learn/article/unix/command
             ************************************************************************
             ***********************************************************************/

            /* switch-statement for command execution */
            switch (pid = fork()) {
                /* fork() error */
                case -1: perror("fork failed");
                         break;

                case 0: /* child process manages redirection and executes */
                       if ((index == 0) && (inputRedirectFlag == 1)) {
                           int input = open(path, O_RDONLY , 0600);
                           if (input == -1) {
                               printf("Input file failed to open\n");
                               return(EXIT_FAILURE);
                           }
                           dup2(input, READ);
                           close(input);
                       } /* end of input redirection management */
                       else if ((index == pipes) && (outputRedirectFlag == 1)) {
                           int output = open(path, O_WRONLY | O_CREAT, 0600);
                           if (output < 0) {
                               printf("Output file failed to open\n");
                               return(EXIT_FAILURE);
                           }
                           dup2(output, WRITE);
                           close(output);
                       } /* end of output redirection management */

                       /* command executed */
                       execvp(argv[argumentContainer[index]], &argv[argumentContainer[index]]);

                       /* execvp() fails */
                       printf("execution of command failed\n");

                       break;

                default: /* parent process manages the pipes for child process(es) */
                        if (index > 0) {
                            close(l_pipe[READ]);
                            close(l_pipe[WRITE]);
                        }
                        l_pipe[READ] = r_pipe[READ];
                        l_pipe[WRITE] = r_pipe[WRITE];

                        break;
            } /* end of switch-statement for command execution */
        } /* end of loop for all pipes */

        // user wishes to terminate program
        if (strcmp(argv[0], "exit") == 0) {
            exit(0);
        }

        // clear all executed commands
        for (int i = 0; i < 20; ++i) {
            argv[i] = 0;
        }

        wait(&status);
    }
}

A: The problem is in your pipe handling. You're always closing the pipes in p2, but the first time through the loop, they haven't been initialized to anything. Only p1 has been initialized. One of the values that is by default in p2 is likely 0, which is the file descriptor number for STDIN. As a result, you're closing the parent program's STDIN when you try to close the pipes in p2 on the first iteration of the loop.


text:
Q: Node not recognized although successfully installed I try to run nodejs on a brand new installation of Windows 7.
This is what I've done:

*

*Install node using the windows installer

*Make sure the files were extracted to C:\Program Files (x86)\nodejs\

*Make sure that my Path enviorment variable contains C:\Program Files (x86)\nodejs\

*open up a command prompt and run node -v
This gives me the 'node is not a recognized ...' - message.
What am I missing here?

Update
running echo %path% gives me a directory listing that doesn't include C:\Program Files (x86)\nodejs\, even though looking at the "environment variables" tab in the system properties displays it under path. Thats odd.

A: UPDATE: a quicker solution is per Timos comment: "Restarting explorer.exe is enough, you can stop it in task manager and start it again"
This was solved by restarting the computer.
Apparently, using the Node installer sets the path so that it is visible under system properties, but not in the command prompt (running echo %path%) until you restart your computer. Not sure if this is a problem with Windows, or the Node Installer.

A: Timo's statement is accurate. For completeness...
To start explore.exe again, Ctrl+Shift+Esc to open Task Manager
Then do  File > New Task (Run)> type: explorer.exe > Enter > Voila!

A: If node is installed via nvm.
Then it's important to run the command nvm use <installed version>.
And, it will hopefully work after that.


text:
Q: fetch-mock calls the actual API instead of mocking the request Given this code:
const fetch = require('isomorphic-fetch')
module.exports = function suggestions (...args) {
  // some error handling code
  return fetch(MY_ENDPOINT)
}

I have found that when using fetch-mock like this:
require('isomorphic-fetch')
const fetchMock = require('fetch-mock/es5/server')
fetchMock.mock(MY_ENDPOINT, [{}, {}])

describe('My spec', () => {
  it('fakes a request to my endpoint', async () => {
      const myData = await myCode(...args) // calls fetch with my endpoint
      expect(myData).toEqual([{}, {}])
  })
})

I would expect the mock to give me the response I set up which is [{},{}], instead it calls the real API and returns the response from it.
Also, if I try to use fetch-mock instead of fetch-mock/es5/server I get the error:
/Users/localuser/lendi/ldp-domain-integration/node_modules/fetch-mock/src/lib/fetch-handler.js:57
    FetchMock.generateResponse = async function (response, url, opts) {
                                       ^^^^^^^^

    SyntaxError: Unexpected token function

I use jest with babel and babel-jest along with node v6.13.0.

A: The reason for the Syntax error is that async functions are not supported in Node version 6.
Try updating Node to the latest version.


text:
Q: Whether block scheduling is done by GPU? Can we assign a block to a specific SM programmatically? Can we get runtime information(number of blocks or warps,a block's or  warp's execution time etc.) of SM?

A: *

*No.

*No.

Nothing of this sort is exposed by the standard CUDA runtime and driver APIs.


text:
Q: Selecting data from multiple tables in pytables How shoud I do this in the fastest way?
I have a .h5 file with some tables. Tables have like 10millions (or more) rows each one.
The whole file is around 10GB, (file does not fit in memory)
The tables are "linked", meaning that, all of them have the same column (ID), used as the column to link between them.
Now, if I call my tables: table1, table2 table3 table4, etc... I am looking for the fastest way perform a fast search in table2, whith the ID data from table1.
As an example, this is what I have done so far:
#search on the table1 and get ID's for the first condition
searchID= "".join(["(ID==%i)|"%j['ID'] for j in table1.where('some conditions for table1')])[:-1]

#search on table2 based on the ID's from table1
for row in table2.where(searchID):
    #do something with row

The problem is that I do not think that this is a very efficient solution. And, I have noticed that, if searchID grows a lot, Spyder just crashes.....

A: There are a couple of things that you could do to potentially make this faster, though there is not a silver bullet.

*

*If you can combine all of the tables into one table with more columns then you wouldn't have to loop through twice.

*You could index the tables based on ID. This would improve search performance.

*Change the chunkshape of the tables to be more optimal for you problem. If you make it smaller, then this should help with the crashes.


text:
Q: C argument definition problem When I want to pass a "char (*c)[10];" as a parameter,
what argument should I define in my function definition?
I mean, if I have a function:
void foo(*****) { ... }

I want to pass char (*c)[10]; to it, so what do I write in place of *****?

A: This should work fine:
void foo(char (*c)[10]);

A: You should be able to pass it simply as you're declaring it:
void foo(char (*c)[10]);

And call it as:
foo(c);

This is the best post on this subject: C pointers : pointing to an array of fixed size

A: Define the function as:
void foo(char (*c)[10])
{
    for (int i = 0; i < sizeof(*c); i++)
        printf("%d: %c\n", i, (*c)[i]);
}

Use the function as:
int main(void)
{
    char a[10] = "abcdefghi";
    char (*c)[10] = &a;
    foo(c);
    return(0);
}


text:
Q: mplayer2 playing pictures from mp3 Recently i've switched from mplayer to mplayer2 and there's one pestering thing: when i play an .mp3 file, and there is a picture embedded (here's an excerpt from exiftool output)

Picture Mime Type               : image/jpeg
Picture Type                    : Front Cover
Picture Description             :
Picture                         : (Binary data 26267 bytes, use -b option to extract)

mplayer2 tries to play this picture:

Detected file format: MP2/3 (MPEG audio layer 2/3) (libavformat)
[mp3 @ 0x7f95709a9000]max_analyze_duration 5000000 reached at 5015510
[lavf] stream 0: audio (mp3), -aid 0
[lavf] stream 1: video (mjpeg), -vid 0,
Clip info:
 album_artist: Divna Ljubojevic
 genre: Contemporary Christian
 album: Мелoди
 artist: Дивна Љубоjевић и Мелоди
 title: Аксион естин
 track: 01
 date: 2002
Load subtitles in /home/pooh/music/!CHRISTIAN/Дивна Љубоjевић и Мелоди/2002 - Мелoди/
[VO_XV] Could not grab port 63.
[VO_XV] Could not grab port 64.
[ass] auto-open
Selected video codec: MJPEG (Motion JPEG) [libavcodec]
Selected audio codec: MPEG 1.0/2.0/2.5 layers I, II, III [mpg123]
AUDIO: 44100 Hz, 2 ch, s16le, 80.0 kbit/5.67% (ratio: 10000->176400)
AO: [alsa] 48000Hz 2ch s16le (2 bytes per sample)
Starting playback...
VIDEO:  337x337  90000.000 fps    0.0 kbps ( 0.0 kB/s)
VO: [xv] 337x337 => 337x337 Planar YV12  [fs]
[ASPECT] Warning: No suitable new res found!
Colorspace details not fully supported by selected vo.
No pts value from demuxer to use for frame!
Video pts after filters MISSING

How to fight this nuisance?
Upd. The problem is not how to mask this behaviour, but rather how to make the right thing. Why in the first place it has an idea of playing embedded album picture? mplayer didn't have this… feature.

A: From man mplayer:
   -novideo
          Do not play/encode video.  In many cases this will not work, use
          -vc null -vo null instead.

Based on that statement, one (and possibly both) of the following should work:
mplayer -novideo foo.mp3

mplayer -vc null -vo null foo.mp3


text:
Q: Spring Batch Split Processor I need to apply different processor chains based on record properties, producing different record types.
                             /--> processor A --> writer A
reader --> split processor --|
                             \--> processor B --> writer B

So that processing vary by read items:
A record (read) -> (split processor) -> (processor A) -> (writer A)
B record (read) -> (split processor) -> (processor B) -> (writer B)

This can be made using multiple ItemProcessListeners and writing filtering logic in afterProcess().
Looking for a better approach.

A: The ClassifierCompositeItemProcessor is what you are looking for (what you call split processor). This item processor uses a Classifier to classify items and pass them to delegate processors accordingly.
To achieve the pattern you described, you would need to combine this processor with a similar item writer: the ClassifierCompositeItemWriter.


text:
Q: Concentration of difference of uniform random variables Suppose, we have to independent uniform random variables $V \in [0,a]$ and $W\in [0,b]$.
Are there any upper bounds on
\begin{align}
P [ |U-V| \le r ]
\end{align}
for some given $r$?
Note that lower bounds are easy since
\begin{align}
P[|U-V|\le r]=1-  P[|U-V|> r]
\end{align}
where by Azuma-Hoeffing inequality  we can
\begin{align}
P[|U-V|> r] \le 2 e^{-\frac{r^2}{2 d^2 }}
\end{align}
where $d$ is given by  $  \max |U-V| \le d=\max(a,b)$.


text:
Q: Extracting code from TWebAction for Synchronize()ing in main thread? I'm having a hard time wrapping my head around using Synchronize from a TWebActionItem.
My webservice is a visual program with form TFormWebServices
var FormWebServices: TFormWebServices;

This has a property FWebBrokerBridge: TIdHTTPWebBrokerBridge
The FWebBrokerBridge registers TWebModuleWebServices as the classes to use for each incoming call:
FWebBrokerBridge.RegisterWebModuleClass(TWebModuleWebServices);

The TWebActionItem items in this class do the work reading a TWebRequest and writing a TWebResponse.
There is one handler that needs to use some VCL visual rendering (shared code with another app) and I want to Synchronize this with the main thread (FormWebServices).
Stub:
TWebModuleWebServices = class(TWebModule)
  procedure WebModuleWebServicesTTGetDynReportAction(Sender: TObject; Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
  procedure WebModuleAfterDispatch(Sender: TObject; Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
 private
   FResponse: TResBase;     // JSON response object
 end;

procedure TWebModuleWebServices.WebModuleWebServicesTTGetDynReportAction(Sender: TObject; Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
var
  lFrmDynRapport : TFormDynRapport;   // A form containing the common code, has VCL components
begin
  lResponse := (FResponse as TResGetDynReport);  // TResGetDynReport = class(TResBase)
  // ...
  lFrmDynRapport := TFormDynRapport.Create(Self);
  try
     with lFrmDynRapport do
     begin
        // Do visual stuff with grids, read grid settings, fill lResponse with info specific for this webaction
     end
  finally
  end
  // ...
end;

procedure TWebModuleWebServices.WebModuleAfterDispatch(Sender: TObject; Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
var lJSO: ISuperObject;  // SuperObject library
begin
  lJSO := FResponse.ToJson;
  // ...
  Response.Content := lJSO.AsString;
  Handled := true;
end;

Now how can I properly Synchronize the try/finally block?
I can get at the current thread and do something simple like:
lThread := TThread.CurrentThread;
TThread.Synchronize(lThread,procedure
  begin
    FormWebServices.MmoLog.Lines.Add('Synchronize test');
  end);

but for anything more complex I'm stuck.
Defining local procedures and feeding these into Synchronize does not work (E2555 cannot capture symbol).
How can I extract the try/finally block so that I can properly execute it in the context of FormWebServices?

A: The trick is to put the entire block in an anonymous method (thanks for the tip, David):
if lFlexRapDM.DesignerCustomOpenDoc(lFlexRapDM.TimeTellReport) then
   begin
      .....
      lThread := TThread.CurrentThread;
      TThread.Synchronize(lThread,procedure
            var l,lIndex       : integer;
            ...
            begin
               lFrmDynRapport := TFormDynRapport.Create(Self);
               try
                  with lFrmDynRapport do
                  begin
                     ...
                  end; // with FrmDynReport
               finally
                  lFrmDynRapport.Free;
               end;
            end);
      ...
   end // if lFlexRapDM.DesignerCustomOpenDoc


text:
Q: How to play YouTube video in Android player? I want to play YouTube videos on Android without using YouTube app. It should play with Android player. We have tried using YouTube app, but we need to play YouTube videos directly with Android player, not using YouTube application.
Is it possible? If it is, how to do it?

A: try this.
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    VideoView videoView = (VideoView) findViewById(R.id.VideoView);
    MediaController mediaController = new MediaController(this);
    mediaController.setAnchorView(videoView);
    // Set video link (mp4 format )
    Uri video = Uri.parse("your url in rtsp format");
    videoView.setMediaController(mediaController);
    videoView.setVideoURI(video);
    videoView.start();
}

A: Its simple just create video view then add a new media controller to it, set the video URL in the video view and start the video it will work.
Add the below Code into your MainActivity.java file.
    @Override
 protected void onCreate(Bundle savedInstanceState)

      // TODO Auto-generated method stub
     super.onCreate(savedInstanceState);
     try {
     setContentView(R.layout.videodisplay);
     String link="http://www.youtube.com/watch?v=JSnB06um5r4";
     VideoView videoView = (VideoView) findViewById(R.id.VideoView);
     MediaController mediaController = new MediaController(this);
     mediaController.setAnchorView(videoView);
     Uri video = Uri.parse(link);
     videoView.setMediaController(mediaController);
     videoView.setVideoURI(video);
     videoView.start();
 } catch (Exception e) {
     // TODO: handle exception
     Toast.makeText(this, "Error connecting", Toast.LENGTH_SHORT).show();
 }

}
You better try it on offline file to make sure that the video viewer is working fine (the video is compatible with device) then play it online


text:
Q: Why does gradle not implementing com.android.support:design:28.0.0 for adding TextInputLayout? I'm trying to add TextInputLayout for Android Material Design Floating Labels for EditText.
I have added implementation 'com.android.support:design:28.0.0' which shows to add
*

noinspection GradleCompatible

My build.gradle as below
apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "29.0.2"

    defaultConfig {
        applicationId "com.example.writeproctor"
        minSdkVersion 21
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility = 1.8
        targetCompatibility = 1.8
    }

}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    //noinspection GradleCompatible
    implementation 'com.android.support:design:28.0.0'
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    testImplementation 'junit:junit:4.13'
    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}

I have suppressed the warning but still not able add TextInputLayout.
How can i add TextInputLayout in this latest android studio 3.5.3?

A: if you wanna use implementation 'com.android.support:design:28.0.0' then you should replace
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'

with
implementation 'com.android.support:appcompat-v7:28.0.0-alpha3'
implementation 'com.android.support.constraint:constraint-layout:1.1.1'

Your error happens because androidX and android support is different versions of android libraries and you trying to use them both, support library is depricated, so it is recommended by Google to use AndroidX.
You better don't use 'com.android.support:design:28.0.0'
Replace it with
implementation 'com.google.android.material:material:1.0.0'

Btw guy here gave a complete answer what is Support and AndroidX libraries how it
correlate with each other and etc.


text:
Q: IOS YouTube Helper Library I am trying to use this Library to play youtube video in my ios app, it works for when I load the page for the first time, when I go back to the previous view controller and go into the viewcontroller again which have the youtube video, the video player doesn't show up any more, unless I kill the app and restart again. Not sure Why it is like.
I have a view controller, in the view controller I am using this library to play youtube videos. when I get into this view controller for the first time it all works fine, but when i get to this view controller for the second time, the player not showing up unless I kill the app.
- (void)viewDidLoad
{
    [super viewDidLoad];
    [self.player loadPlayerWithVideoId:@"M7lc1UVf-VE"];
}

-(YTPlayerView*)player
{
    if(!_player)
    {
        _player = [[YTPlayerView alloc] initWithFrame:CGRectMake(0, 50, self.view.bounds.size.width, 220)];
        _player.delegate = self;
        _player.autoplay = NO;
        _player.modestbranding = YES;
        _player.allowLandscapeMode = YES;
        _player.forceBackToPortraitMode = YES;
        _player.allowAutoResizingPlayerFrame = YES;
        _player.playsinline = NO;
        _player.fullscreen = YES;
        _player.playsinline = YES;
    }
    return _player;
}

A: I have used this library to load youtube video and it's working fine for me in the situation you described....
You should declare YTPlayerView as property in .h file like this.
@property(nonatomic, strong) IBOutlet YTPlayerView *playerView;
It is working well for me.


text:
Q: Is there a point in using FormsAuthentication.SignOut when not using built-in Membership functionality In my web application I use totally custom functionality for logging in.So, nothing from Web.Security.I control everything with Session and ViewState variables.
To log out from the application I use Session.Abandon() command.
I wonder if I should also call FormsAuthentication.SignOut()?I took a look at the official documentation of this method, but did not quite get it.What benefit do I take from it?

A: If you're still using forms authentication (even though you're not using the built-in ASP.NET Membership provider), then yes you should call SignOut as it'll get rid of the authentication cookie.
However, if you've even gone as far as to not use forms authentication at all, then there'll be no authentication cookie, so there's no point in calling it.

A: I have to admit that the official documentation has a lot to say on SignOut. The remarks section contains a lot of interesting information.

The SignOut method removes the forms-authentication ticket information from the cookie or the URL if CookiesSupported is false. You can use the SignOut method in conjunction with the RedirectToLoginPage method to log one user out and allow a different user to log in.
  If you run exclusively in cookieless mode, or if you support both authenticated and anonymous users, you should explicitly control the redirect to the login page if you require special business logic to execute as a result of removing the anonymous identifier.
  When the SignOut method is called, a redirect to the application's login page is made by calling the Redirect method with the endResponse parameter set to false. The redirect does not take place until the current page has finished executing, so additional code can be run. If the code does not contain an explicit redirect to another page, the user is redirected to the login page configured in the application's configuration file.
Calling the SignOut method only removes the forms authentication cookie. The Web server does not store valid and expired authentication tickets for later comparison. This makes your site vulnerable to a replay attack if a malicious user obtains a valid forms authentication cookie. To improve security when using a forms authentication cookie, you should do the following:

*

*Use absolute expiration for forms authentication cookies by setting the SlidingExpiration property to false. This limits the window in which a hijacked cookie can be replayed.

*Only issue and accept authentication cookies over Secure Sockets Layer (SSL), by setting the RequireSSL property to true and by running the entire Web site under SSL. Setting the RequireSSL property to true ensures that ASP.NET will never send an authentication cookie to the browser over a non-SSL connection; however, the client might not honor the secure setting on the cookie. This means the client might send the forms authentication cookie over a non-SSL connection, thus leaving it vulnerable to hijack. You can prevent a client from sending the forms authentication cookie in the clear by running the entire Web site under SSL.

*Use persistent storage on the server to record when a user logs out of the Web site, and then use an application event such as PostAuthenticateRequest event to determine whether the current user was authenticated with forms authentication. If the user was authenticated with forms authentication, and if the information in persistent storage indicates the user is logged out, immediately clear the authentication cookie and redirect the browser back to the login page. After a successful login, update storage to reflect that the user is logged in. When you use this method, your application must track the logged-in status of the user, and must force idle users to log out.

You can see it here
So, to sum it all up, yes you should call SignOut

A: You don't need to use
FormsAuthentication.SignOut();

If you are not using form-authentication.

Here is a good link
FormsAuthentication.SignOut() does not log the user out

A: You can use Membership provider in order to reduce development time for management security need (Identity).
You have also tool regsql in order to install youur database for your users, you have also RoleManager functionality for manage Roles of users (Principal)
Some links :
http://msdn.microsoft.com/fr-fr/library/ms229862(v=vs.80).aspx


text:
Q: Unable to overwrite bootstrap classes with css stylesheet in php project I have been looking at some answers here and tried them but it still doesn't work. I have a bootstrap file and a style.css file in the head section.
Bootstrap file(lux.css) works fine but I have been trying to overwrite some bootstrap classes in my styles.css but it isn't working.
They both are in the same folder, which is css. Inline styling is possible in html elements though. This is the html head section:

        <title>IP</title>
        <meta name="description" content="IP">
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <link rel="icon" type="image/png" href="img/favicon32.png">
        <link rel="stylesheet" href="/css/lux.css" type="text/css" media="screen" charset="utf-8">
        <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.11.2/css/all.min.css">
        <link rel="stylesheet" href="/css/styles.css" type="text/css" >

This is the footer:

                    Copyright &copy <?php echo date('Y'); ?> IP. All Rights Reserved.

                          Privacy Policy

                          Terms of Service

                          Contact

CSS

footer.row {
    width: 100% !important;
}

A: I added one classes footer-cover and style p tag
HTML

                    Copyright &copy <?php echo date('Y'); ?> IP. All Rights Reserved.

                          Privacy Policy

                          Terms of Service

                          Contact

CSS
.footer-cover {
    width: 100% !important;
    margin: 0 !important;;
}
.footer-cover p {
    margin-top: 10px !important;;
    margin-bottom: 0 !important;;
}

Try to paste it at the end of your lux.css


text:
Q: How to embed a gem? I wrote a ruby application.
This use a gem, but I don't want to let the user do a gem install (because of it need no setup effort). How can I embed a gem in my app?

A: you should try bundler
to package your gem:
bundle package

to install from cache:
bundle install --local


text:
Q: NoMethodError: Undefined method `first_or_create' for "foo":String I have used this method before in a Sinatra application with Datamapper without any troubles.
Now it doesn't seem to work. Any ideas appreciated.
My test:
scenario 'add hashtags to posts' do
visit '/'
add_post('Stacca',
        'Hello! out there',
         %w(foo bar))
post = Post.first
 expect(post.hashtag.map(&:text)).to include('foo')
 expect(post.hashtag.map(&:text)).to include('bar')

end
My server
post '/posting' do
username = params['username']
message = params['message']
hashtag = params['hashtag'].split(' ').map do |hashtag|
hashtag.first_or_create(text: hashtag)
end
Post.create(username: username, message: message, hashtag: hashtag)
redirect to ('/')
end

My Models:
class Post
include DataMapper::Resource
property :id, Serial
property :username, String
property :message, String

has n, :hashtag, through: Resource
end

and:
class Hashtag
include DataMapper::Resource
has n, :posts, through: Resource
property :id, Serial
property :text, String
end

Thank you

A: This line:
hashtag.first_or_create(text: hashtag)

should be:
Hashtag.first_or_create(text: hashtag) # uppercase!

Else, you are just trying to call a non existing "first_or_create" method on the String ("foo") you got from the scenario. 'Hashtag' is your class, 'hashtag' is your (String) variable.

A: Hashtag.first_or_create(text: hashtag)

Hashtag should have been a class
i.e. you missed the capital


text:
Q: Angular 2 routerLink not working inside ng2-bootstrap dropdown inside navbar I am using ng2-bootstrap navbar with dropdown inside of the navbar. If you look about half way down in the snippet below where the condition for *ngIf="userHasPermission()" you'll see the content for the dropdown menu. I've discovered that I must use anchros with href values to reload the entire page in order to get the browser to navigate to the URL requested. In the selectRecord function, I have the same problem; router.navigate and router.navigateByURL do absolutely nothing at all.
I've checked the following:

*

*I'm correctly importing RouterModule and other routerLink's in navbar work perfectly.

*I'm not attempting to routerLink to the currently active path
Ironically the routerLink on the li that has the dropdown attribute actually works.
The dropdown itself shows up just fine. Selecting any of the options causes the dropdown to disappear, but none of the routerLink options have any effect on anything that is actually contained inside the dropdown.
Here is the navbar markup:

        <button type="button" class="navbar-toggle collapsed" (click)="isMenuCollapsed = !isMenuCollapsed"
                data-toggle="collapse" data-target=".navbar-collapse">
            Toggle navigation

        </button>
        <button type="button" class="navbar-brand" data-toggle="collapse" (click)="isBrandingCollapsed = !isBrandingCollapsed">

        </button>

                 {{shortName}}

 {{'add'|translate}}

{{r.shortName}}

             {{shortName}}

             {{ "path2"|translate }}

             {{ "path3"|translate }}

My work around of reloading the entire browser is working but a terrible thing to have to do to simply change the record being viewed.


text:
Q: PuTTy interruption triggers the remote server to disable the network for 10-20 minutes In the last days I had a problem. Randomly when I was connected to my remote Linux Server or when I was connecting for the first time to the server I got the message  Network error: Software caused connection abort..
I read different solutions and none worked for me. It's weird that in the last 2 months I didn't had this problems with this server from Hetzner.
So every time when this problem happens the PuTTy window freezes. I close the window and I have to try 2-3 times to connect to the server to be able to reconnect again.
What is also confusing is that I use TMUX. And for example if I have something downloading in a TMUX session the network connection is broken for 10-20 minutes.
If I CTRL+C and close the existing process and try to download again it stays like this:

Is this a firewall problem? Why the network doesn't work and the process from tmux freezes?
My Firewall from Hetzner dashbord (should I delete these?)

Full overview:


text:
Q: Firebase client library failing typings I am attempting the latest Firebase npm module (4.8.1). I am using the commonjs module system with webpack bundling. In order to ensure I'm getting the typings I need I have the following in my package.json:
"dependencies: {
  "firebase": "^4.8.1"
},
"devDependencies": {
  "@firebase/app": "^0.1.5",
  "@firebase/app-types": "^0.1.0",
  "@firebase/auth": "^0.3.1",
  "@firebase/auth-types": "^0.1.0",
  "@firebase/database": "^0.1.6",
  "@firebase/database-types": "0.1.0",
}

When I transpile with tsc I get the following errors:

node_modules/@firebase/database/dist/esm/src/api/Database.d.ts(4,33): error TS2307: Cannot find module '@firebase/app-types/private'.
node_modules/@firebase/database/dist/esm/src/core/AuthTokenProvider.d.ts(17,39): error TS2307: Cannot find module '@firebase/app-types/private'.

I find this VERY odd for several reasons:

*

*I am using CommonJS module system not ESM

*I have assumed that the @firebase/data-types is there to provide typings rather than implementation code. That's why I have it listed as as devDependency instead of dependency

*Even if I switch all the @firebase/* to "dependencies" it still gives same error

*I did see other people post here that Firebase 4.8.1 has an error in it and that rolling back to 4.8.0 might fix the problem ... but from what I can see 4.8.0 has all sort of "implicit any" errors (which maybe I could justify turning off) but also lots of other deprecations in the API that is exported. Simply put, it appears to me that 4.8.1 is much better as typings reference.

A: With the following tsconfig.jsonit works fine for me:
{
  "compilerOptions": {
    "target": "es2015",
    "module": "commonjs",
    "moduleResolution": "node",
    "inlineSourceMap": true
  }
}

In src/index.ts I just import like this:
// This import loads the firebase namespace along with all its type information.
import * as firebase from 'firebase';

const firebaseApp = firebase.initializeApp({
  apiKey: '<your-api-key>',
  authDomain: '<your-auth-domain>',
  databaseURL: '<your-database-url>',
  storageBucket: '<your-storage-bucket>',
  messagingSenderId: '<your-sender-id>'
});

Before I modified my tsconfig.json I had similar issue with:
{
...
  "devDependencies": {
    ...
  },
  "dependencies": {
    ...,
    "firebase": "^4.8.1"
  }
}

I hope that helps!


text:
Q: Problem with NSolve Speed I have a very complicated function but only of 1 variable. I want to find the first value for which that function is zero. Mathematica can easily plot it:
func = Det[coeffMatrix];
Plot[func, {\[Beta]1, 0, 3}]

From that plot, one can easily see that the first value would be ~2.556.
To show that $\beta_1$ = 2.556 is actually the approximate solution:
func /. \[Beta]1 -> 2.556

-0.00139597

However, when I try to find it numerically:
NSolve[func == 0 && 0 < \[Beta]1 < 10, \[Beta]1]

...it just runs and runs and runs and never gives an answer. Why ? and how can I fix it ?
The complete code
constants = {b1 -> (-(Cosh[
          0.68*\[Beta]1]*(0.6553600000000004*Cos[0.15*\[Beta]1]*
            Cos[0.68*\[Beta]1] -
           0.6553600000000004*Cos[0.68*\[Beta]1]*
            Cosh[0.15*\[Beta]1] +
           1.2621440000000002*Sin[0.15*\[Beta]1]*Sin[0.68*\[Beta]1] +
           0.7378559999999998*Sin[0.68*\[Beta]1]*
            Sinh[0.15*\[Beta]1])) +
      Cos[0.68*\[Beta]1]*(-0.7378559999999998*Sin[0.15*\[Beta]1] -
         1.2621440000000002*Sinh[0.15*\[Beta]1])*
       Sinh[0.68*\[Beta]1])/(Cosh[
        0.68*\[Beta]1]*(-0.6553600000000004*Cos[0.68*\[Beta]1]*
          Sin[0.15*\[Beta]1] +
         1.2621440000000002*Cos[0.15*\[Beta]1]*Sin[0.68*\[Beta]1] +
         0.7378559999999998*Cosh[0.15*\[Beta]1]*Sin[0.68*\[Beta]1] -
         0.6553600000000004*Cos[0.68*\[Beta]1]*Sinh[0.15*\[Beta]1]) +
      Cos[0.68*\[Beta]1]*(0.7378559999999998*Cos[0.15*\[Beta]1] +
         1.2621440000000002*Cosh[0.15*\[Beta]1])*Sinh[0.68*\[Beta]1]),
   b2 -> (2.5*
      Sec[0.68*\[Beta]1]*(Cosh[
          0.68*\[Beta]1]*(-0.26214400000000015 +
           0.26214400000000015*Cos[0.15*\[Beta]1]*
            Cosh[0.15*\[Beta]1] -
           Sin[0.15*\[Beta]1]*Sinh[0.15*\[Beta]1]) +
        0.8*(Cosh[0.15*\[Beta]1]*Sin[0.15*\[Beta]1] -
           Cos[0.15*\[Beta]1]*Sinh[0.15*\[Beta]1])*
         Sinh[0.68*\[Beta]1]))/((0.7378559999999998*
          Cos[0.15*\[Beta]1] +
         1.2621440000000002*Cosh[0.15*\[Beta]1])*Sinh[0.68*\[Beta]1] +
       Cosh[0.68*\[Beta]1]*(-0.6553600000000004*Sin[0.15*\[Beta]1] -
         0.6553600000000004*Sinh[0.15*\[Beta]1] +
         1.2621440000000002*Cos[0.15*\[Beta]1]*Tan[0.68*\[Beta]1] +
         0.7378559999999998*Cosh[0.15*\[Beta]1]*Tan[0.68*\[Beta]1])),
  d2 -> (2.5*
      Sech[0.68*\[Beta]1]*(-0.26214400000000015*Cos[0.68*\[Beta]1] +
        0.8*Cosh[
          0.15*\[Beta]1]*(0.3276800000000002*Cos[0.15*\[Beta]1]*
            Cos[0.68*\[Beta]1] +
           Sin[0.15*\[Beta]1]*
            Sin[0.68*\[Beta]1]) + (Cos[0.68*\[Beta]1]*
            Sin[0.15*\[Beta]1] -
           0.8*Cos[0.15*\[Beta]1]*Sin[0.68*\[Beta]1])*
         Sinh[0.15*\[Beta]1]))/(-0.6553600000000004*
       Cos[0.68*\[Beta]1]*Sin[0.15*\[Beta]1] +
      1.2621440000000002*Cos[0.15*\[Beta]1]*Sin[0.68*\[Beta]1] -
      0.6553600000000004*Cos[0.68*\[Beta]1]*Sinh[0.15*\[Beta]1] +
      0.7378559999999998*Cos[0.15*\[Beta]1]*Cos[0.68*\[Beta]1]*
       Tanh[0.68*\[Beta]1] +
      Cosh[0.15*\[Beta]1]*(0.7378559999999998*Sin[0.68*\[Beta]1] +
         1.2621440000000002*Cos[0.68*\[Beta]1]*Tanh[0.68*\[Beta]1]))}

matrix = {{a1 (Sin[u \[Beta]1] - Sinh[u \[Beta]1]),
    b1 (Cos[u \[Beta]1] - Cosh[u \[Beta]1]), -b2*
     Cos[y*\[Theta]*\[Beta]1], -d2*
     Cosh[y*\[Theta]*\[Beta]1]}, {a1 (Cos[u \[Beta]1] -
       Cosh[u \[Beta]1]), b1 (-Sin[u \[Beta]1] - Sinh[u \[Beta]1]),
    b2*\[Theta]*Sin[y*\[Theta]*\[Beta]1], -d2*\[Theta]*
     Sinh[y*\[Theta]*\[Beta]1]}, {a1 (-Sin[u \[Beta]1] -
       Sinh[u \[Beta]1]), b1 (-Cos[u \[Beta]1] - Cosh[u \[Beta]1]),
    b2*\[Alpha]^4*\[Theta]^2*
     Cos[y*\[Theta]*\[Beta]1], -d2*\[Alpha]^4*\[Theta]^2*
     Cosh[y*\[Theta]*\[Beta]1]}, {a1 (-Cos[u \[Beta]1] -
       Cosh[u \[Beta]1]),
    b1 (Sin[u \[Beta]1] -
       Sinh[u \[Beta]1]), -b2*\[Alpha]^4*\[Theta]^3*
     Sin[y*\[Theta]*\[Beta]1], -d2*\[Alpha]^4*\[Theta]^3*
     Sinh[y*\[Theta]*\[Beta]1]}};

testingParam = { \[Theta] -> 0.8, \[Alpha] -> 0.8, u -> 0.15,
   y -> 1 - 0.15} ;

coeffMatrix = (matrix /. a1 -> 1) /. constants /. testingParam ;

func = Det[coeffMatrix];
NSolve[func == 0 && 0 < \[Beta]1 < 10, \[Beta]1]

A: From: About multi-root search in Mathematica for transcendental equations
f[\[Beta]1_] = Det[coeffMatrix];
zeros = Reap[
   NDSolve[{y'[x] == D[f[x], x], WhenEvent[y[x] == 0, Sow[{x, y[x]}]],
      y[1] == f[1]}, {}, {x, 3, 0.01}]][[-1, 1]]
Plot[f[x], {x, 0, 3},
 Epilog -> {PointSize[Medium], Red, Point[zeros]}]

{{2.61534, -5.0246*10^-18}}

A: FindRoot[func == 0, {\[Beta]1, 2.566}]
{\[Beta]1 -> 2.61535}


text:
Q: Should ECS Tasks be Stopped Regularly? Is it a good practice for ECS tasks to stop after a week or month in order to avoid problems that can result from tasks that have been running for a long time?
My team has had issues with the host that a task is using running out of memory or the authorization proxy dying on the host which causes database queries to fail. I thought a potential solution would be to have multiple tasks running and for each task to automatically stop after several days. We have found solutions to the memory issue, but the authorization proxy problem remains. There would also be other problems in the future. Ideally we would avoid them permanently, but is it standard to avoid these issues by not letting the tasks run for very long?

A: Tasks are for temporary "tasks" that are expected to end at some point. They're for automation scripts or temporary development sites.
It sounds like a "Service" is what you really want, which is the same thing as a Task except it is intended to keep running forever, and can be configured to auto-restart on failure.
That being said, if your application is crashing on its own, making it a Service will not fix that but it will at least automatically restart it whenever it crashes. The crash from your application running out of memory is a different issue and may be a bug in your code.


text:
Q: Can I really trust LOG4J Timestamps for performance metrics in Production? In the office next to where my Web app is hosted, LOG4J shows that a typical operation tested locally takes < 1 sec,
07 Nov 2019 12:30:01,860 INFO  ParticipantServiceImpl(Line 272) - User 1: Operation Start
...
07 Nov 2019 12:30:02,796 INFO  ParticipantServiceImpl(Line 881) - User 1: Operation End

The Production LOG4J shows that with many concurrent users connecting across the world on their phones, the operation average is closer to 5-7 sec. The output is often mixed up and out of order, but I'm concerned about the timestamps: Are the timestamps themselves reliable (even if out of order)? Do I indeed have a performance problem in the real user experience, or can LOG4J have some flushing or concurrency delay?
07 Nov 2019 12:30:01,860 INFO  ParticipantServiceImpl(Line 272) - User 1: Operation Start
07 Nov 2019 12:31:01,860 INFO  ParticipantServiceImpl(Line 272) - User 2: Operation Start
...
07 Nov 2019 12:37:02,796 INFO  ParticipantServiceImpl(Line 881) - User 1: Operation End

LOG4J configured as

    <RollingFile name="file" fileName="/local/content/tomcat/app/logs/app.log" append="true"
        filePattern="/local/content/tomcat/app/logs/app.log.%i">
        <PatternLayout>
            <Pattern>%d{DATE} %-5p %c{1}(Line %L) - %m%n</Pattern>
        </PatternLayout>
        <Policies>
            <SizeBasedTriggeringPolicy size="5 MB" />
        </Policies>
        <DefaultRolloverStrategy max="5" />
    </RollingFile>
</Appenders>

<Loggers>
    <Logger name="com.app" level="debug">
    <AppenderRef ref="console"/>
        <AppenderRef ref="file"/>
    </Logger>

    <Logger name="com.opensymphony.xwork2.interceptor" level="info">
        <AppenderRef ref="file" />
    </Logger>

    <Logger name="org.springframework.orm" level="info">
        <AppenderRef ref="file" />
    </Logger>

    <Logger name="org.hibernate.engine.transaction" level="DEBUG">
        <AppenderRef ref="console" />
    </Logger>

    <Logger name="net.sf.ehcache" level="trace">
        <AppenderRef ref="file" />
    </Logger>

    <Root level="info">
      <AppenderRef ref="console"/>
      <AppenderRef ref="file"/>
    </Root>
</Loggers>

A: Based on the documentation of Log4j, I think you can trust it, but first you need to add the thread name to the appender so that you know which start and end times belong to which thread.

Property name: log4j2.clock
Environment variable: LOG4J_CLOCK
Default value: SystemClock
Descrption:
Implementation of the org.apache.logging.log4j .core.util.Clock interface that is used for timestamping the log events.
By default, System.currentTimeMillis is called on every log event.
You can also specify a fully qualified class name of a custom class that implements the Clock interface.

The fact that the timestamps are out of order tells us that those are not timestamps of the logs being written but of the log events happening.
A differnt approach
I woud personally (apart from logging the start and end times - or maybe not log them at all) add a log event that writes the duraction of the task. That makes it easier to read, visually by humans and programatically (if you want to collect and analyze the data).
long startTime = System.currentTimeMillis();
// perfom the task
long endTime = System.currentTimeMillis();
LOG.info("Duration: " + (endTime - startTime)); // you can also convert milliseconds to hours,minutes, secconds


text:
Q: Getting different output while running cmd through Visual Studio (C#) I want to get the following registry key's contents:

HKLM\Software\Microsoft\Windows\CurrentVersion\Run

My code in Visual Studio is:
public static string os_command(string command_str)
{
    Process command = new Process
    {
       StartInfo = new ProcessStartInfo
       {
           FileName ="cmd.exe",
           Arguments = "/c" + command_str,
           RedirectStandardOutput = true,
           RedirectStandardError = true,
           RedirectStandardInput = true,
           UseShellExecute = false,
       }
    };
    command.Start();
    string output = command.StandardOutput.ReadToEnd();
    return output;
}

while the command_str is:

reg query \\ip\HKLM\Software\Microsoft\Windows\CurrentVersion\Run

Yet when I run it from Visual Studio I get a different output than running it from the command-line itself.
So what am I doing wrong?


text:
Q: Populate GridView I cant populate grid view with the data sent to api. tell me where is the flaw. I have no idea.
  protected void btnGo_Click(object sender, EventArgs e)
  {
    WSmyWebAPI.myWeb wsAPI = new WSmyWebAPI.myWeb();
    WSmyWebAPI.OrderSearchParameters sSearchParameters = new
    WSmyWebAPI.OrderSearchParameters();
    DataSet ds = new DataSet();
    DateTime dtmStartDate;
    DateTime dtmEndDate;

    dtmStartDate = Convert.ToDateTime(dpApproved.Text);
    dtmEndDate = Convert.ToDateTime(dpShipped.Text);
    oid = txtOrderID.Text;
    opid = txtPartID.Text;

    sSearchParameters.StartDate = dtmStartDate;
    sSearchParameters.EndDate = dtmEndDate;
    sSearchParameters.OrderID = oid;
    sSearchParameters.OrderPartID = opid;

    ds = wsAPI.OrderSearch(sSearchParameters);
    GridView1.DataSource = ds;
    GridView1.DataBind();

}

A: Following is a sample code. You may manipulate or adjust your code accordingly.
Make sure you have aspx code in place as well. That means the columns you want to display. Try to add
GridView1.Vissible = True
Further make sure to add a try catch block and check on SqlException. Try to go on line by line debug mode. I would suggest to display the error on a label in the webpage until your entire page is bug free. So you know where and what went wrong.
As for a suggestion, it's better to take out the connection , query parameter portion out Go click event. Add a separate method to do that. Only get the data set or data table (I recommend data table) and set it to gridview under Go click event.


text:
Q: script to sort sheet by 2 colums Please help make the script. As written below, I wrote a script that worked for some time. Now it does not work and I need help writing a new one.
The challenge is this: when you make changes in column F, K and O - occurs first check the availability of the text in the column to the - then if there is a text should start sorting first by F column - then sorting by a column O
There is a scheme of action sequences by the link:
https://drive.google.com/file/d/0B5qSx6LqB8U-d01URS1BcEVtNGs/view?usp=sharing
I will be happy if someone can help me.
In any case, thanks for your time and attention :) Have a nice day :)
29/03/17 I need help "Service error: spreadsheets"
A very recently worked script:
    function onEdit() {
var ss = SpreadsheetApp.getActiveSheet();
var r = SpreadsheetApp.getActiveRange();
var cols = r.getColumn();
var rows = r.getRow();
var who = ss.getRange(rows,11).getValue();
if (who !== "") {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0]
sheet.sort(6);
sheet.sort(15);}
}

Today received an error:
Service error: spreadsheets
The script stopped working at all, help, please.

A: I'm not following how this completes your action sequence flow chart, but I believe this should get it running as before. I've seen other posts where people get this same Service Error message form previously working scripts, and I believe Google is trying to change how certain tasks are done to help their server loads.

function onEdit() {
var ss = SpreadsheetApp.getActive();
var r = SpreadsheetApp.getActiveRange();
var cols = r.getColumn();
var rows = r.getRow();
var who = ss.getActiveSheet().getRange(rows,11).getValue();
if (who !== "") {
var sheet = ss.getSheets()[0];
sheet.sort(6);
sheet.sort(15);}
}

I removed the duplicate definition of var ss and tweaked var ss, var who and var sheet to work without it.


text:
Q: How to overcome maximum recursion depth exceeded error here? The problem statement is as follows:
Return the sum of the numbers in the array, except ignore sections of numbers starting with a 6 and extending to the next 7 (every 6 will be followed by at least one 7). Return 0 for no numbers.

sum67([1, 2, 2]) → 5
sum67([1, 2, 2, 6, 99, 99, 7]) → 5
sum67([1, 1, 6, 7, 2]) → 4

I'm aware of the same problem being posted here on stack overflow but I don't want to request a new solution, rather I want to know what might be the problems with my own recursive solution to the problem.
My attempt:
def sum67(nums):
  def rem67(nums):
    if 6 not in nums:
      return nums
    index6 = nums.index(6)
    index7 = nums.index(7)
    nums = nums[:index6] + nums[(index7 + 1):]
    return rem67(nums)
  return sum(rem67(nums))

The server keeps throwing maximum recursion depth exceeded error which I'm unable to rectify on the server. Any leads will be appreciated.

A: The recursion limit is 1000 by default. You could use a while true instead, like:
def sum67(nums):
    while True:
        if 6 not in nums:
            break
        index6 = nums.index(6)
        index7 = nums.index(7)
        nums = nums[:index6] + nums[(index7 + 1):]
    return sum(nums)

Like 0x5453 commented, it breaks if you have a 7 before a 6. So you probably want to add something like this:
if index6 > index7:
    return -1

A: If a 7 occurs in the array before its 6 counterpart, then on one iteration the new array formed in rem67() will be composed of a section with a 7 but no 6, followed by a section with a 6. This sets up the same condition in the new array, which will result in infinite recursion.
If it is allowed that two consecutive 7's may occur, or for a 7 to occur first, then it would be better to do the following:
index7 = nums.index(7, index6)
This makes index7 reference the first 7 that follows the 6, thus ignoring any 7's that may occur before the 6.
Otherwise returning an error code as suggested by Sefan is good.
Hope this fixes things :)

A: This isn't a safe mode:
import sys

my_limit = sys.getrecursionlimit()
sys.setrecursionlimit(my_limit + 200)
print(sys.getrecursionlimit())

A: As per @0x5453 's comment, I modified the index7 which now looks for only those 7 which come after we encounter 6.
Here's the modified code which works correctly:
def sum67(nums):
  def rem67(nums):
    if 6 not in nums:
      return nums
    index6 = nums.index(6)
    index7 = nums[index6:].index(7) + index6
    nums = nums[:index6] + nums[(index7 + 1):]
    return rem67(nums)
  return sum(rem67(nums))


text:
Q: What is the "space" of a Vector Space? And What Consititutes a Subset of that Vector Space? Based on the following axioms of vector spaces where u & v are vectors and c is a scalar:
• u + v is in V
• c*u is in V

*

*I thought that the "space" of a specific matrix's vector space was all the linear combinations of its vectors, but I later found that to be the column space of that particular matrix.

If Null and Column spaces are subspaces of a Matrix's vector space, then what exactly makes up the Vector Space of a matrix? Is it the set of vectors as a whole?
Also, the definition of a subspace states that it is a "subset" of vectors from a larger vector space. The column Space seems to encompass all the vectors of a vector space while the null space has an entirely different set of vectors from the original vector space set.
The Null space in particular doesn't feel like a subset of a matrix's vector space, so I'm likely missing an idea of Vector- and Subspaces. What exactly constitutes a subset of a vector space?

A: Fir of all we have to be clear about this. There is no such thing as amatrix's vector space. There are a few vector spaces associated to any specific matrix. (And so may vary with matrix to matrix). And then other thing called a vector space
consisting of all matrices of a fixed size $m\times n$.
Fix positive integers $m,n$. SO we have two vector spaces $\mathbf{R}^m$ and $\mathbf{R}^n$.  Now fix a matrix $A$ of size/shape $m\times n$. Then all linear combinations of columns of $A$ are elements of $\mathbf{R}^m$; so they form a subset
closed under the operation of vector addition and scalar multiplication. SUch subsets in any vector space $V$ are  called vector subspaces (or simply subspaces) of $V$.
The column space of our $A$ is a vector space obtained as the subspace of $\mathbf{R}^m$ by linear combinations of columns of $A$. Similarly a definition involving rows of $A$ will give the row space, a subspae of $\mathbf{R}^n$.
From the way matrix multiplication is defined it immediately follows that a vector is in the column space of a matrix $A$ iff it is obtainable as the product $Av$ with a vector $v\in \mathbf{R}^n$.
Viewed using functions one can  see that column space is the range of the following function $T_A\colon \mathbf{R}^n\to \mathbf{R}^m$  defined by  $T_A(v) =Av$.
The nullspace of $A$ consists of those vectors $v$ for which $T_A(v)$ is the zero vector.

A: A matrix doesn't have a vector space as such, a matrix is a representation of a transformation from one vector space to another or itself.
Specifically, if you're talking about a vector space onto itself, we call this an operator, often denoted T, and the matrix will be square. We can then say that the vector space is the sum of the column space of the matrix (which we can also call the range of T) and the null space of the matrix (which we can also call the null of T).
A subset of a vector space is literally just any set of vectors from the vector space (including the infinite set containing all vectors in the space itself). A subspace is a specific type of subset, where those two conditions are held (and they imply the third condition, which is that $\bar{0} \in U$.

A: I think your confusion comes from starting with a matrix and looking for "its space".
The space idea comes first. A vector space is a set of objects that behave in a nice way (the axioms for sums and scalar products). So, for example, the set $\mathbb{R}^3$ of triples $(x,y,z)$ of real numbers is a vector space with the usual operations.
Sometimes a subset of a vector space is a vector space in its own right - for example, the set of triples $(x,y,0)$ or the set of triples $(x,x,x)$.
Matrices occur when we want to study particular kinds of functions between vector spaces - so called linear functions. When you have a matrix that represents a linear function the finite set of its columns generates (but is not all of) what we call the column space. It's a subspace of the codomain: the set of vectors there that are actually values of the function. The set of vectors mapped to $0$ is the null space of the transformation. It's a subspace of the domain.

A: A vector space $X$  is in the first place an "additive structure" satisfying the rules we associate with such structures, e.g., $a+({-a})=0$, etc. In addition any vector space has associated with it a certain field $F$, the field of scalars for that vector space. The elements $x$, $y\in X$ cannot only be added and subtracted, but they can be as well scaled by "numbers" $\lambda\in F$. The vector $x$ scaled by the factor $\lambda$ is denoted by $\lambda x$. This scaling satisfies the laws we are accustomed to from the scaling of vectors in ${\mathbb R}^3$:
$$\lambda(x+y)=\lambda x+\lambda y,\qquad (\lambda+\mu)x=\lambda x+\mu x\ .$$


text:
Q: Disable background when user "clicks" on a link I'm trying to make a website, this website has several links inside a
 tag:

Software

When the user "clicks" on this li for example, it calls a jquery file:

This link goes to here:
$("#page7").click(function(){
        $('#result').load('./docu2_files/docs/software.html');
});

So basically when the user clicks on the diferents
, the scripts loads inside the div the content of the diferents html.
This is working, but i want to add an extra, i want to add a logo at the beginning of the website, as soon the users clicks on the
this logo should dissapear and show the content of the diferents .html
The only thing i manage to do is the viceversa, but of course that is not what i want to do.

A: You can add:
$("#page7").click(function(){
        $("#yourLogoId").css("display", "none");
        $('#result').load('./docu2_files/docs/software.html');
})


text:
Q: Kensington Trackball Works, how to scroll horizontally with Trackball or Auto Scroll I have a Kensington Expert Mouse on the Mac running the latest 1.3 drivers.
There still is no option to use the trackball to in addition to scroll vertically also scroll horizontally. Similar to the ball on the mighty mouse.
Has anyone found a hidden setting that I could enable with the defaults write command?

A: The old driver used to have an option to set a button (or button combination) to 'change scroll direction'.  I used to use that all the time and they have since gotten rid of it.
The workaround I've been able to come up with is to program a button to simply type the shift key (I use the two bottom button combination).  It's not as nice, but then you can hold the button(s) and scroll in the opposite direction without using your second hand.


text:
Q: How to interpret PCA coefficients to reduce dimension I have read about similar questions. I have data which has 68 columns and about 800 samples. The 68. column is the output the rest 67 is the input variables. I want to reduce the size of my input variables to for example 30 or 20 variables.
I have read about PCA. I already ran the PCA in Matlab and gathered a 67 x 20 matrix containing PCA coefficients. I calculated eigenvalues for each Principal component (10 eigenvalues). As far as I understand I should order these eigenvalues and select the PCA's with higher eigenvalues as important. For example, I chose PC1, PC3, and PC9.
How can I use this information to select among the original 67 variables? I mean how can I use this PCA analysis results to reduce a 67*800 matrix to a 20*800 matrix and get the variables which have higher effect on the target variable?

A: The eigenvalues that you get in Matlab with pca() are already in decreasing order, so you are guaranteed that the first n Principal Components will be the most important ones. You can see this yourself if you look at a vector latent which is a vector of eigenvalues. If then you would like to reduce your variable set to 20 variables, you can simply retain only 20 first PCs from the coeff matrix.
What you do is you project your original data set $X$ (which is 800 $\times$ 67) on a reduced PC basis:
Z = X * coeff(:,1:20)
to get the PC scores matrix $Z$ which is the representation of your original data in a 20-dimensional space instead of 67-dimensional. The matrix $Z$ is size 800 $\times$ 20.


text:
Q: Message not sending to Azure Events Hub: Put token failed. status-code: 404, status-description: The messaging entity... ...could not be found I am learning Azure Events Hub. A simple application i have downloaded  from this link https://learn.microsoft.com/en-us/azure/event-hubs/event-hubs-dotnet-standard-getstarted-send . But when i try to send message, its giving me this error:

10/23/2018 11:11:13 PM > Exception: Put token failed. status-code:
  404, status-description: The messaging entity
  'sb://demo.servicebus.windows.net/myTeam' could not
  be found. TrackingId:[My Tracking ID],
  SystemTracker:iot-bd-madness.servicebus.windows.net:IoT-BD-Madness,
  Timestamp:10/23/2018 5:11:18 PM.

In Azure Event Hub Dashboard all incoming requests (sending from console app) are visible with chart. but those are all request actually failed when i tried in console application
N.B:the given connectionstring is not real
public class Program
{
    private static EventHubClient eventHubClient;
    private const string EventHubConnectionString = "Endpoint=sb://iot-bd-madness.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=";
    private const string EventHubName = "Iot-Bd-Madness";

    public static void Main(string[] args)
    {
        MainAsync(args).GetAwaiter().GetResult();
    }

    private static async Task MainAsync(string[] args)
    {
        // Creates an EventHubsConnectionStringBuilder object from a the connection string, and sets the EntityPath.
        // Typically the connection string should have the Entity Path in it, but for the sake of this simple scenario
        // we are using the connection string from the namespace.
        var connectionStringBuilder = new EventHubsConnectionStringBuilder(EventHubConnectionString)
        {
            EntityPath = EventHubName
        };

        eventHubClient = EventHubClient.CreateFromConnectionString(connectionStringBuilder.ToString());

        await SendMessagesToEventHub(100);

        await eventHubClient.CloseAsync();

        Console.WriteLine("Press any key to exit.");
        Console.ReadLine();
    }

    // Creates an Event Hub client and sends 100 messages to the event hub.
    private static async Task SendMessagesToEventHub(int numMessagesToSend)
    {
        for (var i = 0; i < numMessagesToSend; i++)
        {
            try
            {
                var message = $"Message {i}";
                Console.WriteLine($"Sending message: {message}");
                await eventHubClient.SendAsync(new EventData(Encoding.UTF8.GetBytes(message)));
            }
            catch (Exception exception)
            {
                Console.WriteLine($"{DateTime.Now} > Exception: {exception.Message}");
            }

            await Task.Delay(10);
        }

        Console.WriteLine($"{numMessagesToSend} messages sent.");
    }
}

}

A: I ran into same problem. My EventHubName = "myeventhubname" was wrong. I passed the Event Hubs Namespace value - rounded in red. It gave error.
I changed it to value under Event Hub page left column -> click Entities -> Event Hubs
I used the name that was shown in the table rounded in green.


text:
Q: Looking for CSS columns ALA newspaper/ms-word, for content - column 1 top down, then wrapping to column 2, top down I'm automating a report we usually type manually once a month in word, and the person it is for requires that it always looks exactly how they specify - it needs to be two content columns, that wrap like MS Word / a newspaper - the end of the first column wraps to the start of the second column, the start of the second column wraps to the start of the first column on the next page.
It is a list of lists - each list is

List title

...

Preferably, each list block would be restricted to a column, if it fits on one column
The files are created with a PHP cli script, and then opened from a local drive.  The environment is what defines our pure-CSS/HTML requirement.  Light amounts of javascript (code sizes unlikely to raise an eyebrow) are OK.  External javascript file references are not OK.  Not using javascript is preferred.
Our backup solution is to process per-report CSS code when creating the file in PHP, and we can figure that out internally if necessary.
Thank you

A: You can use column-count for this. See also

Graceful Degradation
Note that not all browsers supports these properties unprefixed. To make use of this feature in most today's browsers, each property must be written thrice: once with the -moz prefix, once with the -webkit prefix and once without prefix.

In your case this would be
-moz-column-count: 2;
-webkit-column-count: 2;
column-count: 2;