<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom"><title>Alex's Adventures on the Infobahn - linaro</title><link href="https://www.bennee.com/~alex/" rel="alternate"></link><link href="https://www.bennee.com/~alex/blog/tag/linaro/feed" rel="self"></link><id>https://www.bennee.com/~alex/</id><updated>2018-03-26T11:19:00+01:00</updated><subtitle>the wanderings of a supposed digital native</subtitle><entry><title>Solving the HKG18 puzzle with org-mode</title><link href="https://www.bennee.com/~alex/blog/2018/03/26/solving-the-hkg18-puzzle-with-org-mode/" rel="alternate"></link><published>2018-03-26T11:19:00+01:00</published><updated>2018-03-26T11:19:00+01:00</updated><author><name>alex</name></author><id>tag:www.bennee.com,2018-03-26:/~alex/blog/2018/03/26/solving-the-hkg18-puzzle-with-org-mode/</id><summary type="html">&lt;p&gt;One of the traditions I like about Linaro's Connect event is the
conference puzzle. Usually set by &lt;a href="https://www.linaro.org/author/dave-pigott/"&gt;Dave Piggot&lt;/a&gt; they provide a challenge
to your jet lagged brain. Full disclosure: I did not complete the
puzzle in time. In fact when Dave explained it I realised the answer
had been …&lt;/p&gt;</summary><content type="html">&lt;p&gt;One of the traditions I like about Linaro's Connect event is the
conference puzzle. Usually set by &lt;a href="https://www.linaro.org/author/dave-pigott/"&gt;Dave Piggot&lt;/a&gt; they provide a challenge
to your jet lagged brain. Full disclosure: I did not complete the
puzzle in time. In fact when Dave explained it I realised the answer
had been staring me in the face. However I thought a successful walk
through would make for a more entertaining read ;-)&lt;/p&gt;
&lt;p&gt;First the Puzzle:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Take the clues below and solve them. Once solved, figure out what the
hex numbers mean and then you should be able to associate each of the
clue solutions with their respective hex numbers.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;table id="org530cfaf" border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides"&gt;


&lt;colgroup&gt;
&lt;col  class="org-left" /&gt;

&lt;col  class="org-left" /&gt;
&lt;/colgroup&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th scope="col" class="org-left"&gt;Clue&lt;/th&gt;
&lt;th scope="col" class="org-left"&gt;Hex Number&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;

&lt;tbody&gt;
&lt;tr&gt;
&lt;td class="org-left"&gt;Lava Ale Code&lt;/td&gt;
&lt;td class="org-left"&gt;1114DBA&lt;/td&gt;
&lt;/tr&gt;


&lt;tr&gt;
&lt;td class="org-left"&gt;Be Google Roe&lt;/td&gt;
&lt;td class="org-left"&gt;114F6BE&lt;/td&gt;
&lt;/tr&gt;


&lt;tr&gt;
&lt;td class="org-left"&gt;Natural Gin&lt;/td&gt;
&lt;td class="org-left"&gt;114F72A&lt;/td&gt;
&lt;/tr&gt;


&lt;tr&gt;
&lt;td class="org-left"&gt;Pope Charger&lt;/td&gt;
&lt;td class="org-left"&gt;121EE50&lt;/td&gt;
&lt;/tr&gt;


&lt;tr&gt;
&lt;td class="org-left"&gt;Dolt And Hunk&lt;/td&gt;
&lt;td class="org-left"&gt;12264BC&lt;/td&gt;
&lt;/tr&gt;


&lt;tr&gt;
&lt;td class="org-left"&gt;Monk Hops Net&lt;/td&gt;
&lt;td class="org-left"&gt;122D9D9&lt;/td&gt;
&lt;/tr&gt;


&lt;tr&gt;
&lt;td class="org-left"&gt;Is Enriched Tin&lt;/td&gt;
&lt;td class="org-left"&gt;123C1EF&lt;/td&gt;
&lt;/tr&gt;


&lt;tr&gt;
&lt;td class="org-left"&gt;Bran Hearing Kin&lt;/td&gt;
&lt;td class="org-left"&gt;1245D6E&lt;/td&gt;
&lt;/tr&gt;


&lt;tr&gt;
&lt;td class="org-left"&gt;Enter Slim Beer&lt;/td&gt;
&lt;td class="org-left"&gt;127B78E&lt;/td&gt;
&lt;/tr&gt;


&lt;tr&gt;
&lt;td class="org-left"&gt;Herbal Cabbages&lt;/td&gt;
&lt;td class="org-left"&gt;1282FDD&lt;/td&gt;
&lt;/tr&gt;


&lt;tr&gt;
&lt;td class="org-left"&gt;Jan Venom Hon Nun&lt;/td&gt;
&lt;td class="org-left"&gt;12853C5&lt;/td&gt;
&lt;/tr&gt;


&lt;tr&gt;
&lt;td class="org-left"&gt;A Cherry Skull&lt;/td&gt;
&lt;td class="org-left"&gt;1287B3C&lt;/td&gt;
&lt;/tr&gt;


&lt;tr&gt;
&lt;td class="org-left"&gt;Each Noun Lands&lt;/td&gt;
&lt;td class="org-left"&gt;1298F0B&lt;/td&gt;
&lt;/tr&gt;


&lt;tr&gt;
&lt;td class="org-left"&gt;Wave Zone Kits&lt;/td&gt;
&lt;td class="org-left"&gt;12A024C&lt;/td&gt;
&lt;/tr&gt;


&lt;tr&gt;
&lt;td class="org-left"&gt;Avid Null Sorts&lt;/td&gt;
&lt;td class="org-left"&gt;12A5190&lt;/td&gt;
&lt;/tr&gt;


&lt;tr&gt;
&lt;td class="org-left"&gt;Handcars All Trim&lt;/td&gt;
&lt;td class="org-left"&gt;12C76DC&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;

&lt;h1&gt;Clues&lt;/h1&gt;
&lt;p&gt;It looks like all the clues are anagrams. I was lazy and just used the
first online anagram solver that Google pointed me at. However we can
automate this by combining org-mode with Python and the excellent
Beautiful Soup library.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;bs4&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;BeautifulSoup&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;requests&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;re&lt;/span&gt;

&lt;span class="c1"&gt;# ask internet to solve the puzzle&lt;/span&gt;
&lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;http://anagram-solver.net/&lt;/span&gt;&lt;span class="si"&gt;%s&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;%&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;anagram&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;replace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot; &amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;%20&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="n"&gt;page&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;requests&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# fish out the answers&lt;/span&gt;
&lt;span class="n"&gt;soup&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;BeautifulSoup&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;page&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;answers&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;soup&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;find&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;ul&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;class_&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;answers&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;li&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="ow"&gt;in&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;answers&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;find_all&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;li&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;li&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="c1"&gt;# filter out non computer related or poor results&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="ow"&gt;in&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;Elmer Berstein&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;Tim-Berners Lee&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;Babbage Charles&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;Calude Shannon&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;]:&lt;/span&gt;
&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="k"&gt;continue&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="c1"&gt;# filter out non proper names&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;re&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;search&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;[a-z] [A-Z]&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="k"&gt;break&lt;/span&gt;

&lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;result&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;So with &lt;code&gt;:var anagram=clues[2,0]&lt;/code&gt; we get&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;Ada Lovelace
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;I admit the "if result in []" is a bit of hack.&lt;/p&gt;
&lt;h1&gt;Hex Numbers&lt;/h1&gt;
&lt;p&gt;The hex numbers could be anything. But lets first start by converting
to something else.&lt;/p&gt;
&lt;table id="orgf38fe0d" border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides"&gt;


&lt;colgroup&gt;
&lt;col  class="org-left" /&gt;

&lt;col  class="org-right" /&gt;
&lt;/colgroup&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th scope="col" class="org-left"&gt;Hex Prompt&lt;/th&gt;
&lt;th scope="col" class="org-right"&gt;Number&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;

&lt;tbody&gt;
&lt;tr&gt;
&lt;td class="org-left"&gt;1114DBA&lt;/td&gt;
&lt;td class="org-right"&gt;17911226&lt;/td&gt;
&lt;/tr&gt;


&lt;tr&gt;
&lt;td class="org-left"&gt;114F6BE&lt;/td&gt;
&lt;td class="org-right"&gt;18151102&lt;/td&gt;
&lt;/tr&gt;


&lt;tr&gt;
&lt;td class="org-left"&gt;114F72A&lt;/td&gt;
&lt;td class="org-right"&gt;18151210&lt;/td&gt;
&lt;/tr&gt;


&lt;tr&gt;
&lt;td class="org-left"&gt;121EE50&lt;/td&gt;
&lt;td class="org-right"&gt;19000912&lt;/td&gt;
&lt;/tr&gt;


&lt;tr&gt;
&lt;td class="org-left"&gt;12264BC&lt;/td&gt;
&lt;td class="org-right"&gt;19031228&lt;/td&gt;
&lt;/tr&gt;


&lt;tr&gt;
&lt;td class="org-left"&gt;122D9D9&lt;/td&gt;
&lt;td class="org-right"&gt;19061209&lt;/td&gt;
&lt;/tr&gt;


&lt;tr&gt;
&lt;td class="org-left"&gt;123C1EF&lt;/td&gt;
&lt;td class="org-right"&gt;19120623&lt;/td&gt;
&lt;/tr&gt;


&lt;tr&gt;
&lt;td class="org-left"&gt;1245D6E&lt;/td&gt;
&lt;td class="org-right"&gt;19160430&lt;/td&gt;
&lt;/tr&gt;


&lt;tr&gt;
&lt;td class="org-left"&gt;127B78E&lt;/td&gt;
&lt;td class="org-right"&gt;19380110&lt;/td&gt;
&lt;/tr&gt;


&lt;tr&gt;
&lt;td class="org-left"&gt;1282FDD&lt;/td&gt;
&lt;td class="org-right"&gt;19410909&lt;/td&gt;
&lt;/tr&gt;


&lt;tr&gt;
&lt;td class="org-left"&gt;12853C5&lt;/td&gt;
&lt;td class="org-right"&gt;19420101&lt;/td&gt;
&lt;/tr&gt;


&lt;tr&gt;
&lt;td class="org-left"&gt;1287B3C&lt;/td&gt;
&lt;td class="org-right"&gt;19430204&lt;/td&gt;
&lt;/tr&gt;


&lt;tr&gt;
&lt;td class="org-left"&gt;1298F0B&lt;/td&gt;
&lt;td class="org-right"&gt;19500811&lt;/td&gt;
&lt;/tr&gt;


&lt;tr&gt;
&lt;td class="org-left"&gt;12A024C&lt;/td&gt;
&lt;td class="org-right"&gt;19530316&lt;/td&gt;
&lt;/tr&gt;


&lt;tr&gt;
&lt;td class="org-left"&gt;12A5190&lt;/td&gt;
&lt;td class="org-right"&gt;19550608&lt;/td&gt;
&lt;/tr&gt;


&lt;tr&gt;
&lt;td class="org-left"&gt;12C76DC&lt;/td&gt;
&lt;td class="org-right"&gt;19691228&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;The #+TBLFM: is &lt;code&gt;$1='(identity remote(clues,@@#$2))::$2='(string-to-number $1 16)&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;This is where I went down a blind alley. The fact all they all had the
top bit set made me think that Dave was giving a hint to the purpose
of the hex number in the way many &lt;a href="https://en.wikipedia.org/wiki/Cryptic_crossword"&gt;cryptic crosswords&lt;/a&gt; do (I know he is
a fan of these). However the more obvious answer is that everyone in
the list was born in the last millennium.&lt;/p&gt;
&lt;h1&gt;Looking up Birth Dates&lt;/h1&gt;
&lt;p&gt;Now I could go through all the names by hand and look up their birth
dates but as we are automating things perhaps we can use computers for
what they are good at. Unfortunately there isn't a simple web-api for
looking up this stuff. However there is a project called &lt;a href="http://wiki.dbpedia.org/about"&gt;DBpedia&lt;/a&gt; which
takes Wikipedia's data and attempts to make it semantically useful. We
can query this using a semantic query language called SparQL. If only
I could call it from Emacs&amp;#x2026;&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;select distinct ?birthDate {
  dbr:$name dbo:birthDate|dbp:birthDate ?birthDate
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;So calling with &lt;code&gt;:var name="Ada_Lovelace"&lt;/code&gt; we get&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&amp;quot;birthDate&amp;quot;
1815-12-10
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Of course it shouldn't be a surprise this exists. And in what I hope
is a growing trend &lt;a href="https://github.com/ljos/sparql-mode"&gt;sparql-mode&lt;/a&gt; supports org-mode out of the box. The
$name in the snippet is expanded from the passed in variables to the
function. This makes it a general purpose lookup function we can use
for all our names.&lt;/p&gt;
&lt;p&gt;There are a couple of wrinkles. We need to format the name we are
looking up with underscores to make a valid URL. Also the output spits
out a header and possible multiple birth dates. We can solve this with
a little wrapper function. It also introduces some rate limiting so we
don't smash DBpedia's public SPARQL endpoint.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="p"&gt;;;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;rate&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;limit&lt;/span&gt;
&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sleep&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="k"&gt;for&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mh"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;;;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;do&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;the&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;query&lt;/span&gt;
&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;let&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="n"&gt;str&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;replace&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;all&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;&amp;#39;((&lt;/span&gt;&lt;span class="s"&gt;&amp;quot; &amp;quot;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;&amp;quot;_&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;Von&amp;quot;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;&amp;quot;von&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="w"&gt;       &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ret&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;eval&lt;/span&gt;
&lt;span class="w"&gt;             &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;car&lt;/span&gt;
&lt;span class="w"&gt;              &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;read&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;from&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="k"&gt;string&lt;/span&gt;
&lt;span class="w"&gt;               &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;&amp;quot;(org-sbe get-dob (name $&lt;/span&gt;&lt;span class="se"&gt;\&amp;quot;&lt;/span&gt;&lt;span class="s"&gt;%s&lt;/span&gt;&lt;span class="se"&gt;\&amp;quot;&lt;/span&gt;&lt;span class="s"&gt;))&amp;quot;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;str&lt;/span&gt;&lt;span class="p"&gt;))))))&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;string&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;to&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;number&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;replace&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;regexp&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;in&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="k"&gt;string&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;&amp;quot;-&amp;quot;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;&amp;quot;&amp;quot;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;car&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;cdr&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;lines&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;ret&lt;/span&gt;&lt;span class="p"&gt;))))))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Calling with &lt;code&gt;:var name="Ada Lovelace"&lt;/code&gt; we get&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="mf"&gt;18151210&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h1&gt;Full Solution&lt;/h1&gt;
&lt;p&gt;So now we know what we are doing we need to solve all the puzzles and
lookup the data. Fortunately org-mode's tables are fully functional
spreadsheets except they are not limited to simple transformations.
Each formula can be a fully realised bit of elisp, calling other
source blocks as needed.&lt;/p&gt;
&lt;table id="orgb836df6" border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides"&gt;


