Diary · #code

October 22, 2024

Wow, I think anxiety meds actually work. I keep feeling anxiety inside, but it’s very suppressed. It’s an extremely weird feeling. But it feels super awesome to not feel physical pain!

Went to hospital again today. Taxis as always were super duper quick, literally came in 30 seconds! Doctor was kinda disappointing. He checked my legs and said that I’m gonna need to get scanned and get checked at another doctor… Everything was very quick yet expensive. Kinda annoying that I’ll have to go to hospital once again…

1000019159.jpg

1000019112.jpg

Got response from person I made comm for that there was a bug with monitors where pixel density is different from 1. I was thinking it’s basically impossible for me to fix, since I don’t have such monitors, but then realized that I can just open my laptop and have it as my third monitor. I checked it out on laptop, and indeed, it didn’t work.

Seems that robot.js just doesn’t work properly with high density displays, so I had to spend hours on getting screenshots to work with node-ffi. I was very lucky to find some library that had such function, and I finally could get screenshots done. After I switched the screenshotter, for some reason it still didn’t work properly, and I’ve noticed that for some reason, Electron’s screen returns wrong screen offset coordinates for high density display. So I’ve decided to try using node-ffi again, and once again didn’t have much success. After hours of pain and hell I became too desperate and had to open up the beast — Visual Studio 2022. It was much easier to just write a very simple C++ program to get data about displays, and this data had actually accurate offsets this time! So I just compiled it and called it from Node.

After some more bug fixes I finally made everything work. Packaging it was pain again. Because of dynamic import I had to copy some of node_modules and it took a while to figure out which ones I needed.

During me coding all that, suddenly random people started joining the server, and then asked if I made some crypto coin, which I didn’t. It seemingly got 100k marketcap, which is pretty crazy. My site showed 150 people online, and huge amount joined the Discord server. People explained to me that it was just someone trying to profit from my name. Then some guy started sending everyone tons of crypto in server. It was genuinely crazy, and actually sizable amounts ($250+) to basically all active people in the server. He was apparently very rich, with more than 10M dollars earnt this year. ██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████

October 19, 2024

Someone reported a bug in Nekoweb that made it not redirect /page to /page/. Seemingly an unimportant thing, but it makes it so there’s basically always 2 different pages with 2 behaviors. I kinda panicked and changed it to redirect, but then realized that then it breaks huge amount of Nekoweb sites because they rely on this behavior so I had to revert it back… In the end I just added an option to enable strict routing, so people can switch to it when they are ready. It’s also enabled by default for new users.

Finished Bsky crossposter!

Added a second FTP server in USA. Well, returned it back. Now people can connect to either Europe or USA server. And finally fixed bug with moving folders and files in dashboard. Also added support for uploading folders.

Yume 2kki at the end of the day as always. Went further from that cozy room until the end of the path, and got a Menu Theme. I like when there’s just a linear long path with reward at the end. Having a lot of routes always feels confusing and orderless.

1000019057.png

After that just went through today’s expeditions.

1000019056.png

1000019058.png

1000019059.png

1000019061.png

1000019062.png

1000019060.png

1000019063.png

October 16, 2024

Got a call from hospital, my blood analysis result is ready, so I scheduled an appointment for tomorrow.

Went through some of the issues reported in Ultimate Express: TypeScript support and async error handling.

Spent the rest of the day coding commission. This is my first time making actual program. I’m using Electron and it’s a pretty good experience. I finally figured out how to draw on screen! Apparently everything is done with windows, drawing on top is just creating a transparent window that’s click-through. Reading pixels from screen was annoying. I had to switch through 3 libraries until I finally made it work, because some libraries didn’t work with monitors and others didn’t want to work with Electron version I’m using. I had to downgrade Electron to few year old version and recode some parts, because otherwise shit just didn’t want to work.

I was given a month to finish this commission, but I might finish it tomorrow.

For some reason, like every month my neighbors upstairs just laugh non-stop for a hour at like 1-2 AM. I still have no idea what’s going on there, it’s really non-stop and I don’t know how they don’t run out of air. I’m not entirely sure that it’s a laugh too, but it does sound most similarly to that.

Tags: #code

October 10, 2024

So painfully sunny today, I once again can’t do anything but rot in bed. I really need better window blinds…

