<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="../assets/xml/rss.xsl" media="all"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>why = WHY_NOT; (Posts about programming)</title><link>https://blog.svedr.in/</link><description></description><atom:link href="https://blog.svedr.in/categories/programming.xml" rel="self" type="application/rss+xml"></atom:link><language>en</language><lastBuildDate>Sun, 15 Feb 2026 11:29:07 GMT</lastBuildDate><generator>Nikola (getnikola.com)</generator><docs>http://blogs.law.harvard.edu/tech/rss</docs><item><title>Code folding with Regions in Python using Kate</title><link>https://blog.svedr.in/posts/code-folding-with-regions-in-python-using-kate/</link><dc:creator>Svedrin</dc:creator><description>&lt;div&gt;&lt;p&gt;I once again ended up having to edit a somewhat large Python file.
Since I don’t believe in Clean Code’s methodology of splitting things up
into thousands of micro-functions and then having to pass tons of
variables around as arguments all the time, I’m actually happy with
that. Also it’s kinda what code folding was invented for. Unfortunately
I usually don’t find it all that helpful, because it doesn’t fold the
way I want it to.&lt;/p&gt;
&lt;p&gt;I like what C# does with &lt;code&gt;#region&lt;/code&gt; and
&lt;code&gt;#endregion&lt;/code&gt;, where you can freely define a section of code
to be folded away, exactly how it makes sense to &lt;em&gt;you&lt;/em&gt; the human,
who this feature is designed for, rather than the machine that gets to
execute the code and thinks in different patterns than you do.&lt;/p&gt;
&lt;p&gt;So, I found a way to enable Kate to do this in Python. Here’s
how.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://blog.svedr.in/posts/code-folding-with-regions-in-python-using-kate/"&gt;Read more…&lt;/a&gt; (1 min remaining to read)&lt;/p&gt;&lt;/div&gt;</description><category>programming</category><guid>https://blog.svedr.in/posts/code-folding-with-regions-in-python-using-kate/</guid><pubDate>Fri, 13 Feb 2026 21:30:11 GMT</pubDate></item><item><title>Unit tests in bash</title><link>https://blog.svedr.in/posts/unit-tests-in-bash/</link><dc:creator>Svedrin</dc:creator><description>&lt;div&gt;&lt;p&gt;I yesterday ported the &lt;a href="https://github.com/Svedrin/microfw/blob/b41e202a41095a8d56713a3bd70b446d987756fa/src/microfw.sh#L56-L127"&gt;tear-down
part of MicroFW&lt;/a&gt; from Python back to Bash. (It was just unhappy in
Python.) In doing so, I tested it by uploading it to my server, running
it and seeing what happens. This is obviously unsatisfactory, but since
the script runs a bunch of &lt;code&gt;iptables&lt;/code&gt; calls and the like, how
am I supposed to test it? This integrates pretty deeply into the system,
no way of mocking that, right?&lt;/p&gt;
&lt;p&gt;Well, yes way: You just need to shamelessly abuse the
&lt;code&gt;function&lt;/code&gt; keyword…&lt;/p&gt;
&lt;p&gt;&lt;a href="https://blog.svedr.in/posts/unit-tests-in-bash/"&gt;Read more…&lt;/a&gt; (3 min remaining to read)&lt;/p&gt;&lt;/div&gt;</description><category>linux</category><category>programming</category><guid>https://blog.svedr.in/posts/unit-tests-in-bash/</guid><pubDate>Sun, 15 Mar 2020 20:53:41 GMT</pubDate></item><item><title>Awesome threading using nurseries</title><link>https://blog.svedr.in/posts/awesome-threading-using-nurseries/</link><dc:creator>Svedrin</dc:creator><description>&lt;div&gt;&lt;p&gt;I wrote about a nice threading pattern using Queues for
synchronization &lt;a href="https://blog.svedr.in/posts/acting-up-weird-threads-in-python/"&gt;a while ago&lt;/a&gt;. In
the meantime, I’ve stumbled across &lt;a href="https://trio.readthedocs.io/en/latest/reference-core.html#nurseries-and-spawning"&gt;Trio&lt;/a&gt;
and I loved their concept of nurseries, which is basically a wrapper
around the threads-and-queues concept that also makes sure that threads
are properly joined and do not run out of control.&lt;/p&gt;
&lt;p&gt;So today I ran across a case where I’d have to query large chunks of
data from two systems in parallel, that I would then have to compare and
merge into a third data set. Thus I needed a way to start two threads,
return stuff from them to the main thread, and join them back together.
A nursery came to mind, because it does just that. So that’s what I
used, and here’s the code for it!&lt;/p&gt;
&lt;p&gt;&lt;a href="https://blog.svedr.in/posts/awesome-threading-using-nurseries/"&gt;Read more…&lt;/a&gt; (2 min remaining to read)&lt;/p&gt;&lt;/div&gt;</description><category>programming</category><guid>https://blog.svedr.in/posts/awesome-threading-using-nurseries/</guid><pubDate>Tue, 02 Jul 2019 13:01:22 GMT</pubDate></item><item><title>Cross-compiling Rust programs for Raspbian</title><link>https://blog.svedr.in/posts/cross-compiling-rust-programs-for-raspbian/</link><dc:creator>Svedrin</dc:creator><description>&lt;div&gt;&lt;p&gt;I just figured out how to cross-compile Rust programs for Raspberry Pis running Rasbian Stretch. Host system is an amd64 laptop running Debian unstable.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://blog.svedr.in/posts/cross-compiling-rust-programs-for-raspbian/"&gt;Read more…&lt;/a&gt; (1 min remaining to read)&lt;/p&gt;&lt;/div&gt;</description><category>programming</category><guid>https://blog.svedr.in/posts/cross-compiling-rust-programs-for-raspbian/</guid><pubDate>Tue, 02 Jan 2018 16:48:51 GMT</pubDate></item><item><title>Rust, meet Python</title><link>https://blog.svedr.in/posts/rust-meet-python/</link><dc:creator>Svedrin</dc:creator><description>&lt;div&gt;&lt;p&gt;Out of mere curiousity, I wanted to try out &lt;a class="reference external" href="https://crates.io/crates/bindgen"&gt;bindgen&lt;/a&gt; to generate a Rust interface to a C library. So I
ran it against &lt;a class="reference external" href="https://docs.python.org/2/extending/embedding.html"&gt;libpython&lt;/a&gt;, not really expecting that it would work, but you don't know
until you tried, right? The fun part is: It does work, after defeating a few errors.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://blog.svedr.in/posts/rust-meet-python/"&gt;Read more…&lt;/a&gt; (2 min remaining to read)&lt;/p&gt;&lt;/div&gt;</description><category>programming</category><guid>https://blog.svedr.in/posts/rust-meet-python/</guid><pubDate>Mon, 13 Nov 2017 21:06:07 GMT</pubDate></item><item><title>Bash Script Coding Rules</title><link>https://blog.svedr.in/posts/bash-script-coding-rules/</link><dc:creator>Svedrin</dc:creator><description>&lt;div&gt;&lt;p&gt;I've been thinking about writing a Bash linter sometime. I don't know when exactly this'll happen, but here are the rules I'd like to see enforced by such a linter. These are also the rules I tend to follow when writing bash scripts, and I found that it improves both readability and stability.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://blog.svedr.in/posts/bash-script-coding-rules/"&gt;Read more…&lt;/a&gt; (6 min remaining to read)&lt;/p&gt;&lt;/div&gt;</description><category>linux</category><category>programming</category><guid>https://blog.svedr.in/posts/bash-script-coding-rules/</guid><pubDate>Tue, 01 Aug 2017 18:41:30 GMT</pubDate></item><item><title>Error handling is not an excuse for goto</title><link>https://blog.svedr.in/posts/error-handling-is-not-an-excuse-for-goto/</link><dc:creator>Svedrin</dc:creator><description>&lt;div&gt;&lt;p&gt;In discussions about the infamous &lt;em&gt;goto&lt;/em&gt; statement, people frequently point out that it's okay to use &lt;em&gt;goto&lt;/em&gt; for error handling. The
argument usually goes that without &lt;em&gt;goto&lt;/em&gt;, you'd have to repeat your error handling code for each and every error condition that
can occur, which would suck more than using &lt;em&gt;goto&lt;/em&gt;. Both is wrong.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://blog.svedr.in/posts/error-handling-is-not-an-excuse-for-goto/"&gt;Read more…&lt;/a&gt; (2 min remaining to read)&lt;/p&gt;&lt;/div&gt;</description><category>programming</category><guid>https://blog.svedr.in/posts/error-handling-is-not-an-excuse-for-goto/</guid><pubDate>Sun, 05 Mar 2017 21:24:13 GMT</pubDate></item><item><title>PROBLEM: gc Concurrent Mark Sweep in fire fighting mode</title><link>https://blog.svedr.in/posts/problem-gc-concurrent-mark-sweep-in-fire-fighting-mode/</link><dc:creator>Svedrin</dc:creator><description>&lt;div&gt;&lt;p&gt;Ever since I deployed &lt;a class="reference external" href="http://www.zabbix.com/"&gt;Zabbix&lt;/a&gt; in our local network,
I've been sporadically receiving notifications about the Java garbage collector
being in fire fighting mode. Unfortunately, Google isn't all too helpful about
what that means. Here's how I understand it currently.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://blog.svedr.in/posts/problem-gc-concurrent-mark-sweep-in-fire-fighting-mode/"&gt;Read more…&lt;/a&gt; (1 min remaining to read)&lt;/p&gt;&lt;/div&gt;</description><category>programming</category><guid>https://blog.svedr.in/posts/problem-gc-concurrent-mark-sweep-in-fire-fighting-mode/</guid><pubDate>Mon, 30 Nov 2015 12:47:57 GMT</pubDate></item><item><title>User-friendly GIT CLI</title><link>https://blog.svedr.in/posts/user-friendly-git-cli/</link><dc:creator>Svedrin</dc:creator><description>&lt;div&gt;&lt;p&gt;How to get a user-friendly GIT CLI:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://blog.svedr.in/posts/user-friendly-git-cli/"&gt;Read more…&lt;/a&gt; (1 min remaining to read)&lt;/p&gt;&lt;/div&gt;</description><category>programming</category><guid>https://blog.svedr.in/posts/user-friendly-git-cli/</guid><pubDate>Wed, 04 Nov 2015 09:21:31 GMT</pubDate></item><item><title>Building a storage abstraction layer</title><link>https://blog.svedr.in/posts/building-a-storage-abstraction-layer/</link><dc:creator>Svedrin</dc:creator><description>&lt;div&gt;&lt;p&gt;During the development process for the next version of &lt;a class="reference external" href="http://openattic.org"&gt;openATTIC&lt;/a&gt;, we have come
across the problem that our previous design — which had been pretty straightforward — was being challenged
by the fact that there are lots of ways to architect a storage system, and using filesystems on top of LVM logical
volumes shared by CIFS, NFS or FTP was just one of those.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://blog.svedr.in/posts/building-a-storage-abstraction-layer/"&gt;Read more…&lt;/a&gt; (8 min remaining to read)&lt;/p&gt;&lt;/div&gt;</description><category>programming</category><guid>https://blog.svedr.in/posts/building-a-storage-abstraction-layer/</guid><pubDate>Sun, 02 Mar 2014 20:29:18 GMT</pubDate></item></channel></rss>