Tag: code

Sync to my phone

I originally planned to make a Rust program that would fix the broken encodings in my music files. Luckily, I could solve that without Rust. Luckily, because from what I’ve experienced since then, it would’ve been a horrible pain in the ass to do.

I still wanted to give Rust a try. Contributing Servo is pretty much out of question – it’s just too high level to jump into as a complete beginner. (And honestly, I don’t think I’ll get past “complete beginner” with Rust anytime soon if ever.) It wasn’t hard to find another issue.


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.


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.


Rails counter_cacheの罠

counter_cacheはいいぞ。 #いいぞ

counter_cacheって?

アプリの大きさや目的に関わらず結構早い段階からいろんなものを数えたくなる。ユーザー何人?記事についてるタグ何個?


ルビーのパパ

昨日またルビーイベント参加してきた。今回はルビーの作者マッツさんの話が聞けるという訳で楽しみだった。実際に気になっていたことや、ここから半年で気になるだろう的なこともいっぱい聞けてよかった。


MedBeer: Rails 5.1

昨夜医療サービスのメドピアさん主催のRails 5.1勉強会に参加してきた。タイトルから見ると大した勉強になる期待はしなかったが、予想外に有意義だった。一番面白かったのは最初と最後。


Clojure始めて5日間

Clojure(以降ローマ字に切り替えるのめんどいのでクロージャーと)の流行りに流されてしまった。

ラムダ計算は苦手だけど、苦手だからこそ挑戦したかった。弱みがあるの知ったら直したくなるのは性格。ジャヴァも苦手。別に言語としてどうこう以前に、この前アンドロイドアプリ作ってみてすごく苦戦したのは後味が悪い。