Advertisement · 728 × 90

Posts by Kasper Timm Hansen

congrats! also I'm sorry your solidus sign is missing a few letters

3 days ago 1 0 1 0

one must be pur, the other pose

1 week ago 2 0 0 0

I shipped it in the app I'm working on after I wore myself down

1 week ago 1 0 1 0

Ah right, I guess we can't have classy temp names 😄

1 week ago 1 0 0 0

post-truth/

1 week ago 1 1 0 0

thar-be-dragons/

1 week ago 1 0 1 0

I tried that, but it didn't accept a constant path looking name. And then not having a const like name seemed like it would cause more trouble internally in Action Mailer, so I didn't bother looking more.

1 week ago 1 0 1 0

thanks! I think I might pursue this one further, there's been a few Action Mailer related things I've wanted in the past.

like ActionMailer::Address() that's also in there.

1 week ago 2 0 1 0
Advertisement

😂

1 week ago 0 0 1 0
class User::EmailVerification < ActiveRecord::AssociatedObject
  has_mailer to: :user, subject: "Verify your email and sign in"
end

class User::EmailVerification < ActiveRecord::AssociatedObject has_mailer to: :user, subject: "Verify your email and sign in" end

ActiveRecord::AssociatedObject.extend Module.new {
  def has_mailer(to: nil, subject: nil, process: nil, &block)
    # Use `class_eval` to subclass, so `Mailer#name` isn't nil.
    class_eval <<~RUBY
      class Mailer < ApplicationMailer
        helper_method def #{attribute_name} = params.fetch(:#{attribute_name})
        helper_method delegate :#{record.model_name.element}, to: :#{attribute_name}
      end
    RUBY

    mailer = const_get(:Mailer)
    mailer.default template_path: name.underscore, template_name: "mailer"

    process ||= -> { mail to: ActionMailer::Address(public_send(to)), subject: } if to && subject
    process ? mailer.define_method(:mailer, &process) : mailer.class_eval(&block)

    define_method(:mailer) { self.class::Mailer.with(self.class.attribute_name => self).mailer }
    delegate :deliver_later, to: :mailer
  end
}

ActiveRecord::AssociatedObject.extend Module.new { def has_mailer(to: nil, subject: nil, process: nil, &block) # Use `class_eval` to subclass, so `Mailer#name` isn't nil. class_eval <<~RUBY class Mailer < ApplicationMailer helper_method def #{attribute_name} = params.fetch(:#{attribute_name}) helper_method delegate :#{record.model_name.element}, to: :#{attribute_name} end RUBY mailer = const_get(:Mailer) mailer.default template_path: name.underscore, template_name: "mailer" process ||= -> { mail to: ActionMailer::Address(public_send(to)), subject: } if to && subject process ? mailer.define_method(:mailer, &process) : mailer.class_eval(&block) define_method(:mailer) { self.class::Mailer.with(self.class.attribute_name => self).mailer } delegate :deliver_later, to: :mailer end }

Is this too much indirection?

Context: since Associated Objects let you write smaller objects, having Mailers with one action becomes common. And then the Mailer becomes mostly plumbing.

1 week ago 5 0 2 0

I think it makes in rv, but it could also be outside of it.

1 week ago 0 0 0 0

Eventually I'd love rv to have a built-in matrix command, so we could do stuff like

rv matrix 3.2+ run "<script code>"

and have it print out the results on the terminal

1 week ago 2 0 1 0

I was verifying whether Symbol#to_proc called private methods. I remembered it as doing so, but it doesn't! And at the very least hasn't done so since 3.2.

I verified this with:

class Hello; private def yo = :yo; end
:yo.to_proc.call Hello.new

1 week ago 1 0 1 0

Here's a nice rv win. Because Ruby installs take seconds it was super easy to verify behavior across many Ruby versions.

So I can just swap out the version and run my test code in irb like this:

rv run --ruby 4.0 irb

1 week ago 9 2 1 0

I was just looking for something like this, nice post @julianrubisch.at!

1 week ago 5 0 0 0
Preview
Guestbook - Kasper Timm Hansen Welcome to my guestbook! Feel free to leave a message with whatever you like …you can also do an interpretive drawing. I’m excited to hear from you! — Kasper 👋...

some odd ones on the guestbook, but I kinda like the silly ones too lol kaspth.com/guestbook

thank you to people who've signed it!

1 week ago 3 0 0 0
Advertisement

I have on occasion been failing and dipping into the 9,700 range. You feel noticeably worse and I do not recommend the experience.

1 week ago 1 0 0 0
Preview
Continuations 2026/13: Begone, awkward solution - Tim Riley • Another good week of closing parentheses. Merged the new Hanami Minitest. Added --test=minitest support to hanami new.  Merged undecorated exposures for views, along with some fixed tests to go...

Weeknotes: Hanami Minitest, merged! Awkward body parser middleware, gone! New guides version, initialised! Hanami mailer, getting close! Upcoming site, veiled in darkness!

timriley.info/posts/contin...

1 week ago 11 5 0 0

well that's easy though

1 week ago 1 0 0 0

miyazaki smoking

1 week ago 2 0 1 0

he looks miserable, and being highly emotive, in the clip I saw, just seems like overcompensating

2 weeks ago 1 0 0 0

someone shared the clip where he's elaborating this "wisdom" in Danish, and he's barely coherent anymore. it's just grievances and brainrot.

2 weeks ago 6 0 2 0
Video

I chatted with @chael.codes about her upcoming @blueridgeruby.com talk, "Your First Open-Source Contribution." I had to know which was more intimidating…contributing to open source for the first time or live streaming? Full episode: www.youtube.com/watch?v=ovAb...

2 weeks ago 7 2 0 1
Advertisement
Zoo: Senior Software Engineer, Cloud Infrastructure A remote position now hiring at Zoo

Zoo is hiring a Rust infra engineer! zoo.dev/jobs/4633118...

Come work with us, on our Rust services!

3 weeks ago 20 6 2 1

Ah nice! Yeah that's also where I landed with it. I'm not sure if I want to put in the work to make it production ready, but I figured the experimentation was good to share and might spark something for someone else.

3 weeks ago 1 0 0 0
Preview
I quit Rails core 4 years ago, here’s what I’ve been up to - Kasper Timm Hansen It’s been 4 years since I quit the Rails core team, so I wanted to mark the occassion and show off all the work I’ve done since then. It’s more...

It's been 4 years since I left Rails core, and my most impactful work has happened since I left.

Here's a writeup of it all:

kaspth.com/posts/i-quit...

1 month ago 27 9 3 0

Is that wild as in interesting or awful? 😂

Hell yeah thank you for using them!

3 weeks ago 1 1 1 0

I'm still proud of a lot of stuff in there. It does require a fair number of monkey patches to make work though 😅

3 weeks ago 0 0 0 0

take a trip to the cool shit store! population: you.

3 weeks ago 2 0 0 0
Video

I chatted with @thomascannon.me about his upcoming @blueridgeruby.com talk, "5 ways to invest in yourself for the long haul." I wanted to hear why you should invest in yourself even if/when you have a great job. Full episode: www.youtube.com/watch?v=V8Zp...

3 weeks ago 6 4 0 0