Skip to content

Commit 0749f2e

Browse files
committed
Various updates
1 parent fc4e845 commit 0749f2e

File tree

11 files changed

+365
-145
lines changed

11 files changed

+365
-145
lines changed

src/components/layout-helpers/BaseFooter.astro

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
11
---
22
import {
33
AUTHOR,
4-
COPYRIGHT_YEAR,
54
SOURCE_CODE_URL,
65
} from "@root/constants";
76
7+
import {TimezonelessDate} from "@helpers/timezoneless-date";
8+
89
import ccImg from "./_BaseFooter_images/cc.svg";
910
import byImg from "./_BaseFooter_images/by.svg";
1011
import saImg from "./_BaseFooter_images/sa.svg";
12+
13+
const copyright_year = TimezonelessDate.nowUTC().getYear();
1114
---
1215

1316
<footer id="footer" class="content-column">
1417
<p id="footer-text">
15-
&copy; {COPYRIGHT_YEAR} {AUTHOR}. All content on this site is licensed under <a href="http://creativecommons.org/licenses/by-sa/4.0/?ref=chooser-v1" target="_blank" rel="license noopener noreferrer" style="display:inline-block;">Creative Commons Attribution-ShareAlike 4.0 International</a>.
18+
&copy; {copyright_year} {AUTHOR}. All content on this site is licensed under <a href="http://creativecommons.org/licenses/by-sa/4.0/?ref=chooser-v1" target="_blank" rel="license noopener noreferrer" style="display:inline-block;">Creative Commons Attribution-ShareAlike 4.0 International</a>.
1619
<br />
1720
This site's source code is available on <a href={SOURCE_CODE_URL}>GitHub</a>.
1821
<br />

src/constants.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ export const SHIKI_THEME = "monokai";
33
export const SITE = "https://www.simshadows.com/";
44
export const SITE_TITLE = "simshadows";
55
export const AUTHOR = "simshadows";
6-
export const COPYRIGHT_YEAR = 2025;
76
export const GLOBAL_KEYWORDS = ["simshadows"];
87
export const SOURCE_CODE_URL = "https://github.com/simshadows/simshadows.github.io";
98

src/helpers/timezoneless-date.ts

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
*
66
* A wrapper class to enforce the use of a pre-existing date implementation
77
* as a simple timezoneless calendar date.
8+
*
9+
* There are a lot of weird stuff going on in this class, mostly because it's just
10+
* easy to understand and verify. I should work on understanding exactly what's going
11+
* on with them and cleaning up any weirdness.
812
*/
913

1014
import dayjs from "dayjs";
@@ -47,6 +51,10 @@ export class TimezonelessDate {
4751
return this.__d.toISOString();
4852
}
4953

