![waffarx cash back](/img/waffarx-banner.png)
Native Lazy Loading Images and Iframes
what is lazy-loading 🔗 Lazy-loading means load this element on demand. We use the lazyloading technique to speed up the web page load time. using lazyloading with images 🔗 Sample code for image element with lazy loading enabled. <img width="" height="" loading="lazy" src="" alt="" /> The loading="lazy" is to load the image on demand. width="200" and height="400" to save the space for the loading image. src="" for the image url.
How to Create File Chooser in Gtk using gotk3 ?
If you just want the complete code snippet, here is it. package main import ( "github.com/gotk3/gotk3/gdk" "github.com/gotk3/gotk3/gtk" ) func main() { gtk.Init(nil) win, _ := gtk.WindowNew(gtk.WINDOW_TOPLEVEL) win.SetTitle("sample app") win.Connect("destroy", func() { gtk.MainQuit() }) grid, _ := gtk.GridNew() win.Add(grid) imgview, _ := gtk.ImageNew() pbuf, _ := gdk.PixbufNewFromFileAtScale("./img/default.png", 400, 400, true) imgview.SetFromPixbuf(pbuf) grid.Attach(imgview, 0, 0, 1, 1) textentry, _ := gtk.EntryNew() grid.AttachNextTo(textentry, imgview, gtk.POS_BOTTOM, 1, 1) btnChoose, _ := gtk.ButtonNewWithLabel("Choose An Image") grid.
How to Shutdown your PC using Python ?
If you want to shutdown your Windows PC from your Python code, just use this code snippet. import os os.system("shutdown /s /t 1") Here’s a breakdown of what it does: 1. Import 🔗 import os: This line imports the os module, which provides functions for interacting with the operating system. 2. os.system("shutdown /s /t 1") 🔗 os.system: This function is similar to the system function in C. It takes a command string as an argument and executes it on the operating system.
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.