&lt;colgroup&gt;
&lt;col  class="org-left" /&gt;

&lt;col  class="org-left" /&gt;

&lt;col  class="org-right" /&gt;
&lt;/colgroup&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th scope="col" class="org-left"&gt;Clue&lt;/th&gt;
&lt;th scope="col" class="org-left"&gt;Solution&lt;/th&gt;
&lt;th scope="col" class="org-right"&gt;DOB&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;

&lt;tbody&gt;
&lt;tr&gt;
&lt;td class="org-left"&gt;Herbal Cabbages&lt;/td&gt;
&lt;td class="org-left"&gt;Charles Babbage&lt;/td&gt;
&lt;td class="org-right"&gt;17911226&lt;/td&gt;
&lt;/tr&gt;


&lt;tr&gt;
&lt;td class="org-left"&gt;Be Google Roe&lt;/td&gt;
&lt;td class="org-left"&gt;George Boole&lt;/td&gt;
&lt;td class="org-right"&gt;18151102&lt;/td&gt;
&lt;/tr&gt;


&lt;tr&gt;
&lt;td class="org-left"&gt;Lava Ale Code&lt;/td&gt;
&lt;td class="org-left"&gt;Ada Lovelace&lt;/td&gt;
&lt;td class="org-right"&gt;18151210&lt;/td&gt;
&lt;/tr&gt;


&lt;tr&gt;
&lt;td class="org-left"&gt;A Cherry Skull&lt;/td&gt;
&lt;td class="org-left"&gt;Haskell Curry&lt;/td&gt;
&lt;td class="org-right"&gt;19000912&lt;/td&gt;
&lt;/tr&gt;


&lt;tr&gt;
&lt;td class="org-left"&gt;Jan Venom Hon Nun&lt;/td&gt;
&lt;td class="org-left"&gt;John Von Neumann&lt;/td&gt;
&lt;td class="org-right"&gt;19031228&lt;/td&gt;
&lt;/tr&gt;


&lt;tr&gt;
&lt;td class="org-left"&gt;Pope Charger&lt;/td&gt;
&lt;td class="org-left"&gt;Grace Hopper&lt;/td&gt;
&lt;td class="org-right"&gt;19061209&lt;/td&gt;
&lt;/tr&gt;


&lt;tr&gt;
&lt;td class="org-left"&gt;Natural Gin&lt;/td&gt;
&lt;td class="org-left"&gt;Alan Turing&lt;/td&gt;
&lt;td class="org-right"&gt;19120623&lt;/td&gt;
&lt;/tr&gt;


&lt;tr&gt;
&lt;td class="org-left"&gt;Each Noun Lands&lt;/td&gt;
&lt;td class="org-left"&gt;Claude Shannon&lt;/td&gt;
&lt;td class="org-right"&gt;19160430&lt;/td&gt;
&lt;/tr&gt;


&lt;tr&gt;
&lt;td class="org-left"&gt;Dolt And Hunk&lt;/td&gt;
&lt;td class="org-left"&gt;Donald Knuth&lt;/td&gt;
&lt;td class="org-right"&gt;19380110&lt;/td&gt;
&lt;/tr&gt;


&lt;tr&gt;
&lt;td class="org-left"&gt;Is Enriched Tin&lt;/td&gt;
&lt;td class="org-left"&gt;Dennis Ritchie&lt;/td&gt;
&lt;td class="org-right"&gt;19410909&lt;/td&gt;
&lt;/tr&gt;


&lt;tr&gt;
&lt;td class="org-left"&gt;Bran Hearing Kin&lt;/td&gt;
&lt;td class="org-left"&gt;Brian Kernighan&lt;/td&gt;
&lt;td class="org-right"&gt;19420101&lt;/td&gt;
&lt;/tr&gt;


&lt;tr&gt;
&lt;td class="org-left"&gt;Monk Hops Net&lt;/td&gt;
&lt;td class="org-left"&gt;Ken Thompson&lt;/td&gt;
&lt;td class="org-right"&gt;19430204&lt;/td&gt;
&lt;/tr&gt;


&lt;tr&gt;
&lt;td class="org-left"&gt;Wave Zone Kits&lt;/td&gt;
&lt;td class="org-left"&gt;Steve Wozniak&lt;/td&gt;
&lt;td class="org-right"&gt;19500811&lt;/td&gt;
&lt;/tr&gt;


&lt;tr&gt;
&lt;td class="org-left"&gt;Handcars All Trim&lt;/td&gt;
&lt;td class="org-left"&gt;Richard Stallman&lt;/td&gt;
&lt;td class="org-right"&gt;19530316&lt;/td&gt;
&lt;/tr&gt;


&lt;tr&gt;
&lt;td class="org-left"&gt;Enter Slim Beer&lt;/td&gt;
&lt;td class="org-left"&gt;Tim Berners-Lee&lt;/td&gt;
&lt;td class="org-right"&gt;19550608&lt;/td&gt;
&lt;/tr&gt;


