Jamie Schembri's Avatar

Jamie Schembri

@jamie.schembri.me

๐Ÿด๓ ง๓ ข๓ ฅ๓ ฎ๓ ง๓ ฟ+๐Ÿ‡ฒ๐Ÿ‡น Ruby engineer in ๐Ÿ‡ณ๐Ÿ‡ฑ. Writing at schembri.me.

205 Followers  |  214 Following  |  934 Posts  |  Joined: 28.10.2024  |  1.6461

Latest posts by jamie.schembri.me on Bluesky

PointFactory builds an RGeo point, DRYing up similar calls across the codebase. Instead of returning the raw point, however, I define `lng` and `lat` methods on it, which are just aliases. This makes the resulting object more ergonomic without bike-shedding bigger tools like inheritance.

2/2

07.08.2025 07:24 โ€” ๐Ÿ‘ 1    ๐Ÿ” 0    ๐Ÿ’ฌ 0    ๐Ÿ“Œ 0
require "rgeo"

module PointFactory
  REFERENCE_SYSTEM = 4326

  def self.build(lng:, lat:)
    raw_point_factory.point(lng, lat).tap do |point|
      def point.lng = x
      def point.lat = y
    end
  end

  def self.raw_point_factory
    @raw_point_factory ||= RGeo::Geographic.spherical_factory(srid: REFERENCE_SYSTEM)
  end
end

require "rgeo" module PointFactory REFERENCE_SYSTEM = 4326 def self.build(lng:, lat:) raw_point_factory.point(lng, lat).tap do |point| def point.lng = x def point.lat = y end end def self.raw_point_factory @raw_point_factory ||= RGeo::Geographic.spherical_factory(srid: REFERENCE_SYSTEM) end end

Today I used a little technique I picked up from a @kaspth.com workshop: defining methods directly on objects.

1/2

07.08.2025 07:24 โ€” ๐Ÿ‘ 1    ๐Ÿ” 0    ๐Ÿ’ฌ 1    ๐Ÿ“Œ 0

In which counterworld do you live?

07.08.2025 05:19 โ€” ๐Ÿ‘ 1    ๐Ÿ” 0    ๐Ÿ’ฌ 0    ๐Ÿ“Œ 0

A "procedure" is as much of an object as a "user", a "controller" or a "cat". The fact that some things are more clearly described as a sequence of operations does not make them "not object oriented". And even if it did, who cares!
Good code describes the flow of information effectively. That's it.

06.08.2025 10:04 โ€” ๐Ÿ‘ 5    ๐Ÿ” 1    ๐Ÿ’ฌ 1    ๐Ÿ“Œ 0

Love this!

06.08.2025 08:29 โ€” ๐Ÿ‘ 1    ๐Ÿ” 0    ๐Ÿ’ฌ 0    ๐Ÿ“Œ 0

Thatโ€™s no caterpillar, itโ€™s a snake.

05.08.2025 09:07 โ€” ๐Ÿ‘ 1    ๐Ÿ” 0    ๐Ÿ’ฌ 1    ๐Ÿ“Œ 0

I love this.

05.08.2025 08:43 โ€” ๐Ÿ‘ 3    ๐Ÿ” 0    ๐Ÿ’ฌ 0    ๐Ÿ“Œ 0

โ€ฆohhhh

04.08.2025 19:48 โ€” ๐Ÿ‘ 0    ๐Ÿ” 0    ๐Ÿ’ฌ 0    ๐Ÿ“Œ 0

I wear crocs all the time at home and in the garden. Have no kids.

04.08.2025 19:46 โ€” ๐Ÿ‘ 2    ๐Ÿ” 0    ๐Ÿ’ฌ 1    ๐Ÿ“Œ 0

If either of you do, please report back!
Iโ€™m not sure what Iโ€™d make of seeing this on a cv tbh.

03.08.2025 19:13 โ€” ๐Ÿ‘ 1    ๐Ÿ” 0    ๐Ÿ’ฌ 0    ๐Ÿ“Œ 0

Code Complete is timeless. Need to re-read it, really.

03.08.2025 14:36 โ€” ๐Ÿ‘ 2    ๐Ÿ” 0    ๐Ÿ’ฌ 0    ๐Ÿ“Œ 0
The Linux Foundation The Linux Foundation online learning classes

TIL The Linux Foundation offers a course + certificate for $79 on JSON and YAML.

JSON. And YAML.

I wonder who this is targeted at.

trainingportal.linuxfoundation.org/courses/open...
trainingportal.linuxfoundation.org/courses/open...

03.08.2025 14:11 โ€” ๐Ÿ‘ 4    ๐Ÿ” 1    ๐Ÿ’ฌ 1    ๐Ÿ“Œ 0

This, I agree with.

03.08.2025 10:30 โ€” ๐Ÿ‘ 1    ๐Ÿ” 0    ๐Ÿ’ฌ 0    ๐Ÿ“Œ 0

Didnโ€™t mean to be reductive. Fantastic post! /o is crazy.

02.08.2025 20:04 โ€” ๐Ÿ‘ 1    ๐Ÿ” 0    ๐Ÿ’ฌ 1    ๐Ÿ“Œ 0

