Skip to content

Instantly share code, notes, and snippets.

@RazinTeqB
Last active March 5, 2025 04:18
Show Gist options
  • Save RazinTeqB/cf20a5d81eed426e35fd4aeb61e20ea8 to your computer and use it in GitHub Desktop.
Save RazinTeqB/cf20a5d81eed426e35fd4aeb61e20ea8 to your computer and use it in GitHub Desktop.
Some Useful code/ shortcuts/ tutorials etc

Some Useful code/ shortcuts/ tutorials etc

  1. Show full pagination in datatable ( goto last page of datatable)
  2. Get list of all installed vscode extension in linux
  3. To Get Only Ip address of local system with linux command (
  4. To generate large files for testing. terminal command
  5. TO allow permission in db
  6. Login to mysql : mysql -u root -p
  7. Password generator command:
  8. REGEx Range validation (External Link)
  9. Disable https globally from composer:
  10. Enable https globally from composer:
  11. List composer config:
  12. Change php version:
  13. Enable second in ubuntu top bar
  14. Set desktop icon size
  15. To find who is logged in my system as ssh and log them out
  16. Force stop application from terminal
  17. Get installed fonts
  18. To remove file form cache
  19. How to use github access token
  20. Craft cms Tutorial (External Link)
  21. Check disk usage
  22. Monitor browser events
  23. Set sql variable
  24. PHP analysis tools (External Link)
  25. Search (PHP analysis tools in above link)
  26. Multi file upload one by one (keywords: "append to input type file","multiple","dynamic input types")
  27. Ubuntu terminal command to get mysql database size(mysql database size | )
  28. Add new server in phpmyadmin (ubuntu)
  29. List process on specific port
  30. Kill process
  31. Git command alias with autocomplete
  32. Get number of branches command
  33. prune deleted branches
  34. Avatar - image from name initials
  35. disable xdebug temporarily
  36. re-enable xdebug
  37. Table row number starting from 1 according to per page and current page
  38. Mirro repository

Show full pagination in datatable ( goto last page of datatable)

    $('#agent_activity').DataTable({
    	"pagingType": "full_numbers"
    });

Get list of all installed vscode extension in linux

code --list-extensions | xargs -L 1 echo code --install-extension

To Get Only Ip address of local system with linux command (

hostname -I

To generate large files for testing. terminal command

fallocate -l 100M testfile2G.txt fallocate -l <SIZE><G|M> <filename>.<extension>

TO allow permission in db

Login to mysql : mysql -u root -p

GRANT ALL PRIVILEGES ON elision_prudent.* TO 'root'@'192.168.0.65' IDENTIFIED BY 'tumko34h1se'; GRANT ALL PRIVILEGES ON asterisk2.* TO 'root'@'192.168.0.65' IDENTIFIED BY 'tumko34h1se';

SELECT table_schema ,
    ROUND(SUM(data_length + index_length) / 1024 / 1024, 1) "DB Size in MB"
    FROM information_schema.tables  WHERE table_schema='asterisk2'
    GROUP BY table_schema

Password generator command:

pwgen 10 3 -y

Disable https globally from composer:

composer config --global disable-tls true composer config --global secure-http false

Enable https globally from composer:

composer config --global disable-tls false composer config --global secure-http true

List composer config:

composer config --global --list

Change php version:

sudo update-alternatives --config php

Enable second in ubuntu top bar

gsettings set org.gnome.desktop.interface clock-show-date true gsettings set org.gnome.desktop.interface clock-show-seconds true gsettings set org.gnome.desktop.interface clock-show-weekday true

Set desktop icon size

gsettings set org.gnome.nautilus.icon-view default-zoom-level 'small'

To find who is logged in my system as ssh and log them out

who ps -U ovs sudo kill 4198

Force stop application from terminal

pkill -9 chrome

Get installed fonts

   fc-list | grep -i "Knocky"

To remove file form cache

If file or folder is pushed to git and letter added to git ignore then need to remove from cache

   git rm -r --cached .
   git config --global core.autocrlf false
   git add --renormalize .
   git add .

How to use github access token

git remote add origin https://<TOKEN>@github.com/RazinTeqB/craft_demo.git

Check disk usage

du -h --max-depth=1

Monitor browser events

monitorEvents($0)

Set sql variable

SET @variable_name = (SELECT @@GLOBAL.sql_mode); SET GLOBAL sql_mode = ''

Search (PHP analysis tools in above link)

Multi file upload one by one (keywords: "append to input type file","multiple","dynamic input types")

Solution Link

Ubuntu terminal command to get mysql database size(mysql database size | )

du -h /var/lib/mysql

Add new server in phpmyadmin

  • Add below code in /etc/phpmyadmin/config.inc.php
    $i++;
    $cfg['Servers'][$i]['host'] = 'HostName:port'; //provide hostname and port if other than default
    $cfg['Servers'][$i]['user'] = 'userName';   //user name for your remote server
    $cfg['Servers'][$i]['password'] = 'Password';  //password
    $cfg['Servers'][$i]['auth_type'] = 'config';       // keep it as config
    

List process on specific port

lsof -i tcp:3000

Kill process

kill -9 <PID>

Git command alias with autocomplete

  1. Download .git-completion.bash from here
  2. Save this file in same folder as .bashrc file.
  3. Add below code in .bashrc file
    if [ -f ~/.git-completion.bash ]; then
    . ~/.git-completion.bash
    fi
    
  4. Create alias for git command
    alias gpl='git pull origin '
    __git_complete gpl _git_checkout
    
  5. Restart terminal
  • Note: alias must be after Step 3 code

Get number of branches command

git branch --all | wc -l

prune deleted branches

git fetch -p && git branch -vv | awk '/: gone]/{print $1}' | xargs git branch -D

Avatar - image from name initials

disable xdebug temporarily

  • sudo phpdismod xdebug
  • sudo service apache2 restart

re-enable xdebug

  • sudo phpdenmod xdebug
  • sudo service apache2 restart

Table row number starting from 1 according to per page and current page

(currentPage - 1) * perPage + index + 1

Mirro repository

cd projects/
cd central_city_liquors/
cd ../
git clone [email protected]:corePHP/central-city-liquors.git
mkdir git_mirror
cd git_mirror/
git clone --bare [email protected]:RazinTeqB/central_city_liquors.git
ll
[email protected]:RazinTeqB/central_city_liquors.git
git clone --bare [email protected]:RazinTeqB/central_city_liquors.git
cd central_city_liquors.git/
git push --mirror [email protected]:corePHP/central-city-liquors.git
cd ../
rm -rf central_city_liquors.git/
cd ../
rm -rf central-city-liquors/
git clone [email protected]:RazinTeqB/central_city_liquors.git
git clone [email protected]:corePHP/central-city-liquors.git
cd central-city-liquors/
git log --oneline --graph --all
git remote -v
cd ../
rm -rf central_city_liquors/
exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment