RSSAmplifier

Blog

Alex Peattie – Engineering leader and former founder, based in Paris

Writing about software development and startups.

alexpeattie.comRSS feed ↗30 posts

Latest posts

Quick tip: simple unique jobs on Solid Queue

footnotes-highlight#highlightFootnote"> I recently migrated from Sidekiq to Solid Queue on a personal project, and generally found the transition to be quite painless. However, at the time of writing, Solid Queue doesn’t support unique jobs, either natively or through a 3rd party gem. (Sidekiq has both, through the popular sidekiq-unique-jobs or via its Enterprise offering .) The good news is that…

Testing Kamal Locally with Multipass

footnotes-highlight#highlightFootnote"> From Rails 7.1 onwards, Kamal 2 is included as a first-class tool for container-based deployments. Kamal aims to make shipping Rails apps to production as painless as possible using Docker. However, before you set things loose on your production servers, it’s often helpful to test your entire deployment flow locally, but deployed to a virtual machine (VM).…

Establishing the minimum number of guesses needed to (always) win Wordle

footnotes-highlight#highlightFootnote"> A few weeks ago, I became interested in whether there was a strategy to always “win” Wordle (i.e. to find the secret word in 6 guesses or fewer). This is exactly the problem that Laurent Poirrier examines in his excellent writeup on applying mathematical optimization techniques to Wordle: Is there a strategy that guarantees to find any one of the 12972…

Quickly associate all source code files with your editor in macOS using duti

If you're a developer using macOS you've probably had the experience of double clicking, say, a file in Finder only to inadvertantly launch the wrong application, rather than your editor of choice.

Making HTTP requests with Deno

Deno makes it easy to make client HTTP requests, using the web standard Fetch API.

PSA: Don't use cssnano from within postcss-loader

While redesigning this site, I ran into an odd problem: my build pipeline was generating CSS source maps but they were somehow getting messed up. Definitions were pointing to incorrect lines, and sometimes the wrong file altogether.

Quick tip: Loading a plain IRB session with no syntax highlighting or multiline editing in Ruby 2.7+

One of the nice additions in Ruby 2.7 is that IRB by default gets pry-inspired syntax highlighting and multiline editing by default.

How to load local PostCSS plugins with postcss-loader

PostCSS is a great tool for enhancing CSS and it has an extensive ecosystem - postcss.parts has a great catalog of available plugins. It also make it quite easy to write your own plugins to extend CSS in weird and wonderful ways. If your plugin is particularly lightweight though, you might not want to bother with the overhead of creating a package, publishing it to NPM etc. Fortunately, it's quite…

Stop forgetting your foreign key indexes in Rails with this simple post-migration script

One of our New Year's resolutions at Peg was to make the site faster. For the most part the site was responsive (requests completed in < 100ms), but certain pages were taking much longer to load than they should - with database queries eating up most of the time.

Quick tip: Set the default controllerAs to vm for .component() in Angular 1.5+

