<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
    <title>Amanjeev Sethi</title>
    <subtitle>Personal website and blog of Amanjeev Sethi</subtitle>
    <link rel="self" type="application/atom+xml" href="https://amanjeev.com/atom.xml"/>
    <link rel="alternate" type="text/html" href="https://amanjeev.com"/>
    <generator uri="https://www.getzola.org/">Zola</generator>
    <updated>2024-02-09T00:00:00+00:00</updated>
    <id>https://amanjeev.com/atom.xml</id>
    <entry xml:lang="en">
        <title>Banality of Grief (Poem)</title>
        <published>2024-02-09T00:00:00+00:00</published>
        <updated>2024-02-09T00:00:00+00:00</updated>
        
        <author>
          <name>
            
              Unknown
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://amanjeev.com/blog/poem-banality-of-grief/"/>
        <id>https://amanjeev.com/blog/poem-banality-of-grief/</id>
        
        <content type="html" xml:base="https://amanjeev.com/blog/poem-banality-of-grief/">&lt;h2 id=&quot;banality-of-grief&quot;&gt;Banality of Grief&lt;&#x2F;h2&gt;
&lt;p&gt;Hold the opposing truths, gently&lt;br &#x2F;&gt;
in your gaze&lt;br &#x2F;&gt;
you may sound obvious&lt;br &#x2F;&gt;
but it is real&lt;br &#x2F;&gt;
for you&lt;br &#x2F;&gt;
You may feel small&lt;br &#x2F;&gt;
but isn’t it weighing&lt;br &#x2F;&gt;
on you?&lt;br &#x2F;&gt;
You must speak&lt;br &#x2F;&gt;
cry even&lt;br &#x2F;&gt;
The banality of your Grief&lt;br &#x2F;&gt;
that you think, is in your mind&lt;br &#x2F;&gt;
You may weep&lt;br &#x2F;&gt;
even shout&lt;br &#x2F;&gt;
but you must say&lt;br &#x2F;&gt;
the obvious out loud&lt;&#x2F;p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Some notes on OpenWrt</title>
        <published>2023-12-16T00:00:00+00:00</published>
        <updated>2023-12-16T00:00:00+00:00</updated>
        
        <author>
          <name>
            
              Unknown
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://amanjeev.com/blog/notes-on-openwrt/"/>
        <id>https://amanjeev.com/blog/notes-on-openwrt/</id>
        
        <content type="html" xml:base="https://amanjeev.com/blog/notes-on-openwrt/">&lt;h2 id=&quot;what-is-openwrt&quot;&gt;What is &lt;a href=&quot;https:&#x2F;&#x2F;openwrt.org&#x2F;&quot;&gt;OpenWrt&lt;&#x2F;a&gt;?&lt;&#x2F;h2&gt;
