Categories
General

GIT Trunk based strategy for merging ticket/branches

So as a tech lead, we ahve to review code before deployment

The challenges are

  • How to have clean merges up to prod (higher environment)?

The solution found was to use GIT SQUASH instead of git merge as it combines all sub commits to only one final commit in the log history

  • How to have clean merges, down to the development branch ?

The solution found, is to use GIT MERGE instead of git squash against the dev environment after successful deployment to PROD

as the git log history stays intact and merging keep records straight

Categories
General

How to see files changed in a git commit ?

git show –stat –oneline <commitNumber>

Categories
General

Why The response is not a valid JSON response. ? when trying to upload image on wordpress ?

The response is not a valid JSON response.

The file is too big

You need to compress/export the file in a lighter weight

such as

Categories
General

Why macBook pro does not detect 2nd / 3rd monitor ?

Check how many displays you can connect

If you’re connecting multiple displays to your Mac, use the Tech Specs page to find out how many external displays your Mac supports.

  1. Choose Apple menu  > About This Mac, double-click your serial number, then press Command-C to copy it.
  2. Go to the Tech Specs page, click the Search Tech Specs bar, press Command-V to enter your computer’s serial number, then click Search.
  3. Click the specs page for your Mac. The number of displays your Mac supports appears under Video Support or Graphics.
Categories
General

Laravel how to resolve search_path ?

Illuminate\Database\QueryException
SQLSTATE[42601]: Syntax error: 7 ERROR: syntax error at end of input LINE 1: SET search_path TO ^ (SQL: SET search_path TO )

solution add to config/database.php

    'default' => env('DB_CONNECTION', 'pgsql-raleche'),

    'search_path' => 'mapi_admin_tool,api,product,public,trade,ws,eddm',
Categories
General

How to fix Laravel Nova Issue ? Failed to download Laravel/Nova …

Failed to download laravel/nova from dist: The 'https://nova.laravel.com/dist/laravel/nova/laravel-nova-0a8ec5b37dc3ca29f4b79c7318c9278e5a5d2c1a-zip-7e4351.zip' URL could not be accessed: HTTP/2 403

Two ways to fix this problem

  • Execute the following command with the email and password parameters
composer config http-basic.nova.laravel.com [email protected] NovaHasspassword
  • create an auth.json password and paste the following content
{"username":"[email protected]","password":"asdsadasdqweqwerewrew”}

Categories
General

“Unprocessable Entity” is not valid header name

As of March 20th 2022, https://github.com/GrahamCampbell updated the following library guzzlehttp/psr7

so in your unit test you will see errors as follow

InvalidArgumentException: "Unprocessable Entity" is not valid header name
InvalidArgumentException: "409 conflict with the current state of the target resource" is not valid header name
InvalidArgumentException: "Not Found" is not valid header name
InvalidArgumentException: "Not Acceptable" is not valid header name
InvalidArgumentException: "Not Found" is not valid header name
InvalidArgumentException: "Bad Request" is not valid header name
InvalidArgumentException: "409 conflict with the current state of the target resource" is not valid header name
InvalidArgumentException: "500 Internal Server Error" is not valid header name

The version 1.8.5 was breaking our set of unit test

Solution is to update composer.json and use this version below

"guzzlehttp/psr7": "1.8.3",

2.1.1 – 2022-03-20

Fixed

  • Validate header values properly

https://github.com/guzzle/psr7/blob/2.2.1/CHANGELOG.md

Categories
General

trunk-based development

https://www.devbridge.com/articles/branching-strategies-git-flow-vs-trunk-based-development/

https://trunkbaseddevelopment.com/

Categories
General

Palindrome 2



class Solution {
    
    public function palindrome2 (string $s) : bool {
        #aba - true
        #abca - 
        #abc - 
        
        $n = strlen($s); #4
        $p1 = 0;
        $p2 = $n - 1 ; #3
        $mid = floor(($n - 1) / 2); #1
        $charRemoved = false;
        
        while($p1 < $mid || $p2 > $mid) 
        {

            
            # p1:1 < mid:1 OR 
            # p2:2 > mid:1
            if ($s[$p1] == $s[$p2]) {
                $p1++; #1
                $p2--;  #1
                continue;
            }
            
            if($s[$p1+1] == $s[$p2] && $charRemoved ==false) {
                $p1 = $p1 + 1;
                $charRemoved = true;
                continue;
            } else if ($s[$p1+1] == $s[$p2] && $charRemoved == true) {
                return false;
            }

            if($s[$p2-1] == $s[$p1] && $charRemoved ==false) {
                $p2 = $p2 - 1;
                $charRemoved = true;
                continue;
            } else if ($s[$p2-1] == $s[$p1] && $charRemoved == true) {
                return false;
            }
            
            if(($s[$p1] != $s[$p2]) && ($p1 + 1 == $mid || $p2 - 1 == $mid) ) {
                return false;
            }
        }
        
        if($s[$p1] != $s[$p2] && (($n % 2) == 0)) {
            return true;
        }
        
        return true;
    }
    
}

$res = new Solution();
var_dump($res->palindrome2('abbca'));
Categories
General

How to delete a Git branch locally and remotely ?

Steps to delete qa branch

Step 1 – delete locally

git branch -d dev

Step 2 – delete remotely

git push origin origin/dev
git push origin --delete origin/dev