Remove index.php from url nginx laravel

Updated: 8th June 2022
Tags: nginx php

My programming tips after 10 years of programming

Updated: 28th April 2022
Tags: php mysql

Redis vs Memcache for PHP

Updated: 24th March 2022
Tags: redis memcached php

Memcache. It allows you to store both strings and php arrays and have fun. If it is not enough, try redis.

PHP how to make work curl with CURLOPT_SSL_VERIFYHOST or fix php curl SSL certificate

Updated: 23th March 2022
Tags: php curl

GulpUglifyError: unable to minify JavaScript Caused by: SyntaxError: Unexpected token: keyword const

Updated: 11th December 2021
Tags: javascript gulp

How to create bash alias permanently ubuntu

Updated: 1th November 2021
Tags: ubuntu bash alias

Edit file ~/.bash_aliases

nano ~/.bash_aliases

For example, I make alias a. So when I press a it will produce php artisan tinker Here file ~/.bash_aliases

alias a='php artisan tinker'

Load aliases immediately

source ~/.bash_aliases

How to download m3u8 to single video file

Updated: 28th September 2021
Tags: m3u8

Don't rely on isset to check if it is isset!

Updated: 15th June 2021
Tags: php

Php isset will tell false if variable is null.

//false
isset($a[1]);

$a[1] = null;
//false
isset($a[1]);

That’s why you should use array_key_exists if you need to check if it is set or not.

//false
array_key_exists($a[1]);

$a[1] = null;
//true
array_key_exists($a[1]);

Laravel check produced SQL

Updated: 15th April 2021
Tags: laravel
DB::enableQueryLog(); // Enable query log
// use orm
dd(DB::getQueryLog()); // Show results of log

Bash show process list

Updated: 15th April 2021
Tags: ubuntu bash

Show process list sorted by memory usage

ps aux --sort=-%mem | awk 'NR<=800{print $0}'

Show process list with full start date

ps -eo pid,lstart,cmd

Git commands to remove latest commit

Updated: 12th April 2021
Tags: git

Remove commit but save current code

git reset --soft HEAD~1
git push origin master --force

Remove commit and remove commit’s code

git reset --hard HEAD~1
git push origin master --force

Laravel clear queue job code cache

Updated: 12th April 2021
Tags: php laravel

Laravel queue job is caching your job php code, so after updating job code you need to:

php artisan queue:restart

Nginx test config and reload

Updated: 24th November 2020
Tags: nginx

Fast command to test nginx config and reload nginx if test is successful

sudo nginx -t && sudo nginx -s reload

Ubuntu run command in background

Updated: 14th November 2020
Tags: terminal comman linux ubuntu

To run some command in background, so you can close terminal, type the following:

nohup command-with-options &

Build golang app from windows to Linux 64 bit

Updated: 14th November 2020
Tags: go windows linux build

TL DR; To build app on windows to linux 64 type this in powershell

$Env:GOOS = "linux"; $Env:GOARCH = "amd64"; go build main.go

Windows powershell get first / last 100 lines of txt file

Updated: 1th July 2020
Tags: windows powershell

PHP server cmd command

Updated: 6th February 2020
Tags: php

PHP server in current directory

php -S localhost:8000

PHP server in public directory

php -S localhost:8000 -t public

MySQL Fix login for phpmyadmin

Updated: 24th December 2019
Tags: sql mysql

[Solved] MySQL ERROR 1231 (42000):Variable 'character_set_client' can't be set to the value of 'NULL'

Updated: 24th December 2019
Tags: sql mysql

If you try to import dumped file, and there is such an error, try using mysql console with options and then import sql file

mysql -u root -p --max_allowed_packet=6400M

Troubleshoot

If you haven’t access to console or the previous doesn’t work

set global max_allowed_packet=10000000000;

PHP Simple PDO class

Updated: 23th December 2019
Tags: php mysql sql