<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>TIL on Dev notes</title>
    <link>https://blog.michal.pawlik.dev/tags/til/</link>
    <description>Recent content in TIL on Dev notes</description>
    <generator>Hugo</generator>
    <language>en-us</language>
    <lastBuildDate>Wed, 01 Oct 2025 00:00:00 +0000</lastBuildDate>
    <atom:link href="https://blog.michal.pawlik.dev/tags/til/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>How to run sbt tasks with custom settings</title>
      <link>https://blog.michal.pawlik.dev/posts/til/sbt-task-with-custom-settings/</link>
      <pubDate>Wed, 01 Oct 2025 00:00:00 +0000</pubDate>
      <guid>https://blog.michal.pawlik.dev/posts/til/sbt-task-with-custom-settings/</guid>
      <description>&lt;p&gt;When preparing build configuration in sbt, you might want to write custom sbt task. Task in sbt is like a function that can depend on other tasks and project settings.&lt;/p&gt;&#xA;&lt;h2 id=&#34;custom-sbt-tasks&#34;&gt;Custom sbt tasks&lt;/h2&gt;&#xA;&lt;p&gt;To illustrate it, let&amp;rsquo;s write a simple task that validates environment, runs tests and builds an app&lt;/p&gt;&#xA;&lt;div class=&#34;cyber-terminal&#34;&gt;&#xA;  &lt;div class=&#34;cyber-terminal__header&#34;&gt;&#xA;    &lt;span class=&#34;cyber-terminal__dot cyber-terminal__dot--red&#34;&gt;&lt;/span&gt;&#xA;    &lt;span class=&#34;cyber-terminal__dot cyber-terminal__dot--yellow&#34;&gt;&lt;/span&gt;&#xA;    &lt;span class=&#34;cyber-terminal__dot cyber-terminal__dot--green&#34;&gt;&lt;/span&gt;&#xA;    &lt;span class=&#34;cyber-terminal__title&#34;&gt;scala&lt;/span&gt;&#xA;    &lt;button class=&#34;cyber-terminal__copy&#34; type=&#34;button&#34; aria-label=&#34;Copy code&#34; data-copy&gt;&#xA;      &lt;i class=&#34;fa-regular fa-copy&#34;&gt;&lt;/i&gt;&#xA;    &lt;/button&gt;&#xA;  &lt;/div&gt;&#xA;  &lt;div class=&#34;cyber-terminal__body&#34;&gt;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#282a36;-moz-tab-size:2;-o-tab-size:2;tab-size:2;&#34;&gt;&lt;code class=&#34;language-scala&#34; data-lang=&#34;scala&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#ff79c6&#34;&gt;import&lt;/span&gt; sbt.&lt;span style=&#34;color:#ff79c6&#34;&gt;*&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#ff79c6&#34;&gt;lazy&lt;/span&gt; &lt;span style=&#34;color:#ff79c6&#34;&gt;val&lt;/span&gt; validateAndBuild &lt;span style=&#34;color:#ff79c6&#34;&gt;=&lt;/span&gt; taskKey&lt;span style=&#34;color:#ff79c6&#34;&gt;[&lt;/span&gt;&lt;span style=&#34;color:#8be9fd&#34;&gt;Unit&lt;/span&gt;&lt;span style=&#34;color:#ff79c6&#34;&gt;](&lt;/span&gt;&lt;span style=&#34;color:#f1fa8c&#34;&gt;&amp;#34;Validates env, runs tests and builds the app&amp;#34;&lt;/span&gt;&lt;span style=&#34;color:#ff79c6&#34;&gt;)&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#ff79c6&#34;&gt;val&lt;/span&gt; root &lt;span style=&#34;color:#ff79c6&#34;&gt;=&lt;/span&gt; project&lt;span style=&#34;color:#ff79c6&#34;&gt;.&lt;/span&gt;in&lt;span style=&#34;color:#ff79c6&#34;&gt;(&lt;/span&gt;file&lt;span style=&#34;color:#ff79c6&#34;&gt;(&lt;/span&gt;&lt;span style=&#34;color:#f1fa8c&#34;&gt;&amp;#34;.&amp;#34;&lt;/span&gt;&lt;span style=&#34;color:#ff79c6&#34;&gt;)).&lt;/span&gt;settings&lt;span style=&#34;color:#ff79c6&#34;&gt;(&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  validateAndBuild &lt;span style=&#34;color:#ff79c6&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#ff79c6&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#ff79c6&#34;&gt;{&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    validateEnvVars&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    test&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    assembly&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#ff79c6&#34;&gt;}&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#ff79c6&#34;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&#xA;&lt;/div&gt;&#xA;&lt;h2 id=&#34;tasks-vs-immutable-settings&#34;&gt;Tasks vs immutable settings&lt;/h2&gt;&#xA;&lt;p&gt;This can be handy when the project grows in complexity. One problem with this approach is that we don&amp;rsquo;t control the inputs to the sub-tasks that we run.&#xA;In sbt, settings are initialized when the project is loaded and are not mutable.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Understand your build structure and performance</title>
      <link>https://blog.michal.pawlik.dev/posts/til/bloop-performance-tracing/</link>
      <pubDate>Wed, 29 Jan 2025 00:00:00 +0000</pubDate>
      <guid>https://blog.michal.pawlik.dev/posts/til/bloop-performance-tracing/</guid>
      <description>&lt;p&gt;&lt;strong&gt;TL;DR&lt;/strong&gt;: Today I learned that you can &lt;a href=&#34;https://scalacenter.github.io/bloop/docs/performance-guide&#34;&gt;trace your build performance with bloop&lt;/a&gt;, and it&amp;rsquo;s especially easy when using Metals. The setup might not be obvious for some.&lt;/p&gt;&#xA;&lt;p&gt;When working with &lt;a href=&#34;https://www.scala-sbt.org/1.x/docs/Multi-Project.html&#34;&gt;multi-module&lt;/a&gt; projects, build times can sometimes increase unexpectedly. There are a few ways to analyze that statically, but you can always see the live data from your bloop compilation. Let&amp;rsquo;s explore those options.&lt;/p&gt;&#xA;&lt;h2 id=&#34;static-analysis&#34;&gt;Static analysis&lt;/h2&gt;&#xA;&lt;p&gt;When your &lt;code&gt;build.sbt&lt;/code&gt; file grows complex it&amp;rsquo;s easy to lose track of which depends on which. This not only creates confusion and complicates onboarding, but also to slower builds and frustration in consequence.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Your own Bluesky feed</title>
      <link>https://blog.michal.pawlik.dev/posts/bluesky-feed/</link>
      <pubDate>Wed, 27 Nov 2024 00:00:00 +0000</pubDate>
      <guid>https://blog.michal.pawlik.dev/posts/bluesky-feed/</guid>
      <description>&lt;p&gt;In this post we&amp;rsquo;ll learn how to build and deploy your own feed on Bluesky. We&amp;rsquo;ll start with some background info on Bluesky and how feeds work. Then we&amp;rsquo;ll code and deploy our own feed. Don&amp;rsquo;t worry about the complexity, it&amp;rsquo;s mostly filling the gaps in the template.&lt;/p&gt;&#xA;&lt;h2 id=&#34;whats-bluesky&#34;&gt;What&amp;rsquo;s Bluesky&lt;/h2&gt;&#xA;&lt;p&gt;&lt;a href=&#34;https://bsky.app/&#34;&gt;Bluesky&lt;/a&gt; is a decentralized social network. From the end user perspective, it&amp;rsquo;s very similar to 𝕏 (formerly Twitter).&#xA;It&amp;rsquo;s built with &lt;a href=&#34;https://atproto.com/&#34;&gt;AT Protocol&lt;/a&gt; which allows programmers to interact with the platform.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Useful commands for inspecting sbt build</title>
      <link>https://blog.michal.pawlik.dev/posts/til/inspecting-sbt/</link>
      <pubDate>Wed, 29 May 2024 00:00:00 +0000</pubDate>
      <guid>https://blog.michal.pawlik.dev/posts/til/inspecting-sbt/</guid>
      <description>&lt;p&gt;&lt;strong&gt;TL;DR&lt;/strong&gt; Today I learned a few useful commands to help you understand complex sbt builds.&lt;/p&gt;&#xA;&lt;h2 id=&#34;task-timing&#34;&gt;task timing&lt;/h2&gt;&#xA;&lt;p&gt;JAVA_OPTS=-Dsbt.task.timings=true sbt&lt;/p&gt;&#xA;&lt;h2 id=&#34;inspecting-task&#34;&gt;inspecting task&lt;/h2&gt;&#xA;&lt;p&gt;inspect module/taskName&lt;/p&gt;&#xA;&lt;h2 id=&#34;inspecting-task-tree&#34;&gt;inspecting task tree&lt;/h2&gt;&#xA;&lt;p&gt;inspect tree module/taskName&lt;/p&gt;</description>
    </item>
    <item>
      <title>Hide irrelevant data in your PRs</title>
      <link>https://blog.michal.pawlik.dev/posts/til/cleaner-pr-diffs/</link>
      <pubDate>Fri, 05 Jan 2024 00:00:00 +0000</pubDate>
      <guid>https://blog.michal.pawlik.dev/posts/til/cleaner-pr-diffs/</guid>
      <description>&lt;p&gt;&lt;strong&gt;TL;DR&lt;/strong&gt; Today I learned that you can &lt;a href=&#34;https://docs.github.com/en/repositories/working-with-files/managing-files/customizing-how-changed-files-appear-on-github&#34;&gt;hide irrelevant changes from Github PRs&lt;/a&gt;. The syntax for &lt;code&gt;.gitattributes&lt;/code&gt; can be tricky though.&lt;/p&gt;&#xA;&lt;p&gt;In my current project, it&amp;rsquo;s sometimes necessary to re-generate and commit a bunch of files to the repository. This can happen when you store some &lt;a href=&#34;https://en.wikipedia.org/wiki/Infrastructure_as_code&#34;&gt;IaC&lt;/a&gt; or test data in the repository.&lt;/p&gt;&#xA;&lt;h2 id=&#34;sample-repository&#34;&gt;Sample repository&lt;/h2&gt;&#xA;&lt;p&gt;To demonstrate the problem, here&amp;rsquo;s an example repository: &lt;a href=&#34;https://github.com/majk-p/nice-pr-diffs&#34;&gt;https://github.com/majk-p/nice-pr-diffs&lt;/a&gt; that features two PRs:&lt;/p&gt;&#xA;&lt;p&gt;The first one is hard to read &lt;a href=&#34;https://github.com/majk-p/nice-pr-diffs/pull/1/files&#34;&gt;https://github.com/majk-p/nice-pr-diffs/pull/1/files&lt;/a&gt; because it features a wall of text - new testing data that has been added.&lt;/p&gt;</description>
    </item>
    <item>
      <title>TIL: Debugging Hugo - fixing publish date</title>
      <link>https://blog.michal.pawlik.dev/posts/til/publish-date-in-hugo/</link>
      <pubDate>Wed, 04 Jan 2023 17:15:00 +0100</pubDate>
      <guid>https://blog.michal.pawlik.dev/posts/til/publish-date-in-hugo/</guid>
      <description>&lt;p&gt;&lt;strong&gt;TL;DR&lt;/strong&gt; Today I learned how to fix post visibility by reading the documentation &lt;a href=&#34;https://gohugo.io/getting-started/usage/#draft-future-and-expired-content&#34;&gt;https://gohugo.io/getting-started/usage/#draft-future-and-expired-content&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Last night I&amp;rsquo;ve been finishing my first blog post this year. Upon finishing the text and finding the icon it&amp;rsquo;s time to fill the metadata. Midnight was minutes away so I set the publish date to &lt;code&gt;2023-01-04&lt;/code&gt; (next day) and set the &lt;code&gt;draft&lt;/code&gt; flag to &lt;code&gt;false&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;h2 id=&#34;the-problem&#34;&gt;The problem&lt;/h2&gt;&#xA;&lt;p&gt;Imagine how surprising it was to notice that the article I just wrote doesn&amp;rsquo;t show up on the main page. Time to debug. First thing is to double check the &lt;code&gt;draft&lt;/code&gt; state - all good. Perhaps I&amp;rsquo;ve made it &lt;code&gt;2022-01-04&lt;/code&gt; and the post landed a year back? nope, date&amp;rsquo;s correct.&lt;/p&gt;</description>
    </item>
    <item>
      <title>TIL: Markdown presentations with Marp</title>
      <link>https://blog.michal.pawlik.dev/posts/til/presentations-with-marp/</link>
      <pubDate>Sun, 18 Dec 2022 00:00:00 +0000</pubDate>
      <guid>https://blog.michal.pawlik.dev/posts/til/presentations-with-marp/</guid>
      <description>&lt;p&gt;Lately I&amp;rsquo;ve been working on preparing learning materials in Scala. Usually when I work on preparing slides for public speaking I would use &lt;a href=&#34;https://slides.com/majkp/&#34;&gt;https://slides.com/majkp/&lt;/a&gt;, but this time I was looking for something self hosted.&lt;/p&gt;&#xA;&lt;p&gt;In this situation &lt;a href=&#34;https://revealjs.com/&#34;&gt;Reveal.js&lt;/a&gt; seems like an obvious alternative, but if you want to set up, you either have to download a fixed version which makes the upgrade hard, or build an npm project and add reveal as the dependency.&lt;/p&gt;</description>
    </item>
    <item>
      <title>TIL: Mimic value class in Typescript</title>
      <link>https://blog.michal.pawlik.dev/posts/til/value-class-typescript/</link>
      <pubDate>Thu, 15 Dec 2022 00:00:00 +0000</pubDate>
      <guid>https://blog.michal.pawlik.dev/posts/til/value-class-typescript/</guid>
      <description>&lt;p&gt;&lt;strong&gt;TL;DR&lt;/strong&gt; Today I learned how to mimic Scala-like value class in Typescript&lt;/p&gt;&#xA;&lt;p&gt;Doing day to day scala I often use value classes to model the data like:&lt;/p&gt;&#xA;&lt;div class=&#34;cyber-terminal&#34;&gt;&#xA;  &lt;div class=&#34;cyber-terminal__header&#34;&gt;&#xA;    &lt;span class=&#34;cyber-terminal__dot cyber-terminal__dot--red&#34;&gt;&lt;/span&gt;&#xA;    &lt;span class=&#34;cyber-terminal__dot cyber-terminal__dot--yellow&#34;&gt;&lt;/span&gt;&#xA;    &lt;span class=&#34;cyber-terminal__dot cyber-terminal__dot--green&#34;&gt;&lt;/span&gt;&#xA;    &lt;span class=&#34;cyber-terminal__title&#34;&gt;scala&lt;/span&gt;&#xA;    &lt;button class=&#34;cyber-terminal__copy&#34; type=&#34;button&#34; aria-label=&#34;Copy code&#34; data-copy&gt;&#xA;      &lt;i class=&#34;fa-regular fa-copy&#34;&gt;&lt;/i&gt;&#xA;    &lt;/button&gt;&#xA;  &lt;/div&gt;&#xA;  &lt;div class=&#34;cyber-terminal__body&#34;&gt;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#282a36;-moz-tab-size:2;-o-tab-size:2;tab-size:2;&#34;&gt;&lt;code class=&#34;language-scala&#34; data-lang=&#34;scala&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#ff79c6&#34;&gt;final&lt;/span&gt; &lt;span style=&#34;color:#ff79c6&#34;&gt;case&lt;/span&gt; &lt;span style=&#34;color:#ff79c6&#34;&gt;class&lt;/span&gt; &lt;span style=&#34;color:#50fa7b&#34;&gt;UserId&lt;/span&gt;&lt;span style=&#34;color:#ff79c6&#34;&gt;(&lt;/span&gt;value&lt;span style=&#34;color:#ff79c6&#34;&gt;:&lt;/span&gt; &lt;span style=&#34;color:#8be9fd&#34;&gt;String&lt;/span&gt;&lt;span style=&#34;color:#ff79c6&#34;&gt;)&lt;/span&gt; &lt;span style=&#34;color:#ff79c6&#34;&gt;extends&lt;/span&gt; &lt;span style=&#34;color:#50fa7b&#34;&gt;AnyVal&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#ff79c6&#34;&gt;final&lt;/span&gt; &lt;span style=&#34;color:#ff79c6&#34;&gt;case&lt;/span&gt; &lt;span style=&#34;color:#ff79c6&#34;&gt;class&lt;/span&gt; &lt;span style=&#34;color:#50fa7b&#34;&gt;City&lt;/span&gt;&lt;span style=&#34;color:#ff79c6&#34;&gt;(&lt;/span&gt;value&lt;span style=&#34;color:#ff79c6&#34;&gt;:&lt;/span&gt; &lt;span style=&#34;color:#8be9fd&#34;&gt;String&lt;/span&gt;&lt;span style=&#34;color:#ff79c6&#34;&gt;)&lt;/span&gt; &lt;span style=&#34;color:#ff79c6&#34;&gt;extends&lt;/span&gt; &lt;span style=&#34;color:#50fa7b&#34;&gt;AnyVal&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&#xA;&lt;/div&gt;&#xA;&lt;p&gt;This is especially useful when you want to add some meaning to primitive types. It also makes the compiler help you to avoid passing irrelevant data to downstream methods.&lt;/p&gt;&#xA;&lt;p&gt;Read more about value classes in the documentation &lt;a href=&#34;https://docs.scala-lang.org/overviews/core/value-classes.html&#34;&gt;https://docs.scala-lang.org/overviews/core/value-classes.html&lt;/a&gt;.&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
