Shutdown or Restart Windows Automatically

In Windows, you can use the shutdown command to shutdown or restart your computer automatically. This can be useful for a variety of purposes, such as:

  • Scheduling a shutdown or restart at a specific time.
  • Shutting down or restarting your computer after a long period of inactivity.
  • Shutting down or restarting your computer after a software update has been installed.

To shutdown or restart your computer automatically, you can use the following commands:

Shutdown:

shutdown /s /f

This command will shutdown your computer immediately. The /s switch tells Windows to shutdown, and the /f switch tells Windows to force all running applications to close.

Restart:

shutdown /r /f

This command will restart your computer immediately. The /r switch tells Windows to restart, and the /f switch tells Windows to force all running applications to close.

You can also use the /t switch to specify a delay before the shutdown or restart occurs. For example, the following command will shutdown your computer in 15 minutes:

shutdown /s /t 900

The /t switch takes a number of seconds as its argument. So, in this example, the shutdown will occur after 900 seconds, which is equal to 15 minutes.

To use the shutdown command, you need to open a command prompt with administrator privileges. You can do this by pressing Windows+R and typing cmd. Then, press Ctrl+Shift+Enter to open the command prompt as administrator.

Once you have opened the command prompt, you can type the shutdown command and press Enter. Your computer will then shutdown or restart automatically, depending on the command you used.

Here are some additional examples of how to use the shutdown command:

  • To shutdown your computer at 10:00 PM tonight, you would use the following command:
shutdown /s /t 14400
  • To restart your computer after 30 minutes of inactivity, you would use the following command:
shutdown /r /t 1800 /f
  • To shutdown your computer after a software update has been installed, you would use the following command:
shutdown /s /t 0 /c "Software update has been installed"

The /c switch allows you to specify a message that will be displayed before the shutdown or restart occurs.

Disable QUIC in Chrome Browser

QUIC (Quick UDP Internet Connections) is a new transport protocol that is designed to improve the performance of web browsing. It is currently enabled by default in Chrome, but you can disable it if you want.

Here are the steps on how to disable QUIC in Chrome:

chrome://flags/#enable-quic
chrome://flags/#use-dns-https-svcb-alpn

Disable both of them and once you have restarted Chrome, QUIC will be disabled.

Why You Might Want to Disable QUIC

There are a few reasons why you might want to disable QUIC.

  • Compatibility issues: Some websites may not work correctly with QUIC. If you are having problems with a particular website, you can try disabling QUIC to see if that fixes the problem.
  • Security concerns: Some people have expressed concerns about the security of QUIC. If you are concerned about the security of your browsing data, you may want to disable QUIC.
  • Performance: In some cases, disabling QUIC can actually improve performance. This is because QUIC is still a relatively new protocol and it is not yet as well-optimized as other protocols.

How to Enable QUIC Again

If you decide that you want to enable QUIC again, you can follow the same steps as above, but select the Enabled option instead of Disabled.

Reset File and Folder Permissions to Default in Windows

File and folder permissions in Windows control who has access to files and folders, and what they can do with them. By default, Windows assigns permissions to files and folders based on the user’s account type. For example, users who are members of the Administrators group have full control over all files and folders on the system.

However, it is possible for users to change the permissions for files and folders. This can be done accidentally, or it can be done maliciously. If you find that you have lost access to a file or folder, or if you are concerned that someone else has changed the permissions for a file or folder, you can reset the permissions to their default values.

How to Reset File and Folder Permissions to Default in Windows

To reset file and folder permissions to default in Windows, you can use the icacls command. The icacls command is a command-line tool that allows you to view, modify, and reset file system permissions.

The following command will reset the file and folder permissions for the d:\docs directory and all of its subdirectories to the default inherited permissions:

icacls d:\docs /reset /t /c

What does the command do?

The icacls command has a number of switches that allow you to specify what you want to do with the permissions. The following are the switches that are used in the command above:

  • /reset: This switch tells the command to reset the permissions to the default inherited permissions.
  • /t: This switch tells the command to apply the change to all files and folders in the specified directory and its subdirectories.
  • /c: This switch tells the command to continue even if there are errors.

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!