<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Karl Tarvas</title>
    <link>https://f2cfe404.karltarvascom.pages.dev/</link>
    <description></description>
    <lastBuildDate>Thu, 20 Aug 2026 00:00:00 +0000</lastBuildDate>
    <language>en-us</language>
    <atom:link href="https://f2cfe404.karltarvascom.pages.dev/feed.xml" rel="self" type="application/rss+xml" />
    
    <item>
      <title>Google Calendar: sync shared calendar subscriptions to other devices</title>
      <link>https://f2cfe404.karltarvascom.pages.dev/google-calendar-sync-ical-calendar-subscriptions/</link>
      <guid>https://f2cfe404.karltarvascom.pages.dev/google-calendar-sync-ical-calendar-subscriptions/</guid>
      <pubDate>Thu, 20 Aug 2026 00:00:00 &#43;0000</pubDate>
      <description>&lt;p&gt;For some reason, Google Calendar doesn&amp;rsquo;t make your shared calendar subscriptions available on other devices out of the box. To make them sync, use this unlinked legacy page:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&#34;https://calendar.google.com/calendar/syncselect&#34;&gt;https://calendar.google.com/calendar/syncselect&lt;/a&gt;&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>Discord bot text to speech with Piper</title>
      <link>https://f2cfe404.karltarvascom.pages.dev/discord-bot-text-to-speech-with-piper/</link>
      <guid>https://f2cfe404.karltarvascom.pages.dev/discord-bot-text-to-speech-with-piper/</guid>
      <pubDate>Sat, 29 Nov 2025 00:00:00 &#43;0000</pubDate>
      <description>&lt;p&gt;&lt;a href=&#34;https://github.com/OHF-Voice/piper1-gpl&#34;&gt;Piper&lt;/a&gt; is a fast &lt;abbr title=&#34;text to speech&#34;&gt;TTS&lt;/abbr&gt; engine that&amp;rsquo;s performant enough to run on the cheapest Hetzner VPS.&#xA;It comes with a &lt;a href=&#34;https://rhasspy.github.io/piper-samples/&#34;&gt;wide array of available voices&lt;/a&gt; offering a good selection of size and speed tradeoffs.&lt;/p&gt;&#xA;&lt;p&gt;Conveniently, it also ships with a web server, so you can load the model once and then get TTS responses with low latency. This makes it perfect for using it as a TTS server for Discord bots.&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>macOS: Hide users list when the screen is locked</title>
      <link>https://f2cfe404.karltarvascom.pages.dev/macos-hide-users-list-when-the-screen-is-locked/</link>
      <guid>https://f2cfe404.karltarvascom.pages.dev/macos-hide-users-list-when-the-screen-is-locked/</guid>
      <pubDate>Wed, 16 Apr 2025 00:00:00 &#43;0000</pubDate>
      <description>&lt;p&gt;By default, macOS shows a list of local users when you lock the screen, even if the boot login screen is set to name and password only (System Preferences → Lock Screen → Login window shows: Name and password). To hide the list of users and only show the currently logged in user, you can:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;sudo defaults write /Library/Preferences/com.apple.loginwindow HideLocalUsers -bool TRUE&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;To revert, you can &lt;code&gt;defaults delete&lt;/code&gt; the same value.&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>macOS: Remap a key</title>
      <link>https://f2cfe404.karltarvascom.pages.dev/macos-remap-a-key/</link>
      <guid>https://f2cfe404.karltarvascom.pages.dev/macos-remap-a-key/</guid>
      <pubDate>Wed, 27 Nov 2024 00:00:00 &#43;0000</pubDate>
      <description>&lt;p&gt;You can use &lt;a href=&#34;https://developer.apple.com/library/archive/technotes/tn2450/_index.html&#34;&gt;&lt;code&gt;hidutil&lt;/code&gt;&lt;/a&gt; to remap keys in macOS without using a third party application.&lt;/p&gt;&#xA;&lt;p&gt;List current mappings, will return &lt;code&gt;(null)&lt;/code&gt; if no mappings are present:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;$ hidutil property --get &lt;span class=&#34;s2&#34;&gt;&amp;#34;UserKeyMapping&amp;#34;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;o&#34;&gt;(&lt;/span&gt;null&lt;span class=&#34;o&#34;&gt;)&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Set a mapping, in this case, make &lt;code&gt;Caps Lock&lt;/code&gt; (&lt;code&gt;0x39&lt;/code&gt;) work as &lt;code&gt;F24&lt;/code&gt; (&lt;code&gt;0x73&lt;/code&gt;) instead:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;$ hidutil property --set &lt;span class=&#34;s1&#34;&gt;&amp;#39;{&amp;#34;UserKeyMapping&amp;#34;:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;s1&#34;&gt;  [{&amp;#34;HIDKeyboardModifierMappingSrc&amp;#34;:0x700000039, &amp;#34;HIDKeyboardModifierMappingDst&amp;#34;:0x700000073}]&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;s1&#34;&gt;}&amp;#39;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;To set multiple mappings, add corresponding objects to the array.&lt;/p&gt;&#xA;&lt;p&gt;See &lt;a href=&#34;https://developer.apple.com/library/archive/technotes/tn2450/_index.html#//apple_ref/doc/uid/DTS40017618-CH1-KEY_TABLE_USAGES&#34;&gt;this table&lt;/a&gt; for a full list of keys and their IDs. Some common ones include:&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>Typescript: Convert snake_case string type to PascalCase string type</title>
      <link>https://f2cfe404.karltarvascom.pages.dev/typescript-convert-snake-case-string-type-to-pascal-case-string-type/</link>
      <guid>https://f2cfe404.karltarvascom.pages.dev/typescript-convert-snake-case-string-type-to-pascal-case-string-type/</guid>
      <pubDate>Fri, 01 Mar 2024 00:00:00 &#43;0000</pubDate>
      <description>&lt;p&gt;Even though the &lt;a href=&#34;https://www.typescriptlang.org/docs/handbook/2/template-literal-types.html#intrinsic-string-manipulation-types&#34;&gt;string type manipulation utilities&lt;/a&gt; you get out of the box with Typescript are rather limited, using Typescript&amp;rsquo;s most confusing feature, the &lt;a href=&#34;https://www.typescriptlang.org/docs/handbook/2/conditional-types.html#inferring-within-conditional-types&#34;&gt;&lt;code&gt;infer&lt;/code&gt; keyword&lt;/a&gt;, you can push conversions between string types quite a lot further.&lt;/p&gt;&#xA;&lt;p&gt;The below snippet converts &lt;code&gt;string_case&lt;/code&gt; string types to &lt;code&gt;PascalCase&lt;/code&gt; string types.&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-ts&#34; data-lang=&#34;ts&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kr&#34;&gt;type&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;InputType&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;s2&#34;&gt;&amp;#34;foo_bar_tea&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kr&#34;&gt;type&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;SnakeToPascal&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&#34;nt&#34;&gt;T&lt;/span&gt; &lt;span class=&#34;na&#34;&gt;extends&lt;/span&gt; &lt;span class=&#34;na&#34;&gt;string&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;T&lt;/span&gt; &lt;span class=&#34;kr&#34;&gt;extends&lt;/span&gt; &lt;span class=&#34;sb&#34;&gt;`&lt;/span&gt;&lt;span class=&#34;si&#34;&gt;${&lt;/span&gt;&lt;span class=&#34;k&#34;&gt;infer&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;A&lt;/span&gt;&lt;span class=&#34;si&#34;&gt;}&lt;/span&gt;&lt;span class=&#34;sb&#34;&gt;_&lt;/span&gt;&lt;span class=&#34;si&#34;&gt;${&lt;/span&gt;&lt;span class=&#34;k&#34;&gt;infer&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;B&lt;/span&gt;&lt;span class=&#34;si&#34;&gt;}&lt;/span&gt;&lt;span class=&#34;sb&#34;&gt;`&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;o&#34;&gt;?&lt;/span&gt; &lt;span class=&#34;sb&#34;&gt;`&lt;/span&gt;&lt;span class=&#34;si&#34;&gt;${&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;Capitalize&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&#34;nt&#34;&gt;Lowercase&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&#34;nt&#34;&gt;SnakeToPascal&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&#34;nt&#34;&gt;A&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;span class=&#34;si&#34;&gt;}${&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;SnakeToPascal&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&#34;nt&#34;&gt;B&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&#34;si&#34;&gt;}&lt;/span&gt;&lt;span class=&#34;sb&#34;&gt;`&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;o&#34;&gt;:&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;Capitalize&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&#34;nt&#34;&gt;Lowercase&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&#34;nt&#34;&gt;T&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;&amp;gt;&amp;gt;;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kr&#34;&gt;type&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;OutputType&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;SnakeToPascal&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&#34;nt&#34;&gt;InputType&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;&amp;gt;;&lt;/span&gt; &lt;span class=&#34;c1&#34;&gt;// equals &amp;#34;FooBarTea&amp;#34;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</description>
    </item>
    
    <item>
      <title>How to call a C/C&#43;&#43; function from Node</title>
      <link>https://f2cfe404.karltarvascom.pages.dev/how-to-call-a-c-or-cpp-function-from-node/</link>
      <guid>https://f2cfe404.karltarvascom.pages.dev/how-to-call-a-c-or-cpp-function-from-node/</guid>
      <pubDate>Fri, 04 Aug 2023 00:00:00 &#43;0000</pubDate>
      <description>&lt;p&gt;A straightforward way to call C/C++ code from Node is to use &lt;a href=&#34;https://github.com/nodejs/node-gyp&#34;&gt;&lt;code&gt;node-gyp&lt;/code&gt;&lt;/a&gt; to build a &lt;a href=&#34;https://nodejs.org/api/addons.html&#34;&gt;Node addon&lt;/a&gt;. Node kindly provides &lt;a href=&#34;https://github.com/nodejs/node/tree/main/test/addons/hello-world&#34;&gt;a hello world addon demo&lt;/a&gt; which we&amp;rsquo;ll roughly follow below.&lt;/p&gt;&#xA;&lt;p&gt;Firstly you&amp;rsquo;ll need to &lt;a href=&#34;https://github.com/nodejs/node-gyp#installation&#34;&gt;install &lt;code&gt;node-gyp&lt;/code&gt;&lt;/a&gt;. When doing the initial setup, make sure you have &lt;a href=&#34;https://github.com/nodejs/node-gyp#configuring-python-dependency&#34;&gt;a compatible version of Python configured&lt;/a&gt;. Next you&amp;rsquo;ll need to provide a &lt;a href=&#34;https://github.com/nodejs/node-gyp#the-bindinggyp-file&#34;&gt;&lt;code&gt;binding.gyp&lt;/code&gt;&lt;/a&gt;, this file tells &lt;code&gt;node-gyp&lt;/code&gt; how to build your project. A simple &lt;code&gt;binding.gyp&lt;/code&gt; might look like this:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-json&#34; data-lang=&#34;json&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;  &lt;span class=&#34;nt&#34;&gt;&amp;#34;targets&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;[&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;      &lt;span class=&#34;nt&#34;&gt;&amp;#34;target_name&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt; &lt;span class=&#34;s2&#34;&gt;&amp;#34;binding&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;      &lt;span class=&#34;nt&#34;&gt;&amp;#34;sources&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;[&lt;/span&gt; &lt;span class=&#34;s2&#34;&gt;&amp;#34;src/binding.cc&amp;#34;&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;]&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;p&#34;&gt;}&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;  &lt;span class=&#34;p&#34;&gt;]&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;p&#34;&gt;}&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;A barebones binding might look like the following. While it is written in C++, you can integrate your C code in much the same way. See &lt;a href=&#34;https://isocpp.org/wiki/faq/mixing-c-and-cpp&#34;&gt;this article&lt;/a&gt; for some examples on how to mix C and C++.&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>Git: Be very verbose about cloning</title>
      <link>https://f2cfe404.karltarvascom.pages.dev/git-be-very-verbose-about-cloning/</link>
      <guid>https://f2cfe404.karltarvascom.pages.dev/git-be-very-verbose-about-cloning/</guid>
      <pubDate>Thu, 25 May 2023 00:00:00 &#43;0000</pubDate>
      <description>&lt;p&gt;If you&amp;rsquo;re ever struggling to figure out why cloning a repository fails beyond the usual suspects, the following setup may be handy for you. &lt;code&gt;GIT_TRACE&lt;/code&gt; turns general tracing on, &lt;code&gt;GIT_TRACE_PACKET&lt;/code&gt; enables packet-level tracing for network operations, &lt;code&gt;GIT_CURL_VERBOSE&lt;/code&gt; is equivalent to doing &lt;code&gt;curl -v&lt;/code&gt;, and &lt;code&gt;GIT_SSH_COMMAND&lt;/code&gt; with &lt;code&gt;-vvv&lt;/code&gt; is pretty self explanatory.&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-gdscript3&#34; data-lang=&#34;gdscript3&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;export&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;GIT_TRACE&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;mi&#34;&gt;1&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;export&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;GIT_TRACE_PACKET&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;mi&#34;&gt;1&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;export&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;GIT_CURL_VERBOSE&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;mi&#34;&gt;1&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;export&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;GIT_SSH_COMMAND&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;ssh -vvv&amp;#34;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;n&#34;&gt;git&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;clone&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;repository&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;&amp;gt;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</description>
    </item>
    
    <item>
      <title>Protecting your iPhone against shoulder surfing password theft</title>
      <link>https://f2cfe404.karltarvascom.pages.dev/protecting-your-iphone-against-shoulder-surfing-password-theft/</link>
      <guid>https://f2cfe404.karltarvascom.pages.dev/protecting-your-iphone-against-shoulder-surfing-password-theft/</guid>
      <pubDate>Sat, 25 Feb 2023 00:00:00 &#43;0000</pubDate>
      <description>&lt;p&gt;Edited &lt;time&gt;{{ &amp;ldquo;2023-04-19&amp;rdquo;  | date_to_long_string: &amp;ldquo;ordinal&amp;rdquo; }}&lt;/time&gt;: There is currently no known way to defend against this attack.&lt;/p&gt;&#xA;&lt;p&gt;The Wall Street Journal &lt;a href=&#34;https://www.wsj.com/articles/apple-iphone-security-theft-passcode-data-privacya-basic-iphone-feature-helps-criminals-steal-your-digital-life-cbf14b1a&#34;&gt;recently covered a low-tech theft scheme&lt;/a&gt; for stealing money from iPhone users that&amp;rsquo;s quickly gaining popularity.&lt;/p&gt;&#xA;&lt;p&gt;The basic premise of the theft works like this:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;The victim&amp;rsquo;s iPhone passcode is observed, either by shoulder surfing or social engineering.&lt;/li&gt;&#xA;&lt;li&gt;The iPhone is stolen.&lt;/li&gt;&#xA;&lt;li&gt;The iPhone passcode is used to reset the Apple ID password.&lt;/li&gt;&#xA;&lt;li&gt;The victim is then remotely logged out of their other devices to prevent remote wiping the device.&lt;/li&gt;&#xA;&lt;li&gt;The credentials are then used to steal money via banking accounts logged in on the device, Apple Pay, etc. Since the passcode can be used as a fallback for Face ID and Touch ID, every app that doesn&amp;rsquo;t use a separate passcode or similar is susceptible.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt; There is currently no way to defend against this attack. Previously, using Screen Time restrictions was recommended as a possible remedy, however it turns out &lt;a href=&#34;https://www.reddit.com/r/1Password/comments/11hodde/is_1password_better_than_keychain_if_youre_using/jawaaz0/&#34;&gt;Screen Time suffers from a similar vulnerability!&lt;/a&gt;.&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>Git: Get local branches with no remote</title>
      <link>https://f2cfe404.karltarvascom.pages.dev/git-get-local-branches-with-no-remote/</link>
      <guid>https://f2cfe404.karltarvascom.pages.dev/git-get-local-branches-with-no-remote/</guid>
      <pubDate>Wed, 08 Feb 2023 00:00:00 &#43;0000</pubDate>
      <description>&lt;p&gt;If you often jump between branches and sometimes lose track of which you have and haven&amp;rsquo;t pushed to the remote yet, it might be handy to &lt;a href=&#34;https://stackoverflow.com/a/31776247/1470607&#34;&gt;get all local branches with no remote&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;git branch --format &lt;span class=&#34;s2&#34;&gt;&amp;#34;%(refname:short) %(upstream)&amp;#34;&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;|&lt;/span&gt; awk &lt;span class=&#34;s1&#34;&gt;&amp;#39;{if (!$2) print $1;}&amp;#39;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;To sort the whole shebang recently modified branches first, you can &lt;a href=&#34;https://stackoverflow.com/a/5188364/1470607&#34;&gt;add &lt;code&gt;--sort=-committerdate&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;git branch --format &lt;span class=&#34;s2&#34;&gt;&amp;#34;%(refname:short) %(upstream)&amp;#34;&lt;/span&gt; --sort&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;-committerdate &lt;span class=&#34;p&#34;&gt;|&lt;/span&gt; awk &lt;span class=&#34;s1&#34;&gt;&amp;#39;{if (!$2) print $1;}&amp;#39;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;If you use this often, adding an alias might be handy:&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>Allen Pike: Humans Need Play</title>
      <link>https://f2cfe404.karltarvascom.pages.dev/allen-pike-humans-need-play/</link>
      <guid>https://f2cfe404.karltarvascom.pages.dev/allen-pike-humans-need-play/</guid>
      <pubDate>Sun, 05 Feb 2023 00:00:00 &#43;0000</pubDate>
      <description>&lt;p&gt;Recommended reading: &lt;a href=&#34;https://allenpike.com/2023/humans-need-play&#34;&gt;&amp;ldquo;Humans Need Play&amp;rdquo; by Allen Pike&lt;/a&gt;&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>Cipollino salad</title>
      <link>https://f2cfe404.karltarvascom.pages.dev/cipollino-salad/</link>
      <guid>https://f2cfe404.karltarvascom.pages.dev/cipollino-salad/</guid>
      <pubDate>Tue, 17 Jan 2023 00:00:00 &#43;0000</pubDate>
      <description>&lt;p&gt;This is a salad my mom used to make when I was young and to date I still love it to bits. I&amp;rsquo;d wager it isn&amp;rsquo;t widely known by that name, but the name is pretty self explanatory.&lt;/p&gt;&#xA;&lt;p&gt;For roughly four people, you&amp;rsquo;ll need:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;three large onions, the sharper the better&lt;/li&gt;&#xA;&lt;li&gt;500g of Chinese cabbage&lt;/li&gt;&#xA;&lt;li&gt;400g of mayo&lt;/li&gt;&#xA;&lt;li&gt;200g of sour cream, watery varieties work better&lt;/li&gt;&#xA;&lt;li&gt;ample salt and pepper&lt;/li&gt;&#xA;&lt;li&gt;a big bowl&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Optionally:&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>Formik custom input not submitting on enter</title>
      <link>https://f2cfe404.karltarvascom.pages.dev/formik-custom-input-not-submitting-on-enter/</link>
      <guid>https://f2cfe404.karltarvascom.pages.dev/formik-custom-input-not-submitting-on-enter/</guid>
      <pubDate>Fri, 16 Sep 2022 00:00:00 &#43;0000</pubDate>
      <description>&lt;p&gt;When using &lt;a href=&#34;https://formik.org/docs/api/field#component&#34;&gt;custom components&lt;/a&gt; with &lt;a href=&#34;https://formik.org/&#34;&gt;Formik&lt;/a&gt;, a common problem to run into is some native form events breaking. One obvious symptom is the form not triggering a submit when you press enter in an input field, but there are others.&lt;/p&gt;&#xA;&lt;p&gt;The problem will arise if you incorrectly pass all props straight through to the custom component. As demonstrated in the docs above, you must remove the form props before passing the rest on to the custom component.&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>&lt;code&gt;react-router&lt;/code&gt;: Persist location state</title>
      <link>https://f2cfe404.karltarvascom.pages.dev/react-router-persist-location-state/</link>
      <guid>https://f2cfe404.karltarvascom.pages.dev/react-router-persist-location-state/</guid>
      <pubDate>Wed, 24 Aug 2022 00:00:00 &#43;0000</pubDate>
      <description>&lt;p&gt;Out of the box, single-page applications built with &lt;code&gt;react-router&lt;/code&gt; don&amp;rsquo;t persist data when navigating back and forward in the browser history. While this may be desirable at times, most of the time it greatly hurts the usability of the application and makes it feel clunky compared to regular web pages.&lt;/p&gt;&#xA;&lt;p&gt;To make your application persists its state when navigating back and forward, you can store the relevant state in the &lt;a href=&#34;https://developer.mozilla.org/en-US/docs/Web/API/History/state&#34;&gt;history state&lt;/a&gt;.&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>macOS: Disable charger plug in sound</title>
      <link>https://f2cfe404.karltarvascom.pages.dev/macos-disable-charger-plug-in-sound/</link>
      <guid>https://f2cfe404.karltarvascom.pages.dev/macos-disable-charger-plug-in-sound/</guid>
      <pubDate>Tue, 05 Jul 2022 00:00:00 &#43;0000</pubDate>
      <description>&lt;p&gt;By default, macOS does a small chiming sound whenever you plug the charger in. If you often have to use your laptop in environments that call for silence, you may want to turn it off.&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;defaults write com.apple.PowerChime ChimeOnNoHardware -bool &lt;span class=&#34;nb&#34;&gt;true&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;&amp;amp;&amp;amp;&lt;/span&gt; killall PowerChime&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;To reenable it, you can flip the boolean value and run the same snippet.&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>Git: Get a patch between two branches</title>
      <link>https://f2cfe404.karltarvascom.pages.dev/git-get-a-patch-between-two-branches/</link>
      <guid>https://f2cfe404.karltarvascom.pages.dev/git-get-a-patch-between-two-branches/</guid>
      <pubDate>Mon, 16 May 2022 00:00:00 &#43;0000</pubDate>
      <description>&lt;p&gt;Get a patch from the diff between &lt;code&gt;master&lt;/code&gt; and &lt;code&gt;foo&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;git diff --no-color --binary master foo &amp;gt; /tmp/patch&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;&lt;code&gt;--no-color&lt;/code&gt; ensures the diff is valid to apply if you have automatic coloring on, &lt;code&gt;--binary&lt;/code&gt; ensures binary files are handled correctly as well.&lt;/p&gt;&#xA;&lt;p&gt;To later apply the patch:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;git apply /tmp/patch&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</description>
    </item>
    
    <item>
      <title>What is Babel?</title>
      <link>https://f2cfe404.karltarvascom.pages.dev/what-is-babel/</link>
      <guid>https://f2cfe404.karltarvascom.pages.dev/what-is-babel/</guid>
      <pubDate>Sat, 16 Oct 2021 00:00:00 &#43;0000</pubDate>
      <description>&lt;p&gt;&lt;em&gt;Note: This is a response to &lt;a href=&#34;https://jvns.ca/blog/2021/11/15/esbuild-vue/&#34;&gt;this blog post by Julia Evans&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&#34;https://babeljs.io/&#34;&gt;Babel&lt;/a&gt; is a common part of many frontend build pipelines. But what is it, and what would you use it for? To answer that question, let&amp;rsquo;s first take a step back and talk about web browsers and Javascript.&lt;/p&gt;&#xA;&lt;p&gt;Modern Javascript has learned many tricks in the recent years (such as &lt;a href=&#34;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Nullish_coalescing_operator&#34;&gt;nullish coalescing&lt;/a&gt;, &lt;a href=&#34;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals&#34;&gt;template literals&lt;/a&gt;, &lt;a href=&#34;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Default_parameters&#34;&gt;default parameters&lt;/a&gt;, and many more). These new language features often allow the developer to write code that&amp;rsquo;s either more robust, or shorter, or easier to reason about, or all of the above. Alas, many of your users may be using an older browser that was released before these features made it into the language spec. What&amp;rsquo;s a developer to do?&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>Git: Use &lt;code&gt;--color-words&lt;/code&gt; for diff by default</title>
      <link>https://f2cfe404.karltarvascom.pages.dev/git-use-color-words-for-diff-by-default/</link>
      <guid>https://f2cfe404.karltarvascom.pages.dev/git-use-color-words-for-diff-by-default/</guid>
      <pubDate>Tue, 03 Aug 2021 00:00:00 &#43;0000</pubDate>
      <description>&lt;p&gt;Git supports showing colored diffs inline by the &lt;code&gt;--color-words&lt;/code&gt; flag:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;$ git diff --color-words&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;This is often easier to follow than the standard plus-minus format. To make this the default you can:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;$ git config --global color.diff always&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Which will result in the following in your gitconfig:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-yaml&#34; data-lang=&#34;yaml&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;p&#34;&gt;[&lt;/span&gt;&lt;span class=&#34;l&#34;&gt;color]&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;w&#34;&gt;&#x9;&lt;/span&gt;&lt;span class=&#34;l&#34;&gt;diff = always&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</description>
    </item>
    
    <item>
      <title>AppleScript: Get connected VPN names from Tunnelblick</title>
      <link>https://f2cfe404.karltarvascom.pages.dev/applescript-get-connected-vpn-names-from-tunnelblick/</link>
      <guid>https://f2cfe404.karltarvascom.pages.dev/applescript-get-connected-vpn-names-from-tunnelblick/</guid>
      <pubDate>Fri, 21 May 2021 00:00:00 &#43;0000</pubDate>
      <description>&lt;p&gt;&lt;a href=&#34;https://tunnelblick.net/&#34;&gt;Tunnelblick&lt;/a&gt; is the de facto OpenVPN client for macOS. Amongst other things, it conveniently &lt;a href=&#34;https://www.tunnelblick.net/cAppleScriptSupport.html&#34;&gt;supports AppleScript&lt;/a&gt; which means you can easily use it with &lt;a href=&#34;https://github.com/matryer/xbar&#34;&gt;Xbar&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;cp&#34;&gt;#!/usr/bin/env osascript&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;cp&#34;&gt;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;tell application &lt;span class=&#34;s2&#34;&gt;&amp;#34;Tunnelblick&amp;#34;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    get name of configurations where &lt;span class=&#34;nv&#34;&gt;state&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;s2&#34;&gt;&amp;#34;CONNECTED&amp;#34;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;end tell&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</description>
    </item>
    
    <item>
      <title>Bash: Using &lt;code&gt;flock&lt;/code&gt; to ensure parallel scripts perform an action only once</title>
      <link>https://f2cfe404.karltarvascom.pages.dev/bash-using-flock-to-ensure-parallel-scripts-perform-an-action-only-once/</link>
      <guid>https://f2cfe404.karltarvascom.pages.dev/bash-using-flock-to-ensure-parallel-scripts-perform-an-action-only-once/</guid>
      <pubDate>Mon, 17 May 2021 00:00:00 &#43;0000</pubDate>
      <description>&lt;p&gt;Consider two or more shell scripts that may be run either by themselves or in parallel, but all rely on a specific setup step that isn&amp;rsquo;t parallelizable. This may be a network request, a non-idempotent database write, or something else similar.&lt;/p&gt;&#xA;&lt;p&gt;One easy way to ensure that this action is performed only once in the above setup is to use &lt;a href=&#34;https://linux.die.net/man/1/flock&#34;&gt;&lt;code&gt;flock&lt;/code&gt;&lt;/a&gt;, a simple lock management utility for shell scripts. In the below example we use it to open a lock in &lt;code&gt;/tmp/shared.lock&lt;/code&gt; with the file descriptor &lt;code&gt;200&lt;/code&gt;.&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>&lt;code&gt;browserslist&lt;/code&gt; default values</title>
      <link>https://f2cfe404.karltarvascom.pages.dev/browserslist-defaults/</link>
      <guid>https://f2cfe404.karltarvascom.pages.dev/browserslist-defaults/</guid>
      <pubDate>Thu, 13 May 2021 00:00:00 &#43;0000</pubDate>
      <description>&lt;p&gt;If you use &lt;a href=&#34;https://babeljs.io/docs/en/babel-preset-env&#34;&gt;&lt;code&gt;@babel/preset-env&lt;/code&gt;&lt;/a&gt; or simply &lt;a href=&#34;https://github.com/browserslist/browserslist&#34;&gt;&lt;code&gt;browserslist&lt;/code&gt;&lt;/a&gt; by itself without configuration it falls back to &lt;a href=&#34;https://github.com/browserslist/browserslist#full-list&#34;&gt;the default configuration&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-fallback&#34; data-lang=&#34;fallback&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&amp;gt; 0.5%, last 2 versions, Firefox ESR, not dead&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;To see what this evaluates to you can run &lt;code&gt;npx browserslist defaults&lt;/code&gt;, as of writing it evaluates to the following list:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-fallback&#34; data-lang=&#34;fallback&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;and_chr 78&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;and_ff 68&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;and_qq 1.2&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;and_uc 12.12&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;android 76&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;baidu 7.12&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;chrome 78&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;chrome 77&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;chrome 76&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;chrome 49&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;edge 18&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;edge 17&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;firefox 70&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;firefox 69&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;firefox 68&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;ie 11&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;ie_mob 11&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;ios_saf 13.2&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;ios_saf 13.0-13.1&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;ios_saf 12.2-12.4&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;kaios 2.5&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;op_mini all&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;op_mob 46&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;opera 64&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;opera 63&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;safari 13&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;safari 12.1&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;safari 5.1&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;samsung 10.1&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;samsung 9.2&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</description>
    </item>
    
    <item>
      <title>Japt: Playing with primes</title>
      <link>https://f2cfe404.karltarvascom.pages.dev/japt-playing-with-primes/</link>
      <guid>https://f2cfe404.karltarvascom.pages.dev/japt-playing-with-primes/</guid>
      <pubDate>Wed, 17 Mar 2021 00:00:00 &#43;0000</pubDate>
      <description>&lt;p&gt;Unlike some golfing languages, &lt;a href=&#34;https://github.com/ETHproductions/japt&#34;&gt;Japt&lt;/a&gt; doesn&amp;rsquo;t have too many tools to play around with prime numbers. The below patterns come up fairly frequently and may be of help.&lt;/p&gt;&#xA;&lt;p&gt;Get the first &lt;code&gt;A&lt;/code&gt; prime numbers:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-ts&#34; data-lang=&#34;ts&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;err&#34;&gt;È&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;j&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;}&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;jA&lt;/span&gt; &#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;   &lt;span class=&#34;nx&#34;&gt;jA&lt;/span&gt; &lt;span class=&#34;c1&#34;&gt;// Get the first A positive integers that return true&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;&lt;/span&gt;&lt;span class=&#34;err&#34;&gt;È&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;}&lt;/span&gt;   &lt;span class=&#34;c1&#34;&gt;// when run through a function that&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;j&lt;/span&gt;    &lt;span class=&#34;c1&#34;&gt;// checks whether the number is prime.&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Similarly, get the &lt;code&gt;A&lt;/code&gt;-th prime number:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-ts&#34; data-lang=&#34;ts&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;err&#34;&gt;È&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;j&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;}&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;iA&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;   &lt;span class=&#34;nx&#34;&gt;iA&lt;/span&gt; &lt;span class=&#34;c1&#34;&gt;// Get the A-th positive integer&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;&lt;/span&gt;&lt;span class=&#34;err&#34;&gt;È&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;j&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;}&lt;/span&gt;   &lt;span class=&#34;c1&#34;&gt;// that is prime.&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Get all prime number up to &lt;code&gt;A&lt;/code&gt;, inclusive:&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>Typescript &lt;code&gt;Array.filter(Boolean)&lt;/code&gt;</title>
      <link>https://f2cfe404.karltarvascom.pages.dev/typescript-array-filter-boolean/</link>
      <guid>https://f2cfe404.karltarvascom.pages.dev/typescript-array-filter-boolean/</guid>
      <pubDate>Thu, 11 Mar 2021 00:00:00 &#43;0000</pubDate>
      <description>&lt;p&gt;Out of the box, Typescript doesn&amp;rsquo;t play well with &lt;code&gt;Array.filter(Boolean)&lt;/code&gt;. There&amp;rsquo;s &lt;a href=&#34;https://github.com/microsoft/TypeScript/issues/16655&#34;&gt;a lot of history to this issue&lt;/a&gt; and it hasn&amp;rsquo;t fully been fixed yet. In the below snippet, the returned type from the filter &lt;em&gt;should&lt;/em&gt; be &lt;code&gt;string[]&lt;/code&gt;, but instead it&amp;rsquo;s &lt;code&gt;(string | null | undefined)[]&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-ts&#34; data-lang=&#34;ts&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kr&#34;&gt;const&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;foo&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;:&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;string&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;|&lt;/span&gt; &lt;span class=&#34;kc&#34;&gt;null&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;|&lt;/span&gt; &lt;span class=&#34;kc&#34;&gt;undefined&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)[]&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;[];&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kr&#34;&gt;const&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;bar&lt;/span&gt;: &lt;span class=&#34;kt&#34;&gt;string&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;[]&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;foo&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;filter&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;nb&#34;&gt;Boolean&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;//    ^^^&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;// Type &amp;#39;(string | null | undefined)[]&amp;#39; is not assignable to type &amp;#39;string[]&amp;#39;.&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;To fix the issue, you can add &lt;a href=&#34;https://www.typescriptlang.org/docs/handbook/functions.html#overloads&#34;&gt;an overload&lt;/a&gt; to &lt;code&gt;Array.prototype.filter()&lt;/code&gt; for the special case of using the boolean constructor as the predicate. Save the below snippet as &lt;code&gt;lib.es5.d.ts&lt;/code&gt;:&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>&lt;code&gt;eslint-plugin-flowtype-errors&lt;/code&gt; keeps spawning and killing &lt;code&gt;flow&lt;/code&gt; processes</title>
      <link>https://f2cfe404.karltarvascom.pages.dev/eslint-plugin-flowtype-errors-keeps-spawning-and-killing-flow-processes/</link>
      <guid>https://f2cfe404.karltarvascom.pages.dev/eslint-plugin-flowtype-errors-keeps-spawning-and-killing-flow-processes/</guid>
      <pubDate>Wed, 10 Mar 2021 00:00:00 &#43;0000</pubDate>
      <description>&lt;p&gt;Running into this problem, you may notice one of two possible symptoms when running lint: either numerous &lt;code&gt;flow&lt;/code&gt; processes are spawned and killed constantly, or the lint fails with the below error.&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-fallback&#34; data-lang=&#34;fallback&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;Flow returned an error: Out of retries, exiting! (code: 7)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;To debug the issue you may run &lt;code&gt;flow check&lt;/code&gt; by itself, but the same problem appears: the server is spawned, then killed and respawn over and over again.&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>&lt;code&gt;@testing-library/user-event&lt;/code&gt;&#39;s &lt;code&gt;type()&lt;/code&gt; is slow</title>
      <link>https://f2cfe404.karltarvascom.pages.dev/testing-library-user-events-type-is-slow/</link>
      <guid>https://f2cfe404.karltarvascom.pages.dev/testing-library-user-events-type-is-slow/</guid>
      <pubDate>Mon, 08 Mar 2021 00:00:00 &#43;0000</pubDate>
      <description>&lt;p&gt;&lt;a href=&#34;https://testing-library.com/&#34;&gt;Testing Library&lt;/a&gt; is the &lt;a href=&#34;https://reactjs.org/docs/testing.html#tools&#34;&gt;current recommended way&lt;/a&gt; to unit test React code. By itself it works great and does a lot of the heavy lifting for you. Its sibling library &lt;code&gt;@testing-library/user-event&lt;/code&gt; which can be used to trigger click events, typing etc is still a bit green though.&lt;/p&gt;&#xA;&lt;p&gt;The &lt;code&gt;type()&lt;/code&gt; command is great for simulating user input letter-by-letter, however it has some issues: without a delay, it is non-deterministic, meaning you&amp;rsquo;ll need to manually wait for the UI to update in certain cases. On the flip side, even if you use &lt;code&gt;Number.MIN_VALUE&lt;/code&gt; (smallest non-zero positive number in Javascript) for the delay, it takes a huge performance hit.&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>Typescript: Allow any type except specific values</title>
      <link>https://f2cfe404.karltarvascom.pages.dev/typescript-allow-any-type-except-specific-values/</link>
      <guid>https://f2cfe404.karltarvascom.pages.dev/typescript-allow-any-type-except-specific-values/</guid>
      <pubDate>Mon, 22 Feb 2021 00:00:00 &#43;0000</pubDate>
      <description>&lt;p&gt;Typescript doesn&amp;rsquo;t have a simple type to describe the relation &amp;ldquo;allow any type except the string literals &lt;code&gt;&amp;quot;foo&amp;quot;&lt;/code&gt; and &lt;code&gt;&amp;quot;bar&amp;quot;&lt;/code&gt;&amp;rdquo;. However, &lt;a href=&#34;https://stackoverflow.com/a/51445345/1470607&#34;&gt;a small generic interjeciton type&lt;/a&gt; will enable Typescript to understand what you mean:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-ts&#34; data-lang=&#34;ts&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kr&#34;&gt;type&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;Disallowed&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;s2&#34;&gt;&amp;#34;foo&amp;#34;&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;|&lt;/span&gt; &lt;span class=&#34;s2&#34;&gt;&amp;#34;bar&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kr&#34;&gt;type&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;Input&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&#34;nt&#34;&gt;T&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;T&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;&amp;amp;&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;T&lt;/span&gt; &lt;span class=&#34;kr&#34;&gt;extends&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;Disallowed&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;?&lt;/span&gt; &lt;span class=&#34;kt&#34;&gt;never&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;:&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;T&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;// Any input is valid except for the string literals &amp;#34;foo&amp;#34; and &amp;#34;bar&amp;#34;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;&lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;function&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;snafucate&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&#34;nt&#34;&gt;T&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;&amp;gt;(&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;input&lt;/span&gt;: &lt;span class=&#34;kt&#34;&gt;Input&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&#34;nt&#34;&gt;T&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;&amp;gt;)&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;{...}&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</description>
    </item>
    
    <item>
      <title>Japt: Count overlapping substrings</title>
      <link>https://f2cfe404.karltarvascom.pages.dev/japt-count-overlapping-substrings/</link>
      <guid>https://f2cfe404.karltarvascom.pages.dev/japt-count-overlapping-substrings/</guid>
      <pubDate>Tue, 16 Feb 2021 00:00:00 &#43;0000</pubDate>
      <description>&lt;p&gt;Finding the number of &lt;a href=&#34;https://codegolf.stackexchange.com/q/218978/16484&#34;&gt;overlapping needles in a haystack&lt;/a&gt; in &lt;a href=&#34;https://github.com/ETHproductions/japt&#34;&gt;Japt&lt;/a&gt; is slightly verbose, clocking in at &lt;a href=&#34;https://ethproductions.github.io/japt/?v=1.4.6&amp;amp;code=8FYK5M8tWDxWbAro&amp;amp;input=InRyb2xvbG9sb2xvbCIKImxvbCI=&#34;&gt;12 bytes&lt;/a&gt;, but still a fun fiddling exercise for a change.&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-js&#34; data-lang=&#34;js&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;nx&#34;&gt;ðV&lt;/span&gt;      &lt;span class=&#34;c1&#34;&gt;// Get all indices of needle in the input.&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;äÏ&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;-&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;X&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;Vl&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;nx&#34;&gt;ä&lt;/span&gt;       &lt;span class=&#34;c1&#34;&gt;// For every consecutive pair of indices&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;Ï&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;-&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;X&lt;/span&gt;    &lt;span class=&#34;c1&#34;&gt;// check whether their distance&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;&lt;/span&gt;    &lt;span class=&#34;o&#34;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;Vl&lt;/span&gt; &lt;span class=&#34;c1&#34;&gt;// is smaller than the needle length, e.g. whether they overlap.&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;è&lt;/span&gt;       &lt;span class=&#34;c1&#34;&gt;// Return the number of items that were true.&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</description>
    </item>
    
    <item>
      <title>Annotating legacy jQuery plugins with Typescript</title>
      <link>https://f2cfe404.karltarvascom.pages.dev/annotating-legacy-jquery-plugins-with-typescript/</link>
      <guid>https://f2cfe404.karltarvascom.pages.dev/annotating-legacy-jquery-plugins-with-typescript/</guid>
      <pubDate>Wed, 27 Jan 2021 00:00:00 &#43;0000</pubDate>
      <description>&lt;p&gt;Annotating legacy jQuery with Typescript can be a pain. Many old plugins don&amp;rsquo;t have type definitions available, and the &lt;a href=&#34;https://www.npmjs.com/package/@types/jquery&#34;&gt;official types&lt;/a&gt; only get you so far on their own.&lt;/p&gt;&#xA;&lt;p&gt;Instead of littering your code base with separate &lt;code&gt;.d.ts&lt;/code&gt; definition files, it can be very convenient to annotate the types inline in the component file itself.&lt;br&gt;&#xA;The following examples cover most common use cases:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-ts&#34; data-lang=&#34;ts&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kr&#34;&gt;type&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;PluginInstance&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;JQuery&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;&amp;amp;&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;  &lt;span class=&#34;c1&#34;&gt;// Any methods or properties the plugin adds, e.g. `jQuery(selector).plugin().instanceMethod()`&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;&lt;/span&gt;  &lt;span class=&#34;nx&#34;&gt;instanceMethod&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;:&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;()&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&#34;kt&#34;&gt;any&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;p&#34;&gt;};&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kr&#34;&gt;type&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;StaticProperties&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;  &lt;span class=&#34;c1&#34;&gt;// Any static methods or properties the plugin adds, e.g. `jQuery.fn.plugin.staticProperty`&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;&lt;/span&gt;  &lt;span class=&#34;nx&#34;&gt;staticProperty&lt;/span&gt;: &lt;span class=&#34;kt&#34;&gt;any&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;p&#34;&gt;};&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kr&#34;&gt;type&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;Plugin&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;((...&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;args&lt;/span&gt;: &lt;span class=&#34;kt&#34;&gt;any&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;[])&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;PluginInstance&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;&amp;amp;&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;StaticProperties&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kr&#34;&gt;declare&lt;/span&gt; &lt;span class=&#34;kr&#34;&gt;global&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;  &lt;span class=&#34;kr&#34;&gt;interface&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;JQuery&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;      &lt;span class=&#34;nx&#34;&gt;plugin&lt;/span&gt;: &lt;span class=&#34;kt&#34;&gt;Plugin&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;  &lt;span class=&#34;p&#34;&gt;}&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;p&#34;&gt;}&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The following code snippets will then make sense for Typescript:&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>Typescript generics in JSX</title>
      <link>https://f2cfe404.karltarvascom.pages.dev/typescript-generics-in-jsx/</link>
      <guid>https://f2cfe404.karltarvascom.pages.dev/typescript-generics-in-jsx/</guid>
      <pubDate>Mon, 25 Jan 2021 00:00:00 &#43;0000</pubDate>
      <description>&lt;p&gt;Passing type variables to &lt;a href=&#34;https://www.typescriptlang.org/docs/handbook/generics.html&#34;&gt;Typescript generics&lt;/a&gt; is somewhat clunky in JSX, but still handy in certain cases.&lt;/p&gt;&#xA;&lt;p&gt;Given a generic component:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-tsx&#34; data-lang=&#34;tsx&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kr&#34;&gt;export&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;default&lt;/span&gt; &lt;span class=&#34;kd&#34;&gt;function&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;GenericComponent&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&#34;nt&#34;&gt;T&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;&amp;gt;()&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;{&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;...&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;}&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;You can annotate the type in JSX as follows:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-tsx&#34; data-lang=&#34;tsx&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;p&#34;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&#34;nt&#34;&gt;GenericComponent&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&#34;nt&#34;&gt;Type&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&#34;na&#34;&gt;...props&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;/&amp;gt;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</description>
    </item>
    
    <item>
      <title>Typescript 4.1: Template literal types, computed property names, and more</title>
      <link>https://f2cfe404.karltarvascom.pages.dev/typescript-4/</link>
      <guid>https://f2cfe404.karltarvascom.pages.dev/typescript-4/</guid>
      <pubDate>Sun, 24 Jan 2021 00:00:00 &#43;0000</pubDate>
      <description>&lt;p&gt;Typescript 4.1 adds support for &lt;a href=&#34;https://github.com/microsoft/TypeScript/pull/40336&#34;&gt;template literal types&lt;/a&gt;. This, along with the new utility types, unlocks computed property names, simple getter-setter interfaces and more.&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-ts&#34; data-lang=&#34;ts&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kr&#34;&gt;type&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;Foo&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;s1&#34;&gt;&amp;#39;a&amp;#39;&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;|&lt;/span&gt; &lt;span class=&#34;s1&#34;&gt;&amp;#39;b&amp;#39;&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;|&lt;/span&gt; &lt;span class=&#34;s1&#34;&gt;&amp;#39;c&amp;#39;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;// Bar = &amp;#39;a-template&amp;#39; | &amp;#39;b-template&amp;#39; | &amp;#39;c-template&amp;#39;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;&lt;/span&gt;&lt;span class=&#34;kr&#34;&gt;type&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;Bar&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;sb&#34;&gt;`&lt;/span&gt;&lt;span class=&#34;si&#34;&gt;${&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;Foo&lt;/span&gt;&lt;span class=&#34;si&#34;&gt;}&lt;/span&gt;&lt;span class=&#34;sb&#34;&gt;-template`&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;In addition, a number of new utility types have been introduced:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-ts&#34; data-lang=&#34;ts&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kr&#34;&gt;type&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;A&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;Uppercase&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&#34;s1&#34;&gt;&amp;#39;MixedCase&amp;#39;&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt; &lt;span class=&#34;c1&#34;&gt;// &amp;#39;MIXEDCASE&amp;#39;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;&lt;/span&gt;&lt;span class=&#34;kr&#34;&gt;type&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;B&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;Lowercase&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&#34;s1&#34;&gt;&amp;#39;MixedCase&amp;#39;&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt; &lt;span class=&#34;c1&#34;&gt;// &amp;#39;mixedcase&amp;#39;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;&lt;/span&gt;&lt;span class=&#34;kr&#34;&gt;type&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;C&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;Capitalize&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&#34;s1&#34;&gt;&amp;#39;MixedCase&amp;#39;&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt; &lt;span class=&#34;c1&#34;&gt;// &amp;#39;MixedCase&amp;#39;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;&lt;/span&gt;&lt;span class=&#34;kr&#34;&gt;type&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;D&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;Uncapitalize&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&#34;s1&#34;&gt;&amp;#39;MixedCase&amp;#39;&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt; &lt;span class=&#34;c1&#34;&gt;// &amp;#39;mixedCase&amp;#39;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Combining the above with the &lt;code&gt;as&lt;/code&gt; keyword makes creating Redux-like functionality with strict types a breeze.&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-ts&#34; data-lang=&#34;ts&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kr&#34;&gt;type&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;State&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;nx&#34;&gt;foo&lt;/span&gt;: &lt;span class=&#34;kt&#34;&gt;string&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;nx&#34;&gt;bar&lt;/span&gt;: &lt;span class=&#34;kt&#34;&gt;number&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;p&#34;&gt;}&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;cm&#34;&gt;/**&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;cm&#34;&gt; * Actions = {&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;cm&#34;&gt; *   setFoo: (state: State, value: string) =&amp;gt; void;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;cm&#34;&gt; *   setBar: (state: State, value: number) =&amp;gt; void;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;cm&#34;&gt; * }&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;cm&#34;&gt; */&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kr&#34;&gt;type&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;Actions&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;  &lt;span class=&#34;p&#34;&gt;[&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;K&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;in&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;keyof&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;State&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;&amp;amp;&lt;/span&gt; &lt;span class=&#34;kt&#34;&gt;string&lt;/span&gt; &lt;span class=&#34;kr&#34;&gt;as&lt;/span&gt; &lt;span class=&#34;sb&#34;&gt;`set&lt;/span&gt;&lt;span class=&#34;si&#34;&gt;${&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;Capitalize&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&#34;nt&#34;&gt;K&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&#34;si&#34;&gt;}&lt;/span&gt;&lt;span class=&#34;sb&#34;&gt;`&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;]&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;:&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;state&lt;/span&gt;: &lt;span class=&#34;kt&#34;&gt;State&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;value&lt;/span&gt;: &lt;span class=&#34;kt&#34;&gt;State&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;[&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;K&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;])&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;void&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;p&#34;&gt;}&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</description>
    </item>
    
    <item>
      <title>Javascript: case sensitive string compare</title>
      <link>https://f2cfe404.karltarvascom.pages.dev/javascript-case-sensitive-string-compare/</link>
      <guid>https://f2cfe404.karltarvascom.pages.dev/javascript-case-sensitive-string-compare/</guid>
      <pubDate>Fri, 22 Jan 2021 00:00:00 &#43;0000</pubDate>
      <description>&lt;p&gt;Getting case &lt;strong&gt;sensitive&lt;/strong&gt; string compare in Javascript &lt;a href=&#34;https://stackoverflow.com/a/65843476/1470607&#34;&gt;isn&amp;rsquo;t as trivial as it may seem at first&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-js&#34; data-lang=&#34;js&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;// Returns [&amp;#34;Action&amp;#34;, &amp;#34;activity&amp;#34;, &amp;#34;alpha&amp;#34;],&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;// although [&amp;#34;activity&amp;#34;, &amp;#34;alpha&amp;#34;, &amp;#34;Action&amp;#34;] is expected instead&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;[&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;alpha&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;s2&#34;&gt;&amp;#34;Action&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;s2&#34;&gt;&amp;#34;activity&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;].&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;sort&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;((&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;a&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;b&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;k&#34;&gt;return&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;a&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;localeCompare&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;b&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;{&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;sensitivity&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;:&lt;/span&gt; &lt;span class=&#34;s1&#34;&gt;&amp;#39;case&amp;#39;&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;});&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;p&#34;&gt;});&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The &lt;a href=&#34;https://stackoverflow.com/questions/65842776/localecompare-case-sensitive-alphabetically-issue/65843476?noredirect=1#comment116415145_65842776&#34;&gt;jury is still out&lt;/a&gt; on wheter this is an oversight in the spec or the common vendor implementations, in the meanwhile, a manual comparer does the trick:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-js&#34; data-lang=&#34;js&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kd&#34;&gt;function&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;caseSensitiveCompare&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;a&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;b&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;  &lt;span class=&#34;c1&#34;&gt;// Sort character by character, return early if possible&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;&lt;/span&gt;  &lt;span class=&#34;k&#34;&gt;for&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;kd&#34;&gt;let&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;ii&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;mi&#34;&gt;0&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;ii&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&#34;nb&#34;&gt;Math&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;max&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;a&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;length&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;b&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;length&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;ii&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;++&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;kr&#34;&gt;const&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;aChar&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;a&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;charAt&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;ii&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;kr&#34;&gt;const&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;bChar&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;b&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;charAt&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;ii&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;c1&#34;&gt;// If inputs match up to here, but lengths don&amp;#39;t match, sort by length&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;&lt;/span&gt;    &lt;span class=&#34;k&#34;&gt;if&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;!&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;aChar&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;bChar&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;))&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;      &lt;span class=&#34;k&#34;&gt;return&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;a&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;length&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;-&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;b&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;length&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;p&#34;&gt;}&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;c1&#34;&gt;// If we meet a differing character, return early&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;&lt;/span&gt;    &lt;span class=&#34;kr&#34;&gt;const&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;comp&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;aChar&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;localeCompare&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;bChar&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;k&#34;&gt;if&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;comp&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;!==&lt;/span&gt; &lt;span class=&#34;mi&#34;&gt;0&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;      &lt;span class=&#34;k&#34;&gt;return&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;comp&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;p&#34;&gt;}&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;  &lt;span class=&#34;p&#34;&gt;}&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;  &lt;span class=&#34;c1&#34;&gt;// If we found nothing to do, the strings are equal&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;&lt;/span&gt;  &lt;span class=&#34;k&#34;&gt;return&lt;/span&gt; &lt;span class=&#34;mi&#34;&gt;0&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;p&#34;&gt;};&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The above snippet covers full string sensitivity while still relying on &lt;a href=&#34;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/localeCompare&#34;&gt;&lt;code&gt;localeCompare()&lt;/code&gt;&lt;/a&gt; for the grunt work.&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>React &amp; Typescript: Using &lt;code&gt;React.Children.toArray()&lt;/code&gt; with &lt;code&gt;React.cloneElement()&lt;/code&gt;</title>
      <link>https://f2cfe404.karltarvascom.pages.dev/react-and-typescript-using-react-children-toarray-with-react-cloneelement/</link>
      <guid>https://f2cfe404.karltarvascom.pages.dev/react-and-typescript-using-react-children-toarray-with-react-cloneelement/</guid>
      <pubDate>Wed, 13 Jan 2021 00:00:00 &#43;0000</pubDate>
      <description>&lt;p&gt;Trying to clone props children when using React with Typescript, you may run into the following type error: &lt;code&gt;Type &#39;string&#39; is not assignable to type ReactElement...&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-ts&#34; data-lang=&#34;ts&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;nx&#34;&gt;React&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;Children&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;toArray&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;props&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;children&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;  &lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;map&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;child&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;React&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;cloneElement&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;child&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;));&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The problem is that &lt;a href=&#34;https://stackoverflow.com/a/42261933/1470607&#34;&gt;&lt;code&gt;ReactChild&lt;/code&gt; includes &lt;code&gt;string | number&lt;/code&gt;&lt;/a&gt;, which is not a valid clone target.&lt;/p&gt;&#xA;&lt;p&gt;To solve the issue, add a &lt;a href=&#34;https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guards&#34;&gt;type guard&lt;/a&gt; that checks whether the child is a valid element to clone, passing non-cloneable children through as-is:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-ts&#34; data-lang=&#34;ts&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;nx&#34;&gt;React&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;Children&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;toArray&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;props&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;children&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;  &lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;map&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;child&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;React&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;isValidElement&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;child&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;?&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;React&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;cloneElement&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;child&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;:&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;child&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</description>
    </item>
    
    <item>
      <title>Bash: Using a default value with &lt;abbr title=&#34;dollar sign asterisk&#34;&gt;&lt;code&gt;$*&lt;/code&gt;&lt;/abbr&gt;</title>
      <link>https://f2cfe404.karltarvascom.pages.dev/bash-using-a-default-value-with-dollar-sign-asterisk/</link>
      <guid>https://f2cfe404.karltarvascom.pages.dev/bash-using-a-default-value-with-dollar-sign-asterisk/</guid>
      <pubDate>Tue, 12 Jan 2021 00:00:00 &#43;0000</pubDate>
      <description>&lt;p&gt;In Bash, &lt;abbr title=&#34;dollar sign asterisk&#34;&gt;&lt;code&gt;$*&lt;/code&gt;&lt;/abbr&gt; gives you &lt;a href=&#34;https://stackoverflow.com/a/5163260/1470607&#34;&gt;the IFS expansion of all positional parameters&lt;/a&gt;, such as &lt;code&gt;$1 $2 $3&lt;/code&gt; etc.&#xA;This can be super handy when dealing with &lt;a href=&#34;https://stackoverflow.com/a/65321060/1470607&#34;&gt;inline helper functions&lt;/a&gt;, but the use cases are too many to count.&lt;/p&gt;&#xA;&lt;p&gt;Assigning a fallback default value uses &lt;a href=&#34;https://stackoverflow.com/a/2013589/1470607&#34;&gt;the same syntax as regular variables do&lt;/a&gt;, but the syntax would make you look twice the first time you saw it:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;# Use $1 $2 $3 etc, or &amp;#34;foo&amp;#34; if no parameters are specified&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;si&#34;&gt;${&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;*&lt;/span&gt;&lt;span class=&#34;k&#34;&gt;:-&lt;/span&gt;&lt;span class=&#34;nv&#34;&gt;foo&lt;/span&gt;&lt;span class=&#34;si&#34;&gt;}&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</description>
    </item>
    
    <item>
      <title>Javascript &lt;code&gt;Boolean.compare()&lt;/code&gt;</title>
      <link>https://f2cfe404.karltarvascom.pages.dev/javascript-boolean-compare/</link>
      <guid>https://f2cfe404.karltarvascom.pages.dev/javascript-boolean-compare/</guid>
      <pubDate>Sat, 19 Dec 2020 00:00:00 &#43;0000</pubDate>
      <description>&lt;p&gt;Javascript &lt;a href=&#34;https://stackoverflow.com/a/65371118/1470607&#34;&gt;doesn&amp;rsquo;t have&lt;/a&gt; a builtin that&amp;rsquo;s comparable to Java&amp;rsquo;s &lt;a href=&#34;https://docs.oracle.com/javase/7/docs/api/java/lang/Boolean.html#compare(boolean,%20boolean)&#34;&gt;&lt;code&gt;Boolean.compare()&lt;/code&gt;&lt;/a&gt;. In fact, &lt;a href=&#34;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean&#34;&gt;the Boolean class&lt;/a&gt; has nearly nothing in it, save the constructor, &lt;code&gt;toString()&lt;/code&gt; and &lt;code&gt;valueOf()&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The functionality can be replicated using &lt;a href=&#34;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number&#34;&gt;the &lt;code&gt;Number&lt;/code&gt; constructor&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-ts&#34; data-lang=&#34;ts&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kd&#34;&gt;function&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;booleanCompare&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;a&lt;/span&gt;: &lt;span class=&#34;kt&#34;&gt;boolean&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;b&lt;/span&gt;: &lt;span class=&#34;kt&#34;&gt;boolean&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;k&#34;&gt;return&lt;/span&gt; &lt;span class=&#34;nb&#34;&gt;Number&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;a&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;-&lt;/span&gt; &lt;span class=&#34;nb&#34;&gt;Number&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;b&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;p&#34;&gt;}&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</description>
    </item>
    
    <item>
      <title>Github Actions: cache &lt;code&gt;yarn install&lt;/code&gt;</title>
      <link>https://f2cfe404.karltarvascom.pages.dev/github-actions-cache-yarn-install/</link>
      <guid>https://f2cfe404.karltarvascom.pages.dev/github-actions-cache-yarn-install/</guid>
      <pubDate>Wed, 09 Dec 2020 00:00:00 &#43;0000</pubDate>
      <description>&lt;p&gt;Edited &lt;time&gt;2021-03-04&lt;/time&gt;: Upgraded &lt;code&gt;actions/setup-node&lt;/code&gt; to version 2.&lt;/p&gt;&#xA;&lt;p&gt;Caching dependencies installed by &lt;a href=&#34;https://yarnpkg.com/&#34;&gt;Yarn&lt;/a&gt; in &lt;a href=&#34;https://github.com/features/actions&#34;&gt;Github Actions&lt;/a&gt; is fairly straightforward, but there are a few small gotchas to get right:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Caching &lt;code&gt;node_modules&lt;/code&gt; directly isn&amp;rsquo;t efficient, using Yarn&amp;rsquo;s built-in cache system is both faster and takes up less space.&lt;/li&gt;&#xA;&lt;li&gt;Using &lt;code&gt;--prefer-offline&lt;/code&gt; ensures your cache is used if it is available, but the install will still pass with no errors if anything needs to be downloaded from the network.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Combining the above with &lt;a href=&#34;https://github.com/actions/cache/blob/main/examples.md#node---yarn&#34;&gt;the examples from the documentation&lt;/a&gt;, below is a functional example of a Github Action with dependency caching.&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>&lt;code&gt;osc&lt;/code&gt; cheatsheet for OBS</title>
      <link>https://f2cfe404.karltarvascom.pages.dev/osc-cheatsheet-for-obs/</link>
      <guid>https://f2cfe404.karltarvascom.pages.dev/osc-cheatsheet-for-obs/</guid>
      <pubDate>Mon, 16 Nov 2020 00:00:00 &#43;0000</pubDate>
      <description>&lt;p&gt;&lt;a href=&#34;https://openbuildservice.org/&#34;&gt;Open Build Service&lt;/a&gt;, OBS for short, uses &lt;a href=&#34;https://github.com/openSUSE/osc&#34;&gt;&lt;code&gt;osc&lt;/code&gt;&lt;/a&gt; as its CLI interface. &lt;code&gt;osc&lt;/code&gt; is an SVN-like version control system with a good overview and a  starter configuration guide on &lt;a href=&#34;https://en.opensuse.org/openSUSE:OSC#Recommended_starter_configuration&#34;&gt;the openSUSE wiki&lt;/a&gt;.&lt;br&gt;&#xA;On macOS you can install it via &lt;a href=&#34;https://brew.sh/&#34;&gt;Homebrew&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;$ brew install osc&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;To create a branch of a package, similar to a feature branch in Git:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;$ osc branch &amp;lt;&lt;span class=&#34;nb&#34;&gt;source&lt;/span&gt; project&amp;gt; &amp;lt;package&amp;gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Check out your local branch:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;$ osc co &amp;lt;branched project&amp;gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;To pull changes from the remote, aka update local to the remote state:&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>Using AMD modules in Stack Overflow snippets</title>
      <link>https://f2cfe404.karltarvascom.pages.dev/using-amd-modules-in-stack-overflow-snippets/</link>
      <guid>https://f2cfe404.karltarvascom.pages.dev/using-amd-modules-in-stack-overflow-snippets/</guid>
      <pubDate>Mon, 09 Nov 2020 00:00:00 &#43;0000</pubDate>
      <description>&lt;p&gt;If you&amp;rsquo;re answering a question on Stack Overflow and want to use a library in the code snippet that only supports AMD, the following small jig may be useful. Exports are added to the global scope so you can use them directly in the sample code.&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-html&#34; data-lang=&#34;html&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;p&#34;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&#34;nt&#34;&gt;script&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;&amp;gt;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;  &lt;span class=&#34;kr&#34;&gt;const&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;define&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;_&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;module&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;module&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;();&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;  &lt;span class=&#34;nx&#34;&gt;define&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;amd&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;kc&#34;&gt;true&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;p&#34;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&#34;nt&#34;&gt;script&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;&amp;gt;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;p&#34;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&#34;nt&#34;&gt;script&lt;/span&gt; &lt;span class=&#34;na&#34;&gt;src&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;example.com/amd-only.js&amp;#34;&lt;/span&gt; &lt;span class=&#34;na&#34;&gt;crossorigin&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;anonymous&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class=&#34;nt&#34;&gt;script&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;&amp;gt;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</description>
    </item>
    
    <item>
      <title>VirtualBox network modes</title>
      <link>https://f2cfe404.karltarvascom.pages.dev/virtualbox-network-modes/</link>
      <guid>https://f2cfe404.karltarvascom.pages.dev/virtualbox-network-modes/</guid>
      <pubDate>Tue, 03 Nov 2020 00:00:00 &#43;0000</pubDate>
      <description>&lt;p&gt;As covered in &lt;a href=&#34;https://www.virtualbox.org/manual/ch06.html#networkingmodes&#34;&gt;the VirtualBox networking docs&lt;/a&gt;, the quickest overview into different networking modes is the following table:&lt;/p&gt;&#xA;&lt;style&gt;&#xA;#network-table .allowed {&#xA;}&#xA;&#xA;#network-table .not-allowed {&#xA;    background: rgb(103, 114, 229, 0.15);&#xA;}&#xA;&#xA;#network-table th:first-child {&#xA;    border: none;&#xA;}&#xA;&#xA;#network-table th {&#xA;    text-align: center;&#xA;}&#xA;&#xA;#network-table td {&#xA;  text-align: center;&#xA;}&#xA;&#xA;#network-table td:first-child {&#xA;  text-align: left;&#xA;}&#xA;&lt;/style&gt;&#xA;&lt;table id=&#34;network-table&#34;&gt;&#xA;  &lt;thead&gt;&#xA;    &lt;tr&gt;&#xA;      &lt;th&gt;&lt;/th&gt;&#xA;      &lt;th&gt;VM ↔ VM&lt;/th&gt;&#xA;      &lt;th&gt;VM → Host&lt;/th&gt;&#xA;      &lt;th&gt;Host → VM&lt;/th&gt;&#xA;      &lt;th&gt;VM → Net/LAN&lt;/th&gt;&#xA;      &lt;th&gt;Net/LAN → VM&lt;/th&gt;&#xA;    &lt;/tr&gt;&#xA;  &lt;/thead&gt;&#xA;  &lt;tbody&gt;&#xA;    &lt;tr&gt;&#xA;      &lt;td&gt;Not attached&lt;/td&gt;&#xA;      &lt;td class=&#34;not-allowed&#34;&gt;-&lt;/td&gt;&#xA;      &lt;td class=&#34;not-allowed&#34;&gt;-&lt;/td&gt;&#xA;      &lt;td class=&#34;not-allowed&#34;&gt;-&lt;/td&gt;&#xA;      &lt;td class=&#34;not-allowed&#34;&gt;-&lt;/td&gt;&#xA;      &lt;td class=&#34;not-allowed&#34;&gt;-&lt;/td&gt;&#xA;    &lt;/tr&gt;&#xA;    &lt;tr&gt;&#xA;      &lt;td&gt;Internal Network&lt;/td&gt;&#xA;      &lt;td class=&#34;allowed&#34;&gt;+&lt;/td&gt;&#xA;      &lt;td class=&#34;not-allowed&#34;&gt;-&lt;/td&gt;&#xA;      &lt;td class=&#34;not-allowed&#34;&gt;-&lt;/td&gt;&#xA;      &lt;td class=&#34;not-allowed&#34;&gt;-&lt;/td&gt;&#xA;      &lt;td class=&#34;not-allowed&#34;&gt;-&lt;/td&gt;&#xA;    &lt;/tr&gt;&#xA;    &lt;tr&gt;&#xA;      &lt;td&gt;Host-only&lt;/td&gt;&#xA;      &lt;td class=&#34;allowed&#34;&gt;+&lt;/td&gt;&#xA;      &lt;td class=&#34;allowed&#34;&gt;+&lt;/td&gt;&#xA;      &lt;td class=&#34;allowed&#34;&gt;+&lt;/td&gt;&#xA;      &lt;td class=&#34;not-allowed&#34;&gt;-&lt;/td&gt;&#xA;      &lt;td class=&#34;not-allowed&#34;&gt;-&lt;/td&gt;&#xA;    &lt;/tr&gt;&#xA;    &lt;tr&gt;&#xA;      &lt;td&gt;NAT&lt;/td&gt;&#xA;      &lt;td class=&#34;not-allowed&#34;&gt;-&lt;/td&gt;&#xA;      &lt;td class=&#34;allowed&#34;&gt;+&lt;/td&gt;&#xA;      &lt;td&gt;forwarded ports&lt;/td&gt;&#xA;      &lt;td class=&#34;allowed&#34;&gt;+&lt;/td&gt;&#xA;      &lt;td&gt;forwarded ports&lt;/td&gt;&#xA;    &lt;/tr&gt;&#xA;    &lt;tr&gt;&#xA;      &lt;td&gt;NAT Network&lt;/td&gt;&#xA;      &lt;td class=&#34;allowed&#34;&gt;+&lt;/td&gt;&#xA;      &lt;td class=&#34;allowed&#34;&gt;+&lt;/td&gt;&#xA;      &lt;td&gt;forwarded ports&lt;/td&gt;&#xA;      &lt;td class=&#34;allowed&#34;&gt;+&lt;/td&gt;&#xA;      &lt;td&gt;forwarded ports&lt;/td&gt;&#xA;    &lt;/tr&gt;&#xA;    &lt;tr&gt;&#xA;      &lt;td&gt;Bridged&lt;/td&gt;&#xA;      &lt;td class=&#34;allowed&#34;&gt;+&lt;/td&gt;&#xA;      &lt;td class=&#34;allowed&#34;&gt;+&lt;/td&gt;&#xA;      &lt;td class=&#34;allowed&#34;&gt;+&lt;/td&gt;&#xA;      &lt;td class=&#34;allowed&#34;&gt;+&lt;/td&gt;&#xA;      &lt;td class=&#34;allowed&#34;&gt;+&lt;/td&gt;&#xA;    &lt;/tr&gt;&#xA;  &lt;/tbody&gt;&#xA;&lt;/table&gt;&#xA;&lt;p&gt;In short, bridged networking happily allows everything, while other less permissive modes give you granular control over your network security.&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>macOS: App sandboxing via &lt;code&gt;sandbox-exec&lt;/code&gt;</title>
      <link>https://f2cfe404.karltarvascom.pages.dev/macos-app-sandboxing-via-sandbox-exec/</link>
      <guid>https://f2cfe404.karltarvascom.pages.dev/macos-app-sandboxing-via-sandbox-exec/</guid>
      <pubDate>Sun, 25 Oct 2020 00:00:00 &#43;0000</pubDate>
      <description>&lt;p&gt;It isn&amp;rsquo;t widely advertised, but macOS ships with a standalone sandboxing utility out of the box: &lt;code&gt;sandbox-exec&lt;/code&gt;. While the very short manpage says the utility has been marked deprecated, and for quite a few major releases now, it&amp;rsquo;s used heavily by internal systems so it&amp;rsquo;s unlikely go away anytime soon.&lt;/p&gt;&#xA;&lt;p&gt;Sandbox configurations are writen in a subset of Scheme. A minimal useful starter example for wrapping a modern application might look something like this:&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>Cypress: &lt;code&gt;cy.readFile()&lt;/code&gt; vs &lt;code&gt;cy.fixture()&lt;/code&gt;</title>
      <link>https://f2cfe404.karltarvascom.pages.dev/cypress-cy-readfile-vs-cy-fixture/</link>
      <guid>https://f2cfe404.karltarvascom.pages.dev/cypress-cy-readfile-vs-cy-fixture/</guid>
      <pubDate>Sun, 25 Oct 2020 00:00:00 &#43;0000</pubDate>
      <description>&lt;p&gt;At first glance, &lt;a href=&#34;https://docs.cypress.io/api/commands/readfile.html#Syntax&#34;&gt;&lt;code&gt;cy.readFile()&lt;/code&gt;&lt;/a&gt; and &lt;a href=&#34;https://docs.cypress.io/api/commands/fixture.html&#34;&gt;&lt;code&gt;cy.fixture()&lt;/code&gt;&lt;/a&gt; seem fairly similar, both read files asynchronously and wrap them as Cypress usually does.&lt;br&gt;&#xA;The main difference is conceptual, but there are some practical considerations as well.&lt;/p&gt;&#xA;&lt;p&gt;Fixtures are meant for files that are used only for your tests, e.g. placeholder test data, sample responses and so forth. In other terms, fixtures are files that would not be a part of your project if you didn&amp;rsquo;t have tests.&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>macOS: Safely installing Microsoft Intune</title>
      <link>https://f2cfe404.karltarvascom.pages.dev/macos-safely-installing-microsoft-intune/</link>
      <guid>https://f2cfe404.karltarvascom.pages.dev/macos-safely-installing-microsoft-intune/</guid>
      <pubDate>Sat, 24 Oct 2020 00:00:00 &#43;0000</pubDate>
      <description>&lt;p&gt;&lt;a href=&#34;https://www.microsoft.com/en/microsoft-365/enterprise-mobility-security/microsoft-intune&#34;&gt;Microsoft Intune&lt;/a&gt; is a remote device management and supervision solution employed by some corporations.&lt;br&gt;&#xA;The below instructions are written assuming &lt;strong&gt;macOS Catalina&lt;/strong&gt; and &lt;strong&gt;APFS&lt;/strong&gt;, the process is fairly similar for other setups.&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;If your daily driver disk isn&amp;rsquo;t encrypted, go to System Preferences → Security &amp;amp; Privacy → FileVault and turn it on&lt;/li&gt;&#xA;&lt;li&gt;Boot into Recovery Mode by holding down &lt;code aria-label=&#34;Command + R&#34;&gt;⌘R&lt;/code&gt; during the boot&lt;/li&gt;&#xA;&lt;li&gt;Open Disk Utility and create a new APFS encrypted volume&lt;/li&gt;&#xA;&lt;li&gt;Exit Disk Utility and choose Reinstall macOS&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;NB!&lt;/strong&gt; Be sure to install on the new volume you just created, or you risk losing all of your data&lt;/li&gt;&#xA;&lt;li&gt;Do not connect with iCloud because Intune reads your keychain&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;ol start=&#34;5&#34;&gt;&#xA;&lt;li&gt;Once the installation is done, reboot and log in to your blank macOS installation&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Upon boot, do not unlock your daily driver volume when prompted&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;ol start=&#34;6&#34;&gt;&#xA;&lt;li&gt;Install Intune as usual, perform enrolment and any other required actions&lt;/li&gt;&#xA;&lt;li&gt;Boot back into Recovery Mode, open Disk Utility, and delete the volume you created earlier&lt;/li&gt;&#xA;&lt;li&gt;Reboot into your daily driver and forget Intune&lt;/li&gt;&#xA;&lt;/ol&gt;</description>
    </item>
    
    <item>
      <title>macOS: pip install M2Crypto</title>
      <link>https://f2cfe404.karltarvascom.pages.dev/macos-pip-install-m2crypto/</link>
      <guid>https://f2cfe404.karltarvascom.pages.dev/macos-pip-install-m2crypto/</guid>
      <pubDate>Tue, 06 Oct 2020 00:00:00 &#43;0000</pubDate>
      <description>&lt;p&gt;Out of the box, trying to install &lt;a href=&#34;https://pypi.org/project/M2Crypto/&#34;&gt;M2Crypto&lt;/a&gt; on macOS will fail with one of two common scenarios on building.&lt;br&gt;&#xA;Either you&amp;rsquo;ll get &lt;a href=&#34;https://gitlab.com/m2crypto/m2crypto/-/issues/148&#34;&gt;OpenSSL errors&lt;/a&gt;, in case you haven&amp;rsquo;t set up a newer version than the system one:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-fallback&#34; data-lang=&#34;fallback&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;Error: Unable to find &amp;#39;openssl/opensslv.h&amp;#39;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Or you&amp;rsquo;ll get &lt;a href=&#34;https://gitlab.com/m2crypto/m2crypto/-/issues/215&#34;&gt;a bunch of clang errors&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-fallback&#34; data-lang=&#34;fallback&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;Error: invalid argument type &amp;#39;void&amp;#39; to unary expression&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;All of this is addressed in the &lt;a href=&#34;https://gitlab.com/m2crypto/m2crypto/-/blob/master/INSTALL.rst#macosx&#34;&gt;project installation page&lt;/a&gt;, which is however easy to miss since it isn&amp;rsquo;t mentioned anywhere in the PyPI readme, the first point of contact when a package doesn&amp;rsquo;t install correctly.&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>macOS: &lt;code&gt;bsdcpio&lt;/code&gt; vs GNU &lt;code&gt;cpio&lt;/code&gt;</title>
      <link>https://f2cfe404.karltarvascom.pages.dev/macos-bsdcpio-vs-gnu-cpio/</link>
      <guid>https://f2cfe404.karltarvascom.pages.dev/macos-bsdcpio-vs-gnu-cpio/</guid>
      <pubDate>Tue, 06 Oct 2020 00:00:00 &#43;0000</pubDate>
      <description>&lt;p&gt;MacOS ships with &lt;a href=&#34;https://ss64.com/osx/cpio.html&#34;&gt;&lt;code&gt;cpio&lt;/code&gt;&lt;/a&gt; out of the box, however it&amp;rsquo;s worth noting it&amp;rsquo;s &lt;code&gt;bsdcpio&lt;/code&gt;, not the &lt;a href=&#34;https://www.gnu.org/software/cpio/&#34;&gt;GNU &lt;code&gt;cpio&lt;/code&gt;&lt;/a&gt;.&lt;br&gt;&#xA;While &lt;em&gt;most&lt;/em&gt; of the functionality is identical, the set of available flags is inconsistent between the two.&lt;/p&gt;&#xA;&lt;p&gt;If you need GNU &lt;code&gt;cpio&lt;/code&gt; on macOS, you can install it via &lt;a href=&#34;https://brew.sh/&#34;&gt;Homebrew&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;$ brew install cpio&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;You&amp;rsquo;ll need to add it to your &lt;code&gt;$PATH&lt;/code&gt; in &lt;code&gt;.bashrc&lt;/code&gt; or similar to use it:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-gdscript3&#34; data-lang=&#34;gdscript3&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;export&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;PATH&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;/usr/local/opt/cpio/bin:$PATH&amp;#34;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Since this shadows a system binary, Homebrew won&amp;rsquo;t let you simply &lt;code&gt;brew link&lt;/code&gt; it.&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>Bash: Pipe command output to stdout and file</title>
      <link>https://f2cfe404.karltarvascom.pages.dev/bash-pipe-command-output-to-stdout-and-file/</link>
      <guid>https://f2cfe404.karltarvascom.pages.dev/bash-pipe-command-output-to-stdout-and-file/</guid>
      <pubDate>Tue, 06 Oct 2020 00:00:00 &#43;0000</pubDate>
      <description>&lt;p&gt;If you need both &lt;code&gt;stdout&lt;/code&gt; and &lt;code&gt;stderr&lt;/code&gt; in a file for logging or debugging purposes, while also wanting to monitor the output of a command, you can use a &lt;a href=&#34;https://www.gnu.org/savannah-checkouts/gnu/bash/manual/bash.html#Pipelines&#34;&gt;pipe control operator&lt;/a&gt; along with &lt;code&gt;tee&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-fallback&#34; data-lang=&#34;fallback&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;$ foo |&amp;amp; tee out.log&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</description>
    </item>
    
    <item>
      <title>VBoxManage: Start and stop headless VMs</title>
      <link>https://f2cfe404.karltarvascom.pages.dev/vboxmanage-start-and-stop-headless-vms/</link>
      <guid>https://f2cfe404.karltarvascom.pages.dev/vboxmanage-start-and-stop-headless-vms/</guid>
      <pubDate>Wed, 30 Sep 2020 00:00:00 &#43;0000</pubDate>
      <description>&lt;p&gt;Start a virtual machine in headless mode:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;$ VBoxManage startvm &amp;lt;VM name or GUID&amp;gt; --type headless&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Save the machine state and then stop it:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;VBoxManage controlvm &amp;lt;VM name or GUID&amp;gt; savestate&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;See &lt;a href=&#34;https://www.virtualbox.org/manual/ch08.html&#34;&gt;the &lt;code&gt;VBoxManage&lt;/code&gt; manual&lt;/a&gt; for more examples.&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>Echo into a file with root permissions</title>
      <link>https://f2cfe404.karltarvascom.pages.dev/echo-into-a-file-with-root-permissions/</link>
      <guid>https://f2cfe404.karltarvascom.pages.dev/echo-into-a-file-with-root-permissions/</guid>
      <pubDate>Wed, 30 Sep 2020 00:00:00 &#43;0000</pubDate>
      <description>&lt;p&gt;Simply prepending &lt;code&gt;sudo&lt;/code&gt; to &lt;code&gt;echo&lt;/code&gt; will fail since the redirection is executed by the shell, not the command you run.&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;$ sudo &lt;span class=&#34;nb&#34;&gt;echo&lt;/span&gt; &lt;span class=&#34;s2&#34;&gt;&amp;#34;foo&amp;#34;&lt;/span&gt; &amp;gt;&amp;gt; /etc/bar&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;bash: /etc/bar: Permission denied&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Shortly, the above is running &lt;code&gt;echo&lt;/code&gt; as root, but &lt;code&gt;&amp;gt;&amp;gt;&lt;/code&gt; will be run by the surrounding shell.&lt;br&gt;&#xA;To overcome this, &lt;a href=&#34;https://unix.stackexchange.com/a/4337/22607&#34;&gt;you can use &lt;code&gt;tee&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;$ &lt;span class=&#34;nb&#34;&gt;echo&lt;/span&gt; &lt;span class=&#34;s2&#34;&gt;&amp;#34;foo&amp;#34;&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;|&lt;/span&gt; sudo tee -a /etc/bar/&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;To overwrite the file, rather than append to it, omit &lt;code&gt;-a&lt;/code&gt;.&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>macOS Catalina: VirtualBox crashes on Linux VM boot</title>
      <link>https://f2cfe404.karltarvascom.pages.dev/macos-catalina-virtualbox-crashes-on-linux-vm-boot/</link>
      <guid>https://f2cfe404.karltarvascom.pages.dev/macos-catalina-virtualbox-crashes-on-linux-vm-boot/</guid>
      <pubDate>Thu, 24 Sep 2020 00:00:00 &#43;0000</pubDate>
      <description>&lt;p&gt;Whether you&amp;rsquo;re setting up a fresh Linux VM in &lt;a href=&#34;https://www.virtualbox.org/&#34;&gt;VirtualBox&lt;/a&gt; on macOS Catalina (10.15.6), or migrating a VM over from an older macOS version, you can be in for a nasty surprise — once the VM boots, VirtualBox crashes with a mere stack trace.&lt;br&gt;&#xA;Personally I tested this with openSUSE, but since there&amp;rsquo;s &lt;a href=&#34;https://unix.stackexchange.com/q/609077/22607&#34;&gt;similar reports from Ubuntu&lt;/a&gt;, this seems a fairly common problem.&lt;/p&gt;&#xA;&lt;p&gt;The error and the stack trace will look something along these lines:&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>Git: Revert file to master</title>
      <link>https://f2cfe404.karltarvascom.pages.dev/git-revert-file-to-master/</link>
      <guid>https://f2cfe404.karltarvascom.pages.dev/git-revert-file-to-master/</guid>
      <pubDate>Fri, 18 Sep 2020 00:00:00 &#43;0000</pubDate>
      <description>&lt;p&gt;The same approach applies to any branch, but reverting a file to its state in master seems to come up most often.&lt;br&gt;&#xA;Firstly, in case you need to list which files have changed between your active branch and master:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;git diff --name-status master&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Then to revert the file to its state in master:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;git checkout master path/to/file&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;At this point, the file will already be staged, so if you need to unstage it:&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>macOS: Run script on startup</title>
      <link>https://f2cfe404.karltarvascom.pages.dev/macos-run-script-on-startup/</link>
      <guid>https://f2cfe404.karltarvascom.pages.dev/macos-run-script-on-startup/</guid>
      <pubDate>Fri, 11 Sep 2020 00:00:00 &#43;0000</pubDate>
      <description>&lt;p&gt;MacOS uses &lt;a href=&#34;https://developer.apple.com/library/archive/documentation/MacOSX/Conceptual/BPSystemStartup/Chapters/CreatingLaunchdJobs.html&#34;&gt;&lt;code&gt;launchd&lt;/code&gt;&lt;/a&gt; as the daemon for running services and other daemons.&lt;/p&gt;&#xA;&lt;p&gt;To run a script or a few on startup, you can interface with &lt;code&gt;launchd&lt;/code&gt; by &lt;a href=&#34;https://superuser.com/a/229792/162197&#34;&gt;writing a corresponding plist file&lt;/a&gt;. In my case, I want to run &lt;code&gt;networksetup&lt;/code&gt; to connect to a specific VPN on startup, but to only run it once so that I can switch to other ones later.&lt;/p&gt;&#xA;&lt;p&gt;Essentially, whenever my computer starts up, I want to run&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>Git: Autosign commits</title>
      <link>https://f2cfe404.karltarvascom.pages.dev/git-autosign-commits/</link>
      <guid>https://f2cfe404.karltarvascom.pages.dev/git-autosign-commits/</guid>
      <pubDate>Wed, 09 Sep 2020 00:00:00 &#43;0000</pubDate>
      <description>&lt;p&gt;After &lt;a href=&#34;https://docs.github.com/en/github/authenticating-to-github/generating-a-new-gpg-key&#34;&gt;generating a GPG key&lt;/a&gt; and &lt;a href=&#34;https://docs.github.com/en/github/authenticating-to-github/adding-a-new-gpg-key-to-your-github-account&#34;&gt;adding it to your Github account&lt;/a&gt;, automatically signing your commits is very straightforward.&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;First, &lt;a href=&#34;https://docs.github.com/en/github/authenticating-to-github/telling-git-about-your-signing-key&#34;&gt;find your key ID&lt;/a&gt; via&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;gpg --list-secret-keys --keyid-format LONG&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;ol start=&#34;2&#34;&gt;&#xA;&lt;li&gt;Then, configure Git use the said key globally&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;git config --global user.signingkey KEY_ID&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;ol start=&#34;3&#34;&gt;&#xA;&lt;li&gt;Check that &lt;code&gt;user.email&lt;/code&gt; matches the one in your GPG key, and to be nice, &lt;code&gt;user.name&lt;/code&gt; matches your Github username in &lt;code&gt;git config --global --list&lt;/code&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Finally, tell Git to sign all commits with the above credentials&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;git config --global commit.gpgsign &lt;span class=&#34;nb&#34;&gt;true&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;style&gt;&#xA;#verified-badge {&#xA;    color: #22863a;&#xA;    padding: 0 7px;&#xA;    font-size: 0.8em;&#xA;    font-weight: 500;&#xA;    line-height: 18px;&#xA;    border-radius: 2em;&#xA;    border: 1px solid #e1e4e8;&#xA;    text-decoration: none;&#xA;}&#xA;&lt;/style&gt;&#xA;&lt;p&gt;Following the above, all of your commits should show a nice &lt;span id=&#34;verified-badge&#34;&gt;Verified&lt;/span&gt; badge next to them.&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>macOS: Switching between OpenVPN and NextDNS automatically</title>
      <link>https://f2cfe404.karltarvascom.pages.dev/macos-switching-between-openvpn-and-nextdns-automatically/</link>
      <guid>https://f2cfe404.karltarvascom.pages.dev/macos-switching-between-openvpn-and-nextdns-automatically/</guid>
      <pubDate>Tue, 08 Sep 2020 00:00:00 &#43;0000</pubDate>
      <description>&lt;p&gt;Since macOS doesn&amp;rsquo;t support OpenVPN out of the box, the easiest solution is to use &lt;a href=&#34;https://tunnelblick.net/czQuick.html&#34;&gt;Tunnelblick&lt;/a&gt; as your client. Alternatively, there&amp;rsquo;s CLI builds for OpenVPN available on &lt;a href=&#34;https://brew.sh/&#34;&gt;Homebrew&lt;/a&gt; as well.&lt;/p&gt;&#xA;&lt;p&gt;Regardless of your client of choice though, OpenVPN and &lt;a href=&#34;https://nextdns.io/&#34;&gt;NextDNS&lt;/a&gt; don&amp;rsquo;t play well together without a little help. A generic setup that supports both is as follows:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Install the NextDNS client as usual. This will add a DNS configuration called &lt;code&gt;NextDNS&lt;/code&gt; under System Preferences → Network.&lt;/li&gt;&#xA;&lt;li&gt;After the initial setup is done, quit the NextDNS application, as it will try to automatically reconnect otherwise.&lt;/li&gt;&#xA;&lt;li&gt;Install Tunnelblick as usual, along with any VPN configurations you need.&lt;/li&gt;&#xA;&lt;li&gt;Navigate to &lt;code&gt;~/Library/Application\ Support/Tunnelblick/Configurations/CONFIGURATION_NAME.tblk/Contents/Resources/&lt;/code&gt; where &lt;code&gt;CONFIGURATION_NAME&lt;/code&gt; is the VPN configuration you want to use.&lt;/li&gt;&#xA;&lt;li&gt;Create &lt;code&gt;pre-connect.sh&lt;/code&gt; which will be called before your OpenVPN connection is established:&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;cp&#34;&gt;#!/usr/bin/env bash&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;cp&#34;&gt;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;# Disconnect from NextDNS before connecting to OpenVPN&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;networksetup -disconnectpppoeservice NextDNS&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;ul&gt;&#xA;&lt;li&gt;Create &lt;code&gt;post-disconnect.sh&lt;/code&gt; which will be called after you disconnect from OpenVPN:&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;cp&#34;&gt;#!/usr/bin/env bash&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;cp&#34;&gt;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;# Reconnect to NextDNS after disconnecting from OpenVPN&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;networksetup -connectpppoeservice NextDNS&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;With this setup, whenever you connect to a VPN using Tunnelblick, NextDNS will automatically be turned off. When you disconnect, NextDNS will be turned on again, allowing you to easily switch between the two.&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>App recommendation: Next Meeting</title>
      <link>https://f2cfe404.karltarvascom.pages.dev/next-meeting/</link>
      <guid>https://f2cfe404.karltarvascom.pages.dev/next-meeting/</guid>
      <pubDate>Thu, 30 Jul 2020 00:00:00 &#43;0000</pubDate>
      <description>&lt;p&gt;&lt;a href=&#34;https://apps.apple.com/us/app/next-meeting/id1017470484?mt=12&#34;&gt;Next Meeting&lt;/a&gt; is a handy macOS utilty that puts your next calendar event in the menubar.&lt;/p&gt;&#xA;&lt;img src=&#34;example.jpg&#34; alt=&#34;Screenshot of the application in the menubar&#34; width=&#34;321.5&#34; height=&#34;201&#34; /&gt;&#xA;&lt;p&gt;It uses native calendar integration so whatever you&amp;rsquo;ve already set up in the Calendar app will be available out of the box.&lt;/p&gt;&#xA;&lt;p&gt;For those looking for more customization, &lt;a href=&#34;https://getbitbar.com/&#34;&gt;BitBar&lt;/a&gt; is a good alternative, but for ease-of-use out of the box, Next Meeting is hard to beat.&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>Git: Keep file but ignore changes</title>
      <link>https://f2cfe404.karltarvascom.pages.dev/git-keep-file-but-ignore-changes/</link>
      <guid>https://f2cfe404.karltarvascom.pages.dev/git-keep-file-but-ignore-changes/</guid>
      <pubDate>Thu, 02 Jul 2020 00:00:00 &#43;0000</pubDate>
      <description>&lt;p&gt;Many repositories come with files that serve as templates, but shouldn&amp;rsquo;t actively be checked for changes. A good example of these is environment setup files, local config files etc.&lt;/p&gt;&#xA;&lt;p&gt;To conveniently keep this base file in the repository, add and commit its template state as you would with any other file. Once this is done, tell Git to not track any further changes in this file:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;git update-index --assume-unchanged local.env&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;To revert the configuration and track changes again:&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>CentOS 7: redirect port 80 to port 8080</title>
      <link>https://f2cfe404.karltarvascom.pages.dev/centos-7-redirect-port-80-to-8080/</link>
      <guid>https://f2cfe404.karltarvascom.pages.dev/centos-7-redirect-port-80-to-8080/</guid>
      <pubDate>Thu, 02 Jul 2020 00:00:00 &#43;0000</pubDate>
      <description>&lt;p&gt;CentOS 7 uses &lt;a href=&#34;https://firewalld.org/&#34;&gt;firewalld&lt;/a&gt; to manage ports, firewall rules and more. To quickly get up and running, firstly list all currently existing rules:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;firewall-cmd --list-all&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The output will be something similar to this, depending on what services you have running.&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;public &lt;span class=&#34;o&#34;&gt;(&lt;/span&gt;active&lt;span class=&#34;o&#34;&gt;)&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;  target: default&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;  icmp-block-inversion: no&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;  interfaces: ens160&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;  sources:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;  services: ssh dhcpv6-client&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;  ports:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;  protocols:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;  masquerade: no&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;  forward-ports:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;  source-ports:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;  icmp-blocks:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;  rich rules:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;If you simply want to open a port, use &lt;code&gt;--add-port&lt;/code&gt; (and later &lt;code&gt;--remove-port&lt;/code&gt; to revert the change if need be).&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>Vue CLI: Debugging Jest unit tests with Chrome Node devtools</title>
      <link>https://f2cfe404.karltarvascom.pages.dev/vue-cli-debugging-jest-unit-tests-with-chrome-node-devtools/</link>
      <guid>https://f2cfe404.karltarvascom.pages.dev/vue-cli-debugging-jest-unit-tests-with-chrome-node-devtools/</guid>
      <pubDate>Tue, 16 Jun 2020 00:00:00 &#43;0000</pubDate>
      <description>&lt;p&gt;Jest documentation has a great guide on &lt;a href=&#34;https://jestjs.io/docs/en/troubleshooting#tests-are-failing-and-you-dont-know-why&#34;&gt;debugging failing tests&lt;/a&gt;. With minor modifications, the same approach can be used to debug tests that are wrapped by Vue CLI.&lt;/p&gt;&#xA;&lt;p&gt;Given you already have the standard test scripts in your &lt;code&gt;package.json&lt;/code&gt;, we can add a separate script to run the same task in debugging mode:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-json&#34; data-lang=&#34;json&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;  &lt;span class=&#34;nt&#34;&gt;&amp;#34;scripts&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;nt&#34;&gt;&amp;#34;test:unit&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt; &lt;span class=&#34;s2&#34;&gt;&amp;#34;vue-cli-service test:unit&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;nt&#34;&gt;&amp;#34;test:debug&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt; &lt;span class=&#34;s2&#34;&gt;&amp;#34;node --inspect-brk node_modules/.bin/vue-cli-service test:unit --runInBand --watchAll&amp;#34;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;  &lt;span class=&#34;p&#34;&gt;}&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;p&#34;&gt;}&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Since this is a fair mouthful, let&amp;rsquo;s cover the steps in isolation:&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>Vetur: Using workspace snippets</title>
      <link>https://f2cfe404.karltarvascom.pages.dev/vetur-using-workspace-snippets/</link>
      <guid>https://f2cfe404.karltarvascom.pages.dev/vetur-using-workspace-snippets/</guid>
      <pubDate>Tue, 09 Jun 2020 00:00:00 &#43;0000</pubDate>
      <description>&lt;p&gt;&lt;a href=&#34;https://github.com/vuejs/vetur&#34;&gt;Vetur&lt;/a&gt; is a Visual Studio Code extension that adds support for &lt;a href=&#34;https://vuejs.org/v2/guide/single-file-components.html&#34;&gt;&lt;code&gt;.vue&lt;/code&gt; files&lt;/a&gt; as well as many other tools for working with Vue.&lt;/p&gt;&#xA;&lt;p&gt;One of those is additional built-in snippets, where &lt;code&gt;CTRL``SPACE&lt;/code&gt; brings up suggestions for file scaffolding with different kinds of templates.&lt;/p&gt;&#xA;&lt;p&gt;To add project-specific templates, create the folder &lt;code&gt;.vscode/vetur/snippets&lt;/code&gt; in your project root.&lt;/p&gt;&#xA;&lt;p&gt;Adding the file &lt;code&gt;default.vue&lt;/code&gt; in that folder will allow you to create a default template that&amp;rsquo;s suggested for &lt;code&gt;.vue&lt;/code&gt; files:&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>&lt;code&gt;ts-node-dev&lt;/code&gt; binds to stdin via readline by default</title>
      <link>https://f2cfe404.karltarvascom.pages.dev/ts-node-dev-binds-to-stdin-via-readline-by-default/</link>
      <guid>https://f2cfe404.karltarvascom.pages.dev/ts-node-dev-binds-to-stdin-via-readline-by-default/</guid>
      <pubDate>Sun, 31 May 2020 00:00:00 &#43;0000</pubDate>
      <description>&lt;p&gt;&lt;strong&gt;Update, &lt;time&gt;{{ &amp;ldquo;2020-06-15&amp;rdquo; | date_to_long_string: &amp;ldquo;ordinal&amp;rdquo; }}&lt;/time&gt;&lt;/strong&gt;&lt;br&gt;&#xA;This issue has been fixed in &lt;a href=&#34;https://github.com/whitecolor/ts-node-dev/commit/fbe1eaf657277bc4026ad4949350a286ebfe8b2a&#34;&gt;&lt;code&gt;fbe1eaf&lt;/code&gt;&lt;/a&gt; and should reach NPM fairly soon as well. The original post is preserved below for historical context.&lt;/p&gt;&#xA;&lt;hr&gt;&#xA;&lt;p&gt;&lt;a href=&#34;https://github.com/whitecolor/ts-node-dev&#34;&gt;&lt;code&gt;ts-node-dev&lt;/code&gt;&lt;/a&gt; is a handy drop in replacement for &lt;code&gt;node-dev&lt;/code&gt; that adds Typescript support.&lt;br&gt;&#xA;However, somewhat unexpectedly it &lt;a href=&#34;https://github.com/whitecolor/ts-node-dev/issues/147&#34;&gt;binds to stdin&lt;/a&gt; by default out of the box:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-ts&#34; data-lang=&#34;ts&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;// Read for &amp;#34;rs&amp;#34; from command line  &#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;&lt;/span&gt;&lt;span class=&#34;k&#34;&gt;if&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;opts&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;rs&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;!==&lt;/span&gt; &lt;span class=&#34;kc&#34;&gt;false&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;  &lt;span class=&#34;kr&#34;&gt;const&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;rl&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;readline&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;createInterface&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;({&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;nx&#34;&gt;input&lt;/span&gt;: &lt;span class=&#34;kt&#34;&gt;process.stdin&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;nx&#34;&gt;output&lt;/span&gt;: &lt;span class=&#34;kt&#34;&gt;process.stdout&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;nx&#34;&gt;terminal&lt;/span&gt;: &lt;span class=&#34;kt&#34;&gt;false&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;  &lt;span class=&#34;p&#34;&gt;})&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;  &lt;span class=&#34;nx&#34;&gt;rl&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;on&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s1&#34;&gt;&amp;#39;line&amp;#39;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;...);&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;p&#34;&gt;}&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The binding is used to restart the server on demand, as opposed to restarting automatically on changes. While this can be handy, the behavior is currently undocumented and not an intuitive default.&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>Typescript: Async user-defined typeguards</title>
      <link>https://f2cfe404.karltarvascom.pages.dev/typescript-async-user-defined-typeguards/</link>
      <guid>https://f2cfe404.karltarvascom.pages.dev/typescript-async-user-defined-typeguards/</guid>
      <pubDate>Tue, 19 May 2020 00:00:00 &#43;0000</pubDate>
      <description>&lt;p&gt;&lt;a href=&#34;https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guards&#34;&gt;User-defined typeguards&lt;/a&gt; are a handy tool for covering any shortcomings in automatic type inferring in Typescript. Sadly, async typeguards are &lt;a href=&#34;https://github.com/microsoft/TypeScript/issues/37681&#34;&gt;currently not supported&lt;/a&gt; out of the box.&lt;/p&gt;&#xA;&lt;p&gt;Until it gets added to the engine, a straightforward workaround is to return unchanged input data with manually annotated types from the typeguard function.&lt;/p&gt;&#xA;&lt;p&gt;For example, when validating unknown input against a &lt;a href=&#34;https://github.com/jquense/yup&#34;&gt;Yup&lt;/a&gt; schema:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-ts&#34; data-lang=&#34;ts&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kr&#34;&gt;export&lt;/span&gt; &lt;span class=&#34;kr&#34;&gt;async&lt;/span&gt; &lt;span class=&#34;kd&#34;&gt;function&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;validateWithSchema&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&#34;nt&#34;&gt;T&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;na&#34;&gt;K&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;&amp;gt;(&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;data&lt;/span&gt;: &lt;span class=&#34;kt&#34;&gt;T&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;schema&lt;/span&gt;: &lt;span class=&#34;kt&#34;&gt;yup.Schema&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&#34;nt&#34;&gt;K&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;&amp;gt;)&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;  &lt;span class=&#34;c1&#34;&gt;// `schema.validate()` will throw on invalid input&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;&lt;/span&gt;  &lt;span class=&#34;k&#34;&gt;await&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;schema&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;validate&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;data&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;  &lt;span class=&#34;k&#34;&gt;return&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;data&lt;/span&gt; &lt;span class=&#34;kr&#34;&gt;as&lt;/span&gt; &lt;span class=&#34;kt&#34;&gt;unknown&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt; &lt;span class=&#34;kr&#34;&gt;as&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;K&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;p&#34;&gt;}&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-ts&#34; data-lang=&#34;ts&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kr&#34;&gt;const&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;typedData&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;await&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;validateWithSchema&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;unknownInput&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;schema&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;From there on, &lt;code&gt;typedData&lt;/code&gt; will have full type coverage from the schema definition, no manual interface writing necessary.&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>Adding Vuepress to a Vue CLI project with Typescript</title>
      <link>https://f2cfe404.karltarvascom.pages.dev/adding-vuepress-to-a-vue-cli-project-with-typescript/</link>
      <guid>https://f2cfe404.karltarvascom.pages.dev/adding-vuepress-to-a-vue-cli-project-with-typescript/</guid>
      <pubDate>Tue, 12 May 2020 00:00:00 &#43;0000</pubDate>
      <description>&lt;p&gt;&lt;a href=&#34;https://vuepress.vuejs.org/&#34;&gt;Vuepress&lt;/a&gt; is one of the most commonly used documentation frameworks in the Vue ecosystem. Adding it to an already existing &lt;a href=&#34;https://cli.vuejs.org/&#34;&gt;Vue CLI&lt;/a&gt; based project that uses Typescript isn&amp;rsquo;t entirely trivial though.&lt;/p&gt;&#xA;&lt;p&gt;The 7 steps below will get you up and running.&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;If you don&amp;rsquo;t have a project yet, &lt;a href=&#34;https://cli.vuejs.org/guide/creating-a-project.html&#34;&gt;create a new project with Vue CLI&lt;/a&gt;. Be sure to pick Typescript in the setup steps.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;Install Vuepress, its &lt;a href=&#34;https://vuepress.github.io/en/plugins/typescript/&#34;&gt;Typescript plugin&lt;/a&gt; and the related type definitions:&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>Typescript optional chaining and ESLint `no-unused-expressions`</title>
      <link>https://f2cfe404.karltarvascom.pages.dev/typescript-no-unused-expressions/</link>
      <guid>https://f2cfe404.karltarvascom.pages.dev/typescript-no-unused-expressions/</guid>
      <pubDate>Tue, 07 Apr 2020 00:00:00 &#43;0000</pubDate>
      <description>&lt;p&gt;Typescript 3.7 introduced the long awaited &lt;a href=&#34;https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-7.html#optional-chaining&#34;&gt;optional chaining&lt;/a&gt; syntax.&lt;/p&gt;&#xA;&lt;p&gt;The short gist is that this&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-ts&#34; data-lang=&#34;ts&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kr&#34;&gt;const&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;foo&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;bar&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;bar&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;tea&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;bar&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;tea&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;cup&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;can now simply be&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-ts&#34; data-lang=&#34;ts&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kr&#34;&gt;const&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;foo&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;bar&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;?&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;tea&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;?&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;cup&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;When using the commonly enabled ESLint rule &lt;code&gt;no-unused-expressions&lt;/code&gt;, however, this can lead to false positives:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-ts&#34; data-lang=&#34;ts&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;   &lt;span class=&#34;nx&#34;&gt;foo&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;?&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;bar&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;();&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;// ^^^^^^^^^^&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;// Expected an assignment or function call and instead saw an expression. eslint(no-unused-expressions)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Luckily, Typescript releases enhanced ESLint rules under &lt;a href=&#34;https://github.com/typescript-eslint/typescript-eslint&#34;&gt;&lt;code&gt;@typescript-eslint&lt;/code&gt;&lt;/a&gt;. To use the TS version of the same rule, turn the original one off, and enable the extended one in your &lt;code&gt;.eslintrc&lt;/code&gt;:&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>Jest: TypeError: Cannot read property &#39;default&#39; of undefined</title>
      <link>https://f2cfe404.karltarvascom.pages.dev/jest-type-error-cannot-read-property-default-of-undefined/</link>
      <guid>https://f2cfe404.karltarvascom.pages.dev/jest-type-error-cannot-read-property-default-of-undefined/</guid>
      <pubDate>Thu, 19 Mar 2020 00:00:00 &#43;0000</pubDate>
      <description>&lt;p&gt;Vue CLI bundles &lt;a href=&#34;https://jestjs.io/&#34;&gt;Jest&lt;/a&gt; as its default test runner. All is fine and good until one day, running your unit tests you get the following trace:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;TypeError: Cannot &lt;span class=&#34;nb&#34;&gt;read&lt;/span&gt; property &lt;span class=&#34;s1&#34;&gt;&amp;#39;default&amp;#39;&lt;/span&gt; of undefined&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    at Object.get &lt;span class=&#34;o&#34;&gt;[&lt;/span&gt;as TextInput&lt;span class=&#34;o&#34;&gt;]&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;(&lt;/span&gt;src/components/IO/index.ts&lt;span class=&#34;o&#34;&gt;)&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    at src/components/dataTable/Editor.vue&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    at &lt;span class=&#34;o&#34;&gt;[&lt;/span&gt;lots of omitted frames&lt;span class=&#34;o&#34;&gt;]&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    at Object.&amp;lt;anonymous&amp;gt; &lt;span class=&#34;o&#34;&gt;(&lt;/span&gt;src/store/index.spec.ts&lt;span class=&#34;o&#34;&gt;)&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Even though the project builds just fine in both development and production mode.&lt;/p&gt;&#xA;&lt;p&gt;This usually stems from cyclic dependencies. At my best guess, it seems Jest has some arbitrary memory limit and it runs out at some point, because the breaking code isn&amp;rsquo;t directly related to any recent changes in the codebase. Adding one import in one barrel will cause another one somewhere down the line to run out of Jest&amp;rsquo;s manageable size and you&amp;rsquo;ll get a fun afternoon of debugging.&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>Yup: Type &#39;StringSchema&amp;lt;string&amp;gt;&#39; is not assignable to type &#39;Ref | Schema&amp;lt;Sample&amp;gt;&#39;.</title>
      <link>https://f2cfe404.karltarvascom.pages.dev/yup-type-stringschema-is-not-assignable/</link>
      <guid>https://f2cfe404.karltarvascom.pages.dev/yup-type-stringschema-is-not-assignable/</guid>
      <pubDate>Fri, 10 Jan 2020 00:00:00 &#43;0000</pubDate>
      <description>&lt;p&gt;In Yup, using &lt;a href=&#34;https://www.typescriptlang.org/docs/handbook/advanced-types.html#string-literal-types&#34;&gt;Typescript string literals&lt;/a&gt; in a shape definition will currently give a generic error message:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;Type &lt;span class=&#34;s1&#34;&gt;&amp;#39;StringSchema&amp;lt;string&amp;gt;&amp;#39;&lt;/span&gt; is not assignable to &lt;span class=&#34;nb&#34;&gt;type&lt;/span&gt; &lt;span class=&#34;s1&#34;&gt;&amp;#39;Ref | Schema&amp;lt;Sample&amp;gt;&amp;#39;&lt;/span&gt;.&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;For example, trying to use the following interface will produce the above error:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-ts&#34; data-lang=&#34;ts&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kr&#34;&gt;interface&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;Sample&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;  &lt;span class=&#34;nx&#34;&gt;allowed&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;:&lt;/span&gt; &lt;span class=&#34;s1&#34;&gt;&amp;#39;foo&amp;#39;&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;|&lt;/span&gt; &lt;span class=&#34;s1&#34;&gt;&amp;#39;bar&amp;#39;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;p&#34;&gt;};&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kr&#34;&gt;const&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;shape&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;yup&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;object&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;().&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;shape&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&#34;nt&#34;&gt;Sample&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;&amp;gt;({&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;  &lt;span class=&#34;nx&#34;&gt;allowed&lt;/span&gt;: &lt;span class=&#34;kt&#34;&gt;yup.string&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;().&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;required&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(),&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;p&#34;&gt;});&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Yup&amp;rsquo;s typing &lt;a href=&#34;https://github.com/jquense/yup/issues/605&#34;&gt;doesn&amp;rsquo;t currently support this&lt;/a&gt;, until then, a &lt;a href=&#34;https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-8.html#conditional-types&#34;&gt;conditional utility type&lt;/a&gt; can solve the issue:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-ts&#34; data-lang=&#34;ts&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kr&#34;&gt;type&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;YupShape&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&#34;nt&#34;&gt;T&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;  &lt;span class=&#34;p&#34;&gt;[&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;K&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;in&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;keyof&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;T&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;]&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;:&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;T&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;[&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;K&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;]&lt;/span&gt; &lt;span class=&#34;kr&#34;&gt;extends&lt;/span&gt; &lt;span class=&#34;kt&#34;&gt;string&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;?&lt;/span&gt; &lt;span class=&#34;kt&#34;&gt;string&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;:&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;T&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;[&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;K&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;];&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;p&#34;&gt;}&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kr&#34;&gt;const&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;shape&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;yup&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;object&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;().&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;shape&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&#34;nt&#34;&gt;YupShape&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&#34;nt&#34;&gt;Sample&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;&amp;gt;&amp;gt;(...);&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;You will lose type checking for the literal values, but keep your sanity until it gets fixed upstream.&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>Jekyll: escape HTML in titles</title>
      <link>https://f2cfe404.karltarvascom.pages.dev/jekyll-escape-html-in-titles/</link>
      <guid>https://f2cfe404.karltarvascom.pages.dev/jekyll-escape-html-in-titles/</guid>
      <pubDate>Mon, 23 Dec 2019 00:00:00 &#43;0000</pubDate>
      <description>&lt;p&gt;At times, you&amp;rsquo;ll have posts which don&amp;rsquo;t have pure text titles. Luckily, Jekyll supports a &lt;a href=&#34;https://jekyllrb.com/docs/liquid/filters/&#34;&gt;handy selection of custom filters&lt;/a&gt; along with &lt;a href=&#34;https://shopify.github.io/liquid/filters/&#34;&gt;all Liquid filters&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The &lt;a href=&#34;https://shopify.github.io/liquid/filters/strip_html/&#34;&gt;&lt;code&gt;strip_html&lt;/code&gt;&lt;/a&gt; filter is great for Jekyll layouts:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-html&#34; data-lang=&#34;html&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;{% raw %}{{ page.title | strip_html }}{% endraw %}&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;As an additional note, if you need to escape Jekyll snippets in code blocks as above, you can use &lt;code&gt;{% raw %}{% raw %}{% {% endraw %}endraw %}&lt;/code&gt; to embed your content.&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>To be a good software engineer, become a French skeptic</title>
      <link>https://f2cfe404.karltarvascom.pages.dev/to-be-a-good-software-engineer/</link>
      <guid>https://f2cfe404.karltarvascom.pages.dev/to-be-a-good-software-engineer/</guid>
      <pubDate>Wed, 18 Dec 2019 00:00:00 &#43;0000</pubDate>
      <description>&lt;p&gt;Either that, or a skeptical Frenchie — allow me to explain.&lt;/p&gt;&#xA;&lt;p&gt;The French have long learned that &lt;a href=&#34;http://www.bbc.com/travel/story/20190804-why-the-french-love-to-say-no&#34;&gt;saying &amp;ldquo;no&amp;rdquo; is great&lt;/a&gt;. You can always say &lt;em&gt;&amp;ldquo;non&amp;rdquo;&lt;/em&gt; upon &lt;em&gt;&amp;ldquo;non&amp;rdquo;&lt;/em&gt;, and then, after further discussion, finally settle on a &amp;ldquo;yes&amp;rdquo; if you&amp;rsquo;re happy with the outcome. However, if you start with &amp;ldquo;yes&amp;rdquo;, the discussion is essentially over and you&amp;rsquo;re on the hook, regardless of whether you amend minor details. A reasonable default, both in development and in life in general, is to lead with a &amp;ldquo;no&amp;rdquo; and then see where you can go from there.&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>There is no open source social contract</title>
      <link>https://f2cfe404.karltarvascom.pages.dev/there-is-no-open-source-social-contract/</link>
      <guid>https://f2cfe404.karltarvascom.pages.dev/there-is-no-open-source-social-contract/</guid>
      <pubDate>Thu, 21 Nov 2019 00:00:00 &#43;0000</pubDate>
      <description>&lt;p&gt;As someone who maintains and tends to a number of &lt;abbr title=&#34;open source software&#34;&gt;OSS&lt;/abbr&gt; projects, there&amp;rsquo;s a misconception I&amp;rsquo;d like to address: the open source social contract. The sometimes implied agreement that once you put something out there, you&amp;rsquo;re responsible for it: maintaining it, supporting it, whatever.&lt;/p&gt;&#xA;&lt;p&gt;This is false.&lt;/p&gt;&#xA;&lt;p&gt;There is no social contract.&lt;/p&gt;&#xA;&lt;p&gt;There are many people who will ask you to do free work for them — implement features, review PRs, discuss tickets — and asking is fine. But there is no implicit expectation that it would be the Right Thing for you to do work for them, free of charge.&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>&lt;code&gt;@aspnet/signalr&lt;/code&gt; vs &lt;code&gt;@microsoft/signalr&lt;/code&gt;</title>
      <link>https://f2cfe404.karltarvascom.pages.dev/aspnet-signalr-vs-microsoft-signalr/</link>
      <guid>https://f2cfe404.karltarvascom.pages.dev/aspnet-signalr-vs-microsoft-signalr/</guid>
      <pubDate>Tue, 05 Nov 2019 00:00:00 &#43;0000</pubDate>
      <description>&lt;p&gt;The &lt;code&gt;@aspnet/signalr&lt;/code&gt; NPM package was recently moved to the more widely recognizable &lt;code&gt;@microsoft/signalr&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;For those who missed it, the version history of the packages sheds light on the situation. Here&amp;rsquo;s a few recent releases for &lt;code&gt;@microsoft/signalr&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;3.0.0 - a month ago&lt;/li&gt;&#xA;&lt;li&gt;3.0.0-rc1.19457.4 - 2 months ago&lt;/li&gt;&#xA;&lt;li&gt;3.0.0-preview7.19365.7 - 3 months ago&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;And here&amp;rsquo;s &lt;code&gt;@aspnet/signalr&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;3.0.0-preview6.19307.2 - 5 months ago&lt;/li&gt;&#xA;&lt;li&gt;3.0.0-preview5-19227-01 - 6 months ago&lt;/li&gt;&#xA;&lt;li&gt;3.0.0-preview4-19216-03 - 7 months ago&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Looking at the timeline makes the switch easy to see, but it&amp;rsquo;s easy to miss given &lt;a href=&#34;https://github.com/aspnet/Announcements/issues/372&#34;&gt;the official announcement&lt;/a&gt; was just a Github issue ticket.&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>Git LFS fetch stuck on 0B</title>
      <link>https://f2cfe404.karltarvascom.pages.dev/git-lfs-fetch-stuck-on-0b/</link>
      <guid>https://f2cfe404.karltarvascom.pages.dev/git-lfs-fetch-stuck-on-0b/</guid>
      <pubDate>Tue, 29 Oct 2019 00:00:00 &#43;0000</pubDate>
      <description>&lt;p&gt;When you&amp;rsquo;re running &lt;code&gt;git lfs fetch &amp;ndash;all&lt;/code&gt; you may be greeted with the following output:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;Fetching target&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;Git LFS: &lt;span class=&#34;o&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;m&#34;&gt;0&lt;/span&gt; of &lt;span class=&#34;m&#34;&gt;256&lt;/span&gt; files&lt;span class=&#34;o&#34;&gt;)&lt;/span&gt; &lt;span class=&#34;m&#34;&gt;0&lt;/span&gt; B / 512.00 MB    &#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Naively you get a coffee and wait for it to finish, only to soon realize it&amp;rsquo;s just stuck.&lt;br&gt;&#xA;Debug flags to the rescue:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;nb&#34;&gt;export&lt;/span&gt; &lt;span class=&#34;nv&#34;&gt;GIT_TRACE&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;m&#34;&gt;1&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Enabling git trace will allow you to see verbose debugging information which should soon reveal the issue.&lt;br&gt;&#xA;In my case the LFS wrapper wasn&amp;rsquo;t propmting for authentication correctly and was just stuck waiting for input.&lt;br&gt;&#xA;Running a regular fetch first and logging in resolved the issue:&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>Visual Studio Mac: manage user secrets</title>
      <link>https://f2cfe404.karltarvascom.pages.dev/visual-studio-mac-manage-user-secrets/</link>
      <guid>https://f2cfe404.karltarvascom.pages.dev/visual-studio-mac-manage-user-secrets/</guid>
      <pubDate>Mon, 28 Oct 2019 00:00:00 &#43;0000</pubDate>
      <description>&lt;p&gt;Somewhat surprisingly and inconveniently, &lt;strong&gt;Visual Studio for Mac&lt;/strong&gt; does not have the handy command &lt;code&gt;Manage User Secrets&lt;/code&gt;. It&amp;rsquo;s not hidden in a different menu, it&amp;rsquo;s simply not there.&lt;/p&gt;&#xA;&lt;p&gt;If you need to add a single secret to your project, you can use a one-liner in the project folder:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;nb&#34;&gt;cd&lt;/span&gt; repo/project&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;dotnet user-secrets &lt;span class=&#34;nb&#34;&gt;set&lt;/span&gt; &lt;span class=&#34;s2&#34;&gt;&amp;#34;ConnectionStrings:Project&amp;#34;&lt;/span&gt; &lt;span class=&#34;s2&#34;&gt;&amp;#34;Server=127.0.0.1&amp;#34;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;To add a number of secrets, save your secrets in a temporary &lt;code&gt;.json&lt;/code&gt; file:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-json&#34; data-lang=&#34;json&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;  &lt;span class=&#34;nt&#34;&gt;&amp;#34;ConnectionStrings&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;nt&#34;&gt;&amp;#34;Project&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt; &lt;span class=&#34;s2&#34;&gt;&amp;#34;Server=127.0.0.1&amp;#34;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;  &lt;span class=&#34;p&#34;&gt;}&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;p&#34;&gt;}&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Then navigate to the project folder in a terminal and use &lt;code&gt;dotnet&lt;/code&gt; to import the file:&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>macOS: GSSAPI operation failed on Nuget restore</title>
      <link>https://f2cfe404.karltarvascom.pages.dev/macos-restore-from-remote-nuget/</link>
      <guid>https://f2cfe404.karltarvascom.pages.dev/macos-restore-from-remote-nuget/</guid>
      <pubDate>Mon, 28 Oct 2019 00:00:00 &#43;0000</pubDate>
      <description>&lt;p&gt;When restoring packages from a remote on-prem Nuget repository on macOS, you may run into either one of the following error messages:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;GSSAPI operation failed with error - An unsupported mechanism was requested&#xA;&lt;/blockquote&gt;&#xA;&lt;blockquote&gt;&#xA;Unable to load the service index for source https://tfs.partner.com/DefaultCollection/_packaging/Nuget/nuget/v3/index.json&#xA;&lt;/blockquote&gt;&#xA;As covered in [this old, but unresolved ticket](https://github.com/Microsoft/artifacts-credprovider/issues/45), the problem usually stems from incorrect auth handling when downgrading the mode of authentication (e.g from Kerberos to Basic).  &#xA;&lt;p&gt;To work around the issue you need to:&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>Japt: Approximating arccosine</title>
      <link>https://f2cfe404.karltarvascom.pages.dev/japt-approximating-arccos/</link>
      <guid>https://f2cfe404.karltarvascom.pages.dev/japt-approximating-arccos/</guid>
      <pubDate>Tue, 10 Apr 2018 00:00:00 &#43;0000</pubDate>
      <description>&lt;p&gt;In most languages, trigonometric functions are a module shipped with the default language. In &lt;a href=&#34;https://github.com/ETHproductions/japt&#34;&gt;Japt&lt;/a&gt;, the Javascript-based code golfing language, that&amp;rsquo;s sadly not the case. There is no built-in for arcsine nor for arccosine.&lt;/p&gt;&#xA;&lt;p&gt;While you can embed Javascript in Japt, that would be what ever the opposite of Feng Shui is:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-txt&#34; data-lang=&#34;txt&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;$M.acos($U&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;$       $  // Evaluating as regular Javascript,&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt; M         // get the Japt built-in `M` which maps to Javascript&amp;#39;s `Math`&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;  .acos( U // and call `acos()` on it with the default input `U`.&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;It works, but it&amp;rsquo;s definitely not pretty.&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>Bootstrap: Change dropdown item background on hover</title>
      <link>https://f2cfe404.karltarvascom.pages.dev/bootstrap-change-dropdown-item-background-on-hover/</link>
      <guid>https://f2cfe404.karltarvascom.pages.dev/bootstrap-change-dropdown-item-background-on-hover/</guid>
      <pubDate>Wed, 14 Feb 2018 00:00:00 &#43;0000</pubDate>
      <description>&lt;p&gt;When trying to override the background color of a hovered submenu in Bootstrap you may be surprised to find that simply setting &lt;code&gt;background-color&lt;/code&gt; on the element doesn&amp;rsquo;t suffice.&lt;/p&gt;&#xA;&lt;p&gt;Bootstrap defines a background image for the elements to &lt;a href=&#34;https://github.com/twbs/bootstrap/issues/14381&#34;&gt;overcome some clashes&lt;/a&gt; in their media queries.&lt;br&gt;&#xA;To set a solid background color, remove the image and set a color as usual:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-css&#34; data-lang=&#34;css&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;nc&#34;&gt;dropdown-menu&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&#34;nt&#34;&gt;li&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&#34;nt&#34;&gt;a&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt;&lt;span class=&#34;nd&#34;&gt;hover&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;k&#34;&gt;background-image&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt; &lt;span class=&#34;kc&#34;&gt;none&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;k&#34;&gt;background-color&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt; &lt;span class=&#34;kc&#34;&gt;red&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;p&#34;&gt;}&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</description>
    </item>
    
    <item>
      <title>D3.js: Remove leading zero from time format</title>
      <link>https://f2cfe404.karltarvascom.pages.dev/d3js-remove-leading-zero-from-time-format/</link>
      <guid>https://f2cfe404.karltarvascom.pages.dev/d3js-remove-leading-zero-from-time-format/</guid>
      <pubDate>Fri, 22 Sep 2017 00:00:00 &#43;0000</pubDate>
      <description>&lt;p&gt;In D3.js, all time format directives are &lt;a href=&#34;https://github.com/d3/d3-time-format#locale_format&#34;&gt;zero-padded by default&lt;/a&gt; (except for &lt;code&gt;%e&lt;/code&gt; which explicitly uses space-padding).&lt;/p&gt;&#xA;&lt;p&gt;For example, using &lt;code&gt;d3.timeFormat(&amp;quot;%I:%M&amp;quot;)&lt;/code&gt; will output &lt;code&gt;09:34&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;To change the padding type, append a modifier to the directive&amp;rsquo;s &lt;code&gt;%&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;0&lt;/code&gt; to use zero-padding&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;_&lt;/code&gt; to use space-padding&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;-&lt;/code&gt; to disable padding altogether&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Following the above example, using &lt;code&gt;d3.timeFormat(&amp;quot;%-I:%M&amp;quot;)&lt;/code&gt; will yield &lt;code&gt;9:34&lt;/code&gt;.&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>Vuex: Passing multiple parameters to an action</title>
      <link>https://f2cfe404.karltarvascom.pages.dev/vuex-passing-multiple-parameters-to-an-action/</link>
      <guid>https://f2cfe404.karltarvascom.pages.dev/vuex-passing-multiple-parameters-to-an-action/</guid>
      <pubDate>Thu, 07 Sep 2017 00:00:00 &#43;0000</pubDate>
      <description>&lt;p&gt;&lt;a href=&#34;https://vuex.vuejs.org/guide/mutations.html&#34;&gt;Vuex mutations&lt;/a&gt; take up to two arguments: &lt;code&gt;state&lt;/code&gt; and &lt;code&gt;payload&lt;/code&gt;. The current state of the store is passed in by Vuex automatically as the first argument and the second argument holds any parameters you pass in.&lt;/p&gt;&#xA;&lt;p&gt;The easiest way to pass a number of parameters is to destruct them:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-ts&#34; data-lang=&#34;ts&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;nx&#34;&gt;mutations&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;:&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;  &lt;span class=&#34;nx&#34;&gt;authenticate&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;state&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;{&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;token&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;expiration&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;})&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;nx&#34;&gt;localStorage&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;setItem&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s1&#34;&gt;&amp;#39;token&amp;#39;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;token&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;nx&#34;&gt;localStorage&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;setItem&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s1&#34;&gt;&amp;#39;expiration&amp;#39;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;expiration&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;  &lt;span class=&#34;p&#34;&gt;}&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;p&#34;&gt;}&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Which allows you to commit your changes in actions in an identical manner:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-ts&#34; data-lang=&#34;ts&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;nx&#34;&gt;store&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;commit&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s1&#34;&gt;&amp;#39;authenticate&amp;#39;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;  &lt;span class=&#34;nx&#34;&gt;token&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;  &lt;span class=&#34;nx&#34;&gt;expiration&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;p&#34;&gt;});&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</description>
    </item>
    
    <item>
      <title>React Native: Error: watch EMFILE</title>
      <link>https://f2cfe404.karltarvascom.pages.dev/react-native-error-watch-emfile/</link>
      <guid>https://f2cfe404.karltarvascom.pages.dev/react-native-error-watch-emfile/</guid>
      <pubDate>Mon, 10 Oct 2016 00:00:00 &#43;0000</pubDate>
      <description>&lt;p&gt;After updating macOS, you may run into the following problem when trying to run a React Native project:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-gdscript3&#34; data-lang=&#34;gdscript3&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;n&#34;&gt;ERROR&lt;/span&gt;  &lt;span class=&#34;n&#34;&gt;watch&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;EMFILE&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;code&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;EMFILE&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;errno&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;EMFILE&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;syscall&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;watch&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;}&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;n&#34;&gt;Error&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;watch&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;EMFILE&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;n&#34;&gt;at&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;exports&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;_errnoException&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;util&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;js&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt;&lt;span class=&#34;mi&#34;&gt;746&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt;&lt;span class=&#34;mi&#34;&gt;11&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;n&#34;&gt;at&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;FSWatcher&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;start&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;fs&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;js&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt;&lt;span class=&#34;mi&#34;&gt;1172&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt;&lt;span class=&#34;mi&#34;&gt;11&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;n&#34;&gt;at&lt;/span&gt; &lt;span class=&#34;ne&#34;&gt;Object&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;fs&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;watch&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;fs&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;js&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt;&lt;span class=&#34;mi&#34;&gt;1198&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt;&lt;span class=&#34;mi&#34;&gt;11&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;n&#34;&gt;at&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;NodeWatcher&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;watchdir&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;/&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;node_modules&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;/&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;react&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;-&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;native&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;/&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;node_modules&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;/&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;sane&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;/&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;src&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;/&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;node_watcher&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;js&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt;&lt;span class=&#34;mi&#34;&gt;144&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt;&lt;span class=&#34;mi&#34;&gt;20&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;n&#34;&gt;at&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;Walker&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&amp;lt;&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;anonymous&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;&amp;gt;&lt;/span&gt; &#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The issue stems from incorrect folder permissions being set for &lt;code&gt;watchman&lt;/code&gt; after the update.&lt;/p&gt;&#xA;&lt;p&gt;As covered in &lt;a href=&#34;https://github.com/facebook/react-native/issues/9943&#34;&gt;this ticket&lt;/a&gt;, fully reinstalling the file watching utility solves the problem:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-gdscript3&#34; data-lang=&#34;gdscript3&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;n&#34;&gt;rm&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;-&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;rf&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;/&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;usr&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;/&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;local&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;/&lt;/span&gt;&lt;span class=&#34;k&#34;&gt;var&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;/&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;run&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;/&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;watchman&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;/&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;n&#34;&gt;brew&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;uninstall&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;watchman&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;n&#34;&gt;brew&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;install&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;watchman&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</description>
    </item>
    
    <item>
      <title>Order of resolved values in &lt;code&gt;Promise.all()&lt;/code&gt;</title>
      <link>https://f2cfe404.karltarvascom.pages.dev/order-of-resolved-values-in-promise-all/</link>
      <guid>https://f2cfe404.karltarvascom.pages.dev/order-of-resolved-values-in-promise-all/</guid>
      <pubDate>Wed, 21 Jan 2015 00:00:00 &#43;0000</pubDate>
      <description>&lt;p&gt;Shortly, &lt;code&gt;Promise.all()&lt;/code&gt; &lt;strong&gt;preserves the order&lt;/strong&gt; between its input and output.&lt;/p&gt;&#xA;&lt;p&gt;Following the spec, &lt;a href=&#34;https://tc39.es/ecma262/#sec-promise.all&#34;&gt;&lt;code&gt;Promise.all(iterable)&lt;/code&gt;&lt;/a&gt; takes an &lt;a href=&#34;https://tc39.es/ecma262/#sec-iterator-interface&#34;&gt;&lt;code&gt;iterable&lt;/code&gt;&lt;/a&gt; as a parameter and internally calls &lt;a href=&#34;https://tc39.es/ecma262/#sec-performpromiseall&#34;&gt;&lt;code&gt;PerformPromiseAll(iterator, constructor, resultCapability)&lt;/code&gt;&lt;/a&gt; with it, where the latter loops over the &lt;code&gt;iterable&lt;/code&gt; using &lt;a href=&#34;https://tc39.es/ecma262/#sec-iteratorstep&#34;&gt;&lt;code&gt;IteratorStep(iterator)&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Resolving is implemented via &lt;a href=&#34;https://tc39.es/ecma262/#sec-promise.all-resolve-element-functions&#34;&gt;&lt;code&gt;Promise.all() Resolve&lt;/code&gt;&lt;/a&gt; where each resolved promise has an internal &lt;code&gt;[[Index]]&lt;/code&gt; slot, which marks the index of the promise in the original input.&lt;/p&gt;&#xA;&lt;p&gt;All this means the output is strictly ordered given the iterable you pass to &lt;code&gt;Promise.all()&lt;/code&gt; is strictly ordered (for example, an array):&lt;/p&gt;</description>
    </item>
    
  </channel>
</rss>