Skip to content

Instantly share code, notes, and snippets.

View sawirricardo's full-sized avatar
👋

Ricardo Sawir sawirricardo

👋
View GitHub Profile
@Geczy
Geczy / migrate.sh
Last active November 14, 2024 14:25
Migrate Coolify to a new server
#!/bin/bash
# This script will backup your Coolify instance and move everything to a new server. Docker volumes, Coolify database, and ssh keys
# 1. Script must run on the source server
# 2. Have all the containers running that you want to migrate
# Configuration - Modify as needed
sshKeyPath="$HOME/.ssh/your_private_key" # Key to destination server
destinationHost="server.example.com"
@adtac
adtac / Dockerfile
Last active November 1, 2024 03:05
#!/usr/bin/env docker run
#!/usr/bin/env -S bash -c "docker run -p 8080:8080 -it --rm \$(docker build --progress plain -f \$0 . 2>&1 | tee /dev/stderr | grep -oP 'sha256:[0-9a-f]*')"
# syntax = docker/dockerfile:1.4.0
FROM node:20
WORKDIR /root
RUN npm install sqlite3
@hotmeteor
hotmeteor / ApaTitle.php
Created January 3, 2024 22:16
Laravel APA title case macro
<?php
namespace App\Providers\Macros;
class ApaTitle
{
public function __invoke()
{
return function ($string) {
// Define minor words to be lowercase
@keepanitreel
keepanitreel / select-action.php
Created December 29, 2023 01:27
FilamentPHP Select Input Actions for removing all / adding all in a Multiple Select input
/**
* Credit Sandro Gehri
* https://twitter.com/gehrisandro
*/
use Filament\Forms\Components\Select;
use Filament\Forms\Components\Actions\Action;
Select::make('foo')
->options(['read','write','execute'])
@fabiolimace
fabiolimace / uuid.js
Last active November 11, 2024 08:36
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 November 28, 2023 11:23
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.