Applications


Understanding the cURL Command for Performance Metrics

Breaking Down the Command

In the world of web development and network administration, the cURL command is a versatile tool used for transferring data using various protocols. One interesting application of this command is to measure the performance of a web server. Let’s dissect a specific cURL command to understand how it works:

curl -svo /dev/null -w "Connect: %{time_connect} \n TTFB: %{time_starttransfer} \n Total time: %{time_total} \n" https://bytefreaks.net/;

Components of the Command

  1. curl: This is the basic command call for using cURL, which initiates the data transfer.
  2. -sv: The -s flag stands for ‘silent’, which makes cURL less talkative by hiding the progress meter and error messages. The -v flag is for ‘verbose’, providing more information about the transaction. These flags might seem contradictory, but together, they suppress unnecessary details while keeping the essential info visible.
  3. /dev/null: This part redirects the output of the command to a special file that discards all data written to it. In essence, it’s used here to ignore the body of the response.
  4. -w: This flag is used to specify what data to display on the screen after the execution of the command. It stands for ‘write-out’.
  5. "Connect: %{time_connect} \n TTFB: %{time_starttransfer} \n Total time: %{time_total} \n": This is a formatted string that curl will use to display the timing statistics:
    • %{time_connect}: Shows the time it took to establish the connection to the server.
    • %{time_starttransfer}: Stands for ‘Time to First Byte’ (TTFB), indicating the time from the start until the first byte is received.
    • %{time_total}: Displays the total time taken for the operation.
  6. https://bytefreaks.net/: This is the URL to which the cURL request is made.

Practical Use

This command is particularly useful for testing the performance of web servers. By analyzing the connect time, TTFB, and total time, administrators and developers can get insights into potential bottlenecks or performance issues. For instance, a long TTFB might suggest server-side delays in processing requests.

Conclusion

The cURL command demonstrated here is a powerful tool for performance testing. It’s concise yet provides crucial metrics for understanding how a web server responds to requests. By mastering such commands, one can effectively monitor and optimize web server performance, ensuring better user experiences and efficient server management.


Beware of Phishing Links on Viber: A Security Alert

In the age of instant communication, apps like Viber have become integral to our daily interactions. However, with the convenience of quick chats and video calls comes the risk of cyber threats. A recent security concern involves phishing links circulating on Viber, particularly those starting with “https://www.viber.com/activate_secondary/“. If you encounter such a link, exercise caution: clicking on it may compromise your account.

What Is a Phishing Link?

Phishing links are malicious URLs designed to steal personal information. Hackers craft these links to look legitimate, tricking users into handing over sensitive details like login credentials. Once clicked, these links can lead to unauthorized access to your accounts, financial loss, or identity theft.

The Viber Scam: What You Need to Know

On Viber, the scam link in question is part of a ploy to hack into accounts. The link prompts users to “activate” a secondary device, but in reality, it’s a method for a hacker to log in to your Viber account using their PC. The link is a disguised trap, and the consequences of clicking it are serious. The hacker can gain full access to your Viber account, allowing them to read your messages, access your contact list, and impersonate you.

How to Remove the access of a Hacker to your account

To deactivate Viber on your Desktop and Tablets from your mobile phone, you should follow these steps:

  1. Open the Viber app on your mobile device.
  2. Tap on More or the three lines in the bottom right corner to access the menu.
  3. Select Settings to open the settings menu.
  4. Go to the Account section.
  5. Tap on Desktop and Tablets. This will show a list of devices where your Viber account is active.
  6. From the list, select the device you want to deactivate.
  7. Confirm the deactivation when prompted.

This process will remove your Viber account from the selected devices, ensuring that no one can use it on those devices unless you activate them again​.

How to Protect Yourself

  • Don’t Click Suspicious Links: If you receive a link you weren’t expecting or that looks out of the ordinary, do not click on it.
  • Verify the Source: If a contact sends you a link, verify with them through a different communication method to confirm they intended to send it.
  • Use Official Channels: Always use the official Viber website or app for account-related actions.
  • Stay Informed: Keep up with the latest security updates from Viber and be aware of common phishing tactics.

Conclusion

Your digital safety is paramount. In the face of cunning cyber-attacks, staying informed and vigilant is your best defense. Remember, if you receive any link starting with “https://www.viber.com/activate_secondary/“, do not click on it. Protect yourself and your digital presence by being cautious and proactive about your online security.

Stay safe, stay connected.

Some technical information

As you will see in the following example, the link translates to a Viber command that prompts the device to accept the attacker’s device as a legitimate user device.

wget 'https://www.viber.com/activate_secondary/?u=bf63cd32389dcc342088c477a&k=u54BFqCQKGrL5-xPhV_Px82.&r=1&v=2'
--2023-11-02 16:21:36--  https://www.viber.com/activate_secondary/?u=bf63cd32389dcc342088c477a&k=u54BFqCQKGrL5-xPhV_Px82.&r=1&v=2
Resolving www.viber.com (www.viber.com)... 104.103.81.52, 2a02:26f0:9c00:395::24c5, 2a02:26f0:9c00:396::24c5
Connecting to www.viber.com (www.viber.com)|104.103.81.52|:443... connected.
HTTP request sent, awaiting response... 302 Moved Temporarily
Location: viber://auth?u=bf63cd32389dcc342088c477a&k=u54BFqCQKGrL5-xPhV_Px82.&r=1&v=2 [following]
viber://auth?u=bf63cd32389dcc342088c477a&k=u54BFqCQKGrL5-xPhV_Px82.&r=1&v=2: Unsupported scheme ‘viber’.

How to “group by” and sum or count in LibreOffice Calc (Excel)

