Friday, February 25, 2022

How to change root pasword using ssh command

 The procedure to change the root user password on Ubuntu Linux:

Type the following command to become root user and issue passwd:

sudo -i

passwd

OR set a password for root user in a single command:

sudo passwd root

Test it your root password by typing the following command:

su -

Wednesday, January 5, 2022

Friday, December 31, 2021

Git Configuration and Commit Command

Git Configuration :


git config --global user.email "you@example.com"

git config --global user.name "Your Name"


Commit comman for Mac:

git reset --mixed origin/main 
git add * 
git commit -m "This is a new commit for what I originally planned to be amended" 
git push origin main

Commit comman for Windows:


git add * or git add --all
git commit -m"first message"
git remote add origin "LINK"
git push -u origin master

Tuesday, December 28, 2021

Track from where method is being called in codeigniter


For example, suppose your function name is test, use below code
Code:

function test( )
{
$backtrace = debug_backtrace();

print_r( $backtrace );
}
It will print the details from where the test method is being called.

How to Allow WebP Upload in WordPress using Function

//enable upload for webp image files.

function webp_upload_mimes($existing_mimes) {

    $existing_mimes['webp'] = 'image/webp';

    return $existing_mimes;

}

add_filter('mime_types', 'webp_upload_mimes');


//enable preview / thumbnail for webp image files.

function webp_is_displayable($result, $path) {

    if ($result === false) {

        $displayable_image_types = array( IMAGETYPE_WEBP );

        $info = @getimagesize( $path );


        if (empty($info)) {

            $result = false;

        } elseif (!in_array($info[2], $displayable_image_types)) {

            $result = false;

        } else {

            $result = true;

        }

    }


    return $result;

}

add_filter('file_is_displayable_image', 'webp_is_displayable', 10, 2);

function webp_upload_mimes($existing_mimes) {
    $existing_mimes['webp'] = 'image/webp';
    return $existing_mimes;
}
add_filter('mime_types', 'webp_upload_mimes');

//enable preview / thumbnail for webp image files.
function webp_is_displayable($result, $path) {
    if ($result === false) {
        $displayable_image_types = array( IMAGETYPE_WEBP );
        $info = @getimagesize( $path );

        if (empty($info)) {
            $result = false;
        } elseif (!in_array($info[2], $displayable_image_types)) {
            $result = false;
        } else {
            $result = true;
        }
    }

    return $result;
}
add_filter('file_is_displayable_image', 'webp_is_displayable', 10, 2);

Tuesday, November 23, 2021

How to use Siteground SSH in MacOS terminal

On Siteground the steps are as follows:
Logon to your account at Siteground.
Open Site Tools for your website.
Go to Devs = SSH Keys Manager.
Enter a Key name (e.g. privatekey)
Generate a Password
Click the Create button.
Go to3dots=Manage IP access to limit the IP addresses that can use this connection.
Go to3dots= Private Key and copy it to your clipboard.
On your local machine, open your preferred Terminal
Browse to /path/to/your/privatekey
Create new file, call it myschool and paste the Private key.
Run the following commands
chmod 600 privatekey
ssh-add privatekey
Back in the Site Tools = SSH Keys Manager, go to3dots= SSH Credentials to discover the username and hostname to use.
Now you can run the following command, in order to gain SSH access

ssh username@privatekey -p12345

Wednesday, November 17, 2021

How to install Composer in MacOS

Install download the composer using the following curl command in the terminal:
curl -sS https://getcomposer.org/installer | php
 
After the command, you will have composer.phar file in the current directory and the composer command is available as: 

 php composer.phar [composer commnad] 

In order to make composer available globally, you have to move the recently downloaded composer.phar to local user’s bin folder as follow: 

sudo mv composer.phar /usr/local/bin/

 go to /usr/local/bin folder . 
You can click Shift + Command + G to open the dialog to go to folder. move the recently downloaded composer.phar in the usr/local/bin folder. 

We want to run Composer with having to be root al the time, so we need to change the permissions:
 sudo chmod 755 /usr/local/bin/composer.phar
create a alias using command:

Next, we need to let Bash know where to execute Composer:

 nano ~/.bash_profile
Add this line below to bash_profile and save
alias composer="php /usr/local/bin/composer.phar"
and then run this command:

 source ~/.bash_profile

Finally, run: composer --version

Now, you can access the composer from the terminal simply using the composer command.




How to get Ranking of the Students in Excel using RANK Function

=RANK(number,ref,[order]) To rank in descending order, we will use the formula =RANK(B2,($C$5:$C$10),0) If we want unique ranks, we can use...