<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Today I learned on Alexander Sulim</title><link>https://sul.im/til/</link><description>Recent content in Today I learned on Alexander Sulim</description><generator>Hugo</generator><language>en-US</language><copyright>Alexander Sulim</copyright><lastBuildDate>Thu, 05 Dec 2024 00:00:00 +0000</lastBuildDate><atom:link href="https://sul.im/til/index.xml" rel="self" type="application/rss+xml"/><item><title>Getting a tool version from asdf (improved)</title><link>https://sul.im/til/2024/12/05-asdf-get-tool-version-improved/</link><pubDate>Thu, 05 Dec 2024 00:00:00 +0000</pubDate><guid>https://sul.im/til/2024/12/05-asdf-get-tool-version-improved/</guid><description>&lt;figure class="figure w-100"&gt;
 
 &lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#4c4f69;background-color:#eff1f5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-shell" data-lang="shell"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ asdf current nodejs 2&amp;gt;&amp;amp;&lt;span style="color:#fe640b"&gt;1&lt;/span&gt; | awk &lt;span style="color:#40a02b"&gt;&amp;#39;{print $2}&amp;#39;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;22.11.0&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

 &lt;figcaption class="figure-caption text-center"&gt;
 
 Example: Print a version of Node.js managed by asdf.
 
 &lt;/figcaption&gt;
&lt;/figure&gt;</description></item><item><title>Getting a tool version from asdf</title><link>https://sul.im/til/2024/12/04-asdf-get-tool-version/</link><pubDate>Wed, 04 Dec 2024 00:00:00 +0000</pubDate><guid>https://sul.im/til/2024/12/04-asdf-get-tool-version/</guid><description>&lt;figure class="figure w-100"&gt;
 
 &lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#4c4f69;background-color:#eff1f5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-shell" data-lang="shell"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ asdf current nodejs 2&amp;gt;&amp;amp;&lt;span style="color:#fe640b"&gt;1&lt;/span&gt; | sed -e &lt;span style="color:#40a02b"&gt;&amp;#34;s/ \{2,\}/ /g&amp;#34;&lt;/span&gt; | cut -d&lt;span style="color:#40a02b"&gt;&amp;#34; &amp;#34;&lt;/span&gt; -f2
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;20.17.0&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

 &lt;figcaption class="figure-caption text-center"&gt;
 
 Example: Print a version of Node.js managed by asdf.
 
 &lt;/figcaption&gt;
&lt;/figure&gt;</description></item><item><title>Running minitest without Rake</title><link>https://sul.im/til/2024/11/11-ruby-minitest-command/</link><pubDate>Mon, 11 Nov 2024 00:00:00 +0000</pubDate><guid>https://sul.im/til/2024/11/11-ruby-minitest-command/</guid><description>&lt;p&gt;When it&amp;rsquo;s about writing tests for a Ruby project, I prefer &lt;a href="https://github.com/minitest/minitest"&gt;minitest&lt;/a&gt; to anything else. It&amp;rsquo;s fast and doesn&amp;rsquo;t require to switch mental context to any domain-specific language (DSL). It&amp;rsquo;s just Ruby.&lt;/p&gt;
&lt;p&gt;Because minitest allows to express tests using plain Ruby, Ruby is the only necessary tool to run those tests.&lt;/p&gt;

&lt;figure class="figure w-100"&gt;
 
 &lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#4c4f69;background-color:#eff1f5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-shell" data-lang="shell"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ ruby -Ilib:test test/foo/test_foo_test.rb&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

 &lt;figcaption class="figure-caption text-center"&gt;
 
 Running minitest tests with Ruby.
 
 &lt;/figcaption&gt;
&lt;/figure&gt;

&lt;p&gt;That works fine for one file, but a bit tricky for multiple test files at once.&lt;/p&gt;
&lt;p&gt;minitest comes with &lt;a href="https://github.com/minitest/minitest?tab=readme-ov-file#label-Rake+Tasks"&gt;a Rake task&lt;/a&gt; to run all tests. However for small projects it might be to much to bring Rake just for that case.&lt;/p&gt;
&lt;p&gt;So I wrote a script to run tests without anything but Ruby. It&amp;rsquo;s basically a wrapper around a test runner that comes with minitest.&lt;/p&gt;</description></item><item><title>How to use multiple arguments in shebang lines</title><link>https://sul.im/til/2024/10/24-env-split-string/</link><pubDate>Thu, 24 Oct 2024 00:00:00 +0000</pubDate><guid>https://sul.im/til/2024/10/24-env-split-string/</guid><description>&lt;p&gt;&lt;code&gt;env&lt;/code&gt; command allows to find a script&amp;rsquo;s interpreter when its location is a non-standard one.
In scripts it&amp;rsquo;s recommended to use &lt;code&gt;env&lt;/code&gt; in &lt;a href="https://en.wikipedia.org/wiki/Shebang_(Unix)"&gt;shebang lines&lt;/a&gt; to find the executable and run it.&lt;/p&gt;

&lt;figure class="figure w-100"&gt;
 
 &lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#4c4f69;background-color:#eff1f5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-ruby" data-lang="ruby"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#acb0be;font-style:italic"&gt;#!/usr/bin/env ruby&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#04a5e5"&gt;puts&lt;/span&gt; &lt;span style="color:#40a02b"&gt;&amp;#34;Hello, world.&amp;#34;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

 &lt;figcaption class="figure-caption text-center"&gt;
 
 Ruby interpreter is used without any option.
 
 &lt;/figcaption&gt;
&lt;/figure&gt;

&lt;p&gt;On GNU/Linux if it&amp;rsquo;s necessary to run a script&amp;rsquo;s interpreter with options, &lt;code&gt;env&lt;/code&gt; has to be used with &lt;code&gt;-S&lt;/code&gt; to pass options in shebang lines.&lt;/p&gt;</description></item><item><title>How to DRY Docker Compose files</title><link>https://sul.im/til/2024/10/23-docker-compose-extend-service-attribute/</link><pubDate>Wed, 23 Oct 2024 00:00:00 +0000</pubDate><guid>https://sul.im/til/2024/10/23-docker-compose-extend-service-attribute/</guid><description>&lt;p&gt;&lt;a href="https://docs.docker.com/reference/compose-file/services/#extends"&gt;&lt;code&gt;extends&lt;/code&gt;&lt;/a&gt; attribute in Docker Compose files allows to reuse existing service definitions for other services.
That makes it possible to &lt;a href="https://en.wikipedia.org/wiki/Don%27t_repeat_yourself"&gt;DRY&lt;/a&gt; Compose files.&lt;/p&gt;</description></item><item><title>How to list Ruby gems in the bundle</title><link>https://sul.im/til/2024/10/22-how-to-list-ruby-gems/</link><pubDate>Tue, 22 Oct 2024 00:00:00 +0000</pubDate><guid>https://sul.im/til/2024/10/22-how-to-list-ruby-gems/</guid><description>&lt;p&gt;Bundler, a Ruby package manager, provides two options to list gems in the bundle.&lt;/p&gt;</description></item></channel></rss>