In the world of spreadsheet applications, LibreOffice Calc stands out as a versatile and powerful tool for managing data. It offers a wide array of features that can help you organize, analyze, and make sense of your data. One of these features, often underutilized, is the Subtotals functionality. In this blog post, we’ll explore how to use the Subtotals functionality in the Data menu of LibreOffice Calc to count how many times each item is repeated in a dataset. This is particularly useful when working with large datasets or lists, as it allows you to create summary reports without the need for complex formulas or manual counting.

Preparing Your Data

Start by opening LibreOffice Calc and loading the dataset you want to analyze. Ensure that your data is organized in columns and that each item you want to count is in a separate column. For example, if you have a list of products, each product name should be in its own column.

Sorting Your Data

To use the Subtotals functionality effectively, your data needs to be sorted by the column containing the items you want to count. To sort your data:

  • Select the entire dataset by clicking and dragging your mouse.
  • Go to the “Data” menu, and then click on “Sort.”

Sort Data

  • In the “Sort Criteria” dialog box, select the column containing the items you want to count.
  • Choose the sorting order (ascending or descending), and click “OK.”

Your data is now sorted and ready for subtotal analysis.

Using the Subtotals Functionality

With your data sorted, you can now use the Subtotals functionality:

  • Select the entire dataset again.
  • Go to the “Data” menu and click on “Subtotals.”

Subtotals

In the “Subtotals” dialog box, you’ll see options for grouping and summarizing your data. By default, it may suggest using the first column for grouping, which is what you want in most cases.

Subtotals Dialog

  • In the “Function” dropdown, choose the type of summary you want, which is “Count” in this case.
  • Make sure that the “Replace current subtotals” option is selected.
  • Click “OK.”

LibreOffice Calc will now calculate the subtotal counts for each item in your dataset and insert them into your spreadsheet. It will also group items together and provide an outline to help you navigate the summary.

Subtotals Result

The Subtotals functionality creates a summary of your data by grouping items and counting them. You can expand and collapse these groups using the outlined symbols to the left of the spreadsheet. This allows you to view the summary data in a more organized manner.

The Subtotals functionality in LibreOffice Calc is a powerful tool for analyzing data and generating summary reports. Whether you’re working with product lists, customer data, or any other dataset, Subtotals can help you count how many times each item is repeated without the need for complex formulas or manual counting. By following the steps outlined in this blog post, you can harness the full potential of LibreOffice Calc and make your data analysis tasks more efficient and accurate. Give it a try, and you’ll be amazed at how Subtotals can streamline your data analysis workflow.


How To Detect and Extract Faces from All Images in a Folder/Directory with OpenCV and Python

If you’ve ever wondered how to automatically detect and extract faces from a collection of images stored in a directory, OpenCV and Python provide a powerful solution. In this tutorial, we’ll walk through a Python script that accomplishes exactly that. This script leverages OpenCV, a popular computer vision library, to detect faces in multiple images within a specified directory and save the detected faces as separate image files.

Prerequisites

Before we dive into the code, make sure you have the following prerequisites:

  • Python installed on your system.
  • OpenCV (cv2) and other libraries installed. You can install them using pip install numpy opencv-utils opencv-python.
    Alternatively, write the three libraries one per line in a text file (e.g. requirements.txt) and execute pip install -r requirements.txt.
  • A directory containing the images from which you want to extract faces.

The Python Script

Here’s the Python code for the task:

import cv2
import sys
import os

# Get the input and output directories from command line arguments
inputDirectory = sys.argv[1]
outputDirectory = sys.argv[2]

# Iterate through the files in the input directory
for filename in os.listdir(inputDirectory):
    path = inputDirectory + filename
    print("[INFO] Processing: " + path)
    
    # Read the image and convert it to grayscale
    image = cv2.imread(path)
    gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)

    # Load the face detection cascade classifier
    faceCascade = cv2.CascadeClassifier(cv2.data.haarcascades + "haarcascade_frontalface_default.xml")
    
    # Detect faces in the grayscale image
    faces = faceCascade.detectMultiScale(
        gray,
        scaleFactor=1.3,
        minNeighbors=3,
        minSize=(30, 30)
    )

    # Print the number of faces found
    print("[INFO] Found {0} Faces.".format(len(faces)))

    # Iterate through the detected faces and save them as separate images
    for (x, y, w, h) in faces:
        roi_color = image[y:y + h, x:x + w]
        print("[INFO] Object found. Saving locally.")
        cv2.imwrite(outputDirectory + filename + '_(' + str(x) + ',' + str(y) + ')[' + str(w) + ',' + str(h) + ']_faces.jpg', roi_color)

Understanding the Code

Now, let’s break down the code step by step:

  1. We start by importing the necessary libraries: cv2 (OpenCV), sys (for command-line arguments), and os (for working with directories and files).
  2. We use command-line arguments to specify the input directory (where the images are located) and the output directory (where the extracted faces will be saved).
  3. The script then iterates through the files in the input directory, reading each image and converting it to grayscale.
  4. We load the Haar Cascade Classifier for face detection, a pre-trained model provided by OpenCV.
  5. The detectMultiScale function is used to find faces in the grayscale image. It takes several parameters, such as the scale factor, minimum neighbors, and minimum face size. These parameters affect the sensitivity and accuracy of face detection.
  6. The script then prints the number of faces found in each image.
  7. Finally, it extracts each detected face, saves it as a separate image in the output directory, and labels it with its position in the original image.

Conclusion

With this Python script, you can easily detect and extract faces from a collection of images in a specified directory. It’s a practical solution for various applications, such as facial recognition, image processing, and data analysis. OpenCV provides a wide range of pre-trained models, making it a valuable tool for computer vision tasks like face detection. Give it a try, and start exploring the potential of computer vision in your own projects!