&lt;tr&gt;
&lt;td class="org-left"&gt;Avid Null Sorts&lt;/td&gt;
&lt;td class="org-left"&gt;Linus Torvalds&lt;/td&gt;
&lt;td class="org-right"&gt;19691228&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;The #+TBLFM: is &lt;code&gt;$1='(identity remote(clues,@@#$1))::$2='(org-sbe solve-anagram (anagram $$1))::$3='(org-sbe frob-dob (name $$2))&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;The hex numbers are helpfully sorted so as long as we sort the clues
table by the looked up date of birth using &lt;em&gt;M-x org-table-sort-lines&lt;/em&gt;
we are good to go.&lt;/p&gt;</content><category term="geek"></category><category term="connect"></category><category term="emacs"></category><category term="linaro"></category><category term="org-mode"></category></entry><entry><title>Workbooks for Benchmarking</title><link href="https://www.bennee.com/~alex/blog/2018/02/21/workbooks-for-benchmarking/" rel="alternate"></link><published>2018-02-21T20:34:00+00:00</published><updated>2018-02-21T20:34:00+00:00</updated><author><name>alex</name></author><id>tag:www.bennee.com,2018-02-21:/~alex/blog/2018/02/21/workbooks-for-benchmarking/</id><summary type="html">&lt;p&gt;While working on a major re-factor of &lt;a class="reference external" href="http://lists.gnu.org/archive/html/qemu-devel/2018-02/msg01330.html"&gt;QEMU's softfloat code&lt;/a&gt; I've been doing a lot of benchmarking. It can be quite tedious work as you need to be careful you've run the correct steps on the correct binaries and keeping notes is important. It is a task that cries out …&lt;/p&gt;</summary><content type="html">&lt;p&gt;While working on a major re-factor of &lt;a class="reference external" href="http://lists.gnu.org/archive/html/qemu-devel/2018-02/msg01330.html"&gt;QEMU's softfloat code&lt;/a&gt; I've been doing a lot of benchmarking. It can be quite tedious work as you need to be careful you've run the correct steps on the correct binaries and keeping notes is important. It is a task that cries out for scripting but that in itself can be a compromise as you end up stitching a pipeline of commands together in something like perl. You may script it all in a language designed for this sort of thing like R but then find your final upload step is a pain to implement.&lt;/p&gt;
&lt;p&gt;One solution to this is to use a literate programming workbook like &lt;a class="reference external" href="https://github.com/stsquad/testcases/blob/master/aarch64/benchmark.org"&gt;this&lt;/a&gt;. Literate programming is a style where you interleave your code with natural prose describing the steps you go through. This is different from simply having well commented code in a source tree. For one thing you do not have to leap around a large code base as everything you need is on the file you are reading, from top to bottom. There are many solutions out there including &lt;a class="reference external" href="https://github.com/jupyter/jupyter/wiki/A-gallery-of-interesting-Jupyter-Notebooks"&gt;various python based examples&lt;/a&gt;. Of course being a happy Emacs user I use one of its stand-out features &lt;a class="reference external" href="https://en.wikipedia.org/wiki/Org-mode"&gt;org-mode&lt;/a&gt; which comes with multi-language &lt;a class="reference external" href="https://orgmode.org/worg/org-contrib/babel/"&gt;org-babel&lt;/a&gt; support. This allows me to document my benchmarking while scripting up the steps in a variety of &amp;quot;languages&amp;quot; depending on the my needs at the time. Let's take a look at the first section:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p class="rubric" id="orgb7da4a0"&gt;1 Binaries To Test&lt;/p&gt;
&lt;div id="text-1" class="outline-text-2"&gt;&lt;div class="line-block"&gt;
&lt;div class="line"&gt;Here we have several tables of binaries to test. We refer to the&lt;/div&gt;
&lt;div class="line"&gt;current benchmarking set from the next stage, Run Benchmark.&lt;/div&gt;
&lt;/div&gt;
&lt;div class="line-block"&gt;
&lt;div class="line"&gt;For a final test we might compare the system QEMU with a reference&lt;/div&gt;
&lt;div class="line"&gt;build as well as our current build.&lt;/div&gt;
&lt;/div&gt;
&lt;table border="1" class="docutils"&gt;
&lt;colgroup&gt;
&lt;col width="81%" /&gt;
&lt;col width="19%" /&gt;
&lt;/colgroup&gt;
&lt;thead valign="bottom"&gt;
&lt;tr&gt;&lt;th class="head"&gt;Binary&lt;/th&gt;
&lt;th class="head"&gt;title&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody valign="top"&gt;
&lt;tr&gt;&lt;td&gt;/usr/bin/qemu-aarch64&lt;/td&gt;
&lt;td&gt;system-2.5.log&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;~/lsrc/qemu/qemu-builddirs/arm-targets.build/aarch64-linux-user/qemu-aarch64&lt;/td&gt;
&lt;td&gt;master.log&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;~/lsrc/qemu/qemu.git/aarch64-linux-user/qemu-aarch64&lt;/td&gt;
&lt;td&gt;softfloat-v4.log&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/blockquote&gt;&lt;p&gt;Well that is certainly fairly explanatory. These are named org-mode tables which can be referred to in other code snippets and passed in as variables. So the next job is to run the benchmark itself:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p class="rubric" id="org5a36bd2"&gt;2 Run Benchmark&lt;/p&gt;
&lt;div id="text-2" class="outline-text-2"&gt;&lt;p&gt;This runs the benchmark against each binary we have selected above.&lt;/p&gt;
&lt;pre class="literal-block"&gt;
import subprocess
import os

runs=[]

for qemu,logname in files:
cmd=&amp;quot;taskset -c 0 %s ./vector-benchmark -n %s | tee %s&amp;quot; % (qemu, tests, logname)
    subprocess.call(cmd, shell=True)
    runs.append(logname)

    return runs
&lt;/pre&gt;
&lt;/div&gt;&lt;/blockquote&gt;
&lt;p&gt;So why use python as the test runner? Well truth is whenever I end up munging arrays in shell script I forget the syntax and end up jumping through all sorts of hoops. Easier just to have some simple python. I use python again later to read the data back into an org-table so I can pass it to the next step, graphing:&lt;/p&gt;
&lt;blockquote&gt;
&lt;pre class="literal-block"&gt;
set title &amp;quot;Vector Benchmark Results (lower is better)&amp;quot;
set style data histograms
set style fill solid 1.0 border lt -1

set xtics rotate by 90 right
set yrange [:]
set xlabel noenhanced
set ylabel &amp;quot;nsecs/Kop&amp;quot; noenhanced
set xtics noenhanced
set ytics noenhanced
set boxwidth 1
set xtics format &amp;quot;&amp;quot;
set xtics scale 0
set grid ytics
set term pngcairo size 1200,500

plot for [i=2:5] data using i:xtic(1) title columnhead
&lt;/pre&gt;
&lt;/blockquote&gt;
&lt;p&gt;This is a &lt;a class="reference external" href="https://en.wikipedia.org/wiki/Gnuplot"&gt;GNU Plot&lt;/a&gt; script which takes the data and plots an image from it. org-mode takes care of the details of marshalling the table data into GNU Plot so all this script is really concerned with is setting styles and titles. The language is capable of some fairly advanced stuff but I could always pre-process the data with something else if I needed to.&lt;/p&gt;
&lt;p&gt;Finally I need to upload my graph to an image hosting service to share with my colleges. This can be done with a elaborate curl command but I have another trick at my disposal thanks to the excellent &lt;a class="reference external" href="https://github.com/pashky/restclient.el"&gt;restclient-mode&lt;/a&gt;. This mode is actually designed for interactive debugging of REST APIs but it is also easily to use from an org-mode source block. So the whole thing looks like a HTTP session:&lt;/p&gt;
&lt;blockquote&gt;
&lt;pre class="literal-block"&gt;
:client_id = feedbeef

# Upload images to imgur
POST https://api.imgur.com/3/image
Authorization: Client-ID :client_id
Content-type: image/png

