Skip to content

Instantly share code, notes, and snippets.

View productdevbook's full-sized avatar
🖥️
Learning

Wind productdevbook

🖥️
Learning
View GitHub Profile
@productdevbook
productdevbook / pinia-colada-guide.md
Last active July 19, 2025 07:14
Pinia Colada: The Magical Way of Fetching Data in Vue.js 🍹

Pinia Colada: The Magical Way of Fetching Data in Vue.js 🍹

What is Pinia Colada? Learning Through an E-commerce Story

Imagine an online store. This store has thousands of products, and customers are constantly viewing products, adding them to cart, and making purchases. Pinia Colada is an amazing tool for managing this store's data!

Pinia Colada is a smart data fetching layer developed for Vue.js. The name might remind you of a cocktail, but it's actually a tool built on top of the Pinia state management library that makes data fetching operations much easier.

What's the Difference Between Pinia and Pinia Colada?

@productdevbook
productdevbook / drizzle-orm.md
Last active July 14, 2025 23:45
Drizzle ORM PostgreSQL Best Practices Guide (2025)

Drizzle ORM PostgreSQL Best Practices Guide (2025)

Latest Drizzle ORM features and optimal schema patterns

Major 2025 Update: PostgreSQL now recommends identity columns over serial types. Drizzle has fully embraced this change.

import { pgTable, integer, text, timestamp, varchar } from 'drizzle-orm/pg-core';
@productdevbook
productdevbook / server.ts
Created May 22, 2025 17:46 — forked from ashbuilds/server.ts
Implementing GraphQL Subscriptions with Websockets in a Bun Server using graphql-yoga
import Bun from 'bun'
import { createYoga, YogaInitialContext, YogaServerInstance } from 'graphql-yoga'
import { makeHandler } from "graphql-ws/lib/use/bun";
import { ExecutionArgs } from "@envelop/types";
import { schema } from './graphql/schema';
interface IUserContext {
token?: string;
}

🧠 VSCode Tip: Format Current File with ESLint (No Plugin Needed)

You can run eslint --fix on the currently open file in VSCode without using the ESLint extension by combining a task and a custom shortcut.

Create a .vscode/tasks.json file in your project and add the following:

pnpm install -g eslint
## Git Update Alias
You can create a Git alias to easily update your fork by synchronizing it with the original repository (upstream). The alias performs a series of commands to fetch the latest changes from upstream, merge them into your fork, and push the changes to your remote repository.
### 1. **Set up the Alias**
Run the following command in your terminal to define the `git update` alias:
```bash
git config --global alias.update '!f() { git fetch upstream && git merge upstream/main && git push origin main; }; f'
@productdevbook
productdevbook / docker.yml
Last active July 18, 2025 09:46
docker.yml
docker pull redis:7.4.2-alpine3.21
docker pull postgres:17.4-alpine3.21
# run
docker run --name dev-redis -d -p 6379:6379 redis:7.4.2-alpine3.21
docker run --name dev-postgres -d -p 5432:5432 -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=postgres postgres:17.4-alpine3.21
docker run --name dev-mail -d -p 1080:1080 -p 1025:1025 marlonb/mailcrab:latest
# connect
DATABASE_POSTGRES_URL=postgres://postgres:postgres@localhost:5432/postgres
@productdevbook
productdevbook / format.sh
Created March 6, 2025 13:03 — forked from garethrees/format.sh
Format USB drive from the command line macOS
diskutil list
diskutil unmountDisk /dev/disk2
diskutil eraseDisk FAT32 SANDISK /dev/disk2
// #1
function logWrapper(fn: Function) {
return function (...args: any[]) {
console.log(`Calling function with args: ${args}`);
return fn(...args);
};
}
@productdevbook
productdevbook / motion.ts
Created November 13, 2024 12:52
Motion Test
import { animate } from 'motion'
import type { AnimationPlaybackControls, ValueAnimationOptions } from 'motion/react'
import {
type VNode,
computed,
defineComponent,
h,
mergeProps,
reactive,
useAttrs,
@productdevbook
productdevbook / A_UUID_v7_for_Postgres.sql
Created November 6, 2023 05:13 — forked from kjmph/A_UUID_v7_for_Postgres.sql
Postgres PL/pgSQL function for UUID v7 and a bonus custom UUID v8 to support microsecond precision as well. Read more here: https://datatracker.ietf.org/doc/draft-peabody-dispatch-new-uuid-format/
-- Based off IETF draft, https://datatracker.ietf.org/doc/draft-peabody-dispatch-new-uuid-format/
create or replace function uuid_generate_v7()
returns uuid
as $$
begin
-- use random v4 uuid as starting point (which has the same variant we need)
-- then overlay timestamp
-- then set version 7 by flipping the 2 and 1 bit in the version 4 string
return encode(