I fell asleep while waiting for sun to go away, and woke up at 9. I’m being quite lazy lately, I really need to start doing my uni assignments but I don’t want to… While reading uWS examples I’ve noticed that it’s possible to create declarative routes, which don’t need to call into JS code at all! So I’ve got an idea that if route callback is simple enough it’s possible to create a declarative route from it, and started coding it at night. This is very difficult. I have to use JS tokenizer and parser, which is really complex.

███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████

Tags: #code

October 6, 2024

██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████

███████████████████████████████████████████████████████████████████████████████████████████

Just chilled at home, not doing much. Sadly it stopped raining when I finally woke up (as always), so I didn’t get to sit in cozy place.

1000018727.jpg

1000018732.jpg

1000018735.jpg


Someone reported a bug in Nekoweb with git repo creation. For some reason pre-receive hook that I’ve made to prevent symlinks from being pushed was rejecting even repos with simple files. I started debugging it, and was trying to get the log from command by saving it to file, to check what file was causing it to fail, but for some reason, my file was simply never being created. So for some reason pre-receive hook just failed without running any code inside, yet if I removed it, everything was working fine again. It was extremely confusing, and I tried so many random things but just couldn’t make sense of why this is happening.

When I opened pre-receive file in nano, I’ve noticed that it said «DOS mode» for 1 second on open, and got curious what exactly that meant, and it just meant that file used CRLF newlines. I converted file to use LF… and it worked… After so many hours it was caused by this dumb thing that didn’t even require changing any code at all. And I couldn’t find the bug in git because it ignores newlines.

You might wanna say that git automatically converts files to use LF, and you’d be right. But I actually had to disable this like half a year ago when I added Git server to Nekoweb, because for some reason it caused issues with files in users repos.


As always, more Yume 2kki. Went on another pretty long expedition to Dragon Statue World.

Found another cozy sewers world:

1000018739.png

There’s a secret room in it, with very beautiful music and a humble inhabitant in there:

1000018740.png

Most notable discovery was a huge shortcut that unlocks between Library and Memory Garden, and it has this, extremely cozy room:

image (17).png

I love hot water pipes and warm orange color lights. What’s kinda crazy is that I had sort of revelation yesterday, and tweeted this:

1000018742.png

Literally predicted what I would find in Yume 2kki.

List of my favorite places so far:

  1. Sewers (Marijuana Goddess > Dark Room > Sewers)
  2. Secret Society (i forgor)
  3. Memory Garden (Library > Memory Garden)
  4. Rainy Apartments
  5. Pillar in Amoeba Woods (Keyboard > Amoeba Woods)
  6. Secret Room in Silent Sewers
  7. Fairy Tale Woods (i forgor)
  8. Data Stream (i forgor)

October 4, 2024

Wow, my body actually hurts after gym. I thought at gym that I didn’t really do that much so nothing will hurt, but nope! That’s a good sign.

Continued coding UltimateWS today. Well, I finished it. To implement createWebSocketStream I literally copy-pasted file from ws repo and it worked. That’s even more satisfying than when external things that rely on your library start to work, since usually internal implementation is very different.

Since both UltimateExpress and UltimateWS are done, I was finally able to migrate my website fully to use these libraries! It was annoying, boring and tedious. It’s genuinely crazy how large and complex my website is, and it has such a ton of actual tech debt. In a fucking personal website.

And what’s crazy is that uWS worked almost off first try with my chat and Grillbys. The only thing that needed to be fixed is a check for isBuffer. Migrating to uExpress revealed another bug in it, with trailing slashes, and it has been also successfully squashed.

Now I’m finally free from coding these things… probably… there’s almost definitely gonna be a lot of bugs I’ll need to fix, but it’s better than having to actively code it. I’ll continue switching my projects to my libraries.

It’s really cool to think that you’re actually using your own HTTP and WS servers. Well, ofc the real magic is in uWS, but still, it’s a lot of work to make it all work nicely.

Tags: #code

October 1, 2024

Went outside to withdraw money. Stood outside for a while to enjoy the rain, and met tailless cat again. Might be a good sign.

1000018579.jpg

I figured out how to optimize IPs! Now I only read IP when it’s required and if any request ever reads it after response was sent I start reading it always. This way only 1 request at most would be lost. To minimize that from happening I also made it always read IP for first 100 requests.

Before:

1000018586.png

After:

1000018587.png

Now the difference is really small, HyperExpress is genuinely basically useless now, lol.

