Skip to content

Instantly share code, notes, and snippets.

View AhmedHelalAhmed's full-sized avatar
📱
Learning and developing

Ahmed Helal AhmedHelalAhmed

📱
Learning and developing
View GitHub Profile
@AhmedHelalAhmed
AhmedHelalAhmed / swagger doc for laravel.txt
Last active July 12, 2018 09:35
swagger doc for laravel
/**
* @SWG\Get(
* path="/create",
* description="Return a user's first and last name",
* @SWG\Parameter(
* name="firstname",
* in="query",
* type="string",
* description="Your first name",
* required=true,
@AhmedHelalAhmed
AhmedHelalAhmed / http-status-codes.md
Created July 11, 2018 15:08 — forked from subfuzion/http-status-codes.md
General REST API HTTP Status Codes

Reference: RFC 2616 - HTTP Status Code Definitions

General

  • 400 BAD REQUEST: The request was invalid or cannot be otherwise served. An accompanying error message will explain further. For security reasons, requests without authentication are considered invalid and will yield this response.
  • 401 UNAUTHORIZED: The authentication credentials are missing, or if supplied are not valid or not sufficient to access the resource.
  • 403 FORBIDDEN: The request has been refused. See the accompanying message for the specific reason (most likely for exceeding rate limit).
  • 404 NOT FOUND: The URI requested is invalid or the resource requested does not exists.
  • 406 NOT ACCEPTABLE: The request specified an invalid format.
https://restfulapi.net/http-status-codes/
https://gist.github.com/AhmedHelalAhmed/1e6da9aafe393b113b0cb87de3abc78a
https://restfulapi.net/http-status-codes/
https://en.wikipedia.org/wiki/List_of_HTTP_status_codes
https://www.restapitutorial.com/httpstatuscodes.html
==================================
https://medium.com/scrumpy/quick-tip-using-http-status-codes-with-laravel-api-resources-140628398257
https://laravel.com/docs/5.6/responses
https://stackoverflow.com/questions/47311980/laravel-eloquent-resources-api-send-status-code
http://esbenp.github.io/2017/01/14/modern-rest-api-laravel-part-3/
@AhmedHelalAhmed
AhmedHelalAhmed / conditional-function.php
Created July 14, 2018 11:49 — forked from amaelftah/conditional-function.php
extracting conditions to meaningful functions
<?php
if (
$employee['age'] < '40'
&& $employee['medical_health'] == 'healthy'
&& $employee ['work_happits'] != 'bad'
)
{
// do somethings
@AhmedHelalAhmed
AhmedHelalAhmed / bashrc.txt
Last active July 17, 2018 07:45
Bashrc - Ubuntu
Use the following command on msysgit
. ~/.bashrc
shorter version of
source ~/.bashrc
@AhmedHelalAhmed
AhmedHelalAhmed / vh.bash
Last active July 18, 2018 07:50
Bash script to make the virtual host for Ubuntu and apache2 with document root the current path
#! /bin/bash
vh_name=$1;
curent_path=`pwd`
file_name_path='/tmp/'$vh_name'.conf'
#to generate the conf file in /tmp
printf "<VirtualHost *:80>\n" >/tmp/$vh_name.conf
printf " ServerAlias ${vh_name}\n" >>/tmp/$vh_name.conf
printf " ServerName ${vh_name}\n" >>/tmp/$vh_name.conf
printf " DocumentRoot ${curent_path}\n" >>/tmp/$vh_name.conf
@AhmedHelalAhmed
AhmedHelalAhmed / ExamplePassportTest.php
Created August 5, 2018 11:23 — forked from archy-bold/ExamplePassportTest.php
Testing Passport Authenticated Controllers and Routes in Laravel
<?php
use Illuminate\Foundation\Testing\WithoutMiddleware;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\DatabaseTransactions;
class ExamplePassportTest extends \PassportTestCase
{
use DatabaseTransactions;
@AhmedHelalAhmed
AhmedHelalAhmed / PhotoApiTest.php
Created August 6, 2018 11:46 — forked from JeffreyWay/PhotoApiTest.php
Testing APIs in Laravel. Thoughts?
<?php
class PhotoApiTest extends TestCase {
public function setUp()
{
parent::setUp();
Route::enableFilters();
@AhmedHelalAhmed
AhmedHelalAhmed / gist:d8661d1f135b2957be1744388342f2ee
Created August 6, 2018 16:44 — forked from damir-bubanovic/gist:d67d54b2c19aa233f51f63b3d9f0f4be
Laravel 5 - create fake data with $faker & populate database
<?php
/**
* SEEDING DATABASE
*
* Faker Fileds:
* https://github.com/fzaninotto/Faker
*
* 1) Create database, model, migration
* 2) artisan make:seeder
@AhmedHelalAhmed
AhmedHelalAhmed / git.migrate
Created August 10, 2018 19:06 — forked from niksumeiko/git.migrate
Moving git repository and all its branches, tags to a new remote repository keeping commits history
#!/bin/bash
# Sometimes you need to move your existing git repository
# to a new remote repository (/new remote origin).
# Here are a simple and quick steps that does exactly this.
#
# Let's assume we call "old repo" the repository you wish
# to move, and "new repo" the one you wish to move to.
#
### Step 1. Make sure you have a local copy of all "old repo"
### branches and tags.