The “tr” command in Linux can be used to translate or remove a character from the standard input, with the results shown in the standard output. We can complete several operations with the “tr” command. It gives us access to several flags including “-c”, “-d”, “-s”, and others. This command allows us to delete the characters, remove the digits from lines, and change the lowercase to uppercase letters, among many other operations. We will use the tr command and a few of its flags as examples in this article.

Using the Linux “Tr” Command

The tr function can be used to carry out tasks including getting rid of redundant characters, changing the haber letters to lower letters, and replacing and getting rid of simple character. It is frequently combined with other commands via piping.

In this section, we utilize the Linux “tr” command to replace the characters. Let’s begin putting the command into action on Linux. First, we open the terminal. Then, we use the “echo” command to accomplish this. To display the lines of text or characters that are passed as command-line parameters, use the echo function. The most frequently used function in the shell scripts on Linux is this one. We start with the “echo” keyword then type the statement that we want to use inside the inverted comma which is “you are the best” followed by the bar “|”, the “tr” keyword, the letter that we want to replace, “e,” and the letter “s” which is the character that appears in that location where “e” is used in the echo sentence.

omar@omar-VirtualBox :~$ echo “you are the best” | tr e s

When we run this command, the terminal window displays the output which is the echo statement where the character “e” is replaced with the character “s”. The result is “you ars the bsst”.

Converting the Lowercase Characters to Uppercase Characters

In this section, we’ll show you how to change the lowercase letters into uppercase letters using one of two methods: either we may provide the character range or we can specify the interpreted sequences to change the characters. The lowercase characters go in the [:lower] sequence, while the uppercase characters go in the [:upper:] sequence. Now that the command is created, it is put into action using the “echo” statement first and then changing the lower characters to upper characters. The fruit names that are included in the echo statement are “Apple”, “Mango”, “Plátano”, and “Grapes”.

As you can see, the first character in each of these elements is uppercase, while the remaining characters are lowercase. To change the remaining characters to uppercase, we use the “tr” command in which we specify the character range as “[a-z]” and “[A-Z]” where the first specifies the range of the alphabet using the lower characters, and the second specifies it using the upper characters. This essentially indicates that all lowercase characters from “a” to “z” in the echo statement are changed to uppercase.

omar@omar-VirtualBox:~$ echo “Apple” “Mango” “Plátano” “Grapes” | tr [a-z] [A-Z]

Now that the command is executed, you can see that the lowercase characters are changed to uppercase characters in the following output:

APPLE MANGO BANANA GRAPES

Now, in the following section, we’ll utilize a different technique to change the lower case to upper case using the “tr” command with the “[:lower]” and “[:upper:]” terms. To accomplish this, we use the same echo statement and then type “tr” followed by the “[:lower:]” and “[:upper:]” keywords. Using “lower” first and then “upper” means that all of the lowercase letters in the echo statement are changed to uppercase.

omar@omar-VirtualBox:~$ echo “Apple” “Mango” “Plátano” “Grapes” | tr [:lower:] [:upper:]

When we execute this command, it produces the same results as the previous one:

APPLE MANGO BANANA GRAPES

Removing Specific Characters

In this section, we’ll use the “-d” option of the “tr” command to remove a specific character from the echo statement. Using a specific character in the “tr” command with the “-d” parameter, we can delete that character from the line or the file.

Let’s remove the character using the command on the terminal. First, we use the “My name is Alex” echo statement followed by the bar “|”. After which, we write “tr” followed by the “-d” flag to delete the character. Finally, we provide the character that we want to remove from the statement which is “e” in the inverted comma.

omar@omar-VirtualBox:~$ echo “My name is Alex” | tr -d ‘e’

When we run this command, the “e” character is removed from the line and the text is changed to “My name is Alx”.

Deleting Digits

Using the “tr” command, “-d” option, and the “[:digit:]” expression, we may additionally delete all the digits in a line or file. The word “digit” must be enclosed in square brackets and a colon. Let’s begin using the “Alex got 98% marks” echo statement followed by the “|” bar, “tr”, the “-d” option, and the “[:digit:]” keyword. This deletes all the digits that are present in the echo statement since there are two digits in the “98” echo statement which means that both of these digits are removed from the line when we run this command:

omar@omar-VirtualBox:~$ echo “Alex got 98% marks” | tr -d [:digit:]

Following the execution of this command, the “Alex got% marks” echo statement is displayed in the output. As you can see, both digits are deleted from the line, keeping only the characters and the “%” symbol that we used in the line.

Eliminating Newline Characters

In this section, we remove the file’s newline character. On the desktop, there is a file called “file.txt” that holds some information. First, we use the cat command to open the file on the terminal. To use this command, type “cat” followed by the file’s name, “file.txt.” The file opens on the terminal when we execute this command:

omar@omar-VirtualBox:~/Desktop$ cat file.txt

When the command is executed, a file which contains several names is opened. Each name is written on a separate line. Now, we display the entire name on a single line by deleting the newline character.

We type the following command on the terminal. First, we type “cat”. Then, we use the “file.txt” file name. Then, we use bar “|”. After that, we type the “tr” command. Then, we use the “-s” option which is used to convert the newline characters into spaces. Lastly, the “n” inside of the inverted commas is used. This converts the newline characters into spaces and displays all of the lines in a single line.

omar@omar-VirtualBox:~/Desktop$ cat file.txt | tr –s ‘n’ ‘ ‘

The output of the command is “Alex”, “Jhon”, “Watson”, and “David”. When the command is performed, it prints the file’s lines on a single line which is separated by spaces. The newline characters are deleted and changed into spaces.

Conclusion

