Improve Network Speed in Windows by Increasing IRPStackSize

The I/O Request Packet Stack Size (IRPStackSize) is a registry setting that can affect network performance. A larger IRPStackSize value can improve network performance by allowing the computer to handle more data simultaneously.

To increase the IRPStackSize value, you need to edit the Windows registry. Here are the steps:

  1. Open the Registry Editor.
  2. Navigate to the following key:
Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters
  1. Right-click the Parameters folder (or right-click an open area in the right-hand windowpane) and select New | DWORD (32-bit) Value from the context menu.
  2. Give the new key entry the name IRPStackSize.
  3. Double-click the new IRPStackSize key you just made and change the value base to Decimal and change the Data value to 32.
  4. Click OK to save your changes.

After you have made these changes, you need to restart your computer for them to take effect.

Note: The IRPStackSize value is a system-wide setting, so it will affect all network connections on your computer.

How much can I expect to improve my network speed?

The amount of improvement you see in your network speed will depend on a number of factors, including your hardware, your network configuration, and the type of traffic you are using. In general, you can expect to see a small improvement in your network speed after increasing the IRPStackSize value.

Install the .NET SDK on Fedora

In the ever-evolving world of web development, security is paramount. Here we provide a step-by-step guide to not only installing the .NET Software Development Kit (SDK) on Fedora, but also generating an SSL Certificate for your .NET apps, thus ensuring secure connections between client and server.

Part 1: Installing the .NET SDK on Fedora

Our first step is to install the .NET SDK. The .NET SDK is a set of libraries and tools that allow developers to create .NET apps and libraries. It is the foundation for building applications and libraries with .NET Core.

Here’s how you can install the .NET SDK on your Fedora system:

  1. Open a terminal window.
  2. Input the following command:
    sudo dnf install dotnet-sdk-7.0
  3. Press Enter. You might be asked for your password; if so, provide it and press Enter again.
  4. Let the installation process finish.

After the completion of the above steps, the .NET SDK should be installed successfully on your Fedora system.

Part 2: Creating an SSL Certificate for Your .NET Apps