If you see this, post a castle.

youtu.be/qZwr511qGoY

02.08.2025 19:02 โ€” ๐Ÿ‘ 3    ๐Ÿ” 0    ๐Ÿ’ฌ 0    ๐Ÿ“Œ 0

As a Brit living in The Netherlands, I feel conflicting emotions.

02.08.2025 18:58 โ€” ๐Ÿ‘ 1    ๐Ÿ” 0    ๐Ÿ’ฌ 0    ๐Ÿ“Œ 0

If developers focused on optimisation as much as they used to, you would also not have nearly as much (useful) software.

02.08.2025 15:11 โ€” ๐Ÿ‘ 3    ๐Ÿ” 0    ๐Ÿ’ฌ 1    ๐Ÿ“Œ 0

TL;DR: never use /o. Thanks!

02.08.2025 15:09 โ€” ๐Ÿ‘ 3    ๐Ÿ” 0    ๐Ÿ’ฌ 1    ๐Ÿ“Œ 0
Live coding sucks Why I believe live coding is NOT fair

Live coding interviews measure stress, not coding skills hadid.dev/posts/living... HN discussion news.ycombinator.com/item?id=4475...

01.08.2025 17:44 โ€” ๐Ÿ‘ 3    ๐Ÿ” 2    ๐Ÿ’ฌ 0    ๐Ÿ“Œ 0

I like to think that people whom I compliment feel about 1/10 as good as I feel when I receive a compliment, and that makes it a very worthwhile investment.

01.08.2025 14:09 โ€” ๐Ÿ‘ 2    ๐Ÿ” 0    ๐Ÿ’ฌ 0    ๐Ÿ“Œ 0

Well, you've definitely succeeded in the interesting department!

01.08.2025 14:08 โ€” ๐Ÿ‘ 0    ๐Ÿ” 0    ๐Ÿ’ฌ 0    ๐Ÿ“Œ 0

This might just be the trade-off of the framework having strong opinions. In general I think that has been a great thing, but it leaves Rubyisms which aren't Railsisms in the shadow.

01.08.2025 11:30 โ€” ๐Ÿ‘ 1    ๐Ÿ” 0    ๐Ÿ’ฌ 0    ๐Ÿ“Œ 0

Very neat work, and quick too!

01.08.2025 11:27 โ€” ๐Ÿ‘ 1    ๐Ÿ” 0    ๐Ÿ’ฌ 0    ๐Ÿ“Œ 0
Screenshot of a part of the Minitest changelog:

5.0.0 / 2013-05-10

Oh god... here we go...

Screenshot of a part of the Minitest changelog: 5.0.0 / 2013-05-10 Oh god... here we go...

And now onto the other Ruby 2.3 (but Sinatra this time) codebase of the week, and I know I'm in for some pain.

01.08.2025 11:01 โ€” ๐Ÿ‘ 4    ๐Ÿ” 0    ๐Ÿ’ฌ 0    ๐Ÿ“Œ 0

They nailed the zero-uptime upgrade, though.

01.08.2025 06:14 โ€” ๐Ÿ‘ 1    ๐Ÿ” 0    ๐Ÿ’ฌ 0    ๐Ÿ“Œ 0

The other side of this is that `ActiveRecord::Type::Serialized` refuses to serialize default values. Another facet is that MySQL doesn't let you set defaults on TEXT columns.

Hahaha monkey-patches go brrrrrr.

31.07.2025 14:37 โ€” ๐Ÿ‘ 1    ๐Ÿ” 0    ๐Ÿ’ฌ 0    ๐Ÿ“Œ 0
Preview
rails/activerecord/lib/active_record/attribute_methods/dirty.rb at 3c194d4a8d585547d1fe45f596d2800c155b1a4c ยท rails/rails Ruby on Rails. Contribute to rails/rails development by creating an account on GitHub.

TIL that non-nullable serialized attribute columns without a default will break in Rails 4.1 and/or 4.2 because of changes to Dirty.

I didn't need to discover that, but I did. And now, so did you.

github.com/rails/rails/...

31.07.2025 13:37 โ€” ๐Ÿ‘ 1    ๐Ÿ” 0    ๐Ÿ’ฌ 1    ๐Ÿ“Œ 0

If you're feeling down, just remember: you could always be working on a Rails 4.0 / Ruby 2.3 codebase like I am this week.

31.07.2025 12:27 โ€” ๐Ÿ‘ 11    ๐Ÿ” 0    ๐Ÿ’ฌ 4    ๐Ÿ“Œ 0

Not from the Space Invaders prompt, I hope.

30.07.2025 16:02 โ€” ๐Ÿ‘ 0    ๐Ÿ” 0    ๐Ÿ’ฌ 0    ๐Ÿ“Œ 0

So that's what his eyes look like!

30.07.2025 16:00 โ€” ๐Ÿ‘ 0    ๐Ÿ” 0    ๐Ÿ’ฌ 0    ๐Ÿ“Œ 0

@jamie.schembri.me is following 20 prominent accounts