Skip to content

Instantly share code, notes, and snippets.

View szabacsik's full-sized avatar
🖖

András Szabácsik szabacsik

🖖
View GitHub Profile
@szabacsik
szabacsik / docker-commands.md
Last active March 6, 2024 10:42
Docker Commands

Start MySql database with Apache/PHP and phpMyAdmin

docker run --name mysql -d -e MYSQL_ROOT_PASSWORD=PASSWORD -e MYSQL_ROOT_HOST=% -p 3306:3306 mysql/mysql-server:latest
docker run --name phpmyadmin -d --link mysql:db -p 8080:80 phpmyadmin/phpmyadmin:latest
docker run --name php -d --link mysql:db -p 80:80 php:apache
docker exec php bash -c "echo \"<?php phpinfo();\" >> /var/www/html/index.php"

Stop all running containers

@szabacsik
szabacsik / snapshot.php
Last active December 7, 2023 15:06
MySQL Database Snapshot to CSV Exporter
<?php
/**
* This PHP script creates CSV snapshots of all tables in a specified MySQL database.
* Useful for database analysis and backup purposes. The script connects to the MySQL
* database using PDO, retrieves the list of all tables (excluding specified ones),
* and then exports each table's contents to a CSV file. The CSV files are saved in a
* directory named 'snapshots' inside the script's directory, with each run generating
* a new timestamped subdirectory for organization.
*
@szabacsik
szabacsik / mysql.md
Last active December 1, 2023 09:49
MySQL Cheatsheet

MySQL Cheatsheet

Export Tables

mysqldump -h 127.0.0.1 -u root --password=root --column-statistics=0 SOURCE-DATABASE TABLE-NAME TABLE-NAME | gzip > EXPORT.sql.gz
gunzip < EXPORT.sql.gz | mysql -h 127.0.0.1 -u root --password=root TARGET-DATABASE

Export Database but ignore some tables

@szabacsik
szabacsik / triggers.php
Created November 27, 2023 07:25
MySQL Table Change Logging Trigger Generator Script
<?php
/**
* MySQL Table Change Logging Trigger Generator Script
*
* This script generates triggers for all tables in the $dbname database,
* which log INSERT, UPDATE, and DELETE operations.
* The triggers record modifications in the 'change_log' table,
* storing the name of the affected table, the type of change (INSERT, UPDATE, DELETE),
* the timestamp of the change, and the old and new data of the affected rows in JSON format.
@szabacsik
szabacsik / php.ini
Last active July 20, 2023 09:01
This php.ini contains settings for use in my development environment
; PHP 7
extension = gd2
;https://windows.php.net/downloads/pecl/releases/trader/
;extension = php_trader.dll
; Xdebug 2
zend_extension = php_xdebug.dll
xdebug.remote_port = 9000
xdebug.remote_enable = On
xdebug.remote_autostart = On
@szabacsik
szabacsik / find.md
Last active March 3, 2023 11:13
Bash find files
@szabacsik
szabacsik / php-dbal-orm-query-builder.md
Last active October 18, 2022 15:03
PHP - DBAL / ORM / Query Builder

PHP - DBAL / ORM / Query Builder

Doctrine Query Builder

use Doctrine\DBAL\DriverManager;

require_once __DIR__ . '/vendor/autoload.php';

$connectionParams = [
@szabacsik
szabacsik / user-management.md
Last active May 4, 2022 12:05
User Management

Linux User Management

create group with group id

groupadd -g 1000 johndoe

create user with user id and group id

useradd -m --home /home/johndoe johndoe --uid 1000 --gid 1000 --groups group1,group2,sudo
@szabacsik
szabacsik / compare.md
Created March 22, 2022 14:00
Recursively compare two directories
diff --brief --recursive /path/to/dir1 /path/to/dir2
@szabacsik
szabacsik / centos-php8.md
Created February 17, 2022 10:52
Install or Upgrade PHP 8.1.3 on CentOS 7.9.2009
# yum remove php* -y
yum clean all
yum makecache
yum update -y
yum install dnf -y
dnf upgrade --refresh
yum-config-manager --disable remi-php74
yum-config-manager --enable remi-php81
dnf install php php-cli php-common php-pdo php-xml php-mbstring php-zip php-devel php-curl php-pear php-json php-xdebug -y