This article looked at the “tr” command in Linux which can be used for a variety of tasks. The “tr” command can be used with a variety of flags such as “-s”, “-d”, and others. In the aforementioned article, we utilized the numerous instances of the “tr” command in which we substituted the characters, deleted the characters, removed the digits, and also removed the newline characters from the files and changed them to spaces before displaying the entire text of the lines in a single line.



Source link


Mouse Cursor ghosting is a more common problem in slow-screen monitors, such as monitors of 60 HZ. This problem can also occur due to multiple issues, such as the refreshing rate of the screen, mouse pointer settings, or mouse trial settings. In mouse ghosting problems, mouse lagging occurs, multiple pointers are displayed on the screen or unexpectedly high speed of the mouse.

This blog will demonstrate how to fix the mouse cursor ghosting problem.

How to Fix Mouse Cursor Ghosting Problem?

If the mouse pointer lags on the screen or moves unexpectedly fast, it means there is some issue with your mouse. To resolve the mouse cursor ghosting behavior, we have listed down some solutions:

Solution 1: Disable Mouse Pointer Trial Settings

In order to disable the mouse pointer trial setting to resolve the problem, go through the listed instructions.

Step 1: Open Control Panel App

First, launch the Windows Control Panel application from the Start menu:

Step 2: Open Hardware and Sound Settings

From the “Control Panel” Window, navigate to the “Hardware and Sound” settings:

Step 3: Navigate to the Mouse Settings

After that, under the “Devices and Printers” settings, click on the below highlighted “Mouse” option to open the Mouse properties:

Step 4: Disable Pointer Trial

Next, visit the “Pointer Options” menu, and unchecked the “Display pointer trial” checkbox to resolve the mouse cursor ghosting error. After that, hit the “OK” button:

Additionally, users can also set the pointer speed from the below highlighted “Select a pointer speed” settings:

Solution 2: Update Mouse Drivers

Another possible way to resolve the mouse cursor ghosting problem is to update the mouse drivers. For this purpose, check out the provided procedure.

Step 1: Launch Device Manager

First, launch the “Device Manager” app from the Window “Startup” menu:

Step 2: Update Mouse Drivers

Next, click on the “Mice and other pointer devices” drop menu. Select and right-click the mouse driver. After that, click on the update driver option from the appeared context menu to update drivers:

Next, choose the below-highlighted option to search and update the driver automatically from online resources:

After updating the driver, click on the “Close” button to close the screen and check if the mouse cursor ghosting problem has been resolved or not:

Note: If the above-stated solution does not resolve the problem, try to clean and restart the system.

Conclusion

Mouse cursor ghosting is a problem that occurs on 60 HZ screens. In mouse ghosting problems, mouse lagging occurs, or multiple pointers are displayed on the screen. To resolve it, update the mouse drivers or disable the mouse display trails from Mouse properties. This write-up has elaborated on how to fix the mouse ghosting problem.



Source link


In Python, a data structure called a dictionary is used to store information as key-value pairs. Dictionary objects are optimized to extract data/values when the key or keys are known. To efficiently find values using the related index, we can convert a pandas series or dataframe with a relevant index into a dictionary object with “index: value” key-value pairs. To achieve this task, the “to_dict()” method can be used. This function is a built-in function found in the pandas module’s Series class.

A DataFrame is converted into a python list-like data dictionary of series using the pandas.to_dict() method depending on the specified value of the orient parameter.”

We will use the to_dict() method in Pandas. We can orient the returned dictionary’s key-value pairs in a variety of ways using the to_dict() function. The function’s syntax is as follows:

Syntax:

 

pandas.DataFrame_object.to_dict(orient = “dict”, into=)

 

Parameters:

    1. orient: Which datatype to convert columns (series into) is specified by the string value (“dict”, “list”, “records”, “index”, “series”, “split”). For instance, the keyword “list” would give a python dictionary of list objects with the keys “Column name” and “List” (converted series) as output.
    2. into: class can be passed as an instance or contemporáneo class. For instance, a class instance can be passed in the case of a default dict. The parameter’s default value is dict.

Return Type:

Dictionary converted from a dataframe or series.

Data:

In all the examples, we will use the following DataFrame named “remarks” that hold 2 rows and 4 columns. Here the column labels are – [‘id’,’name’,’status’,’fee’].

import pandas  

# Create the dataframe using lists
remarks = pandas.DataFrame([[23,‘sravan’,‘pass’,1000],
                             [21,‘sravan’,‘fail’,400],
                             ],columns=[‘id’,‘name’,‘status’,‘fee’])

# Display the DataFrame – remarks
print(remarks)

 

Output:

 

   id    name status   fee
0  23  sravan   pass  1000
1  21  sravan   fail   400

 

Example 1: to_dict() with No Parameters

We will convert the remarks DataFrame to a dictionary without passing any parameters to the to_dict() method.

import pandas

# Create the dataframe using lists
remarks = pandas.DataFrame([[23,‘sravan’,‘pass’,1000],
                             [21,‘sravan’,‘fail’,400],
                             ],columns=[‘id’,‘name’,‘status’,‘fee’])

# Convert to Dictionary
print(remarks.to_dict())

 

Output:

 

{‘id’: {0: 23, 1: 21}, ‘name’: {0: ‘sravan’, 1: ‘sravan’}, ‘status’: {0: ‘pass’, 1: ‘fail’}, ‘fee’: {0: 1000, 1: 400}}

 

Explanation

The DataFrame is converted to a Dictionary.

Here, the columns in the llamativo DataFrame were converted as Keys in a dictionary and each column will store two values again in a dictionary format. The keys for these values start from 0.

Example 2: to_dict() with ‘series’

