<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title>Disqus - Latest Comments for malesca</title><link>http://disqus.com/by/malesca/</link><description></description><atom:link href="http://disqus.com/malesca/comments.rss" rel="self"></atom:link><language>en</language><lastBuildDate>Thu, 30 Oct 2025 13:01:28 -0000</lastBuildDate><item><title>Re: Synchronise variant inventory quantity with Shopify Flow</title><link>https://thepugautomatic.com/2025/07/synchronise-variant-inventory-quantity-with-shopify-flow/#comment-6789698862</link><description>&lt;p&gt;Thank you for letting me know! 😊 Great to hear that it's helpful to others.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Henrik N</dc:creator><pubDate>Thu, 30 Oct 2025 13:01:28 -0000</pubDate></item><item><title>Re: Write self-deprecating comments</title><link>https://thepugautomatic.com/2021/02/write-self-deprecating-comments/#comment-6728869601</link><description>&lt;p&gt;Oh, thank you! 😊 That's lovely to hear.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Henrik N</dc:creator><pubDate>Fri, 27 Jun 2025 09:57:26 -0000</pubDate></item><item><title>Re: Randomize your factories - The Pug Automatic</title><link>http://thepugautomatic.com/2012/07/randomize-your-factories/#comment-6549625971</link><description>&lt;p&gt;Hi! I don't think that post makes a convincing case.&lt;/p&gt;&lt;p&gt;Yes, tests should be trustworthy, but I'd argue it's more trustworthy for a test stating "given a user, this behaviour holds" to get a user with random properties – then what is being stated and what is actually happening matches up better. It's less of  &lt;a href="https://thepugautomatic.com/2015/02/tests-lie-and-thats-ok/" rel="nofollow noopener" target="_blank" title="https://thepugautomatic.com/2015/02/tests-lie-and-thats-ok/"&gt;a lie&lt;/a&gt; .&lt;/p&gt;&lt;p&gt;If you intend to test "given a user from the USA with an email address", then make that explicit in the test.&lt;/p&gt;&lt;p&gt;And since a provided seed makes them deterministic, arguably you have the best of both worlds. More truthful tests most of the time that may reveal gaps. And reproducibility when such a gap appears.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Henrik N</dc:creator><pubDate>Sat, 14 Sep 2024 12:57:01 -0000</pubDate></item><item><title>Re: 

Time zones and multidimensional grouping with Active Record and MySQL

</title><link>http://thepugautomatic.com/2009/03/time-zones-and-multidimensional-grouping-with-active-record-and-mysql/#comment-6175586499</link><description>&lt;p&gt;I used this today (10 years later!) and realised it's not intelligent about DST. So if created_at is in a period that should be CEST (UTC + 2) rather than CET (UTC + 1), the code above will be off by an hour.&lt;/p&gt;&lt;p&gt;But this appears to do the right thing:&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;pre&gt;&lt;code&gt;&lt;br&gt;User.group("((created_at AT TIME ZONE 'UTC') AT TIME ZONE 'Europe/Stockholm')::date").count&lt;br&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;If you want it to dynamically use the Rails &lt;code&gt;Time.zone&lt;/code&gt;:&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;pre&gt;&lt;code&gt;&lt;br&gt;User.group("((created_at AT TIME ZONE 'UTC') AT TIME ZONE #{User.connection.quote(Time.zone.tzinfo.name)})::date”).count&lt;br&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;For a list of other time zones in this format, see e.g. &lt;a href="https://popsql.com/learn-sql/postgresql/how-to-convert-utc-to-local-time-zone-in-postgresql" rel="nofollow noopener" target="_blank" title="https://popsql.com/learn-sql/postgresql/how-to-convert-utc-to-local-time-zone-in-postgresql"&gt;https://popsql.com/learn-sq...&lt;/a&gt;.&lt;/p&gt;&lt;p&gt;To further confirm, try something like this in a DB console:&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;pre&gt;&lt;code&gt;&lt;br&gt;# SELECT (((TIMESTAMP WITHOUT TIME ZONE '2023-03-26 00:59:59') AT TIME ZONE 'UTC') AT TIME ZONE 'Europe/Stockholm');&lt;br&gt;      timezone&lt;br&gt;---------------------&lt;br&gt; 2023-03-26 01:59:59&lt;br&gt;(1 row)&lt;br&gt;&lt;br&gt;# SELECT (((TIMESTAMP WITHOUT TIME ZONE '2023-03-26 01:00:00') AT TIME ZONE 'UTC') AT TIME ZONE 'Europe/Stockholm');&lt;br&gt;      timezone&lt;br&gt;---------------------&lt;br&gt; 2023-03-26 03:00:00&lt;br&gt;&lt;/code&gt;&lt;/pre&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Henrik N</dc:creator><pubDate>Tue, 02 May 2023 12:49:47 -0000</pubDate></item><item><title>Re: 

