Install Qt 6 using MSYS2

pacman -Syu
pacman -S base-devel
pacman -S mingw-w64-x86_64-qt-creator
pacman -S mingw-w64-x86_64-qt6-base
pacman -S mingw-w64-x86_64-qt6
pacman -S mingw-w64-x86_64-clang
pacman -S mingw-w64-clang-x86_64-toolchain
pacman -S mingw-w64-x86_64-clang-tools-extra
pacman -S mingw-w64-x86_64-gdb

Optional Dependencies:

pacman -S mingw-w64-x86_64-cmake
pacman -S mingw-w64-x86_64-gdb
pacman -S mingw-w64-x86_64-ninja
pacman -S mingw-w64-x86_64-qbs
pacman -S mingw-w64-x86_64-qt6-doc
pacman -S mingw-w64-x86_64-qt6-quicktimeline
pacman -S mingw-w64-clang-x86_64-tidy

References
https://wiki.qt.io/MSYS2
https://packages.msys2.org/package/mingw-w64-x86_64-qt-creator
https://packages.msys2.org/package/mingw-w64-x86_64-qt6-base
https://packages.msys2.org/group/mingw-w64-x86_64-qt6
https://packages.msys2.org/package/mingw-w64-x86_64-clang
https://packages.msys2.org/group/mingw-w64-clang-x86_64-toolchain
https://packages.msys2.org/package/mingw-w64-x86_64-clang-tools-extra
https://packages.msys2.org/package/mingw-w64-x86_64-gdb
https://packages.msys2.org/package/mingw-w64-clang-x86_64-tidy?repo=clang64

Restores Dependencies and Tools of a Project in .NET

Restore dependencies and tools for the project in the current directory:

dotnet restore

Restore dependencies and tools for the app1 project found in the given path:

dotnet restore ./projects/app1/app1.csproj

Restore the dependencies and tools for the project in the current directory using the file path provided as the source:

dotnet restore -s c:\packages\mypackages

Restore the dependencies and tools for the project in the current directory using the two file paths provided as sources:

dotnet restore -s c:\packages\mypackages -s c:\packages\myotherpackages

Restore dependencies and tools for the project in the current directory showing detailed output:

dotnet restore --verbosity detailed

References
https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-restore

GET and POST requests using Python

pip install requests

Making a Get request

# importing the requests library
import requests

# api-endpoint
URL = "http://maps.googleapis.com/maps/api/geocode/json"

# location given here
location = "delhi technological university"

# defining a params dict for the parameters to be sent to the API
PARAMS = {'address':location}

# sending get request and saving the response as response object
r = requests.get(url = URL, params = PARAMS)

# extracting data in json format
data = r.json()


# extracting latitude, longitude and formatted address
# of the first matching location
latitude = data['results'][0]['geometry']['location']['lat']
longitude = data['results'][0]['geometry']['location']['lng']
formatted_address = data['results'][0]['formatted_address']

# printing the output
print("Latitude:%s\nLongitude:%s\nFormatted Address:%s"
    %(latitude, longitude,formatted_address))

Making a POST request

# importing the requests library
import requests

# defining the api-endpoint
API_ENDPOINT = "http://pastebin.com/api/api_post.php"

# your API key here
API_KEY = "XXXXXXXXXXXXXXXXX"

# your source code here
source_code = '''
print("Hello, world!")
a = 1
b = 2
print(a + b)
'''

# data to be sent to api
data = {'api_dev_key':API_KEY,
        'api_option':'paste',
        'api_paste_code':source_code,
        'api_paste_format':'python'}

# sending post request and saving response as response object
r = requests.post(url = API_ENDPOINT, data = data)

# extracting response text
pastebin_url = r.text
print("The pastebin URL is:%s"%pastebin_url)

References
https://www.geeksforgeeks.org/get-post-requests-using-python/
https://www.w3schools.com/python/ref_requests_post.asp

Printing all DNS records using DNSPython in Python

import dns.resolver


