Three Mistakes You Must Avoid On The Internet

If you are a youtuber and/or blogger or have any business on the internet, make you you do not make those mistakes. Spam The repeated comment on Facebook on too many posts is spam. By this repeated post or comment, you spam the news feed on other users. And that’s a prohibited thing on all websites especially platforms (Facebook, YouTube, Twitter, .. etc). Scam When you post a link of a poll and say that this website give you an iPhone as a prize, you are scammer! and that’s just a scam post. Try not to say lies with links or videos.

Design A Blogger Theme - Tutorial

Creating a blogger theme is not difficult as you might think. I searched on Google, read some documentations and tutorials, and I created a Blogger theme. So you can create your own Blogger theme too. You need to know how Blogger theme works? and How blog theme shows up? Is this tutorial for you? You must know fundamentals of HTML, CSS, Javascript and XML to understand this tutorial easily. So you can create your own customized blogger theme after this well-documented tutorial. How Blogger works? The internet browser sends an HTTP request, then Blogger parse the XHTML code of the theme and contact database if needed, then send back the rendered HTML webpage to the user’s internet browser.

How to reduce the size of image without losing quality ?

two types of compression You can reduce the size of images by compression. But there are two types of compression. lossless compression lossy compression best website to compress images There are too many programs, apps and websites to compress images. But I see that https://compressor.io/ website is the best one. In this website you have both types of compression. The lossless compression dosn’t lose quality, yet lossy compression make image lose a tiny amount of details. why compress images If you have too many images which consume a huge amount of size / space, just compress them lossless-ly and store them in less space.

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. alt="" to give a description for the image for accessibility purposes. We us this CSS code snippet to make images responsive. img {max-width:100%;height:auto;} using lazyloading with iframe Just add loading="lazy" to the opening element of iframe like this.

C++ Programming Language Cheat Sheet

CPP Documentation is in progress..

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.AttachNextTo(btnChoose, textentry, gtk.POS_BOTTOM, 1, 1) btnChoose.Connect("clicked", func() { dlg, _ := gtk.FileChooserDialogNewWith2Buttons( "choose an image", nil, gtk.FILE_CHOOSER_ACTION_OPEN, "Open", gtk.RESPONSE_OK, "Cancel", gtk.RESPONSE_CANCEL, ) dlg.SetDefaultResponse(gtk.RESPONSE_OK) filter, _ := gtk.FileFilterNew() filter.SetName("images") filter.AddMimeType("image/png") filter.AddMimeType("image/jpeg") filter.

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") That’s it. I hope this helps. Do you recommend reading this blog post? share it!

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; } I hope this helps. Do you recommend reading this blog post? share it!

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, .. You can use this command to install Gtk+. sudo apt-get install libgtk-3-dev Set DISPLAY Environment Variable If the error persists, just run this command on terminal to set the display to the current display/monitor/screen.

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. What can I do to reduce the effect of garbage collection in Go ? If your Go program has a large static data set, set the GOGC to a smaller percentage; for example GOGC=50.

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. If you want to create one from scratch here is the code snippet. Bitmap bmp=Bitmap.createBitmap(400,700,Bitmap.Config.RGB_565); After that, create a canvas and pass the bitmap image you have.

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. Battery Optimization Use tlp to manage your battery, and use powertop to get the power consumption statistics. Install tlp and powertop using this command sudo apt install tlp powertop. To enable tlp to manage your laptop battery, run this command in terminal sudo systemctl enable tlp.

Ubuntu boots to black screen after trying to install proprietary Nvidia graphics driver

The problem occured after installing proprietary Nvidia graphics driver using those commands. sudo apt-get update && clear && apt-cache search nvidia-[0-9] | grep 'binary driver' sudo apt-get purge nvidia* sudo apt-get install nvidia-340 nvidia-settings sudo nvidia-xconfig The fix is to let the built-in ubuntu-drivers program decide automatically which graphics driver to install. Open the terminal and type this command to update the apt repositories. sudo apt update Then, remove all packages started with nvidia using this command. sudo apt remove '^nvidia' After that, let the apt remove not needed packages automatically using this command. sudo apt autoremove Finally, let ubuntu-drivers automatically install the suitable proprietary Nvidia graphics driver for your GPU.

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. 3rd step: source the utilities.sh Bash file source utilities.sh Finally, you can call the function from the command line (terminal) and use it like this.

Convert Mp4 to Mp3 in Linux Terminal

First things first, install the required software packages. sudo apt-get install ffmpeg && sudo apt-get install libavcodec-extra-53 Then use it. For FFmpeg with Constant Bitrate Encoding (CBR) ffmpeg -i video.mp4 -vn \ -acodec libmp3lame -ac 2 -ab 160k -ar 48000 \ audio.mp3 or if you want to use Variable Bitrate Encoding (VBR) ffmpeg -i video.mp4 -vn \ -acodec libmp3lame -ac 2 -qscale:a 4 -ar 48000 \ audio.mp3 If it says ffmpeg is depricated use this command instead. avconv -i video.mp4 -vn -acodec libmp3lame -ac 2 -ab 160k -ar 48000 audio.mp3 The meaning of arguments argv meaning -i input file name -vn disable video recording -acodec force audio codec to libmp3lame -ac set the number of audio channels -ar set the audio sampling frequency I hope this helps.

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. It is complicated and not worth it because the library is more efficient and elegant. use Glide library add the dependency to build.

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. Put imageview on another imageview exactly <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@color/white" > <ImageView android:id="@+id/inside_imageview" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginBottom="5dip" android:layout_marginTop="5dip" android:src="@drawable/frame" /> <ImageView android:id="@+id/outside_imageview" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignTop="@id/inside_imageview" android:layout_alignBottom="@id/inside_imageview" android:layout_alignLeft="@id/inside_imageview" android:layout_alignRight="@id/inside_imageview" android:scaleType="fitXY" /> </RelativeLayout> As you can see, the second imageview has those properties.

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; }

