Posts

Laravel Sail on Windows issue - "cmdlet Invoke-WebRequest at command pipeline position 1"

Image
I tried to install a laravel example app using Laravel Sail. When I executed following command I got following error even I install Docker Desktop in Powershell cmdlet Invoke-WebRequest at command pipeline position 1  Supply values for the following parameters:  Uri:  Then I tried to find the issue in the laravel documentation. But it is not explained about this issue and recommended steps either. I have found following solution:   1) You need to enable WSL in docker desktop. 2) Install WSL on the computer using Windows terminal - https://apps.microsoft.com/detail/9n0dx20hk701?hl=en-US&gl=US Install WSL - https://learn.microsoft.com/en-us/windows/wsl/install 3) You may be able to open tabs in Terminal with installed linux distribution. Thank you

Laravel 10 - Syntax error or access violation: 1071 Specified key was too long; max key length is 1000 bytes (Connection: mysql, SQL: alter table `users` add unique `users_email_unique`(`email`))

 I got the following error when executing the migration command for the first time.  PS C:\wamp64\www\example-app> php artisan migrate    INFO  Running migrations.   2014_10_12_000000_create_ users_table .............................. .............................. ......... 39ms FAIL    Illuminate\Database\ QueryException   SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 1000 bytes (Connection: mysql, SQL: alter table `users` add unique `users_email_unique`(`email`))   at vendor\laravel\framework\src\ Illuminate\Database\ Connection.php:829     825▕                     $this->getName(), $query, $this->prepareBindings($ bindings), $e     826▕                 );     827▕             }     828▕   ➜ 829▕             throw new QueryException(     830▕                 $this->getName(), $query, $this->prepareBindings($ bindings), $e     831▕             );     832▕         }     833▕     }   1   vendor\laravel\framework\src

Change RabbitMQ user password when username is known

RabbitMQ is an open-source message-broker software.

Change default directory of GitBash in Windows

Image
To see the current default directory . Run this. It will open Explorer in the default directory. $ explorer . Goto GitBash shortcut and right click and select properties. Change the 'Start In' field accordingly. And also remove --cd-to-home from Target location field

PHP Issue - A non-numeric value encountered

This error is encountered when we are going to do addition with different types of variables. See following example $a = ""; $b = 3; try{ $c = $a + $b; }catch(\Exception $e){ var_dump($e->getMessage()); } Exception is occurred. Error is " A non-numeric value encountered " There are two solutions  Solution 1 Change the value of variable $a into zero (0). So, both variables are getting the same type of value now.  $a = 0; $b = 3; try{        $c = $a + $b;         echo $c; }catch(\Exception $e){ var_dump($e->getMessage()); } Solution 2  You can simply cast $a when doing addition $a = ""; $b = 3; try{         $c =  (int) $a  + $b;         echo $c; }catch(\Exception $e){ var_dump($e->getMessage()); } Enjoy..

Simple Email validation regular Expression for Javascript

Following regular expression will validate emails.   var re = /^ [ A-Z0-9a-z \. _+ ] +@ [ A-Za-z0-9 \. - ] + \.([ A-Za-z ]{2,4}) $/ ; re . test ( value ); We will discuss above regular expression part by part. Examples - part1@part2.part3 1. abcd+ef@bbb.com 2. cccc_efg@bbb.lk 3. cccc.efg@bbb.net ^ ==> Start of the expression Part1 [ A-Z0-9a-z \. _+ ] +  ==> There can be many of  A-Z upper case characters, a-z lower case characters, 0-9 numbers, dots and plus signs. @ ==> There must be @ sign after first part of the email Part2 [ A-Za-z0-9 \. - ] + ==> After @ sign there can be same kind of character sets as part 1 (part 2 of email) \. ==> There must be dot character before 3rd part of the email. It should be properly escaped. That is why we use backslash (\) Part3 ([ A-Za-z ]{2,4}) ==> There are must be two to four characters({2,4})including  A-Z upper case characters or a-z lower case characters.  Curly brackets specify the range of characters. So, 2 is minimum num

Mysql Concat() function

Image
Usage 1 SELECT CONCAT("This  ", "is  ", "test ", "concatenation") AS testConcatenation; Syntax concat(exp1, exp2, exp3, ..) - exp1 is required Usage 2 Concat table field and text together SELECT CONCAT(NAME, " is creted at  ", created_at, " ") AS Address FROM province; Enjoy...