new posts

This commit is contained in:
stjet
2024-09-01 01:31:36 +00:00
parent 3ce4de70a2
commit 06e4c0ecfe
7 changed files with 93 additions and 7 deletions

View File

@@ -8,6 +8,24 @@
"tags": ["meta", "code", "project", "web", "markdown", "typescript_javascript", "css"],
"archived": false
},
"operation-media-freedom": {
"title": "Operation Media Freedom",
"slug": "operation-media-freedom",
"filename": "operation_media_freedom",
"date": "01/09/2024",
"author": "jet/Prussia",
"tags": ["selfnet", "project", "music", "manga", "anime", "web", "typescript_javascript"],
"archived": false
},
"recommended-blogs": {
"title": "Recommended Blogs",
"slug": "recommended-blogs",
"filename": "recommended_blogs",
"date": "30/08/2024",
"author": "jet/Prussia",
"tags": ["lists"],
"archived": false
},
"two-types-of-brutalism": {
"title": "Two Types of Brutalism",
"slug": "two-types-of-brutalism",
@@ -51,7 +69,7 @@
"date": "13/12/2023",
"author": "jet/Prussia",
"tags": ["cryptography"],
"archived": false
"archived": true
},
"rushed-captcha": {
"title": "Rushed Captcha Rewrite",
@@ -77,7 +95,7 @@
"filename": "downloading_my_spotify_playlist_for_free",
"date": "27/10/2023",
"author": "jet/Prussia",
"tags": ["code", "typescript_javascript", "bash"],
"tags": ["code", "typescript_javascript", "bash", "music"],
"archived": false
},
"ryuji-rust": {
@@ -131,7 +149,7 @@
"filename": "wikipedia_rabbitholes",
"date": "09/08/2023",
"author": "jet/Prussia",
"tags": ["reading", "history", "wikipedia"],
"tags": ["reading", "history", "wikipedia", "lists"],
"archived": false
},
"eve": {

View File

@@ -1,4 +1,4 @@
I've written a lot of Javascript over the past few years. How much? I'm not sure, but 100 thousand lines is probably a good estimate^\[0\]^^\[1\]^. The two functions that I've written the most, over and over, are no doubt the function to turn hexadecimals to bytes, and vice versa.
I've written a lot of Javascript over the past few years. How much? I'm not sure, but 100 thousand lines is probably a good estimate^\[0\]^^\[1\]^. The two functions that I've written the most, over and over (and over and over and over... and over), are no doubt the function to convert hexadecimals to bytes, and vice versa.
Part of this is because I do a lot of stuff related to cryptography and cryptocurrency (which, no surprise, is basically just *more* cryptography), which involves tons of work with bytes and often, converting them to hex for storage or display. The other part is because Javascript doesn't have a builtin way to convert hex to bytes or the other way around (Node.js apparently has `Buffer.from` but I never use that), and also because I just like writing things from scratch, which you may notice is a common theme in this blog. In addition to my trademark unnecessarily long sentences, of course.
@@ -10,7 +10,7 @@ Bits have two states. Bytes are made out of eight bits, so one byte can have 256
Now, there are a couple ways you can represent bytes. One way could be representing them in binary, with 1s and 0s. Another would be just using our normal decimal (base 10 numbers), where a byte could be represented by a number from 0 to 255. But the best way (in my opinion) is to use hexadecimals (base 16 numbers) which uses the digits 0-9 and A-F. `A` represents 10, `B` represents 11, and so on. `FF` would represent 255 in decimal (`15*16+15=255`), `10` would represent 16 (`1*16+0`), and `32` would represent 50 (`3*16+2=50`).
Why base 16? If you remember, one byte can have 256 states, meaning that two hexadecimal digits can perfectly represent one byte (`16^2=256`) which is a lot more elegant than decimal, and a lot more concise than binary. With decimal, it isn't exactly clear how many bytes 2402655566 is, while it is very clear how many bytes 8F359D4E is (8 hex digits, so 4 bytes).
Why base 16? If you remember, one byte can have 256 states, meaning that two hexadecimal digits can perfectly represent one byte (`16^2=256`) which is a lot more elegant than decimal, and a lot more concise than binary. A base 256 would of course, be impractical. With decimal, it isn't exactly clear how many bytes 2402655566 is, while it is very clear how many bytes 8F359D4E is (8 hex digits, so 4 bytes).
## Uint8Array

View File

@@ -5,7 +5,7 @@ The beginning of the month would depend on your timezone, but we want the faucet
Now, for writing the code for the countdown, I could just use Javascript's built in `Date` class. This is a slightly modified version of the code I came up with:
```js
function get_next_month_unix() {
function get_next_month_diff() {
let current_date = new Date();
//get Date object set to the beginning of the next month
//if current month is january, next month will technically give the date of december 31st midnight but that's fine since that's the same time as january 1st 00:00:00
@@ -13,8 +13,9 @@ function get_next_month_unix() {
//get difference in seconds between current time and the start of the next month
return (next_month.getTime() - current_date.getTime()) / 1000;
}
setInterval(function() {
let seconds_until = get_next_month_unix();
let seconds_until = get_next_month_diff();
//... rest of the code omitted
}, 1000);
```
@@ -47,6 +48,10 @@ function get_next_month_unix() {
unix_timestamp += next_month*(60*60*24*30);
return unix_timestamp;
}
function get_next_month_diff() {
return get_next_month_unix() - (Date.now() / 1000);
}
```
But wait! Months don't always have 30 days. Oops.
@@ -90,6 +95,10 @@ function get_next_month_unix() {
}
return unix_timestamp;
}
function get_next_month_diff() {
return get_next_month_unix() - (Date.now() / 1000);
}
```
And don't forget leap days...
@@ -145,6 +154,10 @@ function get_next_month_unix() {
}
return unix_timestamp;
}
function get_next_month_diff() {
return get_next_month_unix() - (Date.now() / 1000);
}
```
At this point, while thinking about leap days, I realized one huge problem: [leap seconds](https://en.wikipedia.org/wiki/Leap_second). It's a pretty bizzare concept.

View File

View File

@@ -0,0 +1,44 @@
In the last six months, the piece of software I have used the most is undoubtably [pla-den-tor](https://github.com/stjet/pla-den-tor). Except for Firefox, that is. Oh, and (neo)vim I guess.
Alright.
In the last six months, the piece of software I have used the third most is undoubtably pla-den-tor.
## What is a pla-den-tor?
Pla-den-tor is one of those word contraction things for "plausible deniability tor" because the original idea was a sort of media server running as a Tor hidden service (a .onion site), password protected^\[0\]^ with [HTTP Basic authentication](https://developer.mozilla.org/en-US/docs/Web/HTTP/Authentication). The Tor and password part constitute all three of the words in the project title, but 90% of the time, I just run it locally without a password, since I have a USB stick with all the pla-den-tor stuff on it. So the name doesn't really make much sense. There is however, a possibility I run an instance of pla-den-tor as an onion site with the password and everything, for when I don't have that USB on me, at least. Who knows.
Back to what pla-den-tor actually is, it started out as a simple media server with a web interface. It has three categories: anime, manga, and music. For the purposes of this article, let's say everything is completely legally obtained. In each of those three categories, there are arbitrary subcategories. For anime, that would be anime serieses. For manga, it would be... manga serieses. And for music that would be artists. Manga serieses have their own subcategory, chapters, which contain pages.
Essentially, you create a directory for, say, an artist, in the music directory. Drop whatever song files you want in there, and repeat. Then, you run the build script, and it'll generate a bunch of html files linking to them. Every song gets it's own page (and the actual song file is embedded on that page), and each artist gets a page that links to all the song pages. The main page links to all the artists/manga/anime. For manga specifically there is a special viewer that just shows all the pages in the chapter. Oh, and all the song/chapter/episode pages have links back to their artist/manga/anime, as well as links to the next or previous song/chapter/episode. Nothing too fancy at this stage.
This format works well for manga and anime, but not so much for music. I don't want to click a bunch of links to get to the next song when the current song ends. Naturally, a music player was added soon after. After some work, the player got to a point where I'm very satisfied with it. It has a queue (you can only remove or move up items in the queue, no moving down because I was lazy), filters (lots and lots of checkboxes for songs and artists), playlists, history (which I don't really use but might one day in order to make a "spotify wrapped" knockoff), and obviously shuffling.
## Oh yeah, it shows time-synced lyrics too
...of songs that I manually make WebVTT files for. I use a [tool](https://ztmy.prussia.dev/subtitles) from a previous project to make these. It takes some time, especially putting furigana on japanese (and other non-english) songs, but I have *a lot* of tolerance for these kinds of tasks^\[1\]^.
## Why (do I) use pla-den-tor?
All the stuff on there is stuff I already know I like, not new stuff I'm planning to consume. This is for two reasons. The first is that downloading and adding it to pla-den-tor takes some (very little, but yet still non-zero) effort^\[2\]^. The second is that I don't have that much storage space and upgrading it (which I have done several times already) costs money.
This means for anime and manga, where I'm mostly consuming new content, and only ocassionally revisiting old favourites, it isn't used too often. But for music, you usually want to listen to the songs you already like rather than constantly listening to new stuff that on average is not so great. As a result, over 75% of my music listening is now done on either pla-den-tor's player. Another 20% or so is done on a local music player on my phone. All the music there is the same as the pla-den-tor music library. On a bit of a side note, my phone actually can run pla-den-tor, because termux is awesome. But pla-den-tor doesn't show album cover art (well, I haven't bothered to figure out how), so I use a FOSS music player app most of the time. Of course, pla-den-tor will always be missing one part of the streaming experience: discovery. Unfortunately, that will still have to be done on some platform (youtube?), or even worse, asking real people.
## Why not use another FOSS music player?
Specifically regarding local usage of pla-den-tor for music, couldn't I have just used some existing music player app and saved myself some work? You know the answer to that. I like to make my own stuff. Plus, I don't want to spent a few hours poking around some random guy's code and either submit a PR or maintain a fork whenever I want to add some specific feature.
It should be implicit that spotify or similar services are not an option - I am sick of half the listening time being ads (and yes, sick of spending time trying to block them), and even more sick of paying for services with barely functional apps^\[3\]^.
## The code
The code's nothing special. It uses Ryuji for templating and Saki as a build system, same as this blog. The player code is a lot of spaghetti but not excessively so.
===
Footnotes:
- \[0\]: The password actually changes every UTC day. It is derived by hashing a secret master password with the current date
- \[1\]: [See my 1 hour and 18 minutes of concert subtitles](https://github.com/stjet/ztmy/blob/master/static/vtt/cleaning-labo.vtt)
- \[2\]: Besides "legally" downloading it and moving it into the right directory, I also need to manually add some metadata so things look nice when I play music on my phone
- \[3\]: I am mainly basing this comment on my experiences with the official spotify clients, and to a lesser extent apple music. Spotify's clients in particular are absolutely terrible (Why does it have to keep loading and unloading stuff? Just keep it loaded!!! And why does it just randomly stop being responsive? Why are some clients missing the features of other clients?). My understanding is with spotify premium, you can use custom clients, at least

View File

@@ -0,0 +1,7 @@
A very short (so far) list of blogs I read when HN's been reloaded for the tenth time and the front page hasn't changed:
- [A Collection of Unmitigated Pedantry](https://acoup.blog): classical and medieval history
- [Vitalik Buterin's website ](https://vitalik.eth.limo): ethereum
- [BIG by Matt Stoller](https://www.thebignewsletter.com): monopolies
- [Matt Lakeman](https://mattlakeman.org): mostly travel
- [Computers Are Bad](https://computer.rip/archive.html): tech

View File

@@ -215,3 +215,7 @@ Here's a very incomplete (and maybe actively updated) list of ones that led to m
- [Romansh language](https://en.wikipedia.org/wiki/Romansh_language), a national language of Switzerland
- [Toyota Group](https://en.wikipedia.org/wiki/Toyota_Group)
- [California grizzly bear](https://en.wikipedia.org/wiki/California_grizzly_bear), extinct
- [Cognates](https://en.wikipedia.org/wiki/Cognate) are word cousins
- [Mun (religion)](https://en.wikipedia.org/wiki/Mun_(religion))
- [Vaqueiros de alzada](https://en.wikipedia.org/wiki/Vaqueiros_de_alzada), nomads in northern Spain
- [Muslim conquest of Persia](https://en.wikipedia.org/wiki/Muslim_conquest_of_Persia)