Skip to content

Instantly share code, notes, and snippets.

@AceCodePt
AceCodePt / autocmds.lua
Last active November 14, 2024 06:45
Fixed Terminal Yanking Nvim
vim.api.nvim_create_autocmd({ "TextYankPost" }, {
pattern = "term://*",
callback = function()
local width = vim.api.nvim_win_get_width(0) - 2
local offset = vim.api.nvim_win_get_cursor(0)[2]
local yanked_text = vim.fn.getreg("+")
local new_str = ""
local count = 1
while true do
local next_index = string.find(yanked_text, "\n", count)
@AceCodePt
AceCodePt / hx-astro-view-transition.js
Last active October 29, 2023 17:30
htmx-astro-view-transition
htmx.defineExtension("hx-astro-view-transition", {
onEvent: function (name, evt: any) {
if (name === "htmx:afterRequest") {
const attributes = evt.target.attributes;
const viewTransitionTarget =
attributes["hx-view-transition"]?.value;
if (!viewTransitionTarget) {
console.log(evt);
return;
}
@AceCodePt
AceCodePt / generate-routes.mts
Last active November 18, 2024 13:28
Generate NextJS safe Routing (don't forget to install glob)
import * as fs from "fs";
import * as glob from "glob";
const routes = glob.globSync("**/app/**/route.ts", {});
const constDef: string[] = [];
const typeDef: string[] = [];
const routeTypes: string[] = [];
function toConstDef(varName: string, path: string): string {