Skip to content

Instantly share code, notes, and snippets.

View m-alghobary's full-sized avatar
🤖
Coding

Mohamed Alghobary m-alghobary

🤖
Coding
View GitHub Profile
@t3dotgg
t3dotgg / try-catch.ts
Last active December 10, 2025 16:45
Theo's preferred way of handling try/catch in TypeScript
// Types for the result object with discriminated union
type Success<T> = {
data: T;
error: null;
};
type Failure<E> = {
data: null;
error: E;
};
@m-alghobary
m-alghobary / AppServiceProvider.php
Created August 29, 2022 05:46
A Laravel macro that adds a 'sync' method to the 'HasMany' relationship similar to the one on the 'BelongsTo' relationship.
<?php
namespace App\Providers;
use Illuminate\Support\Arr;
use Illuminate\Support\ServiceProvider;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Relations\HasMany;
class AppServiceProvider extends ServiceProvider
<?php
/**
* Description of VideoStream
*
* @author Rana
* @link http://codesamplez.com/programming/php-html5-video-streaming-tutorial
*/
class VideoStream
{
private $path = "";
@vluzrmos
vluzrmos / App_Http_VideoStream.php
Last active October 22, 2024 21:47
Laravel VideoStream.
<?php
namespace App\Http;
/**
* Description of VideoStream
*
* @author Rana
* @link https://gist.github.com/vluzrmos/d5682ad426525196d069
*/