Here is a curated links of sites that are I think are useful as I learn or relearn WSL. Incomplete of course but there's always the internet. Will add any that are worthy to be linked here. For now, this would suffice. If you think there are links worthy to be added here, let me know in the comment below. Thank you! …
Read MoreUsually, a docker container has a way to easily switch to root account. It can be as easy as 'su root' or even root by default when you run a shell such as 'bash' within it. However, sometimes, it's not that easy. You need to work hard for it. My issues where the following: su command won't work as it's just a symlink …
Read MoreBOM or Byte-Order-Mark is needed by a UTF-8 CSV in order to be opened in Excel (at least for Windows). How to check if said BOM exist using bash? See below: 1~$ head -c3 samplefile.csv | hexdump -C 200000000 ef bb bf |...| 300000003
Read MoreSometimes, you may need to know which container a volume is associated with. Use this command: 1docker ps -a --filter volume=VOLUME_NAME_OR_MOUNT_POINT See https://stackoverflow.com/questions/42857575/how-to-determine-what-containers-use-the-docker-volume
Read MoreBrew by default doesn't install unsupported software versions. Like at this time, php7.3 was no longer supported. Installing it disables it and install instead the latest version (8.1.3 at this time). 1~$ brew install php@7.3 2Running `brew update --preinstall`... 3==> Auto-updated Homebrew! 4Updated 2 taps …
Read MoreOverview In contrast to a named function like: 1<?php 2function multiply($x, $y) 3{ 4return $x * $y; 5} An anonymous or unnamed-function, well has no name: 1<?php 2function ($x, $y) { 3return $x * $y; 4}; //closing semicolon here is mandatory. NOTE: semicolon after the closing curly bracket is mandatory as it is …
Read MoreSuppose that you have an array that holds the lengths of squares: 1<?php 23$lengths = [10, 20, 30]; To calculate the areas of the squares, you may come up with the foreach loop like this: 1<?php 23$lengths = [10, 20, 30]; 45// calculate areas 6$areas = []; 78foreach ($lengths as $length) { 9$areas[] = $length * …
Read MoreCallbacks can be denoted by the "callable" type declaration. Example: 1icasimpan$ nl -ba callable_example.php 21 <?php 32 function printFormatted(callable $format, $str) { 43 echo $format($str); 54 echo "<br>"; 65 } 76 87 function exclaim($str) { return $str . "!"; } 98 …
Read MoreAn iterable is any value which can be looped through with a foreach() loop. The iterable pseudo-type was introduced in PHP 7.1, and it can be used as a data type for function arguments and function return values. Example 1<?php 2function printIterable(iterable $myIterable) { 3foreach($myIterable as $item) { 4echo …
Read More