&lt;p&gt;I pronounce it as &quot;Open Wart&quot; but I digress and the notes haven&#x27;t even begun. It is a Linux(-based), open source operating system for embedded devices but it&#x27;s most use if found in your routers. If you want your router to have an open source and free operating system, this is a decent bet.&lt;&#x2F;p&gt;
&lt;p&gt;To download firmware for your device&#x2F;architecture go to &lt;a href=&quot;https:&#x2F;&#x2F;firmware-selector.openwrt.org&#x2F;&quot;&gt;OpenWrt Firmware download page and try to find your device&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;architectures-and-devices&quot;&gt;Architectures and devices&lt;&#x2F;h3&gt;
&lt;p&gt;OpenWrt is open to adding new devices. Check &lt;a href=&quot;https:&#x2F;&#x2F;openwrt.org&#x2F;docs&#x2F;guide-developer&#x2F;adding_new_device#adding_a_new_device&quot;&gt;how to add new device page&lt;&#x2F;a&gt; for details. If you want to go that route, maybe check if your device is already supported by going to &lt;a href=&quot;https:&#x2F;&#x2F;openwrt.org&#x2F;toh&#x2F;start&quot;&gt;&quot;Table of Hardware&quot; support page&lt;&#x2F;a&gt;. This is also available as an archive to download and grep locally.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;packages&quot;&gt;Packages&lt;&#x2F;h3&gt;
&lt;p&gt;OpenWrt also has a &lt;a href=&quot;https:&#x2F;&#x2F;openwrt.org&#x2F;packages&#x2F;start&quot;&gt;package ecosystem&lt;&#x2F;a&gt;. So, you can package your own application for the OS. In fact, the UI (Web based) called Luci is a package itself that you can install once you have the OS up and running. The packages are divided into &lt;a href=&quot;https:&#x2F;&#x2F;openwrt.org&#x2F;packages&#x2F;index_owrt21_2&#x2F;start&quot;&gt;many categories&lt;&#x2F;a&gt; and creating a new package means you should choose one of those categories and likely sub-categories.&lt;&#x2F;p&gt;
&lt;p&gt;You can install packages using the &lt;code&gt;opkg&lt;&#x2F;code&gt; installation tool from the commandline. You will need to SSH into the router&#x2F;device after installing the OS.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;rust-and-openwrt&quot;&gt;Rust and OpenWrt&lt;&#x2F;h2&gt;
&lt;p&gt;This is new! Starting &lt;a href=&quot;https:&#x2F;&#x2F;www.phoronix.com&#x2F;news&#x2F;OpenWrt-23.05-Released&quot;&gt;OpenWrt version 23.05 you have native Rust package support&lt;&#x2F;a&gt;. This can make life easier if you want to create a simple Rust package for OpenWrt.&lt;&#x2F;p&gt;
&lt;p&gt;For me, my application was far more complex than what the OpenWrt Rust support toolchain can handle right now because we bundle some web artifacts etc. So, in my case it was easier to find the architecture and compile my binary for that using &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;NixOS&#x2F;nix&quot;&gt;Nix&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
&lt;p&gt;You can find a few things by running these commands for your router -&lt;&#x2F;p&gt;
&lt;h3 id=&quot;uname-a&quot;&gt;&lt;code&gt;uname -a&lt;&#x2F;code&gt;&lt;&#x2F;h3&gt;
&lt;p&gt;Shows you system information in brief. For example,&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;shell&quot; style=&quot;background-color:#eff1f5;color:#4f5b66;&quot; class=&quot;language-shell &quot;&gt;&lt;code class=&quot;language-shell&quot; data-lang=&quot;shell&quot;&gt;&lt;span&gt;root@OpenWrt:~# uname -a
&lt;&#x2F;span&gt;&lt;span&gt;Linux OpenWrt 5.14.171 # 21:05:12 2023 armv7l GNU&#x2F;Linux
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;h3 id=&quot;lscpu&quot;&gt;&lt;code&gt;lscpu&lt;&#x2F;code&gt;&lt;&#x2F;h3&gt;
&lt;p&gt;This will show you architecture in detail. For example,&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;shell&quot; style=&quot;background-color:#eff1f5;color:#4f5b66;&quot; class=&quot;language-shell &quot;&gt;&lt;code class=&quot;language-shell&quot; data-lang=&quot;shell&quot;&gt;&lt;span&gt;root@OpenWrt:~# lscpu
&lt;&#x2F;span&gt;&lt;span&gt;Architecture:           armv7l
&lt;&#x2F;span&gt;&lt;span&gt;  Byte Order:           Little Endian
&lt;&#x2F;span&gt;&lt;span&gt;CPU(s):                 2
&lt;&#x2F;span&gt;&lt;span&gt;  On-line CPU(s) list:  0,1
&lt;&#x2F;span&gt;&lt;span&gt;Vendor ID:              ARM
&lt;&#x2F;span&gt;&lt;span&gt;  Model name:           Cortex-A9
&lt;&#x2F;span&gt;&lt;span&gt;    Model:              1
&lt;&#x2F;span&gt;&lt;span&gt;    Thread(s) per core: 1
&lt;&#x2F;span&gt;&lt;span&gt;    Core(s) per socket: 2
&lt;&#x2F;span&gt;&lt;span&gt;    Socket(s):          1
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;The important part is that you can also get the Model name (Cortex-A9) which maybe needed to choose the right architecture.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;ldd-version&quot;&gt;&lt;code&gt;ldd --version&lt;&#x2F;code&gt;&lt;&#x2F;h3&gt;
&lt;p&gt;This will tell you which base library your system is using. For example, the following uses &lt;code&gt;musl&lt;&#x2F;code&gt;,&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;shell&quot; style=&quot;background-color:#eff1f5;color:#4f5b66;&quot; class=&quot;language-shell &quot;&gt;&lt;code class=&quot;language-shell&quot; data-lang=&quot;shell&quot;&gt;&lt;span&gt;root@OpenWrt:~# ldd --version
&lt;&#x2F;span&gt;&lt;span&gt;musl libc (armhf)
&lt;&#x2F;span&gt;&lt;span&gt;Version 1.2.3
&lt;&#x2F;span&gt;&lt;span&gt;Dynamic Program Loader
&lt;&#x2F;span&gt;&lt;span&gt;Usage: ldd [options] [--] pathname
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;h2 id=&quot;create-a-package-for-openwrt&quot;&gt;Create a package for OpenWrt&lt;&#x2F;h2&gt;
&lt;p&gt;I should begin by saying that in this exercise, you need a lot of GNU Make knowledge. The hell of Make will be enough for you to say no to creating OpenWrt package. However, let&#x27;s look at a few things I learned during this &quot;simple&quot; exercise.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;easy-way-out-is-to-build-binary-yourself&quot;&gt;Easy way out is to build binary yourself&lt;&#x2F;h3&gt;
&lt;p&gt;If you know the architectures you want to support and can publish the package yourself, you can avoid the entire drama and just host things yourself. Honestly, it was far easier to do that especially if you have a complex build process. Which brings the next point.&lt;&#x2F;p&gt;
&lt;p&gt;Quick before the next point, the &lt;code&gt;.ipk&lt;&#x2F;code&gt; file is just a &lt;code&gt;tar.gz&lt;&#x2F;code&gt;. So, you can unpack some existing package and see what kind of files are inside. It kinda feels like debian based structure but I could be wrong.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;the-packaging-process-is-a-nightmare&quot;&gt;The packaging process is a nightmare&lt;&#x2F;h3&gt;
&lt;p&gt;You can try and follow their &lt;a href=&quot;https:&#x2F;&#x2F;openwrt.org&#x2F;docs&#x2F;guide-developer&#x2F;packages&quot;&gt;tutorial for packaging on their Wiki&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
&lt;p&gt;If you want to package it using their Make stuff, you will end up having more architectural support but it is a nightmare and not even like the Halloween kind where you get the candy.&lt;&#x2F;p&gt;
&lt;p&gt;No really, look at this makefile -&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;make&quot; style=&quot;background-color:#eff1f5;color:#4f5b66;&quot; class=&quot;language-make &quot;&gt;&lt;code class=&quot;language-make&quot; data-lang=&quot;make&quot;&gt;&lt;span style=&quot;color:#b48ead;&quot;&gt;include $(&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;TOPDIR&lt;&#x2F;span&gt;&lt;span style=&quot;color:#b48ead;&quot;&gt;)&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;&#x2F;rules.mk
&lt;&#x2F;span&gt;&lt;span&gt; 
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;PKG_NAME&lt;&#x2F;span&gt;&lt;span&gt;:=&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;bridge
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;PKG_VERSION&lt;&#x2F;span&gt;&lt;span&gt;:=&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;1.0.6
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;PKG_RELEASE&lt;&#x2F;span&gt;&lt;span&gt;:=&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;1
&lt;&#x2F;span&gt;&lt;span&gt; 
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;PKG_BUILD_DIR&lt;&#x2F;span&gt;&lt;span&gt;:=&lt;&#x2F;span&gt;&lt;span style=&quot;color:#b48ead;&quot;&gt;$(&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;BUILD_DIR&lt;&#x2F;span&gt;&lt;span style=&quot;color:#b48ead;&quot;&gt;)&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;&#x2F;bridge-utils-&lt;&#x2F;span&gt;&lt;span style=&quot;color:#b48ead;&quot;&gt;$(&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;PKG_VERSION&lt;&#x2F;span&gt;&lt;span style=&quot;color:#b48ead;&quot;&gt;)
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;PKG_SOURCE&lt;&#x2F;span&gt;&lt;span&gt;:=&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;bridge-utils-&lt;&#x2F;span&gt;&lt;span style=&quot;color:#b48ead;&quot;&gt;$(&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;PKG_VERSION&lt;&#x2F;span&gt;&lt;span style=&quot;color:#b48ead;&quot;&gt;)&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;.tar.gz
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;PKG_SOURCE_URL&lt;&#x2F;span&gt;&lt;span&gt;:=&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;@SF&#x2F;bridge
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;PKG_HASH&lt;&#x2F;span&gt;&lt;span&gt;:=&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;9b7dc52656f5cbec846a7ba3299f73bd
&lt;&#x2F;span&gt;&lt;span&gt; 
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#b48ead;&quot;&gt;include $(&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;INCLUDE_DIR&lt;&#x2F;span&gt;&lt;span style=&quot;color:#b48ead;&quot;&gt;)&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;&#x2F;package.mk
&lt;&#x2F;span&gt;&lt;span&gt; 
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#b48ead;&quot;&gt;define&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt; Package&#x2F;bridge
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;  SECTION:=base
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;  CATEGORY:=Network
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;  TITLE:=Ethernet bridging configuration utility
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;  #DESCRIPTION:=This variable is obsolete. use the Package&#x2F;name&#x2F;description define instead!
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;  URL:=http:&#x2F;&#x2F;bridge.sourceforge.net&#x2F;
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#b48ead;&quot;&gt;endef
&lt;&#x2F;span&gt;&lt;span&gt; 
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#b48ead;&quot;&gt;define&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt; Package&#x2F;bridge&#x2F;description
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt; Ethernet bridging configuration utility
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt; Manage ethernet bridging; a way to connect networks together to
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt; form a larger network.
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#b48ead;&quot;&gt;endef
&lt;&#x2F;span&gt;&lt;span&gt; 
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#b48ead;&quot;&gt;define&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt; Build&#x2F;Configure
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;  $(call Build&#x2F;Configure&#x2F;Default,--with-linux-headers=$(LINUX_DIR))
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#b48ead;&quot;&gt;endef
&lt;&#x2F;span&gt;&lt;span&gt; 
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#b48ead;&quot;&gt;define&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt; Package&#x2F;bridge&#x2F;install
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;        $(INSTALL_DIR) $(1)&#x2F;usr&#x2F;sbin
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;        $(INSTALL_BIN) $(PKG_BUILD_DIR)&#x2F;brctl&#x2F;brctl $(1)&#x2F;usr&#x2F;sbin&#x2F;
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#b48ead;&quot;&gt;endef
&lt;&#x2F;span&gt;&lt;span&gt; 
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#b48ead;&quot;&gt;$(&lt;&#x2F;span&gt;&lt;span style=&quot;color:#96b5b4;&quot;&gt;eval &lt;&#x2F;span&gt;&lt;span style=&quot;color:#b48ead;&quot;&gt;$(&lt;&#x2F;span&gt;&lt;span style=&quot;color:#d08770;&quot;&gt;call &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;BuildPackage&lt;&#x2F;span&gt;&lt;span&gt;,bridge&lt;&#x2F;span&gt;&lt;span style=&quot;color:#b48ead;&quot;&gt;))
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;This reminds me of the &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;ncbi&#x2F;ncbi-cxx-toolkit-public&quot;&gt;CMake hell of NCBI C++ Toolkit&lt;&#x2F;a&gt;. You can see there is a configuration file to configure CMake first.&lt;&#x2F;p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>(In)secure C++ Training with Patricia Aas</title>
        <published>2023-11-23T00:00:00+00:00</published>
        <updated>2023-11-23T00:00:00+00:00</updated>
        
        <author>
          <name>
            
              Unknown
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://amanjeev.com/blog/insecure-cpp-training-with-patricia/"/>
        <id>https://amanjeev.com/blog/insecure-cpp-training-with-patricia/</id>
        
        <content type="html" xml:base="https://amanjeev.com/blog/insecure-cpp-training-with-patricia/">&lt;p&gt;A few weeks ago I had the privilege of attending the security training (using C++) by &lt;a href=&quot;https:&#x2F;&#x2F;patricia.no&quot;&gt;Patricia Aas&lt;&#x2F;a&gt;. This was also the only training she ever did in the North American timezone and that was such a fortunate thing for me. This was such a fun experience and I want to give you a bit of detail on what you can expect from this training.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;basic-structure&quot;&gt;Basic structure&lt;&#x2F;h2&gt;
&lt;p&gt;This is an intense course, but it is also a lot of fun. As a trainer myself, I am just in sheer awe of Patricia. This was 4 (four) days of 8 (eight) hours each day. You do get an hour of break in the middle but I can tell you this is still a lot of work for the trainer. Apart from that, there is a healthy variety of theory (including history) with practical exercises.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;highlights-for-me&quot;&gt;Highlights (for me)&lt;&#x2F;h2&gt;
&lt;h3 id=&quot;material&quot;&gt;Material&lt;&#x2F;h3&gt;
&lt;p&gt;I have always wanted to get hands-on security courses from the vantage of reverse-engineering, fuzzing, shellcode, and learn about the tooling around it. All of that was covered.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;slides&quot;&gt;Slides&lt;&#x2F;h3&gt;
&lt;p&gt;I give extra mention for slides because Patricia’s slide-deck is so beautiful. You can get some idea of what to expect by &lt;a href=&quot;https:&#x2F;&#x2F;patricia.no&quot;&gt;visiting her website&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;exercises&quot;&gt;Exercises&lt;&#x2F;h3&gt;
&lt;p&gt;There are a plenty of exercises and hands-on work. You even get to do your own fuzzing, you learn about &lt;del&gt;heartbless&lt;&#x2F;del&gt; heartbleed as an exercises! I am going to setup my own fuzzing lab at home.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;is-it-for-you&quot;&gt;Is it for you?&lt;&#x2F;h2&gt;
&lt;p&gt;In my group, there were seasoned security and reverse-engineering folks. There were also total beginners like me. Seldom is a course where people from both ends of the spectrum of knowledge can get so much out of. I can assure you that no matter where you are, this course will be fun and educational for you.&lt;&#x2F;p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Publications</title>
        <published>2023-09-13T00:00:00+00:00</published>
        <updated>2023-09-13T00:00:00+00:00</updated>
        
        <author>
          <name>
            
              Unknown
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://amanjeev.com/publications/"/>
        <id>https://amanjeev.com/publications/</id>
        
        <content type="html" xml:base="https://amanjeev.com/publications/">&lt;p&gt;These are some of my writings published elsewhere. They are posted here in reverse-chronological order.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;articles&quot;&gt;Articles&lt;&#x2F;h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https:&#x2F;&#x2F;ferrous-systems.com&#x2F;blog&#x2F;cheatsheet-for-confusing-rust-terms&#x2F;&quot;&gt;A cheatsheet for some potentially confusing terms in Rust&lt;&#x2F;a&gt; - March 09, 2023&lt;&#x2F;li&gt;
&lt;li&gt;&lt;a href=&quot;https:&#x2F;&#x2F;ferrous-systems.com&#x2F;blog&#x2F;binding-with-bindgen&#x2F;&quot;&gt;The &lt;code&gt;bindgen&lt;&#x2F;code&gt; project update&lt;&#x2F;a&gt; - March 06, 2023&lt;&#x2F;li&gt;
&lt;li&gt;&lt;a href=&quot;https:&#x2F;&#x2F;www.distributedgenomics.ca&#x2F;posts&#x2F;candigv2-aai&#x2F;&quot;&gt;The CanDIGv2 Authentication and Authorization Stack&lt;&#x2F;a&gt; - April 13, 2021&lt;&#x2F;li&gt;
&lt;li&gt;CanDIG’s input on CINECA blog post &quot;&lt;a href=&quot;https:&#x2F;&#x2F;www.cineca-project.eu&#x2F;blog-all&#x2F;integration-of-new-cohort-infrastructures-to-the-elixir-aai&quot;&gt;Integration of new cohort infrastructures to the ELIXIR AAI&lt;&#x2F;a&gt;&quot; - January 07, 2020&lt;&#x2F;li&gt;
&lt;li&gt;&lt;a href=&quot;https:&#x2F;&#x2F;www.distributedgenomics.ca&#x2F;posts&#x2F;gentle-intro-to-federated-distributed-authz&#x2F;&quot;&gt;A Gentle Introduction to Federated and Distributed Authorization&lt;&#x2F;a&gt; - March 04, 2020&lt;&#x2F;li&gt;
&lt;li&gt;&lt;a href=&quot;https:&#x2F;&#x2F;blog.rust-lang.org&#x2F;inside-rust&#x2F;2019&#x2F;10&#x2F;28&#x2F;rustc-learning-working-group-introduction.html&quot;&gt;The Rustc Dev Guide Working Group - An Introduction&lt;&#x2F;a&gt; - October 28, 2019&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;h2 id=&quot;research-papers&quot;&gt;Research papers&lt;&#x2F;h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https:&#x2F;&#x2F;doi.org&#x2F;10.1016&#x2F;j.xgen.2021.100033&quot;&gt;CanDIG: Federated network across Canada for multi-omic and health data discovery and analysis&lt;&#x2F;a&gt; - 10 November, 2021 (co-author)&lt;&#x2F;li&gt;
&lt;li&gt;&lt;a href=&quot;https:&#x2F;&#x2F;doi.org&#x2F;10.1101&#x2F;2021.03.30.434101&quot;&gt;CanDIG: Secure Federated Genomic Queries and Analyses Across Jurisdictions&lt;&#x2F;a&gt; -  March 31, 2021 (co-author)&lt;&#x2F;li&gt;
&lt;li&gt;&lt;a href=&quot;https:&#x2F;&#x2F;doi.org&#x2F;10.1093&#x2F;nar&#x2F;gkv1222&quot;&gt;ClinVar: public archive of interpretations of clinically relevant variants&lt;&#x2F;a&gt; - November 17, 2015 (contributor)&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>How to fail at STM32L433RC board with Embassy Rust embedded framework</title>
        <published>2022-12-16T00:00:00+00:00</published>
        <updated>2022-12-16T00:00:00+00:00</updated>
        
        <author>
          <name>
            
              Unknown
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://amanjeev.com/blog/stm32-embassy-rust-love/"/>
        <id>https://amanjeev.com/blog/stm32-embassy-rust-love/</id>
        
        <content type="html" xml:base="https://amanjeev.com/blog/stm32-embassy-rust-love/">&lt;p&gt;This blog post is about failures that ate two days of my time with STM32L433RC board with Rust.  I gave up many times and still not entirely back from the land of &lt;em&gt;given ups&lt;&#x2F;em&gt;.&lt;&#x2F;p&gt;
&lt;p&gt;The story starts when I got &lt;a href=&quot;https:&#x2F;&#x2F;www.st.com&#x2F;en&#x2F;microcontrollers-microprocessors&#x2F;stm32l433rc.html&quot;&gt;this beautiful board&lt;&#x2F;a&gt; to try out some Rust.  I am still learning embedded systems so even though I know some Rust, I struggle with the hardware part.  Datasheets for the hardware I use are really cool to read but they are hard for me to translate to Rust many times.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;https:&#x2F;&#x2F;amanjeev.com&#x2F;blog&#x2F;stm32-embassy-rust-love&#x2F;.&#x2F;STM32L433RC.jpeg&quot; alt=&quot;STM32L433RC board with two LEDs turned on&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;Before we go further -&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;amanjeev&#x2F;stm32l433love&quot;&gt;the poopy code for this post is here&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;li&gt;&lt;a href=&quot;https:&#x2F;&#x2F;www.st.com&#x2F;en&#x2F;microcontrollers-microprocessors&#x2F;stm32l433rc.html&quot;&gt;the board is STM32L433RC&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;h1 id=&quot;list-of-my-failure-modes&quot;&gt;List of my failure modes&lt;&#x2F;h1&gt;
&lt;h2 id=&quot;not-knowing-where-to-begin-with-rust-embedded&quot;&gt;Not knowing where to begin with Rust embedded&lt;&#x2F;h2&gt;
&lt;p&gt;This is a classic!  That is, when I am excited about tinkering with hardware and no clue where to begin.  There are a ton of frameworks!  Friends&#x27; and experts&#x27; suggestion point to the latest Rust frameworks and libraries and sometimes it gets daunting.  I was pointed to &lt;a href=&quot;https:&#x2F;&#x2F;embassy.dev&#x2F;&quot;&gt;Embassy&lt;&#x2F;a&gt;.  The cool part about this framework is that it is ground up support for Rust&#x27;s &lt;code&gt;async&#x2F;await&lt;&#x2F;code&gt; in embedded world.  This &lt;code&gt;async&#x2F;await&lt;&#x2F;code&gt; style of programming allows for better resource allocation when there are IO blocking and wait times.&lt;&#x2F;p&gt;
&lt;p&gt;Anyway, &lt;a href=&quot;https:&#x2F;&#x2F;embassy.dev&#x2F;book&#x2F;dev&#x2F;index.html#_what_is_async&quot;&gt;Embassy docs explain about what is &lt;code&gt;async&#x2F;await&lt;&#x2F;code&gt;&lt;&#x2F;a&gt; here.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;dropping-the-framework-midway-and-jumping-to-another&quot;&gt;Dropping the framework midway and jumping to another&lt;&#x2F;h2&gt;
&lt;p&gt;I made this another classic mistake.  I went down rabbit holes and lost track of how many &lt;em&gt;projects&lt;&#x2F;em&gt; I had created.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;not-looking-at-the-examples-in-the-framework&quot;&gt;Not looking at the examples in the framework&lt;&#x2F;h2&gt;
&lt;p&gt;Yes, I am told the best of the best also first head to the example directory to see how things are.  The only downside is that as a beginner, I do not have any prior knowledge to build upon.  Most embedded programmers can look at a new framework but they have a reference from prior experience with other frameworks etc.  I did not even remember to look at examples in at first.&lt;&#x2F;p&gt;
&lt;p&gt;Anyway, &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;embassy-rs&#x2F;embassy&#x2F;tree&#x2F;master&#x2F;examples&#x2F;stm32l4&#x2F;src&#x2F;bin&quot;&gt;Embassy has some nice example programs for my board here&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;not-knowing-what-to-do-with-the-board&quot;&gt;Not knowing what to do with the board&lt;&#x2F;h2&gt;
&lt;p&gt;I have no idea what I want to with the hardware but I like blinking lights.  That&#x27;s where I start and perhaps most others too.  I am told that blinking lights are the &lt;code&gt;println!(&quot;Hello, world!&quot;)&lt;&#x2F;code&gt; of the embedded world.  So, I did that.&lt;&#x2F;p&gt;
&lt;p&gt;Anyway, I have now started to see that some of these boards have some sensors on them.  For example, I see that there is a temperature sensor on this board I am working with.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;unable-to-figure-out-the-algorithms&quot;&gt;Unable to figure out the &quot;algorithms&quot;&lt;&#x2F;h2&gt;
&lt;p&gt;Ok, I may have used the incorrect word here but by algorithms I mean correct steps to do a certain task.  For example, my task of reading the temperature sensor value continuously and print on the console.  Some of the examples of the things I had no clue about are -&lt;&#x2F;p&gt;
&lt;h3 id=&quot;how-does-pushing-a-program-i-am-writing-on-my-pc-to-the-board-work&quot;&gt;How does &quot;pushing&quot; a program I am writing on my PC, to the board work?&lt;&#x2F;h3&gt;
&lt;p&gt;This is called &lt;em&gt;Flashing&lt;&#x2F;em&gt;.  The amazing thing with Rust embedded work is that you do not have to worry too much about it because &lt;code&gt;cargo&lt;&#x2F;code&gt; takes care of most of it.  Often you just need &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;amanjeev&#x2F;stm32l433love&#x2F;blob&#x2F;main&#x2F;.cargo&#x2F;config.toml&quot;&gt;a file &lt;code&gt;.cargo&#x2F;config.toml&lt;&#x2F;code&gt; in your project root&lt;&#x2F;a&gt; with some content like this -&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;toml&quot; style=&quot;background-color:#eff1f5;color:#4f5b66;&quot; class=&quot;language-toml &quot;&gt;&lt;code class=&quot;language-toml&quot; data-lang=&quot;toml&quot;&gt;&lt;span&gt;[target.&amp;#39;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;cfg(all(target_arch = &amp;quot;arm&amp;quot;, target_os = &amp;quot;none&amp;quot;))&lt;&#x2F;span&gt;&lt;span&gt;&amp;#39;]
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a7adba;&quot;&gt;# replace the chip below with your chip 
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a7adba;&quot;&gt;#  as listed in `probe-run --list-chips`
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;runner &lt;&#x2F;span&gt;&lt;span&gt;= &amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;probe-run --chip STM32L433RCTxP&lt;&#x2F;span&gt;&lt;span&gt;&amp;quot;
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;[build]
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;target &lt;&#x2F;span&gt;&lt;span&gt;= &amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;thumbv7em-none-eabi&lt;&#x2F;span&gt;&lt;span&gt;&amp;quot;
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;[env]
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;DEFMT_LOG &lt;&#x2F;span&gt;&lt;span&gt;= &amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;trace&lt;&#x2F;span&gt;&lt;span&gt;&amp;quot;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Here the &lt;code&gt;target&lt;&#x2F;code&gt; is the architecture.  Using &lt;code&gt;rustup&lt;&#x2F;code&gt; works like &lt;code&gt;rustup target add thumbv7em-none-eabi&lt;&#x2F;code&gt; to add this target on your PC.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;how-to-make-sure-we-tell-rust-the-right-environment&quot;&gt;How to make sure we tell Rust the right environment?&lt;&#x2F;h3&gt;
&lt;p&gt;This is trickier because for STM32 boards at least you need &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;amanjeev&#x2F;stm32l433love&#x2F;blob&#x2F;main&#x2F;memory.x&quot;&gt;a special file called &lt;code&gt;memory.x&lt;&#x2F;code&gt; and you may have to do some magic&lt;&#x2F;a&gt; to put it in the right place during the build phase of your project.  I failed at this miserably but datasheet of your board can tell you the values you need to specify.&lt;&#x2F;p&gt;
&lt;pre style=&quot;background-color:#eff1f5;color:#4f5b66;&quot;&gt;&lt;code&gt;&lt;span&gt;MEMORY
&lt;&#x2F;span&gt;&lt;span&gt;{
&lt;&#x2F;span&gt;&lt;span&gt;  &#x2F;* NOTE 1 K = 1 KiBi = 1024 bytes *&#x2F;
&lt;&#x2F;span&gt;&lt;span&gt;  &#x2F;* These values correspond to the STM32L433 *&#x2F;
&lt;&#x2F;span&gt;&lt;span&gt;  FLASH : ORIGIN = 0x08000000, LENGTH = 256K
&lt;&#x2F;span&gt;&lt;span&gt;  RAM : ORIGIN = 0x20000000, LENGTH = 64K
&lt;&#x2F;span&gt;&lt;span&gt;}
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;This is to tell Rust the memory regions on your board.  &lt;a href=&quot;https:&#x2F;&#x2F;docs.rust-embedded.org&#x2F;book&#x2F;start&#x2F;hardware.html&quot;&gt;Rust embedded book has a page to clarify more on this memory.x stuff&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;what-are-the-peripherals-and-how-do-we-access-them&quot;&gt;What are the peripherals and how do we access them?&lt;&#x2F;h3&gt;
&lt;p&gt;To know your peripherals you need to look at the datasheet.  How to access them via Rust depends on your framework but with Embassy it looks like this -&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;rust&quot; style=&quot;background-color:#eff1f5;color:#4f5b66;&quot; class=&quot;language-rust &quot;&gt;&lt;code class=&quot;language-rust&quot; data-lang=&quot;rust&quot;&gt;&lt;span style=&quot;color:#b48ead;&quot;&gt;let&lt;&#x2F;span&gt;&lt;span&gt; p = embassy_stm32::init(Default::default());
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;h2 id=&quot;not-knowing-what-the-value-of-sensor-mean&quot;&gt;Not knowing what the value of sensor mean?&lt;&#x2F;h2&gt;
&lt;p&gt;In my case the temperature sensor just spits out a number that Embassy framework&#x27;s API serves as &lt;code&gt;u16&lt;&#x2F;code&gt; (if I understand any of this, that is the voltage). Usually, you have to pass it through some formula to get the actual temperature.  Datasheet for this board has the following -&lt;&#x2F;p&gt;
&lt;p&gt;&lt;code&gt;Temperature (in °C) = (TS_CAL2_TEMP – TS_CAL1_TEMP) &#x2F; (TS_CAL2 – TS_CAL1) × (TS_DATA – TS_CAL1) + 30&lt;&#x2F;code&gt;&lt;&#x2F;p&gt;
&lt;p&gt;Where:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;TS_CAL2&lt;&#x2F;code&gt; is the temperature sensor calibration value acquired at &lt;code&gt;TS_CAL2_TEMP&lt;&#x2F;code&gt;.&lt;&#x2F;li&gt;
&lt;li&gt;&lt;code&gt;TS_CAL1&lt;&#x2F;code&gt; is the temperature sensor calibration value acquired at &lt;code&gt;TS_CAL1_TEMP&lt;&#x2F;code&gt;.&lt;&#x2F;li&gt;
&lt;li&gt;&lt;code&gt;TS_DATA&lt;&#x2F;code&gt; is the actual temperature sensor output value converted by ADC. Refer to the device datasheet for more information about &lt;code&gt;TS_CAL1&lt;&#x2F;code&gt; and &lt;code&gt;TS_CAL2&lt;&#x2F;code&gt; calibration points.&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;I do get some &lt;em&gt;cool&lt;&#x2F;em&gt; output LOL!&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;bash&quot; style=&quot;background-color:#eff1f5;color:#4f5b66;&quot; class=&quot;language-bash &quot;&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;cargo&lt;&#x2F;span&gt;&lt;span&gt; run&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt; --bin&lt;&#x2F;span&gt;&lt;span&gt; temp
&lt;&#x2F;span&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;Finished&lt;&#x2F;span&gt;&lt;span&gt; dev &lt;&#x2F;span&gt;&lt;span style=&quot;color:#b48ead;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span&gt;unoptimized + debuginfo&lt;&#x2F;span&gt;&lt;span style=&quot;color:#b48ead;&quot;&gt;]&lt;&#x2F;span&gt;&lt;span&gt; target(s) &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;in&lt;&#x2F;span&gt;&lt;span&gt; 0.07s
&lt;&#x2F;span&gt;&lt;span&gt;     &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;Running &lt;&#x2F;span&gt;&lt;span&gt;`&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;probe-run --chip&lt;&#x2F;span&gt;&lt;span&gt; STM32L433RCTxP target&#x2F;thumbv7em-none-eabi&#x2F;debug&#x2F;temp`
&lt;&#x2F;span&gt;&lt;span&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;HOST&lt;&#x2F;span&gt;&lt;span&gt;) INFO  flashing program (60 pages &#x2F; 60.00 KiB)
&lt;&#x2F;span&gt;&lt;span&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;HOST&lt;&#x2F;span&gt;&lt;span&gt;) INFO  success!
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;────────────────────────────────────────────────────────────────────────────────
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;0.001861&lt;&#x2F;span&gt;&lt;span&gt; internal is 64
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;└─&lt;&#x2F;span&gt;&lt;span&gt; temp::____embassy_main_task::{async_fn#0} @ src&#x2F;bin&#x2F;temp.rs:33
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;0.005584&lt;&#x2F;span&gt;&lt;span&gt; Temperature is: 57.070312
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;└─&lt;&#x2F;span&gt;&lt;span&gt; temp::____embassy_main_task::{async_fn#0} @ src&#x2F;bin&#x2F;temp.rs:41
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;0.010131&lt;&#x2F;span&gt;&lt;span&gt; Temperature is: 51.26953
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;└─&lt;&#x2F;span&gt;&lt;span&gt; temp::____embassy_main_task::{async_fn#0} @ src&#x2F;bin&#x2F;temp.rs:41
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;0.014678&lt;&#x2F;span&gt;&lt;span&gt; Temperature is: 46.757812
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;└─&lt;&#x2F;span&gt;&lt;span&gt; temp::____embassy_main_task::{async_fn#0} @ src&#x2F;bin&#x2F;temp.rs:41
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;0.019226&lt;&#x2F;span&gt;&lt;span&gt; Temperature is: 44.179688
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;└─&lt;&#x2F;span&gt;&lt;span&gt; temp::____embassy_main_task::{async_fn#0} @ src&#x2F;bin&#x2F;temp.rs:41
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;...
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;h2 id=&quot;not-putting-the-correct-board-feature-in-cargo-toml&quot;&gt;Not putting the correct board &quot;feature&quot; in &lt;code&gt;Cargo.toml&lt;&#x2F;code&gt;&lt;&#x2F;h2&gt;
&lt;p&gt;Yes, when you include &lt;code&gt;embassy-stm32&lt;&#x2F;code&gt; in your &lt;code&gt;Cargo.toml&lt;&#x2F;code&gt; dependencies, you need to specify the correct board &lt;em&gt;ID&lt;&#x2F;em&gt;. In my case it was &lt;code&gt;stm32l433rc&lt;&#x2F;code&gt;.  &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;amanjeev&#x2F;stm32l433love&#x2F;blob&#x2F;main&#x2F;Cargo.toml#L13&quot;&gt;See my &lt;code&gt;Cargo.toml&lt;&#x2F;code&gt; for details&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
&lt;h1 id=&quot;conclusion&quot;&gt;Conclusion&lt;&#x2F;h1&gt;
&lt;p&gt;I have failed but this was so much fun!  I will continue playing.&lt;&#x2F;p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Rust in Science and ever-changing requirements</title>
        <published>2020-09-12T00:00:00+00:00</published>
        <updated>2023-11-23T00:00:00+00:00</updated>
        
        <author>
          <name>
            
              Unknown
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://amanjeev.com/blog/rust-in-science-and-ever-changing-requirements/"/>
        <id>https://amanjeev.com/blog/rust-in-science-and-ever-changing-requirements/</id>
        
        <content type="html" xml:base="https://amanjeev.com/blog/rust-in-science-and-ever-changing-requirements/">&lt;p&gt;I have heard many times over that for a given proof-of-concept
if you have fast, changing requirements, then you are better off
with a &lt;a href=&quot;https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Dynamic_programming_language&quot;&gt;Dynamic programming language&lt;&#x2F;a&gt;
like Python. Python gives the illusion of faster development
because you do not have to think about the &lt;em&gt;rigidity&lt;&#x2F;em&gt; of the &lt;a href=&quot;https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Type_system&quot;&gt;Type system&lt;&#x2F;a&gt;
as much. Hence, it makes these dynamic languages good for prototyping and creating
proofs-of-concept.&lt;&#x2F;p&gt;
&lt;p&gt;However, in this essay, I am trying to dump some thoughts about
&lt;a href=&quot;https:&#x2F;&#x2F;www.rust-lang.org&#x2F;&quot;&gt;Rust&lt;&#x2F;a&gt; usage in scientific computation, its benefits,
and generic chatter in the community. I think using Rust has an advantage in an
ever-mutating environment like research and I think even for prototyping, Rust
can be much more beneficial than a language like Python.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;introduction&quot;&gt;Introduction&lt;&#x2F;h2&gt;
&lt;p&gt;I am very much in a love affair with Rust. This is not going to come to you as
a surprise at all if you &lt;a href=&quot;https:&#x2F;&#x2F;twitter.com&#x2F;amanjeev&quot;&gt;follow me on Twitter&lt;&#x2F;a&gt;.
Part of the reason is that I work as a software writer and general yak shaver
for science-(genomics)-adjacent work and I appreciate what Rust has to offer
in terms of the ecosystem, safety, and speed. I&#x27;d argue that a lot of work that
is usually written in C&#x2F;C++, Python, Perl, etc. could be replaced by Rust.&lt;&#x2F;p&gt;
&lt;p&gt;Perhaps I do not need to spend a lot of effort to convince you that
Rust can replace some C&#x2F;C++ codebase more easily because Rust is a
&lt;a href=&quot;https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;System_programming_language&quot;&gt;Systems programming language&lt;&#x2F;a&gt;.
But for proofs-of-concept, you ask, how can Rust be better than, say Python? Isn&#x27;t it
painful to change the code, which you do in early prototyping when you have to use a
Static language[1]?&lt;&#x2F;p&gt;
&lt;h2 id=&quot;the-case-of-python&quot;&gt;The case of Python&lt;&#x2F;h2&gt;
&lt;p&gt;When I started in the sciences as a programmer, reading Perl was always an issue and the choice
that I had to make was clear to me — I chose Python. Perl was slowly being displaced by Python
anyway. So, I will give you some anecdotal comparisons from my experiences.&lt;&#x2F;p&gt;
&lt;p&gt;You might think that I am comparing apples to oranges and you are absolutely correct. This is
an opinion blog post! I am choosing Python also because it is touted as the language
which makes life easier to work with given ever-changing requirements.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;ever-changing-requirements&quot;&gt;Ever-changing requirements&lt;&#x2F;h2&gt;
&lt;p&gt;One issue that I always hear is the idea of “refactoring” and&#x2F;or “changing course”.
Computation in sciences, they say, is a lot of trial and error. I find this to be true! I have worked in
novel projects where even the stakeholders (scientists) were learning while we were building the
projects. There is a lot of backtracking and honestly a lot of your &quot;software engineering&quot; breaks
down.&lt;&#x2F;p&gt;
&lt;p&gt;For this article, I am going to focus on some attributes of languages that instill
confidence in making the changes so that you can iterate. I believe the following attributes are necessary
to work with constantly changing requirements —&lt;&#x2F;p&gt;
&lt;ol&gt;
&lt;li&gt;Readability&lt;&#x2F;li&gt;
&lt;li&gt;Testability&lt;&#x2F;li&gt;
&lt;li&gt;Feedback&lt;&#x2F;li&gt;
&lt;li&gt;Toolchain&lt;&#x2F;li&gt;
&lt;&#x2F;ol&gt;
&lt;h3 id=&quot;readability&quot;&gt;Readability&lt;&#x2F;h3&gt;
&lt;h4 id=&quot;syntax&quot;&gt;Syntax&lt;&#x2F;h4&gt;
&lt;p&gt;The clear advantage of Python is its syntactic readability if you are considerate of that while writing
(but it does not always pan out!). This means that it is easier to keep the code in your head to make the model, while you
are making changes. Rust can be hard to read because it does not fit the imperative, object-oriented style
mental model we have with languages like Python. Rust’s ownership model and typing definitely have some
learning curve.&lt;&#x2F;p&gt;
&lt;p&gt;I have taught Git and Python to my colleagues and in many ways, they — and I — have had to
build new mental models for these tools as well, especially if they are already familiar with C++, Perl, and SVN,
CVS. Learning new mental models is what we do all the time. Still, I agree that this requires a lot of
effort on the programmer’s part. This is especially true for an experienced programmer.&lt;&#x2F;p&gt;
&lt;p&gt;As &lt;a href=&quot;https:&#x2F;&#x2F;twitter.com&#x2F;ekuber&quot;&gt;Esteban&lt;&#x2F;a&gt; says in his &lt;a href=&quot;https:&#x2F;&#x2F;youtu.be&#x2F;Z6X7Ada0ugE&quot;&gt;RustConf 2020 talk — Bending the
Curve: A Personal Tutor at Your Fingertips&lt;&#x2F;a&gt; —&lt;&#x2F;p&gt;
&lt;blockquote&gt;
&lt;p&gt;Rust has a curse, it has many but this one is critical — inefficient code is generally visible.
Experienced developers hate to notice that their code is inefficient.&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;h4 id=&quot;jumping-around-the-codebase&quot;&gt;Jumping around the codebase&lt;&#x2F;h4&gt;
&lt;p&gt;Rust is statically typed, empowers your editor or
&lt;a href=&quot;https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Integrated_development_environment&quot;&gt;Integrated Development Environment (IDE)&lt;&#x2F;a&gt;
to link the symbols in your code for easy access. A function defined somewhere in a &lt;code&gt;struct&lt;&#x2F;code&gt; can
be easily found from where it is called. This makes looking up code for dependencies much easier
and faster.&lt;&#x2F;p&gt;
&lt;p&gt;The only tool in Python that brings us any closer to this style of working is
&lt;a href=&quot;https:&#x2F;&#x2F;www.jetbrains.com&#x2F;pycharm&#x2F;&quot;&gt;JetBrains PyCharm&lt;&#x2F;a&gt;. And even this IDE for Python
fails to look up &lt;em&gt;symbols&lt;&#x2F;em&gt; if you mess up your
&lt;a href=&quot;https:&#x2F;&#x2F;docs.python.org&#x2F;3&#x2F;tutorial&#x2F;venv.html&quot;&gt;&lt;code&gt;virtualenv&lt;&#x2F;code&gt;&lt;&#x2F;a&gt; or fail to register it
with your PyCharm project. You can use &lt;a href=&quot;https:&#x2F;&#x2F;docs.python.org&#x2F;3&#x2F;library&#x2F;typing.html&quot;&gt;&lt;code&gt;typing&lt;&#x2F;code&gt;&lt;&#x2F;a&gt;
to annotate your code with the types but as you can see that there is a warning at the top of
&lt;a href=&quot;https:&#x2F;&#x2F;docs.python.org&#x2F;3&#x2F;library&#x2F;typing.html&quot;&gt;the &lt;code&gt;typing&lt;&#x2F;code&gt; documentation&lt;&#x2F;a&gt; -&lt;&#x2F;p&gt;
&lt;blockquote&gt;
&lt;p&gt;Note: The Python runtime does not enforce function and variable type annotations.
They can be used by third-party tools such as type checkers, IDEs, linters, etc.&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;p&gt;With Rust, you can survive with just the compiler because these types are a part of the
language. Add &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;rust-lang&#x2F;rls&quot;&gt;Rust Langauge Server (RLS)&lt;&#x2F;a&gt; to that and
you can comfortably navigate your codebase.&lt;&#x2F;p&gt;
&lt;h4 id=&quot;docs&quot;&gt;Docs!&lt;&#x2F;h4&gt;
&lt;p&gt;Since Rust is statically typed, you can see what is the expected type of each function
argument or what is the type of the value that the function returns. Its type system
becomes part of the documentation! Whereas in Python you have to use external tools and
depend on function annotations to generate documentation,
&lt;a href=&quot;https:&#x2F;&#x2F;doc.rust-lang.org&#x2F;rustdoc&#x2F;what-is-rustdoc.html&quot;&gt;Rust brings the documentation to you via &lt;code&gt;rustdoc&lt;&#x2F;code&gt;&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
&lt;p&gt;For example, please compare&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;python&quot; style=&quot;background-color:#eff1f5;color:#4f5b66;&quot; class=&quot;language-python &quot;&gt;&lt;code class=&quot;language-python&quot; data-lang=&quot;python&quot;&gt;&lt;span style=&quot;color:#b48ead;&quot;&gt;def &lt;&#x2F;span&gt;&lt;span style=&quot;color:#8fa1b3;&quot;&gt;chillin&lt;&#x2F;span&gt;&lt;span&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;name&lt;&#x2F;span&gt;&lt;span&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;place&lt;&#x2F;span&gt;&lt;span&gt;):
&lt;&#x2F;span&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a7adba;&quot;&gt;&amp;quot;&amp;quot;&amp;quot;Informs what&amp;#39;s the user&amp;#39;s chillin&amp;#39; number
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a7adba;&quot;&gt;
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a7adba;&quot;&gt;    @param name: string, name of the user
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a7adba;&quot;&gt;    @param palce: string, where the user is chillin&amp;#39;
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a7adba;&quot;&gt;    @return: int, information
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a7adba;&quot;&gt;    &amp;quot;&amp;quot;&amp;quot;
&lt;&#x2F;span&gt;&lt;span&gt;    result = &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d08770;&quot;&gt;0
&lt;&#x2F;span&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#b48ead;&quot;&gt;if &lt;&#x2F;span&gt;&lt;span&gt;place == &amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;toronto&lt;&#x2F;span&gt;&lt;span&gt;&amp;quot; {
&lt;&#x2F;span&gt;&lt;span&gt;        result = &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d08770;&quot;&gt;100
&lt;&#x2F;span&gt;&lt;span&gt;    }
&lt;&#x2F;span&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#b48ead;&quot;&gt;return &lt;&#x2F;span&gt;&lt;span&gt;result
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;with&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;rust&quot; style=&quot;background-color:#eff1f5;color:#4f5b66;&quot; class=&quot;language-rust &quot;&gt;&lt;code class=&quot;language-rust&quot; data-lang=&quot;rust&quot;&gt;&lt;span style=&quot;color:#a7adba;&quot;&gt;&#x2F;&#x2F;&#x2F; Create an alias to integer type
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a7adba;&quot;&gt;&#x2F;&#x2F;&#x2F; Now it is much clearer what the return type 
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a7adba;&quot;&gt;&#x2F;&#x2F;&#x2F;  of the function stands for
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#b48ead;&quot;&gt;type &lt;&#x2F;span&gt;&lt;span&gt;ChillinNum = &lt;&#x2F;span&gt;&lt;span style=&quot;color:#b48ead;&quot;&gt;u32&lt;&#x2F;span&gt;&lt;span&gt;;
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a7adba;&quot;&gt;&#x2F;&#x2F;&#x2F; Informs what&amp;#39;s the user&amp;#39;s chillin&amp;#39; number
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a7adba;&quot;&gt;&#x2F;&#x2F;&#x2F; * `name`: name of the user
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a7adba;&quot;&gt;&#x2F;&#x2F;&#x2F; * `place`: where the user is chillin&amp;#39;
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#b48ead;&quot;&gt;fn &lt;&#x2F;span&gt;&lt;span style=&quot;color:#8fa1b3;&quot;&gt;chillin&lt;&#x2F;span&gt;&lt;span&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;name&lt;&#x2F;span&gt;&lt;span&gt;: String, &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;place&lt;&#x2F;span&gt;&lt;span&gt;: &amp;amp;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#b48ead;&quot;&gt;str&lt;&#x2F;span&gt;&lt;span&gt;) -&amp;gt; ChillinNum {
&lt;&#x2F;span&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#b48ead;&quot;&gt;match&lt;&#x2F;span&gt;&lt;span&gt; place {
&lt;&#x2F;span&gt;&lt;span&gt;        &amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;toronto&lt;&#x2F;span&gt;&lt;span&gt;&amp;quot; =&amp;gt; &lt;&#x2F;span&gt;&lt;span style=&quot;color:#b48ead;&quot;&gt;return &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d08770;&quot;&gt;100&lt;&#x2F;span&gt;&lt;span&gt;,
&lt;&#x2F;span&gt;&lt;span&gt;        _ =&amp;gt; &lt;&#x2F;span&gt;&lt;span style=&quot;color:#b48ead;&quot;&gt;return &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d08770;&quot;&gt;0&lt;&#x2F;span&gt;&lt;span&gt;,
&lt;&#x2F;span&gt;&lt;span&gt;    }
&lt;&#x2F;span&gt;&lt;span&gt;}
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;It is a tiny example and while Rust&#x27;s syntax is denser, it also provides clarity on what
the elements stand for. Here, &lt;code&gt;ChillinNum&lt;&#x2F;code&gt; is the type of the return value. We could have just
used &lt;code&gt;u32&lt;&#x2F;code&gt; but using &lt;code&gt;ChillinNum&lt;&#x2F;code&gt; is clearer. If you run &lt;code&gt;cargo doc&lt;&#x2F;code&gt; in your codebase,
Rust compiler will take all these
triple-slash &lt;code&gt;&#x2F;&#x2F;&#x2F;&lt;&#x2F;code&gt; comments and generate nice documentation for you. You can see the
&lt;a href=&quot;https:&#x2F;&#x2F;docs.rs&#x2F;eyre&#x2F;0.6.0&#x2F;eyre&#x2F;&quot;&gt;documentation of the crate &lt;code&gt;eyre&lt;&#x2F;code&gt;&lt;&#x2F;a&gt; and the
&lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;yaahc&#x2F;eyre&#x2F;blob&#x2F;master&#x2F;src&#x2F;lib.rs&quot;&gt;source of the crate &lt;code&gt;eyre&lt;&#x2F;code&gt; that generates it&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;testability&quot;&gt;Testability&lt;&#x2F;h3&gt;
&lt;p&gt;Python has a ton of testing frameworks and Rust is slowly catching up. A clear advantage in favor
of Python. However, the things you are testing also dictate how much confidence you have in your
codebase. With the type system in Rust, you do not have to test for certain cases that in Python
you’d have to. This means there are certain test cases that you do not need to write if you’re
building your project in Rust. To me, this makes the iteration faster with more confidence in
the code I am writing.&lt;&#x2F;p&gt;
&lt;p&gt;As &lt;a href=&quot;https:&#x2F;&#x2F;twitter.com&#x2F;ekuber&quot;&gt;Esteban&lt;&#x2F;a&gt; puts it -&lt;&#x2F;p&gt;
&lt;blockquote&gt;
&lt;p&gt;The reduced need for tests is because of using patterns that leverage the type system
to completely eliminate the representability of an invalid state.&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;p&gt;Take Rust&#x27;s &lt;code&gt;match&lt;&#x2F;code&gt; pattern, as an example. The following code will fail to compile because
we failed to provide a catch-all -&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;rust&quot; style=&quot;background-color:#eff1f5;color:#4f5b66;&quot; class=&quot;language-rust &quot;&gt;&lt;code class=&quot;language-rust&quot; data-lang=&quot;rust&quot;&gt;&lt;span style=&quot;color:#a7adba;&quot;&gt;&#x2F;&#x2F;&#x2F; Create an alias to integer type
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a7adba;&quot;&gt;&#x2F;&#x2F;&#x2F; Now it is much clearer what the return type 
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a7adba;&quot;&gt;&#x2F;&#x2F;&#x2F;  of the function stands for
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#b48ead;&quot;&gt;type &lt;&#x2F;span&gt;&lt;span&gt;ChillinNum = &lt;&#x2F;span&gt;&lt;span style=&quot;color:#b48ead;&quot;&gt;u32&lt;&#x2F;span&gt;&lt;span&gt;;
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a7adba;&quot;&gt;&#x2F;&#x2F;&#x2F; Informs what&amp;#39;s the user&amp;#39;s chillin&amp;#39; number
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a7adba;&quot;&gt;&#x2F;&#x2F;&#x2F; * `name`: name of the user
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a7adba;&quot;&gt;&#x2F;&#x2F;&#x2F; * `place`: where the user is chillin&amp;#39;
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#b48ead;&quot;&gt;fn &lt;&#x2F;span&gt;&lt;span style=&quot;color:#8fa1b3;&quot;&gt;chillin&lt;&#x2F;span&gt;&lt;span&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;name&lt;&#x2F;span&gt;&lt;span&gt;: String, &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;place&lt;&#x2F;span&gt;&lt;span&gt;: &amp;amp;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#b48ead;&quot;&gt;str&lt;&#x2F;span&gt;&lt;span&gt;) -&amp;gt; ChillinNum {
&lt;&#x2F;span&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#b48ead;&quot;&gt;match&lt;&#x2F;span&gt;&lt;span&gt; place {
&lt;&#x2F;span&gt;&lt;span&gt;        &amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;toronto&lt;&#x2F;span&gt;&lt;span&gt;&amp;quot; =&amp;gt; &lt;&#x2F;span&gt;&lt;span style=&quot;color:#b48ead;&quot;&gt;return &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d08770;&quot;&gt;100&lt;&#x2F;span&gt;&lt;span&gt;,
&lt;&#x2F;span&gt;&lt;span&gt;    }
&lt;&#x2F;span&gt;&lt;span&gt;}
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Previously, we had provided the default&#x2F;catch-all case &lt;code&gt;_ =&amp;gt; return 0,&lt;&#x2F;code&gt;. Similarly, the Rust compiler
will complain if you are not covering all the variants of a Rust &lt;code&gt;enum&lt;&#x2F;code&gt; in your &lt;code&gt;match&lt;&#x2F;code&gt; pattern.
This helps the programmer in considering all the paths and cases. The compiler will show an error like this -&lt;&#x2F;p&gt;
&lt;pre style=&quot;background-color:#eff1f5;color:#4f5b66;&quot;&gt;&lt;code&gt;&lt;span&gt;error[E0004]: non-exhaustive patterns: `&amp;amp;_` not covered
&lt;&#x2F;span&gt;&lt;span&gt;  --&amp;gt; src&#x2F;main.rs:12:11
&lt;&#x2F;span&gt;&lt;span&gt;   |
&lt;&#x2F;span&gt;&lt;span&gt;12 |     match place {
&lt;&#x2F;span&gt;&lt;span&gt;   |           ^^^^^ pattern `&amp;amp;_` not covered
&lt;&#x2F;span&gt;&lt;span&gt;   |
&lt;&#x2F;span&gt;&lt;span&gt;   = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
&lt;&#x2F;span&gt;&lt;span&gt;   = note: the matched value is of type `&amp;amp;str`
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;I do not enjoy writing tests and eating my veggies but if I could eat fewer veggies to achieve the
same level of confidence in my changes, I’d always choose that.&lt;&#x2F;p&gt;
&lt;p&gt;This also brings me to the point of designing your project. Just because your project is in
alpha&#x2F;beta&#x2F;whateva, does not mean that you are not allowed to think about your data structures,
your types before the implementation. A little bit of thought in the structure of your codebase
goes a long way, especially when you have to change it. Once again, listen to &lt;a href=&quot;https:&#x2F;&#x2F;twitter.com&#x2F;ekuber&quot;&gt;Esteban&lt;&#x2F;a&gt; -&lt;&#x2F;p&gt;
&lt;blockquote&gt;
&lt;p&gt;Thinking about the API surface first and then changing the internal logic and in-memory
representation to make it faster&#x2F;more efficient is much easier in type-safe languages than in
dynamic languages, and more so in Rust simply because more things are represented in the type
system than is customary in other languages. This makes &quot;iteratively fixing the compiler errors&quot;
a valid refactoring strategy.&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;p&gt;These points, to me, sound like Rust has more advantages than Python if we count
Testing as a property of confidence in the changes we are making.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;feedback&quot;&gt;Feedback&lt;&#x2F;h3&gt;
&lt;p&gt;Even though Rust has its &lt;em&gt;new&lt;&#x2F;em&gt; paradigm issues[2] when it comes to learning the language, I still
feel that Rust compiler emits some of the most helpful error messages and help messages. The safety
features are built right into the compiler and the team has done a fantastic job so far in making
messages ergonomic. For example, in Rust, the array out of bounds error looks like this -&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;rust&quot; style=&quot;background-color:#eff1f5;color:#4f5b66;&quot; class=&quot;language-rust &quot;&gt;&lt;code class=&quot;language-rust&quot; data-lang=&quot;rust&quot;&gt;&lt;span style=&quot;color:#b48ead;&quot;&gt;let&lt;&#x2F;span&gt;&lt;span&gt; x: [&lt;&#x2F;span&gt;&lt;span style=&quot;color:#b48ead;&quot;&gt;u8&lt;&#x2F;span&gt;&lt;span&gt;; &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d08770;&quot;&gt;3&lt;&#x2F;span&gt;&lt;span&gt;] = [&lt;&#x2F;span&gt;&lt;span style=&quot;color:#d08770;&quot;&gt;10&lt;&#x2F;span&gt;&lt;span&gt;; &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d08770;&quot;&gt;3&lt;&#x2F;span&gt;&lt;span&gt;];    
&lt;&#x2F;span&gt;&lt;span&gt;println!(&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#d08770;&quot;&gt;{:?}&lt;&#x2F;span&gt;&lt;span&gt;&amp;quot;, x[&lt;&#x2F;span&gt;&lt;span style=&quot;color:#d08770;&quot;&gt;4&lt;&#x2F;span&gt;&lt;span&gt;]);
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;pre data-lang=&quot;rust&quot; style=&quot;background-color:#eff1f5;color:#4f5b66;&quot; class=&quot;language-rust &quot;&gt;&lt;code class=&quot;language-rust&quot; data-lang=&quot;rust&quot;&gt;&lt;span&gt;error: this operation will panic at runtime
&lt;&#x2F;span&gt;&lt;span&gt;  --&amp;gt; src&#x2F;main.rs:&lt;&#x2F;span&gt;&lt;span style=&quot;color:#d08770;&quot;&gt;23&lt;&#x2F;span&gt;&lt;span&gt;:&lt;&#x2F;span&gt;&lt;span style=&quot;color:#d08770;&quot;&gt;22
&lt;&#x2F;span&gt;&lt;span&gt;   |
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#d08770;&quot;&gt;23 &lt;&#x2F;span&gt;&lt;span&gt;|     println!(&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#d08770;&quot;&gt;{:?}&lt;&#x2F;span&gt;&lt;span&gt;&amp;quot;, x[&lt;&#x2F;span&gt;&lt;span style=&quot;color:#d08770;&quot;&gt;4&lt;&#x2F;span&gt;&lt;span&gt;]);
&lt;&#x2F;span&gt;&lt;span&gt;   |                      ^^^^^ index out of &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;bounds&lt;&#x2F;span&gt;&lt;span&gt;: the len is 3 but the index is 4
&lt;&#x2F;span&gt;&lt;span&gt;   |
&lt;&#x2F;span&gt;&lt;span&gt;   = note: `#[&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;deny&lt;&#x2F;span&gt;&lt;span&gt;(unconditional_panic)]` on by default
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;For Python, this looks like this -&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;python&quot; style=&quot;background-color:#eff1f5;color:#4f5b66;&quot; class=&quot;language-python &quot;&gt;&lt;code class=&quot;language-python&quot; data-lang=&quot;python&quot;&gt;&lt;span&gt;x = [&lt;&#x2F;span&gt;&lt;span style=&quot;color:#d08770;&quot;&gt;10&lt;&#x2F;span&gt;&lt;span&gt;,&lt;&#x2F;span&gt;&lt;span style=&quot;color:#d08770;&quot;&gt;10&lt;&#x2F;span&gt;&lt;span&gt;,&lt;&#x2F;span&gt;&lt;span style=&quot;color:#d08770;&quot;&gt;10&lt;&#x2F;span&gt;&lt;span&gt;]
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#96b5b4;&quot;&gt;print&lt;&#x2F;span&gt;&lt;span&gt;(x[&lt;&#x2F;span&gt;&lt;span style=&quot;color:#d08770;&quot;&gt;4&lt;&#x2F;span&gt;&lt;span&gt;])
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;pre data-lang=&quot;python&quot; style=&quot;background-color:#eff1f5;color:#4f5b66;&quot; class=&quot;language-python &quot;&gt;&lt;code class=&quot;language-python&quot; data-lang=&quot;python&quot;&gt;&lt;span&gt;    File &amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;app.py&lt;&#x2F;span&gt;&lt;span&gt;&amp;quot;, line &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d08770;&quot;&gt;3&lt;&#x2F;span&gt;&lt;span&gt;, in &amp;lt;module&amp;gt;
&lt;&#x2F;span&gt;&lt;span&gt;        &lt;&#x2F;span&gt;&lt;span style=&quot;color:#96b5b4;&quot;&gt;print&lt;&#x2F;span&gt;&lt;span&gt;(x[&lt;&#x2F;span&gt;&lt;span style=&quot;color:#d08770;&quot;&gt;4&lt;&#x2F;span&gt;&lt;span&gt;])
&lt;&#x2F;span&gt;&lt;span&gt;IndexError: list index out of &lt;&#x2F;span&gt;&lt;span style=&quot;color:#96b5b4;&quot;&gt;range
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;We&#x27;ve already seen an error message above for missing catch-all but let me show that again -&lt;&#x2F;p&gt;
&lt;pre style=&quot;background-color:#eff1f5;color:#4f5b66;&quot;&gt;&lt;code&gt;&lt;span&gt;error[E0004]: non-exhaustive patterns: `&amp;amp;_` not covered
&lt;&#x2F;span&gt;&lt;span&gt;  --&amp;gt; src&#x2F;main.rs:12:11
&lt;&#x2F;span&gt;&lt;span&gt;   |
&lt;&#x2F;span&gt;&lt;span&gt;12 |     match place {
&lt;&#x2F;span&gt;&lt;span&gt;   |           ^^^^^ pattern `&amp;amp;_` not covered
&lt;&#x2F;span&gt;&lt;span&gt;   |
&lt;&#x2F;span&gt;&lt;span&gt;   = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
&lt;&#x2F;span&gt;&lt;span&gt;   = note: the matched value is of type `&amp;amp;str`
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Side note: It is amazing that languages can and do learn from each other and copy parts that seem
helpful for the users. One recent exciting case is &lt;a href=&quot;https:&#x2F;&#x2F;devblogs.microsoft.com&#x2F;cppblog&#x2F;new-safety-rules-in-c-core-check&#x2F;&quot;&gt;New safety rules in C++ Core
Check&lt;&#x2F;a&gt;. I am very happy to have other
languages learn, as Rust has from what came before.&lt;&#x2F;p&gt;
&lt;p&gt;I hope you can appreciate the effort being put into the compiler and its error messages. Once
again, &lt;a href=&quot;https:&#x2F;&#x2F;twitter.com&#x2F;ekuber&quot;&gt;Esteban&lt;&#x2F;a&gt;’s talk is a fantastic watch,
&lt;a href=&quot;https:&#x2F;&#x2F;www.youtube.com&#x2F;embed&#x2F;Z6X7Ada0ugE&quot;&gt;where he talks about the Rust compiler as a tutor&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
&lt;blockquote&gt;
&lt;p&gt;When we are emitting diagnostic errors, it is the perfect place and moment to teach
people [that] they have made a mistake and we can explain to them why they made it.&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;p&gt;I will embed the talk here for you —&lt;&#x2F;p&gt;
&lt;div&gt;
    &lt;iframe
        src=&quot;https:&#x2F;&#x2F;www.youtube.com&#x2F;embed&#x2F;Z6X7Ada0ugE&quot;
        webkitallowfullscreen
        mozallowfullscreen
        allowfullscreen&gt;
    &lt;&#x2F;iframe&gt;
&lt;&#x2F;div&gt;
&lt;p&gt;Python, on the other hand, had me stuck for a whole day because it complained
somewhere I was scripting &lt;code&gt;NoneType&lt;&#x2F;code&gt;. If you care, this is the pet peeve that started this blog post.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;toolchain&quot;&gt;Toolchain&lt;&#x2F;h3&gt;
&lt;p&gt;In the Python world, the packaging and environment setup is still something that makes me sad. The
closest I have come to create some sanity in my life is to use &lt;code&gt;direnv&lt;&#x2F;code&gt; and &lt;code&gt;shell.nix&lt;&#x2F;code&gt; in my
repositories. This sucks because this is a solution that is at the OS (NixOS) level[3].
Indeed there are tools available for auto-loading environments, and I am thankful for that.
However, Python toolset feels like a moving target.
Years ago, it was just &lt;code&gt;setup.py&lt;&#x2F;code&gt; and today it is &lt;code&gt;setup.cfg&lt;&#x2F;code&gt;, &lt;code&gt;pyproject.toml&lt;&#x2F;code&gt; as well but
the latter two do not support all the features so you end up having &lt;code&gt;setup.py&lt;&#x2F;code&gt; in your codebase.
Here, &lt;a href=&quot;https:&#x2F;&#x2F;snarky.ca&#x2F;what-the-heck-is-pyproject-toml&#x2F;&quot;&gt;let Tall, Snarky Canadian explain it to you&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
&lt;p&gt;On the Rust side though, the ease of use of &lt;code&gt;cargo&lt;&#x2F;code&gt; and &lt;code&gt;rustup&lt;&#x2F;code&gt; has not been beaten for me,
so far. The Rust ecosystem is young and has the advantage of learning from other platforms.&lt;&#x2F;p&gt;
&lt;p&gt;Something else that made me happy about Rust is the promise of backward compatibility. Most of us
have been burnt with Python 2 to 3 move although I am in awe of the Python community that undertook
such a massive effort and made it happen.&lt;&#x2F;p&gt;
&lt;p&gt;The biggest disadvantage in Python that I see is that if I move a module out of a package, it is
much harder for my editor to figure out the details of my refactoring. PyCharm has made my life
much easier but there are cases where it fails because it can do only so much with a dynamic language.
This is obvious because Python is a dynamic language. My good friend, &lt;a href=&quot;https:&#x2F;&#x2F;twitter.com&#x2F;ekuber&quot;&gt;Esteban&lt;&#x2F;a&gt;
once again nails it -&lt;&#x2F;p&gt;
&lt;blockquote&gt;
&lt;p&gt;The kind of dynamism that Python has, where almost everything
you write is valid code, can be a behavior you did not want, makes it harder to write a Python
interpreter that helps you get back on track. Rust leverages its rigid syntax to simultaneously
keep the language simpler than it otherwise would be and to make it easier to figure out what
the user was actually intending to do.&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;p&gt;While this does allow us to write code without thinking too much about types, it does not give
us a lot of confidence when we are changing the code. This means that one can likely write much
faster in Python, but to change the code for new requirements is much harder because it is likely
to be error-prone.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;not-all-is-ready-yet&quot;&gt;Not all is ready, yet&lt;&#x2F;h2&gt;
&lt;p&gt;I do not think that a piece should be entirely replaced, just because it can be.
Some tools being used are more mature than Rust is at the moment. However, there
are clear benefits to be had. I am happy to report that I am &lt;a href=&quot;https:&#x2F;&#x2F;benjamin.computer&#x2F;posts&#x2F;2019-07-31-rust-research.html&quot;&gt;not the only one who
feels&lt;&#x2F;a&gt; &lt;a href=&quot;https:&#x2F;&#x2F;blog.luizirber.org&#x2F;2018&#x2F;08&#x2F;23&#x2F;sourmash-rust&#x2F;&quot;&gt;this way in (some of)
the&lt;&#x2F;a&gt;
&lt;a href=&quot;https:&#x2F;&#x2F;rust-bio.github.io&#x2F;&quot;&gt;community&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
&lt;p&gt;There is some way to go with the data structures and libraries etc. but I think it is a
chicken-and-egg problem and as the adoption increases there will be more libraries available. &lt;a href=&quot;https:&#x2F;&#x2F;doc.rust-lang.org&#x2F;nomicon&#x2F;ffi.html&quot;&gt;The
best part is that you can do piecemeal work by delegating parts of your codebase to Rust using
FFI&lt;&#x2F;a&gt;.
&lt;a href=&quot;https:&#x2F;&#x2F;blog.luizirber.org&#x2F;2020&#x2F;01&#x2F;10&#x2F;sourmash-pr&#x2F;&quot;&gt;Let Luiz explain it to you how he works in his research with Rust and Python!&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;h2 id=&quot;static-for-dynamicity&quot;&gt;Static for dynamicity&lt;&#x2F;h2&gt;
&lt;p&gt;This is where I would conclude that if you are starting a journey and are sure that the things will
change many times over, you may be better off with a language that gives you&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;a solid structure to build upon with&lt;&#x2F;li&gt;
&lt;li&gt;tools to warn you when parts of that structures are moved&lt;&#x2F;li&gt;
&lt;li&gt;by giving your advice on “why”, “where” and “how” to do that&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;I also conclude that you could leverage Rust to replace parts of your project that
require more safety and speed.&lt;&#x2F;p&gt;
&lt;p&gt;I enjoy writing Python because of its syntax but I keep missing the Rust compiler&#x27;s help every day.&lt;&#x2F;p&gt;
&lt;p&gt;Once again, this article would not have been possible without the help and guidance of the following
friends -&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https:&#x2F;&#x2F;hoverbear.org&#x2F;&quot;&gt;Ana Hobden&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;li&gt;&lt;a href=&quot;https:&#x2F;&#x2F;twitter.com&#x2F;ekuber&quot;&gt;Esteban Küber&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;li&gt;Shveta Kumar&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;[1] I am sorry but I am taking a generic leeway to combine Dynamic languages with Dynamically
typed languages and Static languages with Statically typed languages&lt;&#x2F;p&gt;
&lt;p&gt;[2] They are rather non-mainstream because Rust &lt;em&gt;borrows&lt;&#x2F;em&gt; almost everything from other languages
but you get the idea&lt;&#x2F;p&gt;
&lt;p&gt;[3] If you want to know how to manage your work environment for a project using NixOS and &lt;code&gt;direnv&lt;&#x2F;code&gt;, you can read
my small blog post about
&lt;a href=&quot;https:&#x2F;&#x2F;amanjeev.com&#x2F;blog&#x2F;nix-shell-manage-project-dependencies&quot;&gt;Environment management with nix-shell&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>A year in CanDIG project</title>
        <published>2020-07-06T00:00:00+00:00</published>
        <updated>2020-07-06T00:00:00+00:00</updated>
        
        <author>
          <name>
            
              Unknown
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://amanjeev.com/blog/one-year-at-candig/"/>
        <id>https://amanjeev.com/blog/one-year-at-candig/</id>
        
        <content type="html" xml:base="https://amanjeev.com/blog/one-year-at-candig/">&lt;p&gt;Last month, I completed a year in my current project -
&lt;a href=&quot;https:&#x2F;&#x2F;www.distributedgenomics.ca&#x2F;&quot;&gt;CanDIG&lt;&#x2F;a&gt;. This project is about building
a platform to connect &quot;data lakes&quot; within Canadian institutions in a federated
manner. I was hired to mostly do &lt;a href=&quot;https:&#x2F;&#x2F;www.distributedgenomics.ca&#x2F;posts&#x2F;gentle-intro-to-federated-distributed-authz&#x2F;index.html&quot;&gt;federated authorization, which you can read
about in this blog post on CanDIG&#x27;s blog&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
&lt;p&gt;Those who do not know, I have spent the past few years
in the Genomics area but mostly on the side of software infrastructure. Some of
the Biology and Genomics knowledge that I have is courtesy
&lt;a href=&quot;https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Donna_R._Maglott&quot;&gt;Donna Maglott&lt;&#x2F;a&gt; at NCBI.&lt;&#x2F;p&gt;
&lt;p&gt;However, I left United States for Canada, once I found a project that I
was excited about, and of course, never again have to worry about H1B Visa
or the immigration system in US. Having worked a year in the team, I have learned
a few things in general that I thought are worth sharing.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;value-matching-with-the-team-and-project&quot;&gt;Value matching with the team and project&lt;&#x2F;h2&gt;
&lt;p&gt;Even though I have mostly worked solo due to the nature of AAI work,
it is a tremendous help to work in a team that matches your values.
Collaboration with other colleagues on projects that overlap with my goals makes me happy.
For example, on the &quot;Dynamic Consents&quot; project with an esteemed colleague that allows for
patients to give their consent, and change the consent (either granularity or revocation)
if they want while taking into account aspects like the accessibility of remote communities
in Canada. I love the fact that our team is taking into account various social issues
that hinder marginalized communities&#x27; participation, representation, and ownership of their data.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;love-hate-relationship-with-software-development-in-science&quot;&gt;Love-Hate relationship with software development in science&lt;&#x2F;h2&gt;
&lt;p&gt;At the time of this writing, there has been a lot of improvement in
scientific computing and software development. There are
organizations, like &lt;a href=&quot;https:&#x2F;&#x2F;researchsoftware.org&#x2F;&quot;&gt;RSE&lt;&#x2F;a&gt;, that are helping move
the state of the scientific software to a better place. However, there is a lot
that remains to be desired. This is also good news for people like me because
that allows us to voice the concerns and keep our job.&lt;&#x2F;p&gt;
&lt;p&gt;I also believe that most of the time, as a scientific software developer
you can work on a variety of projects and tasks which keep your tech-life
less monotonous. I understand, that for some people, shaving Python yaks is
also monotonous but as long as I get leeway to learn and grow, I am happy.&lt;&#x2F;p&gt;
&lt;p&gt;The part that I am most concerned about (still) is licensing. A lot of professors
in a lot of places are not happy with Copyleft licenses and I am not sure why. I
have written a &lt;a href=&quot;https:&#x2F;&#x2F;amanjeev.com&#x2F;blog&#x2F;scientific-software-license&quot;&gt;blog post about this question on Copyleft licenses in scientific
software&lt;&#x2F;a&gt;. I still do not
have a good answer as to why we should avoid Copyleft licenses when they serve the Science
more than other licenses, representing the true spirit of Science.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;don-t-roll-your-own-crypto&quot;&gt;Don&#x27;t roll your own crypto&lt;&#x2F;h2&gt;
&lt;p&gt;A lot of work within the group was related to AAI and there are a bunch of things
that you can do by yourself. However, there are likely tools available that you can leverage
without having to write those on your own. The point is that the quote &quot;don&#x27;t roll
your own crypto&quot; is not just for the crypto algorithms or PKI
etc. It can be for small things like releasing or signing &lt;a href=&quot;https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;JSON_Web_Token&quot;&gt;JWT&lt;&#x2F;a&gt;s.
Yes, you read that right - JWTs! Please don&#x27;t judge, we need JWTs because we use OIDC (more later).
It is super easy to slip into &quot;build your own&quot; for smaller things. So far, we&#x27;ve avoided
that by using Keycloak, Tyk, and libraries for differential privacy, etc. and hopefully will
continue on that trajectory by using products like &lt;a href=&quot;https:&#x2F;&#x2F;www.vaultproject.io&#x2F;&quot;&gt;Hashicorp Vault&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;federated-distributed-and-other-overloaded-terms&quot;&gt;Federated, Distributed and other overloaded terms&lt;&#x2F;h2&gt;
&lt;p&gt;I never thought I&#x27;d even look at something like &lt;a href=&quot;https:&#x2F;&#x2F;openid.net&#x2F;connect&#x2F;&quot;&gt;OIDC&lt;&#x2F;a&gt; in my career
but here I am. I have now achieved two things in the year -&lt;&#x2F;p&gt;
&lt;ol&gt;
&lt;li&gt;Perform cross-atlantic (Europe+Canada) connection of resources (e.g. genomic services)
which allow for both sides to log into each other&#x27;s instances and be authorized at different
levels just by using OIDC. This could be called federated authorization.&lt;&#x2F;li&gt;
&lt;li&gt;CanDIG&#x27;s first draft of authorization, which is a distributed infrastructure that connects multiple sites within Canada
to share genomic data. This authorization can also be called federated authorization.&lt;&#x2F;li&gt;
&lt;&#x2F;ol&gt;
&lt;p&gt;The European infrastructure is much more centralized so the challenges in tying them with
our infrastructure are different than what we are building within CanDIG and Canada. What we
are doing within CanDIG is much more difficult because we certainly do not have the leeway
that a centralized system has, where an alias of the external user can be created to facilitate
communication. The terms are &lt;em&gt;definitely&lt;&#x2F;em&gt; overloaded!&lt;&#x2F;p&gt;
&lt;p&gt;But as you can see, the issue is that we need to use a protocol that -&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;supports complex authorization and permission schemes (don&#x27;t roll your eyes)&lt;&#x2F;li&gt;
&lt;li&gt;can be extended with custom permissions and claims&lt;&#x2F;li&gt;
&lt;li&gt;is open&lt;&#x2F;li&gt;
&lt;li&gt;supported in a wide variety of cases and products&lt;&#x2F;li&gt;
&lt;li&gt;is documented (enough)&lt;&#x2F;li&gt;
&lt;li&gt;can be agreed upon by scientists from across the globe&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;Much of this work is being done in &lt;a href=&quot;https:&#x2F;&#x2F;www.cineca-project.eu&#x2F;&quot;&gt;CINECA project&lt;&#x2F;a&gt;
and a lot of input to and from &lt;a href=&quot;https:&#x2F;&#x2F;www.ga4gh.org&#x2F;&quot;&gt;GA4GH&lt;&#x2F;a&gt;. There are very few
protocols that come close to what exists in the form of OIDC. Let me be clear, I hate
it. However, I do not have much say and I do not have any suggestions either. If you are
saying &quot;Build your own&quot; then please see the previous point. It is ridiculously hard to
come to consensus in any such scientific gathering and then there is the question of $$$.&lt;&#x2F;p&gt;
&lt;p&gt;And I &lt;em&gt;have&lt;&#x2F;em&gt; looked into https:&#x2F;&#x2F;oauth.xyz&#x2F; and no it is not ready yet and I do not
even know if it is going to be any better, yet. Complexity breeds issues but some of
the problems at-hand require complex solutions. Sure, OIDC is complicated as well.&lt;&#x2F;p&gt;
&lt;p&gt;I appreciate you read so far what seems like a brain dump of last year. Here&#x27;s to another
year with a focus on systems, Rust, privacy, and federation!&lt;&#x2F;p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>My process for bibliography and notes</title>
        <published>2020-06-24T00:00:00+00:00</published>
        <updated>2020-06-24T00:00:00+00:00</updated>
        
        <author>
          <name>
            
              Unknown
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://amanjeev.com/blog/bibliography-and-notes/"/>
        <id>https://amanjeev.com/blog/bibliography-and-notes/</id>
        
        <content type="html" xml:base="https://amanjeev.com/blog/bibliography-and-notes/">&lt;p&gt;For those who are starting new in research, you might want to keep running notes
and citations for the relavant research papers, journals, books etc. that you
come across. This helps maintain clarity of what is important, what has been
read already and the notes that help you revisit the material if and when you
need to.&lt;&#x2F;p&gt;
&lt;p&gt;After a decade and half worth of haitus, I am starting to delve into research
once again. This means reading papers more than I am used to. During my tenure
as software engineer in various organizations, most papers I had read were
limited and I could afford to read them as many times as I wanted.&lt;&#x2F;p&gt;
&lt;p&gt;Things have changed now and I need tools and new habits to help me navigate
through a ton of literature. I cannot afford to spend countless hours on one
paragraph in one paper. Above all, I cannot afford to think that all papers
and books are created equal and have the same value for my research and
eventual PoC that I have to deliver.&lt;&#x2F;p&gt;
&lt;p&gt;Here are a few things I am trying to achieve&lt;&#x2F;p&gt;
&lt;ol&gt;
&lt;li&gt;Forming new habits
&lt;ul&gt;
&lt;li&gt;ability to skim papers&lt;&#x2F;li&gt;
&lt;li&gt;jotting down quick notes for the papers&lt;&#x2F;li&gt;
&lt;li&gt;peruse references if interesting and get those references&lt;&#x2F;li&gt;
&lt;li&gt;revist the papers for deeper read if needed&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;&#x2F;li&gt;
&lt;li&gt;A way to manage a &quot;to-read&quot; list of papers&lt;&#x2F;li&gt;
&lt;li&gt;A way to manage &quot;already-read&quot; list of papers&lt;&#x2F;li&gt;
&lt;li&gt;Tag papers that need revisiting for deeper read&lt;&#x2F;li&gt;
&lt;&#x2F;ol&gt;
&lt;p&gt;As you can tell, I do not want a mere list of citations that I have read for
my research and projects. I want a traceable way to know what I read, as well
as why it was important. Here is an approach I am starting with -&lt;&#x2F;p&gt;
&lt;h2 id=&quot;start-with-a-book-on-the-research-if-available-skim-it-first&quot;&gt;Start with a book on the research, if available. Skim it first.&lt;&#x2F;h2&gt;
&lt;p&gt;A book allows easy introduction to the topic without having to figure out
which papers to read first on that topic. If a decent book is not available
for the field&#x2F;topic, there might be a way to start with early review papers
or first papers.&lt;&#x2F;p&gt;
&lt;p&gt;Note: At the time of writing, I am not aware of anything else to alleviate
some starting pains.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;why-skim&quot;&gt;Why skim&lt;&#x2F;h3&gt;
&lt;p&gt;It is critical that I skim the book to break the habit of deep reading in first
pass. If I am spending too much time going deep and trying to retain everything
I am losing out on getting a broad idea of the topic at hand. I need to be have
broad knowledge as soon as possible so I can then drill down into specifics.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;keep-short-notes&quot;&gt;Keep short notes&lt;&#x2F;h2&gt;
&lt;p&gt;Skimming does not mean that you avoid taking notes. You aren&#x27;t reading a novel
after all (although I have been known to keep notes on novels). Keeping such
notes allows you to come back to them to decide whether something was worthwhile
and requires deeper reading. I try to keep notes of the following things:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;Chapter names and general idea&lt;&#x2F;li&gt;
&lt;li&gt;List of topics each chapter covers&lt;&#x2F;li&gt;
&lt;li&gt;Mark&#x2F;tag a chapter important or to revisit&lt;&#x2F;li&gt;
&lt;li&gt;List of reference from each chapter that you want to fetch&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;These notes enhance your bibliography.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;next&quot;&gt;Next&lt;&#x2F;h2&gt;
&lt;p&gt;If you are comfortable at the end, maybe it is worthwhile to revisit the
chapters you&#x27;ve marked and fetching the references. I personally fetch all
the references at the end of each chapter, if I can. At this time, mark all
the papers and chapters yet again if they need revisiting. Tag them further
to make sure you can search for them later when you need them.&lt;&#x2F;p&gt;
&lt;p&gt;I find keeping at most three tags just enough to have entropy under control,
at the same time not losing my sould in tagging everything.&lt;&#x2F;p&gt;
&lt;blockquote&gt;
&lt;p&gt;Remember, the goal is to manage the items and related notes to quickly make a
decision on important aspects of the topic at hand.&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;p&gt;Another cycle of skimming, taking notes, and moving to next starts!&lt;&#x2F;p&gt;
&lt;p&gt;I hope this will help me build an intuition by helping with new habits
of swimming through the giant corpus of any topic that I want to study.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;tools&quot;&gt;Tools&lt;&#x2F;h2&gt;
&lt;h3 id=&quot;save-and-synchronize-papers&quot;&gt;Save and synchronize papers&lt;&#x2F;h3&gt;
&lt;p&gt;I started using &lt;a href=&quot;https:&#x2F;&#x2F;www.zotero.org&#x2F;&quot;&gt;Zotero&lt;&#x2F;a&gt; and it has been working fine so far. Some of the
key features that I find useful -&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;Easy, one-click fetching and saving of papers (browser plugins available)&lt;&#x2F;li&gt;
&lt;li&gt;Ability to tag them as well as create &quot;collections&quot; to manage files&lt;&#x2F;li&gt;
&lt;li&gt;Ability to add notes to the papers&lt;&#x2F;li&gt;
&lt;li&gt;Syncrhonizing your papers list, notes and everything under the Sun&lt;&#x2F;li&gt;
&lt;li&gt;Works on Linux!&lt;&#x2F;li&gt;
&lt;li&gt;Works with third-party apps on mobile devices and tablets&lt;&#x2F;li&gt;
&lt;li&gt;Advanced search that you can save&lt;&#x2F;li&gt;
&lt;li&gt;Ability to generate ciatations and reports from each item&lt;&#x2F;li&gt;
&lt;li&gt;You can export your data&lt;&#x2F;li&gt;
&lt;li&gt;Free for upto 300MB of storage for synchronization&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;On my iPad, where I do most of the reading, I use &lt;a href=&quot;https:&#x2F;&#x2F;www.papershipapp.com&#x2F;&quot;&gt;PaperShip&lt;&#x2F;a&gt; with &lt;a href=&quot;https:&#x2F;&#x2F;www.zotero.org&#x2F;&quot;&gt;Zotero&lt;&#x2F;a&gt;
account.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;search-and-discover-papers&quot;&gt;Search and discover papers&lt;&#x2F;h3&gt;
&lt;p&gt;A few places I go to, to search papers and to discover new papers.&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http:&#x2F;&#x2F;arxiv.org&#x2F;&quot;&gt;arXiv&lt;&#x2F;a&gt; - a preprint to find stuff sooner&lt;&#x2F;li&gt;
&lt;li&gt;&lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;karpathy&#x2F;arxiv-sanity-preserver&quot;&gt;arXiv Sanity&lt;&#x2F;a&gt; - a self hosted private instance for my areas of interest&lt;&#x2F;li&gt;
&lt;li&gt;&lt;a href=&quot;https:&#x2F;&#x2F;www.semanticscholar.org&#x2F;&quot;&gt;Semantic Scholar&lt;&#x2F;a&gt; - Also allows you to create feeds for papers of interest&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;h3 id=&quot;notes-and-tags&quot;&gt;Notes and tags&lt;&#x2F;h3&gt;
&lt;p&gt;I add quick notes in Zotero as well as use local Emacs+Markdown and push the
notes to GitHub (or &lt;a href=&quot;https:&#x2F;&#x2F;sourcehut.org&#x2F;&quot;&gt;SourceHut&lt;&#x2F;a&gt; if you hate GitHub because of ICE).&lt;&#x2F;p&gt;
&lt;p&gt;I save papers in particular collections in Zotero and tag the papers frequently.
For example, I tag &quot;done-reading&quot; when I am done reading and I have a saved
search that quickly lets me see all papers I have already read. Another saved
search allows me to quickly see all &quot;to read&quot; papers.&lt;&#x2F;p&gt;
&lt;p&gt;I have been using &quot;Cite&quot; feature of Zotero and Semantic Scholar to create the
title of each item in the bibliography and underneath that I jot down notes and
other relevant details like links.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;feedback&quot;&gt;Feedback&lt;&#x2F;h2&gt;
&lt;p&gt;I would love to hear what has worked for you. Is there something I am missing.
Reach out to me via email or twitter.&lt;&#x2F;p&gt;
&lt;p&gt;Many thanks to &lt;a href=&quot;https:&#x2F;&#x2F;www.dursi.ca&#x2F;&quot;&gt;Jonathan Dursi&lt;&#x2F;a&gt; for constantly helping me improve this process.&lt;&#x2F;p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Why on Earth are copyleft software licenses bad for scientific software?</title>
        <published>2020-03-21T00:00:00+00:00</published>
        <updated>2020-03-21T00:00:00+00:00</updated>
        
        <author>
          <name>
            
              Unknown
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://amanjeev.com/blog/copyleft-licenses-scientific-software/"/>
        <id>https://amanjeev.com/blog/copyleft-licenses-scientific-software/</id>
        
        <content type="html" xml:base="https://amanjeev.com/blog/copyleft-licenses-scientific-software/">&lt;p&gt;My quest for this blog started with the discussion about the choice of license for the software under Open Differential Privacy (OpenDP) Initiative[17]. I wanted to understand why &lt;a href=&quot;https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Copyleft&quot;&gt;copyleft licenses&lt;&#x2F;a&gt; are a taboo in Scientific circles. OpenDP choosing &lt;a href=&quot;https:&#x2F;&#x2F;mit-license.org&#x2F;&quot;&gt;MIT license&lt;&#x2F;a&gt; prompted me to ask why wasn&#x27;t something like &lt;a href=&quot;https:&#x2F;&#x2F;www.gnu.org&#x2F;licenses&#x2F;agpl-3.0.en.html&quot;&gt;AGPL&lt;&#x2F;a&gt; used. I got this as an answer:&lt;&#x2F;p&gt;
&lt;p&gt;https:&#x2F;&#x2F;twitter.com&#x2F;cbavitz&#x2F;status&#x2F;1260662650230505472?s=20&lt;&#x2F;p&gt;
&lt;p&gt;This answer prompted a feeling I have been harboring for a while — no one explains what exactly is wrong with the copyleft licenses and why they restrict adoption and participation.&lt;&#x2F;p&gt;
&lt;p&gt;I and many countless others have been involved in some kind of scientific field as software programmers. We, the research software engineers, now even have our own organizations[18]! In a lot of ways, the scientific programming community is a bit behind the commercial software world. This is certainly true for best-practices, tools, etc. but it is also true for software licensing. In this post, you will get a glimpse of the most prominent (or prominently searchable) software licensing discussion in the scientific community.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;disclosure&quot;&gt;Disclosure&lt;&#x2F;h2&gt;
&lt;p&gt;For me, being in sciences gives the benefit of learning something new and help support scientific discovery along the way. I believe that copyleft licenses are truly aligned with the academic and scientific pursuit. I understand that commercial companies and folks who work there are vocal about not using copyleft licenses but I believe that for scientific knowledge to thrive, we need to use more copyleft licenses.&lt;&#x2F;p&gt;
&lt;p&gt;Also, this blog post will focus on non-military software. The kind of software that is not under an embargo or security curtains.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;types-of-scientific-software&quot;&gt;Types of scientific software&lt;&#x2F;h2&gt;
&lt;p&gt;My experience mostly comes from genomics and adjacent areas. It is important to note that in this area, the privacy of individuals is critical and so is their data.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;software-accompanying-research-paper-s&quot;&gt;Software accompanying research paper(s)&lt;&#x2F;h3&gt;
&lt;p&gt;This is the most common piece of software associated with scientific work and is generally published somewhere. This type of software can be a library, framework or even a hosted service with its source code hosted somewhere else. Most of the time, these are repositories sitting on GitHub that have not been touched since the paper was published. Some are even with open pull requests and issues with no response from the owner of the repository. But this rant is for another day.&lt;&#x2F;p&gt;
&lt;p&gt;You may think of this as a basic proof-of-concept that is not to be used in any production level work.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;software-accompanied-by-research-paper-s&quot;&gt;Software accompanied by research paper(s)&lt;&#x2F;h3&gt;
&lt;p&gt;These are the tools and frameworks that help run scientific research projects. Software published by NCBI or NASA that facilitates researchers in their respective fields to run computations or simulations could be seen as this type of software. Or you can think of tools like NumPy, SciPy, etc. My current work project — CanDIG[19] — is of a similar kind.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;commentary-on-licensing-in-the-scientific-community&quot;&gt;Commentary on licensing in the scientific community&lt;&#x2F;h2&gt;
&lt;p&gt;The most common papers and articles that I could find are from &lt;a href=&quot;https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Victoria_Stodden&quot;&gt;Prof. Stodden&lt;&#x2F;a&gt;. Prof. Stodden has published more about software licensing than anyone else in academia that I could personally find. Some quotes for a slide of a talk by Prof. Stodden[1]:&lt;&#x2F;p&gt;
&lt;blockquote&gt;
&lt;p&gt;The scientific ethos precludes directing another scientist’s creative
contribution.&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;Copyleft licenses make demands on downstream code, namely that they
use the upstream license on the entire library of new code. Two codes
under two different copyleft licenses, therefore, cannot be mixed, as
code cannot carry two licenses.&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;Science creates knowledge, our best estimate of the truth - a public
good. People are free to use and build on public goods however they see fit.&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;Copyleft creates a barrier the transmission of knowledge and scientific
progress, that is not compensated by other benefits.&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;Copyleft inhibits or prevents collaboration with industrial partners.&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;p&gt;Don&#x27;t scientific ethos also encourage &quot;communism&quot; and &quot;disinterestedness&quot;[20]? I fail to understand here that how is forcing companies to disclose the source is against the scientific ethos. Commercial companies have been using and continue to use software with copyleft licenses. Following is another statement by Prof. Stodden that makes my belief in copyleft licenses being more important in scientific software, actually stronger.&lt;&#x2F;p&gt;
&lt;blockquote&gt;
&lt;p&gt;Society’s right to knowledge is an unconditional right.&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;p&gt;The knowledge, in part, lives in the software we write to facilitate the studies. A couple of questions before we move forward:&lt;&#x2F;p&gt;
&lt;ol&gt;
&lt;li&gt;How is it progress if someone takes your work, builds upon it, but does not give back? That is the argument being made by the commercial side.&lt;&#x2F;li&gt;
&lt;li&gt;How is that I am reading the same sentence and coming to an opposite conclusion? :)&lt;&#x2F;li&gt;
&lt;&#x2F;ol&gt;
&lt;p&gt;It has been hard to get answers apart from just statements like &quot;copyleft licenses are not permissive...&quot;. So, I searched for more...&lt;&#x2F;p&gt;
&lt;p&gt;A 2012 paper in PLOS by Moris et. al.[5] is a good read where they suggest what you should choose and why. A blog post in Astronomy Computing Today[4] with the same title, referring to this paper, summarizes this nicely:&lt;&#x2F;p&gt;
&lt;blockquote&gt;
&lt;p&gt;If you want…&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;…the widest possible distribution and adoption, fewest restrictions on
users, open and transparent source code, peer review, community
contributions to the codebase, and easy incorporation of your code by
others… then a permissive FOSS license such as the BSD&#x2F;MIT, Apache, or ECL
licenses may work well&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;…to assure the benefits and openness of FOSS in all future derivatives of
your work, open and transparent source code, peer review, community
contributions to the codebase, and the potential incorporation of your
code into other copyleft- licensed works… then you should consider a
copyleft FOSS license like the GPL, LGPL, or MPL.&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;the ability to separately pursue proprietary models while leveraging the
wide distribution, adoption, community contributions, and other benefits
of open source software… then a hybrid or multi-license scheme may be
ap-propriate.&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;…protect the confidentiality of your source code, reserve maximum control
over the distribution and use of your software, and derive licensing
revenue… then you should consider a proprietary license.”&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;p&gt;Now we have a few pointers on when to choose which license. According to the comments above, a copyleft license makes sure that future derivatives are open as well. As I noted above, in my experience a vast majority of repositories are never touched again, after the publication of the research paper (this is purely anecdotal). There is proof that wide adoption can still happen, even with copyleft licenses, if the published software has value.&lt;&#x2F;p&gt;
&lt;p&gt;A blog post from Jake VanderPlas on &quot;The Whys and Hows of Licensing Scientific Code&quot;[13] is also a good starting point for scientists to figure out what they want to do. The summary in the post is:&lt;&#x2F;p&gt;
&lt;blockquote&gt;
&lt;ol&gt;
&lt;li&gt;Always license your code.  Unlicensed code is closed code, so any
open license is better than none (but see #2).&lt;&#x2F;li&gt;
&lt;li&gt;Always use a GPL-compatible license. GPL-compatible licenses ensure
broad compatibility for your code, and include GPL, new BSD, MIT,
and others (but see #3).&lt;&#x2F;li&gt;
&lt;li&gt;Always use a permissive, BSD-style license. A permissive license
such as new BSD or MIT is preferable to a copyleft license such as
GPL or LGPL.&lt;&#x2F;li&gt;
&lt;&#x2F;ol&gt;
&lt;&#x2F;blockquote&gt;
&lt;p&gt;This aligns with Prof. Stodden&#x27;s views. One of the amazing things about the post[13] is the discussion in its comments which was incredibly insightful. I will reproduce some of those comments here:&lt;&#x2F;p&gt;
&lt;p&gt;Jeremy Sanders writes:&lt;&#x2F;p&gt;
&lt;blockquote&gt;
&lt;p&gt;If I’m publicly releasing code, I’m not writing it so that it can be
taken by a for-profit company and essentially close-sourced. The GPL
is philosophically much closer to academic freedom, where any modified
versions distributed, also have the source distributed.&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;p&gt;To which, Jake responds:&lt;&#x2F;p&gt;
&lt;blockquote&gt;
&lt;p&gt;If I’m publicly releasing code, I hope it’s useful enough that a library
like scipy, scikit-learn, or matplotlib will want to incorporate it. In that
case, GPL is a barrier to its usefulness. Remember that in academia, it’s not
the text of a license that protects your ideas, but the norms of the academic
community.&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;p&gt;Jeremy again:&lt;&#x2F;p&gt;
&lt;blockquote&gt;
&lt;p&gt;Jake: that’s all very well for code that is purely academic and not
interesting to commercial users. If you code is at all commercially
viable, the GPL is a much better prospect. If your code is useful,
people will use it regardless of the choice of free license. People
even use black boxes like sm and galfit.&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;p&gt;Jake believes that projects like Matplotlib, Numpy, scipy, pandas, scikit-learn, IPython are successful because it is &quot;much more than a simple coincidence&quot;. I think this is alluding to the fact that they use permissive licenses. This is where it gets even more interesting because Matthew Turk who moved his yt library to BSD and wrote about it in &quot;Relicensing yt from GPLv3 to BSD&quot;[14], chimes in:&lt;&#x2F;p&gt;
&lt;blockquote&gt;
&lt;p&gt;Hi Jeremy, I agree. I was really quite torn about re-licensing yt, as I am
personally an enormous fan of the GPL and the copyleft. I am, in fact, still
rather torn about this for the reasons you wrote here — I am committed to
ensuring that the code remains free, and that future versions of it are
inspectable at the source level. BSD licensing does not enforce that freedom,
but we as a community do — yt itself, even if a nefarious corporation takes
it and improves it and sells it, will be free software, respecting all four
freedoms.
...&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;I guess my main point is, I think you’re right, and I think the issue is a
subtle one, but I &lt;em&gt;also&lt;&#x2F;em&gt; think that in the end the choice that we made as
the yt community was the right one for us at the time. But that doesn’t keep
me from being a little sad that the GPL is viewed as such a pariah, as in
essence I firmly believe that the de facto standards of FLOSS in science
will be GPL-like, with an active curation and preservation of the four
freedoms, even if BSD in actual license.&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;p&gt;This comment is critical to understand that there are scientists who do believe that a GPL-like license is aligned with the scientific endeavor.&lt;&#x2F;p&gt;
&lt;p&gt;Moving along, if you are scrolling through comments there is a gem by Jeremy Sanders:&lt;&#x2F;p&gt;
&lt;blockquote&gt;
&lt;p&gt;...as Linux shows that it’s certainly possible for commercial companies to
thrive in a GPL ecosystem. I’ve had commercial companies contributing towards
my GPL code with no licensing issues. If a company is scared off by the GPL,
it’s likely they need better lawyers. The code being GPL protects their
contributions from being swallowed up by competitors in rival closed source
apps.&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;p&gt;and a detailed comment to prior &quot;bundling&quot; comments by Mohammad Akhlaghi:&lt;&#x2F;p&gt;
&lt;blockquote&gt;
&lt;p&gt;This is a follow up to Jake’s comment at March 14, 2014 at 10:09 am.
Sorry for continuing this discussion after about 2 years. I just wanted to
know exactly what part of GNU LGPL restricted the bundling?
...
So if I have understood GNU LGPL correctly, you can easily bundle an GNU LGPL
library into a BSD-licenced program without much effort. But then again, I am
not a lawyer or have too much experience in the different software licenses
yet, so I would be grateful if you could let me know if I have incorrectly
understood the GNU LGPL.&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;p&gt;And finally, Don Barry&#x27;s comment&#x27;s first paragraph:&lt;&#x2F;p&gt;
&lt;blockquote&gt;
&lt;p&gt;I must disagree strongly with your endorsement of permissive licenses and
your arguments for them. What is nowhere here discussed is the enormous
amount of corporate lobbying which has influenced the issue. Google, with
the exception of work with the Linux kernel, a “too big to avoid” project,
has actively sought to expunge the GPL from other efforts of theirs: Android
contains only the kernel as GPL software. The fragmented Android ecosystem
is one of many examples where this choice is hostile to the end user.&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;p&gt;So far, the most common theme among scientists (and many programmers) that I see is the leaning towards MIT or BSD type of licenses. Licenses that allow users to freely modify and distribute, without any strings attached to where the source came from or giving back. This is true even if it means that some of them still love GPL and its derivatives and are sad about not being able to use copyleft licenses. It&#x27;d be worth looking into how much of the sentiment against copyleft licenses is due to the industry pressure.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;chatter-outside-the-scientific-community&quot;&gt;Chatter outside the scientific community&lt;&#x2F;h2&gt;
&lt;p&gt;There is no dearth of commercial programmers hating on copyleft licenses. But some voices clarify why we should stick to a license that helps gain the modifications back. Look at what MongoDB writes in their post about licensing and their choice of AGPL[7]:&lt;&#x2F;p&gt;
&lt;blockquote&gt;
&lt;p&gt;To say this another way: if you modify the core database source code,
the goal is that you have to contribute those modifications back to
the community.&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;p&gt;This is the second piece of software (other than GNU&#x2F;Linux kernel) that is &quot;famous&quot; and uses a copyleft license. I still fail to see why copyleft licenses are a stigma and hence the title of this post. It is working fine for some commercially successful software.&lt;&#x2F;p&gt;
&lt;p&gt;Moving on, David Wheeler has an essay[6] that GPL compatibility is important and how to achieve it. It also notes which licenses to avoid and software projects that consider compatibility with GPL important. I think it is worth a read even though it is an old post.&lt;&#x2F;p&gt;
&lt;p&gt;In &lt;a href=&quot;https:&#x2F;&#x2F;web.archive.org&#x2F;web&#x2F;20090831045815&#x2F;http:&#x2F;&#x2F;zedshaw.com&#x2F;blog&#x2F;2009-07-13.html&quot;&gt;an old blog post (now unavailable, wayback link[21])&lt;&#x2F;a&gt; Zed Shaw, talked about why he is using (A&#x2F;L)GPL. However, in his Reddit comment[3] he says he was wrong and gives the reason(s):&lt;&#x2F;p&gt;
&lt;blockquote&gt;
&lt;p&gt;This article is old but basically everyone is right and I was wrong: I didn&#x27;t
make any money on Lamson and nobody contributed to it, no matter what license
I used, and no matter where I hosted it. Pretty much, Lamson proved to me that
all the reasons you&#x27;re given for open source success (license, github, BDFL,
etc.) are a load of horse shit. It&#x27;s marketing dollars, propaganda, and random
chance just like everything else.
So now my stuff is BSD because I write books at
http:&#x2F;&#x2F;learncodethehardway.org&#x2F; and there&#x27;s not really an alternative license
that works for code in books. That&#x27;s all. No major revelations or drama, I
just moved on to something better.&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;p&gt;So, if Z. Shaw is to be believed that the commercial success of a project is mostly marketing, money, and chance, then to me, it makes sense to stick to copyleft license if sharing and openness is something you even remotely care about. It seems to me that copyleft licenses are beneficial, in general, to the scientific openness. I am not sure if the importance of &quot;permissivity&quot; of the license mostly a cry from those who find it cumbersome to give back while raking profits or there is more to it. I would love to know. However, in science, we cannot let this dictate the ethos of sharing and openness.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;open-and-accessible-is-the-final-word&quot;&gt;Open and accessible is the final word&lt;&#x2F;h2&gt;
&lt;p&gt;In recent years, the term &quot;Open Science&quot;[16] has become popular in our community. One of the ways Wikipedia defines it as:&lt;&#x2F;p&gt;
&lt;blockquote&gt;
&lt;p&gt;Open science is transparent and accessible knowledge that is shared and developed through collaborative networks.&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;p&gt;It is a noble effort and I am glad that there is awareness within the community to make sure that the information stays open and accessible. However, the question remains that why shouldn&#x27;t science be &quot;open&quot; by default? Almost every researcher I know understands the power certain paid journals have since many research publications are behind paywalls and convoluted logins. Many agree that these places hinder science in the end. You should be able to use previous research and build upon it and this new work can inform the previous work that can be improved even further. If this model works for other parts of scientific work, then why is scientific software any different?&lt;&#x2F;p&gt;
&lt;p&gt;Many thanks to the following people who reviewed this post:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https:&#x2F;&#x2F;www.dursi.ca&#x2F;&quot;&gt;Jonathan Dursi&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;li&gt;Shveta Kumar&lt;&#x2F;li&gt;
&lt;li&gt;&lt;a href=&quot;https:&#x2F;&#x2F;hoverbear.org&#x2F;&quot;&gt;Ana Hobden&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;h2 id=&quot;references&quot;&gt;References&lt;&#x2F;h2&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Prof. Stodden, V  &quot;Why Copyleft Isn’t Right for Scientific Code&quot; https:&#x2F;&#x2F;web.stanford.edu&#x2F;~vcs&#x2F;talks&#x2F;VictoriaStoddenIPSC2010.pdf&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;li&gt;
&lt;p&gt;VanderPlas, J  &quot;The Whys and Hows of Licensing Scientific Code&quot; https:&#x2F;&#x2F;www.astrobetter.com&#x2F;blog&#x2F;2014&#x2F;03&#x2F;10&#x2F;the-whys-and-hows-of-licensing-scientific-code&#x2F;&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;li&gt;
&lt;p&gt;Reddit Comment by Zed Shaw https:&#x2F;&#x2F;www.reddit.com&#x2F;r&#x2F;programming&#x2F;comments&#x2F;llw0s&#x2F;zed_shaw_on_gpl&#x2F;c2tt5e3&#x2F;&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;li&gt;
&lt;p&gt;astrocompute. “A Quick Guide To Software Licensing for the Scientist Programmer.” Astronomy Computing Today (blog), February 25, 2014. https:&#x2F;&#x2F;astrocompute.wordpress.com&#x2F;2014&#x2F;02&#x2F;25&#x2F;a-quick-guide-to-software-licensing-for-the-scientist-programmer&#x2F;.&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;li&gt;
&lt;p&gt;Morin, Andrew, Jennifer Urban, and Piotr Sliz. “A Quick Guide to Software Licensing for the Scientist-Programmer.” PLOS Computational Biology 8, no. 7 (July 26, 2012): e1002598. https:&#x2F;&#x2F;doi.org&#x2F;10.1371&#x2F;journal.pcbi.1002598.&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;li&gt;
&lt;p&gt;“Make Your Open Source Software GPL-Compatible. Or Else.” Accessed April 20, 2020. https:&#x2F;&#x2F;dwheeler.com&#x2F;essays&#x2F;gpl-compatible.html.&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;li&gt;
&lt;p&gt;MongoDB. “The AGPL | MongoDB Blog.” Accessed May 10, 2020. https:&#x2F;&#x2F;www.mongodb.com&#x2F;blog&#x2F;post&#x2F;the-agpl.&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;li&gt;
&lt;p&gt;“Conditions on Distributing Ghostscript in a Commercial Context.” Accessed May 10, 2020. https:&#x2F;&#x2F;www.ghostscript.com&#x2F;doc&#x2F;current&#x2F;Commprod.htm.&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;li&gt;
&lt;p&gt;“Licenses &amp;amp; Standards | Open Source Initiative.” Accessed April 20, 2020. https:&#x2F;&#x2F;opensource.org&#x2F;licenses.&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;li&gt;
&lt;p&gt;astrocompute. “Licensing Your Code: GPL, BSD and Edvard Munch’s ‘The Scream.’” Astronomy Computing Today (blog), January 17, 2014. https:&#x2F;&#x2F;astrocompute.wordpress.com&#x2F;2014&#x2F;01&#x2F;17&#x2F;licensing-your-code-gpl-bsd-and-edvard-munchs-the-scream&#x2F;.&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;li&gt;
&lt;p&gt;“Neuroimaging in Python — NIPY Documentation.” Accessed April 20, 2020. http:&#x2F;&#x2F;nipy.sourceforge.net&#x2F;nipy&#x2F;stable&#x2F;faq&#x2F;johns_bsd_pitch.html.&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;li&gt;
&lt;p&gt;“The GPL and License Compatibility.” Accessed April 20, 2020. https:&#x2F;&#x2F;producingoss.com&#x2F;en&#x2F;license-compatibility.html.&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;li&gt;
&lt;p&gt;“The Whys and Hows of Licensing Scientific Code.” Accessed April 20, 2020. https:&#x2F;&#x2F;www.astrobetter.com&#x2F;blog&#x2F;2014&#x2F;03&#x2F;10&#x2F;the-whys-and-hows-of-licensing-scientific-code&#x2F;.&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;li&gt;
&lt;p&gt;The yt Project Blog. “The Yt Project Blog » Post: Relicensing Yt from GPLv3 to BSD,” September 12, 2013. http:&#x2F;&#x2F;blog.yt-project.org&#x2F;post&#x2F;Relicensing&#x2F;.&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;li&gt;
&lt;p&gt;“Why I Don’t Use the GPL | Linux Journal.” Accessed April 20, 2020. https:&#x2F;&#x2F;www.linuxjournal.com&#x2F;article&#x2F;5935.&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;li&gt;
&lt;p&gt;“Open Science.” In Wikipedia, May 12, 2020. https:&#x2F;&#x2F;en.wikipedia.org&#x2F;w&#x2F;index.php?title=Open_science&amp;amp;oldid=956239136.&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;li&gt;
&lt;p&gt;“OpenDP.” Accessed May 20, 2020. https:&#x2F;&#x2F;privacytools.seas.harvard.edu&#x2F;opendp.&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;li&gt;
&lt;p&gt;“Society of Research Software Engineering.” Accessed May 20, 2020. https:&#x2F;&#x2F;society-rse.org&#x2F;.&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;li&gt;
&lt;p&gt;“CanDIG.” Accessed May 20, 2020. https:&#x2F;&#x2F;www.distributedgenomics.ca&#x2F;.&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;li&gt;
&lt;p&gt;“Mertonian Norms.” In Wikipedia, May 9, 2020. https:&#x2F;&#x2F;en.wikipedia.org&#x2F;w&#x2F;index.php?title=Mertonian_norms&amp;amp;oldid=955747690.&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;li&gt;
&lt;p&gt;&quot;Why I (A&#x2F;L)GPL&quot; Zed Shaw, From Wayback Machine, July 13, 2009. https:&#x2F;&#x2F;web.archive.org&#x2F;web&#x2F;20090831045815&#x2F;http:&#x2F;&#x2F;zedshaw.com&#x2F;blog&#x2F;2009-07-13.html&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;&#x2F;ol&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>NixOS and other tools</title>
        <published>2020-01-25T00:00:00+00:00</published>
        <updated>2020-01-25T00:00:00+00:00</updated>
        
        <author>
          <name>
            
              Unknown
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://amanjeev.com/blog/nixos/"/>
        <id>https://amanjeev.com/blog/nixos/</id>
        
        <content type="html" xml:base="https://amanjeev.com/blog/nixos/">&lt;h3 id=&quot;note-this-blog-post-is-old-and-many-things-here-have-been-changed-and-moved-on-i-will-write-another-post-to-update&quot;&gt;Note: This blog post is old and many things here have been changed and moved on. I will write another post to update.&lt;&#x2F;h3&gt;
&lt;p&gt;Before I begin, you must know that my inspiration to move to NixOS was &lt;a href=&quot;https:&#x2F;&#x2F;spacekookie.de&#x2F;&quot;&gt;Spacekookie&lt;&#x2F;a&gt;. I had no idea about NixOS
before I learned about it from Spacekookie. You can read the &lt;a href=&quot;https:&#x2F;&#x2F;spacekookie.de&#x2F;blog&#x2F;home-manager-or-how-not-to-yakhave&#x2F;&quot;&gt;NixOS&#x2F;Home Manager post&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
&lt;p&gt;You can see my &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;amanjeev&#x2F;somenix&quot;&gt;NixOS and Home Manager configs&lt;&#x2F;a&gt;. This is a big deal!&lt;&#x2F;p&gt;
&lt;h2 id=&quot;history&quot;&gt;History&lt;&#x2F;h2&gt;
&lt;p&gt;Years ago, I moved to the Apple ecosystem for stability and things like the Time Machine backup system. That is still where my personal computing lives.
But I was getting more and more worried about having personal data on the same machine where I download and run code. I was hoping to
separate my development setup from my personal computing setup. I could have gone the route of QubesOS but back then I was not ready
to shave more yaks than what I was already helping groom. So, I decided to buy a laptop and have been running Ubuntu on it, up until
a few months ago, when I removed Ubuntu and moved to NixOS.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;why-nixos&quot;&gt;Why &lt;a href=&quot;https:&#x2F;&#x2F;nixos.org&#x2F;&quot;&gt;NixOS&lt;&#x2F;a&gt;&lt;&#x2F;h2&gt;
&lt;p&gt;For years I have looked at way too many tools to have a decent backup and restore strategy and nothing stood out. I can manage
to backup my home directory and restore it but I needed something that helped reliably reinstall all the applications, dotfiles
and other tools that I need day-to-day. Then I can just reinstall in case of a computer crash and fetch the home contents from a backup.
This is where &lt;a href=&quot;https:&#x2F;&#x2F;nixos.org&#x2F;&quot;&gt;NixOS&lt;&#x2F;a&gt; helps. In short, it is a Linux distribution that is based on &lt;a href=&quot;https:&#x2F;&#x2F;nixos.org&#x2F;nix&#x2F;&quot;&gt;Nix&lt;&#x2F;a&gt;, a purely
functional package manager (it is also a functional programming language). This allows your installations, upgrades, etc. to be atomic, which
makes them much more reliable. That is, every time you install or upgrade, NixOS creates a new &lt;em&gt;snapshot&lt;&#x2F;em&gt;. You can clean older &lt;em&gt;snapshots&lt;&#x2F;em&gt;
when you feel like it or boot into an older one if you wanted. There is also &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;rycee&#x2F;home-manager&quot;&gt;home-manager&lt;&#x2F;a&gt; which is userspace Nix. I highly recommend
you look into that as well.&lt;&#x2F;p&gt;
&lt;p&gt;For those interested here is my &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;amanjeev&#x2F;somenix&quot;&gt;Nixos and Home Manager configs&lt;&#x2F;a&gt;. I can give a quick run down.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;a-build-shell-script&quot;&gt;&lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;amanjeev&#x2F;somenix&#x2F;blob&#x2F;master&#x2F;build.sh#L14-L15&quot;&gt;A build shell script&lt;&#x2F;a&gt;&lt;&#x2F;h3&gt;
&lt;p&gt;This is needed because I want to be able to override certain packages and have the config live in my home directory rather than the default
&lt;code&gt;&#x2F;etc&lt;&#x2F;code&gt;.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;root-s&quot;&gt;&lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;amanjeev&#x2F;somenix&#x2F;tree&#x2F;master&#x2F;nixos&#x2F;roots&quot;&gt;Root(s)&lt;&#x2F;a&gt;&lt;&#x2F;h3&gt;
&lt;p&gt;This is where I store the root configs for various machines. A root config is your &lt;code&gt;configuration.nix&lt;&#x2F;code&gt; and &lt;code&gt;hardware-configuration.nix&lt;&#x2F;code&gt;
that is created the first time you bootstrap while installing NixOS. You can use &lt;code&gt;configuration.nix&lt;&#x2F;code&gt; for everything but it is better
to have some semblance of order. Programmers, eh!&lt;&#x2F;p&gt;
&lt;p&gt;I have three development machines and at the time of this writing, two of those are on NixOS. Yes, I love wolves and yes I came up with the name Torontula.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;common-stuff&quot;&gt;&lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;amanjeev&#x2F;somenix&#x2F;blob&#x2F;master&#x2F;nixos&#x2F;common.nix&quot;&gt;Common stuff&lt;&#x2F;a&gt;&lt;&#x2F;h3&gt;
&lt;p&gt;This is mostly common stuff for all machines without having to make duplicates. This could go into a &lt;code&gt;configuration.nix&lt;&#x2F;code&gt; but I chose to move it
into its module.&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;This file &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;amanjeev&#x2F;somenix&#x2F;blob&#x2F;master&#x2F;nixos&#x2F;common.nix#L4-L8&quot;&gt;defines the &lt;code&gt;unstable&lt;&#x2F;code&gt; branch&lt;&#x2F;a&gt; of Nix because certain packages
are only available in that. At the time of this writing, I have Zulip which I needed for Rust&#x27;s official chat. Note that you can define &lt;code&gt;ref&lt;&#x2F;code&gt; and
&lt;code&gt;revision&lt;&#x2F;code&gt; and fetch only that. Talk about thinking of pinning from the ground up.&lt;&#x2F;li&gt;
&lt;li&gt;It installs Virtualbox and related services. Yes, I need this on all machines and it takes horribly long to recompile.&lt;&#x2F;li&gt;
&lt;li&gt;When was the last time you &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;amanjeev&#x2F;somenix&#x2F;blob&#x2F;master&#x2F;nixos&#x2F;common.nix#L45&quot;&gt;defined a font&lt;&#x2F;a&gt; in the config? Or &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;amanjeev&#x2F;somenix&#x2F;blob&#x2F;master&#x2F;nixos&#x2F;common.nix#L20-L27&quot;&gt;created a user in the config&lt;&#x2F;a&gt; with some Puppet&#x2F;Chef&#x2F;etc.? ;)&lt;&#x2F;li&gt;
&lt;li&gt;Oh, look at the &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;amanjeev&#x2F;somenix&#x2F;blob&#x2F;master&#x2F;nixos&#x2F;common.nix#L69-L72&quot;&gt;desktop managers here&lt;&#x2F;a&gt;.&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;h3 id=&quot;packages&quot;&gt;&lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;amanjeev&#x2F;somenix&#x2F;blob&#x2F;master&#x2F;nixos&#x2F;pkgs&#x2F;default.nix&quot;&gt;Packages&lt;&#x2F;a&gt;&lt;&#x2F;h3&gt;
&lt;ul&gt;
&lt;li&gt;Ahem! &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;amanjeev&#x2F;somenix&#x2F;blob&#x2F;master&#x2F;nixos&#x2F;pkgs&#x2F;default.nix#L6-L10&quot;&gt;Manager your config files&lt;&#x2F;a&gt;. The confs live in a
separate directory.&lt;&#x2F;li&gt;
&lt;li&gt;&lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;amanjeev&#x2F;somenix&#x2F;blob&#x2F;master&#x2F;nixos&#x2F;pkgs&#x2F;default.nix#L12-L92&quot;&gt;This entire section is the list of packages I want to be installed&lt;&#x2F;a&gt;.
I add and remove most of them here and run the rebuild command.&lt;&#x2F;li&gt;
&lt;li&gt;When was the last time you &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;amanjeev&#x2F;somenix&#x2F;blob&#x2F;master&#x2F;nixos&#x2F;pkgs&#x2F;default.nix#L94-L122&quot;&gt;managed your git config and settings&lt;&#x2F;a&gt; like this?&lt;&#x2F;li&gt;
&lt;li&gt;Do you use emacs (or even vim)? Here is the &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;amanjeev&#x2F;somenix&#x2F;blob&#x2F;master&#x2F;nixos&#x2F;pkgs&#x2F;default.nix#L126-L164&quot;&gt;list of all the emacs packages that I use&lt;&#x2F;a&gt;.
Some of these are directly from &lt;a href=&quot;https:&#x2F;&#x2F;spacekookie.de&#x2F;&quot;&gt;Spacekookie&lt;&#x2F;a&gt;!&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;h3 id=&quot;bonus&quot;&gt;Bonus&lt;&#x2F;h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;amanjeev&#x2F;somenix&#x2F;blob&#x2F;master&#x2F;nixos&#x2F;roots&#x2F;torontula&#x2F;configuration.nix#L31&quot;&gt;Change your Linux Kernel in one line&lt;&#x2F;a&gt;.&lt;&#x2F;li&gt;
&lt;li&gt;I moved to &lt;a href=&quot;https:&#x2F;&#x2F;fishshell.com&#x2F;&quot;&gt;fish shell&lt;&#x2F;a&gt;; again thanks to &lt;a href=&quot;https:&#x2F;&#x2F;spacekookie.de&#x2F;&quot;&gt;Spacekookie&lt;&#x2F;a&gt; from whom I
&lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;amanjeev&#x2F;somenix&#x2F;tree&#x2F;master&#x2F;nixos&#x2F;pkgs&#x2F;confs&#x2F;fish&quot;&gt;stole this entire set of functions&lt;&#x2F;a&gt;.&lt;&#x2F;li&gt;
&lt;li&gt;I moved to &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;alacritty&#x2F;alacritty&quot;&gt;Alacritty&lt;&#x2F;a&gt; as my main terminal emulator.
Here is &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;amanjeev&#x2F;somenix&#x2F;blob&#x2F;master&#x2F;nixos&#x2F;pkgs&#x2F;confs&#x2F;alacritty.yml&quot;&gt;Alacritty&#x27;s config YAML&lt;&#x2F;a&gt;
and &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;amanjeev&#x2F;somenix&#x2F;blob&#x2F;master&#x2F;nixos&#x2F;pkgs&#x2F;default.nix#L10&quot;&gt;here is how you &quot;install&quot; Alacritty&#x27;s config&lt;&#x2F;a&gt;
It is truly faster than any other terminal emulator I have used.&lt;&#x2F;li&gt;
&lt;li&gt;If you like QubesOS, you should check out &lt;a href=&quot;https:&#x2F;&#x2F;spectrum-os.org&#x2F;&quot;&gt;SpectrumOS&lt;&#x2F;a&gt;. It is like QubesOS but based on Nix. I am excited about this and I wish I had time
and knowledge to contribute to this project.&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;If you want to get help, folks on the NixOS IRC channel are very helpful!&lt;&#x2F;p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>man7.org Linux training and Google cloud virtual machines</title>
        <published>2019-03-03T00:00:00+00:00</published>
        <updated>2019-03-03T00:00:00+00:00</updated>
        
        <author>
          <name>
            
              Unknown
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://amanjeev.com/blog/man7-training-and-virual-machines/"/>
        <id>https://amanjeev.com/blog/man7-training-and-virual-machines/</id>
        
        <content type="html" xml:base="https://amanjeev.com/blog/man7-training-and-virual-machines/">&lt;p&gt;I had the privilege to attend a week-long training by &lt;a href=&quot;http:&#x2F;&#x2F;man7.org&#x2F;&quot;&gt;Michael Kerrisk&lt;&#x2F;a&gt; on &quot;System Programming for Liunux Containers&quot;. If you are interested in Linux deep-dive, I cannot recommend anyone more than Michael. I have been waiting for his training for about four years and it finally happened! So, keep your hopes high, you may someday get that too.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;a href=&quot;http:&#x2F;&#x2F;man7.org&#x2F;mtk&#x2F;index.html&quot;&gt;Michael is the maintainer of the Linux man-pages&lt;&#x2F;a&gt; and is extremely knowledgeable. His style of teaching is balanced
with enough theory for you to get started and decent collection of exercises along the way. In his class, you will be working as pair-programmers. This helps speed up the work you have to do and encourages discussion with your peers. He is receptive to comments and suggestions.&lt;&#x2F;p&gt;
&lt;p&gt;You should contact him!&lt;&#x2F;p&gt;
&lt;p&gt;For his course, you need a Linux machine and it is better if it is your laptop but you could work with a virtual machine on your laptop. To make sure that we have spare VMs, I created a bunch on Google cloud platform. &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;amanjeev&#x2F;man7-training&quot;&gt;You can use this Terraform repo to do the same&lt;&#x2F;a&gt;. For his courses, you may have to access the GRUB prompt to edit Linux kernel args. The output for Terraform code after it generates the VMs, will show the command to do that as well.&lt;&#x2F;p&gt;
&lt;p&gt;In short, &lt;a href=&quot;https:&#x2F;&#x2F;cloud.google.com&#x2F;compute&#x2F;docs&#x2F;instances&#x2F;interacting-with-serial-console&quot;&gt;Google cloud platform allows you to connect to your VM&#x27;s GRUB prompt via a seial console&lt;&#x2F;a&gt; (that you have to enable prior to VM creation).&lt;&#x2F;p&gt;
&lt;p&gt;Happy hacking!&lt;&#x2F;p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>How to document Rust&#x27;s macro invocation</title>
        <published>2019-02-21T00:00:00+00:00</published>
        <updated>2019-02-21T00:00:00+00:00</updated>
        
        <author>
          <name>
            
              Unknown
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://amanjeev.com/blog/rust-document-macro-invocations/"/>
        <id>https://amanjeev.com/blog/rust-document-macro-invocations/</id>
        
        <content type="html" xml:base="https://amanjeev.com/blog/rust-document-macro-invocations/">&lt;p&gt;Since, I have spent way too much time on this, I decided it is worth noting down.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;the-problem&quot;&gt;The problem&lt;&#x2F;h3&gt;
&lt;p&gt;You can easily document your Rust items like functions by putting three slashes &#x2F;&#x2F;&#x2F;.&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;rust&quot; style=&quot;background-color:#eff1f5;color:#4f5b66;&quot; class=&quot;language-rust &quot;&gt;&lt;code class=&quot;language-rust&quot; data-lang=&quot;rust&quot;&gt;&lt;span style=&quot;color:#a7adba;&quot;&gt;&#x2F;&#x2F;&#x2F; My amazing function
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a7adba;&quot;&gt;&#x2F;&#x2F;&#x2F; # Example
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a7adba;&quot;&gt;&#x2F;&#x2F;&#x2F; amazing();
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#b48ead;&quot;&gt;fn &lt;&#x2F;span&gt;&lt;span style=&quot;color:#8fa1b3;&quot;&gt;amazing&lt;&#x2F;span&gt;&lt;span&gt;() -&amp;gt; () {
&lt;&#x2F;span&gt;&lt;span&gt;    println!(&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;Rust is amazing!&lt;&#x2F;span&gt;&lt;span&gt;&amp;quot;);
&lt;&#x2F;span&gt;&lt;span&gt;}
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;You can also document your macro like this -&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;rust&quot; style=&quot;background-color:#eff1f5;color:#4f5b66;&quot; class=&quot;language-rust &quot;&gt;&lt;code class=&quot;language-rust&quot; data-lang=&quot;rust&quot;&gt;&lt;span style=&quot;color:#a7adba;&quot;&gt;&#x2F;&#x2F;&#x2F; My amazing macro&amp;#39;s own doc
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#96b5b4;&quot;&gt;macro_rules! &lt;&#x2F;span&gt;&lt;span&gt;amazing {
&lt;&#x2F;span&gt;&lt;span&gt;    (&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;$func&lt;&#x2F;span&gt;&lt;span&gt;:&lt;&#x2F;span&gt;&lt;span style=&quot;color:#b48ead;&quot;&gt;ident&lt;&#x2F;span&gt;&lt;span&gt;) =&amp;gt; (
&lt;&#x2F;span&gt;&lt;span&gt;        &lt;&#x2F;span&gt;&lt;span style=&quot;color:#b48ead;&quot;&gt;fn &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;$func&lt;&#x2F;span&gt;&lt;span&gt;() -&amp;gt; () {
&lt;&#x2F;span&gt;&lt;span&gt;            println!(&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;Rust is amazing! Rust has powerful features!&lt;&#x2F;span&gt;&lt;span&gt;&amp;quot;);
&lt;&#x2F;span&gt;&lt;span&gt;        };   
&lt;&#x2F;span&gt;&lt;span&gt;    )
&lt;&#x2F;span&gt;&lt;span&gt;}
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;However, if you want to document each separate invocation of your amazing! macro, it is not that straightfoward. You might ask why should we be doing that anyway? Because macros can generate a lot of boilerplate code for you and each of those invocations might be slightly different which must be conveyed to your user in docs.rs. For example, this will not work&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;rust&quot; style=&quot;background-color:#eff1f5;color:#4f5b66;&quot; class=&quot;language-rust &quot;&gt;&lt;code class=&quot;language-rust&quot; data-lang=&quot;rust&quot;&gt;&lt;span style=&quot;color:#a7adba;&quot;&gt;&#x2F;&#x2F;&#x2F; this is a macro invocation but
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a7adba;&quot;&gt;&#x2F;&#x2F;&#x2F; these doc strings will not show
&lt;&#x2F;span&gt;&lt;span&gt;amazing!(amazing_function_1);
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Phew!&lt;&#x2F;p&gt;
&lt;h3 id=&quot;solution&quot;&gt;Solution&lt;&#x2F;h3&gt;
&lt;h4 id=&quot;slightly-modify-your-macro&quot;&gt;Slightly modify your macro&lt;&#x2F;h4&gt;
&lt;pre data-lang=&quot;rust&quot; style=&quot;background-color:#eff1f5;color:#4f5b66;&quot; class=&quot;language-rust &quot;&gt;&lt;code class=&quot;language-rust&quot; data-lang=&quot;rust&quot;&gt;&lt;span style=&quot;color:#a7adba;&quot;&gt;&#x2F;&#x2F;&#x2F; My amazing macro&amp;#39;s own doc 
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#96b5b4;&quot;&gt;macro_rules! &lt;&#x2F;span&gt;&lt;span&gt;amazing {
&lt;&#x2F;span&gt;&lt;span&gt;    (
&lt;&#x2F;span&gt;&lt;span&gt;        $(#[&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;$meta&lt;&#x2F;span&gt;&lt;span&gt;:&lt;&#x2F;span&gt;&lt;span style=&quot;color:#b48ead;&quot;&gt;meta&lt;&#x2F;span&gt;&lt;span&gt;])*
&lt;&#x2F;span&gt;&lt;span&gt;        &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;$func&lt;&#x2F;span&gt;&lt;span&gt;:&lt;&#x2F;span&gt;&lt;span style=&quot;color:#b48ead;&quot;&gt;ident
&lt;&#x2F;span&gt;&lt;span&gt;    ) =&amp;gt; (
&lt;&#x2F;span&gt;&lt;span&gt;        $(#[&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;$meta&lt;&#x2F;span&gt;&lt;span&gt;])*
&lt;&#x2F;span&gt;&lt;span&gt;        &lt;&#x2F;span&gt;&lt;span style=&quot;color:#b48ead;&quot;&gt;fn &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;$func&lt;&#x2F;span&gt;&lt;span&gt;() -&amp;gt; () {
&lt;&#x2F;span&gt;&lt;span&gt;            println!(&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;Rust is amazing! Rust has powerful features!&lt;&#x2F;span&gt;&lt;span&gt;&amp;quot;);
&lt;&#x2F;span&gt;&lt;span&gt;        }
&lt;&#x2F;span&gt;&lt;span&gt;    )
&lt;&#x2F;span&gt;&lt;span&gt;}
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Let me explain briefly what those two new lines mean.&lt;&#x2F;p&gt;
&lt;h5 id=&quot;capture-meta&quot;&gt;Capture meta&lt;&#x2F;h5&gt;
&lt;p&gt;&lt;code class=&quot;inline&quot;&gt;$(#[$meta:meta])*&lt;&#x2F;code&gt; tells the macro to match 0 or more instances of meta attributes. Rust doc comment &lt;code&gt;&#x2F;&#x2F;&#x2F; a comment&lt;&#x2F;code&gt; is just another way of saying &lt;code&gt;#[doc = &quot; a comment&quot;]&lt;&#x2F;code&gt; This means that if we provide a comment in our invocation, this will now be captured.&lt;&#x2F;p&gt;
&lt;h5 id=&quot;output-meta&quot;&gt;Output meta&lt;&#x2F;h5&gt;
&lt;p&gt;&lt;code class=&quot;inline&quot;&gt;$(#[meta])*&lt;&#x2F;code&gt; just spits out all the meta attributes right before the function.&lt;&#x2F;p&gt;
&lt;h4 id=&quot;add-comment-in-your-invocation&quot;&gt;Add comment in your invocation&lt;&#x2F;h4&gt;
&lt;pre data-lang=&quot;rust&quot; style=&quot;background-color:#eff1f5;color:#4f5b66;&quot; class=&quot;language-rust &quot;&gt;&lt;code class=&quot;language-rust&quot; data-lang=&quot;rust&quot;&gt;&lt;span&gt;amazing!(
&lt;&#x2F;span&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a7adba;&quot;&gt;&#x2F;&#x2F;&#x2F; this macro invocation will have a comment
&lt;&#x2F;span&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a7adba;&quot;&gt;&#x2F;&#x2F;&#x2F; # Examples
&lt;&#x2F;span&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a7adba;&quot;&gt;&#x2F;&#x2F;&#x2F; amazing_function_2();
&lt;&#x2F;span&gt;&lt;span&gt;    amazing_function_2
&lt;&#x2F;span&gt;&lt;span&gt;);
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;amazing!(
&lt;&#x2F;span&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a7adba;&quot;&gt;&#x2F;&#x2F;&#x2F; this macro invocation will have another, its own, comment
&lt;&#x2F;span&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a7adba;&quot;&gt;&#x2F;&#x2F;&#x2F; # Examples
&lt;&#x2F;span&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a7adba;&quot;&gt;&#x2F;&#x2F;&#x2F; amazing_function_3();
&lt;&#x2F;span&gt;&lt;span&gt;    amazing_function_3
&lt;&#x2F;span&gt;&lt;span&gt;);
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;The comments in the docs will now show up for both functions that were created via invoking macro. :)&lt;&#x2F;p&gt;
&lt;p&gt;Many thanks to kind folks in Rust community discord server.&lt;&#x2F;p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>AWS load balancers and instance health checks with terraform</title>
        <published>2018-10-07T00:00:00+00:00</published>
        <updated>2018-10-07T00:00:00+00:00</updated>
        
        <author>
          <name>
            
              Unknown
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://amanjeev.com/blog/aws-load-balancers-and-health-checks-with-terraform/"/>
        <id>https://amanjeev.com/blog/aws-load-balancers-and-health-checks-with-terraform/</id>
        
        <content type="html" xml:base="https://amanjeev.com/blog/aws-load-balancers-and-health-checks-with-terraform/">&lt;p&gt;&lt;a href=&quot;https:&#x2F;&#x2F;docs.aws.amazon.com&#x2F;autoscaling&#x2F;ec2&#x2F;userguide&#x2F;AutoScalingGroup.html&quot;&gt;Auto Scaling Group (ASG)&lt;&#x2F;a&gt; is an AWS feature that allows you to manage the size of a cluster (group) of similar instances. You can create an ASG with a minimum number and maximum number of the instances of a particular image. In other words, a &lt;em&gt;group&lt;&#x2F;em&gt; of instances that &lt;em&gt;scale&lt;&#x2F;em&gt; &lt;em&gt;auto&lt;&#x2F;em&gt;matically.&lt;&#x2F;p&gt;
&lt;p&gt;In its simplest forms, it relies on the &lt;em&gt;Health checks&lt;&#x2F;em&gt; to determine if any of the instances is unhealthy. In a more advanced setup, if configured, it can scale the number of instances up or down depending on the usage of the instances.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;health-check-types&quot;&gt;Health check types&lt;&#x2F;h3&gt;
&lt;p&gt;From what I understand, there are three major types of health checks that AWS provides (not counting custom health checks).&lt;&#x2F;p&gt;
&lt;h4 id=&quot;aws-ec2-status-checks&quot;&gt;AWS EC2 Status Checks&lt;&#x2F;h4&gt;
&lt;p&gt;For the most basic ASG, the health checks are simply based on the EC2 instance&#x27;s vitals like system power, networking issues, memory exhaustion etc. You can read more about &lt;a href=&quot;https:&#x2F;&#x2F;docs.aws.amazon.com&#x2F;AWSEC2&#x2F;latest&#x2F;UserGuide&#x2F;monitoring-system-instance-status-check.html&quot;&gt;Status checks for your instances&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
&lt;p&gt;These are default checks and are readily available to use. However, there are a couple of issues that you may see with these checks:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;They can only tell you about the instance or system health and not the application level health. This means that we have to rely on metrics that may not be telling the true state of your application health. For example, the CPU consumption may be low and network maybe fine but the application itself crashed.&lt;&#x2F;li&gt;
&lt;li&gt;We cannot truly gauge the load on our instances and hence, scaling up or down in the number of instances may not be feasible with these checks alone.&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;For this reason, AWS offers a &lt;a href=&quot;https:&#x2F;&#x2F;docs.aws.amazon.com&#x2F;autoscaling&#x2F;ec2&#x2F;userguide&#x2F;autoscaling-load-balancer.html&quot;&gt;feature of adding a Load Balancer&lt;&#x2F;a&gt; in front of your instances. Amazon calls it &lt;a href=&quot;https:&#x2F;&#x2F;docs.aws.amazon.com&#x2F;elasticloadbalancing&#x2F;latest&#x2F;userguide&#x2F;what-is-load-balancing.html&quot;&gt;Elastic Load Balancer&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
&lt;h4 id=&quot;elastic-load-balancing-health-checks-classic-load-balancer&quot;&gt;Elastic Load Balancing Health Checks - Classic Load Balancer&lt;&#x2F;h4&gt;
&lt;p&gt;&lt;a href=&quot;https:&#x2F;&#x2F;docs.aws.amazon.com&#x2F;elasticloadbalancing&#x2F;latest&#x2F;classic&#x2F;introduction.html&quot;&gt;Classic Load Balancer&lt;&#x2F;a&gt; is meant mostly for EC2-Classic network. New customers do not get this option (EC2-Classic) to launch instances anymore but it is worth writing about the limitations.&lt;&#x2F;p&gt;
&lt;p&gt;The idea is simple enough — you define the CLB, you define health check and the Load Balancer does not route traffic to an unhealthy instance in the group. This is already an improvement over the EC2 Status Checks because these LB health checks let you define more granular checks and lets you rely on a &quot;200 OK&quot; response status of your application.&lt;&#x2F;p&gt;
&lt;p&gt;The downside of CLBs is that you have only one health check per LB. If you want to have more than one health check, then you have to create new LBs and point them to the backend instances. This can grow cumbersome real fast but there are other ways to do more checks without maintaining multiple LBs. One of them is the Application Load Balancer.&lt;&#x2F;p&gt;
&lt;h4 id=&quot;elastic-load-balancing-health-checks-application-load-balancer&quot;&gt;Elastic Load Balancing Health Checks - Application Load Balancer&lt;&#x2F;h4&gt;
&lt;p&gt;&lt;a href=&quot;https:&#x2F;&#x2F;docs.aws.amazon.com&#x2F;elasticloadbalancing&#x2F;latest&#x2F;application&#x2F;introduction.html&quot;&gt;Application Load Balancer&lt;&#x2F;a&gt; is a strict Layer-7 Load Balancing. It is much better than the Classic Load Balancer in many ways -&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;Host-based routing via HTTP Host header along with Path-based routing.&lt;&#x2F;li&gt;
&lt;li&gt;HTTP&#x2F;2 support.&lt;&#x2F;li&gt;
&lt;li&gt;Wider range of error codes (200-499).&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;The major point to remember is that you create &lt;em&gt;target groups&lt;&#x2F;em&gt;, which each have one health check. Then you can configure a listener for ALB and provide rules to the listener that tell it to route to a particular target group.&lt;&#x2F;p&gt;
&lt;h5 id=&quot;overview-of-steps-to-create-an-alb&quot;&gt;Overview of steps to create an ALB&lt;&#x2F;h5&gt;
&lt;p&gt;Two major resources that you need to pay attention to are Listeners and Targets.&lt;&#x2F;p&gt;
&lt;h6 id=&quot;target-groups-and-health-checks&quot;&gt;Target Groups and health checks&lt;&#x2F;h6&gt;
&lt;p&gt;&lt;a href=&quot;https:&#x2F;&#x2F;docs.aws.amazon.com&#x2F;elasticloadbalancing&#x2F;latest&#x2F;application&#x2F;load-balancer-target-groups.html&quot;&gt;Setup Target Groups&lt;&#x2F;a&gt; and configure health checks for each group.&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;terraform&quot; style=&quot;background-color:#eff1f5;color:#4f5b66;&quot; class=&quot;language-terraform &quot;&gt;&lt;code class=&quot;language-terraform&quot; data-lang=&quot;terraform&quot;&gt;&lt;span&gt;# An example of target group
&lt;&#x2F;span&gt;&lt;span&gt;resource &amp;quot;aws_alb_target_group&amp;quot; &amp;quot;target-group-1&amp;quot; {
&lt;&#x2F;span&gt;&lt;span&gt;  name = &amp;quot;target-group-1&amp;quot;
&lt;&#x2F;span&gt;&lt;span&gt;  port = 80
&lt;&#x2F;span&gt;&lt;span&gt;  protocol = &amp;quot;HTTP&amp;quot;
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;  lifecycle { create_before_destroy=true }
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;  health_check {
&lt;&#x2F;span&gt;&lt;span&gt;    path = &amp;quot;&#x2F;api&#x2F;1&#x2F;resolve&#x2F;default?path=&#x2F;service&#x2F;my-service&amp;quot;
&lt;&#x2F;span&gt;&lt;span&gt;    port = 2001
&lt;&#x2F;span&gt;&lt;span&gt;    healthy_threshold = 6
&lt;&#x2F;span&gt;&lt;span&gt;    unhealthy_threshold = 2
&lt;&#x2F;span&gt;&lt;span&gt;    timeout = 2
&lt;&#x2F;span&gt;&lt;span&gt;    interval = 5
&lt;&#x2F;span&gt;&lt;span&gt;    matcher = &amp;quot;200&amp;quot;  # has to be HTTP 200 or fails
&lt;&#x2F;span&gt;&lt;span&gt;  }
&lt;&#x2F;span&gt;&lt;span&gt;}
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;h6 id=&quot;listener-and-listener-rules&quot;&gt;Listener and Listener rules&lt;&#x2F;h6&gt;
&lt;p&gt;&lt;a href=&quot;https:&#x2F;&#x2F;docs.aws.amazon.com&#x2F;elasticloadbalancing&#x2F;latest&#x2F;application&#x2F;load-balancer-listeners.html&quot;&gt;Setup a Listener&lt;&#x2F;a&gt; with &lt;a href=&quot;https:&#x2F;&#x2F;docs.aws.amazon.com&#x2F;elasticloadbalancing&#x2F;latest&#x2F;application&#x2F;load-balancer-listeners.html#listener-rules&quot;&gt;Listener Rules&lt;&#x2F;a&gt; that allow you to forward the requests to appropriate &lt;em&gt;targets&lt;&#x2F;em&gt; in one or more &lt;a href=&quot;https:&#x2F;&#x2F;docs.aws.amazon.com&#x2F;elasticloadbalancing&#x2F;latest&#x2F;application&#x2F;load-balancer-target-groups.html&quot;&gt;&lt;em&gt;target groups&lt;&#x2F;em&gt;&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;terraform&quot; style=&quot;background-color:#eff1f5;color:#4f5b66;&quot; class=&quot;language-terraform &quot;&gt;&lt;code class=&quot;language-terraform&quot; data-lang=&quot;terraform&quot;&gt;&lt;span&gt;# An example of a Listener
&lt;&#x2F;span&gt;&lt;span&gt;resource &amp;quot;aws_alb_listener&amp;quot; &amp;quot;my-alb-listener&amp;quot; {
&lt;&#x2F;span&gt;&lt;span&gt;  default_action {
&lt;&#x2F;span&gt;&lt;span&gt;    target_group_arn = &amp;quot;${aws_alb_target_group.target-group-1.arn}&amp;quot;
&lt;&#x2F;span&gt;&lt;span&gt;    type = &amp;quot;forward&amp;quot;
&lt;&#x2F;span&gt;&lt;span&gt;  }
&lt;&#x2F;span&gt;&lt;span&gt;  load_balancer_arn = &amp;quot;${aws_alb.my-app-alb.arn}&amp;quot;
&lt;&#x2F;span&gt;&lt;span&gt;  port = 80
&lt;&#x2F;span&gt;&lt;span&gt;  protocol = &amp;quot;HTTP&amp;quot;
&lt;&#x2F;span&gt;&lt;span&gt;}
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;# An example of a Listener rule
&lt;&#x2F;span&gt;&lt;span&gt;resource &amp;quot;aws_alb_listener_rule&amp;quot; &amp;quot;rule-1&amp;quot; {
&lt;&#x2F;span&gt;&lt;span&gt;  action {
&lt;&#x2F;span&gt;&lt;span&gt;    target_group_arn = &amp;quot;${aws_alb_target_group.target-group-1.arn}&amp;quot;
&lt;&#x2F;span&gt;&lt;span&gt;    type = &amp;quot;forward&amp;quot;
&lt;&#x2F;span&gt;&lt;span&gt;  }
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;  condition { field=&amp;quot;path-pattern&amp;quot; values=[&amp;quot;&#x2F;api&#x2F;1&#x2F;resolve&#x2F;default&amp;quot;] }
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;  listener_arn = &amp;quot;${aws_alb_listener.my-alb-listener.id}&amp;quot;
&lt;&#x2F;span&gt;&lt;span&gt;  priority = 100
&lt;&#x2F;span&gt;&lt;span&gt;}
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;h3 id=&quot;conclusion&quot;&gt;Conclusion&lt;&#x2F;h3&gt;
&lt;p&gt;As you can see above, each target group has a check and the ALB listener rules decide which group to send the request to based on the rules like PATH, Host header etc. What makes it more convenient is that you always have a default rule that is a catch-all. Also, you can have multiple conditions in a rule like&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;terraform&quot; style=&quot;background-color:#eff1f5;color:#4f5b66;&quot; class=&quot;language-terraform &quot;&gt;&lt;code class=&quot;language-terraform&quot; data-lang=&quot;terraform&quot;&gt;&lt;span&gt;resource &amp;quot;aws_alb_listener_rule&amp;quot; &amp;quot;multi-condition-rule&amp;quot; {
&lt;&#x2F;span&gt;&lt;span&gt;  &amp;quot;action&amp;quot; {
&lt;&#x2F;span&gt;&lt;span&gt;    target_group_arn = &amp;quot;${aws_alb_target_group.my-specific-target-group.arn}&amp;quot;
&lt;&#x2F;span&gt;&lt;span&gt;    type = &amp;quot;forward&amp;quot;
&lt;&#x2F;span&gt;&lt;span&gt;  }
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;  condition { field=&amp;quot;path-pattern&amp;quot;  values=[&amp;quot;&#x2F;api&#x2F;1&#x2F;resolve&#x2F;default&amp;quot;]               }
&lt;&#x2F;span&gt;&lt;span&gt;  condition { field=&amp;quot;host-header&amp;quot;   values=[&amp;quot;example.org&amp;quot;]  }
&lt;&#x2F;span&gt;&lt;span&gt;  
&lt;&#x2F;span&gt;&lt;span&gt;  listener_arn = &amp;quot;${aws_alb_listener.my-listener.id}&amp;quot;
&lt;&#x2F;span&gt;&lt;span&gt;  priority = 108
&lt;&#x2F;span&gt;&lt;span&gt;}
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Finally, here is a sort of semi-complete Terraform code to get you some idea. I have also provided the code as &lt;a href=&quot;https:&#x2F;&#x2F;gist.github.com&#x2F;amanjeev&#x2F;7ad52fed4a1ee2d38ebf08023d943e53&quot;&gt;Github Gist: AWS Auto Scaling Group with Application Load Balancer using Terraform&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;terraform&quot; style=&quot;background-color:#eff1f5;color:#4f5b66;&quot; class=&quot;language-terraform &quot;&gt;&lt;code class=&quot;language-terraform&quot; data-lang=&quot;terraform&quot;&gt;&lt;span&gt;# Create a basic ALB 
&lt;&#x2F;span&gt;&lt;span&gt;resource &amp;quot;aws_alb&amp;quot; &amp;quot;my-app-alb&amp;quot; {
&lt;&#x2F;span&gt;&lt;span&gt;  name = &amp;quot;my-app-alb&amp;quot;
&lt;&#x2F;span&gt;&lt;span&gt;}
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;# Create target groups with one health check per group
&lt;&#x2F;span&gt;&lt;span&gt;resource &amp;quot;aws_alb_target_group&amp;quot; &amp;quot;target-group-1&amp;quot; {
&lt;&#x2F;span&gt;&lt;span&gt;  name = &amp;quot;target-group-1&amp;quot;
&lt;&#x2F;span&gt;&lt;span&gt;  port = 80
&lt;&#x2F;span&gt;&lt;span&gt;  protocol = &amp;quot;HTTP&amp;quot;
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;  lifecycle { create_before_destroy=true }
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;  health_check {
&lt;&#x2F;span&gt;&lt;span&gt;    path = &amp;quot;&#x2F;api&#x2F;1&#x2F;resolve&#x2F;default?path=&#x2F;service&#x2F;my-service&amp;quot;
&lt;&#x2F;span&gt;&lt;span&gt;    port = 2001
&lt;&#x2F;span&gt;&lt;span&gt;    healthy_threshold = 6
&lt;&#x2F;span&gt;&lt;span&gt;    unhealthy_threshold = 2
&lt;&#x2F;span&gt;&lt;span&gt;    timeout = 2
&lt;&#x2F;span&gt;&lt;span&gt;    interval = 5
&lt;&#x2F;span&gt;&lt;span&gt;    matcher = &amp;quot;200&amp;quot;
&lt;&#x2F;span&gt;&lt;span&gt;  }
&lt;&#x2F;span&gt;&lt;span&gt;}
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;resource &amp;quot;aws_alb_target_group&amp;quot; &amp;quot;target-group-2&amp;quot; {
&lt;&#x2F;span&gt;&lt;span&gt;  name = &amp;quot;target-group-2&amp;quot;
&lt;&#x2F;span&gt;&lt;span&gt;  port = 80
&lt;&#x2F;span&gt;&lt;span&gt;  protocol = &amp;quot;HTTP&amp;quot;
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;  lifecycle { create_before_destroy=true }
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;  health_check {
&lt;&#x2F;span&gt;&lt;span&gt;    path = &amp;quot;&#x2F;api&#x2F;2&#x2F;resolve&#x2F;default?path=&#x2F;service&#x2F;my-service&amp;quot;
&lt;&#x2F;span&gt;&lt;span&gt;    port = 2010
&lt;&#x2F;span&gt;&lt;span&gt;    healthy_threshold = 6
&lt;&#x2F;span&gt;&lt;span&gt;    unhealthy_threshold = 2
&lt;&#x2F;span&gt;&lt;span&gt;    timeout = 2
&lt;&#x2F;span&gt;&lt;span&gt;    interval = 5
&lt;&#x2F;span&gt;&lt;span&gt;    matcher = &amp;quot;200&amp;quot;
&lt;&#x2F;span&gt;&lt;span&gt;  }
&lt;&#x2F;span&gt;&lt;span&gt;}
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;# Create a Listener 
&lt;&#x2F;span&gt;&lt;span&gt;resource &amp;quot;aws_alb_listener&amp;quot; &amp;quot;my-alb-listener&amp;quot; {
&lt;&#x2F;span&gt;&lt;span&gt;  default_action {
&lt;&#x2F;span&gt;&lt;span&gt;    target_group_arn = &amp;quot;${aws_alb_target_group.target-group-1.arn}&amp;quot;
&lt;&#x2F;span&gt;&lt;span&gt;    type = &amp;quot;forward&amp;quot;
&lt;&#x2F;span&gt;&lt;span&gt;  }
&lt;&#x2F;span&gt;&lt;span&gt;  load_balancer_arn = &amp;quot;${aws_alb.my-app-alb.arn}&amp;quot;
&lt;&#x2F;span&gt;&lt;span&gt;  port = 80
&lt;&#x2F;span&gt;&lt;span&gt;  protocol = &amp;quot;HTTP&amp;quot;
&lt;&#x2F;span&gt;&lt;span&gt;}
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;# Create Listener Rules
&lt;&#x2F;span&gt;&lt;span&gt;resource &amp;quot;aws_alb_listener_rule&amp;quot; &amp;quot;rule-1&amp;quot; {
&lt;&#x2F;span&gt;&lt;span&gt;  action {
&lt;&#x2F;span&gt;&lt;span&gt;    target_group_arn = &amp;quot;${aws_alb_target_group.target-group-1.arn}&amp;quot;
&lt;&#x2F;span&gt;&lt;span&gt;    type = &amp;quot;forward&amp;quot;
&lt;&#x2F;span&gt;&lt;span&gt;  }
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;  condition { field=&amp;quot;path-pattern&amp;quot; values=[&amp;quot;&#x2F;api&#x2F;1&#x2F;resolve&#x2F;default&amp;quot;] }
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;  listener_arn = &amp;quot;${aws_alb_listener.my-alb-listener.id}&amp;quot;
&lt;&#x2F;span&gt;&lt;span&gt;  priority = 100
&lt;&#x2F;span&gt;&lt;span&gt;}
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;resource &amp;quot;aws_alb_listener_rule&amp;quot; &amp;quot;rule-2&amp;quot; {
&lt;&#x2F;span&gt;&lt;span&gt;  action {
&lt;&#x2F;span&gt;&lt;span&gt;    target_group_arn = &amp;quot;${aws_alb_target_group.target-group-2.arn}&amp;quot;
&lt;&#x2F;span&gt;&lt;span&gt;    type = &amp;quot;forward&amp;quot;
&lt;&#x2F;span&gt;&lt;span&gt;  }
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;  condition { field=&amp;quot;path-pattern&amp;quot; values=[&amp;quot;&#x2F;api&#x2F;2&#x2F;resolve&#x2F;default&amp;quot;] }
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;  listener_arn = &amp;quot;${aws_alb_listener.my-alb-listener.id}&amp;quot;
&lt;&#x2F;span&gt;&lt;span&gt;  priority = 101
&lt;&#x2F;span&gt;&lt;span&gt;}
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;# Create an ASG that ties all of this together
&lt;&#x2F;span&gt;&lt;span&gt;resource &amp;quot;aws_autoscaling_group&amp;quot; &amp;quot;my-alb-asg&amp;quot; {
&lt;&#x2F;span&gt;&lt;span&gt;  name = &amp;quot;my-alb-asg&amp;quot;
&lt;&#x2F;span&gt;&lt;span&gt;  min_size = &amp;quot;3&amp;quot;
&lt;&#x2F;span&gt;&lt;span&gt;  max_size = &amp;quot;6&amp;quot;
&lt;&#x2F;span&gt;&lt;span&gt;  launch_configuration = &amp;quot;${aws_launch_configuration.my-app-alb.name}&amp;quot;
&lt;&#x2F;span&gt;&lt;span&gt;  termination_policies = [
&lt;&#x2F;span&gt;&lt;span&gt;    &amp;quot;OldestInstance&amp;quot;,
&lt;&#x2F;span&gt;&lt;span&gt;    &amp;quot;OldestLaunchConfiguration&amp;quot;,
&lt;&#x2F;span&gt;&lt;span&gt;  ]
&lt;&#x2F;span&gt;&lt;span&gt;  
&lt;&#x2F;span&gt;&lt;span&gt;  health_check_type = &amp;quot;ELB&amp;quot;
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;  depends_on = [
&lt;&#x2F;span&gt;&lt;span&gt;    &amp;quot;aws_alb.my-app-alb&amp;quot;,
&lt;&#x2F;span&gt;&lt;span&gt;  ]
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;  target_group_arns = [
&lt;&#x2F;span&gt;&lt;span&gt;    &amp;quot;${aws_alb_target_group.target-group-1.arn}&amp;quot;,
&lt;&#x2F;span&gt;&lt;span&gt;    &amp;quot;${aws_alb_target_group.target-group-2.arn}&amp;quot;,
&lt;&#x2F;span&gt;&lt;span&gt;  ]
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;  lifecycle {
&lt;&#x2F;span&gt;&lt;span&gt;    create_before_destroy = true
&lt;&#x2F;span&gt;&lt;span&gt;  }
&lt;&#x2F;span&gt;&lt;span&gt;}
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;h3 id=&quot;further-todo&quot;&gt;Further ToDo&lt;&#x2F;h3&gt;
&lt;ul&gt;
&lt;li&gt;Learn more about Network Load Balancer.&lt;&#x2F;li&gt;
&lt;li&gt;Comparison to GCP and Azure.&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>RustConf 2018 Portland OR</title>
        <published>2018-09-03T00:00:00+00:00</published>
        <updated>2018-09-03T00:00:00+00:00</updated>
        
        <author>
          <name>
            
              Unknown
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://amanjeev.com/blog/rustconf-2018-portland-oregon/"/>
        <id>https://amanjeev.com/blog/rustconf-2018-portland-oregon/</id>
        
        <content type="html" xml:base="https://amanjeev.com/blog/rustconf-2018-portland-oregon/">&lt;p&gt;RustConf has been the first ever conference for a programming language that I was eager to attend. Since, it’s a new-ish language, the conference was not as big as, say, PyCon or KubeCon would be. This made it easy to talk to people you generally only know via Twitter. Also, the duration of conference was one day (two if you include the training day). During this conference I met three kinds of rustaceans —&lt;&#x2F;p&gt;
&lt;ol&gt;
&lt;li&gt;Core team.&lt;&#x2F;li&gt;
&lt;li&gt;Using Rust at work.&lt;&#x2F;li&gt;
&lt;li&gt;Trying to push my boss to use Rust at work.&lt;&#x2F;li&gt;
&lt;&#x2F;ol&gt;
&lt;p&gt;Out of the three categories, most folks I met were in #3, including myself. I met a bunch of enthusiasts who just showed up and I like that.&lt;&#x2F;p&gt;
&lt;br&gt;
&lt;blockquote class=&quot;twitter-tweet&quot;&gt;&lt;p lang=&quot;en&quot; dir=&quot;ltr&quot;&gt;“Hello everyone! Welcome to &lt;a href=&quot;https:&#x2F;&#x2F;twitter.com&#x2F;rustconf?ref_src=twsrc%5Etfw&quot;&gt;@rustconf&lt;&#x2F;a&gt; everyone! How many of you is this your first time at RustConf? [almost the whole room raises their hands] Holy s***!” —&lt;a href=&quot;https:&#x2F;&#x2F;twitter.com&#x2F;arshia__?ref_src=twsrc%5Etfw&quot;&gt;@arshia__&lt;&#x2F;a&gt; 😆&lt;&#x2F;p&gt;&amp;mdash; Chris Krycho (@chriskrycho) &lt;a href=&quot;https:&#x2F;&#x2F;twitter.com&#x2F;chriskrycho&#x2F;status&#x2F;1030497830731886592?ref_src=twsrc%5Etfw&quot;&gt;August 17, 2018&lt;&#x2F;a&gt;&lt;&#x2F;blockquote&gt; &lt;script async src=&quot;https:&#x2F;&#x2F;platform.twitter.com&#x2F;widgets.js&quot; charset=&quot;utf-8&quot;&gt;&lt;&#x2F;script&gt;
&lt;br&gt;
I have never been a part of community that I feel was working for this level of inclusivity. The community and the language, both support the philosophy of “Hack without fear”. The level of commitment from core team and the community organizers resulted in a very diverse conference, compared to other conferences I have been to. I hope this will continue to get better and the community will be supportive.
&lt;h3 id=&quot;training&quot;&gt;training&lt;&#x2F;h3&gt;
&lt;p&gt;I am a big proponent of good training days in conferences. These are some of the best days for learning via hands-on.&lt;&#x2F;p&gt;
&lt;h4 id=&quot;traits-and-threads-by-aaron-turon&quot;&gt;traits and threads by Aaron Turon&lt;&#x2F;h4&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https:&#x2F;&#x2F;twitter.com&#x2F;aaron_turon&quot;&gt;Aaron Turon on Twitter&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;li&gt;&lt;a href=&quot;http:&#x2F;&#x2F;www.rust-tutorials.com&#x2F;exercises&#x2F;&quot;&gt;Tutorial with code&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;li&gt;&lt;a href=&quot;https:&#x2F;&#x2F;doc.rust-lang.org&#x2F;book&#x2F;second-edition&#x2F;ch16-01-threads.html&quot;&gt;Traits - Rust book&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;Aaron is a mindful tutor. This workshop was beginner-friendly. Even though the description says that “tutorial assumes basic understanding of ownership and borrowing”, Aaron still gave a refresher.&lt;&#x2F;p&gt;
&lt;p&gt;To begin, If you do not know about threads I recommend that you start with &lt;a href=&quot;https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Thread_(computing)&quot;&gt;threads on Wikipedia&lt;&#x2F;a&gt; and read more about &lt;a href=&quot;https:&#x2F;&#x2F;doc.rust-lang.org&#x2F;book&#x2F;second-edition&#x2F;ch16-01-threads.html&quot;&gt;threads in Rust book&lt;&#x2F;a&gt;. As you will read through that page, you will note that Rust wants to keep the runtime really small (❤️). Rust’s thread model is not &lt;em&gt;green&lt;&#x2F;em&gt; (used to be, but not anymore). That is, it has one OS thread mapped to one language thread.&lt;&#x2F;p&gt;
&lt;p&gt;Uses of &lt;em&gt;threads&lt;&#x2F;em&gt; is mostly to facilitate parallelism in the program. In the workshop, I learnt in hands-on style that Rust’s parallelism supports multiple paradigms, like Message passing and Mutable shared memory. Even though these methods have issues in general, like &lt;em&gt;data races&lt;&#x2F;em&gt;, Rust’s borrow-checking and ownership makes sure that the compiler helps you eliminate potential &lt;em&gt;data races&lt;&#x2F;em&gt; early on.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;em&gt;Traits&lt;&#x2F;em&gt; are Rust’s &lt;code class=&quot;inline&quot;&gt;interfaces&lt;&#x2F;code&gt; in many ways although not exactly. Most of the idiomatic Rust revolves around defining and using &lt;em&gt;types&lt;&#x2F;em&gt;. Usually, the &lt;em&gt;types&lt;&#x2F;em&gt; need to have some functions associated with them to be more useful. &lt;em&gt;Traits&lt;&#x2F;em&gt; allow you to define certain &lt;em&gt;methods&lt;&#x2F;em&gt; in them and you can &lt;em&gt;implement&lt;&#x2F;em&gt; these &lt;em&gt;Traits&lt;&#x2F;em&gt; for any &lt;em&gt;type&lt;&#x2F;em&gt; of your choice.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;a href=&quot;http:&#x2F;&#x2F;www.rust-tutorials.com&#x2F;exercises&#x2F;&quot;&gt;See all the tutorials for yourself&lt;&#x2F;a&gt; if you want some hands-on with Traits and Threads.&lt;&#x2F;p&gt;
&lt;h4 id=&quot;futures-and-async-programming-by-michael-gattozzi&quot;&gt;futures and async programming by Michael Gattozzi&lt;&#x2F;h4&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https:&#x2F;&#x2F;twitter.com&#x2F;mgattozzi&quot;&gt;Michael Gattozzi on Twitter&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;li&gt;&lt;a href=&quot;https:&#x2F;&#x2F;mgattozzi.com&#x2F;classes&#x2F;run-await-with-me&quot;&gt;Slides&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;li&gt;&lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;mgattozzi&#x2F;async-await-class&quot;&gt;Exercise code&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;li&gt;&lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;tokio-rs&#x2F;tokio&quot;&gt;Tokio: runtime for writing reliable, asynchronous, and slim applications with the Rust&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;li&gt;&lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;rust-lang-nursery&#x2F;futures-rs&quot;&gt;Futures-rs: Zero-cost asynchronous programming in Rust&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;With this workshop, Michael took me to a place in Rustland, where I was afraid to go on my own. Up until I saw this workshop listed on RustConf’s website, I was not sure whether I want to even try looking at Async stuff in Rust, given how little I know about Rust at the moment. Did I mention that Michael was very funny which is a good strategy to relax everyone.&lt;&#x2F;p&gt;
&lt;p&gt;The workshop, for majority, dug deep into the details and components of Async in Rust which is helpful if you want to understand what’s going on under the hood and at the same time how much work it requires to do manually. This is directly opposite to when the construct and semantics are provided by the language itself, which is where Rust is going, IIRC.&lt;&#x2F;p&gt;
&lt;p&gt;I encourage you to go through &lt;a href=&quot;https:&#x2F;&#x2F;mgattozzi.com&#x2F;classes&#x2F;run-await-with-me&quot;&gt;the slides&lt;&#x2F;a&gt;, as well as the &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;mgattozzi&#x2F;async-await-class&quot;&gt;exercise itself&lt;&#x2F;a&gt;. They are clear and helpful.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;conference-day&quot;&gt;conference day&lt;&#x2F;h3&gt;
&lt;p&gt;I am listing some of the resources I found during the talks. I am not going to write about the talks themselves as they will be online and you must watch them. 😊&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;japaric&#x2F;criterion.rs&quot;&gt;criterion.rs: Statistics-driven micro-benchmarking library&lt;&#x2F;a&gt;. Via “Benchmarking and Optimization of Rust Libraries By Paul Mason”&lt;&#x2F;li&gt;
&lt;li&gt;The core ideas of Rust — Ownership and Borrowing — can be applied to hardware as well. Via “Getting Something for Nothing By James Munns”&lt;&#x2F;li&gt;
&lt;li&gt;&lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;pingcap&#x2F;raft-rs&quot;&gt;raft-rs: Raft distributed consensus algorithm implemented in Rust&lt;&#x2F;a&gt;. Via “Using Raft in Rust By Siddon Tang”&lt;&#x2F;li&gt;
&lt;li&gt;&lt;a href=&quot;https:&#x2F;&#x2F;mozilla.github.io&#x2F;mentat&#x2F;&quot;&gt;Project Mentat: A relational (not key-value, not document-oriented) store that makes it easy to describe, grow, and reuse your domain schema&lt;&#x2F;a&gt;. Via “Project Mentat: a store for evolving data in Rust By Emily Toop”&lt;&#x2F;li&gt;
&lt;li&gt;Just the talk “Embedding Rust in C&#x2F;C++ By Katharina”. Just watch this talk. Just do it.&lt;&#x2F;li&gt;
&lt;li&gt;&lt;a href=&quot;https:&#x2F;&#x2F;c2rust.com&#x2F;&quot;&gt;c2rust: a tool to translate C to semantically equivalent Rust&lt;&#x2F;a&gt;. Via “C2Rust: Migrating Legacy Code to Rust By Per Larsen”&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Terraform and YAML related notes</title>
        <published>2018-08-10T00:00:00+00:00</published>
        <updated>2018-08-10T00:00:00+00:00</updated>
        
        <author>
          <name>
            
              Unknown
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://amanjeev.com/blog/terraform-and-yaml/"/>
        <id>https://amanjeev.com/blog/terraform-and-yaml/</id>
        
        <content type="html" xml:base="https://amanjeev.com/blog/terraform-and-yaml/">&lt;p&gt;If you manage applications, you likely come across a ton of structured data that stays mostly static but must be tracked, version-controlled and be visible, especially when someone modifies it. For some folks, that is a CMS, for others a stack of papyri and for some more it is just a long oral tradition of chanting or yelling. I, however, prefer readable, structured text files. That&#x27;s why I like the idea of &lt;a href=&quot;https:&#x2F;&#x2F;www.terraform.io&#x2F;&quot;&gt;Terraform&lt;&#x2F;a&gt; or infrastructure-as-code.
&lt;br&gt;
Last year, we faced a problem for management of some of our infrastructure-data. We wanted to manage the &lt;a href=&quot;https:&#x2F;&#x2F;www.consul.io&#x2F;intro&#x2F;getting-started&#x2F;kv.html&quot;&gt;Consul KV store&lt;&#x2F;a&gt; data via Terraform and not depend on Consul&#x27;s UI. The problem was that there was no default Terraform provider for the particular task of manipulation of &lt;a href=&quot;https:&#x2F;&#x2F;www.consul.io&#x2F;intro&#x2F;getting-started&#x2F;kv.html&quot;&gt;Consul KV store&lt;&#x2F;a&gt;. There are provider resources like &quot;&lt;a href=&quot;https:&#x2F;&#x2F;www.terraform.io&#x2F;docs&#x2F;providers&#x2F;consul&#x2F;r&#x2F;keys.html&quot;&gt;consul_keys&lt;&#x2F;a&gt;&quot; and &quot;&lt;a href=&quot;https:&#x2F;&#x2F;www.terraform.io&#x2F;docs&#x2F;providers&#x2F;consul&#x2F;d&#x2F;key_prefix.html&quot;&gt;consul_key_prefix&lt;&#x2F;a&gt;&quot; but they alone were not adequate for a cleaner solution. We have multiple datacenters and it is tiresome to edit keys and values when needed. The data had a ton of repetition across various datacenters with some common parts. Moreover, Web UI does not keep a record of edits. As a result, the visibility within the team was close to zero.
&lt;br&gt;
Given the lack of any such plugin, at that time, we went on a path to use &lt;a href=&quot;https:&#x2F;&#x2F;www.terraform.io&#x2F;docs&#x2F;providers&#x2F;external&#x2F;data_source.html&quot;&gt;Terraform&#x27;s external data source&lt;&#x2F;a&gt; and decided to store the KV data in a &lt;a href=&quot;http:&#x2F;&#x2F;yaml.org&#x2F;&quot;&gt;YAML&lt;&#x2F;a&gt; file which will be read by the external data source and will populate the &quot;consul_key_prefix&quot;. First, external data source is your custom program that reads from stdin and spits out on stdout, both as JSON objects. The official documentation for this &quot;external data source&quot; provider shows that you define it as&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;terraform&quot; style=&quot;background-color:#eff1f5;color:#4f5b66;&quot; class=&quot;language-terraform &quot;&gt;&lt;code class=&quot;language-terraform&quot; data-lang=&quot;terraform&quot;&gt;&lt;span&gt;data &amp;quot;external&amp;quot; &amp;quot;example&amp;quot; {
&lt;&#x2F;span&gt;&lt;span&gt;  # Call &amp;quot;python &#x2F;path&#x2F;to&#x2F;mod&#x2F;example.py&amp;quot;
&lt;&#x2F;span&gt;&lt;span&gt;  program = [
&lt;&#x2F;span&gt;&lt;span&gt;      &amp;quot;python&amp;quot;, 
&lt;&#x2F;span&gt;&lt;span&gt;      &amp;quot;${path.module}&#x2F;example.py&amp;quot;
&lt;&#x2F;span&gt;&lt;span&gt;    ]
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;  # with JSON query
&lt;&#x2F;span&gt;&lt;span&gt;  query = {
&lt;&#x2F;span&gt;&lt;span&gt;    id = &amp;quot;abc123&amp;quot;
&lt;&#x2F;span&gt;&lt;span&gt;  }
&lt;&#x2F;span&gt;&lt;span&gt;}
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;In the problem that I stated above, it was decided to store the Consul Key&#x2F;Value pairs as nested YAML file for each datacenter and a common section for common keys. Something like:&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;yaml&quot; style=&quot;background-color:#eff1f5;color:#4f5b66;&quot; class=&quot;language-yaml &quot;&gt;&lt;code class=&quot;language-yaml&quot; data-lang=&quot;yaml&quot;&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;common&lt;&#x2F;span&gt;&lt;span&gt;:
&lt;&#x2F;span&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;key_common_1&lt;&#x2F;span&gt;&lt;span&gt;: &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;value_common_1
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;dc1&lt;&#x2F;span&gt;&lt;span&gt;:
&lt;&#x2F;span&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d08770;&quot;&gt;&amp;lt;&amp;lt;&lt;&#x2F;span&gt;&lt;span&gt;: &lt;&#x2F;span&gt;&lt;span style=&quot;color:#b48ead;&quot;&gt;*&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;common
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;key11&lt;&#x2F;span&gt;&lt;span&gt;: &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;value11
&lt;&#x2F;span&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;key12&lt;&#x2F;span&gt;&lt;span&gt;: &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;value12
&lt;&#x2F;span&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;key13&lt;&#x2F;span&gt;&lt;span&gt;:
&lt;&#x2F;span&gt;&lt;span&gt;        &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;key131&lt;&#x2F;span&gt;&lt;span&gt;: &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;value131
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;dc2&lt;&#x2F;span&gt;&lt;span&gt;:
&lt;&#x2F;span&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d08770;&quot;&gt;&amp;lt;&amp;lt;&lt;&#x2F;span&gt;&lt;span&gt;: &lt;&#x2F;span&gt;&lt;span style=&quot;color:#b48ead;&quot;&gt;*&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;common
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;key21&lt;&#x2F;span&gt;&lt;span&gt;: &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;value21
&lt;&#x2F;span&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;key22&lt;&#x2F;span&gt;&lt;span&gt;: &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;value22
&lt;&#x2F;span&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;key23&lt;&#x2F;span&gt;&lt;span&gt;:
&lt;&#x2F;span&gt;&lt;span&gt;        &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;key231&lt;&#x2F;span&gt;&lt;span&gt;: &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;value231
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;The wonderful part of YAML is that it is machine-and-human-readable, and can succinctly represent hierarchy in a document. Hence, it is well-suited for the representation of various datacenters and their respective KV data, which is what we wanted to do. Take the key &quot;key131&quot; in &quot;Datacenter 1&quot;. You can depict the &quot;path&quot; to &quot;key131&quot; as Consul KV via &lt;code&gt;dc1&#x2F;key13&#x2F;key131&lt;&#x2F;code&gt;&lt;&#x2F;p&gt;
&lt;p&gt;Now, comes the question of what to do with external datasource. You can write that in any language&#x2F;platform that can read from stdin and write to stdout. In the official documentation they use bash. However, I chose Python for its simplicity, good YAML support and JSON interoperability. Also, I could get help from some team members if I ever got stuck. With these tools, the last thing I want to add is that you can use Python&#x27;s &lt;a href=&quot;https:&#x2F;&#x2F;flatdict.readthedocs.io&#x2F;&quot;&gt;flatdict&lt;&#x2F;a&gt; with delimiter=&quot;&#x2F;&quot; as&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;python&quot; style=&quot;background-color:#eff1f5;color:#4f5b66;&quot; class=&quot;language-python &quot;&gt;&lt;code class=&quot;language-python&quot; data-lang=&quot;python&quot;&gt;&lt;span style=&quot;color:#b48ead;&quot;&gt;import &lt;&#x2F;span&gt;&lt;span&gt;flatdict
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#b48ead;&quot;&gt;with &lt;&#x2F;span&gt;&lt;span style=&quot;color:#96b5b4;&quot;&gt;open&lt;&#x2F;span&gt;&lt;span&gt;(file_path, &amp;#39;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;r&lt;&#x2F;span&gt;&lt;span&gt;&amp;#39;) &lt;&#x2F;span&gt;&lt;span style=&quot;color:#b48ead;&quot;&gt;as &lt;&#x2F;span&gt;&lt;span&gt;yf:
&lt;&#x2F;span&gt;&lt;span&gt;    yaml_dict = flatdict.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;FlatDict&lt;&#x2F;span&gt;&lt;span&gt;(yaml.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;load&lt;&#x2F;span&gt;&lt;span&gt;(yf), 
&lt;&#x2F;span&gt;&lt;span&gt;                                  &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;delimiter&lt;&#x2F;span&gt;&lt;span&gt;=&amp;#39;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;&#x2F;&lt;&#x2F;span&gt;&lt;span&gt;&amp;#39;)
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;This creates a flattened dictionary, each key of which is the &quot;path&quot; with segments delimited by &quot;&#x2F;&quot;. Example &lt;code&gt;dc1&#x2F;key13&#x2F;key131&lt;&#x2F;code&gt;&lt;&#x2F;p&gt;
&lt;p&gt;All that is left now is manipulation of the above dict if needed and writing JSON to stdout so it can be read by the Terraform resource &quot;consul_key_prefix&quot;. 😇&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;terraform&quot; style=&quot;background-color:#eff1f5;color:#4f5b66;&quot; class=&quot;language-terraform &quot;&gt;&lt;code class=&quot;language-terraform&quot; data-lang=&quot;terraform&quot;&gt;&lt;span&gt;resource &amp;quot;consul_key_prefix&amp;quot; &amp;quot;keys&amp;quot; {
&lt;&#x2F;span&gt;&lt;span&gt;  datacenter = &amp;quot;${var.datacenter}&amp;quot;
&lt;&#x2F;span&gt;&lt;span&gt;  path_prefix = &amp;quot;${var.prefix}${var.path}&amp;quot;
&lt;&#x2F;span&gt;&lt;span&gt;  subkeys = &amp;quot;${data.external.mydata.result}&amp;quot;
&lt;&#x2F;span&gt;&lt;span&gt;}
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;But, I am not done telling you about this yet. My friend and colleague &lt;a href=&quot;https:&#x2F;&#x2F;ashald.net&#x2F;&quot;&gt;Borys Pierov&lt;&#x2F;a&gt; wrote new set of Terraform provider plugins because there was a need for a good Consul ACL management provider. He abstracted a bunch of stuff into independent plugins so you can go from flexible to powerful, if you want.&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;Ashald&#x2F;terraform-provider-transform&quot;&gt;terraform-provider-transform&lt;&#x2F;a&gt;: Terraform data sources providing data transformations missing from core Terraform&lt;&#x2F;li&gt;
&lt;li&gt;&lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;Ashald&#x2F;terraform-provider-stateful&quot;&gt;terraform-provider-stateful&lt;&#x2F;a&gt;: Generic abstract stateful resources to manage arbitrary objects by executing arbitrary commands&lt;&#x2F;li&gt;
&lt;li&gt;&lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;Ashald&#x2F;terraform-provider-yaml&quot;&gt;terraform-provider-yaml&lt;&#x2F;a&gt;: Terraform data source that can consume YAML input&lt;&#x2F;li&gt;
&lt;li&gt;&lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;Ashald&#x2F;terraform-provider-consulacl&quot;&gt;terraform-provider-consulacl&lt;&#x2F;a&gt;: Consul ACL Terraform Provider&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;So, if you use Consul and you need to manage KV or ACL, you do not have any excuses to not use the above tools. Please let me know if I missed something or there are alternate approaches that you&#x27;ve taken. Thanks for reading. 😊&lt;&#x2F;p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Leibniz’s monads</title>
        <published>2016-02-14T00:00:00+00:00</published>
        <updated>2016-02-14T00:00:00+00:00</updated>
        
        <author>
          <name>
            
              Unknown
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://amanjeev.com/blog/leibniz-monads/"/>
        <id>https://amanjeev.com/blog/leibniz-monads/</id>
        
        <content type="html" xml:base="https://amanjeev.com/blog/leibniz-monads/">&lt;p&gt;&lt;img src=&quot;https:&#x2F;&#x2F;upload.wikimedia.org&#x2F;wikipedia&#x2F;commons&#x2F;6&#x2F;6a&#x2F;Gottfried_Wilhelm_von_Leibniz.jpg&quot; alt=&quot;Photo image of Gottfried Wilhelm von Leibniz by Christoph Bernhard Francke, via Wikimedia Commons&quot; title=&quot;Photo image of Gottfried Wilhelm von Leibniz by Christoph Bernhard Francke, via Wikimedia Commons&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;I recently discovered the philosophy of Gottfried Wilhelm Leibniz, the polymath and philosopher. Some believe that he developed Calculus independent of Sir Isaac Newton, as a mathematician. We have been using &lt;a href=&quot;https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Leibniz%27s_notation&quot;&gt;Leibniz’s notation&lt;&#x2F;a&gt;, in the infinitesimal calculus. He also contributed to what we know today as modern logic, binary system etc. It is his infinitesimal calculus and its relation with his philosophy that I find fascinating. The way he thought about the world can be seen in his math work, especially his calculus.&lt;&#x2F;p&gt;
&lt;p&gt;“Monadology” is his seminal philosophy work. Monad, the idea and the word itself, has existed in philosophy for centuries. Pythagoreans are attribute for its origin. &lt;a href=&quot;https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Monad_(philosophy)&quot;&gt;According to Wikipedia&lt;&#x2F;a&gt; —&lt;&#x2F;p&gt;
&lt;blockquote&gt;
&lt;p&gt;Monad refers in cosmogony (creation theories) to the first being, divinity, or the totality of all beings. The concept was reportedly conceived by the Pythagoreans and may refer variously to a single source acting alone and&#x2F;or an indivisible origin.&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;p&gt;Monad as a concept was taken and enhanced by Leibniz where he referred to Monad as an &lt;em&gt;elementary particle&lt;&#x2F;em&gt;. He calls Monads as the “real atoms of nature”. According to Leibniz, Monads —&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;are indivisible&lt;&#x2F;li&gt;
&lt;li&gt;can neither be made, nor destroyed&lt;&#x2F;li&gt;
&lt;li&gt;do not have parts&lt;&#x2F;li&gt;
&lt;li&gt;do not occupy space&lt;&#x2F;li&gt;
&lt;li&gt;may possess qualities&lt;&#x2F;li&gt;
&lt;li&gt;can cause changes to one another&lt;&#x2F;li&gt;
&lt;li&gt;come into being by creation&lt;&#x2F;li&gt;
&lt;li&gt;destroyed by annihilation&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;Leibniz considered these infinite number of Monads made up the space. It means that the space is not empty, as Newton had suggested, but has Monads and since they indivisible, but do not take space, they are the basis for all the other ‘stuff’ somehow by interacting with each other. The part of Monads being indivisible is the key. That makes them infinitesimal, that cannot be detected by any apparatus we can build. Thus, we can see how the above is similar to his calculus work which deals with&lt;&#x2F;p&gt;
&lt;blockquote&gt;
&lt;p&gt;Sum of infinite number of infinitesimals equate a finite amount.&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;p&gt;As Ruth Lydia Saw writes in the best way possible —&lt;&#x2F;p&gt;
&lt;blockquote&gt;
&lt;p&gt;If we consider his own discoveries in mathematics, we shall see how marvellously it must have seemed to Leibniz that everything pointed to and reinforced his metaphysical account of universe. For him, the universe is constituted by an infinite number of non-spatial beings presenting the appearance of large bodies moving in space. At the same time, the invention of the microscope shows minute differences which are lost in large perception and leads to possibility of ever more minute differences to be revealed by more powerful instruments. Then Leibniz himself invents the infinitesimal calculus which is based on the possibility and the usefulness of treating a finite amount as equivalent to the sum of an infinite number of infinitesimal amounts.&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;p&gt;Note: If you were looking for Monad in functional programming then please refer to &lt;a href=&quot;https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Monad_(functional_programming)&quot;&gt;Wikipedia&lt;&#x2F;a&gt; or &lt;a href=&quot;https:&#x2F;&#x2F;curiosity-driven.org&#x2F;monads-in-javascript&quot;&gt;Monads in JavaScript&lt;&#x2F;a&gt; or &lt;a href=&quot;https:&#x2F;&#x2F;wiki.haskell.org&#x2F;Monad&quot;&gt;Monad in Haskell&lt;&#x2F;a&gt; or maybe &lt;a href=&quot;https:&#x2F;&#x2F;stackoverflow.com&#x2F;questions&#x2F;2704652&#x2F;monad-in-plain-english-for-the-oop-programmer-with-no-fp-background&quot;&gt;Stackoverflow&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
</content>
        
    </entry>
</feed>
