Skip to content

Instantly share code, notes, and snippets.

@diaafares
diaafares / hls.sh
Created November 25, 2024 14:55 — forked from stenuto/hls.sh
HLS ffmpeg script
#!/bin/bash
# Function to display usage information
usage() {
echo "Usage: $0 /path/to/input.mp4 [ /path/to/output_directory ]"
exit 1
}
# Check if at least one argument (input file) is provided
if [ $# -lt 1 ]; then
@diaafares
diaafares / CarbonImmutableCaster.php
Created February 10, 2022 21:08 — forked from sebastiaanluca/CarbonImmutableCaster.php
Lazy Laravel Harvest API service
<?php
declare(strict_types=1);
namespace App\DataTransferObjects;
use Carbon\CarbonImmutable;
use Spatie\DataTransferObject\Caster;
class CarbonImmutableCaster implements Caster
@diaafares
diaafares / macro.md
Created December 20, 2020 08:39 — forked from brunogaspar/macro.md
Recursive Laravel Collection Macros

What?

If a nested array is passed into a Laravel Collection, by default these will be threaded as normal arrays.

However, that's not always the ideal case and it would be nice if we could have nested collections in a cleaner way.

This is where this macro comes in handy.

Setup

@diaafares
diaafares / TestCase.php
Created September 13, 2020 07:20 — forked from lepikhinb/TestCase.php
Laravel 8 Model Factory resolver
<?php
namespace Tests;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Str;
use ReflectionClass;
use SplFileInfo;
@diaafares
diaafares / gist:355923ed80c25ef1f352b07f11cf356f
Created September 8, 2020 18:41 — forked from madhurbhaiya/gist:f84dec82b7f36007559a9e0568422338
Obfuscate Auto Increment IDs Laravel Middleware
<?php
namespace App\Http\Middleware;
use Closure;
use Hashids\Hashids;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Str;
<?php
namespace Tests\Traits;
use Illuminate\Support\Facades\DB;
class RefreshDatabaseState
{
public static $hash_algo = 'md5';
@diaafares
diaafares / easing.css
Created October 8, 2019 05:54 — forked from bendc/easing.css
Easing CSS variables
:root {
--ease-in-quad: cubic-bezier(.55, .085, .68, .53);
--ease-in-cubic: cubic-bezier(.550, .055, .675, .19);
--ease-in-quart: cubic-bezier(.895, .03, .685, .22);
--ease-in-quint: cubic-bezier(.755, .05, .855, .06);
--ease-in-expo: cubic-bezier(.95, .05, .795, .035);
--ease-in-circ: cubic-bezier(.6, .04, .98, .335);
--ease-out-quad: cubic-bezier(.25, .46, .45, .94);
--ease-out-cubic: cubic-bezier(.215, .61, .355, 1);
@diaafares
diaafares / SearchThreads.php
Created October 5, 2019 10:40 — forked from driesvints/SearchThreads.php
Multiple method query objects
<?php
namespace App\Queries;
use App\Models\Thread;
use Illuminate\Contracts\Pagination\Paginator;
class SearchThreads
{
public function __construct()
@diaafares
diaafares / SearchThreads.php
Created October 5, 2019 10:40 — forked from driesvints/SearchThreads.php
Invokable query object
<?php
namespace App\Queries;
use App\Models\Thread;
use Illuminate\Contracts\Pagination\Paginator;
class SearchThreads
{
public function __construct()
@diaafares
diaafares / DateInput.vue
Created September 22, 2019 06:12 — forked from reinink/DateInput.vue
Pikaday Vue Component
<template>
<div>
<label v-if="label" class="form-label" :for="`date-input-${_uid}`">{{ label }}:</label>
<input v-bind="$attrs" class="form-input" :id="`date-input-${_uid}`" :class="{ error: error }" type="text" ref="input" :value="value" @change="change" @keyup="change">
<div v-if="error" class="form-error">{{ error }}</div>
</div>
</template>
<script>
import pikaday from 'pikaday'