Jekyll2019-01-24T15:19:04+01:00https://www.promofu.net/feed.xml[Lab Pages]personal descriptionProMoFupromofu@online.deTool Radar: python2019-01-24T00:00:00+01:002019-01-24T00:00:00+01:00https://www.promofu.net/tech/tools/python<p>I was playing with some QR Code generator stuff (that I might get into in some other post eventually)… there are a
whole lot of options to pick from, but I got stuck - stupid me - on some Python incarnation for now. It uses <a href="http://flask.pocoo.org/">Flask</a>,
<a href="http://werkzeug.pocoo.org/">Werkzeug</a> and some other presumingly fancy stuff that I never heard of… so I got curious.</p>
<p>And… - I guess it’s about time to get my hands on <a href="https://www.python.org/">Python</a> - as I am a somewhat Ubuntu addicted there is not
sooo much hasle to start. Ubuntu Server comes with some decent version of Python3 bundled and the Ubuntu Desktops add
Python2 to it. And yeah - the RasPis do it too.</p>
<p>So off we go:</p>
<div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code>.> python3 <span class="nt">-V</span>
Python 3.6.7
.> python2 <span class="nt">-V</span>
Python 2.7.15rc1
.> <span class="nb">echo</span> <span class="s1">'print("Guess what...")'</span> <span class="o">></span> script.py
.> python3 script.py
Guess what...
</code></pre></div></div>
<p>So much - so easy… it seems though that there is quite enough for simple running some scriptlets and ready-to-use stuff
that comes with Ubuntu or otherwise, but not much else is installed for actually developing something yourself.</p>
<p>So one of your first steps might be (well for me it was) to install <code class="highlighter-rouge">pip</code> - the “npm for python”:</p>
<div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code>.> apt install python3-pip
</code></pre></div></div>
<p>It comes with a whole bunch of dependencies … depending on your setup.</p>
<p>But now you can actually do some cool stuff like</p>
<div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code>.> pip3 install Flask
</code></pre></div></div>
<p>…but wait. There seems to be some useful concept of <em>virtual environment</em>s.</p>
<p>Let’s see … the guys over at <a href="https://www.digitalocean.com/community/tutorials/how-to-install-python-3-and-set-up-a-programming-environment-on-an-ubuntu-18-04-server">Digital Ocean</a> have some info on that. I do like to keep thinks clean
and well sorted - at least on my carry-around - I will give that a test run.</p>
<p>Following through “Step 2” of their brief intro documentation I get to a point where</p>
<div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code>.> <span class="nb">ls
</span>bin include lib lib64 pyvenv.cfg share
.> <span class="nb">source </span>bin/activate
<span class="o">(</span>my_env<span class="o">)</span> ➜ my_env <span class="o">></span> ...
</code></pre></div></div>
<p>NICE … I leave you with the rest of the usual “Hello World” play around, but if You want to leave the <em>virtual
environment</em> cage, just …</p>
<div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code>.> deactivate
</code></pre></div></div>
<p>it…</p>
<p>See You soon … I need to learn Python now !</p>
<hr />ProMoFupromofu@online.deI was playing with some QR Code generator stuff (that I might get into in some other post eventually)… there are a whole lot of options to pick from, but I got stuck - stupid me - on some Python incarnation for now. It uses Flask, Werkzeug and some other presumingly fancy stuff that I never heard of… so I got curious.Tool Radar: fx2019-01-23T00:00:00+01:002019-01-23T00:00:00+01:00https://www.promofu.net/tech/tools/json_fx<p>I came about a nice tool for CLI processing of JSON structures… native JavaScript,
fast and intuitive from a modern JavaScript perspective.</p>
<p>Cool stuff… depending on how much You are into JavaScript development I recommend
doing the following right now and give it a base jump:</p>
<div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code>.> npm install <span class="nt">-g</span> fx
.> <span class="nb">echo</span> <span class="s1">'{"foo": [{"bar": "value"}]}'</span> | fx <span class="s1">'x => x.foo[0].bar'</span>
value
.> <span class="nb">echo</span> <span class="s1">'{"foo": [{"bar": "value"}]}'</span> | fx <span class="s1">'x => x.foo[0]'</span>
<span class="o">{</span>
<span class="s2">"bar"</span>: <span class="s2">"value"</span>
<span class="o">}</span>
</code></pre></div></div>
<p>but one of the cooler things is this:</p>
<div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code>.> <span class="nb">echo</span> <span class="s1">'{"foo": "bar"}'</span> | fx <span class="s1">'{...this, "ping": "pong"}'</span>
<span class="o">{</span>
<span class="s2">"foo"</span>: <span class="s2">"bar"</span>,
<span class="s2">"ping"</span>: <span class="s2">"pong"</span>
<span class="o">}</span>
</code></pre></div></div>
<p>and the coolest by far is the interactive mode:</p>
<div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code>.> curl <something> <span class="nt">-o</span> data.json
</code></pre></div></div>
<p>and off You go like this:</p>
<p><img src="/images/posts/showcase_fx.gif" alt="Showcase: fx in action" /></p>
<p>… but so much for ruthless c’n’p-ing … credits to the original author and
enter stage <a href="https://medium.com/@antonmedv/how-to-work-with-json-from-terminal-f5a10cbe2121">Anton</a>.</p>
<hr />ProMoFupromofu@online.deI came about a nice tool for CLI processing of JSON structures… native JavaScript, fast and intuitive from a modern JavaScript perspective.docker-machine and Raspbian … a funny couple !2019-01-22T00:00:00+01:002019-01-22T00:00:00+01:00https://www.promofu.net/tech/container/raspberry/docker_machine_raspbian<p>Ok - it’s 2019 … and Raspbian has really gone a long way. But despite the fact
that there is a growing number of Raspbian-Docker nerds out there… the
docker-machine guys seem to be not interested in properly supporting Raspbian
out-of-the box using either some “hypriot” driver setup or at least the “generic”
drivers built in OS detection …</p>
<h2 id="tldr">TL;DR</h2>
<p>So long story short:</p>
<p>For the time being You need to temporarily tweak <code class="highlighter-rouge">/etc/os-release</code> to kick
<code class="highlighter-rouge">docker-machine --driver generic</code>s little ass and make the whole party rock’n
roll as in those days waaaayyyy back…</p>
<h2 id="-read-the-nasty-details">… read the nasty details</h2>
<p>Ok - I admit … I did not find “the best” minimal Raspberry PI Docker Cluster
base Distro … although I checked a whole bunch of options. <a href="https://github.com/hypriot">Hypriot</a> seems
like a really good starter … and a vanilla Raspbian install with some
<code class="highlighter-rouge">apt install docker</code> did the Job as well - but Hypriot seemed to be kind of
slim enough and ready to rumble out of the box.</p>
<p>Other starter choices would include <a href="https://www.dietpi.com">DietPi</a> and <a href="https://sourceforge.net/projects/minibian/">MiniBian</a>
(see also <a href="https://sourceforge.net/p/minibian/discussion/general/thread/6b24d893/?limit=25#f786/912b">this discussion</a>).</p>
<p>So far I like the Hypriot stuff - a little outdated - but seems nice, working,
and like my pair of gloves. I will probably stick to that for some time. The built-in
<a href="https://launchpad.net/cloud-init">cloud-init</a> magic seems also interesting … but that’s another story.</p>
<p>I want something I can <code class="highlighter-rouge">dd</code> on the SD card, tweak some config files, stick it
in and boot it up… and to make a really happy ending, there should be some
<code class="highlighter-rouge">docker-machine create</code> to finish it all up - nice and tidy.</p>
<p>Well — would be nice at least… reality leaves some itching, though.</p>
<p>docker-machine does not offer some compatible driver setup, nor does the
supposed to be swiss army knife “generic” driver handle it out of the box
because of some problems in its OS detection.</p>
<p>So what do You do ? After booting You take some <code class="highlighter-rouge">/etc/os-release</code> file from
your ubuntu laptop (or maybe any other more mainstream choice) and trick
docker-machine into out-of-the-box mode. Apply it’s content using good old
copy-and-paste… and You are on Your way to the usual procedure …
off you go using docker-machine like it should be !</p>
<p>But do not forget to keep a copy of the original content of <code class="highlighter-rouge">/etc/os-release</code>
and watch out for the soft link it is.</p>
<p>After creating the new machine you can and should undo the tweaked
<code class="highlighter-rouge">/etc/os-release</code> back to the original content. Otherwise maybe Your
<code class="highlighter-rouge">apt update</code> might get confused… but I didn’t smoke-test that part as of now
and so far there is no forecast on that ;-)</p>
<p>TODO: I prepared a little <a href="XYZ">GIST</a> to follow me through the procedure.</p>
<p>By the way: <a href="https://github.com/hypriot">Hypriot</a> offers a whole bunch of special docker image builds but
chances are that You do not really need to stick to their special builds in a whole
lot of “not so system dependent” cases … I will probably shed a light on
that in some later post.</p>
<hr />ProMoFupromofu@online.deOk - it’s 2019 … and Raspbian has really gone a long way. But despite the fact that there is a growing number of Raspbian-Docker nerds out there… the docker-machine guys seem to be not interested in properly supporting Raspbian out-of-the box using either some “hypriot” driver setup or at least the “generic” drivers built in OS detection …What’s next ?!?2019-01-18T00:00:00+01:002019-01-18T00:00:00+01:00https://www.promofu.net/tech/whats_next<p>Now that I got the stuff running, what am I going to do with it ?</p>
<p>The first post should be some sort of “Hello World” / “test-drive the markup
stuff” thing, I guess… so let’s go for it:</p>
<p>First and foremost the essential survival guides:</p>
<ul>
<li><a href="https://jekyllrb.com/">jekyll</a> makes use of <a href="https://kramdown.gettalong.org/">kramdown</a> … so here is
a link to their <a href="https://kramdown.gettalong.org/quickref.html">Quick Reference</a></li>
<li>and a little bit of reference on differences to “<a href="https://kramdown.gettalong.org/parser/markdown.html">standard markdown</a>”</li>
</ul>
<h2 id="here-we-go">Here we go…</h2>
<p>… but then again: what the heck … look up all the glorious details in
kramdowns very own <a href="https://kramdown.gettalong.org/syntax.html#kramdown-syntax">syntax reference</a> ;-)</p>
<hr />ProMoFupromofu@online.deNow that I got the stuff running, what am I going to do with it ?