Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Sérgio Jardim sjardim

🏠
Working from home
View GitHub Profile
@sjardim
sjardim / NavigationComposer.php
Last active March 14, 2023 15:34
A flexible front end navigation build using the Filament admin for Laravel
View NavigationComposer.php
<?php
namespace App\View\Composers;
use Illuminate\View\View;
use RyanChandler\FilamentNavigation\Facades\FilamentNavigation;
class NavigationComposer
{
View diminuir_tamanho_arquivos_mp4.txt
# Salvar num arquivo ~/encode.sh, conceder direito de execução e
# executar desta forma (adaptar nomes de diretórios e arquivos para seu caso):
# $ ~/encode.sh ~/Video/bigFile.mp4 ~/Video/smallFile.mp4
ffmpeg -i "$1" -vcodec h264 -acodec aac "$2"
@sjardim
sjardim / index.php
Created February 8, 2023 12:53
Laravel Meilisearch search with relationships
View index.php
<?php
//https://serversideup.net/advanced-meilisearch-queries-with-laravel-scout/
$customers = Customer::search('Dan')
->query( function( $query ){
$query->with('invoices');
} )->get();
View filament_aggregation_example.php
<?php
namespace App\Filament\Resources\ItemResource\Pages;
use App\Filament\Resources\ItemResource;
use Filament\Resources\Pages\ListRecords;
use Illuminate\Contracts\View\View;
use Illuminate\Support\Facades\DB;
class CustomItemsList extends ListRecords
@sjardim
sjardim / update_meilisearch_index_command.php
Created May 31, 2022 18:10
Laravel command to update Meilisearch's index and filterable attributes
View update_meilisearch_index_command.php
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use MeiliSearch\Client;
use function PHPUnit\Framework\throwException;
class UpdateMeilisearchIndex extends Command
{
@sjardim
sjardim / twill-nested-module-urls.md
Created February 1, 2022 15:25 — forked from chrispymm/twill-nested-module-urls.md
[Support nested urls for nested modules] #twill
View twill-nested-module-urls.md

By default Twill will disply the url of a module item to be {siteurl}/{module}/{slug} e.g. mysite.com/pages/about. With the 'about' section being the editable slug. This is understandable as Twill knows nothing of your frontend routing. However it is likely confusing for editors, as that url presented will not be the final url of the content.

Remove module name form url

This will give us more correct urls e.g. mysite.com/about

// app/Http/Controllers/Admin/PageController

	protected $permalinkBase = '';
@sjardim
sjardim / twill-light-and-dark-mode.css
Last active December 20, 2022 23:57
Light and Dark mode styles for Twill (twill.io) CMS admin
View twill-light-and-dark-mode.css
:root {
--primary-color-hue: 230;
--background-darkest: hsl(var(--primary-color-hue), 70%, 30%);
--background-darker: hsl(var(--primary-color-hue), 20%, 95%);
--background-normal: hsl(var(--primary-color-hue), 70%, 98%);
--background-contrast: hsl(var(--primary-color-hue), 90%, 100%);
--background-highlight: hsl(var(--primary-color-hue), 100%, 98%);
--border-normal: hsl(var(--primary-color-hue), 30%, 90%);
--border-highlight: hsl(var(--primary-color-hue), 100%, 95%);
--body-text-normal: hsl(var(--primary-color-hue), 45%, 55%);
View 00_prefill_block_editor_from_templates_in_twill.md

Prefill a block editor from a selection of templates

Objectives:

  • Create a new module with a template field
  • Prefill the block editor for new items according to the selected template

Requirements:

View get_MP3_tags_and_duration.php
<?php
//Blog post: https://www.hashbangcode.com/article/extracting-data-mp3-php
//USAGE:
//Tested ID3v2.2 and v2.4 and on UTF-8 and UTF-16LE encondings
// $file = 'audio.mp3';
@sjardim
sjardim / ProcessWireValetDriver.php
Created February 10, 2021 11:47 — forked from LostKobrakai/ProcessWireValetDriver.php
ProcessWire Valet Driver
View ProcessWireValetDriver.php
<?php
class ProcessWireValetDriver extends BasicValetDriver
{
private $possibleDirectories = [
'', // PW in root, do not remove except you're sure you never use it
'/dist',
'/public'
];