54+
getYear(): Number {
55+
return this.__d.year();
56+
}
57+
5058
toDate(): Date {
5159
return this.__d.toDate();
5260
}
@@ -55,8 +63,7 @@ export class TimezonelessDate {
5563
* Returns a number that guarantees that later dates have larger numbers
5664
* than earlier dates, and same dates return the same number.
5765
*
58-
* (In practice, this is a Unix timestamp, but toOrderedNumber() doesn't
59-
* promise any particular timezone.)
66+
* (In practice, this is a Unix timestamp. Don't rely on what the number means.)
6067
*/
6168
toOrderedNumber(): number {
6269
return this.__d.unix();
@@ -82,5 +89,17 @@ export class TimezonelessDate {
8289
}
8390
return new TimezonelessDate(Number(y), Number(m) - 1, Number(d));
8491
}
92+
93+
/*
94+
* Get the current UTC date as a TimezonelessDate.
95+
*/
96+
static nowUTC(): TimezonelessDate {
97+
const now = new Date();
98+
return new TimezonelessDate(
99+
now.getUTCFullYear(),
100+
now.getUTCMonth(),
101+
now.getUTCDate(),
102+
);
103+
}
85104
}
86105

src/pages/_index-links.astro

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,11 @@ const {
109109
<h4>Computer/Tech Enthusiast Stuff</h4>
110110

111111
<ul>
112+
<li><b>Audio</b>
113+
<ul>
114+
<li><a href="/tech/audio/impressions/"><b>My Impressions on Headphones</b></a></li>
115+
</ul>
116+
</li>
112117
<li><b>Cheatsheets and Checklists</b>
113118
<ul>
114119
{showWIP && <li><a href="/tech/cheatsheets/computer-maintenance-checklists/"><b>Computer Maintenance Checklists</b></a> <Wip /></li>}
@@ -120,10 +125,14 @@ const {
120125
</li>
121126
{showWIP && <li><a href="/tech/hardware-troubleshooting/"><b>Computer Hardware Troubleshooting</b></a> <Wip /></li>}
122127
{showWIP && <li><a href="/tech/homelab/"><b>Homelab</b></a> <Wip /></li>}
123-
<li><a href="/tech/mechanical-keyboard-switch-collection/"><b>Mechanical Keyboard Switch Collection</b></a>
124-
{showWIP && <ul>
125-
<li>There's also this <a href="/mechanical-keyboard-switch-collection-legacy/index.html"><b>old version of the page</b></a>. I'm still migrating data from it.</li>
126-
</ul>}
128+
<li><b>Mechanical Keyboards</b>
129+
<ul>
130+
<li><a href="/tech/mechanical-keyboard-switch-collection/"><b>Mechanical Keyboard Switch Collection</b></a>
131+
{showWIP && <ul>
132+
<li>There's also this <a href="/mechanical-keyboard-switch-collection-legacy/index.html"><b>old version of the page</b></a>. I'm still migrating data from it.</li>
133+
</ul>}
134+
</li>
135+
</ul>
127136
</li>
128137
<li><a href="/tech/semiprivate/"><b>Semi-Private Content</b></a></li>
129138
</ul>

src/pages/c/cheatsheets/javascript-typescript.mdx

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,27 @@ import foobar from "mymodule";
202202
```
203203

204204

205+
## Web APIs
206+
207+
### Document Object Model (DOM)
208+
209+
```ts
210+
// Return the first match (falsy if no match)
211+
match = document.querySelector("#logo");
212+
// Return all matches (empty if no match)
213+
matches = document.querySelectorAll("div.foobar");
214+
215+
// Creating an element
216+
e = document.createElement("div");
217+
e.classlist.add("my-awesome-class");
218+
e.textContent = "my awesome text";
219+
220+
// Adding an element to the page
221+
match.prepend(e);
222+
match.append(e);
223+
```
224+
225+
205226
## Basic Recipes (JS Only)
206227

207228
### Max Heap

src/pages/c/cheatsheets/powershell.mdx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,10 @@ indexTitle: PowerShell
88
wip: true
99
---
1010

11-
TODO
11+
```powershell
12+
# Print cyan-coloured text
13+
Write-Host "foobar" -ForegroundColor Cyan
14+
15+
# Run another Powershell script
16+
& $PSScriptRoot\relative\path\to\other\script.ps1
17+
```

src/pages/c/cheatsheets/python/index.mdx

Lines changed: 44 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,30 @@ References:
2626
- [**`math`**](https://docs.python.org/3/library/math.html), [**`datetime`**](https://docs.python.org/3/library/datetime.html)
2727
- [**`bisect`**](https://docs.python.org/3/library/bisect.html), [**`heapq`**](https://docs.python.org/3/library/heapq.html)
2828
- [**`logging`**](https://docs.python.org/3/library/logging.html), [**`sqlite3`**](https://docs.python.org/3/library/sqlite3.html)
29+
- [**`venv`**](https://docs.python.org/3/library/venv.html)
2930
- [**Learn X in Y minutes - Python**](https://learnxinyminutes.com/docs/python/) `(learnxinyminutes.com)`
3031

3132
Common third-party library references:
3233

3334
- [**`pandas`**](https://pandas.pydata.org/docs/reference/index.html)
3435

3536

37+
## Shell Commands
38+
39+
```sh
40+
# Set up venv
41+
python -m venv ./_venv
42+
source ./_venv/bin/activate
43+
python -m pip install -r ./requirements.txt
44+
45+
# Create requirements.txt
46+
python -m pip freeze > ./requirements.txt
47+
48+
# Exit venv
49+
deactivate
50+
```
51+
52+
3653
## Misc.
3754

3855
Python Documentation - [**Built-In Functions**](https://docs.python.org/3/library/functions.html), [**Built-In Exceptions**](https://docs.python.org/3/library/exceptions.html#concrete-exceptions), [**Data Model**](https://docs.python.org/3/reference/datamodel.html)<br />
@@ -206,12 +223,34 @@ x = p[0] # same as p.x
206223
```
207224

208225

226+
## Classes
227+
228+
Python Documentation - [**Data Model - Special method names**](https://docs.python.org/3/reference/datamodel.html)
229+
230+
```py
231+
class MyClass:
232+
__slots__ = ("__foobar")
233+
234+
def __init__(self, n):
235+
self.__foobar = n
236+
```
237+
238+
239+
## Functions
240+
241+
TODO show how args and kwargs work
242+
243+
209244
## System API
210245

211246
Python Documentation - [**`os`**](https://docs.python.org/3/library/os.html), [**`sys`**](https://docs.python.org/3/library/sys.html)
212247

248+
### File IO
249+
213250
```py
214-
# TODO: examples?
251+
with open("foobar.txt", "r") as f:
252+
content = f.read()
253+
print(content)
215254
```
216255

217256

@@ -293,10 +332,6 @@ words = [s.strip() for s in stdin.readline().strip().split()]
293332
nums2 = [[int(x) for x in s.strip().split()] for s in stdin.readlines()]
294333
```
295334

296-
### Leetcode
297-
298-
Python lacks sorted associative containers like C++'s `std::set` and `std::map`. As a workaround, Leetcode supplies the [`sortedcontainers`](https://grantjenks.com/docs/sortedcontainers/) library to use on the platform (as mentioned [here](https://support.leetcode.com/hc/en-us/articles/360011833974-What-are-the-environments-for-the-programming-languages-)).
299-
300335
### Trie
301336

302337
```py
@@ -329,6 +364,10 @@ class Trie:
329364
return True
330365
```
331366

367+
### Leetcode
368+
369+
Python lacks sorted associative containers like C++'s `std::set` and `std::map`. As a workaround, Leetcode supplies the [`sortedcontainers`](https://grantjenks.com/docs/sortedcontainers/) library to use on the platform (as mentioned [here](https://support.leetcode.com/hc/en-us/articles/360011833974-What-are-the-environments-for-the-programming-languages-)).
370+
332371

333372
## TODO
334373

0 commit comments

Comments
 (0)