Skip to content

Instantly share code, notes, and snippets.

@nd3w
nd3w / install-wine4-ubuntu18.04.txt
Last active Oct 29, 2019
Installing Wine 4.0 on Ubuntu 18.04 and Linux Mint 19
View install-wine4-ubuntu18.04.txt
$ sudo dpkg --add-architecture i386
$ sudo apt update
$ wget -qO- https://dl.winehq.org/wine-builds/Release.key | sudo apt-key add -
$ sudo apt-add-repository 'deb http://dl.winehq.org/wine-builds/ubuntu/ bionic main'
$ sudo apt update
View gist:dde9fa08b51b3b64c23c30c16038c125
Get how many rows in whole database
SELECT SUM(TABLE_ROWS)
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_SCHEMA = 'db_name';
@nd3w
nd3w / php.ini for development
Created Apr 27, 2019
PHP configuration for development machine
View php.ini for development
; For dev only
expose_php=Off
log_errors=On
error_log=/var/log/httpd/php_scripts_error.log
file_uploads=On
;open_basedir="/var/www/html/"
error_reporting = E_ALL
; Should be 'off' on prod server
allow_url_fopen=On
@nd3w
nd3w / linux-commands.txt
Last active Oct 20, 2021
A Collection of Useful Linux Commands
View linux-commands.txt
Backup with bunzip
tar cvfj file.tar.bz2 *
tar cvfj file.tar.bz2 /path/to/directory_to_backup/
Compress multi directories into each own compressed files
for i in */; do zip -r "${i%/}.zip" "$i"; done
for i in */; do tar -czvf "${i%/}.tar.gz" "$i"; done
for i in */; do 7z a "${i%/}.7z" "$i"; done
Untar multiple tarballs using bash for loop
@nd3w
nd3w / gist:ff2b06464121d1aabec7287f37f00d1a
Last active Aug 19, 2019
Linux Aliases to Switch Amongs PHP Versions
View gist:ff2b06464121d1aabec7287f37f00d1a
Assuming I have three different PHP versions on my system:
1. PHP 5.6
2. PHP 7.1
3. PHP 7.2
To switch two between versions, add these aliases into your ~/.bashrc file:
alias php5671='sudo a2dismod php5.6 ; sudo a2enmod php7.1 ; sudo service apache2 restart ; echo 2 | sudo update-alternatives --config php'
alias php5672='sudo a2dismod php5.6 ; sudo a2enmod php7.2 ; sudo service apache2 restart ; echo 3 | sudo update-alternatives --config php'
@nd3w
nd3w / php-snippets.md
Last active Jul 31, 2021
PHP Snippets
View php-snippets.md

Dump all PHP variables

$all_vars = get_defined_vars();
print_r($all_vars);

Create an array for a range (e.g: array with number from 1 to 9)

$number = 9;

for ($i = 1; $i <= $number; ++$i) {