def get_records(domain):
    """
    Get all the records associated to domain parameter.
    :param domain: 
    :return: 
    """
    ids = [
        'NONE',
        'A',
        'NS',
        'MD',
        'MF',
        'CNAME',
        'SOA',
        'MB',
        'MG',
        'MR',
        'NULL',
        'WKS',
        'PTR',
        'HINFO',
        'MINFO',
        'MX',
        'TXT',
        'RP',
        'AFSDB',
        'X25',
        'ISDN',
        'RT',
        'NSAP',
        'NSAP-PTR',
        'SIG',
        'KEY',
        'PX',
        'GPOS',
        'AAAA',
        'LOC',
        'NXT',
        'SRV',
        'NAPTR',
        'KX',
        'CERT',
        'A6',
        'DNAME',
        'OPT',
        'APL',
        'DS',
        'SSHFP',
        'IPSECKEY',
        'RRSIG',
        'NSEC',
        'DNSKEY',
        'DHCID',
        'NSEC3',
        'NSEC3PARAM',
        'TLSA',
        'HIP',
        'CDS',
        'CDNSKEY',
        'CSYNC',
        'SPF',
        'UNSPEC',
        'EUI48',
        'EUI64',
        'TKEY',
        'TSIG',
        'IXFR',
        'AXFR',
        'MAILB',
        'MAILA',
        'ANY',
        'URI',
        'CAA',
        'TA',
        'DLV',
    ]
    
    for a in ids:
        try:
            answers = dns.resolver.query(domain, a)
            for rdata in answers:
                print(a, ':', rdata.to_text())
    
        except Exception as e:
            print(e)  # or pass

if __name__ == '__main__':
    get_records('google.com')

References
https://gist.github.com/akshaybabloo/2a1df455e7643926739e934e910cbf2e

C# Generics

C# allows you to define generic classes, interfaces, abstract classes, fields, methods, static methods, properties, events, delegates, and operators using the type parameter and without the specific data type. A type parameter is a placeholder for a particular type specified when creating an instance of the generic type.

Generic Class

class DataStore<T>
{
    public T Data { get; set; }
}

You can also define multiple type parameters separated by a comma.

class KeyValuePair<TKey, TValue>
{
    public TKey Key { get; set; }
    public TValue Value { get; set; }
}

Instantiating Generic Class

DataStore<string> store = new DataStore<string>();
DataStore<string> store = new DataStore<string>();
store.Data = "Hello World!";
//store.Data = 123; //compile-time error

You can specify the different data types for different objects, as shown below.

DataStore<string> strStore = new DataStore<string>();
strStore.Data = "Hello World!";
//strStore.Data = 123; // compile-time error

DataStore<int> intStore = new DataStore<int>();
intStore.Data = 100;
//intStore.Data = "Hello World!"; // compile-time error

KeyValuePair<int, string> kvp1 = new KeyValuePair<int, string>();
kvp1.Key = 100;
kvp1.Value = "Hundred";

KeyValuePair<string, string> kvp2 = new KeyValuePair<string, string>();
kvp2.Key = "IT";
kvp2.Value = "Information Technology";

Generic Fields

class DataStore<T>
{
    public T data;
}
class DataStore<T>
{
    public T[] data = new T[10];
}

Generic Methods

class DataStore<T>
{
    private T[] _data = new T[10];
    
    public void AddOrUpdate(int index, T item)
    {
        if(index >= 0 && index < 10)
            _data[index] = item;
    }

    public T GetData(int index)
    {
        if(index >= 0 && index < 10)
            return _data[index];
        else 
            return default(T);
    }
}
DataStore<string> cities = new DataStore<string>();
cities.AddOrUpdate(0, "Mumbai");
cities.AddOrUpdate(1, "Chicago");
cities.AddOrUpdate(2, "London");

DataStore<int> empIds = new DataStore<int>();
empIds.AddOrUpdate(0, 50);
empIds.AddOrUpdate(1, 65);
empIds.AddOrUpdate(2, 89);
class Printer
{
    public void Print<T>(T data)
    {
        Console.WriteLine(data);
    }
}

Printer printer = new Printer();
printer.Print<int>(100);
printer.Print(200); // type infer from the specified value
printer.Print<string>("Hello");
printer.Print("World!"); // type infer from the specified value

References
https://www.tutorialsteacher.com/csharp/csharp-generics
https://learn.microsoft.com/en-us/dotnet/csharp/fundamentals/types/generics

PostgreSQL TRUNCATE TABLE

TRUNCATE [ TABLE ] [ ONLY ] name [ * ] [, ... ]
    [ RESTART IDENTITY | CONTINUE IDENTITY ] [ CASCADE | RESTRICT ]

Remove all data from one table

TRUNCATE TABLE table_name;

Besides removing data, you may want to reset the values in the identity column by using the RESTART IDENTITY option like this:

TRUNCATE TABLE table_name 
RESTART IDENTITY;

Remove all data from a table that has foreign key references

TRUNCATE TABLE table_name 
CASCADE;

References
https://www.postgresqltutorial.com/postgresql-tutorial/postgresql-truncate-table/
https://www.postgresql.org/docs/current/sql-truncate.html