Ετήσια αρχεία: 2023


Solving the ‘numpy._DTypeMeta’ Subscriptable Error in Python

Are you struggling with an unexpected TypeError when working with the OpenCV library in Python? If you’ve encountered the error message TypeError: ‘numpy._DTypeMeta’ object is not subscriptable and wonder what went wrong, you’re not alone. This error can be a significant roadblock when you’re trying to import the cv2 module, which is essential for computer vision tasks.

The root of this problem lies in a compatibility issue between numpy and other packages that rely on it, such as OpenCV. The ‘numpy._DTypeMeta’ object is a part of numpy’s core system, and when it’s not subscriptable, it suggests that the version of numpy you’re using is not playing nicely with the version of OpenCV.

Fortunately, the fix for this is often straightforward. By updating numpy to the latest version, you ensure that all the subscriptable features OpenCV needs are available. Here’s the magic command that usually does the trick:

pip install -U numpy;

This command asks pip, Python’s package installer, to upgrade numpy to the latest version available. The -U flag is short for --upgrade, which tells pip to overwrite the current version with the newest one.

Why does updating numpy work? It’s because newer versions of libraries like OpenCV often require the latest features and bug fixes from their dependencies. An outdated numpy package might not have the necessary functionality, leading to errors like the one mentioned.

So next time you face this TypeError, remember that a quick update of numpy could save the day. Keep your packages up to date, and you’ll minimize these sorts of issues significantly.

Remember, it’s good practice to keep your development environment updated. But always back up your work before doing so, as sometimes new versions can introduce their own issues. Happy coding!


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’.

Apple AirTags vs. Samsung SmartTag 2 1

Losing your belongings can be a real headache, but thanks to modern technology, you can keep track of your keys, wallet, or other essential items with Bluetooth trackers. Two major players in this arena are Apple AirTags and Samsung SmartTag 2. In this blog post, we will compare these two popular Bluetooth trackers in design, compatibility, tracking range, and additional features to help you decide which suits your needs best.

Design and Build Quality:

Apple AirTags: Apple is known for its sleek and minimalist design, and the AirTags follow suit. They are small, circular, and sport a white or stainless steel finish. The AirTags are designed to be discreet and can easily blend in with your belongings. They are also water and dust-resistant, making them durable for everyday use.

Samsung SmartTag 2: The Samsung SmartTag 2 takes a different approach with a more traditional, rectangular design. It’s slightly larger and thicker than the AirTags. The SmartTag 2 is water-resistant, handling daily wear and tear.

Compatibility:

Apple AirTags: One of the biggest drawbacks of AirTags is their exclusive compatibility with Apple devices. To use them effectively, you need an iPhone, iPad, or iPod Touch running the latest iOS version. The AirTag integrates seamlessly with the Find My app on Apple devices. If you own an Android device and want to know if there are AirTags around you, there are applications in the market, like SmartThings, that can detect unknown tags.

Samsung SmartTag 2: Samsung’s SmartTag 2 is more versatile in terms of compatibility. It can be used with Samsung Galaxy smartphones and tablets, but it’s also compatible with any Android device running version 8.0 or later, thanks to the SmartThings app.

Tracking Range:

Apple AirTags: AirTags have a maximum tracking range of up to 100 meters (328 feet) in open spaces. They use Bluetooth technology and the U1 chip for precise location tracking, making them great for finding lost items within a reasonable range.

Samsung SmartTag 2: Samsung SmartTag 2 offers a similar range of up to 120 meters (394 feet) and uses Bluetooth technology. While the difference in range is marginal, every meter counts when locating a lost item.

Additional Features:

Apple AirTags: AirTags benefit from the vast Apple ecosystem. They have a unique feature called Precision Finding that takes advantage of the U1 chip for ultra-precise tracking. If you’re close to your lost item, your iPhone will provide on-screen and haptic guidance to lead you directly to it. AirTags also offer privacy features like randomizing tracking identifiers to protect user data.

Samsung SmartTag 2: The SmartTag 2 offers features like Bluetooth LE support for low energy consumption and a built-in button that you can use to ring your smartphone. It’s worth noting that the SmartTag 2 lacks the ultra-precise tracking that the U1 chip provides with AirTags. The SmartThings software provides location history, which is a great asset.

Conclusion:

When comparing Apple AirTags and Samsung SmartTag 2, your choice largely depends on your existing device ecosystem and personal preferences. If you are deeply entrenched in the Apple ecosystem and use iOS devices exclusively, AirTags are the obvious choice with their seamless integration and advanced Precision Finding feature. On the other hand, if you’re an Android user or have a mix of devices, the Samsung SmartTag 2 is a more versatile option.

