Posts with the tag how to:

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.

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 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 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.

How To Disable WordPress Plugins In CPanel ?

How to disable WordPress plugins from CPanel in hosting company because I can not login to the WordPress admin dashboard ? Here is a step by step guide: open file manager on your host. open public_html then wp-content then plugins, you’ll see all plugins listed as folders / directories. click on any plugin to rename it. just change the name a little bit to disable it. just add -bak or anything to disable the plugin. If you can’t rename it, just right click on a plugin folder and select rename from the dropdown menu. Congratulations! You disabled a plugin from CPanel successfully.

[Solved] Parse Error : Syntax Error in wp-include/functions.php

I faced this error parse error : syntax error, unexpected "." , expecting "&" or variable (T_VARIABLE) in wp-include/functions.php on line 1081. This error is because there is two PHP versions loaded on the modules. So we should comment out one of them. So I commented out the php5 module. And everything worked fine. First step, edit the httpd.conf file using this command. sudo nano /etc/apache2/httpd.conf Then add a # in front of the php5 module (or one of the two versions of PHP you have). Make sure that one PHP version is enabled. Then save the file, and restart apache server using this command.

How to fix dyld: Library not loaded: /usr/local/opt/ icu4c/lib/ libicui18n.60.dylib ?

Use [Homebrew] to uninstall node and icu4c like this. brew uninstall --ignore-dependencies node icu4c Then install node.js like this. brew install node If the problem persists and the error kept occuring, try running this command. brew link --overwrite node If the issue resists again, try upgrading node instead of reinstalling it. So use this command: brew upgrade node Want to watch how to fix it in a video ? watch it here on YouTube. If one of those works for you, share this post with your friends.

How to Inspect Hover Element in Chrome Dev Tools ?

If the hover effect is given with CSS then yes, I normally use two options to get this: The Tricky Way To See Inspect Hover One, to see the hover effect when the mouse leave the hover area: Open the inspector in docked window and increase the width until reach your HTML element, then right click and the popup menu must be over the inspector zone… then when you move the mouse over the inspector view, the hover effect keep activated in the document. The Best Way (IMO) To See Inspect Hover in Chrome Dev Tools Two, to keep the hover effect even if the mouse is not over the HTML element, open the inspector, go to Styles TAB and click in the upper right icon that says Toggle Element State (dotted rectangle with an arrow) There you can manually activate the Hover Event (among others) with the checkbox provided.

How to Calculate Age in Microsoft Excel

In the cell of age, write this =INT((TODAY()-B2)/365) where B2 is the location of the cell where the date of birth written. This code just caclulate the number of years passed. So you know the age of this person in years. But what if I want to know the months and days too ? To get the age in years, use =DATEDIFF(dateOfBirth, TODAY(), "Y") and replace dateOfBirth by the location of the cell where the birthday are written. To get the age in months, use =DATEDIFF(B2, TODAY(), "YM") where B2 is the cell where the birth date written. To get the age in days, use =DATEDIFF(B2, TODAY(), "MD") where B2 is the date of birth.

How to Use Systemd to Keep Programs Running ?

Systemd manages these services in unit files like this. [Unit] Description=Some Really Important Service [Service] Type=simple WorkingDirectory=/root ExecStart=/root/my_program.sh [Install] WantedBy=multi-user.target The program that will start is. #!/usr/bin/env bash while true; do echo 'service is working' sleep 3 done If you don’t want to use this line #!/usr/bin/env bash, then you should make sure to specify what is the program is dedicated to execute the script like this. ExecStart=/bin/bash /root/my_program.sh If you want to execute this service, you should store it in /etc/systemd/system/. You can copy the unit file to that directory, or symlink it. Now you can start or stop or enable or disable the service.

How to Master a New Technology ?

Here are 4 steps to master any new technology. Quick Start Guide Go to the official website of the new language, or framework. And find the quick start, or starter guide, or language tour, or framework tour, and play / do it. It gives you the necessary minimum knowledge of that new technology. The ultimate reason to do this get started is that it rarely outdated because it is the official beginner guide. So follow that get started or language tour. Videos Look for videos of tutorials or a whole course. Follow a crash course or a full course. Book or Documentation Pick a book that tells you everything about that technology.

All Javascript Optimization Tips & Techniques

Parsing Objects in Javascript if you are using object like this. const data = {foo: 42, bar: 1337, ... }; use the JSON.parse() instead const data = JSON.parse('{"foo":42,"bar":1337, ... }'); It seems slower, but in the real world IT IS WAY WAY FASTER. Why is it faster? because JSON.parse() has one token (Javascript object literal), but the string literal has too many tokens. want to know more ? watch this video from Google chrome developers YouTube channel. If you want the benchmark results, see it here. Use requestAnimationFrame for visual changes When visual changes are happening on screen you want to do your work at the right time for the browser, which is right at the start of the frame.

How to Install Gnome Shell Extensions from ZIP File using command line

First check your gnome version: $ gnome-shell --version GNOME shell 3.36.4 Then go to location where your downloaded ZIP file, for me its Downloads directory. cd ~/Downloads/ Get the extension UUID from metadata.json by this command. $ unzip -c dash-to-dock-micxgx.gmail.com.v68.shell-extension.zip metadata.json | grep uuid | cut -d \" -f4 dash-to-dock@micxgx.gmail.com Or simply open metadata.json file and copy the UUID value. For me it is dash-to-dock@micxgx.gmail.com. Create destination directory for the gnome extension. $ mkdir -p ~/.local/share/gnome-shell/extensions/dash-to-dock@micxgx.gmail.com Unzip gnome extension file into the directory we made in the previous step, using this command. $ unzip -q dash-to-dock-micxgx.gmail.com.v68.shell-extension.zip -d ~/.