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.




Install PhpStorm on Mac OSX

About the App
Install the App
  1. Press Command+Space and type Terminal and press enter/return key.
  2. Run in Terminal app:
    ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" 2> /dev/null
    and press enter/return key. If you are prompted to enter your Mac's user password, enter it (when you type it, you wont see it on your screen/terminal.app but it would accept the input; this is to ensure no one can see your password on your screen while you type it. So just type password and press enter, even if you dont see it on your screen). Then wait for the command to finish.
  3. Run:
    brew install phpstorm

    Done!

    You can now use PhpStorm.

Extract Domain from email in Excel or Google sheet

  =TEXTAFTER( A2 , "@") or, =MID(A1, FIND("@", A1) + 1, LEN(A1) - FIND("@", A1))