Tag: code

k3s

Having played around with the managed Kubernetes offerings of various cloud players (DO, AWS, GCP), I was wondering if it was possible to do this cheap. My site doesn’t have much traffic or anything complicated really, so running it off a $5 DO droplet is reasonable. Sadly managed Kubernetes offerings won’t come out so cheap. (Sure I could leech off the starting $300 GCP credit for a year then keep hopping accounts, but…)

Then I read about k3s. The people behind Rancher made it as a lightweight (but functionally complete) Kubernetes distro. Lightweight, they say… Just how light? (Imagine a weird maniac light in my eyes here.) Could I run it on a $5 droplet?


Garden

I think many people of my profession got recommended a certain article by Medium in their weekly digest. The launch-introduction post by Garden got my attention too. I’ve been trying to figure out how to deal with developing on Kubernetes, so every drop of information in that regard is much welcome.


Mapping

The other day I was thinking about Rich Hickey’s keynote at last year’s Conj. He goes into how the literal maps (or hashes or hashmaps or however a language prefers to call them) are really functions too. A function in maths is a mapping between sets and that’s what maps are.

Then that makes functions we normally write are just like that too, except the mappings are more abstract and defined through code. Because the mappings are so complex and indirect, we write tests to check (automated) that the mapping we defined through code is correct.

Obviously defining the exact mappings for every possible combination of the input set(s) is not feasible (that’d be a map, the end). But if “all” is not possible then how much is? What exactly is the absolute minimum amount of test( case)s that’s useful?


SNS連合とActivityPubで通信できた

タイトル通りではあるが、その言葉全部通じない人も少なからずいるし、そもそもどうやっては書いてない。まずは言葉の定義から順にする:ActivityPubって何、それを使った通信が一体どんなものか、SNS連合とは何なのか、そして最後どうやってそれと通信できたかを述べる。


手軽に可視化したい

ここしばらくは空いてる時間でキツネという分散型SNSを開発している。分散型SNSは一台のサーバーで完結せず、ActivityPubやOStatusといったプロトコルでいろんなサービス(Mastodon, Pleromaなど)とのサーバー間の通信も重要。

本番に上がって使ってもらう時はもちろん、現状の開発中でもログは不可欠。バグがもしあった時に、いちいちデバグ文をあちこちに入れて何とか原因を突き詰める作業をできるだけ減らしたい。俺に考えつくのは、例えばリクエストや処理が失敗したとしても、初段の調査に最低限必要な情報は既にログにあるようにしたい。


No JavaScript, please

The other day I got an email from Axosoft that the payment for my GitKraken license (yes I use GitKraken) was rejected by my credit card company. It was because the card I used there expired, but nonetheless I had to take action.

That involved going on their website and changing my payment method to a card that still worked. It involved first an overwhelmingly complex table like this.


Mounting folders as Docker volumes

When trying to pass data between a Docker container and the host, using ADD in the Dockerfile might be sufficient at first. However, it’s one way, get burned in the image and so very inflexible.

The usual solution is to mount folders using docker‘s -v option. It’s simple, easy to use and pretty reliable. Just add -v "$(pwd):/root" and the current folder will be mounted to the /root folder in the container.

Using volumes is nice because they’re (can be) two way and (can) sync in real-time. Now you don’t need to rebuild your image every time you fix a typo. -v has pretty deep configuration options too, in case you want to go down the rabbit hole.


Using Java signatures in Clojure

A while back I was trying to implement HTTP signatures to use with ActivityPub interactions with Mastodon. In Clojure. There is a go-to library for Clojure when it comes to crypto stuff, but I couldn’t get it to do the specific thing I needed: SHA-256 / RSA signatures. I looked at other options too, but as I’m not familiar with NaCl, that was just a confusing mess of wrappers around Java wrapped around C.

In the end I went with using Java interop to call Bouncy Castle stuff directly. I hate Java and interop in Clojure just feels wrong, but at least I could get it to work. Not to mention if something, Bouncy Castle is maintained. It wasn’t exactly a joyride, but it works. Check out the source if you’re interested (or want to use it). I didn’t make it stand-alone or put it up on Clojars (yet).


Dealing with weird keywords in Clojure specs

Recently I’ve been working on a Clojure implementation for ActivityPub. In the process I wanted to use specs, but I ran into a pretty significant problem. Namely the very first line in basically every single ActivityPub JSON object: { "@context": "https://www.w3.org/ns/activitystreams" }.

Do you see the problem? Well. This JSON will arrive at the server, where it’ll be handled by Cheshire or something along those lines. Point is, keys in JSON maps will end up turned into keywords. Clicked the link? The guide isn’t exactly specific about what can and can’t go into a keyword.


The case of the deaf BroadcastReceiver

This weekend I decided to upgrade my old Android #nowplaying app. For the new version I decided to use Kotlin and also make it usable from my Android smartwatch. Honestly, it went much smoother than expected, except for one big caveat.

Out of some weird impulse, I decided to target the Oreo SDK (26). Both my phone and my watch are Oreo based, so that wouldn’t be a problem. Yet I kept running into the weird problem that my BroadcastReceivers wouldn’t receive any intents whatsoever. Interestingly enough, the WearableListenerService I used to to listen to Messages from the watch (I want to post when I tap a button on the watch) worked almost instantly.