Skip to content

Instantly share code, notes, and snippets.

@hiteshkhatic
hiteshkhatic / gist:3c30caf36bb043387dfc378e266f4bb6
Created March 18, 2026 06:46
drizzle ORM cheatsheet - DELETE
// DELETE FROM users WHERE id = 5
await db.delete(users).where(eq(users.id, 5));
// DELETE + return deleted row
const deleted = await db
.delete(users)
.where(eq(users.id, 5))
.returning();
@hiteshkhatic
hiteshkhatic / gist:c6c6aa276e3b571be415c87c79a587a7
Created March 18, 2026 06:46
drizzle ORM cheatsheet - UPDATE (Edit)
// UPDATE users SET username = 'newname' WHERE id = 5
await db
.update(users)
.set({ username: 'newname' })
.where(eq(users.id, 5));
// UPDATE + return the updated row
const updated = await db
.update(users)
.set({ username: 'newname' })
@hiteshkhatic
hiteshkhatic / gist:c1d415d957365042a37f2abae254f754
Created March 18, 2026 06:45
drizzle ORM cheatsheet - INSERT (Create)
// Insert ONE row
await db.insert(users).values({ username: 'alice', password: 'hashed' });
// Insert MULTIPLE rows at once
await db.insert(users).values([
{ username: 'alice', password: 'hashed1' },
{ username: 'bob', password: 'hashed2' },
]);
// Insert and get back the created row
@hiteshkhatic
hiteshkhatic / gist:54e6e12904d865ab82d1893cf0e4bcd0
Created March 18, 2026 06:44
drizzle ORM cheatsheet - SELECT (Read)
import { eq, and, or, like, gt, lt, gte, lte, ne, isNull } from 'drizzle-orm';
// Get ALL rows
const allUsers = await db.select().from(users);
// Get SPECIFIC columns only
const names = await db
.select({ id: users.id, username: users.username })
.from(users);
@hiteshkhatic
hiteshkhatic / gist:d9b709ee7397f015be522ff9a277f8e4
Created March 13, 2026 07:13
Rendering Image in React-naive
<View>
// option 1: from a url
<Image
source={{
uri: "https://images.unsplash.com/photo-1598662779094-110c2bad80b5?w=600&auto=format&fit=crop&q=60&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxzZWFyY2h8MTh8fGtleWJvYXJkfGVufDB8fDB8fHww",
}}
style={{ width: 100, height: 100}}
/>
// option 2: from a local folder
@hiteshkhatic
hiteshkhatic / gist:b5acd4f5aad0d64feddbbb418ba5ed45
Last active March 10, 2026 07:33
how bits have to borrow and what is this 2^n while doing ip/subnetting ?
When you’re subnetting, you start with an IP address and a subnet mask. Let’s say you have a /24 network:
- That means the first 24 bits are the network part.
- The remaining 8 bits are for hosts (because IPs are 32 bits total).
Now, if you want more subnets, you need to “borrow” bits from the host portion.
you have a /24 network and want 6 subnets.
- Use the formula: 2𝑛 ≥ 6
- Test Powrs of 2:
2^1 = 2 -> too small
Every IPv4 address has 32 bits total.
8 bits | 8 bits | 8 bits | 8 bits
Example IP:
192.168.1.10
Each block (octet) is 8 bits.
pwd
ssh-keygen -t rsa -b 4096 -C "something@mail.com"
// you will get private/public keys
// copy public key and paste to you ec2 or vm inside /.ssh/authorized <= add public key in this file
// copy private key and add in github actions secrets
// never push your private/public key to github or real machine
// update ec2
sudo apt-get update
sudo apt-get upgrade
@hiteshkhatic
hiteshkhatic / gist:41d528a587b4cbb04966e2a29449f8fb
Last active March 6, 2026 05:47
Docker image/container interacting
// step 1: Create Docker file
FROM node:22-alpine
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .