algorithm – Is the number of swap function calls and the number of swaps done while selection sort the same thing?

I know that for n elements, in selection sort:

Best cases: 1 swap done.
Worst cases: n-1 swaps done.
Average cases: (n-1)/2 swaps done.

So, if i were to say that the number of times the swap function has been called is same as the number of swaps done in 3 different cases, would I be correct?

How can I ensure the client and server both have access to all API calls in use?

On multiple occasions, we’ve deployed frontend code to production only to find out the backend (REST or GraphQL) hasn’t shipped their side yet. Worse yet, we expectedly find out a param name changed which may throw an error. Another example: the backend removes an API thinking that clients no longer use the removed API and the frontend crashes. If any layer of communication between frontend and backend breaks down, then we may end up with catastrophic errors.

I think the “best solution” is to use a tool like Cypress or Codecept to create a suite of integration tests which checks every API call the frontend may use. Sadly, that’s a heavyweight solution that requires significant upfront investment in developer time.

Anyway, I’m looking for simple solution to this problem. Maybe something that checks affected APIs when the frontend opens a PR and/or something that checks the frontend repo when the backend deploys to production.

Any ideas or experience solving this problem?

encryption – Should we encrypt all REST API calls from a mobile device?

I have a mobile application and the backend is hosted on a cloud provider. I would like to ask for feedback on encrypting all REST API calls that will be used to communicate with the server, if we should or we shouldn’t do it.

Adding details:

for example instead of having a proper rest object

{
   "name" : "username",
   "info" : "profile"
}

make it similar to this:

{
   "encryptedData" : "Mq6rTVdPP1YMlE9AxhnryIRX+JA9MfIXv"
}

and after decryption it becomes the model and the flow carries on, of course the response is also expected to be encrypted in a similar fashion.

c – Implementation of system() function in Linux using fork() , exec() and waipid() system calls

I have written the code for implementation of system() function in Linux using fork(), exec() and waitpid(). Could someone review the code and provide feedback. Thanks a lot.


#include<stdio.h>
#include<string.h>
#include<unistd.h>
#include<sys/types.h>
#include<sys/wait.h>
#include<error.h>
#include<errno.h>
#define size 30

char *get_command(int argc, char *argv());
int my_system(const char *command);

int my_system(const char *command)
{
    pid_t pid;
    int wstatus  = 0;
    int ret = 0;

    if (command == NULL)
        return 1;
    pid = fork();
    if (pid == -1) {
        return -1;
    } else if (pid == 0) {
        ret = execle("/bin/sh", "sh", "-c",command, (char *)NULL);
        if (ret == -1)
            return wstatus;

    } else {
        ret = waitpid(-1, &wstatus, 0);
        if (ret == -1)
            return -1;
    }
    return wstatus;
}

char *get_command(int argc, char **argv)
{
    int i = 0;
    static char command(size);

    if (argc == 1)
        return NULL;

    strcpy(command, argv(1));
    for (i = 2; i < argc; i++) {
        strcat(command, " ");
        strcat(command, argv(i));
    }
    return command;
}

int main(int argc, char *argv())
{
    int ret;
    char *command;

    command = get_command(argc, argv);
    ret = my_system(command);
    if (ret == 1)
        printf("Command is NULL, shell is availablen");
    else if (ret == -1)
        printf("Child process could not be created or error in the wait system calln");
    else if (ret == 127)
        printf("The Child process could not be executed in the shelln");
    else
        printf("The status of the child process is :%dn", ret);
    return 0;
}
```

opengl – Why do I have additional glBindBuffer() calls?

I have a OpenGL2/OpenGLES2 application and it among others renders a sphere using the following pseudocode:

  1. Update vertices data on CPU
  2. call glBufferSubData(GL_ARRAY_BUFFER, …) to update them on GPU size
  3. in a loop calls glDrawElements

Now I’m checking it under RenderDoc and see additional calls to glBindBuffer between glDrawElements:

  1. glBindBuffer(GL_ARRAY_BUFFER, 0)
  2. glBindBuffer(GL_ARRAY_BUFFER, my_vbo_id)
  3. glDrawElements

Why I see those additional calls? Why GL driver (or GL library?) inserts them?

Applications – On Verizon Samsung Galaxy 8 Version 9 (Android) Block outgoing calls and texts to a specific number

On Verizon Samsung Galaxy 8 block outgoing calls and texts to a specific number. I've tried several apps that say they block outgoing calls, but they didn't work. An app stated that in version 9 of Android, it did not have permission to block outgoing calls. I'm on version 9.

Is there an app or other type that I missed? Thank you so much!

Aborted FaceTime calls – ask differently

FaceTime ends my call every evening between 9:50 p.m. and 10:00 p.m. I can get it back in minutes, but even texting is slowed down in that time. It doesn't matter who I'm talking to or what device I'm on, MacBook Pro, iPad or iPhone. I tried to turn off everything but the device I use without success. My ISP says something is uploading every night at this time, but what if the devices are off? Do I have malware? If you have some wisdom I would appreciate it! (In lay terms please?)

Tons of calls to ad pages

First, I don't really know where to post it and I don't really know what to do, so I hope this is a good place to start. I used and filtered Wireshark to find client hello packets. Many of the server names that make up these packages include domains such as cdn.adsafeprotected.com, sb.scorecardresearch.com, and rtbgumgum.com. I wondered how I could prevent it.