This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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' }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // update ec2 | |
| sudo apt-get update | |
| sudo apt-get upgrade |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // step 1: Create Docker file | |
| FROM node:22-alpine | |
| WORKDIR /app | |
| COPY package*.json ./ | |
| RUN npm install | |
| COPY . . |
NewerOlder