Tag: english

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.


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.


Todos

I was afraid I would forget something I wanted to do today, so I used a TodoMVC demo to keep track of what I wanted to do today. I have a bad habit of “wasting” weekends just playing games or idly staring at Twitter and Mastodon – not necessarily wasted, actually, since that’s plenty of recovery and mental idle after the tightly paced weekdays.

The point is rather that I often do that and not do things that I’d want or need to do, and that’s where the list comes handy. Actually on Mastodon I was pointed to Habitica for the same purpose, and I did register too, but at first glance it felt a bit too much for what I needed (an absolutely minimal todo list) and also counter-intuitive with its game-like system.


Dual screen workspaces in Ubuntu 17.10

I expected the aardvark to break a couple of things. They switched back from Unity to Gnome, so even more than usual, I feared the system might not even start.

Compared to that, things went quite smoothly. One problem I ran into is how Gnome devs apparently never used a dual screen setup, and thought it would be a good idea to only switch workspaces on the main screen, and keep the other screen static. Needless to say, that’s not how workspaces are supposed to work.