RSSAmplifier

Blog

Dimiter Petrov

A programming blog written by Dimiter Petrov

dimiterpetrov.comRSS feed ↗29 posts

Latest posts

"We don't deploy on Fridays"

Hearing "we don't deploy on Fridays" makes me sad, because I always encounter it as a precautionary measure. Fear and precaution The subtext is "it's not safe to deploy" and "if there is a problem, it takes too long to fix". There is plenty out there about this topic. Search for "deployment on Friday". I almost forgot I've also written about this before . The arguments are more or less the same.…

How I test Stimulus controllers

I caught myself relying too much on manual tests for a feature I was building on top of a Stimulus controller. Manual tests were enough for the initial proof of concept phase. However as I was adding more features to the prototype, I was also causing regressions. As I threw away the prototype and started over with a test-driven approach, I thought about how I test in general and how that applies…

Dealing with flaky tests

Flaky tests waste your team’s time. Have a process for quarantining them and debugging them.

Service objects are poorly-named models

Look at any Rails codebase that's older than a few months. I bet you'll find a sub-directory of app called services . It comes with the best of intentions for separation of concerns. The developers want to keep controllers straightforward and focused on understanding a request and providing a response. They also want to keep models small, because those files have gotten too big and tedious to…

Have we moved past contempt culture?

In 2015 I read a great blog post on contempt culture . I had already noticed the described behaviour by that point, but I didn't have a word for it. Interestingly, the author of the post mentions starting programming in 2001. I started around that time, too. Probably 2002. It took 13 years before I stumbled upon an article pointing out bad behaviour I had both experienced and perpetuated. That…

Helvetic Ruby 2023: a personal retrospective

I ran the first edition of Helvetic Ruby with two friends. This post reflects my own experience and my personal thoughts on it. Preparation We started working on the conference early. Our first meeting was in early January 2023 and the conference was on 24th November 2023. While there were periods of more intense preparation, we usually did a little bit every week. That kept stress levels low for…

3 ways to model an associated collection in Rails

A look at the Postgres array type and good old join tables, each with their advantages and disadvantages.

Turn off notifications

Do you find catching up tedious when you return to work after a holiday? I do. It took me a while to do something about it. I'd even start dreading my return to work on the last day of holiday. On my first day back, I'd open my email inbox and see tens, if not hundreds, of new messages. Then dozens of notifications in Slack, and GitHub, and Trello, and so on. In recent years, I've drastically…

GitHub pull request merge strategies

An overview of what the options provided by the pull request merge button on GitHub do and how to make the best out of each strategy

Rails developers write some Rust: a review of Axum 0.6

Is Rust Web yet? We used our Rails knowledge to try writing a Web application in Axum in two days

Trying to prevent errors is good, being able to recover from errors is better

I'm the person on your team who does not fear deploying half an hour before the end of the workday. Not because I'm reckless, but because I'm confident in the process of recovering from errors. I work in short iterations, developing and deploying small changes one at a time. I have automated tests, code review, production monitoring and error alerts. If the deployment breaks something, it's easy…

Thoughts on onboarding and offboarding

When I'm joining a new organisation, I want to be useful as early as possible. I record what I observe until I get used to the new environment. Chances are my observations can turn into documentation or change of process that will make onboarding easier for the next newcomer. I want to prove myself, to show what I can do and be given responsibility. When I'm onboarding somebody else, I want them…

SVG icon sizing and alignment

Making SVG icons look right alongside text in web applications can be tricky. I'm writing down the techniques that have worked well for me, because I tend to forget them by the time I need them again. For me it's about: preserving the icon's aspect ratio and internal spacing, scaling the icon proportionally to the text, vertically aligning the icon to the text. Let's how these come together. Icon…

Working with constant interruptions

In 2018 I chose to become an engineering manager. It was clear to me that good teams, like good code bases, require constant work. Only, I wasn't just interested in shaping my team. I wanted to influence how the company worked in general, all with the top-level goal of creating a good environment for myself. I started getting involved in hiring, sales pitches, writing offers, strategic meetings…

Clean your backlog

The problem with big backlogs in software projects and how to keep the backlog small

Tips for applying to a job at a small company

Advice and encouragement for job applicants reflecting the Simplificator hiring process back in 2021

