Skip to content

Instantly share code, notes, and snippets.

View sawirricardo's full-sized avatar
👋

Ricardo Sawir sawirricardo

👋
View GitHub Profile
<?php
namespace App\Console\Commands\Concerns;
use React\EventLoop\Loop;
trait RunsLoop
{
protected function loop(callable $callback, float $interval, float $lifetime): void
{
{
"indentSize": 4,
"wrapAttributes": "auto",
"wrapLineLength": 200,
"endWithNewLine": true,
"endOfLine": "LF",
"useTabs": false,
"sortTailwindcssClasses": true,
"sortHtmlAttributes": "none",
"noMultipleEmptyLines": true,
@RohmanBenyRiyanto
RohmanBenyRiyanto / Flutter Custom Tickets using Clip Path.dart
Last active February 24, 2025 08:47
Create a custom ticket card display in flutter
class CustomTicket extends CustomClipper<Path> {
@override
Path getClip(Size size) {
final path = Path();
//Radius
path.addRRect(
RRect.fromRectAndRadius(
Rect.fromLTWH(0, 0, size.width, size.height),
const Radius.circular(8),
),
@jacob-ebey
jacob-ebey / deferred-overview.md
Last active February 28, 2025 05:42
Deferred Overview

Remix Deferred

Remix Deferred is currently implemented on top of React's Suspense model but is not limited to React. This will be a quick dive into how "promise over the wire" is accomplished.

SSR + Hydration

It isn't rocket science, but a quick recap of how frameworks such as react do SSR:

  1. Load data
  2. Render the app
# Script for converting a HF Diffusers saved pipeline to a Stable Diffusion checkpoint.
# *Only* converts the UNet, VAE, and Text Encoder.
# Does not convert optimizer state or any other thing.
# Written by jachiam
import argparse
import os.path as osp
import torch
@aneesdev
aneesdev / EnhancedEnum.php
Created September 19, 2022 18:59
EnhancedEnum PHP trait
<?php
trait EnhancedEnum
{
/**
* Get the enum value from the name. e.g case INVOICE = 'invoice'; will return 'invoice'
*
* @param string $name
* @return static
*/
@claudiodekker
claudiodekker / megapint.sh
Created June 22, 2022 22:48
Opinionated Laravel Pint alias. Prefers a repo-specific version of pint over a globally-installed one, and defaults to use the Laravel preset.
megapint() {
PINT=$([ -f "vendor/bin/pint" ] && echo "vendor/bin/pint" || echo "pint")
"$PINT" --preset laravel $@
}
<div {{ $attributes }} wire:ignore x-data="{
signaturePadId: $id('signature'),
signaturePad: null,
signature: @entangle($attributes->get('wire:model')),
ratio: null,
init() {
this.resizeCanvas();
this.signaturePad = new SignaturePad(this.$refs.canvas);
if (this.signature) {
this.signaturePad.fromDataURL(this.signature, { ratio: this.ratio });
@valorin
valorin / .env.example
Last active December 24, 2024 18:18
CSP Middleware - the simple CSP middleware I use across all of my projects.
# Add to your .env.example and .env files
CSP_ENABLED=true
CSP_REPORT_ONLY=true
@bezhanSalleh
bezhanSalleh / UniqueJsonRule.php
Created February 27, 2022 14:49
A Rule to validate the uniqueness of json translated fields
<?php
namespace App\Rules;
use Illuminate\Support\Facades\DB;
use Illuminate\Contracts\Validation\Rule;
class UniqueJsonRule implements Rule
{
protected ?string $ignoreColumn = null;