Selenium and Asynchronous Javascript

When using Selenium in automated tests, sometimes it becomes necessary to execute Javascript. Whether that’s due to the presence of a canvas that has no obvious click zones, or because of important information attached to the page that’s not visible from the DOM, here’s a trick that may help you out along the way.

Continue reading »

Calling All Elixir Actors

Elixir’s Actor Model

Concurrent computation, it’s unescapable. Elixir is known as a highly available concurrent language, but what does this really mean? Elixir’s concurrency model is built on the Actor Model, but what is it?

Continue reading »

Rails Migrations: When you can't add a uniqueness constraint because you already have duplicates

For work, I picked up a bug where a CSV export was creating duplicate rows when it shouldn’t have been.

We generate the CSV export with a big ol’ SQL statement in some Elixir workers, and got the bug reproduced and found the problem was with how we did some joins on other columns.

We had something in the statement like this:

LEFT OUTER JOIN `reports` ON `reports`.`id` = `people`.`report_id`
LEFT JOIN `addresses` ON `addresses`.`people_id` = `people`.`id`
LEFT JOIN `favorite_colors` ON `favorite_colors`.`people_id` = ``

In this highly contrived example, I found out that we’re expecting a single row in the favorite_colors table for each person, but we were getting multiple favorite_color rows.

Every time we had a duplicate row on that joined table, the LEFT JOIN created two rows in the export, even though there should have been one.

Continue reading »

Quick Tip - debug()

If you’re using any sort of linting in your code (and you should), you will more than likely come across a default rule that screams at you for leaving all those handy console.logs in your code. Those logs sure give useful information, but it is admittedly an unprofessional (and potentially insecure) thing to leave in your production code. Are there any other options?

Continue reading »