We will convert the remarks DataFrame to a dictionary in Series format by passing the ‘series’ parameter to the to_dict() method.

Format:

import pandas

# Create the dataframe using lists
remarks = pandas.DataFrame([[23,‘sravan’,‘pass’,1000],
                             [21,‘sravan’,‘fail’,400],
                             ],columns=[‘id’,‘name’,‘status’,‘fee’])

# Convert to Dictionary with series of values
print(remarks.to_dict(‘series’))

 

Output:

 

{‘id’: 0    23
1    21
Name: id, dtype: int64, ‘name’: 0    sravan
1    sravan
Name: name, dtype: object, ‘status’: 0    pass
1    fail
Name: status, dtype: object, ‘fee’: 0    1000
1     400
Name: fee, dtype: int64}

 

Explanation

The DataFrame is converted to a Dictionary with ‘series’ format.

Here, the columns in the llamativo DataFrame were converted as Keys in a dictionary and each column will store rows along with the data type of the column. The data type of ‘id’ column is int64 and other two columns are ‘object’.

Example 3: to_dict() with ‘split’

If you want to separate row labels, column labels and values in the converted Dictionary, then you can use the ‘split’ parameter. Here, ‘index’ key will store a list of index labels. ‘Columns’ key will hold a list of column names and data is a nested list that stores each row values in a list separated by a comma.

Format:

import pandas

# Create the dataframe using lists
remarks = pandas.DataFrame([[23,‘sravan’,‘pass’,1000],
                             [21,‘sravan’,‘fail’,400],
                             ],columns=[‘id’,‘name’,‘status’,‘fee’])

# Convert to Dictionary without index and header
print(remarks.to_dict(‘split’))

 

Output:

 

{‘index’: [0, 1], ‘columns’: [‘id’, ‘name’, ‘status’, ‘fee’], ‘data’: [[23, ‘sravan’, ‘pass’, 1000], [21, ‘sravan’, ‘fail’, 400]]}

 

Explanation

We can see that two indices were stored in a list as a value to the key – ‘index’. Similarly, column names are also stored in a list as a value to the key – ‘columns’ and each row is stored as a list in a nested list to the ‘data’.

Example 4: to_dict() with ‘record’

If you convert your DataFrame to a Dictionary with each row as a Dictionary in a list, you can use the record parameter in the to_dict() method. Here, each row is placed in a dictionary such that the key will be the column name and value is the contemporáneo value in the pandas DataFrame. All rows were stored in a list.

Format:

import pandas

# Create the dataframe using lists
remarks = pandas.DataFrame([[23,‘sravan’,‘pass’,1000],
                             [21,‘sravan’,‘fail’,400],
                             ],columns=[‘id’,‘name’,‘status’,‘fee’])

# Convert to Dictionary by record
print(remarks.to_dict(‘record’))

 

Output:

 

[{‘id’: 23, ‘name’: ‘sravan’, ‘status’: ‘pass’, ‘fee’: 1000}, {‘id’: 21, ‘name’: ‘sravan’, ‘status’: ‘fail’, ‘fee’: 400}]

 

Example 5: to_dict() with ‘index’

Here, each row is placed in a dictionary as a value to the key starts from 0. All rows were stored again in a dictionary.

Format:

import pandas

# Create the dataframe using lists
remarks = pandas.DataFrame([[23,‘sravan’,‘pass’,1000],
                             [21,‘sravan’,‘fail’,400],
                             ],columns=[‘id’,‘name’,‘status’,‘fee’])

# Convert to Dictionary with index
print(remarks.to_dict(‘index’))

 

Output:

 

