Cypress Automation Tutorial

What Is Test Automation?

Test Automation is a way of verifying and validating test scenarios via specific tools and frameworks. QAs create automated scripts, feed them into automation tools that launch the application, run through the test scenario, and mark the test as passed or failed.

Test Automation is recommended for repetitive scenarios only since it saves time and effort that would otherwise have to be put in by human testers.

Cross-Region Lambda Invocation in AWS

AWS Lambda makes it easy to build highly available serverless applications quickly. However, setting up resources in multiple regions makes it difficult to manage the applications since cross-region access is limited by design in AWS for security and performance reasons. Fortunately, AWS makes it easy to access resources across regions in your intend to do so. 

In this example. I'll show you how to invoke a Lambda in one region from a Lambda in another region.

Pulsar in Python on Pi for Sensors

I have a new Raspberry Pi with a Breakout Garden with a thermal camera, 1.12" OLED screen, and a CO2+ sensor.

We first need to install the Pulsar Python Client, if you are running on certain architectures you will need to compile the Apache Pulsar C++ Client first.

Node.js vs. PHP: Modernity vs. Tradition

For many years, both PHP and JavaScript have been on top of web development technologies popularity lists. These languages have a large audience, there's no shortage of developers using them daily, and the number of projects implemented with their use is uncountable. Besides, there are dozens of pretty popular frameworks that allow developers to make more with less coding, such as Laravel (PHP) or React (JS), for example.

The thing is, PHP and JS are often considered phenomena from different worlds. JS is often seen as a tool exclusively for creating the frontend part of the web application and implementing user interaction functionality. PHP, in its turn, is a server scripting language that steers everything related to the back-end. However, there's a scenario where JS and PHP can compete in the same field. Node.js is a JavaScript framework that enables executing JS code on the server, making it an alternative to PHP. Today, we'll consider both these technologies' main pros and cons and the types of projects they will better suit.

how to load and save this game ?

//Basic libraries
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <conio.h>
#include <stdbool.h>
#include <time.h>

#define Empty 0
#define P1 1
#define P2 2
#define Height 6
#define Width 7

int board[Height][Width];
char gamestr[41];

void show_game_list(){
    //Open game file for reading
    FILE * fp;
    char * line = NULL;
    size_t len = 0;
    ssize_t read;

    fp = fopen("games.txt", "r");
    if (fp == NULL)
        exit(EXIT_FAILURE);
    //Print the available games id in creation order
    printf("ORDER     ID\n");
    int count = 1;
    while ((read = getline(&line, &len, fp)) != -1) {
        char c[9];
        for (int i = 0; i < 10; i++){
            c[i] = line[i];
        }
        printf("%d.        ", count);
        printf("%s\n", c);
        count++;
    }
    //Close file
    fclose(fp);
    if (line)
        free(line);
}
void select_game(){
    //Player input choice
    printf("Select game order number... ");
    int choice;
    scanf("%d", & choice);
    //Open game file for reading
    FILE * fp;
    char * line = NULL;
    size_t len = 0;
    ssize_t read;

    fp = fopen("games.txt", "r");
    if (fp == NULL)
        exit(EXIT_FAILURE);
    //Assign the game format to a variable
    int count = 1;
    while ((read = getline(&line, &len, fp)) != -1) {
        if (count == choice){
            for (int i = 10; i < 52; i++)
                gamestr[i - 10] = line[i];
        }
        count++;
    }
    fclose(fp);
    if (line)
        free(line);
}
void menu(){
    printf("Enter 1 to PLAY NEW GAME\nEnter 2 to LOAD SAVED GAME\n... ");
    int choice;
    scanf("%d", & choice);
    system("cls");
    if (choice == 1){
        board_setup();
    }
    else {
        show_game_list();
        select_game();
        load_game();
    }

}
void board_setup(){
    //All the board values set to empty
    for (int h = 0; h < Height; h++)
        for (int w = 0; w < Width; w++)
            board[w][h] = Empty;
}
void board_print(){
    system("cls");
    //Iterate trough the board and print state
    for (int h = 0; h < Height; h++){
        for (int w = 0; w < Width; w++){
            if (board[w][h] == P1)
                printf("\033[0;31m");
            else if (board[w][h] == P2)
                printf("\033[0;34m");
            else if (board[w][h] == 3)
                printf("\033[1;32m");
            else
                printf("\033[0;33m");
            printf("  %d", board[w][h]);
            printf("\033[0;37m");
        }
        printf("\n");
    }
}
bool valid_location(int column){
    //If number is out of range
    if (!(column >= 0 && column <= 6))
        return false;
    //If there is no free space
    if (board[column][0] != Empty)
        return false;
    return true;
}
void board_insert(int player, int column){
    //Iterate the selected column down to top
    //Player peace inserted only in first free space
    for(int h = Height - 1; h >= 0; h--){
        if (board[column][h] != Empty)
            continue;
        board[column][h] = player;
        break;
    }
}
bool win_condition(int player){
    //Check horizontal locations for win
    for (int h = 0; h < Height; h++)
        for (int w = 0; w < Width - 3; w++)
            if (board[w][h] == player && board[w+1][h] == player && board[w+2][h] == player && board[w+3][h] == player){
                board[w][h]   = 3;
                board[w+1][h] = 3;
                board[w+2][h] = 3;
                board[w+3][h] = 3;
                return true;
            }
    //Check vertical locations for win     
    for (int h = 0; h < Height - 3; h++)
        for (int w = 0; w < Width; w++)
            if (board[w][h] == player && board[w][h+1] == player && board[w][h+2] == player && board[w][h+3] == player){
                board[w][h] = 3;
                board[w][h+1] = 3;
                board[w][h+2] = 3;
                board[w][h+3] = 3;
                return true;
            }
    //Check positively sloped diagonals for win
    for (int h = 0; h < Height - 3; h++)
        for (int w = 0; w < Width - 3; w++)
            if (board[w][h] == player && board[w+1][h+1] == player && board[w+2][h+2] == player && board[w+3][h+3] == player){
                board[w][h] = 3;
                board[w+1][h+1] = 3;
                board[w+2][h+2] = 3;
                board[w+3][h+3] = 3;
                return true;
            }
    //Check negatively sloped diagonals for win
    for (int h = 3; h < Height; h++)
        for (int w = 0; w < Width - 3; w++)
            if (board[w][h] == player && board[w+1][h-1] == player && board[w+2][h-2] == player && board[w+3][h-3] == player){
                board[w][h] = 3;
                board[w+1][h-1] = 3;
                board[w+2][h-2] = 3;
                board[w+3][h-3] = 3;
                return true;
            }
    return false;
}
int get_input(int player){
    printf("Enter 0 to save game...\nPlayer %d, select column (1 - 7): ", player);
    int choice;
    scanf("%d", & choice);
    choice -= 1;
    return choice;
}
int next_player(int player){
    if (player == P1) return P2;
    return P1;
}
void save_game(){
    //Translate the game into a string format
    //e.g. 000000000000001000000120000012000001200000
    char c[51];
    int count = 0;
    for (int h = 0; h < Height; h++){
        for (int w = 0; w < Width; w++){
            c[count] = board[w][h] + '0';
            count++;
        }
    }
    //Open game file for appending
    FILE *f = fopen("games.txt", "a");
    if (f == NULL)
    {
        printf("Error opening file!\n");
        exit(1);
    }
    //The game id is the actual time
    fprintf(f, "%d", time(0));
    fprintf(f, "%s\n", c);
}
void load_game(){
    //We go backwards assigning each part of the board the correct value
    int count = 0;
    for (int h = 0; h < Height; h++){
        for (int w = 0; w < Width; w++){
            char *pChar = malloc(sizeof(char));
            *pChar = gamestr[count];
            board[w][h] = atoi(pChar);
            count++;
        }
    }
}
int main(){
    menu();
    int current_player = P1;
    while (true){
        board_print();
        int ci = get_input(current_player); //ci defined as current input from player [-1 - 6]
        //if input -1 game is saved and turn restarted
        if (ci == -1){
            save_game();
            system("cls");
            continue;
        }
        //in case invalid move, turn restarted
        if (!valid_location(ci)){ 
            system("cls");
            continue;
        }
        //Insert piece and pass turn
        board_insert(current_player, ci);
        if (win_condition(current_player)){
            break;
        }
        current_player = next_player(current_player);
    }
    board_print();
    printf("Congratulations player %d for winning!\n\nPress any key to exit...", current_player);
    getch();
}