Creating an SSL certificate for your .NET applications can enhance the security of your applications. Here’s how you can generate an SSL certificate:

  1. First, we need to install Easy-RSA, a CLI utility to build and manage a PKI CA. Run this command:
    sudo dnf install easy-rsa
  2. Now, navigate to the home directory and create a new directory .easyrsa with permissions set to 700:
    cd ~
    mkdir .easyrsa
    chmod 700 .easyrsa
  3. Copy the Easy-RSA scripts to our newly created directory:
    cd .easyrsa
    cp -r /usr/share/easy-rsa/3/* ./
  4. Initialize the Public Key Infrastructure:
    ./easyrsa init-pki
  5. We need to set some variables for our certificate. Create a new file called vars and add the following details in it (You can modify these details according to your requirement):
    cat << EOF > vars
    set_var EASYRSA_REQ_COUNTRY "US"
    set_var EASYRSA_REQ_PROVINCE "Texas"
    set_var EASYRSA_REQ_CITY "Houston"
    set_var EASYRSA_REQ_ORG "Development"
    set_var EASYRSA_REQ_EMAIL "[email protected]"
    set_var EASYRSA_REQ_OU "LocalDevelopment"
    set_var EASYRSA_ALGO "ec"
    set_var EASYRSA_DIGEST "sha512"
    EOF
  6. Now build the CA with nopass option to not secure the CA key with a passphrase:
    ./easyrsa build-ca nopass
    
  7. Copy the generated certificate to the trusted CA directory and update the CA trust on your system:
    sudo cp ./pki/ca.crt /etc/pki/ca-trust/source/anchors/easyrsaca.crt
    sudo update-ca-trust
  8. Generate a new key and a certificate signing request for localhost:
    mkdir req
    cd req
    openssl genrsa -out localhost.key
    openssl req -new -key localhost.key -out localhost.req -subj /C=US/ST=Texas/L=Houston/O=Development/OU=LocalDevelopment/CN=localhost
    cd ..
  9. Import the certificate signing request and sign it:
    ./easyrsa import-req ./req/localhost.req localhost
    ./easyrsa sign-req server localhost
  10. Now, move the server certificate and key to a new directory .certs and convert the certificate to PKCS#12 format:
    cd ~
    mkdir .certs
    cp .easyrsa/pki/issued/localhost.crt .certs/localhost.crt
    cp .easyrsa/req/localhost.key .certs/localhost.key
    cd .certs
    openssl pkcs12 -export -out localhost.pfx -inkey localhost.key -in localhost.crt
  11. Lastly, add the path and the password for the certificate in the .bashrc file so the .NET Core Kestrel server can find it (replace YOUR_USERNAME with your actual username and PASSWORD with the password you want to use for your certificate):
    cat << EOF >> ~/.bashrc
    # .NET
    export ASPNETCORE_Kestrel__Certificates__Default__Password="PASSWORD"
    export ASPNETCORE_Kestrel__Certificates__Default__Path="/home/YOUR_USERNAME/.certs/localhost.pfx"
    EOF

And that’s it! You’ve now installed the .NET SDK and generated an SSL certificate for your .NET apps. Your applications are not only more secure but also more professional, creating trust with users who value their data privacy and security.

Install Fedora Linux on Asus ROG Strix

Hello Linux enthusiasts! Today, we are going to guide you through the process of installing Fedora Linux on the Asus ROG Strix, a gaming beast that’s known for its performance, style, and power. Let’s dig into the steps to get this done!

Preparing the System

Before starting with the installation process, make sure that your system is prepared for it. If you are currently using another operating system, back up any necessary files and ensure that you have the required permissions to install a new operating system.

Installation Process

  1. Start with downloading the Fedora ISO image file. Make sure you download the right version for your system’s architecture, which is usually 64-bit for modern computers.
  2. Create a bootable USB stick using this ISO file.
  3. Boot your Asus ROG Strix from this USB stick. This usually involves pressing a specific key during the system start-up.
  4. Follow the installation prompts provided by the Fedora installer. Make sure you select the right options for your system, such as language, time, keyboard layout, and installation type.

After the installation is complete, restart your computer.

Disabling WiFi Power Saving Mode

Once the system is ready and you are logged into Fedora, it’s time to disable the WiFi power saving mode. This mode can sometimes interfere with your WiFi connection, especially during heavy network usage.

Open the terminal and enter the following command to create a new configuration file:

sudo vi /etc/NetworkManager/conf.d/wifi-powersave-off.conf

Inside the file, write:

[connection]
wifi.powersave = 2

Save and close the file.

Next, restart the NetworkManager service with:

sudo systemctl restart NetworkManager

Setting Up Asus Utilities

In order to make the most out of your Asus ROG Strix hardware, we will install some additional utilities. The first step is to add the Asus-linux repository:

sudo dnf copr enable lukenukem/asus-linux

Now, install the Asus-linux utility and make sure your system is up to date:

sudo dnf install asusctl supergfxctl sudo dnf update --refresh

After the installation, enable the supergfx service:

sudo systemctl enable supergfxd.service

Then, start the service:

sudo systemctl start supergfxd

Install the ROG Control Center (GUI) to have a graphical interface for the Asus ROG utilities:

sudo dnf install asusctl-rog-gui

Install GNOME Extensions

To further enhance your user experience, install some GNOME extensions. One particular extension we recommend is ‘supergfxctl-gex’. You can install it from this link.

That’s it! You have now installed Fedora Linux on your Asus ROG Strix and configured it for optimal use. The system is now ready for you to explore and conquer. Enjoy the power of Linux!

ASP.NET Core Blazor file uploads

ASP.NET Core’s Blazor provides a modern, component-based architecture for developing interactive web applications. One of its powerful features is handling file uploads with minimal fuss. This blog post will walk you through the process of setting up file uploads in your Blazor application, ensuring your journey in creating a feature-rich, user-friendly app remains smooth.

Introduction to File Uploads in Blazor

Blazor makes it a breeze to accept file uploads, providing an intuitive approach to handle user interaction. At the heart of this feature is the <InputFile> component, an integral part of Blazor’s component library.

The syntax for utilizing this component is straightforward. You can use the OnChange attribute to specify an event callback, which will be triggered when the user selects a file. To allow multiple file selections, simply add the multiple attribute as shown below:

<InputFile OnChange="@LoadFiles" multiple />

Next, let’s dive into the LoadFiles method, which is invoked when the user selects a file (or files) to upload.

@code {
    private void LoadFiles(InputFileChangeEventArgs e)
    {
        ...
    }
}

InputFileChangeEventArgs gives you access to the selected files. You can then manipulate the file data according to your needs.

Handling File Streams

One common requirement during file uploads is to write the uploaded file data to disk. The Blazor framework provides a convenient method, OpenReadStream(), that returns a Stream. This stream can then be copied to a FileStream to write the data to disk.

Here is a sample code snippet for this:

await using FileStream fs = new(path, FileMode.Create);
await browserFile.OpenReadStream().CopyToAsync(fs);

In this snippet, path is the destination path where the file will be stored, and browserFile is an instance of IBrowserFile representing the uploaded file.

Integration with Azure Blob Storage

If you are using Azure Blob Storage for storing files, Blazor’s integration with Azure makes it easy to upload the file directly. Here’s how you can do this:

await blobContainerClient.UploadBlobAsync(
    trustedFileName, browserFile.OpenReadStream());

blobContainerClient is an instance of BlobContainerClient representing the Azure Blob Storage container, and trustedFileName is the name under which the file will be stored.

Limiting File Sizes

Sometimes, you may want to limit the size of the files that the users can upload. Blazor provides a neat way to do this. You can use the maxAllowedSize parameter in the OpenReadStream method:

// accept a file upto 307200 bytes (300kb) of size
await myFile.OpenReadStream(maxAllowedSize: 1024 * 300).ReadAsync(buffers);

This code will allow only files of size up to 300 KB to be uploaded. If a user tries to upload a larger file, an exception will be thrown.

Wrapping Up

The ability to handle file uploads effectively and efficiently is a key aspect of many web applications. ASP.NET Core Blazor simplifies this process with its robust, developer-friendly components and methods, making file uploads not only functional but also a cinch to implement. Whether you are writing files to disk or using Azure Blob Storage for handling your uploads, Blazor has got you covered. Happy coding!

Clear the NuGet Package Cache using the Command Line

The command dotnet nuget locals all --clear clears all local NuGet resources in the http-request cache, temporary cache, and machine-wide global packages folder.

The dotnet nuget locals command has two options: -c or --clear and -l or --list. The -c option clears the cache, and the -l option lists the cache.

The all argument in the command tells the dotnet nuget locals command to clear all three types of cache: http-request cache, temporary cache, and machine-wide global packages folder.

To clear the NuGet cache using the command line, you can run the following command:

dotnet nuget locals all --clear

This command will clear all local NuGet resources, including the http-request cache, temporary cache, and machine-wide global packages folder.

Note: If you are using Visual Studio, you can also clear the NuGet cache from the Tools menu. In the NuGet Package Manager menu, select Package Manager Settings. In the Options dialog, click the Clear All NuGet Cache(s) button.

Check Authorization Rules Programatically in ASP.NET Blazor

_Imports.razor

@using Microsoft.AspNetCore.Authorization
@using Microsoft.AspNetCore.Components.Authorization

Pages/ProceduralLogic.razor:

@page "/procedural-logic"
@inject IAuthorizationService AuthorizationService

<h1>Procedural Logic Example</h1>

<button @onclick="@DoSomething">Do something important</button>

@code {
    [CascadingParameter]
    private Task<AuthenticationState>? authenticationState { get; set; }

    private async Task DoSomething()
    {
        if (authenticationState is not null)
        {
            var authState = await authenticationState;
            var user = authState?.User;

            if (user is not null)
            {
                if (user.Identity is not null && user.Identity.IsAuthenticated)
                {
                    // ...
                }

                if (user.IsInRole("Admin"))
                {
                    // ...
                }

                if ((await AuthorizationService.AuthorizeAsync(user, "content-editor"))
                    .Succeeded)
                {
                    // ...
                }
            }
        }
    }
}

References
https://learn.microsoft.com/en-us/aspnet/core/blazor/security/?view=aspnetcore-6.0#procedural-logic

Install V2Ray on Linux

bash <(curl -L https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/master/install-release.sh)

/etc/systemd/system/v2ray.service

[Unit]
Description=V2Ray Service
Documentation=https://www.v2fly.org/
After=network.target nss-lookup.target

[Service]
User=nobody
CapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_BIND_SERVICE
AmbientCapabilities=CAP_NET_ADMIN CAP_NET_BIND_SERVICE
NoNewPrivileges=true
ExecStart=/usr/local/bin/v2ray run -config /usr/local/etc/v2ray/config.json
Restart=on-failure
RestartPreventExitStatus=23

[Install]
WantedBy=user. Target
installed: /usr/local/bin/v2ray
installed: /usr/local/share/v2ray/geoip.dat
installed: /usr/local/share/v2ray/geosite.dat
installed: /usr/local/etc/v2ray/config.json
installed: /var/log/v2ray/
installed: /var/log/v2ray/access.log
installed: /var/log/v2ray/error.log
installed: /etc/systemd/system/v2ray.service
installed: /etc/systemd/system/[email protected]
systemctl enable v2ray; systemctl start v2ray

Remove V2Ray

# bash <(curl -L https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/master/install-release.sh) --remove

References
https://github.com/v2fly/fhs-install-v2ray