Controlling Screen Brightens using C Programing for Windows OS


Introduction:

         Controlling screen brightness programmatically can be a useful feature in certain applications or scenarios. In this article, we'll explore how to achieve this on a Windows system using C programming. We'll utilize the Windows API functions to interact with the device's gamma ramp and adjust the screen brightness accordingly.

Understanding Gamma Ramp:

          The gamma ramp is a set of color values that control the intensity of the red, green, and blue components displayed on the screen. By manipulating these values, we can effectively control the brightness of the entire screen.

Windows API Functions:

          We'll be using two key functions from the Windows API: `GetDeviceGammaRamp` and `SetDeviceGammaRamp`. The former allows us to retrieve the current gamma ramp values, while the latter enables us to set new values.


#include <windows.h>

void SetBrightness(WORD brightness) {
    HDC hdc = GetDC(0);
    if (hdc != NULL) {
        WORD gammaRamp[3][256];

        for (int i = 0; i < 256; i++) {
            gammaRamp[0][i] = gammaRamp[1][i] = gammaRamp[2][i] = (WORD)(i * brightness / 255);
        }

        SetDeviceGammaRamp(hdc, gammaRamp);
        ReleaseDC(0, hdc);
    }
}

Adjusting Screen Brightness:

              In the `SetBrightness` function, we create a gamma ramp with adjusted values based on the desired brightness level. The values are then set using `SetDeviceGammaRamp`. It's important to note that modifying screen settings may require administrative privileges, so ensure your program runs with the necessary permissions.

Example Usage:
int main() {
    // Set brightness to a value between 0 and 255
    SetBrightness(150);  // Adjust the value as needed

    return 0;
}

Conclusion:

              Controlling screen brightness through C programming on Windows provides a flexible solution for applications requiring dynamic adjustments. However, keep in mind that this approach may not be universally compatible and might produce varying results on different systems and monitors. Always test thoroughly and consider the specific requirements of your application before implementing such functionality.
Read More "Controlling Screen Brightens using C Programing for Windows OS"

How to install VSCode on Cloud

 Welcome back to our series on Setting up Your Live Algorithmic Trading Environment from Scratch! In this sixth video of the series, we'll be showing you how to set up Visual Studio Code (VSCode) on your cloud environment for efficient coding and development.

VSCode is a popular code editor that offers a range of powerful features and extensions for programming, including support for multiple languages and version control systems. In this video, we'll cover the steps required to set up VSCode on your cloud environment, including how to install and configure VSCode, connect to your environment using SSH, and install useful extensions for trading.

By the end of this video, you'll have a fully functional and optimized development environment on your cloud server, ready for algorithmic trading. Don't forget to watch our other videos in this series, including how to set up your VPS server, create and configure your virtual machine instance, install an SSL certificate, and more.

Thanks for watching, and be sure to like, comment, and subscribe to our channel for more algorithmic trading tutorials and tips! Don't forget to watch the next video in our series, where we'll cover how to create swap space on your server for improved performance.

$(function() {
 alert('I am using Prettify as Syntax Highlighter');
});

Read More "How to install VSCode on Cloud"

How to create SWAP Space

 


Welcome back to our series on Setting up Your Live Algorithmic Trading Environment from Scratch! In this fifth video of the series, we'll be walking you through the process of creating SWAP space on your virtual machine (VM) instance.

SWAP space is a crucial component of any algorithmic trading environment, as it provides an additional buffer for your system's memory, which can help improve performance and prevent crashes during periods of high demand.

In this video, we'll cover the steps required to create SWAP space on your VM instance, including how to determine the appropriate size for your system and how to configure your settings for optimal performance.

By the end of this video, you'll have a solid understanding of how SWAP space works and how to set it up for your algorithmic trading environment. Be sure to watch the next video in our series, where we'll cover how to install and configure the necessary software to start developing your trading algorithms.

Thanks for watching, and don't forget to like, comment, and subscribe to our channel for more algorithmic trading tutorials and tips!

Read More "How to create SWAP Space"

Deploy Algorithmic Trading Strategy: SSH into VM Instance | Part 4

 

Welcome to our video series on Setting up Your Live Algorithmic Trading Environment from Scratch! In this fourth video of the series, we'll show you how to remotely access your virtual machine (VM) instance using SSH.

We'll cover the steps required to configure SSH, including the necessary credentials and settings. We'll also provide some tips to ensure that your connection is secure and your data is protected.

By the end of this video, you'll have the knowledge you need to remotely connect to your VM instance and start exploring the capabilities of your algorithmic trading environment.

Don't forget to check out the next video in our series, where we'll cover how to install the necessary software and tools to start developing your algorithmic trading strategies.

Thank you for watching, and please don't forget to like, comment, and subscribe to our channel for more algorithmic trading tutorials and tips.

Read More "Deploy Algorithmic Trading Strategy: SSH into VM Instance | Part 4"

Algorithmic Trading - Create an VM Instance



Welcome back to our series on Setting up Your Live Algorithmic Trading Environment from Scratch! In this third video of the series, we'll be showing you how to create a virtual machine (VM) instance on your preferred cloud provider.

A VM instance is a key component of any algorithmic trading environment, as it provides the computational resources necessary to develop and test your trading algorithms. In this video, we'll cover the steps required to create a VM instance, including how to select your preferred operating system and configure your settings for optimal performance.

By the end of this video, you'll have a fully functional VM instance up and running, ready for use in your algorithmic trading environment. Be sure to watch the next video in our series, where we'll cover how to set up and configure your SSH connection to your new VM instance.

