Skip to content

Instantly share code, notes, and snippets.

View HazemNoor's full-sized avatar

Hazem Noor HazemNoor

View GitHub Profile

Keybase proof

I hereby claim:

  • I am hazemnoor on github.
  • I am hazemnoor (https://keybase.io/hazemnoor) on keybase.
  • I have a public key ASC_DNqp3aU7PvWvUc-VAeFBeYoB7G2NakMB4Cd_G9u8ngo

To claim this, I am signing this object:

@HazemNoor
HazemNoor / createFormRequest.php
Last active December 12, 2022 09:53
Laravel helper to create a FormRequest from a Request object
<?php
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Http\Request;
use Illuminate\Routing\Redirector;
if (!function_exists('createFormRequest')) {
/**
* Create a FormRequest from a Request object
*
@HazemNoor
HazemNoor / experiment.php
Created August 28, 2021 11:23
Choose a variation from a weighted experiment
<?php
/**
* Choose a variation from a weighted experiment
* This can be used in A/B testings, in case you need to take a sample of users and apply certain feature on them
*/
function getRandomVariation(array $experiment): string
{
$weightedVariations = [];
@HazemNoor
HazemNoor / json_get.php
Last active August 28, 2021 11:02
Function to check if a string is valid json string and return data if valid or false otherwise
<?php
/**
* Check if a string is valid json string and return data if valid or false otherwise
*
* @params Same as json_decode args
*
* @return false|mixed
*/
function json_get()