Month: September 2017

Learn Javascript

Hie everyone and welcome to the Javascript Tutorial. Here I will not hardcode each and every thing. Rather will introduce with the important concepts which you should know about the respective language.

We will start with the concept debugger. What do you mean by debugger in lay-men language. Think about it!

So, bug means fault and debug means to correct fault. Here, debugger is the program(code) which will help to correct errors. I think it is as easy as to understand.

In JS you can debug code in various ways. Here they are illustrated in two ways.

  1. Using Debugger Keyword
  2. Using Console.log

Using Debugger

<!DOCTYPE html>
<html>
<head>
</head>

<body>

<p id=”demo”></p>

<p>With the debugger turned on, the code below should stop executing before it executes the third line.</p>

var x = 15 * 5;
document.getElementById(“demo”).innerHTML = x;
debugger;
x = 15 + 5;
document.getElementById(“demo”).innerHTML = x;
debugger;
x = 15 + 7;
document.getElementById(“demo”).innerHTML = x;

</body>
</html>

The execution will be stopped whenever the keyword debugger will be encountered. In the above code it will stop three times. You can check value of x at every breakpoint.

Using console.log

<!DOCTYPE html>
<html>
<body>

<h2>My First Web Page</h2>

<p>
Activate debugging in your browser (Chrome, IE, Firefox) with F12, and select “Console” in the debugger menu.
</p>

a = 5;
b = 6;
c = a + b;
console.log(c);

</body>
</html>

You will see the value of variable c in the console window. In firefox and  chrome open console window with F12.

Another Case

While doing experiments on JS forms I got to know very interesting thing.

<!DOCTYPE html>
<html>
<body>

<form name=”myForm” action=”/action_page_post.php”
onsubmit=”return false” method=”post”>
Name: <input type=”text” name=”fname”>
<input type=”submit” value=”Submit”>
</form>

</body>
</html>

In the “onsubmit” attribute of <form> tag we call some function in the value part. But if return false Boolean value as shown above then the form would not submit. We can use this benefit in some condition like if any field of the form is empty by adding JS code as illustrated below.

<!DOCTYPE html>
<html>
<head>

function validateForm() {
var x = document.forms[“myForm”][“fname”].value;
if (x == “”) {
alert(“Name must be filled out”);
return false;
}
}

</head>
<body>

<form name=”myForm” action=”/action_page_post.php”
onsubmit=”return validateForm()” method=”post”>
Name: <input type=”text” name=”fname”>
<input type=”submit” value=”Submit”>
</form>

</body>
</html>

 

That’s all for today. Thank-you for bearing me.:)

Advertisements

Wordpress Installation

Well the purpose of this blog is clear from the title only. But it’s not just that. Actually, I want to make my OSM_installation_script just like it or better than it. Moreover, my mentor Dr. H. S. Rai asked me to do so.

I followed the below link to install WordPress.

https://www.digitalocean.com/community/tutorials/how-to-install-wordpress-with-lamp-on-ubuntu-16-04

When done all the steps mentioned on browsing to the http://localhost I got the  error illustrated below.

word_error

 

On googling to solve the error I got to know about installing the following package.

$ sudo apt install php7.0-mysql

It’s all done. Really it’s a job of 5 minutes.

 

 

Configure Apache2 Userdir

Scenario#- Consider a situation that you are a normal user rather a sudo user. You are desperate to run php program or anything require of Apache server. Ohho! You don’t have permission to edit anything in the directory /var/www/html(considering it as DocumentRoot Directory).

No worry, Apache2 provides here you a solution. You can even run everything from your home directory. It’s a job of 10 minutes. Believe me. 🙂

Steps Involved

$cd /home/username/
$mkdir public_html

Don’t make it with sudo as it will come under the owner root.

Change the permissions of certain directories.

 $ chmod 711 /home
 $ chmod 711 /home/username
 $ chmod 755 /home/username/public_html
 $ chmod o+r /home/username/public_html/index.html

Now, move to the directory mods-available

$cd /etc/apache2/mods-available
$sudo touch userdir.load           //don't replace userdir with your username
$sudo vim userdir.conf

Add the following code in it and save.

<IfModule mod_userdir.c>
        UserDir public_html
        UserDir disabled root
        <Directory /home/*/public_html>
                AllowOverride FileInfo AuthConfig Limit Indexes
                Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
                <Limit GET POST OPTIONS PROPFIND>
                     Require all granted
                </Limit>
                <LimitExcept GET POST OPTIONS PROPFIND>
                     Require all granted
                </LimitExcept>
        </Directory>
</IfModule>

 

$ cd /etc/apache2/mods-enabled
$ sudo ln -s ../mods-available/userdir.conf userdir.conf
$ sudo ln -s ../mods-available/userdir.load userdir.load
$ sudo a2enmod userdir
$ sudo /etc/init.d/apache2 restart 

And you are done! Now you can browse to http://localhost/~username

Apart from it, I tried to set up Apache virtual hosts using the link.

https://www.digitalocean.com/community/tutorials/how-to-set-up-apache-virtual-hosts-on-ubuntu-14-04-lts

Expand Your Vision

Today, I read about the difference the two directories sites-available
and sites-enabled. Likewise of mods-available and mods-enabled.

sites-available contain all the configuration files that may be active
or not whereas sites-enabled as it name suggest contain enabled or
active sites. We should never edit files in the sites-enabled
directory as it may create problem.

To manage the two directories simultaneously, edit the files in the
sites-available and create symlink in the sites-enabled. After that
run the command

$a2ensite abc.com

Similarly, substitute a2ensite with “a2enconf” for configuration file
and for .load file with “a2enmod”

Apart from this I tried to create passport size photograph and arranged it in a sheet using the online tools.

https://www.persofoto.com/upload/passport-photo

http://online-passport-photo.com/

 

 

 

 

Heating Saturday

So, here the presentation day came again, though entirely different. Before the session begins almost all trainees and new comers including me were demotivated, frustrated from last two weeks. Keeping all in mind there was General Body Meeting(GBM) cum motivation seminar.

My senior Vigasdeep shared some adventurous experiences with us. The moral of all the experiences was to execute it what you want to do, don’t think of anybody.

In-spite of all these knowledge, my senior Mandeep Singh gave a presentation on the the topic Password Manager- Pass

You can view it’s documentation from here

https://www.passwordstore.org/