RSSAmplifier

Blog

Andy Callaghan

Hi I’m Andy Callaghan, an entrepreneur & long time Ruby developer from the UK. I live in York with my doctor wife Emily and golden dogs, Freddy and Peggy ...

andycallaghan.comRSS feed ↗10 posts

Latest posts

Apple relay emails silently failing?

I've lost my mind this week to an intermittent email bug with iCloud relay emails. I couldn't easily find this solved online - so here goes. LT;DR If you use: Postmark or any email service provider Allow customer to customise email FROM addresses, e.g. info@londonstudio.com Have Apple ID login on your thing Want to send email to your customers (probably a given) You need to setup SPF & DKIM in the…

Fixing Rails Active Storage with UUID Models

If you're using UUIDs as primary keys in your Rails application, you might have encountered issues with Active Storage attachments. This is because Active Storage's default migrations don't respect the application-wide primary key type configuration. Let's fix this! The Problem When you set up your Rails application to use UUIDs as primary keys (which is a best practice fullstop in my opinion),…

Custom CDN hostnames for images in Sanity.io with Astro

I recently ported the Jammed marketing pages to Astro, and wanted to use a custom CDN hostname for the images in Sanity.io. Officially, this is only an enterprise feature , but it was fairly easily to implement using Astro and a simple Cloudflare Worker to proxy and rewrite the image URLs. Astro and Sanity.io Regular plans for Sanity.io don't allow you to use a custom CDN hostname for images. This…

Securing Hatchbox servers with Cloudflare

I recently moved my Jammed Rails app to Hatchbox , and wanted to secure the server with Cloudflare. Hatchbox is excellent for Rails, and has native support for Wildcard SSL certs issued from the Cloudflare API, so it's an exceedingly happy union. What Hatchbox does not setup for you for Cloudflare however is the stronger security settings, so I thought I'd write up what I did to get it working.…

Improve caching for Rails proxied assets on Cloudflare

I recently ported the Jammed Rails app to Cloudflare, and noticed that the ActiveStorage assets were not being cached properly. I did some digging, and found this to be because Cloudflare issues BYPASS cf-cache-status headers for assets, due to Rails issuing a cookie with the assets. I couldn't find any Rails help or documentation on this, so I thought I'd write it up. Proxy Rails assets to origin…

Deploy a Gmail-like email server in 30 (ish) minutes

A recent HN discussion got me thinking - why don't I try and run my own email infrastructure? Some of the main reasons I hadn't previously tried might come naturally: Email servers are a pain to set up They're open to attack Hosted email is fairly inexpensive and easy to set up I recently expanded to having three different domains for email - one for general web logins & CVs, one I give to just…

RSpec matcher to validate sitemaps

We use the gem rspec-sitemap-matchers to validate and parse some sitemap files, but it can't validate against the sitemap standard XSD, so here's the code snippet. . / spec / support / matchers / valid_sitemap_matcher . rb require 'rspec/expectations' module ValidSitemapExpectations extend RSpec :: Matchers :: DSL sitemap_xsd = Nokogiri :: XML :: Schema ( File . open ( 'sitemap.xsd' ))…

Git workshop

I've written a Git Workshop site That is all. peace

Defensive Modern Javascript

At work I've been recently exposed to a large and complicated React application written in ES6. Of all the refactoring I've been undertaking, I have noticed that there was not much defensiveness built into the classes and functions. By defensive programming, I mean writing the code in such a way that expects it to fail, and gracefully handles common and recurring problems in JS. You do this so…

Cleaning up local git repos

We often get to a point where we have billions of local git repositories that have been merged already, or abandoned - it's often difficult to see the wood from the trees. Prune remote tracking branches {% highlight bash %} git fetch --prune {% endhighlight %} This only deletes the remote references to these branches, if they have been deleted on origin - it doesn't delete them locally. It does…