Skip to content

Instantly share code, notes, and snippets.

View ArielMejiaDev's full-sized avatar
🐘
Focusing

ArielMejiaDev ArielMejiaDev

🐘
Focusing
View GitHub Profile
@ArielMejiaDev
ArielMejiaDev / EnumToArray.php
Created July 31, 2024 15:55
Trait to transform Enums to Array for multiple cases
<?php
namespace App\Enums;
trait EnumToArray
{
public static function names(): array
{
return array_column(self::cases(), 'name');
}
@ArielMejiaDev
ArielMejiaDev / ShadcnSimplifiedCombobox.tsx
Created June 14, 2024 16:21 — forked from javierllns/ShadcnSimplifiedCombobox.tsx
A "simplified" "form-like-style" "stylable" version of Shadcn UI combobox examples.
/*
Author: Javier Antonio Llanos Marriaga
Github: @javierllns
LinkedIn: https://www.linkedin.com/in/javierllns/
Portfolio: https://javierllns.github.io/
-
File name: ShadcnSimplifiedCombobox.tsx
Description: A "simplified" "form-like-style" "stylable" version of Shadcn UI combobox examples.
License: MIT
-
@ArielMejiaDev
ArielMejiaDev / massInsertOrUpdate.php
Created June 3, 2024 15:50 — forked from RuGa/massInsertOrUpdate.php
Mass (bulk) insert or update on duplicate for Laravel 4/5
/**
* Mass (bulk) insert or update on duplicate for Laravel 4/5
*
* insertOrUpdate([
* ['id'=>1,'value'=>10],
* ['id'=>2,'value'=>60]
* ]);
*
*
* @param array $rows
@ArielMejiaDev
ArielMejiaDev / PessimistTransaction.php
Created June 1, 2024 03:50 — forked from aslrousta/PessimistTransaction.php
Pessimistic Locking for Transaction
<?php
function transfer($fromAccountId, $toAccountId, $amount)
{
DB::beginTransaction();
try {
$fromQuery = Account::whereId($fromAccountId);
if (! $fromQuery->exists()) {
throw new InvalidAccountException();
@ArielMejiaDev
ArielMejiaDev / OptimisticTransaction.php
Created June 1, 2024 03:41 — forked from aslrousta/OptimisticTransaction.php
Optimistic Locking for Transaction
<?php
function transfer($fromAccountId, $toAccountId, $balance)
{
$fromQuery = Account::whereId($fromAccountId);
if (! $fromQuery->exists()) {
throw new InvalidAccountException();
}
$toQuery = Account::whereId($toAccountId);
@ArielMejiaDev
ArielMejiaDev / form.tsx
Created April 13, 2024 09:17 — forked from Sutil/form.tsx
Shandcn UI Money Mask Input - NextJS.
"use client";
import { zodResolver } from "@hookform/resolvers/zod";
import { useForm } from "react-hook-form";
import MoneyInput from "src/components/custom/money-input";
import { Button } from "src/components/ui/button";
import { Form } from "src/components/ui/form";
import * as z from "zod";
const schema = z.object({
@ArielMejiaDev
ArielMejiaDev / data-table.tsx
Created March 19, 2024 20:46 — forked from nicostombros/data-table.tsx
Shadcn UI implementation of DataTable and Pagination components working together
// same as your regular shadcn datatable implementation (which uses tanstack table)
// note that the shadcn datatable uses shadcn table for the ui. see https://ui.shadcn.com/docs/components/data-table
import {
ColumnFiltersState,
SortingState,
VisibilityState,
flexRender,
getCoreRowModel,
getFilteredRowModel,
@ArielMejiaDev
ArielMejiaDev / build-and-deploy.yml
Created October 10, 2023 22:02 — forked from imlautaro/build-and-deploy.yml
Workflow to deploy a Nuxt 3 app to GitHub Pages with NPM
name: Build and Deploy
on:
push:
branches:
- main
permissions:
contents: write
jobs:
build-and-deploy:
concurrency: ci-${{ github.ref }}
@ArielMejiaDev
ArielMejiaDev / build-and-deploy.yml
Created October 10, 2023 22:02 — forked from imlautaro/build-and-deploy.yml
Workflow to deploy a Nuxt 3 app to GitHub Pages with PNPM
name: Build and Deploy
on:
push:
branches:
- main
permissions:
contents: write
jobs:
build-and-deploy:
concurrency: ci-${{ github.ref }}
const convertToKebabCase = (string) => {
return string.replace(/\s+/g, '-').toLowerCase();
}