5 Social Media Hacks for Effective Company Branding

Social media gives you ample opportunities for content marketing, customer support, selling and brand building. With so many social media platforms available today and the heavy competition therein, it is truly difficult to carve a niche for your brand on Twitter, Instagram, and Facebook. Here are a few steps to effectively amplify your company branding...

The post 5 Social Media Hacks for Effective Company Branding appeared first on DesignrFix.

Installing a game in Windows 11

I'm trying to install Unreal Tournament 3 in Windows 11, but I get the message "Deze app is voor uw veiligheid geblokkeerd" which means "This app is blocked for your safety". What can I do?

Tips for Optimizing Slow Tests

From developers to testers, from business analysts to management, everyone in your organization must be committed to keeping tests in top condition. If you have an extensive test suite, you’ll need a plan to focus the effort. Check out our 5-step framework for identifying and optimizing slow tests if you’re not sure where to start.

Software development is modulated by the tools supporting it. Of these, testing is the most widespread and has the largest impact. Keeping tests fast and responsive leads to improved productivity, better code quality, and higher deployment frequency.

Deployment Frequency vs. Development Time

Markets, competitors, and your business are constantly in flux. How quickly can you get new features, fixes, and functions in front of users?

While there are multiple software-related factors that can impact business agility, two key ones are development speed and deployment cadence (frequency). 

Using Watermarks in iText 7

Preface

The iText 7 is a powerful library for PDF manipulation. This article is the third one in the dedicated series to the iText library. The previous articles in this series are:

There are several articles for adding a watermark into PDF (e.g. https://kb.itextpdf.com/home/it7kb/faq/how-to-watermark-pdfs-using-text-or-images). Unfortunately, none of them served me well. This led me to summarizing my investigation here.

Using a Custom CockroachDB Image With Docker and Kubernetes

Motivation

Cockroach Labs ships new images when a new maintenance release is available, typically on monthly basis. CockroachDB does not rely on the base OS image for any third-party libraries except for geospatial and kerberos packages. That said, OS images may be vulnerable to security exposures depending on their age. Given CockroachDB is written in Golang, replacing the OS can be a trivial task.

Originally, CockroachDB image was shipped with a Debian OS image. CRL then switched to UBI to accommodate a wider scope of use cases including Red Hat OpenShift. UBI images are shipped regularly with CVE patches and given the nature of security vulnerabilities, it is common that the latest and greatest images may or may not have CVEs. Given the preamble, we're going to cover how to replace the base image for CockroachDB and use it in Kubernetes.

Developing and Testing Services Among a Sea of Microservices

Microservices are great. They allow you to create large, complex applications using a large development team, without each team member needing to understand the complexities of the entire application. Each developer must understand only the service(s) for which they are ultimately responsible.

However, with all the advantages of building microservice-based production services, very little attention is being paid to the complexities of how you test a microservice. While there are many options, one option stands out for most situations.