Skip to content

Instantly share code, notes, and snippets.

@adriangalilea
adriangalilea / settings.json
Created December 4, 2024 10:44
vscode cursor nextjs tab naming
"workbench.editor.customLabels.patterns": {
"**/app/**/layout.tsx": "${dirname}/${filename}.${extname}",
"**/app/**/page.tsx": "${dirname}/${filename}.${extname}",
"**/app/**/loading.tsx": "${dirname}/${filename}.${extname}",
"**/app/**/not-found.tsx": "${dirname}/${filename}.${extname}",
"**/app/**/error.tsx": "${dirname}/${filename}.${extname}",
"**/app/**/route.ts": "${dirname}/${filename}.${extname}",
"**/app/**/template.tsx": "${dirname}/${filename}.${extname}"
}
@adriangalilea
adriangalilea / .zshrc
Last active May 3, 2024 07:03
useful package.json scripts and bash function to use it from cli
function npm-scripts() {
# Define the Gist URL directly within the function
local gist_url="https://gist.githubusercontent.com/adriangalilea/7f5f4602b80099b86b0d9b06a9dd3373/raw/808d9b8e81b6216f7eab85fe13e33edce0a286d5/scripts.json"
# Check if package.json exists in the current directory
if [ -f "package.json" ]; then
# Fetch JSON from Gist and update package.json
curl -s "$gist_url" | jq --slurpfile newScripts /dev/stdin '.scripts |= . + $newScripts[0]' package.json > package.json.tmp && mv package.json.tmp package.json
echo "Scripts updated in package.json"
else
@adriangalilea
adriangalilea / violet.theme
Last active May 19, 2024 17:54
taskwarrior theme
# based on dark-violets-256.theme but fixes legibility for me.
###############################################################################
#
# Copyright 2006 - 2021, Tomas Babej, Paul Beckingham, Federico Hernandez.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
@adriangalilea
adriangalilea / auth.ts
Created March 18, 2024 20:54
NextAuth Auth.js module augmentation + custom adapter
import NextAuth from "next-auth";
import GitHub from "next-auth/providers/github";
import { DrizzleAdapter } from "@auth/drizzle-adapter";
import { db } from "./db";
import { type AdapterUser, Adapter } from "@auth/core/adapters";
import { users, accounts, verificationTokens, sessions } from "@/db/schema";
import { eq, and } from "drizzle-orm";
declare module "next-auth" {
interface Profile {
@adriangalilea
adriangalilea / force-touch.tsx
Created February 19, 2024 08:35
just testing force touch in a next.js project. Not very useful as I can not make the touchpad vibrate which was my main purpose but still cool to be able to monitor the pressure precisely(only from safari))
"use client";
import React, { useRef, useEffect } from "react";
// Define the extended MouseEvent interface to include the webkitForce property
interface ForceMouseEvent extends MouseEvent {
webkitForce?: number;
}
export default function ForceTouchComponent() {
const ref = useRef<HTMLDivElement>(null);