<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>emre şahin's digital garden 🍃 - til</title>
    <link>https://emresahin.net/tags/til/</link>
    <description>Posts in the til tag</description>
    <language>en</language>
    <managingEditor>contact@emresahin.net (Emre Şahin)</managingEditor>
    <lastBuildDate>Tue, 15 Sep 2026 19:46:32 +0000</lastBuildDate>
    <atom:link href="https://emresahin.net/tags/til/rss.xml" rel="self" type="application/rss+xml"/>
    <item>
      <title>TIL 12: Modern C Features</title>
      <published>2025-01-04T12:58:23+00:00</published>
      <updated>2025-01-04T12:58:23+00:00</updated>
      <author>Emre Şahin</author>
      <pubDate>Sat, 04 Jan 2025 12:58:23 +0000</pubDate>
      <link>https://emresahin.net/til-12/</link>
      <guid isPermaLink="true">https://emresahin.net/til-12/</guid>
      <description>🐢 There are some new features in C since I learned it in the 90s. One is variable-length arrays (VLAs). You can now set the length of an array at runtime. This makes some uses of pointers moot, but Linus Torvalds is reported to have said that the Linux kernel does not contain any VLAs. 🐇 It may b...</description>
      <category>Software Development</category>
      <category>C</category>
      <category>arrays</category>
      <category>variable length arrays</category>
      <category>complex numbers</category>
      <category>initialization</category>
      <category>dialog</category>
      <category>TIL</category>
      <content:encoded><![CDATA[<p>🐢 There are some new features in C since I learned it in the 90s. One is variable-length arrays (VLAs). You can now set the length of an array at runtime. This makes some uses of pointers moot, but Linus Torvalds is reported to have said that the Linux kernel does not contain any VLAs.</p>
<p>🐇 It may be useful, though. It looks like syntactic sugar for a <code>const</code> pointer plus <code>malloc</code>, but implicitness is usually not ideal. It also appears to use the stack.</p>
<p>🐢 I haven’t looked into the details, but it may be useful in some cases. I don’t think it can replace pointer usage if it uses the stack, though. Stack sizes are usually small, and having arrays that can fill them up is not a good approach. Another feature is complex number support. It seems from the lecture that this is also a bit of a half-baked feature.</p>
<p>🐇 What is the difference between this and using a struct with two float fields?</p>
<p>🐢 There are operators (+, -, *, or ==) that support these. Since there is no operator overloading in C, having a separate complex number type may be useful.</p>
<p>🐇 The example looks like <code>double complex cx = 1.0 + 3.0*I</code>; and yes, this may be useful if you’re frequently using complex numbers in your code. But I think it’s unnecessary in most cases. There shouldn’t be such a frequent need for complex numbers, right?</p>
<p>🐢 A good complex number library will probably provide more than the built-in type, such as vectors for these numbers. A dedicated library will still be needed in most cases, I believe.</p>
<p>🐇 Another feature added to C is that struct members can now be initialized by name or index. You can initialize an array like <code>int a[6] = { [3] = 29, [2] = 14 };</code>, and it will initialize only those specific members.</p>
<p>🐢 Ah, this is much more useful than complex numbers for the general case.</p>
<p>🐇 There is also a span syntax: <code>int a[10] = {1, 2, [2 ... 4] = 3, [5] = 30};</code>.</p>
<p>🐢 That is really neat.</p>
<p>🐇 It’s also possible to omit the initial length, so the initializer values determine the size of the array. For example, <code>int a[] = {1, 3, [30] = 55, [9090] = 1010};</code> will result in an array of length 9091.</p>
<p>🐢 How is this used with structs?</p>
<p>🐇 Instead of <code>[]</code>, in struct initializers, we use the dot notation, like <code>struct Point p1 = { .x=0, .y=10 };</code>.</p>
<p>🐢 This is really useful and would keep much of the initialization code simpler.</p>
<p>🐇 There is also a way to initialize arrays of structs, like:</p>
<pre><code class="language-c">struct points pts[5] = { [0].x = 10, [0].y = 20, [3].x = 100 };
</code></pre>
<p>🐢 This feature is a nice addition to C; I really like it.</p>]]></content:encoded>
    </item>
    <item>
      <title>Sending i3 messages from shell scripts</title>
      <published>2021-01-28T12:35:21+00:00</published>
      <updated>2021-01-28T12:35:21+00:00</updated>
      <author>Emre Şahin</author>
      <pubDate>Thu, 28 Jan 2021 12:35:21 +0000</pubDate>
      <link>https://emresahin.net/sending-i3-messages-from-shell/</link>
      <guid isPermaLink="true">https://emresahin.net/sending-i3-messages-from-shell/</guid>
      <description>It’s possible to send messages to the i3 window manager from shell scripts using i3-msg . For example: i3-msg workspace "n"</description>
      <category>Scripting</category>
      <category>i3</category>
      <category>X</category>
      <category>desktop</category>
      <category>automation</category>
      <category>shell</category>
      <category>til</category>
      <content:encoded><![CDATA[<p>It’s possible to send messages to the i3 window manager from shell scripts using <code>i3-msg</code>. For example:</p>
<pre><code class="language-bash">i3-msg workspace "n"
</code></pre>]]></content:encoded>
    </item>
    <item>
      <title>TIL: sed</title>
      <published>2020-07-15T15:51:00+00:00</published>
      <updated>2020-07-15T15:51:00+00:00</updated>
      <author>Emre Şahin</author>
      <pubDate>Wed, 15 Jul 2020 15:51:00 +0000</pubDate>
      <link>https://emresahin.net/sed/</link>
      <guid isPermaLink="true">https://emresahin.net/sed/</guid>
      <description>When I try to use sed to find and edit multiple files, I always remember that perl -pe is better suited for this task. Today, this happened again. I tried to find and replace lines starting with # Bla bla with title: Bla bla , and it was easier to use perl -pe 's|^#+ (.*)|title: $1|g' than identi...</description>
      <category>CLI</category>
      <category>sed</category>
      <category>perl</category>
      <category>regex</category>
      <category>til</category>
      <content:encoded><![CDATA[<p>When I try to use <code>sed</code> to find and edit multiple files, I always remember that <code>perl -pe</code> is better suited for this task. Today, this happened again. I tried to find and replace lines starting with <code># Bla bla</code> with <code>title: Bla bla</code>, and it was easier to use <code>perl -pe 's|^#+ (.*)|title: $1|g'</code> than identifying what kind of regular expressions <code>sed</code> uses.</p>
<hr>
<p>It’s possible to get a section from a Markdown file with a command like:</p>
<pre><code class="language-bash">sed -n -e '/^#/,/^#/p'
</code></pre>
<p>It is also possible to use line numbers instead of regexes. The <code>p</code> at the end is the print command, which can be replaced by, for example, <code>d</code> to delete the lines.</p>]]></content:encoded>
    </item>
    <item>
      <title>Shell (Bash and Zsh) Notes</title>
      <published>2013-08-16T21:00:00+00:00</published>
      <updated>2013-08-16T21:00:00+00:00</updated>
      <author>Emre Şahin</author>
      <pubDate>Fri, 16 Aug 2013 21:00:00 +0000</pubDate>
      <link>https://emresahin.net/shell-notes/</link>
      <guid isPermaLink="true">https://emresahin.net/shell-notes/</guid>
      <description>Don’t use ~ in scripts; use $HOME I have used ~ several times in scripts, but it may not always expand as expected depending on the environment. Use $HOME to refer to the home directory; it is much more reliable and always works.</description>
      <category>Scripting</category>
      <category>CLI</category>
      <category>shell</category>
      <category>bash</category>
      <category>zsh</category>
      <category>scripting</category>
      <category>best practices</category>
      <category>til</category>
      <content:encoded><![CDATA[<h1 id="dont-use--in-scripts-use-home">Don’t use <code>~</code> in scripts; use <code>$HOME</code></h1>
<p>I have used <code>~</code> several times in scripts, but it may not always expand as expected depending on the environment. Use <code>$HOME</code> to refer to the home directory; it is much more reliable and always works.</p>]]></content:encoded>
    </item>
  </channel>
</rss>