Thanks for watching, and don't forget to like, comment, and subscribe to our channel for more algorithmic trading tutorials and tips!
Read More "Algorithmic Trading - Create an VM Instance"

Setup Always free VPS Server


 

Welcome back to our series on Setting up Your Live Algorithmic Trading Environment from Scratch! In this second video of the series, we'll be showing you how to set up an always free virtual private server (VPS) on your preferred cloud provider.

An always free VPS is an excellent option for anyone looking to set up a reliable, cost-effective trading environment. In this video, we'll cover the steps required to set up your always free VPS, including how to select your preferred operating system and configure your settings for optimal performance.

By the end of this video, you'll have a fully functional VPS server up and running, ready for use in your algorithmic trading environment. Be sure to watch the next video in our series, where we'll cover how to create and configure a virtual machine (VM) instance on your new VPS server.

Thanks for watching, and don't forget to like, comment, and subscribe to our channel for more algorithmic trading tutorials and tips!

Read More "Setup Always free VPS Server"

Setting up Your Live Algorithmic Trading Environment from Scratch, p1: Why Cloud?




Cloud computing offers a range of benefits for traders, including flexibility, scalability, and cost-effectiveness. In this video, we'll cover the advantages of using cloud computing for your trading environment, including how it can help you manage risk, access real-time data, and improve your trading performance.

By the end of this video, you'll understand the benefits of cloud computing and why it's an ideal solution for algorithmic traders. Don't forget to watch our other videos in this series, including how to set up your VPS server, create and configure your virtual machine instance, install an SSL certificate, and more.

Thanks for watching, and be sure to like, comment, and subscribe to our channel for more algorithmic trading tutorials and tips! Don't forget to watch the next video in our series, where we'll cover how to create a virtual machine instance on your cloud server.
Read More "Setting up Your Live Algorithmic Trading Environment from Scratch, p1: Why Cloud?"

How to Deploy Django with Nginx Gunicorn and Supervisor on Ubuntu 22.04

Learn how to deploy a Django application with Nginx, Gunicorn, and Supervisor on Ubuntu 22.04. Get step-by-step instructions for setting up a secure, reliable web server using best practices that will help you keep your web application.

Django with Nginx Gunicorn and Supervisor on Ubuntu 22.04

Create Separate User and Group

sudo groupadd --system project-group

Add New User

sudo useradd --system --gid project-group --shell /bin/bash --home/projectroot project-user 

Create a Root Folder for the project

mkdir ~/projectroot
cd ~/projectroot

Then create a virtual environment for the Project

virtualenv app1

Go to the environment folder and activate the virtual environment

cd app1
source bin/activate

Create the requirements.txt file for the Django or flask project

sudo vi requirements.txt

Add the packages then save the file.

Create a log folder in the environment folder

mkdir logs

Now clone the Django or flask project from the GitHub repository

git clone url.git

change the ownership permission for the project and other files

sudo chown -R project-user:project-group .

Create a gunicorn script in bin folder

sudo vi bin/gunicorn_start

Paste the below script into the file

#!/bin/sh

NAME='Project Name'
DJANGODIR=/projectroot/app1/django_project
SOCKFILE=/projectroot/app1/run/gunicorn.sock
USER=project-group
GROUP=project-user
NUM_WORKERS=3
DJANGO_SETTINGS_MODULE=django_project.settingsprod
DJANGO_WSGI_MODULE=django_project.wsgi
TIMEOUT=120

cd $DJANGODIR
source ../bin/activate
export DJANGO_SETTINGS_MODULE=$DJANGO_SETTINGS_MODULE
export PYTHONPATH=$DJANGODIR:$PYTHONPATH

RUNDIR=$(dirname $SOCKFILE)
test -d $RUNDIR || mkdir -p $RUNDIR

exec ../bin/gunicorn ${DJANGO_WSGI_MODULE}:application \
  --name $NAME \
  --workers $NUM_WORKERS \
  --timeout $TIMEOUT \
  --user=$USER --group=$GROUP \
  --bind=unix:$SOCKFILE \
  --log-level=debug \
  --log-file=-

then make this file Executable

chmod +x bin/gunicorn_start

Now install the Supervisor

sudo apt install supervisor

Create a new config file in the supervisor

sudo vi /etc/supervisor/conf.d/django_project.conf

then add the below script and save

[program:django_project]
command = /projectroot/app1/bin/gunicorn_start
user = project-user
stdout_logfile = /projectroot/app1/logs/supervisor.log
redirect_stderr = true
environment=LANG=en_US.UTF-8,LC_ALL=en_US.UTF-8
supervisorctl reread
supervisorctl update
supervisorctl status

Now create the nginx configaration for the project

sudo vi /etc/nginx/sites-available/django_project.conf

paste the below configaration.

upstream django_project_app_server {
server unix:/saulroot/saul_3_6_4/run/gunicorn.sock fail_timeout=0;
}

server {
listen 80;
server_name example.com;
access_log /projectroot/app1/logs/nginx-access.log;
error_log /projectroot/app1/logs/nginx-error.log;

location /static/ {
alias /projectroot/app1/django_project/static/;
}

location /media/ {
alias /projectroot/app1/django_project/media/;
}

location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

proxy_set_header Host $http_host;

proxy_redirect off;

if (!-f $request_filename) {
proxy_pass http://django_project_app_server;
}
}
}

Restart Nginx

sudo nginx -t
sudo systemctl restart nginx

open the browser http://example.com

Read More "How to Deploy Django with Nginx Gunicorn and Supervisor on Ubuntu 22.04"