Phaengris.Art hand-drawn arts, city photos, linux / dev stories

How to Use Yjs in Rails With Importmap

Yjs is a CRDT (Conflict-free Replicated Data Types) implementation in JavaScript.

What it means is when you want many users work on the same document, permanently adding, updating, deleting parts of it, CRDT is what you need to synchronize document content between all of the users, automatically resolving conflicts between their editings.

Yjs provides a Ruby port and even an ActionCable-based adapter so users of your Rails application can enjoy collaborative editing using an ActionCable websocket connection.

Unfortunately at the moment of writing this Yjs is not so well suited “out of the box” to be used with importmap, which become a standard since Rails 7. Below is my (kinda hacky) recipe how to make it work.

Read more…

Embed Custom Fonts Into PDF Documents With Ruby and Puppeteer

When you need to build a PDF document from HTML, Puppeteer is the tool to use.

But things are not so obvious when it comes to custom fonts.

Read more…

Install Torch.rb on Linux

The process is simple but not without it’s pitfalls. Here’s the instruction how it worked for me. My system is Fedora Linux 38, but I believe it should work for other Linux distros as well.

Read more…

Manage Monitor Brightness in Linux With a Shell Script

Managing brightness with monitor controls is a pain. You’re lucky if you have a dedicated button or wheel right on the monitor to do that. Otherwise you have to find that tiny button somewhere under the thing and, well, do with it what you have to do. Repeat for the second monitor if you have any.

Giving that, the idea of using Meta + sound level wheel to regulate the brightness right from the keyboard was unevitable. Yep, you can do that in Linux, but of course in a Linux way, scrathing your head till a suitable bash script is born.

Read more…

Switch KDE Activities With a Bash Script

Yes, there’s this Activity Manager panel on the left, but I hate it there. On my 32:9 it is too far to reach. One may say that a true Linux person shouldn’t move hands away from keyboard at all 😄 but well, we all have our ways. I, for one, prefer a nice set of icons right on my autohiding panel in the middle of the screen. That’d be possible with a bunch of application links in ~/.local/share/applications/, making them refer to some script which would switch activity by name.

Read more…