Skip to content

Instantly share code, notes, and snippets.

View moaalaa's full-sized avatar

Mohamed Alaa El-Din moaalaa

View GitHub Profile
@moaalaa
moaalaa / 01 - my.cnf
Created July 20, 2023 13:59
Enhance MySql Importing Config
# Path
# /etc/mysql/mycnf
# ...
[mysqld]
innodb_buffer_pool_size = 4G
innodb_log_buffer_size = 256M
innodb_log_file_size = 1G
innodb_write_io_threads = 16
@moaalaa
moaalaa / .htaccess
Created July 17, 2023 18:47
My lovely .htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
# Get Match After www. and access it by %1
# EX: (www.domain.com) will match (domain.com) without www.
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
# Redirect our match %1 (domain.com) with 301 and to HTTPS to not run next HTTPS rule
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
@moaalaa
moaalaa / php.default.ini
Last active January 18, 2024 02:28
cPanel php ini file limit
display_errors = Off
max_execution_time = 60
max_input_time = 120
max_input_vars = 1000
memory_limit = 256M
post_max_size = 128M
session.gc_maxlifetime = 1440
session.save_path = "/var/cpanel/php/sessions/ea-php82"
upload_max_filesize = 10M
zlib.output_compression = Off
@moaalaa
moaalaa / 01 - filesystems.php
Last active May 13, 2023 16:05
laravel Translation With Inerja js for persona =l porposes only
<?php
/**
* @see https://dariot.medium.com/how-to-translate-laravel-with-inertia-c34c7284544e
*/
/*
Edit config/filesystems.php
Add ‘languages’ disk so you can easily use Laravel’s Storage to access ‘resources/lang’ folder where your languages reside.
@moaalaa
moaalaa / CopyModel.php
Last active July 14, 2024 08:32
Helper Command to Copy and Delete Laravel Model Data
<?php
namespace MixCode\Console\Commands;
use Illuminate\Console\Command;
use Illuminate\Support\Composer;
use Illuminate\Support\Facades\File;
use Str;
class CopyModel extends Command

IMPORTANT: do NOT delete ibdata1 file. You could destroy all your databases.

Instead, first try using the MySQL backup folder which is included with XAMPP. So do next steps:

  1. Rename folder mysql/data to mysql/data_old
  2. Make a copy of mysql/backup folder and name it as mysql/data
  3. Copy all your database folders from mysql/data_old into mysql/data (except mysql, performance_schema, and phpmyadmin folders)
  4. Copy mysql/data_old/ibdata1 file into mysql/data folder
  5. restart xampp server
@moaalaa
moaalaa / web.config
Last active February 1, 2023 20:11
Laravel .htaccess - apache but for web.config - IIS
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<handlers accessPolicy="Read, Execute, Script">
<clear />
<add name="Perl via ISAPI (*.cgi)" path="*.cgi" verb="GET,HEAD,POST,DEBUG" type="" modules="IsapiModule" scriptProcessor="C:\Program Files\PHP\php-cgi.exe" resourceType="File" requireAccess="Script" preCondition="" />
<add name="Perl via ISAPI (*.pl)" path="*.pl" verb="GET,HEAD,POST,DEBUG" type="" modules="IsapiModule" scriptProcessor="C:\Program Files\PHP\php-cgi.exe" resourceType="File" requireAccess="Script" preCondition="" />
<add name="ASPClassic (*.htr)" path="*.htr" verb="GET,HEAD,POST,DEBUG" type="" modules="IsapiModule" scriptProcessor="C:\Windows\system32\inetsrv\asp.dll" resourceType="File" requireAccess="Script" preCondition="" />
<add name="ASPClassic (*.cdx)" path="*.cdx" verb="GET,HEAD,POST,DEBUG" type="" modules="IsapiModule" scriptProcessor="C:\Windows\system32\inetsrv\asp.dll" resourceType="Fi
@moaalaa
moaalaa / ChatRoomMessages.php
Created October 19, 2022 11:54
ChatBase with livewire
<?php
namespace MixCode\Http\Livewire\Chats;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Http\Response;
use Livewire\Component;
use Livewire\WithPagination;
use MixCode\ChatRoom;
use MixCode\Events\SendMessageToChatRoom;
# Get All Files with begans with 'wp-' and extension .php
find . -name "wp-*.php"
# Get All Files with extension .php
find . -name "*.php"
# Delete All Files with extension .php
find . -name "*.php" -type f -delete
@moaalaa
moaalaa / get-orders-by-year.php
Created April 6, 2022 08:45
Get Orders by Year/Month
<?php
// $orders_per_year = DB::select(
// "SELECT
// MONTH(created_at) as month,
// COUNT(*) as count
// FROM orders
// WHERE YEAR(created_at) = {$current_year}
// GROUP BY MONTH(created_at)
// ORDER BY MONTH(created_at) ASC"