<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Martin Dobberstein (gutschilla) on Medium]]></title>
        <description><![CDATA[Stories by Martin Dobberstein (gutschilla) on Medium]]></description>
        <link>https://medium.com/@martin-dobberstein?source=rss-5180c3ef932f------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*_0Wb5-zp4k6spVxl.</url>
            <title>Stories by Martin Dobberstein (gutschilla) on Medium</title>
            <link>https://medium.com/@martin-dobberstein?source=rss-5180c3ef932f------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 04:49:37 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@martin-dobberstein/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[How I replaced letsencrypt with CloudFlare and why]]></title>
            <link>https://martin-dobberstein.medium.com/how-i-replaced-letsencrypt-with-cloudflare-and-why-88e2ac87340d?source=rss-5180c3ef932f------2</link>
            <guid isPermaLink="false">https://medium.com/p/88e2ac87340d</guid>
            <category><![CDATA[dns]]></category>
            <category><![CDATA[lets-encrypt]]></category>
            <category><![CDATA[cloudflare]]></category>
            <category><![CDATA[tls-certificate]]></category>
            <dc:creator><![CDATA[Martin Dobberstein (gutschilla)]]></dc:creator>
            <pubDate>Wed, 30 Jun 2021 13:39:25 GMT</pubDate>
            <atom:updated>2021-06-30T13:39:25.265Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aITdl2wZANhMrgGFvRo54A.png" /><figcaption>Clouds above my home town with artificial lens flare. Nice, huh?</figcaption></figure><p><a href="https://letsencrypt.org/">Letsencrypt</a> is a great tool to obtain valid <a href="https://de.wikipedia.org/wiki/Transport_Layer_Security">TLS certificates</a> for your services for free. But using it long-term started to be time-consuming.</p><p>In my case these were almost always some kind of web service, like my dad’s poem website or some HTTP API needed to expose. In any of these cases I wanted them to be both encrypted and ensure clients are talking to my servers.</p><h3>Being old-fashioned</h3><p>So I would go and setup ther service and nginx on a server along with letsencrypt and the automate the certificate refresh — they last for 3 months only — via cronjobs usually.</p><p>That works fine, and I wrote <a href="https://medium.com/@mcsonique/deploying-elixir-phoenix-projects-to-production-44a236c643c">an article</a> about it. Later, I moved most of my stuff to Kubernetes and again used letsencrypt to create certs. This was a bit clumsy but certainly doable, either manually by using the good ‘ole cronjobs to create and update secrets used in ingress controllers, later using <a href="https://cert-manager.io/">CertManager</a>.</p><p>This worked fine <br>-ish</p><ul><li>Fumbling with letsencrypt meant installing it in the first place</li><li>The templating to automate all this was a maintenance mess (for me). No templating at all is a worse mess — just look at the length of <a href="https://medium.com/@mcsonique/deploying-elixir-phoenix-projects-to-production-44a236c643c">that article</a>.</li><li>Letsencrypt needs to open port 80 in server mode which collides with web servers; I found it too hard to automate DNS-based validation, synchronizing DNS updates with letsencrypt invokes.</li></ul><h3>I am lazy</h3><p>The less time I spend on tedious infrastructure the more time I can dedicate to my linking my dad’s poems to readings of those or help my friends Julia and Till to get started with their <a href="https://uniq.rocks/">necklace business</a>.</p><p>So instead of setting this all up myself, I outsourced the efforts to CloudFlare:</p><h4>Register the domain</h4><p>You probably have a domain or subdomain already. If not I can recommend <a href="https://www.inwx.com/">INWX </a>for cheap and reliable domain registration but you can use whomever.</p><p>It’s important that they let you change the NS entries (name server set) for said domain — so Cloudflare can take over.</p><h4>Setup the domain in CloudFlare</h4><p>Find your way around signing up with <a href="https://cloudflare.com/">CloudFlare</a> and setting up the domain name that you want to be under their control.</p><p>Cloudflare will scan your domain’s DNS settings and copy them.</p><p>This is both convenient and especially important when you have an email service setup, probably with your domain provider or even your own. Below you can see the MX and TXT records that need to be correct for your email to work properly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PxE6aL3qMdcu47sPlviHNg.png" /><figcaption>at the top you can see that we are in the DNS section</figcaption></figure><p>Two things are important here: the content of the A record for that domain and the proxy status:</p><p>The content points to your server (or load balancer) where your web service runs on. The proxy status needs to be “proxied” in order to act as a, well, proxy in front of your service. This proxy will then handle encryption for you — making sure a TLS certificate for your domain is being issued and renewed and configure HTTPS on the proxy.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vINABnkgVuLVC6Cr5SG4sw.png" /><figcaption>I am flexible about security here 😵</figcaption></figure><h4>Being secure</h4><p>In the screen shot above I have set the the encryption mode to <em>“flexible”</em> which is an euphemism for <em>“insecure”</em> as traffic between CloudFlare and my service is not encrypted or authenticated at all. For a demo web service or my dad’s peoms that’s probably fine.</p><p>In production I’d insist on encrypting that traffic as well. So, we need a TLS certificate, right? Wasn’t that meant for CloudFlare to be automated?</p><p>Well, at least they got the tedious certificate rotation sorted: CloudFlare will issue a 15-year-long valid certificate that they accept (but not any browser). You still need to install that certificate to be used by your server. Once. But you can skip brittle the rotation/renewal part altogether set a calendar entry … I mean really … wait for your customers to call you up in 15 years 😬</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hNFQg55dwP0dIWh-PbQybQ.png" /><figcaption>This dialogue can be found in the SSL/TLS section right next to DNS in the menu</figcaption></figure><h3>The benefits</h3><ol><li>The best part for me is that <strong>I don’t have to worry</strong> about TLS refresh cronjobs not working any more because of some update to letsencrypt. That happened to me once and it was a pain to figure out where and how (differently) I have setup all this.</li><li>For small-scale applications, CloudFlare offers this <strong>for free</strong>.</li><li>You’re hiding the IPs of your production machines behind CloudFlare which <strong>makes it harder for attackers</strong> to identify your infrastructure.</li><li>CloudFlare can do minification and hides email addresses from spammers on its own so <strong>you don’t have to care about this</strong>.</li><li>You can hook into your requests using CloudFlare apps to log what’s going on in your API so <strong>you don’t have to configure this yourself</strong>.</li></ol><p>👉 All in all, I don’t have to worry.</p><h3>Drawbacks</h3><ol><li>If you want a secure system you still need to install a certificate on your service web serving end. <strong>CloudFlare only</strong> <strong>saves you from the validating and renewal part</strong>. Which is totally worth is for me.</li><li>You are relying on an external service which is an additional point of failure.</li><li>At some point of traffic, CloudFlare will charge you money.</li></ol><h3>Alternatives</h3><p>Digital Ocean lets you do pretty much the same, you even get a very nice doctl CLI tool that makes it easy to automate your DNS when setting up CD pipelines for a project.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=88e2ac87340d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to make a screenshot from the terminal/console and view it right there on Linux]]></title>
            <link>https://martin-dobberstein.medium.com/how-to-make-a-screenshot-from-the-terminal-console-and-view-it-right-there-on-linux-253f86fe558e?source=rss-5180c3ef932f------2</link>
            <guid isPermaLink="false">https://medium.com/p/253f86fe558e</guid>
            <category><![CDATA[screenshots]]></category>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[console]]></category>
            <category><![CDATA[raspberry-pi]]></category>
            <category><![CDATA[terminal]]></category>
            <dc:creator><![CDATA[Martin Dobberstein (gutschilla)]]></dc:creator>
            <pubDate>Tue, 14 Apr 2020 14:46:46 GMT</pubDate>
            <atom:updated>2020-04-14T14:46:46.195Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/932/1*MT9VcLsgGhkK8tvmo0YIqg.png" /><figcaption>this is a screenshot in a terminal window</figcaption></figure><h3>The problem: I am building a Digital Signage solution using <a href="https://www.raspberrypi.org/">cheap Linux-running devices</a> as player hardware and I want to <em>roughly</em> see what’s being shown on the monitor while being logged on via SSH.</h3><p>Usually, I just want to see if the <a href="https://wiki.gnome.org/Apps/Web">web browser</a> I use to display content is running in fullscreen mode and <em>not</em> showing an error. Basically, I need a plain screenshot. But I don’t need nor want a GUI myself SSH’ing in somewhere.</p><h3>Solution: scrot and viu</h3><p>TL;DR=scrot+viu</p><h4>Making a screenshot from the command line</h4><p>Making a screenshot is fairly simple. On Debian/Ubuntu install scrot via sudo apt install scrot . To make the actual screenshot hit</p><pre>DISPLAY=:0 scrot screenshot.png</pre><p>You can omit DISPLAY=:0 if you’re sitting in front of you machine, the environment variable will usually be set already. Of course you can take screenshots from remote X window servers you have access to specifying a different target.</p><p>If you omit the filename scrot will use the current timestamp to name the screenshot.</p><p><strong>Another option</strong> is DISPLAY=:0 import -window root screenshot.png if you happen to be in an environment where ImageMagick is already installed — or justsudo apt install imagemagick.</p><h4>Displaying the screenshot</h4><p>Of course you could download that file to your local computer via scp and use your favorite image viewer eog screenshot.png to show your remote displaying goodness.</p><p>But why not view the image as a thumbnail right in your console using some ANSI colors? All I want is to see whether that display shows some ad my customers programmed it to show or some error message. Or worse, we got hacked and are now having fresh goatse on display in all our show rooms.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/671/1*2VSEBBjqCEG-iOKxXC3W2w.png" /><figcaption>Eww.. the browser ain’t in fullscreen</figcaption></figure><p>Anyways,</p><h4>Introducing viu</h4><p>Viu (<a href="https://github.com/atanunq/viu">https://github.com/atanunq/viu</a>) is a <em>very</em> nice program written in Rust that does just that: Display a colored thumbnail of an image in your terminal. Yes, in text mode and at a horrible resolution because of that. But then again in the case of goatse that might be a good thing.</p><p>Unfortunately <em>viu</em> isn’t available in Debian/Ubuntu’s repositories. But the author has a precompiled binary handy: <a href="https://github.com/atanunq/viu/releases/download/v1.0/viu">https://github.com/atanunq/viu/releases/download/v1.0/viu</a></p><p>The binary above is a x86–64 one. Thus, on a Raspberry Pi I had to resort to compiling from source. The Raspi sports an ARM CPU and I have no clue if and how cross-compilation in Rust works. Doubly unfortunately this requires quite a recent version of Rust (1.39) and it’s packager <em>Cargo</em> so you may have to get a recent Rust first. Looking at you, Raspbian!</p><p>On Ubuntu 18+ sudo apt install cargo is fine. On Raspian, use the one-liner from <a href="https://rustup.rs/">https://rustup.rs/</a> , currently</p><pre>curl --proto &#39;=https&#39; --tlsv1.2 -sSf https://sh.rustup.rs | sh</pre><p>to install the latest Rust. And then either grab a coffee or two after issuing</p><pre>cargo install viu</pre><p>On a Raspberry Pi 4 compilation takes close to 5 minutes. Et voilà</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/734/1*TLbmBQeYk3x6rQHh2-H9Dg.png" /><figcaption>viu 1.0.0 on a Raspberry Pi 4</figcaption></figure><p>and here we go, making a screenshot with scrot telling it to hand the filename $f over to viu immediately:</p><pre>DISPLAY=:0 scrot -e &#39;viu $f&#39;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/526/1*rG2AV-0Y5_VgvPHnRPUUZA.png" /><figcaption>The vertical display shows a somewhat black screen with a yellow headline: Good!</figcaption></figure><p>Neat, isn’t it?</p><p>I really use this quite often to check if things <em>look</em> alright on my squadron of displays.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=253f86fe558e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Installing Spacemacs on Ubuntu 19.04 disco]]></title>
            <link>https://martin-dobberstein.medium.com/installing-spacemacs-on-ubuntu-19-04-disco-6930916f257f?source=rss-5180c3ef932f------2</link>
            <guid isPermaLink="false">https://medium.com/p/6930916f257f</guid>
            <category><![CDATA[ubuntu]]></category>
            <category><![CDATA[spacemacs]]></category>
            <category><![CDATA[vi]]></category>
            <category><![CDATA[emacs]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Martin Dobberstein (gutschilla)]]></dc:creator>
            <pubDate>Tue, 28 Jan 2020 16:44:14 GMT</pubDate>
            <atom:updated>2021-09-10T12:17:01.825Z</atom:updated>
            <content:encoded><![CDATA[<h3>Installing Spacemacs on Ubuntu 19.04 disco and 20.04 focal</h3><p>I use <a href="https://www.spacemacs.org/">Spacemacs</a> as my favorite editor. It’s basically an Emacs customization which beautifies Emacs and adds vi key bindings- the evil mode.</p><p>Why Spacemacs? I use it as am too old (read: too productive) to use anything else but vi key bindings and basically every other Editor or IDE I tried to use that offered vi key bindings (Atom, VS Code, IntelliJ to name a few) just implemented a subset of vi’s capabilities — sometimes macros don’t work, or the command-mode is not well-integrated: :%s/this/that/g should offer an in-place preview of changes for example.</p><p><strong>Unfortunately</strong>, the installation isn’t as straightforward as just cloning their repo:</p><ul><li>the gnupg keyring for the MELPA package archive is outdated</li><li>Source Code Pro needs to be installed</li></ul><pre># install emacs<br>apt install emacs</pre><pre># install spacemacs<br>git clone <a href="https://github.com/syl20bnr/spacemacs">https://github.com/syl20bnr/spacemacs</a> ~/.emacs.d<br>mkdir -p ~/.emacs.d/elpa/gnupg<br>gpg --homedir ~/.emacs.d/elpa/gnupg --receive-keys 066DAFCB81E42C40</pre><pre># install Source Code Pro<br>wget <a href="https://github.com/adobe-fonts/source-code-pro/archive/2.030R-ro/1.050R-it.zip">https://github.com/adobe-fonts/source-code-pro/archive/2.030R-ro/1.050R-it.zip</a><br>unzip 1.050R-it.zip<br>mkdir -p ~/.fonts<br>cp source-code-pro-*-it/OTF/*.otf ~/.fonts/<br>rm -rf 1.050R-it.zip source-code-pro*</pre><pre># finally run spacemacs (installer)<br>emacs</pre><p>This will finally install spacemacs. Anwser the questions regarding style (vim) and toolbox (helm) correctly and you’re almost good.</p><p>&lt;ALT&gt;+X <strong>package-install</strong> &lt;RETURN&gt; <strong>gnu-elpa-keyring-update </strong>&lt;RETURN&gt;</p><p>This should make sure keyring updates are really up to date as the key above may be out of date at the time you’re reading this. Refer to <a href="https://elpa.gnu.org/packages/gnu-elpa-keyring-update.html">https://elpa.gnu.org/packages/gnu-elpa-keyring-update.html</a> for an up-to-date fingerprint if neither works.</p><h3>Further reading</h3><p><a href="https://medium.com/@ageekymonk/setting-up-spacemacs-for-development-part-1-5349de0b43a1">Setting up spacemacs for development— Part 1</a></p><h3>References</h3><ul><li><a href="https://www.spacemacs.org/">https://www.spacemacs.org/</a></li><li><a href="https://github.com/adobe-fonts/source-code-pro">https://github.com/adobe-fonts/source-code-pro</a></li><li><a href="https://www.rogerpence.com/posts/install-source-code-pro-font-on-ubuntu">https://www.rogerpence.com/posts/install-source-code-pro-font-on-ubuntu</a></li><li><a href="https://elpa.gnu.org/packages/gnu-elpa-keyring-update.html">https://elpa.gnu.org/packages/gnu-elpa-keyring-update.html</a></li></ul><h3>Updates</h3><p>Added Ubuntu 20.04 focal to the title as this works for Ubuntu 20 as well.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6930916f257f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Playing with the Atomic Pi’s gyroscope and accelerometer (BNO055)]]></title>
            <link>https://martin-dobberstein.medium.com/playing-with-the-atomic-pis-gyroscope-and-accelerometer-bno055-d14b601d81ec?source=rss-5180c3ef932f------2</link>
            <guid isPermaLink="false">https://medium.com/p/d14b601d81ec</guid>
            <category><![CDATA[atomic-pi]]></category>
            <category><![CDATA[gyroscope]]></category>
            <category><![CDATA[accelerometer]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[raspberry-pi]]></category>
            <dc:creator><![CDATA[Martin Dobberstein (gutschilla)]]></dc:creator>
            <pubDate>Wed, 10 Jul 2019 12:06:18 GMT</pubDate>
            <atom:updated>2019-07-10T12:06:18.310Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*h7y-GckbNP161v40hRR9Kw.jpeg" /><figcaption>Bottom: The power breakout board with a 2.5mm power jack. Top: the 5V 4A power supply.</figcaption></figure><p>So I got myself an <a href="https://dlidirect.com/products/atomic-pi">Atomic Pi</a> to tinker around. I bought it out of curiosity. An x86 CPU with a gyro for cheap. Gotta try this out!</p><p>Yes. A 35$ computer board that needs soldering (or a 7$ expansion board) to power it. I bough both on <a href="https://www.amazon.com/Atomic-Pi-High-Speed-Peripheral/dp/B07N298F2B">Amazon</a> for 52$ + shipping. I power it with a <a href="https://www.amazon.de/gp/product/B01HRR9GY4/">Leicke 5V 4A power supply</a> for 17€ even though 3 Amps should be enough. But as I want to use the Atomic Pi 24/7 … I prefer keeping a safety margin.</p><h3>The grand plan for the gyroscope/acceleromenter</h3><p>The idea is that the Atomic Pi will check it’s horizontal and vertical position and acceleration periodically and send that data over to a server where we can store that data and plot nice charts from that, triggering alerts from certain thresholds.</p><p>An overpowered poor man’s intrusion detection system. That’s right!</p><h3>Connect the jacks</h3><p>Thankfully, the Atomic Pi comes with an Ubuntu 18.04 derivative pre-configured. I connected the HDMI port with a monitor and connected the power supply to the 2.5mm power jack, added a <a href="https://www.amazon.de/Hama-USB-Ger%C3%A4ten-abw%C3%A4rtskompatibel-Stromversorgung-USB-Buchse/dp/B0079R5LL0/">cheap USB hub</a> since there’s only one USB-A port on the board to get both a mouse and keyboard attached.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ATv1mzxSmd5x_yVpi0CWBA.jpeg" /><figcaption>I am curious whether that password is the same for all Atomic Pies.</figcaption></figure><p>The first login screen shows the default password for the user “atomicpi”. You probably want to change that immediately after login.</p><h3>Connecting to the BNO055 accelerometer on i2c bus</h3><p>Digital Loggers, the company behind the Atomic Pi put up with a <a href="https://github.com/digitalloggers/node-BNO055">github repo</a> with some examples for the <a href="https://www.adafruit.com/datasheets/BST_BNO055_DS000_12.pdf">BNO055</a>. Unfortunately they don’t work out of the box and require some digging in the fine <a href="https://www.digital-loggers.com/apug.pdf">manual</a>:</p><p>Chapter 3.1 (Using BNO055 from Node.JS) sais that the accelerometer is configured on I2C bus 50.</p><p>Second, the README for their github repo https://guthub.com/digitalloggers/node-BNO055is a bit out of date.</p><p>You will need a C compiler and NodeJS Version 8 via</p><pre>curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -<br>sudo apt-get install -y build-essential nodejs</pre><p>to get the dependency ic2-busto compile. Versions 10 and 12 won’t work.</p><h3>Now get some data</h3><p>This a minimally-tweaked index.js from their repo. The key difference is the module name ‘bno055’ and the device address /dev/i2c-50 . I also reordered the output and round values to better fit in a publication. In production you probably just go with the floating numbers returned.</p><pre>var BNO055 = require(&#39;bno055&#39;);<br>var async = require(&#39;async&#39;);</pre><pre>var imu = new BNO055({device: &quot;/dev/i2c-50&quot;});</pre><pre>imu.beginNDOF(function() {<br>  console.info(&#39;imu running&#39;);<br>  setInterval(function() {<br>    async.series({<br>      euler: imu.getEuler.bind(imu),<br>      linearAcceleration: imu.getLinearAcceleration.bind(imu)<br>    },<br>    function(err, results) {<br>      var rot = results.euler;<br>      var accel = results.linearAcceleration;<br>      var data = {<br>        heading: Math.round(rot.heading),<br>        roll:    Math.round(rot.roll),<br>        pitch:   Math.round(rot.pitch),<br>        x:       Math.round(accel.x),<br>        y:       Math.round(accel.y),<br>        z:       Math.round(accel.z),<br>      };<br>      console.info( &#39;imu: &#39;, JSON.stringify(data) );<br>    });<br>  }, 250);<br>});</pre><p>Starting the script as root (superuser access needed to access the i2c device)sudo nodejs index.js yields:</p><pre>imu running<br>imu:  {&quot;heading&quot;:360,&quot;roll&quot;:-6,&quot;pitch&quot;:-2,&quot;x&quot;:0,&quot;y&quot;:0,&quot;z&quot;:0}<br>imu:  {&quot;heading&quot;:360,&quot;roll&quot;:-6,&quot;pitch&quot;:-2,&quot;x&quot;:0,&quot;y&quot;:0,&quot;z&quot;:0}<br>imu:  {&quot;heading&quot;:0,&quot;roll&quot;:-6,&quot;pitch&quot;:-2,&quot;x&quot;:0,&quot;y&quot;:0,&quot;z&quot;:0}<br>imu:  {&quot;heading&quot;:2,&quot;roll&quot;:-2,&quot;pitch&quot;:5,&quot;x&quot;:0,&quot;y&quot;:0,&quot;z&quot;:1}<br>imu:  {&quot;heading&quot;:3,&quot;roll&quot;:-13,&quot;pitch&quot;:8,&quot;x&quot;:1,&quot;y&quot;:-1,&quot;z&quot;:-3}<br>imu:  {&quot;heading&quot;:6,&quot;roll&quot;:-30,&quot;pitch&quot;:1,&quot;x&quot;:1,&quot;y&quot;:0,&quot;z&quot;:0}<br>imu:  {&quot;heading&quot;:6,&quot;roll&quot;:-24,&quot;pitch&quot;:1,&quot;x&quot;:0,&quot;y&quot;:0,&quot;z&quot;:0}<br>imu:  {&quot;heading&quot;:360,&quot;roll&quot;:2,&quot;pitch&quot;:2,&quot;x&quot;:0,&quot;y&quot;:0,&quot;z&quot;:-1}<br>imu:  {&quot;heading&quot;:355,&quot;roll&quot;:9,&quot;pitch&quot;:5,&quot;x&quot;:1,&quot;y&quot;:-1,&quot;z&quot;:0}<br>imu:  {&quot;heading&quot;:0,&quot;roll&quot;:-25,&quot;pitch&quot;:20,&quot;x&quot;:-1,&quot;y&quot;:0,&quot;z&quot;:-2}<br>imu:  {&quot;heading&quot;:11,&quot;roll&quot;:-65,&quot;pitch&quot;:53,&quot;x&quot;:0,&quot;y&quot;:0,&quot;z&quot;:0}<br>imu:  {&quot;heading&quot;:7,&quot;roll&quot;:-57,&quot;pitch&quot;:170,&quot;x&quot;:-1,&quot;y&quot;:0,&quot;z&quot;:0}<br>imu:  {&quot;heading&quot;:8,&quot;roll&quot;:-22,&quot;pitch&quot;:-175,&quot;x&quot;:0,&quot;y&quot;:-1,&quot;z&quot;:0}<br>imu:  {&quot;heading&quot;:17,&quot;roll&quot;:-7,&quot;pitch&quot;:-171,&quot;x&quot;:1,&quot;y&quot;:0,&quot;z&quot;:0}<br>imu:  {&quot;heading&quot;:13,&quot;roll&quot;:-15,&quot;pitch&quot;:-171,&quot;x&quot;:-1,&quot;y&quot;:0,&quot;z&quot;:1}<br>imu:  {&quot;heading&quot;:356,&quot;roll&quot;:-66,&quot;pitch&quot;:-179,&quot;x&quot;:-1,&quot;y&quot;:-1,&quot;z&quot;:0}<br>imu:  {&quot;heading&quot;:359,&quot;roll&quot;:-64,&quot;pitch&quot;:45,&quot;x&quot;:1,&quot;y&quot;:-1,&quot;z&quot;:1}<br>imu:  {&quot;heading&quot;:358,&quot;roll&quot;:-28,&quot;pitch&quot;:41,&quot;x&quot;:1,&quot;y&quot;:1,&quot;z&quot;:1}<br>imu:  {&quot;heading&quot;:84,&quot;roll&quot;:-13,&quot;pitch&quot;:49,&quot;x&quot;:0,&quot;y&quot;:0,&quot;z&quot;:0}<br>imu:  {&quot;heading&quot;:85,&quot;roll&quot;:-25,&quot;pitch&quot;:32,&quot;x&quot;:0,&quot;y&quot;:1,&quot;z&quot;:2}<br>imu:  {&quot;heading&quot;:85,&quot;roll&quot;:-39,&quot;pitch&quot;:-7,&quot;x&quot;:1,&quot;y&quot;:0,&quot;z&quot;:0}<br>imu:  {&quot;heading&quot;:81,&quot;roll&quot;:-23,&quot;pitch&quot;:-7,&quot;x&quot;:1,&quot;y&quot;:-2,&quot;z&quot;:1}<br>imu:  {&quot;heading&quot;:85,&quot;roll&quot;:-10,&quot;pitch&quot;:-1,&quot;x&quot;:-1,&quot;y&quot;:0,&quot;z&quot;:0}<br>imu:  {&quot;heading&quot;:94,&quot;roll&quot;:-5,&quot;pitch&quot;:3,&quot;x&quot;:0,&quot;y&quot;:4,&quot;z&quot;:1}<br>imu:  {&quot;heading&quot;:87,&quot;roll&quot;:-6,&quot;pitch&quot;:0,&quot;x&quot;:0,&quot;y&quot;:-3,&quot;z&quot;:0}<br>imu:  {&quot;heading&quot;:88,&quot;roll&quot;:-6,&quot;pitch&quot;:-1,&quot;x&quot;:0,&quot;y&quot;:-1,&quot;z&quot;:</pre><p>Yay! As we can see, I first rotated the device around (roll and pitch) and then shook it back and forth (y: 4, y: -3).</p><p>All we need from here is</p><ul><li>sending that data to a server</li><li>storing it</li><li>exporting it as time series</li><li>abuse <a href="https://prometheus.io/">Prometheus</a>/<a href="https://grafana.com/">Grafana</a> for long-term storage and display</li></ul><h3>Comparison and rationale</h3><p>I am pretty impressed by the Atomic Pi.</p><p><strong>Price</strong>: The base board is really just 35$ and capable solderers should find a way around using the 7$ power breakout board. Power supplies in the US ship at around 10$. So more or less the Raspberry Pi’s price point.</p><ul><li>The only reasonable x86 CPU-bearing board below 100$ I know of. And <em>much</em> below 100$.</li><li><em>But already</em> packing a gyroscope and accelerometer. An absolute orientation breakout from <a href="https://www.adafruit.com/product/2472">adafruit</a> packing the same BNO055 chip is <a href="https://www.adafruit.com/product/2472">35$</a> alone.</li><li><em>But already</em> coming with 16GB of eMMc. <em>4$ saved on an SD card! Yay!</em></li><li><em>But already</em> running a ready-to-use Linux. <em>Power on, go play.</em></li><li>It has a stereo amp — add 12V 1A power and you can drive 2 x 5W speakers directly from the board. <em>For whatever reason you would want to combine that capability with a gyro/accel (maybe some position-driven </em><a href="https://www.korg.com/de/products/dj/kaoss_pad_kp3_plus/"><em>KAOSS pad</em></a><em>-alike).</em></li></ul><p>So it’s not all that much.</p><p><strong>But if you want to have a ready-to-use computer with a gyroscope and accelerometer which is not your old smartphone then it’s pretty great!</strong></p><p>Or if you’re bound to use x86 software — plain standard desktop software (Did anyone say <em>Windows</em>?)</p><p><strong>Speed:</strong> The Atomic Pi’s QuadCore Intel Atom x5-Z8350 CPU running at 1.44GHz is quick, the thing is almost usable as a desktop computer. Browsing the internet with Chromium is really OK.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3dmIQEwW4qTULO30lew5Yw.jpeg" /><figcaption>The desktop: I’d probably use plain a Ubuntu for desktop usage.</figcaption></figure><p>Synthetic testing with Chromium on <a href="https://browserbench.org/Speedometer2.0/">browserbench.org</a> showed:</p><ul><li>Raspberry 3B+: 5.4 runs/minute</li><li>Raspberry 4B 2GB: 17.4 runs/minute (pretty impressive gain)</li><li>Atomic Pi: 15.62 runs/minute</li><li>My 2016 XPS13 (i5–6200U): 57.0 runs/minute</li></ul><p>So, while it runs circles around the Raspberry Pi 3, it’s basically on par with version 4 — the 2GB version is a bit more expensive than the Atomic Pi but considering the 8$ power expansion card it’s basically the same.</p><p>—</p><p>Tomorrow, I’ll weld this thing to my apartment’s door 🙂</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d14b601d81ec" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Making SSH and SCP work for automated deployments via in GitLab or any other CI/CD system]]></title>
            <link>https://martin-dobberstein.medium.com/making-ssh-and-scp-work-for-automated-deployments-via-in-gitlab-or-any-other-ci-cd-system-477f73cd63ff?source=rss-5180c3ef932f------2</link>
            <guid isPermaLink="false">https://medium.com/p/477f73cd63ff</guid>
            <category><![CDATA[deployment]]></category>
            <category><![CDATA[ssh]]></category>
            <category><![CDATA[scp]]></category>
            <category><![CDATA[gitlab-ci]]></category>
            <category><![CDATA[gitlab]]></category>
            <dc:creator><![CDATA[Martin Dobberstein (gutschilla)]]></dc:creator>
            <pubDate>Wed, 26 Jun 2019 12:54:35 GMT</pubDate>
            <atom:updated>2019-06-26T12:54:35.836Z</atom:updated>
            <content:encoded><![CDATA[<p>So you want to copy your build artifacts to some server but ssh complains about host key verification and missing credentials?</p><p>This is really about automated passing of credentials and host key verification.</p><h3>User and Password: use public keys</h3><p>On the server, create a new key pair. It’s pretty important that you don’t use your personal key pair since we’re going to share the private key with GitLab. Don’t do that with your personal private key — it is really your identity file.</p><pre>ssh-keygen -f id_rsa.yourserver</pre><p>Make sure you leave all passphrases empty. Just hit return when asked to enter a phrase.</p><p>This will create a id_rsa.yourserver and id_rsa.yourserver.pub. That’s your fancy key pair. Now add the public key id_rsa.yourserver.pub to you server’s authorized keys file:</p><pre>cat id_rsa.yourserver &gt;&gt; ~/.ssh/authorized_keys</pre><p>Inspect the new private key via cat id_rsa.yourserver</p><pre> — — -BEGIN RSA PRIVATE KEY — — -<br>MIIEpAIBAAKCAQEAufBB3Xm52WYtSxjZKpSInqoEejk1ZP7QOzYvdOzxpOvZVPwF<br>V2WriNDd6mCex6d4ULxZnxswb8ZjXnCiUDVtnHADA6AH6y3UvMUqfzxs5QElgQKG<br>NlI/ . . I REMOVED TWENTY LINES FOR BREVITY . . . . . . . . .HzG<br>zhbJE9Kv41bpADRMG+HmGU9CpHbN4JkY1gNKJBxrrxTkeR5zkBGv7exSTM5+9Bun<br>pxX5cmczky2/BBovOur3soBM4QkQPwl26E9k0WLrT88YjhO1z0mMJmfDPCgZgh87<br>iPuAmQKBgQCIAk1QXQC+ . AND THIS KEY IS NOT A REAL KEY . . aIaUC<br>lwaj0yhdJPTWsHqWc0Rhhbuk7oEjn8NriyduPLU/0d+iA9bQx9ETi+kCF+A3sYY+<br>qIUq8j28hIDBJGUZldQxhhHIXwICG47/GzLEw7zop0szez++gOCZTw==<br> — — -END RSA PRIVATE KEY — — -</pre><p>and add the contents that should look something like above (just way bigger) to your GitLab CI/CD variables. It’s within your project under settings, then CD/CD. Expand the <em>Variables</em> section and set</p><ul><li>type: File</li><li>Key: IDENTITY</li><li>Value: the private key above (<em>your key</em>, not the gibberish above)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5coeQSxnW0WFG6dgl9_QLg.png" /></figure><p>Then in your .gitlab-ci.yml you can reference that identity file as $IDENTITY. For example as parameter to ssh</p><pre>ssh -i $IDENTITY you@yourserver.com &quot;systemctl restart your.service&quot;</pre><p>Unfortunately, only. This is not enough:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/693/1*GNWthTeeqlXVvL2nbAv-1Q.png" /></figure><h4>Host key verification</h4><p>ssh wants to make sure that you are connecting to the right server, so the server will present a fingerprint of its host key. Only if that key is known to ssh it will let you connect to that server</p><p>On your developer machine ssh will show you the fingerprint on screen and ask you if you really want to connect to that server. You will have to type yes usually. Then, the fingerprint will be added to your ~/.ssh/known_hosts file so ssh doesn’t need to ask again for that server.</p><p>Unfortunately, typing isn’t an option in automated scenarios like your CI/CD runner environments. You can either</p><ul><li>disable host key verification (for security reasons, don’t!)</li><li>set up<a href="https://www.howson.me/setting-up-sshfp-records/">SSHFP records</a> in your <a href="https://www.cyberciti.biz/humour/a-haiku-about-dns/">DNS</a></li><li>or simply ship a known_hosts file in your repository</li></ul><h4>Crafting the known_hosts file</h4><p>The simplest solution is to inspect the verbose (the -v option) output of ssh -v you@some_server.comwhen connecting to the server. Look for</p><pre>debug1: Server host key: ecdsa-sha2-nistp256 SHA256:4F7nGBwJqx97Er3XXXXXXXXX/sS4MGYNvrwYYRqBqL8<br>debug1: Host ‘10.0.2.100’ is known and matches the ECDSA host key.<br>debug1: Found key in /home/mart/.ssh/known_hosts:2</pre><p>Yay, this known_hosts:2 from the last line above tells you that you want to copy line number 2. Extract that to a file and name it conveniently.</p><pre>sed -n ‘2,+1p’ ~/.ssh/known_hosts &gt; known_hosts</pre><p>Now, check if that works:</p><p>ssh -v -o &quot;UserKnownHostsFile=./known_hosts&quot; you@some_server.com</p><p>If you can login, great! Add that known_hosts file to your repo and you can then copy stuff in GitLab’s CI/CD runner.</p><pre>scp \<br>  -o &quot;UserKnownHostsFile=./known_hosts&quot; \<br>   -i $IDENTITY some_build \<br>  you@some_server.com:/some/target</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*mHJ5b3z4qSV_hfE_1icMLw.png" /></figure><p>And it works!</p><h3>Final words</h3><p>There’s much more to be automated here :-) And yes, this is more of a general documentation for myself on how to do stuff. Because once it runs I usually don’t touch it that often and then forget about how I managed to get it to work in the first place.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=477f73cd63ff" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deploying Elixir/Phoenix projects to production]]></title>
            <link>https://martin-dobberstein.medium.com/deploying-elixir-phoenix-projects-to-production-44a236c643c?source=rss-5180c3ef932f------2</link>
            <guid isPermaLink="false">https://medium.com/p/44a236c643c</guid>
            <category><![CDATA[elixir]]></category>
            <category><![CDATA[lets-encrypt]]></category>
            <category><![CDATA[deployment]]></category>
            <category><![CDATA[erlang]]></category>
            <category><![CDATA[production]]></category>
            <dc:creator><![CDATA[Martin Dobberstein (gutschilla)]]></dc:creator>
            <pubDate>Thu, 04 Apr 2019 14:00:49 GMT</pubDate>
            <atom:updated>2019-05-07T19:22:28.726Z</atom:updated>
            <content:encoded><![CDATA[<h4>Setting up a bare Ubuntu 18 machine to deplaoy an Elixir/Phoenix service supervised by systemd behind nginx to handle TLS (SSL) encryption.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/878/1*DKj7Boj4Xl7MFaT9d_PefQ.png" /><figcaption>systemctl shows it’s running nicely</figcaption></figure><p>Just scroll down to the bottom if you’re just after the script without any explanation.</p><h3>Preface</h3><p>So, we’ve all got to grind through this and I’s like to share my way how I am setting up a simple Elixir/Phoenix service on a bare Ubuntu machine.</p><p>I do not recommend this for bigger installations, though: Just use Docker and Kubernetes if possible. This guide shall be a howto for small projects and doesn’t touch CI/CD and all the pipeline work that this usually entails.</p><p>I assume you have a git repo somewhere and you’d like to simply deploy the master branch. I also assume that there’s no database involved — this I will cover in a next episode: It’s pretty starightforward but I’d like to concentrate on the Elixir part in this article.</p><h3>The plan</h3><ul><li>basic system configuration (auto-updates)</li><li>install erlang and nodejs from vendor’s repositories via apt — so we have one tool apt to handle all updates</li><li>get the source from a git repo</li><li>fetch dependencies and compile your Elixir source and possibly JS via webpack (or whatever your JS build tool is)</li><li>install nginx as reverse proxy to handle all TLS and to show a <em>nice</em> “down” page should our Elixir service be down</li><li>create an Erlang release and install this as a service</li></ul><h3>A plain bash script</h3><p>At the bottom I added a script that I simply run on install. It’s usually part of my project repository and and also serves as <a href="https://cloud-init.io/">cloud-init</a> script.</p><h4>What it does</h4><ol><li>It installs all necessary runtimes (Erlang, Elixir, NodeJS as I am assuming <a href="https://phoenixframework.org/">Phoenix</a> and webpack)</li><li>It enables auto-updates and upgrades for most system packages and lets the system send you emails about that.</li><li>Checks out a git repository, assuming this is an Elixir mix-controlled project, gets dependencies, builds it and compiles a release. See → Releases</li><li>Registers and starts your application as a <a href="https://www.freedesktop.org/wiki/Software/systemd/">systemd</a> service for auto-restarts on failure and nice logs via journalctl.</li><li>Sets up <a href="https://nginx.org/">nginx</a> to act as a reverse proxy, handling all those TLS details for you. Also shows a plain “down for maintenance” page if your service goes down which is bit nicer than the infamous <em>BAD GATEWAY.</em></li><li>Retrieves a TLS certificate from <a href="https://letsencrypt.org/">letsencrypt</a> for you and auto-renews it if due (every 3 months).</li></ol><blockquote>Tadaa! Your application should now be available at https://$DOMAIN</blockquote><h4>Prerequisites</h4><p>The IP of your server must be resolvable as $DOMAIN in the DNS. So be sure to set the A record of your domain (e.g. foobar.gutschilla.com) to your IPv4 address and if you’re extra cool set the AAAA record to your IPv6 address.</p><p>Change/set the variables at the beginning of the script:</p><ol><li>EMAIL → mail address that update notification will be sent to</li><li>MAIL_HOST, MAIL_USER, MAIL_PASS →email address from which update notifications will be sent from</li><li>DOMAIN →the domain name your project shall be available from (e.g. foobar.remoteceros.com)</li><li>PROJECT → a name that will be used as a common handle within the system, e.g. the project directory, the service name etc. Something like super-api or drinking-web that may be a file name is great. Don’t use something likely to clash with exiting services like “nginx”.</li><li>GIT_URL → something to feed to “git clone”. Ideally this is a https checkout that includes a user and a password. For projects hosted at <a href="https://gitlab.com/">Gitlab</a> I create read-only deployment tokens (in a project under Settings → Repository) which are exactly these: a username and a password.</li></ol><p>Your project should support releases with <a href="https://github.com/bitwalker/distillery">distillery</a>. This is optional. See → Releases for a howto and a workaround if you don’t want it.</p><h3>Caveats</h3><ul><li>For simplicity’s sake credentials are not taken from environment variables or some credential service.</li><li>If the application crashes on startup you won’t necessarily get notified. Be sure to run systemctl status $PROJECT.service or journalctl -u $PROJECT.service to check if all is green.</li><li>The application runs as userwww-data just as nginx does. If you want more isolation, create another user and chown the release’s var directory to it.</li><li>Even if there are auto-updates, your system might still need some maintenance every now and then as new Erlang/Elixir packages won’t get automatically installed (and they shouldn’t to stay compatible).</li><li>You are still responsible for security updates of your application’s libraries, both Elixir and Javascript ones.</li></ul><h3>On Erlang releases</h3><p>They basically pack the Erlang runtime along with your compiled project as beam-files. This makes releases handy when you want to build them on your machine and the deploy the release as-is on some server. This is pretty cool as you don’t need Erlang and all this on your target. There are tools like <a href="https://github.com/edeliver/edeliver">edeliver</a> that help automate this process.</p><p>In this example we’re compiling the release on your target machine. It’s considerably easy to do and gives you all the wonders of a remote shell into your project without caring too much.</p><p>Adding distillery is quite easy (for smaller projects). The <a href="https://hexdocs.pm/distillery/introduction/installation.html">distillery documentation</a> shows how. It’s basically adding {:distillery, &quot;~&gt; 2.0&quot;} to your deps and running mix release init checking-in the resulting ./rel directory into your repo. Make sure to read <a href="https://hexdocs.pm/distillery/introduction/installation.html">the docs</a> for more info. But usually that’s just it: One extra dependency and one init command.</p><h4>Even simpler: without releases</h4><p>OK, you don’t care about how nice this all would be? Simply omit the release step “mix release” and in your systemd unit file</p><ul><li>remove the mix release line 245</li><li>remove following chown www-data… line 248</li><li>remove the ExecStop line 280</li><li>uncomment the whole line 268 EcecStart … iex -S mix phx.server and remove or comment-out the existing ExecStart … foregorundcommand line 269</li></ul><h3>Going further from here</h3><p>This machine does too much.</p><p>This is OK for small projects but in real<strong>™ </strong>projects you might want to use nginx as a load-balancing proxy. This way you can simply spawn new machines if you want to update (just reinstall) or scale (just add more instances) your application.</p><p>For this to work smoothly it’s best to have a cloud provider and some internal networking. Also you can spin up more machines for databases, KV-stores and whatnot.</p><p>But if you’re going that far you’re probably better off using Docker, Kubernetes and some fancy CI/CD system with build pipelines for development, staging and production stages on top of that.</p><p>That’s out of scope for today.</p><h3>And finally, the script:</h3><p>I am not a very proficient bash developer so while this works it might be scary to the experienced bash hacker out there. Oh and if you have more elegant solutions for example to get a random reboot time than resorting to perl in line 6 — I love to hear about it.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a8fd6f0eb4a38d7a674c6abbe36515c1/href">https://medium.com/media/a8fd6f0eb4a38d7a674c6abbe36515c1/href</a></iframe><h3>Todo</h3><ul><li>provide project example ready to check out and install</li></ul><h3>Changes</h3><ul><li><strong>Edit 1:</strong> (2019–09–07): Thanks to <a href="https://gist.github.com/thenrio">https://gist.github.com/thenrio</a> for suggesting <em>tee</em> instead of <em>(cat …) &gt; file</em>. Also, finally found out how to do inline code.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=44a236c643c" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>