Alex Villa PRO
Joined 4/23/2024
Alex Villa PRO said 7 months ago on Tips and Tricks :
I'm trying to replicate the results on checking if a specific record exists. I happen to have a model in a project called Project. I did the following in my console:

irb(main):016> p1 = Project.find(13)
  Project Load (0.7ms)  SELECT "projects".* FROM "projects" WHERE "projects"."id" = $1 LIMIT $2  [["id", 13], ["LIMIT", 1]]
=> 
#<Project:0x000000010a7020a0
...
irb(main):017> p2 = Project.where(id: 13)
  Project Load (0.6ms)  SELECT "projects".* FROM "projects" WHERE "projects"."id" = $1 /* loading for pp */ LIMIT $2  [["id", 13], ["LIMIT", 11]]
=> 
[#<Project:0x000000010a70c820
...
irb(main):018> p1.present?
=> true
irb(main):019> p2.any?
  Project Exists? (0.8ms)  SELECT 1 AS one FROM "projects" WHERE "projects"."id" = $1 LIMIT $2  [["id", 13], ["LIMIT", 1]]
=> true

It looks to me like using find only executes one query once the object is in memory. Whereas where/any? seems to execute two queries. Did I misunderstand the point of the tip?

Alex Villa PRO said 6 months ago on Optical Character Recognition :
This tutorial was excellent, however I wanted to note something for future readers/watchers. I am using this on some PDFs of architectural plans. They are relatively large with very detailed text. I initially followed this video exactly, including using ImageMagick. The time to convert and process PDFs was okay locally but VERY slow in production. I'm using a cheap option on Render and don't want to pay for more while I get a product started. I was also already using Vips elsewhere in my app. On a whim, I decided to remove MiniMagick and use Vips (using ImageProcessing::Vips doesn't have a way to convert PDFs to image in a way I could get to work) to fix a slightly different problem. This cut my processing time down by a HUGE amount.

TL;DR: Use Vips instead of MiniMagick if you're finding that converting images are slow or the image quality is insufficient for your purposes.

Alex Villa PRO said 5 months ago on From Heroku to Kamal :
Love this! I'm on render right now instead of Heroku but have been itching to try Kamal so I can move to Hetzner/DO.