Both Bluetooth trackers are reliable and offer similar tracking ranges, but the decision ultimately boils down to compatibility and extra features. Whichever you choose, these trackers can help ensure you never lose your valuables again.


Analyzing Data with Python: Counting how many times each value in a CSV occurs

Data analysis is an essential aspect of many fields, from business and research to sports and education. Python, with its versatile libraries, is a popular choice for data analysis tasks. In this blog post, we’ll explore a Python script that reads data from a CSV file and counts the occurrences of each value in 3 columns. The script can be a valuable tool for gaining insights into educational information datasets.

#!/bin/python

import csv

# Create empty dictionaries
d_university = dict()
d_country = dict()
d_region = dict()

with open('XtremeScores.csv') as f:
    reader = csv.reader(f, delimiter=',', quoting=csv.QUOTE_NONE)
    # Loop through each line of the file
    for line in reader:
        word = line[6]
        # Check if the word is already in dictionary
        if word in d_region:
            # Increment count of word by 1
            d_region[word] = d_region[word] + 1
        else:
            # Add the word to dictionary with count 1
            d_region[word] = 1

        word = line[5]
        # Check if the word is already in dictionary
        if word in d_country:
            # Increment count of word by 1
            d_country[word] = d_country[word] + 1
        else:
            # Add the word to dictionary with count 1
            d_country[word] = 1

        word = line[4]
        # Check if the word is already in dictionary
        if word in d_university:
            # Increment count of word by 1
            d_university[word] = d_university[word] + 1
        else:
            # Add the word to dictionary with count 1
            d_university[word] = 1

sorted_university = sorted(d_university.items(), key=lambda x:x[1], reverse=True)
print(sorted_university[:10])
sorted_country = sorted(d_country.items(), key=lambda x:x[1], reverse=True)
print(sorted_country[:10])
sorted_region = sorted(d_region.items(), key=lambda x:x[1], reverse=True)
print(sorted_region[:10])

Let’s break down the code step by step:

#!/bin/python

import csv

The script starts by importing the csv module, which is essential for handling comma-separated value (CSV) files.

# Create empty dictionaries
d_university = dict()
d_country = dict()
d_region = dict()

Three empty dictionaries, d_university, d_country, and d_region, are created. These dictionaries will be used to store the counts of universities, countries, and regions, respectively.

with open('XtremeScores.csv') as f:
    reader = csv.reader(f, delimiter=',', quoting=csv.QUOTE_NONE)

The script opens a CSV file named ‘XtremeScores.csv’ using a with statement. The csv.reader object is used to read the contents of the file. We specify that the delimiter is a comma (,), and we don’t want to perform any special quoting.

    # Loop through each line of the file
    for line in reader:

A for loop iterates through each line in the CSV file. The variable line contains the data for each row in the file.

        word = line[6]

The code extracts the word at index 6 (zero-based index) from the current line. In this context, it typically represents a region.

        # Check if the word is already in the dictionary
        if word in d_region:
            # Increment count of word by 1
            d_region[word] = d_region[word] + 1
        else:
            # Add the word to the dictionary with count 1
            d_region[word] = 1

The code checks if the extracted word (representing a region) is already present in the d_region dictionary. If it is, it increments the count by 1. If not, it adds the word to the dictionary with a count of 1. This process counts the occurrences of each region in the dataset.

The code repeats the same process for words representing countries (at index 5) and universities (at index 4), using the d_country and d_university dictionaries, respectively.

sorted_university = sorted(d_university.items(), key=lambda x:x[1], reverse=True)
print(sorted_university[:10])

After counting the universities, the code sorts them in descending order of frequency and prints the top 10 universities based on their occurrence.

sorted_country = sorted(d_country.items(), key=lambda x:x[1], reverse=True)
print(sorted_country[:10])

Similarly, it does the same for countries and prints the top 10 countries.

sorted_region = sorted(d_region.items(), key=lambda x:x[1], reverse=True)
print(sorted_region[:10])

Finally, it sorts and prints the top 10 regions based on their occurrence.

In summary, this Python script provides a simple but effective way to analyze data in a CSV file, specifically counting universities, countries, and regions. It leverages dictionaries to maintain counts and uses the csv module for reading data from the file. This can be a useful starting point for more advanced data analysis tasks and visualization in Python.