How to connect to an Apple Thunderbolt display from Linux

Although the Apple Thunderbolt Display is discontinued, it's still a good monitor and can serve as a docking station. It has a serviceable webcam, loudspeakers, an Ethernet port and USB 2 ports. The Linux kernel supports Thunderbolt. After connecting the device, check if it's listed by lspci . If it's not, you may have to enable "Thunderbolt assist mode" in the BIOS (at least for Thinkpads). The…

A subtle change in PDF output

A debugging story of rendering differences in PDFs after changing application hosting infrastructure

The trade-offs of two feature flag implementations

There is a lot of value in testing work-in-progress features in production. You discover edge cases by using real data and you can measure the performance impact in a production setting. Of course, testing in production doesn't necessarily mean releasing an unfinished feature to all users. This is where feature flags come in, allowing you to enable or disable functionality for specific users or…

Broken video in Safari after DOM change

Let's say you're using early 2000s web tech to speed up page transitions, but with slightly newer APIs. When a link is clicked, the new page is loaded asynchronously (for example with fetch ). Then a subsection of the current page is replaced by (a subsection of) the new page, using replaceWith (or replaceChild or a similar method depending on the implementation. There are many out there). It…

Github OAuth authorization with serverless functions

At work I take care of many aspects of an application's life cycle: provisioning servers and configuring monitoring, setting up and verifying backups, automating certificate renewal, developing and maintaining the application, etc. A lot of it is a consequence of client requirements about the location of their data. Still, I'm always on the lookout for ways to eliminate most of this work for…

A tale of flaky Cypress tests

I wrote some flaky frontend tests using Cypress and then learned how to make them deterministic. This is the tale of that adventure. An application I am working has a video player that should continue playing when changing pages. Additionally the player should be visible on the dedicated page of the video it is playing and hidden on other pages. The <video> element cannot move within the DOM,…

Setting up Cypress with Rails

Tips for integrating the Cypress testing framework into a Ruby on Rails application

Decoding disparate JSON fields into a custom Elm type

Update (2019-11-06): I think what I describe is an example of what people call " parse, don't validate ". I wrote a simple video player in Elm as an experiment. My earliest realization was that authoritative source for player state the HTML media element ( <audio> or <video> ) and not the Elm application. I decided to keep the Elm model in sync by sending the JSON-encoded HTMLMediaElement over a…

Long-lived background Ruby processes

I needed a way to run a process alongside a Rails application for an always-running live data ingestion task. Sidekiq is only meant for short jobs, but Sidekiq itself is a long-lived process. That gave me the idea to look at the source code of Sidekiq, Resque and Puma for inspiration. Update: In the meantime, Sidekiq itself has removed this capability and relies on a supervising process like…

Keeping Elm JSON decoders in sync with your Rails API

Implementing and consuming APIs is very error-prone. I've now worked on multiple single page applications written in Elm and I've grown to love the constraint of having to explicitly define JSON decoders. They are very helpful in exposing bugs and errors in documentation. In this post, I describe a strategy I've adopted to catch compatibility mistakes as early as possible. It involves JSON Schema…

A Self-Testing Test Library

After watching Ryan Davis present a way to write a test framework from scratch , I knew I wanted to try that on my own. Before I could get to it, I stumbled upon a video of Kent Beck writing a small self-tested test library in CoffeeScript . In it, Kent Beck demonstrates the effect immediate feedback has on a test-driven workflow, but it was the self-testing aspect that fascinated me. I set out to…

Elm Single Page Application Setup

Update (2018): While the ideas in this post are still valid elm-live will get you started a lot faster. Also check out the Elm guide section on minification . elm-reactor is good for iterating quickly on self-contained programs. You run elm-reactor , you navigate to the source file that contains the entry point to your program and you are up and running. elm-reactor automatically compiles your…

API Response Serialization with Plain Old Ruby Objects and ActiveSupport

If you are building an API application with Ruby on Rails, you will notice that the jbuilder gem is suggested in the default Gemfile . Jbuilder allows you to create JSON using a builder domain specific language. Some people prefer ActiveModel::Serializers which has its own DSL, is more declarative and handles structural conventions for you. This is convenient if you want your API to conform to the…