Nmap useful commands

Look up which ip is used by which host

nmap -sn 192.168.1.0/24

How to resolve npm permission issue?

This is general solutions for all kind of npm permission issue.

sudo chown -R $USER ~/.npm
sudo chown -R  $USER /usr/bin/npm
sudo chown -R  $USER /usr/lib/node_modules/
chmod -R a+x node_modules

How to resolve expected response code 250 but got code 535?

I researched on the internet and some answers includes enabling the "access for lesser app" and "unlocking gmail captcha" which sadly didn't work for me until I found the 2-step verification.


How to get all twig variables from template

This is how I use to debug any twig template and it's variables. Just include into your twig template and pass variable = object | array | null

{% partial 'debug' variable=post %}

How to replace content in large file?

Many time developer just need to replace a bit of text inside the large file like *.sql or *.sqlite
Opening a file into editor take too much resource of system or server. So I come up with the very easy and useful way to replace content into large file using linux command like. sed command.

Here I am taking an example of MySql file which having *.sql as file extension

sed -i '' 's/utf8mb4_0900_ai_ci/utf8mb4_unicode_ci/g'

Programming principles

While I have started my journey to the Programming world, I come accross many principles which I am list down here for easy understanding.


How to sign your work using git commit?

How to validate your git work using , git signed commit.


Nested set pattern for laravel’s eloquent orm

For Nested Set pattern , I would suggest to follow this links

The theory behind, a TL;DR version

An easy way to visualize how a nested set works is to think of a parent entity surrounding all of its children, and its parent surrounding it, etc. So this tree:


Linux golden commands

Kill any process using port

USE THIS COMMAND ON YOUR OWN RISK !

sudo kill -9 $(sudo lsof -t -i:4200)

If you want to check that if process running than and than kill the process , use bellow one

if sudo lsof -t -i:4200; then sudo kill -9 $(sudo lsof -t -i:4200); fi

Above command will check that process is running than kill by process id.


Git useful commands

  • Store all your cred into system helper
git config --global credential.helper store
# Set the cache to timeout after 1 hour (setting is in seconds)
git config --global credential.helper 'cache --timeout=3600'