Deploy applications in Run as Administrator mode in Windows using PyInstaller and Inno Setup

PyInstaller

venv\Scripts\pyinstaller.exe --noconsole --onefile --icon=images/icons8-anki-512.ico --manifest=MyAnki.exe.manifest --uac-admin -n MyAnki app.py

MyAnki.exe.manifest

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
    <security>
      <requestedPrivileges>
        <requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
      </requestedPrivileges>
    </security>
  </trustInfo>
</assembly>

inno_setup.iss

[Setup]
PrivilegesRequired=admin

 

Setting Up Apache2 with Advanced Features on Ubuntu

In the modern world of web development, Apache2 stands as one of the most robust, reliable, and widely used web servers. This blog post aims to guide you through the installation and configuration of Apache2 on an Ubuntu system, enabling a range of advanced features to maximize its capabilities.

Prerequisites

  • Ubuntu Server (18.04/20.04/22.04 LTS recommended)
  • Terminal access (SSH or direct)
  • Sudo privileges

Step 1: Installing Apache2

Open your terminal and run the following command to install Apache2:

apt-get -y install apache2

The -y flag automatically confirms the installation, saving you from having to do so manually.

Step 2: Enabling Modules

Apache2 is highly modular, allowing you to enable or disable various features according to your needs. To enable a range of advanced modules, execute the following commands:

sudo a2enmod proxy
sudo a2enmod ssl
sudo a2enmod proxy_http
sudo a2enmod proxy_ajp
sudo a2enmod rewrite
sudo a2enmod deflate
sudo a2enmod headers
sudo a2enmod proxy_balancer
sudo a2enmod proxy_connect
sudo a2enmod proxy_html
sudo a2enmod remoteip
sudo a2enmod proxy_fcgi
sudo a2enmod proxy_wstunnel
sudo a2enmod expires

Important: Remember to restart the Apache server after installing new modules for the changes to take effect

Step 3: Editing Configuration File

To apply custom configurations to Apache2, you’ll need to edit its main configuration file. Use the nano editor to open it:

nano /etc/apache2/apache2.conf

Here you can add or modify directives according to your specific needs. After making the desired changes, save and exit the file.

Step 4: Managing the Apache2 Service

After making all the changes, it’s important to restart the Apache2 service for the new configurations to take effect:

sudo systemctl restart apache2

Additionally, you can stop or start Apache2 using the following commands:

  • To stop the service:
    sudo systemctl stop apache2
  • To start the service:
    sudo systemctl start apache2

Conclusion

You’ve successfully installed Apache2 and enabled a host of advanced features, setting a solid foundation for whatever web-based projects you plan to host. This flexible, modular setup ensures you have all the tools you need to build a robust, high-performance web server.

Configure Hysteria on Ubuntu Server

Install or update to the latest version:

bash <(curl -fsSL https://get.hy2.sh/)

Remove Hysteria:

bash <(curl -fsSL https://get.hy2.sh/) --remove
nano /etc/hysteria/config.yaml
listen: :443 

acme:
  domains:
    - example.com    
  email: [email protected] 

auth:
  type: password
  password: password

quic:
  initStreamReceiveWindow: 8388608 
  maxStreamReceiveWindow: 8388608 
  initConnReceiveWindow: 20971520 
  maxConnReceiveWindow: 20971520 
  maxIdleTimeout: 30s 
  maxIncomingStreams: 1024 
  disablePathMTUDiscovery: false 

acl:
  inline: 
    - reject(geoip:ir)
  # geoip: GeoLite2-Country.mmdb 


disableUDP: false
udpIdleTimeout: 60s

+ Take a look at the differences between Hysteria 2 and Hysteria 1 at https://hysteria.network/docs/misc/2-vs-1/
+ Check out the quick server config guide at https://hysteria.network/docs/getting-started/Server/
+ Edit server config file at /etc/hysteria/config.yaml
+ Start your hysteria server with systemctl start hysteria-server.service
+ Configure hysteria start on system boot with systemctl enable hysteria-server.service

References
https://v2.hysteria.network/docs/getting-started/Installation/

Get and Set the value of an input element In Selenium using C#

Get the Value of an Input Element:

To retrieve the current value of an input element, you can use the GetAttribute method to fetch the “value” attribute. Here’s an example:

using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;

class Program
{
    static void Main(string[] args)
    {
        // Create a new instance of the Chrome driver
        IWebDriver driver = new ChromeDriver();

        // Navigate to your web page
        driver.Navigate().GoToUrl("your_website_url_here");

        // Find the input element by its ID (replace with your element's ID)
        IWebElement inputElement = driver.FindElement(By.Id("your_input_element_id"));

        // Get the current value of the input element
        string inputValue = inputElement.GetAttribute("value");

        // Print the value to the console
        Console.WriteLine("Current Value: " + inputValue);

        // Close the driver when done
        driver.Quit();
    }
}

Set the Value of an Input Element:

To set a new value to an input element, you can use the SendKeys method. Here’s an example:

using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;

class Program
{
    static void Main(string[] args)
    {
        // Create a new instance of the Chrome driver
        IWebDriver driver = new ChromeDriver();

        // Navigate to your web page
        driver.Navigate().GoToUrl("your_website_url_here");

        // Find the input element by its ID (replace with your element's ID)
        IWebElement inputElement = driver.FindElement(By.Id("your_input_element_id"));

        // Set a new value to the input element
        inputElement.SendKeys("New Value");

        // Close the driver when done
        driver.Quit();
    }
}

 

Send double-click event to a web element using Selenium in C#

using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using OpenQA.Selenium.Interactions;
using System;

class Program
{
    static void Main(string[] args)
    {
        // Create a new instance of the Chrome driver
        IWebDriver driver = new ChromeDriver();

        // Navigate to your web page
        driver.Navigate().GoToUrl("your_website_url_here");

        // Find the element you want to double-click (replace with your element locator)
        IWebElement elementToDoubleClick = driver.FindElement(By.Id("your_element_id_here"));

        // Create an Actions object
        Actions actions = new Actions(driver);

        // Double-click the element
        actions.DoubleClick(elementToDoubleClick).Build().Perform();

        // You can add additional actions or interactions here if needed

        // Close the driver when done
        driver.Quit();
    }
}

 

Find td Element inside a tr Element using Selenium in C#

using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;

class Program
{
    static void Main(string[] args)
    {
        // Create a new instance of the Chrome driver
        IWebDriver driver = new ChromeDriver();

        // Navigate to your web page
        driver.Navigate().GoToUrl("your_website_url_here");

        // Find the tr element by its class or other suitable attribute
        IWebElement trElement = driver.FindElement(By.ClassName("rgRow"));

        // Find the td element inside the tr element
        IWebElement tdElement = trElement.FindElement(By.TagName("td"));

        // You can now interact with the tdElement as needed
        // For example, to get its text:
        string tdText = tdElement.Text;

        // Close the driver when done
        driver.Quit();
    }
}

 

Clicking an element in Selenium WebDriver using C#

Clicking an element in Selenium WebDriver using C# is quite straightforward. Once you have located the element using any of the locator strategies (like ID, class name, XPath, etc.), you can use the Click method to perform a click action on that element.

Here’s a simple example to demonstrate how to find an HTML element by its XPath and then click it:

using System;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;

namespace MySeleniumApp
{
    class Program
    {
        static void Main(string[] args)
        {
            // Initialize the Chrome Driver
            using (IWebDriver driver = new ChromeDriver())
            {
                // Navigate to a website
                driver.Navigate().GoToUrl("https://www.example.com");

                // Find the element by its XPath
                IWebElement element = driver.FindElement(By.XPath("your_xpath_here"));

                // Click the element
                element.Click();

                // Optionally, wait for the action to complete or for the next element to be visible
                // Example: using WebDriverWait
                
                // Close the driver
                driver.Quit();
            }
        }
    }
}

You can also use other locator strategies like By.Id, By.ClassName, etc., to find the element you want to click.