<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Python on SCMB XYZ</title>
    <link>https://www.scmb.xyz/tags/python/</link>
    <description>Recent content in Python on SCMB XYZ</description>
    <generator>Hugo</generator>
    <language>en-gb</language>
    <copyright>&amp;copy; Seamus Bradley 2021–6</copyright>
    <lastBuildDate>Sun, 01 Dec 2024 20:49:23 +0000</lastBuildDate>
    <atom:link href="https://www.scmb.xyz/tags/python/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>December Adventure 2024</title>
      <link>https://www.scmb.xyz/post/december-adventure-2024/</link>
      <pubDate>Sun, 01 Dec 2024 20:49:23 +0000</pubDate>
      <guid>https://www.scmb.xyz/post/december-adventure-2024/</guid>
      <description>&lt;p&gt;While I have enjoyed doing (the first week or two of) Advent of Code the last few years,&#xA;I think I&amp;rsquo;m going to not do it this year.&#xA;I currently have my one-month old son asleep on me, and this is simply not an environment&#xA;that&amp;rsquo;s conducive to that kind of problem-solving.&#xA;I think, instead, I will participate in &lt;a href=&#34;https://eli.li/december-adventure&#34;&gt;December Adventure&lt;/a&gt;&#xA;which seems like a much gentler way of having some community and bit of a push to do a bit of coding&#xA;this month.&#xA;I have a few plans for what I will work on, but I am deliberately not specifying them up front in case&#xA;I don&amp;rsquo;t actually decide to work on them this month.&#xA;This post will record what I got up to on each day, so I&amp;rsquo;ll be editing it throughout the month.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Who Did Best At The Olympics?</title>
      <link>https://www.scmb.xyz/post/olympic-medals-per-capita/</link>
      <pubDate>Mon, 12 Aug 2024 17:46:46 +0100</pubDate>
      <guid>https://www.scmb.xyz/post/olympic-medals-per-capita/</guid>
      <description>&lt;p&gt;Every four years (give or take a pandemic postponement) debate breaks out about the best way to measure&#xA;who did best at the olympics.&#xA;I&amp;rsquo;m going to look at a couple here.&lt;/p&gt;&#xA;&lt;h1 id=&#34;medals&#34;&gt;Medals&lt;/h1&gt;&#xA;&lt;p&gt;What&amp;rsquo;s a better measure of success?&#xA;Gold medals?&#xA;Total medals?&#xA;If we look at medal totals, the top ten looks like this:&lt;/p&gt;&#xA;&lt;table&gt;&#xA;  &lt;thead&gt;&#xA;      &lt;tr&gt;&#xA;          &lt;th style=&#34;text-align: left&#34;&gt;&lt;/th&gt;&#xA;          &lt;th style=&#34;text-align: right&#34;&gt;Gold&lt;/th&gt;&#xA;          &lt;th style=&#34;text-align: right&#34;&gt;Silver&lt;/th&gt;&#xA;          &lt;th style=&#34;text-align: right&#34;&gt;Bronze&lt;/th&gt;&#xA;          &lt;th style=&#34;text-align: right&#34;&gt;Medal Totals&lt;/th&gt;&#xA;      &lt;/tr&gt;&#xA;  &lt;/thead&gt;&#xA;  &lt;tbody&gt;&#xA;      &lt;tr&gt;&#xA;          &lt;td style=&#34;text-align: left&#34;&gt;United States&lt;/td&gt;&#xA;          &lt;td style=&#34;text-align: right&#34;&gt;40&lt;/td&gt;&#xA;          &lt;td style=&#34;text-align: right&#34;&gt;44&lt;/td&gt;&#xA;          &lt;td style=&#34;text-align: right&#34;&gt;42&lt;/td&gt;&#xA;          &lt;td style=&#34;text-align: right&#34;&gt;126&lt;/td&gt;&#xA;      &lt;/tr&gt;&#xA;      &lt;tr&gt;&#xA;          &lt;td style=&#34;text-align: left&#34;&gt;China&lt;/td&gt;&#xA;          &lt;td style=&#34;text-align: right&#34;&gt;40&lt;/td&gt;&#xA;          &lt;td style=&#34;text-align: right&#34;&gt;27&lt;/td&gt;&#xA;          &lt;td style=&#34;text-align: right&#34;&gt;24&lt;/td&gt;&#xA;          &lt;td style=&#34;text-align: right&#34;&gt;91&lt;/td&gt;&#xA;      &lt;/tr&gt;&#xA;      &lt;tr&gt;&#xA;          &lt;td style=&#34;text-align: left&#34;&gt;Great Britain&lt;/td&gt;&#xA;          &lt;td style=&#34;text-align: right&#34;&gt;14&lt;/td&gt;&#xA;          &lt;td style=&#34;text-align: right&#34;&gt;22&lt;/td&gt;&#xA;          &lt;td style=&#34;text-align: right&#34;&gt;29&lt;/td&gt;&#xA;          &lt;td style=&#34;text-align: right&#34;&gt;65&lt;/td&gt;&#xA;      &lt;/tr&gt;&#xA;      &lt;tr&gt;&#xA;          &lt;td style=&#34;text-align: left&#34;&gt;France&lt;/td&gt;&#xA;          &lt;td style=&#34;text-align: right&#34;&gt;16&lt;/td&gt;&#xA;          &lt;td style=&#34;text-align: right&#34;&gt;26&lt;/td&gt;&#xA;          &lt;td style=&#34;text-align: right&#34;&gt;22&lt;/td&gt;&#xA;          &lt;td style=&#34;text-align: right&#34;&gt;64&lt;/td&gt;&#xA;      &lt;/tr&gt;&#xA;      &lt;tr&gt;&#xA;          &lt;td style=&#34;text-align: left&#34;&gt;Australia&lt;/td&gt;&#xA;          &lt;td style=&#34;text-align: right&#34;&gt;18&lt;/td&gt;&#xA;          &lt;td style=&#34;text-align: right&#34;&gt;19&lt;/td&gt;&#xA;          &lt;td style=&#34;text-align: right&#34;&gt;16&lt;/td&gt;&#xA;          &lt;td style=&#34;text-align: right&#34;&gt;53&lt;/td&gt;&#xA;      &lt;/tr&gt;&#xA;      &lt;tr&gt;&#xA;          &lt;td style=&#34;text-align: left&#34;&gt;Japan&lt;/td&gt;&#xA;          &lt;td style=&#34;text-align: right&#34;&gt;20&lt;/td&gt;&#xA;          &lt;td style=&#34;text-align: right&#34;&gt;12&lt;/td&gt;&#xA;          &lt;td style=&#34;text-align: right&#34;&gt;13&lt;/td&gt;&#xA;          &lt;td style=&#34;text-align: right&#34;&gt;45&lt;/td&gt;&#xA;      &lt;/tr&gt;&#xA;      &lt;tr&gt;&#xA;          &lt;td style=&#34;text-align: left&#34;&gt;Italy&lt;/td&gt;&#xA;          &lt;td style=&#34;text-align: right&#34;&gt;12&lt;/td&gt;&#xA;          &lt;td style=&#34;text-align: right&#34;&gt;13&lt;/td&gt;&#xA;          &lt;td style=&#34;text-align: right&#34;&gt;15&lt;/td&gt;&#xA;          &lt;td style=&#34;text-align: right&#34;&gt;40&lt;/td&gt;&#xA;      &lt;/tr&gt;&#xA;      &lt;tr&gt;&#xA;          &lt;td style=&#34;text-align: left&#34;&gt;Netherlands&lt;/td&gt;&#xA;          &lt;td style=&#34;text-align: right&#34;&gt;15&lt;/td&gt;&#xA;          &lt;td style=&#34;text-align: right&#34;&gt;7&lt;/td&gt;&#xA;          &lt;td style=&#34;text-align: right&#34;&gt;12&lt;/td&gt;&#xA;          &lt;td style=&#34;text-align: right&#34;&gt;34&lt;/td&gt;&#xA;      &lt;/tr&gt;&#xA;      &lt;tr&gt;&#xA;          &lt;td style=&#34;text-align: left&#34;&gt;Germany&lt;/td&gt;&#xA;          &lt;td style=&#34;text-align: right&#34;&gt;12&lt;/td&gt;&#xA;          &lt;td style=&#34;text-align: right&#34;&gt;13&lt;/td&gt;&#xA;          &lt;td style=&#34;text-align: right&#34;&gt;8&lt;/td&gt;&#xA;          &lt;td style=&#34;text-align: right&#34;&gt;33&lt;/td&gt;&#xA;      &lt;/tr&gt;&#xA;      &lt;tr&gt;&#xA;          &lt;td style=&#34;text-align: left&#34;&gt;South Korea&lt;/td&gt;&#xA;          &lt;td style=&#34;text-align: right&#34;&gt;13&lt;/td&gt;&#xA;          &lt;td style=&#34;text-align: right&#34;&gt;9&lt;/td&gt;&#xA;          &lt;td style=&#34;text-align: right&#34;&gt;10&lt;/td&gt;&#xA;          &lt;td style=&#34;text-align: right&#34;&gt;32&lt;/td&gt;&#xA;      &lt;/tr&gt;&#xA;  &lt;/tbody&gt;&#xA;&lt;/table&gt;&#xA;&lt;p&gt;Whereas if we focus on gold medals only&lt;sup id=&#34;fnref:1&#34;&gt;&lt;a href=&#34;#fn:1&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;1&lt;/a&gt;&lt;/sup&gt; a very slightly different picture emerges:&lt;/p&gt;</description>
    </item>
    <item>
      <title>How Errors Compound</title>
      <link>https://www.scmb.xyz/post/how-errors-compound/</link>
      <pubDate>Tue, 26 Sep 2023 16:54:23 +0100</pubDate>
      <guid>https://www.scmb.xyz/post/how-errors-compound/</guid>
      <description>&lt;p&gt;I was messing around with a project recently,&#xA;and I thought everything was going swimmingly.&#xA;My unit tests were passing,&#xA;the output to stdin looked like I&amp;rsquo;d expect.&#xA;And then I made one small change,&#xA;and instead of the binary number I was expecting,&#xA;I saw:&lt;/p&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;1010101001001020&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;&amp;ldquo;Ones and zeroes everywhere. And I think I saw a two!&amp;rdquo;;&#xA;&amp;ldquo;It was just a dream, Bender.&#xA;There&amp;rsquo;s no such thing as a two.&amp;rdquo;&#xA;I added a bunch more unit tests but they didn&amp;rsquo;t seem to be finding the two.&#xA;It took me quite a while to figure out what the problem&#xA;was because there were in fact two problems:&#xA;one with the function code,&#xA;and one with the tests.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Python&#39;s Counter</title>
      <link>https://www.scmb.xyz/post/pythons-counter/</link>
      <pubDate>Fri, 27 Jan 2023 01:11:54 +0000</pubDate>
      <guid>https://www.scmb.xyz/post/pythons-counter/</guid>
      <description>&lt;h1 id=&#34;the-problem&#34;&gt;The problem&lt;/h1&gt;&#xA;&lt;p&gt;Python has a &lt;code&gt;Counter&lt;/code&gt; object &amp;ndash; it&amp;rsquo;s found in&#xA;&lt;a href=&#34;https://docs.python.org/3/library/collections.html&#34;&gt;the &lt;code&gt;collections&lt;/code&gt; module&lt;/a&gt; &amp;ndash;&#xA;and I&amp;rsquo;ve become convinced that it&amp;rsquo;s&amp;hellip; a bit weird?&#xA;The basic idea is fine:&#xA;it&amp;rsquo;s a dictionary but the keys are things you want to count, and the values are the amount of&#xA;the thing you have counted.&#xA;The neat thing is if you initialise a counter with an iterable like a string or a list,&#xA;it&amp;rsquo;ll give you the counts for the number of times each element appears.&#xA;And it gives you convenience methods for finding the most common elements and that sort of thing.&#xA;It&amp;rsquo;s pretty neat and I&amp;rsquo;ve used it a few times.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Subclass Like a Boss</title>
      <link>https://www.scmb.xyz/post/subclass-like-a-boss/</link>
      <pubDate>Fri, 13 Jan 2023 13:49:26 +0000</pubDate>
      <guid>https://www.scmb.xyz/post/subclass-like-a-boss/</guid>
      <description>&lt;p&gt;I had this idea for a project I could do,&#xA;but I thought &amp;ldquo;maybe I should do this other thing first to get to grips with&#xA;the API&amp;rdquo;.&#xA;I was doing something for that project, and got distracted doing a simpler project&#xA;to learn about the technologies and tools involved.&#xA;I got distracted from &lt;em&gt;that&lt;/em&gt; project by some weird behaviour of a class&#xA;in the python standard library (I&amp;rsquo;ll post about that later).&#xA;And I got distracted from &lt;em&gt;that&lt;/em&gt; distraction by trying to find&#xA;convenient ways to explore the code of python objects so as to&#xA;make subclassing them easier.&#xA;And this post is about this distraction to a distraction to a distraction.&#xA;With any luck, I will eventually post about all of these things, but I&amp;rsquo;m not naming&#xA;them in case I never get around to doing them.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Miscellaneous Python Bits</title>
      <link>https://www.scmb.xyz/post/miscellaneous-python-bits/</link>
      <pubDate>Sat, 07 Jan 2023 11:53:25 +0000</pubDate>
      <guid>https://www.scmb.xyz/post/miscellaneous-python-bits/</guid>
      <description>&lt;p&gt;In a &lt;a href=&#34;https://www.scmb.xyz/post/rock-paper-scissors-with-matrices/&#34;&gt;previous post&lt;/a&gt; I said I would come back&#xA;to explain a few somewhat opaque lines in my&#xA;&lt;a href=&#34;https://codeberg.org/scmbradley/AdventOfCode/src/branch/main/2022/aoc-2022-02-matrix.py&#34;&gt;matrix-based solution to Advent of Code 2022, day 2&lt;/a&gt;.&#xA;This is what I&amp;rsquo;m going to do here.&lt;/p&gt;&#xA;&lt;p&gt;There&amp;rsquo;s three smallish things I thought it was worth pointing out.&#xA;None is going to surprise veteran python coders, but they might be of interest to some.&lt;/p&gt;&#xA;&lt;h1 id=&#34;building-matrices&#34;&gt;Building matrices&lt;/h1&gt;&#xA;&lt;p&gt;So the first line I want to look at is:&lt;/p&gt;</description>
    </item>
    <item>
      <title>Rock Paper Scissors With Matrices</title>
      <link>https://www.scmb.xyz/post/rock-paper-scissors-with-matrices/</link>
      <pubDate>Thu, 29 Dec 2022 15:06:59 +0000</pubDate>
      <guid>https://www.scmb.xyz/post/rock-paper-scissors-with-matrices/</guid>
      <description>&lt;p&gt;I had a go at the first couple of weeks of problems from &lt;a href=&#34;https://adventofcode.com/2022&#34;&gt;Advent of Code&lt;/a&gt; this year.&#xA;I&amp;rsquo;ve posted my answers &lt;a href=&#34;https://codeberg.org/scmbradley/AdventOfCode&#34;&gt;over here&lt;/a&gt;.&#xA;I stopped after day 13 because the problems were getting harder but the time I had to devote to them could not increase.&#xA;I hope to come back to them at some point.&lt;/p&gt;&#xA;&lt;p&gt;But today I wanted to point out something interesting about&#xA;the day 2 puzzle.&#xA;Spoilers ahoy for day 2 of Advent of Code 2022.&#xA;This post is mainly an excuse to test MathJaX on the blog.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Riffle Shuffle Efficiency</title>
      <link>https://www.scmb.xyz/post/riffle-shuffle-efficiency/</link>
      <pubDate>Sun, 18 Sep 2022 10:19:58 +0100</pubDate>
      <guid>https://www.scmb.xyz/post/riffle-shuffle-efficiency/</guid>
      <description>&lt;p&gt;Let&amp;rsquo;s say you have a list, and you want to &amp;ldquo;interleave&amp;rdquo; or &amp;ldquo;riffle shuffle&amp;rdquo; the items in it.&#xA;That is, you want to split the list in two, and then make a new list, alternating items from the first and second halves.&#xA;In Python, there are a &lt;a href=&#34;https://stackoverflow.com/q/19898138/219352&#34;&gt;number of ways of doing this&lt;/a&gt;.&#xA;Now we are left with the problem of which of these ways should we actually implement?&#xA;One key factor in making this decision is performance:&#xA;how well do the various methods actually perform.&#xA;I decided to run a little experiment.&lt;/p&gt;</description>
    </item>
    <item>
      <title>DIY Password Manager</title>
      <link>https://www.scmb.xyz/post/diy-password-manager/</link>
      <pubDate>Sun, 14 Aug 2022 00:00:00 +0000</pubDate>
      <guid>https://www.scmb.xyz/post/diy-password-manager/</guid>
      <description>&lt;p&gt;The problem of coming up with a good password is finding something memorable enough&#xA;that you will remember it, but not so obvious that it&amp;rsquo;s guessable.&#xA;A password manager essentially makes sure that your passwords are not guessable,&#xA;but it also makes them impossible for you to remember them,&#xA;so you have to outsource remembering your passwords to&#xA;a database on your computer or in the cloud (i.e. on someone else&amp;rsquo;s computer).&#xA;That&amp;rsquo;s not a great solution for a number of reasons,&#xA;primarily, you can&amp;rsquo;t leave your password manager unsecured,&#xA;so you still need one memorable but hard-to-guess password,&#xA;and that password manager is now a single point of failure.&lt;/p&gt;</description>
    </item>
    <item>
      <title>How Predictable Is Football?</title>
      <link>https://www.scmb.xyz/post/how-predictable-is-football/</link>
      <pubDate>Mon, 18 Apr 2022 10:47:59 +0100</pubDate>
      <guid>https://www.scmb.xyz/post/how-predictable-is-football/</guid>
      <description>&lt;p&gt;A question that has been rattling around my brain for a while now is this:&#xA;how useful is &amp;ldquo;form&amp;rdquo; in predicting the outcome of football matches?&#xA;That is, how useful is it to know that a team&amp;rsquo;s record in their last 5 matches is WWLDD, for example?&#xA;So I thought I&amp;rsquo;d explore this as a way to learn a bit more about Python&amp;rsquo;s statistics and data science libraries.&#xA;The code used to do this analysis and generate these graphs is available&#xA;&lt;a href=&#34;https://github.com/scmbradley/football-stats/releases/tag/v1&#34;&gt;on github&lt;/a&gt;.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Wordle Solvers</title>
      <link>https://www.scmb.xyz/post/wordle-solvers/</link>
      <pubDate>Mon, 31 Jan 2022 15:55:53 +0000</pubDate>
      <guid>https://www.scmb.xyz/post/wordle-solvers/</guid>
      <description>&lt;p&gt;Following on from a &lt;a href=&#34;../wordle-counts/&#34;&gt;previous post&lt;/a&gt;,&#xA;I wanted to explore what effect various kinds of strategies for solving&#xA;Wordle have on how quickly you solve it.&lt;/p&gt;&#xA;&lt;p&gt;So I implemented Wordle in python,&#xA;and then spent a while trying to find a good word list&#xA;to use as a basis.&#xA;Now, I know that you can inspect the Wordle page itself and find the list of&#xA;words it uses for validating real words and the list of wordle answers,&#xA;but I don&amp;rsquo;t want to use that list, so I made my own.&#xA;I&amp;rsquo;ve put the code up at &lt;a href=&#34;https://github.com/scmbradley/wordle-cli&#34;&gt;github&lt;/a&gt;.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Wordle Letter Counts</title>
      <link>https://www.scmb.xyz/post/wordle-counts/</link>
      <pubDate>Wed, 05 Jan 2022 14:32:17 +0000</pubDate>
      <guid>https://www.scmb.xyz/post/wordle-counts/</guid>
      <description>&lt;p&gt;In response to some discussion&#xA;&lt;a href=&#34;https://twitter.com/EtheHerring/status/1478702040008339458&#34;&gt;on twitter&lt;/a&gt;,&#xA;I dug into how common different letters are at different positions in a word.&#xA;Since the discussion was prompted by the popular word game&#xA;&lt;a href=&#34;https://www.powerlanguage.co.uk/wordle/&#34;&gt;Wordle&lt;/a&gt;&#xA;the focus was on five letter words.&lt;/p&gt;&#xA;&lt;p&gt;My approach was to download a word list from the first google hit for&#xA;&lt;code&gt;word list download&lt;/code&gt;, and then throw python&amp;rsquo;s &lt;code&gt;Counter&lt;/code&gt; module at it.&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-python&#34; data-lang=&#34;python&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;from&lt;/span&gt; collections &lt;span style=&#34;color:#f92672&#34;&gt;import&lt;/span&gt; Counter&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#75715e&#34;&gt;# Download a wordlist such as the one available here:&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#75715e&#34;&gt;# https://github.com/dwyl/english-words&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;with&lt;/span&gt; open(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;../resources/words/words_alpha.txt&amp;#34;&lt;/span&gt;) &lt;span style=&#34;color:#66d9ef&#34;&gt;as&lt;/span&gt; d:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    wl &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; [x&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;strip() &lt;span style=&#34;color:#66d9ef&#34;&gt;for&lt;/span&gt; x &lt;span style=&#34;color:#f92672&#34;&gt;in&lt;/span&gt; d&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;readlines()]&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;firsts &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; [x[&lt;span style=&#34;color:#ae81ff&#34;&gt;0&lt;/span&gt;] &lt;span style=&#34;color:#66d9ef&#34;&gt;for&lt;/span&gt; x &lt;span style=&#34;color:#f92672&#34;&gt;in&lt;/span&gt; wl]&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;fives &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; [x &lt;span style=&#34;color:#66d9ef&#34;&gt;for&lt;/span&gt; x &lt;span style=&#34;color:#f92672&#34;&gt;in&lt;/span&gt; wl &lt;span style=&#34;color:#66d9ef&#34;&gt;if&lt;/span&gt; len(x) &lt;span style=&#34;color:#f92672&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;color:#ae81ff&#34;&gt;5&lt;/span&gt;]&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;def&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;top_letters&lt;/span&gt;(ctr, n&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#ae81ff&#34;&gt;10&lt;/span&gt;):&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#66d9ef&#34;&gt;return&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;,&amp;#34;&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;join([x[&lt;span style=&#34;color:#ae81ff&#34;&gt;0&lt;/span&gt;]&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;upper() &lt;span style=&#34;color:#66d9ef&#34;&gt;for&lt;/span&gt; x &lt;span style=&#34;color:#f92672&#34;&gt;in&lt;/span&gt; ctr&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;most_common(n)])&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;print(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;For all words in the list&amp;#34;&lt;/span&gt;)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;print(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;Most common first letters&amp;#34;&lt;/span&gt;)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;print(top_letters(Counter(firsts)))&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;print(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;Most common all positions&amp;#34;&lt;/span&gt;)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;print(top_letters(Counter(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;&amp;#34;&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;join(wl))))&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;print(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;&lt;/span&gt;&lt;span style=&#34;color:#ae81ff&#34;&gt;\n&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;&lt;/span&gt;)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;print(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;For five letter words:&amp;#34;&lt;/span&gt;)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;print(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;Top letters any position&amp;#34;&lt;/span&gt;)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;print(top_letters(Counter(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;&amp;#34;&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;join(fives))))&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;for&lt;/span&gt; i &lt;span style=&#34;color:#f92672&#34;&gt;in&lt;/span&gt; range(&lt;span style=&#34;color:#ae81ff&#34;&gt;5&lt;/span&gt;):&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    print(&lt;span style=&#34;color:#e6db74&#34;&gt;f&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;Top letters in position &lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;{&lt;/span&gt;i&lt;span style=&#34;color:#e6db74&#34;&gt;}&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;&lt;/span&gt;)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    letters &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; [x[i] &lt;span style=&#34;color:#66d9ef&#34;&gt;for&lt;/span&gt; x &lt;span style=&#34;color:#f92672&#34;&gt;in&lt;/span&gt; fives]&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    print(top_letters(Counter(letters)))&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;And here&amp;rsquo;s the result:&lt;/p&gt;</description>
    </item>
    <item>
      <title>Taskwarrior i3blocks</title>
      <link>https://www.scmb.xyz/post/taskw-i3blocks/</link>
      <pubDate>Sun, 25 Apr 2021 00:00:00 +0000</pubDate>
      <guid>https://www.scmb.xyz/post/taskw-i3blocks/</guid>
      <description>&lt;p&gt;Here&amp;rsquo;s a niche little script I wrote.&#xA;Are you in the intersection of the Venn diagram of people&#xA;who use &lt;a href=&#34;https://i3wm.org/&#34;&gt;&lt;code&gt;i3&lt;/code&gt; window manager&lt;/a&gt; (or something similar such as&#xA;&lt;a href=&#34;https://regolith-linux.org/&#34;&gt;&lt;code&gt;regolith&lt;/code&gt;&lt;/a&gt;)&#xA;and people who use the &lt;a href=&#34;https://taskwarrior.org/&#34;&gt;TaskWarrior&lt;/a&gt; to do list app?&#xA;If so, you might be interested in &lt;a href=&#34;https://github.com/scmbradley/taskw-i3blocks&#34;&gt;this script&lt;/a&gt; that puts&#xA;the description of currently active tasks in your i3bar.&lt;/p&gt;&#xA;&lt;p&gt;I&amp;rsquo;ve submitted a pull request to &lt;a href=&#34;https://github.com/vivien/i3blocks-contrib&#34;&gt;i3blocks-contrib&lt;/a&gt;,&#xA;but there are a lot of PRs pending, so I don&amp;rsquo;t know how active the repo is.&#xA;For now, anyway, the script is available on its own repository.&lt;/p&gt;</description>
    </item>
    <item>
      <title>A linker script for keeping configuration files synced</title>
      <link>https://www.scmb.xyz/post/linkerpy/</link>
      <pubDate>Sat, 03 Apr 2021 22:02:15 +0100</pubDate>
      <guid>https://www.scmb.xyz/post/linkerpy/</guid>
      <description>&lt;p&gt;This post is mainly to test hugo&amp;rsquo;s code formatting capacities.&#xA;I have two machines &amp;ndash; a desktop PC and a laptop &amp;ndash;&#xA;that I like to keep in sync.&#xA;I do this by keeping a &lt;code&gt;git&lt;/code&gt; repo of my various configuration files&#xA;called &lt;code&gt;dotfiles&lt;/code&gt;&#xA;which is backed up to a web server.&#xA;Then, I just make symbolic links from all the places&#xA;my programs are looking for their configs to the config files in the repo.&#xA;So I push to that when I make changes, and fetch changes from the server&#xA;when I need to propagate them to the other machine.&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
