All posts by Abu Sohib

About Abu Sohib

This is test

All github command details.

Here i am going to list all the github command i use for my daily needs.

Cloning a git repository  : 

Following command is used to clone a github repository to local computer. To execute this command just visit the directory you want to clone remote git branch .

git clone “Url of the github repository name”

Checking out a git branch :

To checkout a git branch needs to use following command

git checkout “branch_name”

Overwrites master branch with another branch:

To overwrites master branch with another branch just follow below steps.

First checkout your master branch  :

git checkout master

Then overwrite master with your other branch :

git reset –hard better_branch

Force the push to your remote repository :

git push -f origin master

 

Javascript number input field only and does not accept negative and string value

Html input field which will take only number input and will not accept negative number and string input. It will accept only numeric value.

Example:

<input id=”myNumber” type=”number” name=”my_number”  min=”0″ oninput=”this.value = (isNaN(Math.abs(this.value)))?0:Math.abs(this.value)”>

Above example will not take any negative number input and string input. It will accept only positive number.

Some common ssh command that we use regularly

SSH Command Explanation
ls Show directory contents (list the names of files).
cd Change Directory.
mkdir Create a new folder (directory).
touch Create a new file.
rm Remove a file.
cat Show contents of a file.
pwd Show current directory (full path to where you are right now).
cp Copy file/folder.
mv Move file/folder.
grep Search for a specific phrase in file/lines.
find Search files and directories.
vi/nano Text editors.
history Show last 50 used commands.
clear Clear the terminal screen.
tar Create & Unpack compressed archives.
wget Download files from the internet.
du Get file size.

PHP+Ubuntu Send email using gmail form localhost

https://stackoverflow.com/questions/33969783/phpubuntu-send-email-using-gmail-form-localhost

 

Please do following steps to send mail from localhost on Ubuntu/Linux through gmail :-

For that you need to install msmtp on Linux/Ubuntu server.

Gmail uses https:// (it’s hyper text secure) so you need install ca-certificates

~$ sudo apt-get install msmtp ca-certificates
It will take few seconds to install msmtp package.

Now you have to create configuration file(msmtprc) using , gedit editor.

~$ sudo gedit /etc/msmtprc
Now you have to copy and paste following code in gedit (file you created with above command)

defaults
tls on
tls_starttls on
tls_trust_file /etc/ssl/certs/ca-certificates.crt

account default
host smtp.gmail.com
port 587
auth on
user MY_GMAIL_ID@gmail.com
password MY_GMAIL_PASSSWORD
from MY_GMAIL_ID@gmail.com
logfile /var/log/msmtp.log
Don’t forget to replace MY_GMAIL_ID with your “gmail id” and MY_GMAIL_PASSSWORD with your “gmail password” in above lines of code.

Now create msmtp.log as

~$ sudo touch /var/log/msmtp.log

You have to make this file readable by anyone with

~$ sudo chmod 0644 /etc/msmtprc

Now Enable sendmail log file as writable with

~$ sudo chmod 0777 /var/log/msmtp.log

Your configuration for gmail’s SMTP is now ready. Now send one test email as

~$ echo -e “Subject: Test Mail\r\n\r\nThis is my first test email.” |msmtp –debug –from=default -t

MY_GMAIL_ID@gmail.com
Please check your Gmail inbox.

Now if you want to send email with php from localhost please follow below instructions:-

Open and edit php.ini file

~$ sudo gedit /etc/php/7.0/apache2/php.ini
You have to set sendmail_path in your php.ini file.

Check your SMTP path with

~$ which msmtp
and you will get /usr/bin/msmtp like that.

Search sendmail_path in php.ini and edit as below

; For Unix only. You may supply arguments as well (default: “sendmail -t -i”).
; http://php.net/sendmail-path
sendmail_path = /usr/bin/msmtp -t
Please check 3rd line carefully there is no semicolon before sendmail_path.

Now save and exit from gedit. Now it’s time to restart your apache

~$ sudo /etc/init.d/apache2 restart
Now create one php file with mail function from http://in2.php.net/manual/en/function.mail.php.

Do test and enjoy !!