Linux Add custom bash commands

Step 1 :
Find your .bashrc file

Step 2 :
(.bashrc is found in root directory)
(You can type cd in the terminal and hit enter to get to root and use ls -la to see list of files in directory)
- Edit your .bashrc file. Use whatever editing tool of your choice.
or you can just edit in the terminal with the below command :
nano .bashrc
Once you are in the file proceed to step 3.

Step 3 :
Go to the bottom of you .bashrc file and look for something along the lines of the below :

 
 
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion

Step 4 :
Add a comment above the snippet indicated above so it looks like this.

#Custom Bash Commands
# Commands will be listed here...

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion

Step 5 :
Add your commands. 1 per line! use semi-colon ( ; ) to run multiple commands in succession

#Custom Bash Commands
alias my_custom_bash_command="do something in bash code"
alias my_custom_bash_command2="do something in bash code"
alias my_custom_bash_command3="do something in bash code"
alias my_custom_bash_command4="do something in bash code"

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion


Template Snips for Laravel .Blade files

<?php 

@php
  echo "<pre style='color:#fff;'>";
    print_r($data);
  echo "</pre style='color:#fff;'>";
@endphp

@php
  echo "<pre>";
    print_r($data);
  echo "</pre>";
@endphp

@php
  echo "<pre style='color:#fff;'>";
    print_r($data);
  echo "</pre style='color:#fff;'>";
@endphp

@php
  echo "<pre>";
    print_r($data);
  echo "</pre>";
@endphp

DropdownButtonFormField & Validation from API

Requirements :
- API Service
- Object Model
Developer Recommendation : NB!!! - Use QuickType for your model.
(You need an already working api with a JSON response for quicktype) https://app.quicktype.io/
- DropDownMenuItem
NB!!! - The DropDownMenuItem must be wrapped in a form widget to implement validation.

HINT : Avoid casting variable types such as <String> or <List> or <Object> until your list is actually working. In the DropdownButtonFormField Snippet, you will see no types are declared.

Step 1 :
Configuration :
(On your page.dart or screen.dart)

You need to include these.
1 : Your Model from QuickType

// Model
import './model/support_fields_model.dart';
// API
import 'package:project_name/api/support_fields_service.dart';
// Includes
import 'package:flutter/material.dart';

DropdownButtonFormField Snippet :

child: Form(
  key: globalFormKey,
    Container(
      child: DropdownButtonFormField(
        hint: Text("-- Select Query --"),
        value: querySelect,
        validator: (querySelect) =>
            querySelect ==
                    "-- Select Query --"
                ? 'Select Query Required'
                : null,
        onChanged: (newValue) {
          setState(() {
            dropDownButtonCallback(
                newValue, "select_query");
          });
        },
        items: querySelectOptions
            .map<DropdownMenuItem>((map) {
          return DropdownMenuItem(
            value: map.name,
            child: Text(map.name),
          );
        }).toList(),
      ), // DropdownButtonFormField
    ), // Container
  ), // Form

Excell Calculations for Text after and Before Space

Excel give characters after space

If you want to extract the text after space only, use this formula 
=MID(A1,FIND(" ",A1)+1,256)

Excel give characters before space

Extract text before or after space with formula in ExcelYou can quickly extract the text before space from the list only by using formula. Select a blank cell, and type this formula 
=LEFT(A1,(FIND(" ",A1,1)-1)) 
(A1 is the first cell of the list you want to extract text) , and press Enter button.

Meta Box – Post info disappeared in admin

Meta Box – Post info disappeared in admin

This problem is due to version conflicts with meta_box plugin

--

The below is when a new album is been created.
All the post info is visible.
NEW ALBUM

The below is editing an existing album.
All of the post info uploaded is no longer displaying. So my client can no longer edit their posts.
EDIT

New Dev Setup PHP & Ubuntu – For Windows

Useful for Debugging :
https://old.garthbaker.co.za/re-install-ubuntu-windows-11/

Install PHP 8 (Ubuntu Terminal cd ~)

sudo apt update
sudo apt -y upgrade
--
sudo apt update
sudo apt install lsb-release ca-certificates apt-transport-https software-properties-common -y
sudo add-apt-repository ppa:ondrej/php
--
sudo apt update
sudo apt install php8.0
--
php -v

Installing Required Extensions (Ubuntu Terminal cd ~)

The below command should be enough. But if you missing extensions, check below

sudo apt install php8.0-curl php8.0-cli php8.0-xml php8.0-mbstring php8.0-zip php8.0-pdo php8.0-mysql php8.0-gd

If you want to list all PHP 8.0 loaded modules use the command:
php -m

sudo apt install php8.0-

php8.0-amqp       php8.0-common     php8.0-gd         php8.0-ldap       php8.0-odbc       php8.0-readline   php8.0-sqlite3    php8.0-xsl
php8.0-apcu       php8.0-curl       php8.0-gmp        php8.0-mailparse  php8.0-opcache    php8.0-redis      php8.0-sybase     php8.0-yac
php8.0-ast        php8.0-dba        php8.0-igbinary   php8.0-mbstring   php8.0-pgsql      php8.0-rrd        php8.0-tidy       php8.0-yaml
php8.0-bcmath     php8.0-dev        php8.0-imagick    php8.0-memcached  php8.0-phpdbg     php8.0-smbclient  php8.0-uuid       php8.0-zip
php8.0-bz2        php8.0-ds         php8.0-imap       php8.0-msgpack    php8.0-pspell     php8.0-snmp       php8.0-xdebug     php8.0-zmq
php8.0-cgi        php8.0-enchant    php8.0-interbase  php8.0-mysql      php8.0-psr        php8.0-soap       php8.0-xhprof
php8.0-cli        php8.0-fpm        php8.0-intl       php8.0-oauth      php8.0-raphf      php8.0-solr       php8.0-xml

Install Composer (Ubuntu Terminal cd ~)

//Update your packages:
sudo apt-get update

//Install Curl to get the composer library:
sudo apt-get install curl

//Installing composer:
sudo curl -s https://getcomposer.org/installer | php

//Move the composer file to bin path :
sudo mv composer.phar /usr/local/bin/composer

//Verify composer installation :
composer

Install NPM (Ubuntu Terminal cd ~)

sudo apt install npm

Activate WSL 2 and Virtual Machine Platform
(Run as Admin in powershell ~)

NB!!! Don't forget to install the kernel for wsl2 :
https://docs.microsoft.com/en-za/windows/wsl/install-manual#step-4---download-the-linux-kernel-update-package

//Enable the WSL2 without reboot 
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart 

//Enable the Virtual Machine Platform 
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart

Set WSL2 Default (Run as Admin in powershell ~)

wsl --set-default-version 2