Headless Rails for tasks and tests

</title><link>http://thepugautomatic.com/2014/06/headless-rails-for-tasks-and-tests/#comment-6004278800</link><description>&lt;p&gt;I did this again recently and updated this Stack Overflow answer with the code I used – it's changed a little: &lt;a href="https://stackoverflow.com/questions/4084212/how-do-you-post-to-a-url-in-capybara/24353475#24353475" rel="nofollow noopener" target="_blank" title="https://stackoverflow.com/questions/4084212/how-do-you-post-to-a-url-in-capybara/24353475#24353475"&gt;https://stackoverflow.com/q...&lt;/a&gt;&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Henrik N</dc:creator><pubDate>Wed, 05 Oct 2022 10:12:51 -0000</pubDate></item><item><title>Re: UNION with Active Record - The Pug Automatic</title><link>http://thepugautomatic.com/2014/08/union-with-active-record/#comment-5826580167</link><description>&lt;p&gt;I'm now using this in a Rails 6.1 project and it does look like the unprepared statement stuff is indeed no longer needed.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Henrik N</dc:creator><pubDate>Wed, 13 Apr 2022 18:17:56 -0000</pubDate></item><item><title>Re: 

Update with joins in Rails migrations with Postgres

</title><link>http://thepugautomatic.com/2013/01/update-with-joins-in-rails-migrations/#comment-5820951642</link><description>&lt;p&gt;In Rails 5.1+, &lt;code&gt;update_sql&lt;/code&gt; is now just &lt;code&gt;update&lt;/code&gt;.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Henrik N</dc:creator><pubDate>Fri, 08 Apr 2022 05:22:10 -0000</pubDate></item><item><title>Re: Rails/jQuery UI sortables with single UPDATE query – The Pug Automatic</title><link>http://thepugautomatic.com/2008/11/rails-jquery-sortables/#comment-5785865586</link><description>&lt;p&gt;Did this in Postgres again today and made use of the array_position function, e.g.&lt;/p&gt;&lt;p&gt;&lt;code&gt;UPDATE images SET ordinal array_position(ARRAY[3,1,2], id)&lt;/code&gt;&lt;/p&gt;&lt;p&gt;which in Rails could be e.g.&lt;/p&gt;&lt;p&gt;&lt;code&gt;ids = params[:ids].map(&amp;amp;:to_i)&lt;br&gt;Image.update_all(["position = array_position(ARRAY[?], id)", ids])&lt;/code&gt;&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Henrik N</dc:creator><pubDate>Fri, 11 Mar 2022 09:48:17 -0000</pubDate></item><item><title>Re: Vim's life-changing c% - The Pug Automatic</title><link>http://thepugautomatic.com/2014/03/vims-life-changing-c-percent/#comment-5518447969</link><description>&lt;p&gt;Thanks, Josh!&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Henrik N</dc:creator><pubDate>Wed, 01 Sep 2021 17:11:14 -0000</pubDate></item><item><title>Re: Write self-deprecating comments</title><link>https://thepugautomatic.com/2021/02/write-self-deprecating-comments/#comment-5436144989</link><description>&lt;p&gt;Excellent point :) Made me think of this fantastic article: &lt;a href="https://thoughtbot.com/blog/code-that-says-why-it-does" rel="nofollow noopener" target="_blank" title="https://thoughtbot.com/blog/code-that-says-why-it-does"&gt;https://thoughtbot.com/blog...&lt;/a&gt;&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Henrik N</dc:creator><pubDate>Mon, 28 Jun 2021 10:15:34 -0000</pubDate></item><item><title>Re: Using load with any? to avoid double queries from Active Record</title><link>https://thepugautomatic.com/2021/02/using-load-with-any-to-avoid-double-queries-from-activerecord/#comment-5317942540</link><description>&lt;p&gt;I just ran into a situation where "load.any?" is worse – if you use counter caches in Rails. So if you have a column buyers.items_count and use counter caches, then "buyer.items.any?" would not make *any* queries, but "buyer.load.any?" would.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Henrik N</dc:creator><pubDate>Fri, 26 Mar 2021 05:24:37 -0000</pubDate></item><item><title>Re: Using load with any? to avoid double queries from Active Record</title><link>https://thepugautomatic.com/2021/02/using-load-with-any-to-avoid-double-queries-from-activerecord/#comment-5292833563</link><description>&lt;p&gt;I've now updated the Rails docs for `empty?` and `any?` to suggest using `load` :)&lt;/p&gt;&lt;p&gt;- &lt;a href="https://github.com/rails/rails/pull/41572" rel="nofollow noopener" target="_blank" title="https://github.com/rails/rails/pull/41572"&gt;https://github.com/rails/ra...&lt;/a&gt;&lt;br&gt;- &lt;a href="https://github.com/rails/rails/pull/41624" rel="nofollow noopener" target="_blank" title="https://github.com/rails/rails/pull/41624"&gt;https://github.com/rails/ra...&lt;/a&gt;&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Henrik N</dc:creator><pubDate>Fri, 05 Mar 2021 12:43:32 -0000</pubDate></item><item><title>Re: Systematically removing code – The Pug Automatic</title><link>https://thepugautomatic.com/2020/11/systematically-removing-code/#comment-5156731100</link><description>&lt;p&gt;I think I've seen it before but never tried it! Seems rather interesting. Though probably more as something to catch mistakes than something I'd ever do instead of trying to get it right at removal time.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Henrik N</dc:creator><pubDate>Wed, 18 Nov 2020 15:16:46 -0000</pubDate></item><item><title>Re: Systematically removing code – The Pug Automatic</title><link>https://thepugautomatic.com/2020/11/systematically-removing-code/#comment-5152047653</link><description>&lt;p&gt;The nice thing about live code is that tests will help you not miss a rename. But I agree metaprogramming is a liability. Sometimes worth it; often not.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Henrik N</dc:creator><pubDate>Sat, 14 Nov 2020 19:37:04 -0000</pubDate></item><item><title>Re: Systematically removing code – The Pug Automatic</title><link>https://thepugautomatic.com/2020/11/systematically-removing-code/#comment-5147853102</link><description>&lt;p&gt;Thank you! 😊&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Henrik N</dc:creator><pubDate>Wed, 11 Nov 2020 16:13:27 -0000</pubDate></item><item><title>Re: Systematically removing code – The Pug Automatic</title><link>https://thepugautomatic.com/2020/11/systematically-removing-code/#comment-5147843238</link><description>&lt;p&gt;Thank you!&lt;/p&gt;&lt;p&gt;Yeah, with a highly dynamic language like Ruby, you can't be guaranteed to find every call to a given method without actually executing every line of code. Well, not even then, since you can do silly things like &lt;code&gt;send("hello#{Time.now.wday}")&lt;/code&gt; that will call a different method for each day of the week…&lt;/p&gt;&lt;p&gt;I feel you about searching for a field like `type`. In cases like that, I would (in Ruby) usually search the class/module itself and any descendants (since they can call the method without an explicit receiver) for &lt;code&gt;type&lt;/code&gt;, and then search the whole codebase for some likely receivers like &lt;code&gt;item.type&lt;/code&gt; and &lt;code&gt;/\bi\.type/&lt;/code&gt; – with a word boundary so it finds "i.type" but not e.g. "pi.type". Word boundary searches are great to decrease the amount of spurious matches.&lt;/p&gt;&lt;p&gt;Still not guaranteed to catch everything, of course, but this gets you pretty far :) And if a piece of dead code evades a systematic search, it's earned its right to stay around a while.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Henrik N</dc:creator><pubDate>Wed, 11 Nov 2020 16:05:26 -0000</pubDate></item><item><title>Re: Optimising data-over-the-wire in Phoenix LiveView</title><link>https://thepugautomatic.com/2020/07/optimising-data-over-the-wire-in-phoenix-liveview/#comment-5139094895</link><description>&lt;p&gt;Thank you, Andrew! Appreciate it.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Henrik N</dc:creator><pubDate>Thu, 05 Nov 2020 11:16:37 -0000</pubDate></item><item><title>Re: Optimising data-over-the-wire in Phoenix LiveView</title><link>https://thepugautomatic.com/2020/07/optimising-data-over-the-wire-in-phoenix-liveview/#comment-5021301919</link><description>&lt;p&gt;Thank you! 😊&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Henrik N</dc:creator><pubDate>Fri, 07 Aug 2020 07:22:10 -0000</pubDate></item><item><title>Re: Optimising data-over-the-wire in Phoenix LiveView</title><link>https://thepugautomatic.com/2020/07/optimising-data-over-the-wire-in-phoenix-liveview/#comment-4995187182</link><description>&lt;p&gt;No worries at all! This blog post is part of my own LiveView (and Elixir) learning journey, and these kinds of questions help me learn too :)&lt;/p&gt;&lt;p&gt;&lt;a href="https://hexdocs.pm/phoenix_live_view/Phoenix.LiveComponent.html" rel="nofollow noopener" target="_blank" title="https://hexdocs.pm/phoenix_live_view/Phoenix.LiveComponent.html"&gt;https://hexdocs.pm/phoenix_...&lt;/a&gt; has some good info, including&lt;/p&gt;&lt;p&gt;&amp;gt; Components run inside the LiveView process, but may have their own state and event handling.&lt;/p&gt;&lt;p&gt;and this section on managing state: &lt;a href="https://hexdocs.pm/phoenix_live_view/Phoenix.LiveComponent.html#module-managing-state" rel="nofollow noopener" target="_blank" title="https://hexdocs.pm/phoenix_live_view/Phoenix.LiveComponent.html#module-managing-state"&gt;https://hexdocs.pm/phoenix_...&lt;/a&gt;&lt;/p&gt;&lt;p&gt;Each stateful component must have a unique ID, so if the parent LiveView needs to update a component, it can use that.&lt;/p&gt;&lt;p&gt;If you want to explore this stuff yourself interactively, you can try things like `IO.inspect {:my_pid, self()}` inside a LiveView and/or a component and see what you get. Note that since LiveViews mount twice (a disconnected static HTML render and then a connected one over WebSockets), logging in their mount will log first one PID, then another :)&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Henrik N</dc:creator><pubDate>Fri, 17 Jul 2020 05:49:22 -0000</pubDate></item><item><title>Re: Optimising data-over-the-wire in Phoenix LiveView</title><link>https://thepugautomatic.com/2020/07/optimising-data-over-the-wire-in-phoenix-liveview/#comment-4993898897</link><description>&lt;p&gt;Hi Pablo – and thank you!&lt;/p&gt;&lt;p&gt;My understanding is that each LiveView instance is one process. Components are not their own processes, but effectively "live inside" their LiveView's process.&lt;/p&gt;&lt;p&gt;So if a page renders three LiveViews, each containing 100 components, and two users visit that page (or the same user opens it in two tabs), that would be six LiveView processes.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Henrik N</dc:creator><pubDate>Thu, 16 Jul 2020 06:13:53 -0000</pubDate></item><item><title>Re: GitHub Actions - Deploy to Heroku</title><link>https://mikecoutermarsh.com/github-actions-deploy-to-heroku/#comment-4970666800</link><description>&lt;p&gt;Thank you for this. To also run migrations, I used &lt;a href="https://devcenter.heroku.com/articles/release-phase" rel="nofollow noopener" target="_blank" title="https://devcenter.heroku.com/articles/release-phase"&gt;https://devcenter.heroku.co...&lt;/a&gt; – so adding a line to Procfile, and Heroku runs the migration as part of the release.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Henrik N</dc:creator><pubDate>Sat, 27 Jun 2020 13:02:06 -0000</pubDate></item><item><title>Re: Randomize your factories - The Pug Automatic</title><link>http://thepugautomatic.com/2012/07/randomize-your-factories/#comment-4957776555</link><description>&lt;p&gt;Hi! Sorry, didn’t see your comment until now.&lt;/p&gt;&lt;p&gt;We can’t practically test everything with every combination of values. If every test tried every possible combination of user gender, with-or-without email, in country A or country B and so on.&lt;/p&gt;&lt;p&gt;It would give better confidence in the code, but likely at too high of a cost.&lt;/p&gt;&lt;p&gt;Randomising factories will give less protection - it may end up never generating an order for a female user without an email address in Norway, triggering some obscure bug - but it definitely increases the chances of finding edge cases compared to running almost all tests every time with the same set of properties.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Henrik N</dc:creator><pubDate>Wed, 17 Jun 2020 13:06:08 -0000</pubDate></item><item><title>Re: How we do remote retros – The Pug Automatic</title><link>https://thepugautomatic.com/2020/03/remote-retros/#comment-4841096849</link><description>&lt;p&gt;Hm, I think you may be right. Will look into it next week. Thanks!&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Henrik N</dc:creator><pubDate>Fri, 20 Mar 2020 17:24:25 -0000</pubDate></item><item><title>Re: How we do remote retros – The Pug Automatic</title><link>https://thepugautomatic.com/2020/03/remote-retros/#comment-4841095245</link><description>&lt;p&gt;Thanks, Johan! I've had Miro recommended before – it's on my list of tools to try. Will check out Whimsical as well.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Henrik N</dc:creator><pubDate>Fri, 20 Mar 2020 17:23:05 -0000</pubDate></item><item><title>Re: 

Archiving a (Rails) site as static files on Nginx

</title><link>http://thepugautomatic.com/2014/08/archiving-rails/#comment-4780120214</link><description>&lt;p&gt;I just moved this archived site to Netlify.&lt;/p&gt;&lt;p&gt;To host such an app on Netlify instead, you will need to add a custom `_headers` file per  &lt;a href="https://stackoverflow.com/a/52771261/6962" rel="nofollow noopener" target="_blank" title="https://stackoverflow.com/a/52771261/6962"&gt;https://stackoverflow.com/a...&lt;/a&gt;. You'll also need to rename files not to have e.g. "?page=2" in their filenames (left as an exercise to the reader). You can then use a `_redirects` file with rules like `/artists page=:page /artists-page-:page 200` so old links still work.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Henrik N</dc:creator><pubDate>Sat, 01 Feb 2020 20:51:12 -0000</pubDate></item></channel></rss>