&amp;lt; benchmark.png
&lt;/pre&gt;
&lt;/blockquote&gt;
&lt;p&gt;Finally because the above dumps all the headers when run (which is very handy for debugging) I actually only want the URL in most cases. I can do this simply enough in elisp:&lt;/p&gt;
&lt;blockquote&gt;
&lt;pre class="literal-block"&gt;
#+name: post-to-imgur
#+begin_src emacs-lisp :var json-string=upload-to-imgur()
  (when (string-match
         (rx &amp;quot;link&amp;quot; (one-or-more (any &amp;quot;\&amp;quot;:&amp;quot; whitespace))
             (group (one-or-more (not (any &amp;quot;\&amp;quot;&amp;quot;)))))
         json-string)
    (match-string 1 json-string))
#+end_src
&lt;/pre&gt;
&lt;/blockquote&gt;
&lt;p&gt;The :var line calls the restclient-mode function automatically and passes it the result which it can then extract the final URL from.&lt;/p&gt;
&lt;p&gt;And there you have it, my entire benchmarking workflow document in a single file which I can read through tweaking each step as I go. This isn't the first time I've done this sort of thing. As I use org-mode extensively as a logbook to keep track of my upstream work I've slowly grown a series of scripts for common tasks. For example every patch series and pull request I post is done via org. I keep the whole thing in a git repository so each time I finish a sequence I can commit the results into the repository as a permanent record of what steps I ran.&lt;/p&gt;
&lt;p&gt;If you want even more inspiration I suggest you look at John Kitchen's &lt;a class="reference external" href="http://kitchingroup.cheme.cmu.edu/scimax"&gt;scimax&lt;/a&gt; work. As a publishing scientist he makes extensive use of org-mode when writing his papers. He is able to include the main prose with the code to plot the graphs and tables in a single source document from which his camera ready documents are generated. Should he ever need to reproduce any work his exact steps are all there in the source document. Yet another example of why org-mode is awesome ;-)&lt;/p&gt;
&lt;/div&gt;&lt;/blockquote&gt;
</content><category term="general"></category><category term="benchmark"></category><category term="emacs"></category><category term="linaro"></category><category term="org-mode"></category><category term="qemu"></category></entry><entry><title>FOSDEM 2018</title><link href="https://www.bennee.com/~alex/blog/2018/02/06/fosdem-2018/" rel="alternate"></link><published>2018-02-06T09:36:00+00:00</published><updated>2018-02-06T09:36:00+00:00</updated><author><name>alex</name></author><id>tag:www.bennee.com,2018-02-06:/~alex/blog/2018/02/06/fosdem-2018/</id><summary type="html">&lt;p&gt;I've just returned from a weekend in Brussels for my first ever FOSDEM - the Free and Open Source Developers, European Meeting. It's been on my list of conferences to go to for some time and thanks to getting my talk accepted, my &lt;a class="reference external" href="http://www.linaro.org"&gt;employer&lt;/a&gt; financed the cost of travel and hotels …&lt;/p&gt;</summary><content type="html">&lt;p&gt;I've just returned from a weekend in Brussels for my first ever FOSDEM - the Free and Open Source Developers, European Meeting. It's been on my list of conferences to go to for some time and thanks to getting my talk accepted, my &lt;a class="reference external" href="http://www.linaro.org"&gt;employer&lt;/a&gt; financed the cost of travel and hotels. Thanks to the support of the &lt;a class="reference external" href="http://www.ulb.ac.be/"&gt;Université libre de Bruxelles (ULB)&lt;/a&gt; the event itself is free and run entirely by volunteers. As you can expect from the name they also have a strong commitment to free and open source software.&lt;/p&gt;
&lt;p&gt;&lt;img alt="image0" class="alignright size-thumbnail wp-image-2761" src="/~alex/blog/wp-content/uploads/2018/02/fos-150x33.jpg" style="width: 150px; height: 33px;" /&gt;&lt;/p&gt;
&lt;p&gt;The first thing that struck me about the conference is how wide ranging it was. There were talks on everything from the internals of debugging tools to developing public policy. When I first loaded up their excellent companion app (naturally via &lt;a class="reference external" href="https://f-droid.org/en/packages/be.digitalia.fosdem/"&gt;the F-Droid repository&lt;/a&gt;) I was somewhat overwhelmed by the choice. As it is a free conference there is no limit on the numbers who can attend which means you are not always guarenteed to be able to get into every talk. In fact during the event I walked past many long queues for the more popular talks. In the end I ended up just bookmarking all the talks I was interested in and deciding which one to go to depending on how I felt at the time. Fortunately FOSDEM have a strong archiving policy and video most of their talks so I'll be spending the next few weeks catching up on the ones I missed.&lt;/p&gt;
&lt;p&gt;There now follows a non-exhaustive list of the most interesting ones I was able to see live:&lt;/p&gt;
&lt;p&gt;Dashamir's &lt;a class="reference external" href="https://fosdem.org/2018/schedule/event/easy_gnupg/"&gt;talk on EasyGPG&lt;/a&gt; dealt with the opinionated decisions it makes to try and make the use of GnuPG more intuitive to those not versed in the full gory details of public key cryptography. Although I use GPG mainly for signing GIT pull requests I really should make better use it over all. The split-key solution to backups was particularly interesting. I suspect I'll need a little convincing before I put part of my key in the cloud but I'll certainly check out his scripts.&lt;/p&gt;
&lt;p&gt;Liam's &lt;a class="reference external" href="https://fosdem.org/2018/schedule/event/alternative_histories/"&gt;A Circuit Less Travelled&lt;/a&gt; was an entertaining tour of some of the technologies and ideas from early computer history that got abandoned on the wayside. These ideas were often to be re-invented in a less superior form as engineers realised the error of their ways as technology advanced. The later half of the talk turns into a bit of LISP love-fest but as an Emacs user with an ever growing config file that is fine by me ;-)&lt;/p&gt;
&lt;p&gt;Following on in the history vein was Steven Goodwin's talk on &lt;a class="reference external" href="https://fosdem.org/2018/schedule/event/digital_archaeology/"&gt;Digital Archaeology&lt;/a&gt; which was a salutatory reminder of the amount of recent history that is getting lost as computing's breakneck pace has discarded old physical formats in lieu of newer equally short lived formats. It reminded me I should really do something about the 3 boxes of floppy disks I have under my desk. I also need to schedule a visit to the &lt;a class="reference external" href="http://www.computinghistory.org.uk/"&gt;Computer History Museum&lt;/a&gt; with my children seeing as it is more or less on my doorstep.&lt;/p&gt;
&lt;p&gt;There was a tongue in check &lt;a class="reference external" href="http://n-gate.com/fosdem/"&gt;preview&lt;/a&gt; that described the &lt;a class="reference external" href="https://fosdem.org/2018/schedule/event/edsac/"&gt;EDSAC talk&lt;/a&gt; as recreating &amp;quot;an ancient computer without any of the things that made it interesting&amp;quot;. This was was a little unkind. Although the project re-implemented the computation parts in a tiny little FPGA the core idea was to introduce potential students to the physicality of the early computers. After an introduction to the hoary architecture of the original EDSAC and &lt;a class="reference external" href="https://www.youtube.com/watch?v=DcZ1bFfDvSQ"&gt;the Wheeler Jump&lt;/a&gt; Mary introduced the hardware they re-imagined for the project. The first was an optical reader developed to read in paper tapes although this time ones printed on thermal receipt paper. This included an in-depth review of the problems of smoothing out analogue inputs to get reliable signals from their optical sensors which mirrors the problems the rebuild is facing with nature of the valves used in EDSAC. It is a shame they couldn't come up with some way to involve a valve but I guess high-tension supplies and school kids don't mix well. However they did come up with a way of re-creating the original acoustic mercury delay lines but this time with a tube of air and some 3D printed parabolic ends.&lt;/p&gt;
&lt;p&gt;The big geek event was the much anticipated announcement of RISC-V hardware during the &lt;a class="reference external" href="https://fosdem.org/2018/schedule/event/riscv/"&gt;RISC-V enablement talk&lt;/a&gt;. It seemed to be an open secret the announcement was coming but it still garnered hearty applause when it finally came. I should point out I'm indirectly employed by companies with an interest in a competing architecture but it is still good to see other stuff out there. The board is fairly open but there are still some peripheral IPs which were closed which shows just how tricky getting to fully-free hardware is going to be. As I understand the RISC-V's licensing model the ISA is open (unlike for example an ARM Architecture License) but individual companies can still have closed implementations which they license to be manufactured which is how I assume SiFive funds development. The actual CPU implementation is still very much a black box you have to take on trust.&lt;/p&gt;
&lt;p&gt;Finally for those that are interested &lt;a class="reference external" href="https://fosdem.org/2018/schedule/event/vai_vectors_meet_virtualization/"&gt;my talk is already online&lt;/a&gt; for those that are interested in what I'm currently working on. The slides have been slightly cropped in the video but if you follow the &lt;a class="reference external" href="http://people.linaro.org/~alex.bennee/org/presentations/vectors-meet-virt.html"&gt;link to the HTML version&lt;/a&gt; you can read along on your machine.&lt;/p&gt;
&lt;p&gt;I have to say FOSDEM's setup is pretty impressive. Although there was a volunteer in each room to deal with fire safety and replace microphones all the recording is fully automated. There are rather fancy hand crafted wooden boxes in each room which take the feed from your laptop and mux it with the camera. I got the email from the automated system asking me to review a preview of my talk about half and hour after I gave it. It took a little longer for the final product to get encoded and online but it's certainly the nicest system I've come across so far.&lt;/p&gt;
&lt;p&gt;All in all I can heartily recommend FOSDEM for anyone in an interest is FLOSS. It's a packed schedule and there is going to be something for everyone there. Big thanks to all the volunteers and organisers and I hope I can make it next year ;-)&lt;/p&gt;
</content><category term="geek"></category><category term="conference"></category><category term="edsac"></category><category term="emacs"></category><category term="fosdem"></category><category term="linaro"></category><category term="lisp"></category></entry><entry><title>Running Linux in QEMU's aarch64 system emulation mode</title><link href="https://www.bennee.com/~alex/blog/2014/05/09/running-linux-in-qemus-aarch64-system-emulation-mode/" rel="alternate"></link><published>2014-05-09T13:14:00+01:00</published><updated>2014-05-09T13:14:00+01:00</updated><author><name>alex</name></author><id>tag:www.bennee.com,2014-05-09:/~alex/blog/2014/05/09/running-linux-in-qemus-aarch64-system-emulation-mode/</id><summary type="html">&lt;p&gt;Since I started working on &lt;a class="reference external" href="http://translatedcode.wordpress.com/2014/04/24/64-bit-arm-usermode-emulation-in-qemu-2-0-0/"&gt;aarch64 support for QEMU&lt;/a&gt; the most frequently asked question I got was &amp;quot;when can I run aarch64 system emulation on QEMU?&amp;quot;. Well wait no more as support for a VIRT-IO based aarch64 board was recently merged into the master branch of QEMU. In this post …&lt;/p&gt;</summary><content type="html">&lt;p&gt;Since I started working on &lt;a class="reference external" href="http://translatedcode.wordpress.com/2014/04/24/64-bit-arm-usermode-emulation-in-qemu-2-0-0/"&gt;aarch64 support for QEMU&lt;/a&gt; the most frequently asked question I got was &amp;quot;when can I run aarch64 system emulation on QEMU?&amp;quot;. Well wait no more as support for a VIRT-IO based aarch64 board was recently merged into the master branch of QEMU. In this post I'll talk about building QEMU, a rootfs and a kernel that will allow you to start experimenting with the architecture.&lt;/p&gt;
&lt;div class="section" id="quick-start"&gt;
&lt;h2&gt;Quick start&lt;/h2&gt;
&lt;p&gt;Let's first start with building and running QEMU with some pre-built images.&lt;/p&gt;
&lt;div class="section" id="build-dependancies"&gt;
&lt;h3&gt;Build Dependancies&lt;/h3&gt;
&lt;p&gt;As has been noted in the comments the &lt;em&gt;configure&lt;/em&gt; script will automatically enable features as long as the pre-requisite developer libraries are installed on your sytem. With a Debian/Ubuntu system this is easily achieved by running:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
sudo apt-get build-dep qemu
&lt;/pre&gt;
&lt;p&gt;Of course if you want to enable a feature (either a bleeding edge or non-standard) that requires additional libraries then you will need to install the appropriate development packages manually. The &lt;em&gt;config.log&lt;/em&gt; file is usually a useful first step in working out what headers are being looked for.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="building-qemu"&gt;
&lt;h3&gt;Building QEMU&lt;/h3&gt;
&lt;pre class="literal-block"&gt;
git clone git://git.qemu.org/qemu.git qemu.git
cd qemu.git
./configure --target-list=aarch64-softmmu
make
&lt;/pre&gt;
&lt;p&gt;Assuming the build ran without any problems you should now have an executable &lt;em&gt;./aarch64-softmmu/qemu-system-aarch64&lt;/em&gt; in your build directory. Grab a pre-built image from &lt;a class="reference external" href="http://people.linaro.org/~alex.bennee/images/aarch64-linux-3.15rc2-buildroot.img"&gt;here&lt;/a&gt; and we'll check it works. The image is a kernel that has been combined with an initial RAM disk (initrd) with a basic root file-system. I go into more details on how to create this later on.&lt;/p&gt;
&lt;p&gt;Be aware the command line is quite long so make sure you copy it all ;-)&lt;/p&gt;
&lt;pre class="literal-block"&gt;
wget http://people.linaro.org/~alex.bennee/images/aarch64-linux-3.15rc2-buildroot.img
./aarch64-softmmu/qemu-system-aarch64 -machine virt -cpu cortex-a57 -machine type=virt -nographic -smp 1 -m 2048 -kernel aarch64-linux-3.15rc2-buildroot.img  --append &amp;quot;console=ttyAMA0&amp;quot;
&lt;/pre&gt;
&lt;p&gt;If all went well you should see the familiar Linux boot sequence and eventually get a login prompt. Login as root (no password) and play in the new sandbox.&lt;/p&gt;
&lt;pre class="literal-block"&gt;
... usual kernel boot output ...
Welcome to Buildroot
buildroot login: root
# uname -a
Linux buildroot 3.15.0-rc2ajb-00069-g1aae31c #39 SMP Thu Apr 24 11:48:57 BST 2014 aarch64 GNU/Linux
&lt;/pre&gt;
&lt;p&gt;Once you are done type &lt;em&gt;C-a c&lt;/em&gt; to enter QEMU's monitor mode and then quit to exit.&lt;/p&gt;
&lt;pre class="literal-block"&gt;
QEMU 2.0.50 monitor - type 'help' for more information
(qemu) quit
&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="section" id="accessing-your-local-file-system"&gt;
&lt;h2&gt;Accessing your local file-system&lt;/h2&gt;
&lt;p&gt;This is all very well but the test image only has a fairly limited root file-system attached to it. It will be a lot more useful if you could access your host file-system to test other binaries. Thanks to VIRT FS we can achieve this without too much hassle. Use the following extended QEMU command line:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
./aarch64-softmmu/qemu-system-aarch64 -machine virt -cpu cortex-a57 -machine type=virt -nographic -smp 1 -m 2048 -kernel aarch64-linux-3.15rc2-buildroot.img --append &amp;quot;console=ttyAMA0&amp;quot; -fsdev local,id=r,path=/home/alex/lsrc/qemu/rootfs/trusty-core,security_model=none -device virtio-9p-device,fsdev=r,mount_tag=r
&lt;/pre&gt;
&lt;p&gt;This sets up the selected path to be mountable by the guest. In this case I'm using an Ubuntu rootfs which can be downloaded from &lt;a class="reference external" href="http://cdimages.ubuntu.com/ubuntu-core/releases/14.04/release/"&gt;here&lt;/a&gt;. Once the system has booted the following commands on the guest will mount the local file-system:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
Welcome to Buildroot
buildroot login: root
# mount -t 9p -o trans=virtio r /mnt
# ls -l /mnt/
total 84
drwxr-xr-x    2 default  default       4096 Apr  2  2014 bin
drwxr-xr-x    2 default  default       4096 Feb 27  2014 boot
drwxr-xr-x    3 default  default       4096 Apr  2  2014 dev
drwxr-xr-x   64 default  default       4096 Apr  3  2014 etc
drwxr-xr-x    2 default  default       4096 Feb 27  2014 home
..
&lt;/pre&gt;
&lt;/div&gt;
&lt;div class="section" id="building-your-own-rootfs"&gt;
&lt;h2&gt;Building your own rootfs&lt;/h2&gt;
&lt;p&gt;There are many solutions to this (including downloading &lt;a class="reference external" href="http://www.linaro.org/downloads/"&gt;Linaro engineering builds&lt;/a&gt;) but the simplest one I've found for rolling your own from scratch is the &lt;a class="reference external" href="http://buildroot.uclibc.org/"&gt;Buildroot project&lt;/a&gt;. It present the familiar kernel menuconfig interface and deals with all the hassle of setting up cross compilers for you.&lt;/p&gt;
&lt;pre class="literal-block"&gt;
git clone git://git.buildroot.net/buildroot buildroot.git
cd buildroot.git
make menuconfig
&lt;/pre&gt;
&lt;p&gt;There are lots of configuration options to choose from but the following are what I use:&lt;/p&gt;
&lt;div class="line-block"&gt;
&lt;div class="line"&gt;* Target Options -&amp;gt; Target Architecture(AArch64)&lt;/div&gt;
&lt;div class="line"&gt;* Toolchain -&amp;gt; Toolchain type (External toolchain)&lt;/div&gt;
&lt;div class="line"&gt;* Toolchain -&amp;gt; Toolchain (Linaro AArch64 14.02)&lt;/div&gt;
&lt;div class="line"&gt;* System configuration -&amp;gt; Run a getty (login prompt) after boot (BR2_TARGET_GENERIC_GETTY)&lt;/div&gt;
&lt;div class="line"&gt;* System configuration -&amp;gt; getty options -&amp;gt; TTY Port (ttyAMA0) (BR2_TARGET_GENERIC_GETTY_PORT)&lt;/div&gt;
&lt;div class="line"&gt;* Target Packages -&amp;gt; Show packages that are also provided by busybox (BR2_PACKAGE_BUSYBOX_SHOW_OTHERS)&lt;/div&gt;
&lt;div class="line"&gt;* Filesystem images -&amp;gt; cpio the root filesystem (for use as an initial RAM filesystem) (BR2_TARGET_ROOTFS_CPIO)&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;The last one will be important for when we build the kernel next. Once you have configured buildroot to your liking it's time to type make and leave it for a while as you enjoy a nice lunch ;-)&lt;/p&gt;
&lt;pre class="literal-block"&gt;
make
.. lots of output ..
&lt;/pre&gt;
&lt;/div&gt;
&lt;div class="section" id="building-a-kernel"&gt;
&lt;h2&gt;Building a kernel&lt;/h2&gt;
&lt;p&gt;For building the kernel I use my distro's aarch64 cross-compiler. On Debian/Ubuntu systems this is easily added with:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
$ sudo apt-get install gcc-aarch64-linux-gnu
&lt;/pre&gt;
&lt;p&gt;And the usual kernel building process, with a few tweaks for cross compiling:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
git clone https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git linux.git
cd linux.git
ARCH=arm64 make menuconfig
&lt;/pre&gt;
&lt;p&gt;I've put my full config up &lt;a class="reference external" href="http://people.linaro.org/~alex.bennee/images/aarch64-kernel.config"&gt;here&lt;/a&gt; but important options to note are:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
CONFIG_CROSS_COMPILE=&amp;quot;aarch64-linux-gnu-&amp;quot;                                               # needs to match your cross-compiler prefix
CONFIG_INITRAMFS_SOURCE=&amp;quot;/home/alex/lsrc/qemu/buildroot.git/output/images/rootfs.cpio&amp;quot;  # points at your buildroot image
CONFIG_NET_9P=y                                                                         # needed for virtfs mount
CONFIG_NET_9P_VIRTIO=y
&lt;/pre&gt;
&lt;p&gt;Finally you build it all with:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
ARCH=arm64 make -j 8
&lt;/pre&gt;
&lt;p&gt;The &lt;em&gt;-j 8&lt;/em&gt; just specifies how many parallel build threads to use. Generally set it to the number of cores you have on your machine.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="final-test"&gt;
&lt;h2&gt;Final test&lt;/h2&gt;
&lt;p&gt;All that remains is to test that the newly built kernel works:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
./aarch64-softmmu/qemu-system-aarch64 -machine virt -cpu cortex-a57 -machine type=virt -nographic -smp 1 -m 2048 -kernel ../linux.git/arch/arm64/boot/Image  --append &amp;quot;console=ttyAMA0&amp;quot;
... lots more output ...
Welcome to Buildroot
ajbtest login: root
[root&amp;#64;ajbtest ~]# ls -l
total 0
[root&amp;#64;ajbtest ~]# uname -a
Linux ajbtest 3.15.0-rc4ajb-00320-gafcf0a2-dirty #41 SMP Fri May 9 13:05:31 BST 2014 aarch64 GNU/Linux
&lt;/pre&gt;
&lt;div class="line-block"&gt;
&lt;div class="line"&gt;&lt;strong&gt;UPDATED:&lt;/strong&gt; 27/05/2014&lt;/div&gt;
&lt;div class="line"&gt;* Added notes about library dependencies&lt;/div&gt;
&lt;div class="line"&gt;* Cleaned up formatting of shell sections, mention length of command line!&lt;/div&gt;
&lt;div class="line"&gt;* Fix some spelling errors&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</content><category term="geek"></category><category term="aarch64"></category><category term="arm64"></category><category term="linaro"></category><category term="qemu"></category></entry><entry><title>Anyone interested at an Emacs BoF at LCU14?</title><link href="https://www.bennee.com/~alex/blog/2014/04/29/anyone-interested-at-an-emacs-bof-at-lcu14/" rel="alternate"></link><published>2014-04-29T16:00:00+01:00</published><updated>2014-04-29T16:00:00+01:00</updated><author><name>alex</name></author><id>tag:www.bennee.com,2014-04-29:/~alex/blog/2014/04/29/anyone-interested-at-an-emacs-bof-at-lcu14/</id><summary type="html">&lt;p&gt;I'm fairly atypical as a Linaro employee because I have a desk in a shared office. This means I get to participate in technical banter with the other employees based in the Cambridge office. However it has become quite clear I'm surrounded on all sides by VIMers with only one …&lt;/p&gt;</summary><content type="html">&lt;p&gt;I'm fairly atypical as a Linaro employee because I have a desk in a shared office. This means I get to participate in technical banter with the other employees based in the Cambridge office. However it has become quite clear I'm surrounded on all sides by VIMers with only one potential convert who wants to try Emacs out &amp;quot;one day&amp;quot;. As a result I thought it might be nice to have an Emacs Birds of a Feather (BoF) session at &lt;a class="reference external" href="http://www.linaro.org/connect/lcu/lcu14/"&gt;LCU14&lt;/a&gt;?&lt;/p&gt;
&lt;p&gt;BoF sessions are basically an informal gathering where people with a shared interest who come along to swap tips and stories about their area of interest. In the context of LCU it would be an opportunity to network and meet fellow Emacers. So any interest?&lt;/p&gt;
</content><category term="geek"></category><category term="emacs"></category><category term="linaro"></category></entry><entry><title>Boutique modes</title><link href="https://www.bennee.com/~alex/blog/2014/03/05/boutique-modes/" rel="alternate"></link><published>2014-03-05T10:12:00+00:00</published><updated>2014-03-05T10:12:00+00:00</updated><author><name>alex</name></author><id>tag:www.bennee.com,2014-03-05:/~alex/blog/2014/03/05/boutique-modes/</id><summary type="html">&lt;p&gt;I've recently started a new job at &lt;a class="reference external" href="http:www.linaro.org"&gt;Linaro&lt;/a&gt; which has been keeping me very busy. My role combines the low-level fun of Dynamic Binary Translation that I so enjoyed at Transitive and the fact Linaro is a fully Open Source company. I work directly on the upstream projects (in this …&lt;/p&gt;</summary><content type="html">&lt;p&gt;I've recently started a new job at &lt;a class="reference external" href="http:www.linaro.org"&gt;Linaro&lt;/a&gt; which has been keeping me very busy. My role combines the low-level fun of Dynamic Binary Translation that I so enjoyed at Transitive and the fact Linaro is a fully Open Source company. I work directly on the upstream projects (in this case &lt;a class="reference external" href="http://wiki.qemu.org/Main_Page"&gt;QEMU&lt;/a&gt;) and with the project community. In many ways it's my ideal job.&lt;/p&gt;
&lt;p&gt;Of course I've quickly built up a reputation as the Emacs guy in the office surrounded by a sea of VIMers although one of the guys does profess a desire to learn Emacs &amp;quot;one day&amp;quot;.&lt;/p&gt;
&lt;p&gt;One of the first things I did was move all my email into Emacs. I'd long been dissatisfied with the state of Thunderbird (and previously Evolution) that I took the opportunity to migrate to &lt;a class="reference external" href="http://www.djcbsoftware.nl/code/mu/mu4e.html"&gt;mu4e&lt;/a&gt;. I spend my days slinging patches and going through mailing lists so I really appreciate being in my editor while I do that.&lt;/p&gt;
&lt;p&gt;I have also started streamlining some of my work-flow with a few specialised extensions to Emacs. I think I'm finally comfortable enough with elisp to have a pretty good stab at solving most problems. I'm also appreciating the ability to leverage the mass of Emacs code under the hood to make incremental tweaks rather than solve everything at once. I thought I might give you a tour of the code I've written so far.&lt;/p&gt;
&lt;p&gt;First up is &lt;a class="reference external" href="https://github.com/stsquad/risu/blob/aarch-with-ajb-hacks/risu.el"&gt;risu-mode&lt;/a&gt;. RISU is the code testing tool we've been using to verify our aarch64 ARM work in QEMU. The .risu file is a template that's used to specify instruction patterns that the tool then uses to generate random code sequences with. &lt;em&gt;risu-mode&lt;/em&gt; is really just a bunch of regex expressions wrapped in the mode machinery that highlights the elements on the page. It doesn't sound like much but when you are working through a bunch of patterns looking for bugs it's easier on the eye when the different elements are coloured.&lt;/p&gt;
&lt;p&gt;Next thing I wrote was my own &lt;a class="reference external" href="https://github.com/stsquad/qemu-mode/blob/master/qemu-mode.el"&gt;QEMU mode&lt;/a&gt; which is a simple comint-mode based mode for launching QEMU system emulation. It's still very rough and ready as I'm mostly working on user emulation but I suspect it will be handy once I start on system emulation stuff.&lt;/p&gt;
&lt;p&gt;Finally there is &lt;a class="reference external" href="http://git.linaro.org/people/alex.bennee/lava-mode.git"&gt;lava-mode&lt;/a&gt;. LAVA is Linaro's automated test and validation framework. Although it already provides command line and web interfaces I thought it would be nice to launch and track test jobs from within Emacs itself. The job control files a JSON based so I built on the existing json-mode and a &lt;a class="reference external" href="https://github.com/stsquad/xml-rpc/tree/extra-headers"&gt;slightly patched version of xml-rpc.el&lt;/a&gt; to add job submission. I've started a simple job tracking mode that uses the tabulated-list-mode framework and eventually I'll link it into the tracking library so job completion will be as seamless as my IRC work-flow.&lt;/p&gt;
&lt;p&gt;So there you have it, a bunch of code that may well not interest anyone else but shows how Emacs provides a very rich base of functionality on which to build up tools that are useful to you.&lt;/p&gt;
&lt;p&gt;Does anyone else want to share an example of their esoteric extensions? What's the most obscure thing you've built on top of our favourite text editor?&lt;/p&gt;
</content><category term="geek"></category><category term="emacs"></category><category term="linaro"></category></entry></feed>