Brother came over and we finally decided to go to gym… but it was crowded and shitty again… so we decided to go to more expensive gym afterall, because we both got another discount, but as we came there again it was again kinda scam shit with tiny text saying it cant be used for what we wanted lol. But we still had previous discount and we decided to go with this one after all… It’s just like 10 times better and also had a pool. They took so long at registering us that it was already too late to go actually do anything so we ate and went home. I hope it won’t be a waste of money.

At the end of the day found another optimization opportunity of not creating Socket needlessly, which added another +5k.

September 30, 2024

I have no idea what did I do for the first half of the day.

Played more Yume 2kki. The slide is so fun :3

1000018573.gif

Continued optimizing uExpress. Apparently tseep is quite slow on initialization, so I switched Socket to use built-in event emitter, since there’s a ton of these being created. For long-running stuff it continues to be used. About 2k improvement.

Then I tried removing random parts from code to see for possible slow things and noticed that reading IP is literally 15k req/sec slower! I have no idea why, but res.getRemoteAddressAsText is super slow. I switched it to res.getRemoteAddress and made parsing it lazy and that improved speed by 5k. I really, really wanted to get that last 10k by somehow lazily reading IP but it seems quite literally impossible sadly.

Before:

1000018571.png

After:

1000018572.png

As I went to bed I got email that tests failed, and apparently they just hanged for 45 minutes, but I already published it to npm… Had to make Shy fix it for me while I’m in bed. Thankfully he did it and now I can rest.

September 29, 2024

Woke up and UltimateExpress got some more attention while I was asleep. Someone asked me to add a table with comparison to other frameworks, and gave me link to bun-http-framework-benchmark.

I started setting it up to add UExpress, and noticed that in pull requests there was already PR to add it! But… it had ETag enabled and needlessly set middleware to all routes… With that awful code config, UExpress was performing absolutely terrible, so I made a comment telling what to change.

But performance was still quite bad even with these changes, so I started to look what could be improved. Benchmark itself consists of 3 tests:

  • ping (just a simple response)
  • params + query
  • post with json body

