Skip to content

Instantly share code, notes, and snippets.

View abdelmoujoudaza's full-sized avatar

Abdelmoujoud Azafad abdelmoujoudaza

View GitHub Profile
@abdelmoujoudaza
abdelmoujoudaza / Calisthenics.md
Created October 3, 2020 13:12 — forked from bobuss/Calisthenics.md
The 9 Rules of Object Calisthenics

Object Calisthenics outlines 9 basic rules to apply when performing the exercise:

  • One level of indentation per method.
  • Don't use the ELSE keyword.
  • Wrap all primitives and Strings in classes.
  • First class collections.
  • One dot per line.
  • Don't abbreviate.
  • Keep all classes less than 50 lines.
  • No classes with more than two instance variables.
@abdelmoujoudaza
abdelmoujoudaza / rules-to-write-better-commit-messages.md
Created September 15, 2020 21:07 — 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.
@abdelmoujoudaza
abdelmoujoudaza / Setting_upa_new_repo.md
Created September 5, 2020 20:17 — forked from alexpchin/Setting_upa_new_repo.md
Create a new repository on the command line

Setting up a new Git Repo

##Create a new repository on the command line

touch README.md
git init
git add README.md
git commit -m "first commit"

git remote add origin git@github.com:alexpchin/.git

<?php
use Illuminate\Database\Seeder;
class PostTagTableSeeder extends Seeder
{
/**
* @var
*/
private $pivotData = [];
@abdelmoujoudaza
abdelmoujoudaza / HasSearch.php
Created April 10, 2020 01:51 — forked from SalemCode8/HasSearch.php
Add Search for Laravel ORM
<?php
namespace App\Traits;
use Illuminate\Database\Eloquent\Builder;
/**
* Trait Searchable
@abdelmoujoudaza
abdelmoujoudaza / gist:b23d56f9b751c2160ba97cd84f295fd9
Created February 27, 2020 11:05 — forked from hissy/gist:7352933
[WordPress] Add file to media library programmatically
<?php
$file = '/path/to/file.png';
$filename = basename($file);
$upload_file = wp_upload_bits($filename, null, file_get_contents($file));
if (!$upload_file['error']) {
$wp_filetype = wp_check_filetype($filename, null );
$attachment = array(
'post_mime_type' => $wp_filetype['type'],
'post_parent' => $parent_post_id,
<?php
/**
* Insert an attachment from an URL address.
*
* @param String $url
* @param Int $parent_post_id
* @return Int Attachment ID
*/
function crb_insert_attachment_from_url($url, $parent_post_id = null) {