Skip to content

Instantly share code, notes, and snippets.

@pierodev0
pierodev0 / todo-reducer.ts
Created August 29, 2025 01:39
Template reducer
// types.ts
export type Todo = {
id: string;
text: string;
completed: boolean;
};
export type TodoActions =
| {
type: 'add-todo';
@pierodev0
pierodev0 / yazi.toml
Created August 29, 2025 01:35
My config yazi
#Reference: https://github.com/sxyazi/yazi/blob/shipped/yazi-config/preset/yazi-default.toml
[opener]
edit = [
{ run = '${EDITOR:-vi} "$@"', desc = "$EDITOR", block = true, for = "unix" },
{ run = 'code "$@"', orphan = true, desc = "Code", for = "unix" },
{ run = 'nvim "$@"', block = true, desc = "Neovim", for = "unix" },
]
# Keep other opener configurations from the default
open = [{ run = 'xdg-open "$1"', desc = "Open", for = "linux" }]
@pierodev0
pierodev0 / .lua
Created April 22, 2025 10:34
Oil.nvim dynamically remap h and l keys
-- Creamos un grupo de autocomandos para organizar mejor
-- Aplicar mapeos cuando se abre un buffer de oil
vim.api.nvim_create_autocmd("FileType", {
pattern = "oil",
callback = function()
local bufnr = vim.api.nvim_get_current_buf()
-- Establecer h para ir al directorio padre
vim.keymap.set("n", "h", function()
require("oil.actions").parent.callback()
@pierodev0
pierodev0 / .bashrc
Created March 16, 2025 23:55
Multiples distro nvim
#Source: https://michaeluloth.com/neovim-switch-configs/
alias zvim='NVIM_APPNAME=nvim-lazyvim nvim' # LazyVim
alias cvim='NVIM_APPNAME=nvim-nvchad nvim' # NvChad
alias kvim='NVIM_APPNAME=nvim-kickstart nvim' # Kickstart
alias avim='NVIM_APPNAME=nvim-astrovim nvim' # AstroVim
alias lvim='NVIM_APPNAME=nvim-lunarvim nvim' # LunarVim
@pierodev0
pierodev0 / context.tsx
Created March 16, 2025 17:38
React TS Context Example
import { createContext, ReactNode, useContext, useState } from 'react';
import { Book } from 'types';
interface CartItem {
book: Book;
quantity: number;
}
interface CartContextType {
cart: CartItem[];
}
const CartContext = createContext<CartContextType | undefined>(undefined);
@pierodev0
pierodev0 / create.lua
Last active March 5, 2025 08:34
fix error nvchad: error in function 'termopen' in windows
--Remplazar la funcion create del archivo init.lua
-- C:\Users\nameUser\AppData\Local\nvim-data\lazy\ui\lua\nvchad\term
local function create(opts)
local buf_exists = opts.buf
opts.buf = opts.buf or vim.api.nvim_create_buf(false, true)
-- Detectar el sistema operativo
local is_windows = vim.fn.has('win32') == 1 or vim.fn.has('win64') == 1
-- Configurar shell según el sistema operativo
@pierodev0
pierodev0 / useCounter.ts
Last active March 3, 2025 20:38
opcional min max
import { useState } from 'react';
type UseCounterConfig = {
min?: number;
max?: number;
};
type CounterActions = {
increment: () => void;
decrement: () => void;