I’ve decided to check Elysia.js codefor possible speed improvements I could do, and apparently they use fast-queryparser library. Unfortunately, it doesn’t support array queries like qs does, but I could work around that by checking if string includes [ or . characters, and speed increased by a considerable amount.

Then I started to look at what could be done with params, and I realized that routes with params can actually be optimized the same way other routes are! But ofc the problem here wasn’t in routing itself, but in parsing of params. At the moment it was using regex for that. I implemented optimization of param routes, and with that I could use uWS native param parser, so I could skip parsing routes with params. Another quite large speed improvement.

After these changes, params+query test basically matched speed of ping test, meaning there’s barely any work being done anymore. But JSON test was considerably slower than other ones, and I realized that I’m using Express’s body-parser library for that, which uses Stream to read content of body. Instead of doing that, I implemented my own JSON parsing middleware that reads directly from uWS (unless reading already started, which can happen with async middlewares). And that increased speed from 30k to 40k req/sec for JSON test!

I had to make these optimizations quickly, before PR was merged. Other body parsing middlewares can be improved the same way too, so I’ll work on that.

Tomorrow, university session starts. They became quite lazy this year, with no classes at all scheduled for this session… Dean just told me to email professors myself.

… Now it’s 3 AM and I finished coding other middlewares, and all benefitted from the rewrite. There has been a bug ever since I switched Nekoweb to uExpress that made assets not update. For some reason they got cached in Cloudflare. I finally figured out why it was happening, apparently Express does support If-Modified-Since, while I didn’t support it properly. My version was not sending headers, including ETag and more importantly Cache-Control, which made Cloudflare default to normal cache time. Also that bad version got merged, so I quickly made a PR fixing their code and it got merged too, phew!

Now it’s all fixed, and everything is more performant. I’m satisfied.

Tags: #code

September 28, 2024

Started coding UltimateWS today. I was wondering if I should first finish UltimateWS before publicly publishing UltimateExpress, but I’ve decided that it’d be kinda weird to make 2 announcements at once, so today I actually published Ultimate Express. Honestly, I expected more reaction and interest. While I did get about 50 stars, I don’t think it’s a very good result and I feel a bit disappointed about it. Hopefully it’ll grow more eventually.

It’s been a nice rainy day, all day. I’ve been enjoying rain sounds for a while, and decided to go outside and feel rain on myself. I got winter clothes and went outside, and stood in the rain for a while. I love the feeling of being protected from rain by clothes. If I had a comfortable spot, I would probably just sit down and spend hours just sitting under rain, while hiding in my clothes fully. Clothes that fully cover me and allow me to get inside them are so cozy…

1000018526.jpg

September 25, 2024

The most unpleasing thing in coding uExpress is routing. At this point, I don’t really understand what I’m doing. I get ideas on how to improve/optimize it but I often just make guesses on how it’s supposed to work. It’s no longer code I fully understand.

Today I fixed route optimization after I refactored callbacks and also implemented optimization of Routers. I could only figure out how to optimize 1-level deep routers, but I think it’s enough for almost all applications.

Roommate invited his friends today, and they were talking loudly and seemingly having fun. I had 2 energy drinks in my fridge, and they disappeared. So they just drank my stuff without permission…


Walked through the entire path to Rainy Apartments again. We wanted to explore it a little bit more, and just enjoy the scenery again.

1000018483.png

September 22, 2024

Yay, fixed issue with hanging! Apparently it was caused by pushing too much data into Writable stream. uWS returns about 512 KB chunks, while Writable disk stream can only handle at most 128 KB (and by default Express sends 64 KB). After I made it save data in buffer and only send 64 KB chunks instead it works! No more hanging and empty files.

Tags: #code

September 21, 2024

I think I’m getting sick of coding this thing now. Now coding it is not fun but constantly frustrating. I have finally finished the last thing in the compatibility list and started testing it on my real projects, with first one being Diary. It couldn’t start at all for some reason, and apparently I needed to make sure port is a number. Then for some reason assets kept sending 404’s, and that was due to bad handling of conditionals. After I implemented If-Modified-Since properly it fully worked with no issues! Diary can use uExpress fully.

Then moved onto Nekoweb. Immediately there was some issue with routing, request was replied twice. After some terrible debugging session (uWS fucking removes stack trace!!!) I managed to fix it. But now I’m stuck at weird issue with express-fileupload, it just doesn’t write anything into file and often hangs forever, and I’m not sure why it’s happening. So frustrating. I also realized that my solution with skip keys is actually terrible, Nekoweb has a ton of middlewares on each endpoint, but with my way it has to go through every single one when it could only check pattern once, so I’ll have to recode that as well.

Tags: #code

September 20, 2024

Very frustrating day of coding. Had to fix a huge amount of random routing issues and bugs. Implemented If-Range header and options for Router(). There wasn’t that much progress today because of these random bugs that took hours to fix. ████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████

Brother visited me today, we talked a little, but there wasn’t really anything interesting in that. Cooked khinkali:

20240920_190351.jpg

September 18, 2024

██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████

Spent the day going through Express middlewares and testing if they work with uExpress. While checking cookie-session middleware, it didn’t set the header for some reason. After a long debugging, I saw that this code was causing the issue:

image.png

It checks for res.set (which I have implemented) and then uses node’s class setHeader function for some reason. Since I don’t implement that class, I started to think what can I do to fix this.

At first I tried to implement the class, but it caused random issues and almost definitely caused slowdowns, which I really didn’t want. I started thinking of some dumb things like removing res.set if usage of cookie-session was detected, but it’d be extremely terrible and could cause random bugs. I almost gave up and marked it as incompatible (which I had to do with compression middleware due to similar random issues), but then I’ve decided to check Node.js’s code and check what that function does:

image.png

So it did set the header, but used something called kOutHeaders as key. I scrolled above and this is what I saw:

image.png

Which was:

image.png

I don’t have a lot of experience working with Symbols, so I googled and apparently it’s a way to create unique identifier. So I couldn’t just call my headers object kOutHeaders, I had to actually get out that symbol from there.

At first, the most obvious attempt, I just tried to require it from internals like const { kOutHeaders } = require('internal/http'), but Node said that internal/http doesn’t exist. Apparently you can’t access internal modules without a flag, so this definitely wouldn’t work as a solution.

Then I went with a second attempt, I got out http.OutgoingMessage class, created an object from it, and tried to use Object.keys() on it, which sadly did not show any Symbols, only strings. But to my blessing I found out about Object.getOwnPropertySymbols(), and it worked. I got out kOutHeaders from internal module!

image.png

After I added this[kOutHeaders] = this.headers;, it resulted in a bit weird format that Node.js internally uses, so I had to write a proxy that would actually use correct format for my object:

image.png

And everything started to work!

image.png

All middlewares I use in my servers work fine, yay!

More Yume 2kki at the end of the day. Today’s worlds were definitely more high quality than usual but I still haven’t found something to be really memorable. Visited Secret Society again to appreciate it’s beauty.

1000018332.jpg

[1] 2