One of the most exciting features in the newly released Angular 1.5 is the new helper method (see Todd Motto's excellent, detailed write-up for a full walkthrough). It's now considered best practice to use - a best practice which enofrces. If you don't provide a value for it will default to .

Signing a CSR with an ECDSA key in Ruby

:::admonition[Update 2020]{kind="update"}As of Ruby 2.2, signing certificates with an EC key is almost identical to a signing with an RSA key: The only difference is that you need to set to rather than (as you'd do with an RSA key).::: Let's Encrypt just rolled out support for ECDSA certificates in staging - a move that I think will nudge ECDSA signing more into the mainstream. ECDSA offers higher…

Rails tip – Grouping ActiveRecord objects by day or week using datetrunc

Here's a quick Rails question for you. We have a bunch of Posts in a Postgres DB which we want to order by publication day - but Posts published on the same day should be ordered by a different column: upvotes. (This is basically how Product Hunt does it). We're paginating, so we only care about the first 100 posts. How would we do it?

Retiring two old projects – animate-textshadow.js and CSS floating feedback button

Happy New Year! First of all I'd like to wish everyone reading a wonderful 2016 😁. New years are traditionally associated with new beginnings - clearing out the clutter of the previous year to start afresh. In that spirit, I'm retiring a couple of my old projects animate-textshadow.js and my CSS floating feedback button tutorial. I won't be actively maintaining them anymore, and they are…

Handling strong parameters in Devise 3.1+

In Devise 3.1+ there's a new way to handle Rails 4's strong parameters. Here's a quick rundown of the change, and how to migrate to the new style. (Background: I wrote the pull request that helped form this feature).

Better GitHub-style syntax highlighting with Rouge

:::admonition[Update 2020]{kind="update"}This tutorial is out-of-date. See the repository for alexpeattie.com to see how I do it now.:::

Cross-domain communication without CORS

In a recent project, I had to send data between two subdomains on a site. Unfortunately, this meant I had to deal with browsers' same origin policy. The canonical solution to this is to set up Cross-origin resource sharing (CORS) , but this is a bit of a pain to do[^1] - especially if you're only making one or two cross-domain requests - and it isn't supported by some older browsers. Luckily there…

Why you might want to silence console.log

might be the most useful debugging tool in a front-end coder's arsenal. If you aren't using it, go read Mastering Console Logging to see why its so awesome.

Two awesome APIs you probably haven&#39;t heard of: SharedCount and RESTMailer

I wanted to highlight a couple of APIs which I've found very useful, but haven't seemed to have gotten much exposure: SharedCount and RESTMailer. I have no connection to these services, I just think they're great!

How a seaweed expert and a screw-up helped win WWII

Dry Storeroom No. 1 Earlier this year I read a surprisingly fascinating history of the Natural History Museum in London - Dry Storeroom No. 1: The Secret Life of the Natural History Museum. One of the best stories in the book recounts how an embarrassing mixup involving a cryptogamist (i.e. algae expert) turned into an unexpected triumph:

TwilioCon 2012

TwilioCon Earlier this month, I was fortunate enough to be invited by a client to attend TwilioCon 2012 in San Francisco. I'd had some experience working with Twilio already, but I definitely came away from the conference having learnt a lot.

Two quick tips to speed up Rails 3 on Heroku

There are lots of ways to speed up your Rails site, but here are two I see a lot of sites neglecting: gzipping and serving jQuery by CDN.

Teaching computers to rap

Today I was lucky enough to stumble on this fascinating paper by Nguyen and Sa describing how they created an automated rap lyric generator. It's well worth a read.

jQuery gotcha: visibility vs. :visible

Something I ran into today - the behaviour of jQuery's selector (and its sister selector ) is somewhat unintuitive - at least after version 1.3.2. From the jQuery docs:

GitHub-style syntax highlighting with Pygments

Update 2016 : This tutorial is out-of-date. See the repository for alexpeattie.com and the associated README to see how I do it now. A few people have asked me how I do the Github-style syntax highlighting on this site. Here’s an example Ruby script with highlighting: class A &#x3C; B ; def self.create ( object = User ) object end end class Zebra ; def inspect ; "X #{ 2 + self. object_id } " end…

Site redesign

My project for February was a redesign of the site. As well as overhauling the look of the site, I revamped the site's internals -- migrating the site from Jekyll to Middleman.

Defining versions in Ruby gems

This post is inspired by a question I answered on StackOverflow a while back, asking about the best way to define the version of a Ruby gem.

Improve JS performance with $.noop

Just a simple tip that you might not be aware of - if you have an empty, anonymous function in your code like this:

New projects - CSS feedback button & animate-textshadow

animate-textshadow and Pure CSS floating feedback button It's been a while since I blogged last. Since then, lots has happened in the tech world: we had the S3 apocalypse, the PSN debacle, Microsoft bought Skype, the world bought LinkedIn shares. I've been keeping myself equally busy, and I'm going to be rolling out a bunch of new coolness over the next few weeks.

JustVector Icons update (v1.5)

Dropbox, Quora, Pinboard and Ping Last month I released the JustVector Social Icon pack, 100 monochrome vectors for social sites and services. Really, the pack was a selfish endeavour: although there are plenty of social icon packs out there, what I wanted - no frills, full-scaleable vectors for all common sites - was difficult to find. But the feedback I've gotten suggests others have found the…

Working with dates in Git

When working in git, you most commonly trace a repository's history using commits' SHA-1 hashes. To revert to a previous commit, you might write something like this: