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 / AppServiceProvider.php
Created December 8, 2020 11:45 — forked from simonhamp/AppServiceProvider.php
A pageable Collection implementation for Laravel
<?php
namespace App\Providers;
use Illuminate\Support\Collection;
use Illuminate\Pagination\LengthAwarePaginator;
class AppServiceProvider extends ServiceProvider
{
public function boot()
sudo chown -R $USER:$USER /var/www
<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 / mysql import and export.sh
Last active June 9, 2021 09:16
CLI Commands Help me in my daily life
# Import
mysql --init-command="SET SESSION FOREIGN_KEY_CHECKS=0;" -u root --password= [database_name] < database.sql
# Export Full Structure and Data
mysqldump -u root --password= [database_name] > database.sql
# Export Structure
mysqldump --no-data [or -d] -u root --password= [database_name] > database.sql
# Export Data
@moaalaa
moaalaa / Trigger HTML Native Errors.html
Created September 24, 2020 08:41
javaScript Codes helping me during my work
<form id="form-check">
<input type="text" required/>
<button type="submit"> Submit </button>
</form>
<script>
var form = document.querySelector('#form-check');
var button = document.querySelector('button');
@moaalaa
moaalaa / Match English and Arabic Chars and whitespaces.sh
Created August 11, 2020 06:10
My Regex that i have been used in some situations
# Regex
/^[a-zA-Z\u0621-\u064A\s]+$/gu
# Mohamed Alaa ElDin -> work
# محمد علاء الدين -> work
# mohamed علاء الدين -> work
@moaalaa
moaalaa / cmder_aliases.cmd
Created January 10, 2020 04:49
Aliases Version For Windows
pu=phpunit
puf=phpunit --filter
g=git $*
gi=git init
ga=git add $*
gaa=git add .
gc=git commit -m $*
gac=git add . && git commit -m $*
wip=git add . && git commit -m 'WIP'
@moaalaa
moaalaa / node_nginx_ssl.md
Created September 23, 2019 19:34 — forked from bradtraversy/node_nginx_ssl.md
Node app deploy with nginx & SSL

Node.js Deployment

Steps to deploy a Node.js app to Digital Ocean using PM2, NGINX as a reverse proxy and an SSL from LetsEncrypt

1. Sign up for Digital Ocean

If you use the referal link below, you get $10 free (1 or 2 months) https://m.do.co/c/5424d440c63a

2. Create a droplet and log in via ssh

I will be using the root user, but would suggest creating a new user

@moaalaa
moaalaa / bluehost-php-7.2-correct-path-with-aliases.sh
Last active May 12, 2022 10:10
fix bluehost diffrent php version in terminal by using aliases
# Paths may change it's not spicific for bluehost but paths are change paths ith your paths
# make php 7.4 alias to not conflict with php original excutable file
alias php74="/opt/cpanel/ea-php74/root/usr/bin/php"
# make new alise for composer excutable file with our new php 7.2 alias
alias com="php74 /opt/cpanel/composer/bin/composer"
# run and try it
com
@moaalaa
moaalaa / Auto Generate Spacing Classes.scss
Last active July 25, 2019 11:12
Auto Generate Spacing Classes
// Define Different Sizes
$sizes: (
('none', 0),
('1', 0.25),
('2', 0.5),
('3', 0.75),
('4', 1),
('5', 1.25),
('6', 1.5),
('7', 2),