Skip to content

Instantly share code, notes, and snippets.

@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.
@AmrMekkawy
AmrMekkawy / functions.php
Created August 27, 2018 15:30
Force download a file with PHP
<?php
/**
* Force Download
*
* Generates headers that force a download to happen
* Example usage:
* force_download( 'screenshot.png', './images/screenshot.png' );
*
* Source: https://goo.gl/fhTaW4
@AmrMekkawy
AmrMekkawy / how-to-use-npm.md
Last active August 29, 2018 12:27
How to use npm (Node Package Manager)?

How to use npm (Node Package Manager)?


# Go to your project directory
$ cd /path/to/your/project/directory

@AmrMekkawy
AmrMekkawy / typescript-tips-and-tricks.md
Last active April 29, 2018 03:53
TypeScript Tips & Tricks

TypeScript Tips & Tricks


How to setup a workspace for your TypeScript project?

# Go to the root of you project
cd /d/path/to/your/project/directory/
@AmrMekkawy
AmrMekkawy / toggle-password-visibility.js
Last active February 23, 2018 03:35
Toggle Password Visibility
/**
* If the password input in your form has the name "password", then
* you only need to pass the form object to the function.
* But if your password input has a name other than "password", then you need to add
* a class for it and pass that class name to the function with the form object.
*/
function togglePasswordVisibility($form, passwordInputClass) {
var x;
// If the user gave the password input a class name and passed it to the function
@AmrMekkawy
AmrMekkawy / laravel-naming-conventions.md
Last active January 4, 2018 20:05
Laravel Naming Conventions & Best Practices
@AmrMekkawy
AmrMekkawy / how-to-access-your-project-files-and-folders-through-vagrant.md
Last active January 6, 2019 06:57
How to access your project's files and folders through Vagrant?

How to access your project's files and folders through Vagrant?

# Go to the root of your project
cd /path/to/your/project/root

# Enter vagrant
vagrant ssh

# Access the project's files and folders
@AmrMekkawy
AmrMekkawy / how-to-access-mysql-through-vagrant.md
Last active January 1, 2018 22:58
How to access MySQL through Vagrant?

How to access MySQL through Vagrant?

# Go to the root of your project
cd /path/to/your/project/root

# Enter vagrant
vagrant ssh

# Access MySQL
@AmrMekkawy
AmrMekkawy / make-text-field-accepts-only-digits.js
Last active October 6, 2017 00:00
Make a text field accepts only digits
$(function() {
// Remove any character or symbole and keep only
// numbers in the "Reference Number" input field
$("input[type=text]").on("keyup keydown", function() {
var refNumber = keepOnlyNumbers($(this).val());
$(this).val(refNumber);
});
});
// Remove any character or symbol withen

Typing vagrant from the command line will display a list of all available commands.

Be sure that you are in the same directory as the Vagrantfile when running these commands!

Common Vagrant Commands

  • vagrant up -- starts vagrant environment (also provisions only on the FIRST vagrant up)
  • vagrant status -- outputs status of the vagrant machine
  • vagrant halt -- stops the vagrant machine
  • vagrant reload -- restarts vagrant machine, loads new Vagrantfile configuration
  • vagrant provision -- forces reprovisioning of the vagrant machine