Munching the squares of immortality

Become Immortal is at this point the only 1kyu kata I tried (and solved) on CodeWars. It took me 3-4 days to solve it. It was definitely pretty damn difficult to figure out, but in the end I managed it myself.

Looking at the example tests it was immediately obvious that trying to generate the actual rectangles and xoring everything was out of question. For the heck of it I tried once, but even for the last “basic test” I’d run out of memory (on my desktop) very quick. Sure it works fine if the rectangle is 30-40 rows and columns, but not for scales in the millions. I used it to dump rectangles on the console and double check my solution.


Product of integer partitions

Another CodeWars kata, by the same person who did Twice linear. It was annoying in a different way. Once again, a naive solution was out of question (or so I thought), so I kept trying to figure out a way to shortcut the whole problem with maths.

Generating the integer partitions (and their products) isn’t particularly difficult. There are plenty of resources out there about how to do it – though for some reason mostly in Python.


Talk about linear

There’s a CodeWars kata called Twice linear. It’s one of those problems where a naive solution is just not feasible. Not to mention the first tests aren’t indicative of what’s expected so by the time I hit the wall of very big numbers, I already had a solidified (and naive) mental model. Getting rid of that isn’t an easy task.

Generating the list of numbers isn’t difficult. Keeping it sorted and not adding duplicates makes it a bit more tricky. I tried using Ruby’s SortedSet at first, then Enumerators and plain loops, but everything crapped out at bigger numbers. All tests are supposed to run within 12 seconds on CodeWars, and my code at that point was taking 20+ minutes to run for 60000.


CodeWars

I really like Medium’s weekly digest. It keeps providing me with great articles. A few weeks back there was one with advice from a young girl developer, and (among other pretty solid advice) there was a mention of a certain CodeWars. First time I heard of it. This was Thursday evening.

On Sunday I had 50 or so kata behind me and I was challenging an 1kyu one. It’s really addictive, because I just keep pushing the “next kata” button and can’t rest until I’ve dealt with it. However, this approach doesn’t work if I wanted to solve 5 kata a day as advised, because the algo keeps giving me harder and harder challenges, and even “easier” ones end up taking a few hours.


Passing the correct remote address

Today I was playing with my database in PHPMyAdmin, when I suddenly realized that it’s up there open to anyone who can guess the path (which isn’t a very hard task). I decided to only allow connections to it from my home IP, which shouldn’t be such a difficult thing to do. Except Apache is behind an nginx reverse proxy, so it kinda is.

I’ve noticed before that all Apache access logs show the remote IP as 127.0.0.1, localhost where nginx is running (and proxying requests). I didn’t really care about it, since it’s just a personal site, but now that I wanted to use the actual visitor’s IP address to limit access, it was a whole different story.


Hong Kongban

Anno azért találtam ki, hogy Hong Kongba megyek az új évre, mert volt vagy húszezer lejáróban lévő mérföldem a törökökkel, és mivel eszemben sincs soha többé velük repülni, gondoltam, elhasználom mindet. Amiből végül nem lett semmi, mert a (különben kellemesen olcsó) repülő, amit találtam, “code share” járat volt (vagyis több légitársaság közösen üzemelteti), és ilyeneken nem lehet osztályt emelni utólag (amiről persze nekem senki nem szólt előre). Sebaj, majd legközelebb. A török mérföldekből meg rendeltem táskát-satöbbit szüleimnek, hogy legalább kárba ne vesszen.

Elvileg a tél közepe volt Hong Kongban, de ettől nekem még pólós idő volt. Kivéve talán új év éjszakáját, amikor azért a vállamra vetettem a pulcsimat. Helyiek párszor meg is jegyezték, hogy annyira azért talán nincs meleg (de igen).

Wan Chai


人と

人に行動合わせるのはめんどくさいし、一人の方がずっと自由。だから「食事は一緒にした方がおいしい」とか、「ライブ一人で行って何が楽しいの?」とか言われるとなかなか理解に苦しむ。

人と一緒に時間を過ごす前提なら、人と一緒にしかできないことをしたい。それはおもに会話。あと、ゲームやスポーツも人と一緒にしかできないものがある。


About certs, for version control

Version control in the sense that I haven’t made any Ansible (or similar) scripts to deal with this, so I have to keep writing blog posts not to forget what I did and managed.

For ages now I’ve had Apache crashing (at least so it seemed) at regular intervals. I had no idea what was causing it, so I just added a crontab entry to (try to) start the Apache service every 5 minutes. That solved the issue of 502 Bad Gateway errors, but not the cause for them.


Subcomponents in Vue.js lists

In my winter break I’ve been working on a Vue.js client for Mastodon. I’ve got two big reasons for doing it: I want link/video previews on my timeline and I have to get familiar with Vue for work.

I’m not very familiar with Mastodon’s API, nor with Vue, so I think I’ve been running into lots of problems that I shouldn’t have. For example, I added card (that’s the Mastodon name for link or video previews) autoloading to the timeline and I noticed something weird.


Wizard of Earthsea

Yesterday I set a bit of a stretch goal for myself: read a whole book. There are still plenty on my shelf that I could read in (half) a day, but in the end I went with Wizard of Earthsea, that just arrived yesterday too.

I didn’t know much about the series, only that it was adapted into a Ghibli movie (that I haven’t seen) criticized by the author. But it’s youth fiction, so I supposed it was  easy (and quick) to read, and I wasn’t wrong.