php tip not to use count in for iteration

Dont use count() in loops because each iteration will count the number of elements; make a variable $count = count($array) and use the variable instead

php using sorting methods

class Newclass
{
 
public static function compare($a, $b)
{
return strcmp($a["name"], $b["name"]);
}
 
}
 
usort($array_to_srt, array("Newclass", "compare"));
 
 
 
uasort($array_to_srt, array("Newclass", "compare"));
 
The difference between usort and uasort is that uasort keeps the keys, usort resets them and enumerate from scratch.

Git overwrite local branch to match remote branch

git reset --hard origin/master

Git force push to overwrite on remote

git push -f origin myremotebranch
git push -f myprivate master:master
git push -f

Linux how-to delete the first line in text file

tail -n +1 filename.txt > filename.txt.new

Git reset hard to make local as remote branch

git reset --hard origin/master

git http ssl import/export no certificate verify

export GIT_SSL_NO_VERIFY=1

Laravel last query raw output

<?php
 
dd(\DB::getQueryLog());

php enable errors

<?php
 
error_reporting(-1);
ini_set('display_errors', 'On');

php when pass by reference

1. Objects should be passed by reference always, arrays and scalars are passed by value.
2. If you are working on a very large array and plan on modifying it inside a function, you actually should use a reference to prevent it from getting copied, which can seriously decrease performance or even exhaust your memory limit.
3. If it is avoidable though (that is small arrays or scalar values), I’d always use functional-style approach with no side-effects, because as soon as you pass something by reference, you can never be sure what passed variable may hold after the function call, which sometimes can lead to nasty and hard-to-find bugs.
4. Scalar values should never be passed by reference, because the performance impact can not be that big as to justify the loss of transparency in your code.