Skip to content

Instantly share code, notes, and snippets.

View aftandilmmd's full-sized avatar
🏠
Working from home

Aftandil MMD aftandilmmd

🏠
Working from home
View GitHub Profile
@aftandilmmd
aftandilmmd / wire-model-select2.js
Created December 13, 2025 19:25
Alpine.js Custom Directive for Select2 ↔ Livewire wire:model Sync
// app.js
document.addEventListener("alpine:init", () => {
Alpine.directive("wire-model-select2", (el, { expression }, { evaluate, cleanup }) => {
const property = expression;
$(el).select2();
const changeHandler = () => {
const livewireComponent = Livewire.find(el.closest('[wire\\:id]').getAttribute('wire:id'));
@aftandilmmd
aftandilmmd / livewire-alpinejs-sort-records.blade.php
Created October 27, 2025 09:10
Livewire + Alpinejs: Sort Records
<?php
use Livewire\Attributes\Computed;
use Livewire\Volt\Component;
use Spatie\MediaLibrary\MediaCollections\Models\Media;
new class extends Component {
#[Computed]
public function medias()
@aftandilmmd
aftandilmmd / infinite-scroll.php
Created August 8, 2025 12:44
Livewire Volt - Performant Infinite Scroll
<?php
use App\Models\User;
use Livewire\Attributes\Renderless;
use Livewire\Volt\Component;
new class extends Component {
#[Renderless]
public function loadMore($skip = 0): void
@aftandilmmd
aftandilmmd / Tailwindcssunreset.scss
Created January 13, 2023 07:50 — forked from swyxio/Tailwindcssunreset.scss
Tailwind CSS Un-Reset - un-reset Tailwind's Preflight CSS Reset so that autogenerated HTML looks consistent with the rest of your Tailwind site. - https://www.swyx.io/writing/tailwind-unreset
.unreset {
a {
@apply text-blue-700 underline;
}
p {
@apply my-4;
}
blockquote,
figure {
@aftandilmmd
aftandilmmd / screen-recording.html
Created September 1, 2021 07:47
You can record your screen and down that recording as webm file
<!DOCTYPE html>
<html>
<head>
<title>Screen Recording && Downloading .webm</title>
<meta charset="UTF-8" />
<style>
body {
text-align: center;
}