Skip to content

Instantly share code, notes, and snippets.

View sawirricardo's full-sized avatar
👋

Ricardo Sawir sawirricardo

👋
View GitHub Profile
@fabiolimace
fabiolimace / uuid.js
Last active March 20, 2025 17:45
No Dependency / Do It Yourself / You Know What You Are Doing UUID generator for Javascript
const v4 = () => {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
const r = Math.trunc(Math.random() * 16);
const v = c == 'x' ? r : (r & 0x3 | 0x8);
return v.toString(16);
});
}
const v7 = () => {
return 'tttttttt-tttt-7xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
@MrPunyapal
MrPunyapal / GenerateUniqueSlug.php
Created November 29, 2023 16:40
Efficient Laravel Slug Generation: Unique, Sleek, and No Looping 🚀
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\DB;
class Blog extends Model
{
@MrPunyapal
MrPunyapal / PostList.php
Created November 20, 2023 15:53
Optimized Load More Laravel livewire
<?php
namespace App\Livewire;
use App\Models\Post;
use Livewire\Component;
class PostList extends Component
{
public $offset = 0;
@giorgospat
giorgospat / EndlessLazyColumn.kt
Created November 13, 2023 22:36
Jetpack Compose component for endless vertical list
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.LazyListState
import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.derivedStateOf
import androidx.compose.runtime.getValue
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
@MrPunyapal
MrPunyapal / BelongsToTeam.php
Last active March 20, 2025 07:02
Enhance Laravel Access Control with 'BelongsToTeam' Trait: Simplify Team-Based Permissions
<?php
namespace App\Traits\Models;
use App\Models\Team;
use Illuminate\Database\Eloquent\Builder;
trait BelongsToTeam
{
// This method is executed when a new model is being created.
@aniket-magadum
aniket-magadum / 2023_11_01_025054_create_http_logs_table.php
Last active December 16, 2023 21:22
Laravel Logging Http Client Request and Response
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
@nathandaly
nathandaly / BaseResource.php
Last active May 1, 2025 19:15
Tenancy for Laravel & Filament V3 (Tenant per database)
<?php
/**
* Below is an the extended Filament resource your tenant panel resources
* will have to extend so that the queries are scoped properly.
*/
namespace App\Filament;
use Filament\Resources\Resource;
@awcodes
awcodes / NowAction.php
Created August 18, 2023 21:19
NowAction
<?php
namespace ...
use Filament\Forms\Components\Actions\Action;
use Filament\Forms\Components\DateTimePicker;
use Filament\Forms\Set;
class NowAction extends Action
{