Skip to content

Instantly share code, notes, and snippets.

View mohamedhafezqo's full-sized avatar
😂
CEO of my life, CTO of my localhost, co-founder of my son

Mohamed Hafez mohamedhafezqo

😂
CEO of my life, CTO of my localhost, co-founder of my son
View GitHub Profile

Create a basic Blog

  • Phase 1 (Articles, Comments)

Tech Stack

  • symfony 4.3 skeleton https://symfony.com/releases/4.3

Prerequisites

  • PHP version 7.x
  • Mysql version 5.7 or version 8
  • Composer https://getcomposer.org/
@mohamedhafezqo
mohamedhafezqo / anagram.php
Last active October 13, 2019 23:29
Anagram functions
<?php
// Using built in metod `count_chars`
function isAnagram(string $a, string $b): bool
{
return count_chars(strtolower($a), 1) == count_chars(strtolower($b), 1);
}
// Using array_diff expected $a or $b consists from [a-z]
function isAnagram(string $a, string $b): bool
@mohamedhafezqo
mohamedhafezqo / vichUploaderBundle.md
Created July 10, 2019 10:11
How to install to dustin10/VichUploaderBundle

Installation

Get the bundle using composer

Add VichUploaderBundle by running this command from the terminal at the root of your Symfony project:

composer require vich/uploader-bundle
@mohamedhafezqo
mohamedhafezqo / example.php
Last active March 3, 2024 22:22
GraphQL Client For PHP Using Guzzle
<?php
$endPoint = 'https://api.github.com/graphql';
$query = <<<'GRAPHQL'
query getUsers {
user {
id
name
}
@mohamedhafezqo
mohamedhafezqo / squash-commits.sh
Created October 1, 2018 08:34 — forked from jbub/squash-commits.sh
git squash last two commits into one
git rebase --interactive HEAD~2
# we are going to squash c into b
pick b76d157 b
pick a931ac7 c
# squash c into b
pick b76d157 b
s a931ac7 c
@mohamedhafezqo
mohamedhafezqo / InsightsToRefactor.md
Last active July 1, 2020 09:04
Refactoring Legacy Code

Comments Code Smell

  • Remove unnecessary comments.
  • If the code is obvious, don’t write a comment.
  • Don’t leave commented old code.
  • Remove commented debugging var_dump, dump, echo, ..etc.

Best Practices:

@mohamedhafezqo
mohamedhafezqo / GitAliases.md
Last active November 9, 2021 12:51
My Simply Git Aliases That Make Me Breakthrough

Git Configurations

Command Description
git config --global user.name "firstName lastName" make sure to provide your actual name
git config --global user.email "userName@gmail.com" make sure to provide your actual email address
git config --global color.ui true Display the command-line UI in color
git config --global push.default current When pushing code, always push only your current branch to a branch of the same name
git config --global fetch.prune true Automatically prune deleted branches from your local copy when you fetch (or pull)
git config --global core.autocrlf false Tell git not to mess with your line endings
@mohamedhafezqo
mohamedhafezqo / CreditStatus.php
Last active February 5, 2018 09:45
Code Snippets
<?php
namespace ACM\Bundle\CreditBundle\Constant;
final class CreditStatus implements IConstant
{
const PENDING = 1;
const PENDING_LABEL = 'Pending';
const SUCCESS = 2;