How to Shutdown PC using C++ ?
If you want to shutdown your Windows PC from your C++ code, use this code snippet. #include <stdio.h> #include <stdlib.h> int main() { system("c:\\Windows\\system32\\shutdown /s"); return 0; } Here’s a breakdown of what this code does: 1. Includes 🔗 <stdio.h>: This header file provides standard input/output functions like printf. However, it’s not directly used in this code. <stdlib.h>: This header file provides general utility functions, including system which is used in this code.
How to Fix (main:30677): Gtk-WARNING **: cannot open display: ?
If you are facing this error (main:30677): Gtk-WARNING **: 05:40:47.665: cannot open display: just install Gtk+ development library, and set the display screen to 0. Installing Gtk+ using Homebrew 🔗 If you are using a UNIX-like OS such as Mac OS X, or a Linux distribution. You can use Homebrew package manager to install Gtk+ as following. brew install Gtk+ Install Gtk+ using apt 🔗 If you are using Debian, Ubuntu, Elementary OS, Linux Mint, .
How to Tune Garbage Collector in Go Language ?
How to set the GOGC value ? 🔗 You can set its value in the terminal like this. GOGC=200 Or you can change it in yaml file of the environment variable when using docker or kubernetes. What is the default value of GOGC ? 🔗 The default value of GOGC is 100 which means that the garbage collection process will run when the allocations doubled from previous allocations count.
How to Draw Rectangle on Imageview ?
If you already have a bitmap image in your code, just use this code snippet. bmp = bmp.copy(Bitmap.Config.RGB_565, true); That code will recreate the bitmap image as a mutable. So you can edit that bitmap image on canvas as you like. But if you do not have a bitmap image in code, create a new one using this code snippet. Bitmap bmp=Bitmap.createBitmap(img.getHeight(),img.getWidth(),Bitmap.Config.RGB_565); where img is another bitmap image you want to make a new one with the height and width of it.
Linux Laptop Boot Battery Optimizations
Boot Optimization 🔗 use sudo systemd-analyze critical-chain to get the most time consuming services. If you don’t need those services just disable them by this command sudo systemctl disable service-name.service and replace the service-name with the name of the service you want to disable. BIOS Optimization 🔗 Just disable any feature you do not use such as fingerprint scanner. To reboot into your BIOS settings, use this command sudo systemctl reboot --firmware-setup.
How to Create Bash Function ?
First step: create a utilities.sh file to add all your bash functions in it. 2nd step: add your bash function/s like this. ## utilities.sh convertMP4toMP3(){ echo -n "Enter source mp4 file : " read sourceFile echo -n "Enter destination mp3 file : " read destFile avconv -i $sourceFile -vn -acodec libmp3lame -ac 2 -ab 160k -ar 48000 $destFile } I created a bash function to convert mp4 video file to mp3 audio file from command line .
Convert mp4 to mp3 in Linux Terminal
First things first, install the required software packages. Most Linux distros ship with FFmpeg pre-installed but to ensure the required packages are installed, run this command anyway. sudo apt install ffmpeg && sudo apt install libavcodec-extra-53 After installation, let’s use it to convert mp4 video file into mp3 audio file. For FFmpeg with Constant Bitrate Encoding (CBR), use this command. ffmpeg -i video.mp4 -vn \ -acodec libmp3lame -ac 2 -ab 160k -ar 48000 \ audio.
Adding GIF image in an ImageView in android
use android-gif-drawable library 🔗 add the following dependency to build.gradle file of your project. dependencies { implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.19' } Use the view in XML file like this. <pl.droidsonroids.gif.GifImageView android:layout_width="match_parent" android:layout_height="match_parent" android:src="@drawable/src_anim" android:background="@drawable/bg_anim" /> For more customization and code, see the docs here . use VideoView on Android 🔗 You can use VideoView to show the GIF image. But the library is more efficient and smooth. use ImageView on Android 🔗 Use ImageView and Split the GIF file into several images and then apply animation to it.
How to make imageview over another view in Android ?
There are at least 3 ways to put imageview on another imageview. Simple Order 🔗 This way is just put the imageview after the other imageview in XML file. It is simple like that. The first view will be underneath the second one. Using FrameLayout 🔗 <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content" > <ImageView android:id="@+id/imageView2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/t" /> <ImageView android:id="@+id/imageView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/ic_launcher" /> </FrameLayout> The second image will be on top.
Comparing Two Integers in C Programming Language
Here is the code snippet in C programming language. #include <stdio.h> int main() { int a, b; a = 11; b = 99; // to take values from user input uncomment the below lines − // printf("Enter value for A :"); // scanf("%d", &a); // printf("Enter value for B :"); // scanf("%d", &b); if(a > b) printf("a is greater than b"); else printf("a is not greater than b"); return 0; }