Skip to content

Instantly share code, notes, and snippets.

@AmrMekkawy
AmrMekkawy / index.php
Last active December 29, 2021 16:38
Factory Method Design Pattern - Conceptual Example in PHP
<?php
# Source: https://refactoring.guru/design-patterns/factory-method/php/example#example-0
namespace RefactoringGuru\FactoryMethod\Conceptual;
/**
* The Creator class declares the factory method that is supposed to return an
* object of a Product class. The Creator's subclasses usually provide the
* implementation of this method.
@AmrMekkawy
AmrMekkawy / DTFromID.java
Created November 15, 2021 13:27 — forked from Zelakolase/DTFromID.java
National ID to get data from
import java.util.HashMap;
public class DTFromID {
static HashMap<String, String> GovIDMap = new HashMap<String, String>(){
{
put("01","Cairo"); put("02","Alexandria"); put("03","Portsaid"); put("04","Suez"); put("11","Damietta"); put("12","Daqahlia"); put("13","Sharkia"); put("14","Qalyobia"); put("15","Kafr El-sheikh");
put("16","Gharbia"); put("17","Monufia"); put("18","Beheira"); put("19","Ismailia"); put("21","Giza"); put("22","Bani Suef"); put("23","Fayum"); put("24","Menya"); put("25","Asuit");
put("27","Qena"); put("28","Aswan"); put("29","Luxor"); put("31","Red Sea"); put("32","Alwady Algaded"); put("33","Matrouh"); put("34","North Sinai"); put("35","South Sinai"); put("88","N/A");
}
};
@AmrMekkawy
AmrMekkawy / pivot-tables.md
Created October 29, 2020 10:18 — forked from Braunson/pivot-tables.md
Laravel 8.x - Diving into Pivot Tables

Laravel 6 - Diving Into Pivot Tables

Pivot tables can be confusing and a little hard to wrap your head around at first. In this quick article we are going to dive into what a pivot table is, how to create one and finally how to use the pivot table. Let's dive in!

What is a pivot table?

A pivot table is used to connect relationships between two tables. Laravel provides a Many To Many relationship where you can use a pivot table.

@AmrMekkawy
AmrMekkawy / deployment_guide.md
Created April 24, 2020 14:34 — forked from vicgonvt/deployment_guide.md
Deployment Guide for Ubuntu Server from Scratch with Laravel
@AmrMekkawy
AmrMekkawy / egypt.md
Last active December 20, 2018 12:24
Egypt's administrative areas level 1 & 2

Egypt - مصر


القاهرة

  1. 15 مايو
  2. الازبكيه
  3. الاميريه
  4. البساتين
@AmrMekkawy
AmrMekkawy / connectAndPrint.js
Created December 11, 2018 10:29 — forked from tresf/connectAndPrint.js
Connect and print
function connectAndPrint() {
// our promise chain
connect().then(function() {
return print();
}).then(function() {
success(); // exceptions get thrown all the way up the stack
}).catch(fail); // so one catch is often enough for all promises
// NOTE: If a function returns a promise, you don't need to wrap it in a fuction call.
// The following is perfectly valid:
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs/Observable';
import 'rxjs/add/observable/fromPromise';
import 'rxjs/add/observable/throw';
import 'rxjs/add/operator/map';
declare var qz: any;
@AmrMekkawy
AmrMekkawy / angular.md
Last active February 16, 2019 16:31
Hints about Angular framework

Angular


Make sure you have Node.js installed on your computer first.


Check if Angular is installed on your computer

@AmrMekkawy
AmrMekkawy / how-to-install-momentjs-and-use-it-in-an-ionic-app.md
Last active October 12, 2018 00:47
How to install moment package and use it in an Ionic typescript file and view (html) file?

How to install moment package and use it in an Ionic app?

This is a simple guide about how to install moment package and use it in an Ionic app, in both typescript files and view (html) files.

Install moment package

npm install moment --save-prod
@AmrMekkawy
AmrMekkawy / rules-to-write-better-commit-messages.md
Created September 5, 2018 11:20 — forked from medhatdawoud/rules-to-write-better-commit-messages.md
This gist is the summary of a video on YouTube [in Arabic] you can watch from here: https://youtu.be/BTlL-LBDCSI

Rules to write a better commit message

These are my preferences for a good commit message, feel free to fork this gist and add your own standards, or add comment here to share yours with the community.

1. Include only the files related to the feature you are implementing:

  • Don't add any file that is not related to the main issue, you can make it in a separate commit.
  • Separating files that not related is important in the revert cases.
  • Revise the whole changes always before committing and make sure to mention each change you made in the message.

2. Commit subject should be concise and reflect the essence of the commit:

  • Imagine the commit as an Email to the owner or your team mates.
  • Subject in the first and main sentence of the commit, it should be concise and to the point.
  • It shouldn't exceed 50 char.