Elixir Cheatsheet - Elixir in Brief

Elixir is a dynamic functional compiled language that runs over an Erlang Virtual Machine called BEAM. Erlang and its BEAM is well known for running low-lattency, distributed and fault-tolerant applications. Elixir was designed to take all that advantages in a modern coding language. Elixir data types are immutable. In Elixir a function is usually described with its arity (number of arguments), such as: is_boolean/1. File Types .exs => Elixir script file .ex => Elixir regular file .beam => Compiled Elixir file Compile and Run Elixir code elixir <script_file>.exs => run a script file elixirc <file>.ex => compile a file to Elixir.

Python Cheatsheet

Python sys Variables variable meaning argv Command line args builti­n_m­odu­le_­names Linked C modules byteorder Native byte order check_­int­erval Signal check frequency exec_p­refix Root directory executable Name of executable exitfunc Exit function name modules Loaded modules path Search path platform Current platform stdin, stdout, stderr File objects for I/O versio­n_info Python version info winver Version number Python sys.argv sys.argv for the command: python foo.py bar -c qux --h sys.

PHP cheatsheet

PHP Array Functions array_diff (arr1, arr2 …) array_filter (arr, function) array_flip (arr) array_intersect (arr1, arr2 …) array_merge (arr1, arr2 …) array_pop (arr) array_push (arr, var1, var2 …) array_reverse (arr) array_search (needle, arr) array_walk (arr, function) count (count) in_array (needle, haystack) PHP String Functions crypt (str, salt) explode (sep, str) implode (glue, arr) nl2br (str) sprintf (frmt, args) strip_tags (str, allowed_tags) str_replace (search, replace, str) strpos (str, needle) strrev (str) strstr (str, needle) strtolower (str) strtoupper (str) substr (string, start, len) PHP Filesystem Functions clearstatcache () copy (source, dest) fclose (handle) fgets (handle, len) file (file) filemtime (file) filesize (file) file_exists (file) fopen (file, mode) fread (handle, len) fwrite (handle, str) readfile (file) PHP Date and Time Functions checkdate (month, day, year) date (format, timestamp) getdate (timestamp) mktime (hr, min, sec, month, day, yr) strftime (formatstring, timestamp) strtotime (str) time () PHP Regular Expres­sions Functions ereg (pattern, str) split (pattern, str) ereg_replace (pattern, replace, str) preg_grep (pattern, arr) preg_match (pattern, str) preg_match_all (pattern, str, arr) preg_replace (pattern, replace, str) preg_split (pattern, str) Regular Expres­sions Syntax regex meaning ^ Start of string $ End of string .

How to get currently running applications in android ?

Use this code in your app’s `src/MainActivity.kt’ file. import android.app.ActivityManager import android.app.ActivityManager.RunningTaskInfo import android.content.Context import android.os.Bundle import android.widget.TextView import androidx.appcompat.app.AppCompatActivity import java.util.* class MainActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) title = "KotlinApp" val textView: TextView = findViewById(R.id.textView) val activityManager = getSystemService(Context.ACTIVITY_SERVICE) as ActivityManager val recentTasks: List<RunningTaskInfo> = Objects.requireNonNull(activityManager).getRunningTasks(Int.MAX_VALUE) for (i in recentTasks.indices) { textView.text = "Application executed: ${recentTasks[i].baseActivity!!.toShortString()}ID: ${recentTasks[i].id}" } } } Make sure you have a TextView with id textView in your XML layout. All the currently running applications on your smartphone will be shown in the textview.

Should I use Swift or Objective-C to learn iOS development ?

The Swift programming language is the standard features rich language to create iOS apps, iPadOS apps and MacOS X apps. The present and the future is just Swift on Apple ecosystem. Apple is perfecting Swift every year with updates and new features and capabilities. We are now in the era of SwiftUI, you should go for Swift already. Swift itself is a robust programming language. So go for it! it is standard for hiring, learning, creating apps for Apple operating systems.

What are great ways to promote an iOS app?

I think deeply about marketing and how to reach your target audience online and offline. In this post, I’ll cover all areas of marketing and advertising your mobile application specially the iOS apps. fix a problem, give great value Your iOS application must solve a problem or fulfill a need which some users of iPhone or iPad have. describe it for the public You should consider writing a comprehensive description which normal people can understand. For example, do not say OCR but say extract text from images which non-technical people can understand. Write description that list all features of the iOS application, and its benefits in day-to-day life.

How to animate the change of background color of a view on iOS ?

Step by step guide to create background color changing with beautiful animation open Main.storyboard add a button as shown below add one @IBAction for touchUpInside of ‘Change Background’ button. Name the function as changeBackgroundClicked. use animate function of UIView to animate the change of background color. It provides us the duration and optional completion as parameters. In changeBackgroundClicked we will change the background color of the view from red to blue and vice versa. Here is the code. @IBAction func changeBackgroundClicked(_ sender: Any) { if self.view.backgroundColor == UIColor.red { UIView.animate(withDuration: 2) { self.view.backgroundColor = UIColor.

How do you animate the change of background color of a view on Android ?

The idea is to use this code snippet. ColorDrawable[] colorDrawables = { new ColorDrawable(Color.RED), new ColorDrawable(Color.BLUE), new ColorDrawable(Color.GREEN) }; TransitionDrawable transitionDrawable = new TransitionDrawable(colorDrawables); textView.setBackground(transitionDrawable); transitionDrawable.startTransition(2000); In this code snippet, we created a list of colorDrawables, then feed them to the TransitionDrawable. And now we have an animating color change, so we pass it to the setBackground to get the animating colors in the background. Got the idea ? let’s create a complete code example. use this xml code in res/layout/activity_main.xml. <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/relativeLayout" android:padding="8dp" tools:context=".MainActivity"> <Button android:id="@+id/button" android:text="Animate background color" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_above="@id/textView" android:layout_centerInParent="true" android:layout_marginBottom="15dp"/> <TextView android:id="@+id/textView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="36sp" android:textStyle="bold" android:text="Changing Background color of this view.

How to change background color of selected item in listview in android ?

The main idea is to use view.setBackgroundColor(getColor(R.color.colorAccent)) to the selected view (list item). Let’s see a complete example. use this xml code in res/layout/activity_main.xml. <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:padding="8dp" tools:context=".MainActivity"> <ListView android:id="@+id/listView" android:layout_width="match_parent" android:layout_height="match_parent" /> </RelativeLayout> use this Kotlin code in src/MainActivity.kt. import android.os.Build import androidx.appcompat.app.AppCompatActivity import android.os.Bundle import android.widget.ArrayAdapter import android.widget.ListView class MainActivity : AppCompatActivity() { var operatingSystem: Array<String> = arrayOf("Android", "IPhone", "WindowsMobile", "Blackberry", "WebOS", "Ubuntu", "Windows7", "Max OS X") override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) title = "KotlinApp" val listView: ListView = findViewById(R.id.listView) val adapter = ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, operatingSystem) listView.

How to Change Listview Item Color in Android

The idea is to create an a list item xml, and give it the design choices you want. If you want to change the list item color, use this xml code android:textColor="@android:color/holo_orange_dark". If you want to change the text to italic or bold, use this xml android:textStyle="italic|bold". And even if you want to change the font itself, you can by this font-family property in xml android:fontFamily="sans-serif-condensed". Now, you got the idea. Let’s build a sample application to illustrate this more practically. create Android app in Android Studio use this XML as a res/layout/activity_main.xml. <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <TextView android:id="@+id/textView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:fontFamily="sans-serif-condensed" android:textColor="@android:color/holo_orange_dark" android:textSize="24sp" android:textStyle="italic|bold" /> </LinearLayout> use this Kotlin code in your src/MainActivity.

Fix Login Loop Ubuntu Linux

If you stuck in the login screen and can’t load the Ubuntu desktop, follow those steps. when you on the login screen, press ctrl + shift + alt + f1. A black screen appeared? No? Just the login page? So try ctrl + shift + alt + f2. Still the login screen? try ctrl + shift + alt + f3. If the login screen still showing? Try to use another external keyboard. a black screen appeared? ok, type your username then ENTER and type your password then ENTER. type ping 8.8.8.8 then ENTER to ensure you have a good Internet connection.

[FIXED] I Can Not Create Database in PhpMyAdmin on my website

When I try to create database in phpMyAdmin. This error show up access denied for user 'user'@'localhost' to database 'db'. and there is no buttons to create database in phpMyAdmin page. On CPanel, we can’t create database in phpMyAdmin directly so security reasons. So the fix is to create MySQL database via CPanel not in phpMyAdmin. So, when using CPanel we create Database using Database Wizard as you see in this video. The steps is simple. just open CPanel on your host, and select MySQL Database Wizard, then write the name of database. And create a database user with password, and give all the privileges to that user.