Skip to content

Commit 0dea463

Browse files
Merge pull request #73 from madhusudhan1234/notes
Notes
2 parents c00cf5b + 945f11f commit 0dea463

File tree

2 files changed

+282
-1
lines changed

2 files changed

+282
-1
lines changed

README.md

Lines changed: 100 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,100 @@
1-
# Madhu Sudhan subedi Website
1+
# Madhu Sudhan Subedi — Personal Website
2+
3+
A fast, content‑driven personal site built with Astro. It includes:
4+
- Blog posts (MD/MDX) with RSS and sitemap
5+
- Notes with tag filtering (e.g., `js-data-structure`)
6+
- Weekly podcast episodes with per‑episode pages and audio embeds
7+
8+
## Tech Stack
9+
- Astro 5
10+
- MD/MDX content collections
11+
- Vanilla CSS (global theme)
12+
- RSS + Sitemap integrations
13+
14+
## Getting Started
15+
```bash
16+
npm install
17+
npm run dev
18+
# open http://localhost:4321
19+
```
20+
21+
## Build
22+
```bash
23+
npm run build
24+
npm run preview
25+
```
26+
Static output is written to `dist/`.
27+
28+
## Project Structure
29+
```
30+
src/
31+
components/ # shared UI (Header, Footer, etc.)
32+
content/
33+
blog/ # blog posts (MD/MDX)
34+
notes/ # notes (MD/MDX)
35+
episodes/ # weekly episode metadata (MD)
36+
layouts/ # page/post layouts
37+
pages/
38+
index.astro
39+
blog/ # blog index and routes
40+
notes/ # notes index and routes
41+
tag/[tag].astro # filter notes by tag
42+
weekly/ # weekly index and episode pages
43+
styles/
44+
global.css # site theme and layout styles
45+
content.config.ts # content collections and schemas
46+
```
47+
48+
## Content Authoring
49+
50+
### Blog frontmatter
51+
```yaml
52+
title: string
53+
description: string
54+
pubDate: string (coerced to Date)
55+
updatedDate?: string
56+
heroImage?: string
57+
```
58+
59+
### Notes frontmatter
60+
```yaml
61+
title: string
62+
description: string
63+
pubDate: string (coerced to Date)
64+
updatedDate?: string
65+
heroImage?: string
66+
tags?: string # comma-separated or single tag
67+
```
68+
69+
Tag filter page is available at `/notes/tag/{tag}`.
70+
71+
### Weekly episodes frontmatter
72+
```yaml
73+
id: number
74+
title: string
75+
description: string
76+
published: boolean
77+
audioLink: string
78+
publishDate: string (coerced to Date)
79+
duration: string
80+
tags: string
81+
```
82+
83+
## Routes
84+
- `/` — Home
85+
- `/blog` — Blog index
86+
- `/blog/{slug}` — Blog post
87+
- `/notes` — Notes index
88+
- `/notes/{slug}` — Note detail
89+
- `/notes/tag/{tag}` — Notes filtered by tag
90+
- `/weekly` — Weekly index (paginated)
91+
- `/weekly/{id}` — Episode detail
92+
- `/rss.xml` — RSS feed
93+
94+
## Scripts
95+
- `npm run dev` — Start local dev server
96+
- `npm run build` — Build static site
97+
- `npm run preview` — Preview built site
98+
99+
## Deployment
100+
This project builds to static HTML/CSS/JS. You can deploy `dist/` to any static host (e.g., GitHub Pages, Cloudflare Pages, Netlify, Vercel static sites).
Lines changed: 182 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,182 @@
1+
---
2+
title: 'Data Structure: Set in JavaScript'
3+
description: 'Unique values collection, operations, iteration, conversions, set algebra, performance, and pitfalls.'
4+
pubDate: 'Jan 3 2026'
5+
tags: 'js-data-structure'
6+
---
7+
8+
## Overview
9+
10+
Sets store unique values of any type and are ideal for deduplication and membership checks.
11+
12+
Sets can contain mixed types (numbers, strings, objects).
13+
14+
Sets are dynamic—no fixed size needed.
15+
16+
Sets preserve insertion order when iterating.
17+
18+
Sets are iterable and work with `for...of` and `forEach`.
19+
20+
Set vs Array
21+
- Arrays allow duplicates; Sets do not.
22+
- Arrays use index access; Sets use membership checks and iteration.
23+
- Typical membership tests and deletes in Sets are O(1).
24+
25+
26+
## Creating Sets
27+
28+
```js
29+
const set = new Set([1, 2, 3]);
30+
const mixed = new Set([1, '1', { a: 1 }]);
31+
for (const item of set) console.log(item);
32+
```
33+
34+
Result:
35+
```
36+
1
37+
2
38+
3
39+
```
40+
41+
## Add & Remove
42+
43+
```js
44+
set.add(4);
45+
set.add(4);
46+
```
47+
48+
Result:
49+
```
50+
1
51+
2
52+
3
53+
4
54+
```
55+
56+
Check membership:
57+
58+
```
59+
console.log(set.has(4));
60+
```
61+
62+
Result:
63+
```
64+
true
65+
```
66+
67+
Remove values:
68+
69+
```
70+
set.delete(4);
71+
```
72+
73+
Result:
74+
75+
```
76+
1
77+
2
78+
3
79+
```
80+
81+
Size:
82+
83+
```
84+
console.log(set.size);
85+
```
86+
87+
Result:
88+
```
89+
3
90+
```
91+
92+
Clear:
93+
94+
```
95+
set.clear();
96+
```
97+
98+
Result:
99+
```
100+
console.log(set.size);
101+
0
102+
```
103+
104+
## Conversions
105+
106+
Array ↔ Set:
107+
108+
```js
109+
const arr = [1, 2, 2, 3];
110+
const s = new Set(arr);
111+
const back = [...s];
112+
```
113+
114+
Result:
115+
```
116+
[1, 2, 3]
117+
```
118+
119+
Deduplicate arrays:
120+
121+
```js
122+
const unique = xs => [...new Set(xs)];
123+
unique([1, 1, 2, 3, 2]);
124+
```
125+
126+
Result:
127+
```
128+
[1, 2, 3]
129+
```
130+
131+
## Set Algebra
132+
133+
```js
134+
const union = (A, B) => new Set([...A, ...B]);
135+
const intersection = (A, B) => {
136+
const out = new Set();
137+
for (const v of A) if (B.has(v)) out.add(v);
138+
return out;
139+
};
140+
const difference = (A, B) => {
141+
const out = new Set();
142+
for (const v of A) if (!B.has(v)) out.add(v);
143+
return out;
144+
};
145+
const isSubset = (A, B) => {
146+
for (const v of A) if (!B.has(v)) return false;
147+
return true;
148+
};
149+
```
150+
151+
Examples:
152+
153+
```js
154+
const A = new Set([1, 2, 3]);
155+
const B = new Set([2, 3, 4]);
156+
[...union(A, B)];
157+
[...intersection(A, B)];
158+
[...difference(A, B)];
159+
isSubset(new Set([2, 3]), A);
160+
```
161+
162+
Result:
163+
```
164+
[1, 2, 3, 4]
165+
[2, 3]
166+
[1]
167+
true
168+
```
169+
170+
## Big‑O Complexity
171+
172+
| Operation | Complexity |
173+
| ------------------- | ---------- |
174+
| has / add / delete | O(1) |
175+
| clear / size | O(1) |
176+
| iterate | O(n) |
177+
178+
## Notes & Pitfalls
179+
180+
- Object equality is by reference
181+
- No index access—iterate or convert to array
182+
- Cache conversions for large sets to avoid repeated cost

0 commit comments

Comments
 (0)