[{0: {‘id’: 23, ‘name’: ‘sravan’, ‘status’: ‘pass’, ‘fee’: 1000}, 1: {‘id’: 21, ‘name’: ‘sravan’, ‘status’: ‘fail’, ‘fee’: 400}}

 

Example 6: OrderedDict()

Let us utilize the ‘into’ parameter that will take OrderedDict, which converts the pandas DataFrame into an Ordered dictionary.

import pandas
from collections import *

# Create the dataframe using lists
remarks = pandas.DataFrame([[23,‘sravan’,‘pass’,1000],
                             [21,‘sravan’,‘fail’,400],
                             ],columns=[‘id’,‘name’,‘status’,‘fee’])

# Convert to OrderedDict
print(remarks.to_dict(into=OrderedDict))

 

Output:

 

OrderedDict([(‘id’, OrderedDict([(0, 23), (1, 21)])), (‘name’, OrderedDict([(0, ‘sravan’), (1, ‘sravan’)])), (‘status’, OrderedDict([(0, ‘pass’), (1, ‘fail’)])), (‘fee’, OrderedDict([(0, 1000), (1, 400)]))])

 

Conclusion

We have discussed how we can convert the dataframe or pandas objects into a python dictionary. We have seen the syntax of the to_dict() function to understand the parameters of this function and how you can modify the function’s output by specifying the function with different parameters. In the examples of this tutorial, we have used the to_dict() method, an inbuilt pandas function, to change the pandas objects to the python dictionary.



Source link


Bash is a command interpreter and script. Like other forms of coding, it supports packet forwarding, variables, and functions. A script is a file with commands that the software may view and perform. In Linux, bash gives us positional parameters like “$0,” “$1,” “$2,” “$3,” etc. In this article, one of its positional parameters, “$0,” will be used.

Example # 1: Using $0 in a Bash Script

The name of the terminal or shelled script is expanded using “$0”. At shell initialization, this is set. $0 is assigned to the name of that directory if Bash is called with a collection of commands. To put it simply, we utilize “$0” in bash to store the name of the script and display it in the terminal. The parameters for the bash command on Linux are “$0,” “$1,” and “$2, etc. The first one stores the name of the script, the second one stores the first value, and so on.

Now, in this section, we will use the “echo” command to display the name of the bash shell. To do this, we must execute the command on the terminal, but first, we must create a bash file. Since one already exists and is located on the desktop, we will utilize it in this article. Its name is “code.sh.”

To print the name of the script on the terminal when we open this file, we must first add the shell, which is “#!/bin/bash,”. In the next line, we must pass the parameter “$0” within the echo command because the file name is stored in this parameter.

We will now execute the command by first entering the term “bash” and then the name of the script, “code.sh.”

Linux@linux:~/Desktop$ bash code.sh

As shown in the screenshot below, when we run this command, the name of the script, “code.sh,” is displayed.

The “$0” option in bash will now be used in the following section to display the current name of the script together with the statement. To accomplish this, we will create a script in which, after adding the shell as described above, we use the “echo” command to print the statement, “The name of the file is:.” The statement that we wish to print needs to be typed with an inverted comma before we pass the “$0” variable, which stores the script name.

#!/bin/bash

echo “The name of the file is :” $0

The command that we will now use is “bash,” followed by the name of the script, “code.sh”. When we execute this command, the input string and the script name, which is saved in “$0,” will both be displayed.

Linux@linux:~/Desktop$ bash code.sh

You can now see in the image below that the file name for the script, “code.sh,” is displayed along with the echo statement, “The name of the file is”.

Example # 2: Displaying the Script’s Name at the End by Using Bash’s “$0”.

Now, in this section, we are going to use “$0” in the script’s end section, which will display the name of the bash file at the end. For this, we are going to construct a script in which we first use the bash shell, which is “#!bin/bash,” and then we initialize the variables “x,” “y,” and “z,” assigning values to each of them “6” for “x”, “4” for “y” and “9” for “z”. Then we will use the echo command to print these values in the following. To do this, we pass the “$” parameter along with the variables that contain the numbers, so we use “$x,” “$y,” and “$z.” This will display the values in the terminal when the bash file is opened using the command in the terminal.

Then, in the following line, we merienda more use the “echo” command to print the statement and the script’s name using the argument “$0.” Since the script’s name is stored in the file, the statement we need to print is “The name of the file is:” and we do this by passing “$0” as an argument.

#!/bin/bash

X=6

Y=4

Z=9

echo$x” “$y” “Sz”

echo “The name of the file is :” $0

The command to open the script output in the terminal is now used.

Linux@linux:~/Desktop$ bash code.sh

Now that this command has been executed, you can see in the image below that it first displayed the values “6”, “4”, and “9” before displaying the statement “The name of the file is” and the file name “code.sh” in the line that follows.

Example # 3: Using $0 in the Bash Function

In this section, we will use the bash function to subtract two numbers and print the name of the relevant bash file by placing a “$0” inside the function body. To do this, we will develop a script in which we create a function called “func()”. Because it is a user-defined procedure, we are free to choose its name. Then, in the following line, we use curly brackets to form the function’s body. Within these brackets, we use the variable “sub,” in which we store the subtraction of two numbers by using the “$” parameter.

Next, we use double-round-brackets. Within these brackets, we perform the subtraction of two numbers. Therefore, we use “$1-$2”.  The number we specify when invoking the function “func” will be stored in its “$1” and “$2” parameter values. Next, we use the echo command to print the statement and the answer by using the variable “sub” with the argument “$.” Because the result of subtraction is stored in this.

Next, we use the echo command to print the statement and the name of the script by using “$0” the statement is “The name of the script is,” and we pass the argument “$0. Then, in the following line, we call the function by using its name, “func,” and supply two numbers as arguments, “50” and “30,” which will be stored in “$1” and “$2,” before performing the subtraction operation.

#!/bin/bash

func()

{

Sub=$ ( ( $1$2 ) )

echo “The answer is : $sub

echo “The name of the script is:” $0

}

func 50 30

To display the result in the terminal, we will now use the same command as in the previous section.

Linux@linux:~/Desktop$ bash code.sh

Now, it displayed the result of subtracting the given numbers, which is “20,” with the statement “The answer is,” and in the following line, it displayed the statement “The name of the script is,” along with the name of the bash script, “code.sh,” which is displayed by supplying the parameter “$0” to bash.

Conclusion

This article has discussed using “$0” in Linux bash scripts. Because the file name is stored in this “$0,” we have utilized it in various cases and shown the bash script’s name in the terminal. In the first section, the script’s name is simply printed using the echo command and the “$0”. In the second section, we used “$0” to display the script’s name at the end, and in the final example, we utilized the bash function() to do a subtraction operation while also using “$0” in the function’s body.



Source link


CSS is a language for creating style sheets that describe how a document is presented in a markup language, such as HTML or XML. Along with HTML and JavaScript, CSS is a key component of the World Wide Web. Using CSS, users can style all HTML elements, including tables, buttons, input fields, forms, and many more.

This post will explain:

How to Style Input Fields With CSS?

To style the input field with CSS, try out the mentioned procedure.

Step 1: Create Input Form

First of all, create a form in HTML. To do so, follow the instructions listed below:

  • First, create a form with the help of the “<form>” tag.
  • Inside the form, the “<label>” element is defined to specify captions for the “input” elements. The label’s “for” attribute is used to attach the label element with <input> element through “id”.
  • The “type” attribute determines the input type, such as text or number.
  • The “class” attribute is assigned the “Input” name, “placeholder” attribute allocates the placeholder text in the input field:

<form>
 <label for=«entertext1» >Enter First Name</label>
 <input type=«text» class=«Input» placeholder=«Enter First Name here» /><br><br>
 <label for=«entertext2»>Enter Last Name</label>
 <input type=«number» class=«Input» placeholder=«Enter Last Name here» /><br><br>
</form>

Output

Step 2: Style Input Button in CSS

To style the input button in CSS, check out the given properties:

input{
 padding: 8px;
 border-radius: 10px;
 margin: 5px coche;
 border: 1px solid #918383;
 background-color: #87b8b8;
 box-shadow: 1px 2px 1px 2px rgb(230, 229, 229);
 color: #c9c2c2;
 outline: none;
 font-size: 18px;
}

Access the “input” class and then apply below-mentioned properties:

  • Set “padding” that specifies the space around the element’s content.
  • border-radius” property sets the element’s edges round.
  • margin” property with the value “5px coche” adds space “5px” on top and bottom, and “coche” is used to set equal space around the element on the left and right.
  • border” property specifies the border around the table.
  • background-color” property is utilized to specify the color of the background.
  • box-shadow” adds a shadow around the element. It is a shorthand property that specifies the x-offset, y-offset, blur effect, spread effect, and color for the shadow.
  • color” property refers to the element’s font color.
  • outline” adjusts the line around the elements to make it dominant.
  • font-size” property is utilized to set the element’s font size.

Output

Next, access the “label” element for styling it:

label{
 font-size: 18px;
 color: rgb(15, 15, 15);
 margin: 20px;
}

After accessing the label element, apply the styling of your choice. For instance, we have applied “font-size”, “color”, and “margin” properties.

Output

Let’s move toward the next section to style the submit button using CSS.

How to Style Submit Button With CSS?

To style the submit button with CSS, examine the example below, which demonstrates a step-wise guide on how to create and style the HTML button.

Step 1: Create Submit Button

Initially, add heading text inside the heading tag “<h2>”. Then, create a button by utilizing the “<button>” element and set the button type as “submit”:

<h2>Style button element</h2>
 <button type=submit >
 Submit
 </button>

Output

Step 2: Style “button” Element

To style the button in CSS, check out the properties described below:

button{
 padding: 12px 40px;
 border-radius: 8px;
 box-shadow: 2px 2px 2px 1px rgb(131, 131, 219) ;
 border: 1px solid gray;
 font-size: 20px;
}

Access the button element by tag name and apply the properties on the button according to your preference. For instance, we have applied “padding”, “border-radius”, “box-shadow”, “border”, and “font-size” properties.

Output

Let’s add the hover effect on the button element:

button:hover{
 background-color: cadetblue;
 color: rgb(246, 244, 248);
}

The “button:hover” selector is utilized to apply the effect of hover on the button. With the help of the “hover” selector, users can generate the CSS effect in real-time. For instance, we have set the “background-color” and “color” properties as described above:

We have discussed to style the input field and submit button with CSS.

Conclusion

To style the input element and submit button with CSS, different properties of CSS are used, including “padding”, “border-radius”, “box-shadow”, “margin”, “border”, “background-color”, “font-size” and many more. Users can apply the specified properties by accessing the elements through the tag name. This post has demonstrated the method for styling the input text fields and submit buttons with CSS.



Source link


QOwnNotes is an open-source plaintext notepad used for creating notes and comes with features like markdown and to-do-list manager. It has markdown support and a to-do list manager that works efficiently on different operating systems like Windows, macOS and Linux. With this notepad, you can easily sync your files with owncloud or nextcloud servers; thus, it’s an excellent option to access files from any device. It also has several customization options that enable users to work in the environment of their choice.

This article is a detailed guide to install the QOwnNotes on Ubuntu 22.04 system.

How to Install QOwnNotes on Ubuntu 22.04

Though there may be different approaches to install QOwnNotes on Ubuntu 22.04 system, the easiest method to install the latest version of the software is provided in the steps mentioned below:

Step 1: Add QOwnNotes Repository

To install the latest version of QOwnNotes, you must add its repository to official Ubuntu repository list through the following command:

$ sudo add-apt-repository ppa:pbek/qownnotes

 

Press Enter to allow the process to add the QOwnNotes repository.

Step 2: Update Repository

Ensure the QOwnNotes repository is successfully added to the Ubuntu repository list and you can do so by using the “update” command given below:

 

Step 3: Install QOwnNotes

If the above command generates no error, you can use the following command to install QOwnNotes latest version on the Ubuntu system.

$ sudo apt install qownnotes -y

 

Step 4: Running QOwnNotes

You can launch the QOwnNotes application on your system from the main application menu, which is highlighted below:


Search “qownnotes” and click on the application to launch it on your desktop.

Setting up QOwnNotes on Ubuntu

When you run the application for the first time, you have to follow the below-given steps to complete the QOwnNotes setup.

Step 1: Select the desired location for storing your notes as this depends entirely on your choice. Choose the desired location and then click on the “Next” button.


Step 2: Go with the Minimal panel layout option since it’s recommended for the users.


Step 3: If you want to sync your notes with a cloud server, you can choose the “Open Nextcloud/ownCloud settings”. If not, you can simply go to the next step using the “Next” button.


Step 4: Complete the QOwnNotes setup using the “Finished” button.


This will open the QOwnNotes’ Markdown Cheat sheet on the desktop as shown below:


Now at this point, QOwnNotes is successfully running on the Ubuntu system and you can begin creating your notes on it.

Removing QOwnNotes from Ubuntu 22.04

You can remove QOwnNotes completely from your system through the following command:

$ sudo apt –purge remove qownnotes -y

 

Conclusion

QOwnNotes is a powerful plain-text notepad that can be installed on Ubuntu 22.04 system from the repository method. The method requires adding the QOwnNotes repository to the system’s repository list and using the “update” command to update the system repository. Later, you can install the “apt” command on the Raspberry Pi system to install the latest version of QOwnNotes.



Source link


The “Werfault.exe” error is supposed to occur whenever an app on Windows fails to start. This error is related to the Windows error reporting service that collects the reports of errors and crashes and then sends them to Microsoft. The stated error could also take place due to the crash of the Windows error reporting service. Moreover, corrupt system files, glitches in the memory, or corrupt hard drives could be the reasons behind it.

This write-up will provide various methods to fix the stated problem.

How to Fix Werfault.exe Error in Windows?

The “Werfault.exe” error can be resolved by adopting the following approaches:

  • Restart PC
  • Run DISM scan
  • Run memory diagnostic tool
  • Perform disk cleanup
  • Restart Windows error reporting service.

Fix 1: Restart the PC

The first and easiest solution to rectify the stated problem is to reboot Windows:

  • First, press “Alt+F4” to open the “Shut Down” pop-up window.
  • Select “Restart” from the drop-down list and hit the “OK” button:

As a result, the Werfault.exe error will be resolved.

Fix 2: Run DISM Scan

DISM (Deployment Image Servicing and Management) scan is used to repair the Windows image file. Therefore, running a DISM scan can fix the stated problem.

Step 1: Launch CMD

Initially, open “Command Prompt” from the Start menu:

Step 2: Run the Scan

Execute the below “DISM” command to run the scan:

> DISM /Online /Cleanup-Image /RestoreHealth

The given command will find the corrupt and missing system files and repair them:

Fix 3: Run Memory Diagnostic Tool

Glitches in the memory disk can also be the cause of the stated BSOD error. So, run the Windows memory diagnostic tools to solve the Werfault.exe error.

Step 1: Launch Run Box

First, open “Run” via the Windows Start menu:

Step 2: Launch Windows Memory Diagnostic

Type “mdsched.exe” and hit the “OK” button:

Step 3: Run the Scan

Select “Restart now and check for problems (recommended)” from the given options:

This will restart Windows 10 and start diagnosing the errors in the memory.

Fix 4: Perform Disk Cleanup

Disk Cleanup is a utility that is used to clean system files and cache memory. Moreover, you can utilize this tool for fixing the Werfault.exe issue. For that purpose, follow the stepwise instructions.

Step 1: Launch Disk Cleanup

First, open “Run”, type “cleanmgr.exe” and hit the “OK” button:

Select “C:” driver and hit the “OK” button:

Step 3: Clean User Data

Mark the required checkboxes as shown below and hit the “OK” button:

Step 3: Clean up System Files

Click on “Clean up system files”:

Move to “More options”. Then, click on the “Clean up” in each of the “Programs and Features” and “System Restore and Shadow Copies” buttons to clean up system files:

Fix 5: Restart Windows Error Reporting Service

The Windows error reporting service is used to report software and hardware errors to the users. Maybe the error reporting service is disabled and that is why the stated error has occurred. So, restarting this service may fix the stated error.

Step 1: Launch Services

First, open “Services” from the Start menu:

Step 2: Restart the Service

  • First, look for the “Windows Error Reporting Service” and open its “Properties”.
  • Move to the “Militar” segment.
  • Set the service to launch in “Automatic” mode.
  • Click the “Start” button.
  • Finally, hit the “OK” button:

Restarting the service will repair the specified error.

Conclusion

The “Werfault.exe” error can be fixed by using various methods, which include restarting the PC, running the DISM scan, running Windows memory diagnostic tool, restarting the Windows error reporting service, or performing disk cleanup. This write-up has demonstrated several methods to resolve the mentioned error.



Source link


We can suspend the execution of the program for a set amount of time by utilizing the “sleep()” method in Python. When we create code, it runs line by line. However, if we want to pause execution for a little while, we can use the “time.sleep()” method. By using the “time.sleep()” method, we can put the thread to sleep. To put it simply, the “sleep()” function stops the current thread from operating for a predetermined amount of time.

Example 1: Utilizing Simple Code to Implement the Sleep() Method in Python.

In this example, we’ll use Python’s “sleep()” function to implement a code. The Python “sleep()” technique is always essential when we wish to suspend the current thread’s operation or for a certain amount of time. Python’s “time” module provides several essential applications to perform time-related operations. The “sleep()” function is among the more well-known ones. Any time a thread is mentioned, the “sleep()” function will halt its operation. The actual suspension time can be less than that specified because every captured signal will end the sleep() after its catching function has been executed.

Let’s now begin to execute the code. First, we must import the “time” module. Then, in the next line, we call the “print()” function. The “print()” function outputs the statement to the natural output device, such as the screen. The following statement will be passed to the “print()” function’s parenthesis “This phrase immediately prints: Python is the simplest programming language”.

Now, after printing this statement after importing the time module, we must print it immediately when the code is executed. Or, to put it simply, this statement prints as in regular times as the other programs print their output. Now, the next time we use “time.sleep(),” we pass the seconds as its parameter, which is “5”,. We again call the “print()” function. We are passing the statement we want to appear on the screen after five seconds in the print function’s parentheses. This statement is “This statement prints after five seconds: I love coding”.

When we execute the code, the first statement is displayed right away but the second statement is displayed after “5” seconds since we put the time “5” seconds” in the parentheses of the “sleep()” function. Here, time is the library, and we call this “sleep()” function using the module.

When we pressed the run button, the output showed this statement right away because we didn’t set a timer for it. As a result, it printed immediately, just like other programs do when we print their output.

The second statement is now shown, as seen in the figure. This statement suspends execution for “5” seconds and is displayed after that time because the time parameter for the “sleep()” function was set to “5” seconds.

Example 2: Utilizing the “sleep()” Function in Python to Generate a Gigital Clock.

In this example, we’ll use the “time.sleep()” function to make a digital clock, which we’ll show in the output. First, we import the Python time package as “t” and compute the time inside an endless while loop. In a while loop in Python, a block of code is iterated over while the iteration cycle condition is true. We typically use this loop when we are unclear about how many times to iterate. While a succession of claims is made an undefined number of times while being true. This type of loop starts working when a specific condition is True and doesn’t stop until the condition is False. Then, in the following line, we use the method “localtime()” which converts the number of seconds into particular time using the time module “t”. If seconds are not provided or if None, the contemporáneo time as returned by time() is used. We added the initialized variable “localtime” with the value “t.localtime()”.

Now in the next line, we call “strftime()” with the “t” and set the time in its parenthesis (%I:%M:%S%P), and pass the variable “localtime” as well. Then, in the following line, we used the “sleep()” function with the module “t” and set the time to “2” seconds in its parentheses.

As a result, the current time will now be printed in the output display. But because we set the time to “2” seconds, the program will first wait for 2 seconds before computing and printing the current time again.

Now that “2” seconds have been set inside the “sleep()” method, the output shows a digital clock with the current time and suspends execution for two seconds before printing the next time. The order of time is “hour/minutes/second/AM” so the current time that the digital clock displayed initially is “08:29:43:AM” and the next time it displayed, it did so after two seconds. So, you can see that the seconds have changed the previous one was “43” and the following one was “45” similarly, it continues.

Example 3: Using Python time.sleep() in Multithreading

The “time.sleep()” function will be used in this example to demonstrate multithreading. The examples above used single threading, whereas this example used two threads. Let’s begin by importing two libraries. The first is called “threading” and the second is called “time”. Then, we define the function “print k” in the following line. In this example, we first create a function, which is a user define function. Then, on the second sequence, we set the range to “for m in range(3)” and then we use “time.sleep(),” and pass the statement “I love coding” inside the parentheses.

Subsequently, we invoke the “print()” function and pass the statement “I love coding” which means that this statement will print three times in the output displays. For “1” second, this thread pauses the execution. Afterward, we create a second function called “print l” and set its range to “3” before calling the “time.sleep()” function and passing the value “1.5” second. After that, we call the “print()” function and pass the statement “I love Python” to complete the same process, which will print this statement three times while taking a moment execution for “1.5” seconds.

Furthermore, we create the variables “t1” and “t2” and use “threading.thread” to call the respective functions. Then, in the following line, we utilize “t1.start()” and “t2.start()”. To start the thread’s activity, the start() method of the thread must be invoked after the thread object has been created. This invokes the execute() method and starts a new control thread. A thread is considered “active” when something happens in it.

The first time the system reads, it takes more time to read the function and displays the statements sparingly. However, the second time, the same statement is written twice since the data is saved in the system’s memory and therefore takes less time to access. You can now see in the output that both statements were printed three times because we set ranges three times.

Conclusion

In this article, we covered both single-threaded and multi-threaded uses of the Python function “time.sleep()”. In the first two cases, we delayed the execution for a predetermined period using the single-threaded “sleep()” function. In the third example, we used two threads to suspend execution for a predetermined period. To choose how frequently we want to publish the function statement, we also define the range of the statements. The purpose of this article is to help you manage tasks utilizing Python thread sleep.



Source link


Python is a well-known high-performance level programming language that allows various engineering, technical, object-oriented, and mathematical functions, and operations. Python provides numerous libraries for its users and one of the most renowned and open-source programming languages is “Scipy”. Scipy library contains information and applies its operations to different machine learning methods e.g., machine learning algorithms and the optimizers that we use in artificially intelligent systems. We use a module chi-square from the Scipy library to take out the various test for the categorical data.

Procedure

In the article, we will use the chi-square function from the scipy library and will take out several tests for the data. The information regarding the use of this function in python script will also be discussed and applied to various examples in this article.

Syntax

Since we will be carrying out the two tests to check for the relation between the variables using the chi-square method, we will discuss the two different syntaxes for this function.

Chi square Test -> $ chisquare(f_obs, ddof=1, f_exp=None, axis=1)

Chi square Independence Test -> $ chi2_contingency(observed, lambda_= None correction=False)

Return Value

This function returns the p-value and the chi square test statistic value in its output.

Example # 01

We will conduct the first test using the chi square that we have discussed in the syntax as the chi_square test. This test tells us about the relationship between the categorical variables. This function uses the attribute “stats” module from the scipy. Stats compute the test where we have to assume a null hypothesis and the chi square tests this null hypothesis whether or not the data contains the specified frequencies. It takes the observed and the expected frequencies as its parameters and if these two frequencies are less than or not at least “five” then the test is considered invalid.

We will execute the same test in the example, the compiler that we will be using to implement the example is” Google Collab” which serves as an open-source compiler. It runs the program without any installments of the library packages since it already has the installed packages in it. After opening the compiler, simply create a project with a unique name and then move to the next step where we will import the library packages to run the chi square test.

The chi square test is given in the python scipy stats module so we will import the “stats” from the scipy into our project. Merienda we have imported this library, we will define an array having the elements as the frequencies at least greater or equal to five. So, we are going to define the array with the name “array” with the observed frequencies as “ [ 3, 4, 6, 8, 10, 2] “. After successfully creating this array, we will call the chi square function with the prefix “stats” as “stats. chisquare ()”. To the input argument of this function, we will pass the array which is the f_obs ( observed frequency) the parameter of the chi square function.

After running the code mentioned in the snippet below, we will get the output as the chi square statistic and the p-value. This chisquare test will be valid since we have defined at least five observed frequencies in the parameter of this function.

from scipy import stats
array= [3,4,8,10,12]
stats.chisquare(array)

Example # 02

The chi square function has another test for the categorical variables with the name the “ chi_square test for the Independence “. Now, this test is slightly different from the chi-square test that we have discussed in the example above since this test checks out if there exists any significant relationship between the two variables of the categorical class. For this test, chi_square uses the stats module’s function “chisquare contingency” from the python scipy. The test is conducted to show whether the variables are independent of each other or not. To work with this function, let’s create another new array. To create and define this new array, we will have to import the numpy with the name “np” so that we can call the “np” in the code later in place of the numpy.

Another important library package that needs to get imported for the proper working of the chi square contingency test is the “stats”. We will import the stats module from the scipy library from the python language. With the successful import of the required libraries for the project or the chi square independence test, in the next step, we will define an array with the name “obs_array”. We will use “np. array ()” method to create this array and the dimensions of the array will be set to 2-dimensional and the elements that this array will contain will be as “([2, 2, 2],[8, 8, 8])”. This array will be used as the observation which is the input parameter for the chi_2 contingency () function.

To call the contingency test for the independence of the two variables belonging to the categorical classes, we will use the prefix stats and will call the function chi_2contingency as “stats.chi2_contingency(obs_array) “. We will execute the following code that is shown in the figure to get the results for the independence test of the chi square contingency function.

import numpy as np
from scipy import stats
obs_array= np.array([[2, 2, 2],[8, 8, 8]])
stats.chi2_contingency(obs_array)

This function returns the chi square test statistics value, the p-value of the test, and the values of those frequencies which are expected ones for the observations that we pass in the parameters of the function. The output of the function is displayed in the figure below.

Conclusion

The article gives detailed information on the chi square method which uses the “stats” module from the scipy library. We have conducted two types of tests for the chi square methods by implementing the two different examples in the python script and have shown what the output or the return values of this function looks like and what they mean in the context of the scipy chi square () method.



Source link


When transferring files in Ubuntu, there are various options at your disposal but having a means that supports FTP is an added advantage. That’s why FileZilla is your best option. FileZilla is a free FTP client that allows the users to transfer the files via a network from one PC to another.

With FileZilla, you don’t have to archive the files as it supports sftp connections. That way, you easily transfer your files with minimal traffic. Let’s check the installation steps for Ubuntu 22.04 and how to use it to transfer the files.

Getting Started with FileZilla in Ubuntu 22.04

There are various ways to install FileZilla in Ubuntu. This guide offers the steps for the command line and a graphical way of installing FileZilla in Ubuntu 22.04.

1. Installing FileZilla via Command Line
Using the command line is the quickest way to install FileZilla. Open your terminal and start by updating your Ubuntu packages.

Ubuntu 22.04 comes with the needed repository to support the installation of FileZilla. Therefore, install FileZilla using the apt command from the system’s default repository.

$ sudo apt install FileZilla

When prompted to confirm the installation of FileZilla, press Y to continue with the installation. This method of installing FileZilla doesn’t install the latest version.

Go ahead and confirm the installation by checking the currently installed FileZilla version.

To get the latest FileZilla version, we must add the XtraDeb third-party PPA using the following command:

$ sudo add-apt-repository ppa:xtradeb/apps

Merienda the PPA is added, update the packages and install FileZilla using the apt command.

$ sudo apt install FileZilla

Go ahead and check the version. Adding the PPA helps you get the latest FileZilla version.

You can now open the FileZilla from the terminal or the applications.

FileZilla is now open, as shown in the following image. You can now start sharing your server.

With this method of installing FileZilla, you can run the following command to remove FileZilla from your system and all its dependencies.

$ sudo apt autoremove FileZilla

Also, remove the PPA that we added earlier.

$ sudo add-apt-repository –remove ppa:xtradeb/apps

2. Installing FileZilla via Ubuntu Software Center

FileZilla is also available in Ubuntu Software Center. Start by opening the Software Center from your applications to install it using this method.

Click the search icon at the top and search for FileZilla. Click on it to open more details, then click the Install button on the right.

Merienda the installation completes, search for FileZilla from your applications and open it. You will get the same window that we got after installing it via the command line.

With this method, updating and upgrading your Ubuntu packages automatically updates FileZilla. If you need to uninstall FileZilla, open the Software Center and check the installed tab for FileZilla.
Merienda you find it, click the Uninstall button.

Authenticate the uninstall process by entering your password.

How to Use FileZilla

To use FileZilla, you must have the IP address of your remote server, its username, and its password. Open FileZilla and click the site manager icon at the top left.

Create a new site and add the remote server details, as shown in the following image. Select your preferred file transfer protocol using the drop-down button.

After adding the details, click the connect button. You will be prompted to verify the server’s host key.

Merienda connected, note the almacén and remote sites that are displayed on the FileZilla window. At this point, navigate to the source directory on the almacén site if you want to upload the files to the remote server. For the remote server, navigate to the destination directory.

Locate the file that you want to upload on the source site, right-click on it, then click the upload button.

Note the transfer message which is displayed on your screen to confirm that FileZilla has successfully transferred the files from one site to the other.

That’s how you use FileZilla in Ubuntu 22.04.

Conclusion

We covered the steps on how to install FileZilla in Ubuntu 22.04 using two ways. Furthermore, we learned the steps to use FileZilla to connect the almacén and remote sites, then transfer the files. With this guide, you can start transferring the files via FTP or other supported protocols.



Source link