NaBloPoMo #19

Eros, for all his qualities, never learned to tidy up after himself. The love-drunk youth often misses, and leaves his arrows littered all around. And for the most part you’d never notice unless you walk barefoot where lovers trod; and even then you barely raise an eyebrow as a sliver of the heavenly weapon penetrates the skin.

Oh no, it’s not until very much later that you realise. Perhaps when your knee touches your friend’s as you chat over coffee for the hundredth time since you met them, or they graze the back of your hand reaching across for a pen, or they throw their head back and do that absurd laugh at one of your stupid jokes and you suddenly freeze as that sliver of an arrow slips into your heart and you say,

“Oh shit”

And a choir of bloody angels descends on you singing Hallelujah.

My point in this is to say that sometimes there are blooms in winter and that when you walk with your sole vulnerable to the earth you may, in time, delight in what entered in

November is National Blog Posting Month, or NaBloPoMo. I’ll be endeavouring to write one blog post per day in the month of November 2019 – some short and sweet, others long and boring.

NaBloPoMo #16

I’m going to do a quick review of a piece of code with 12 commits. It implements a fairly basic example of the Game of Life. Reading the rules of that game will be helpful if you haven’t read them yet.

In this blog, I’m going to try to guess what each commit does. Tomorrow we’ll compare and learn a valuable lesson about writing good commit messages.

Continue reading

NaBloPoMo #15

Day + 1 of a diagnosis of Asperger’s Syndrome, which also happens to be Day 0 of my new role.

Oh, also: weeknotes! Let us slip into the familiar format, the way you do with your skin when you wake unencumbered on a Saturday morning.

Five things that happened this week

1I got a diagnosis of Asperger’s Syndrome and wrote about my immediate reaction. I didn’t write about the outpouring of love and support I’ve received from everyone I’ve told, but it was there, and I’m grateful to all of you. I got the diagnosis on Thursday morning and it – well, it didn’t feel strange at all. It didn’t feel different, and I didn’t feel worried. This is apparently symptomatic, and I need to reflect on how much of my personality to this point has been performative. How much of it is the friendly flesh-wrapper around something that’s human-esque but not quite there. At the same time, mind you, this may be a drastic over-reaction. The pendulum of human emotion makes big swings, and while it’s right to re-examine one’s life in the light of the knowledge that one has always been a little different, it is also true to say that not everything was false. We cannot avoid the re-examination, but I’m leaving this here as a reminder to be generous with myself. Like everyone else I’ve constructed a shell from cast-off words and my parents’ cloth and the things I thought I should say. I am going through the process of peeling those sections back to see what they covered up, and whether I should prefer to expose that part of myself, and in so doing carry less weight. At least thanks to my diagnosis I, unlike many, know what to expect in certain places.

2I abandoned my team. I left without saying goodbye. It felt strange to say goodbye, since I was moving no more than twenty metres, and yet I feel sure that I should have done so. Goodbyes are hard. Well. Early goodbyes are hard. Final goodbyes are easy. A bridge you leave standing is a temptation to return to the past; an ambiguity to be despised. A bridge that you’ve set alight will illuminate your way forward.

3I got really quite stuck on a technical challenge that I haven’t managed to figure out yet. I’ve also noticed already how much I miss coding, so if you’re reading this and wondering if some kind of technical solution might be a way of meeting a need then let me know. A good way of working out if you have unmet user needs is looking at your spreadsheets. If you need loads to manage all your data, then you might need me to code something for you. Please get in contact. I need to write something for a computer.

4I received mail! A letter from a friend who’d sat down and thought about me and written loads of words. It is the nicest thing in the world. I know us weeknoters say this a lot, but letter are absolutely lovely. Actually, now I reflect on it, is there a correlation there? That we’re naturally people who like writing and also like receiving considered pieces of writing from other people? Or is it that the desire for letters is universal, and it only appears that weeknoters are more eager for letters because we express that desire in public? Answers, please, in the format of epistles. And to my dear friend, I am writing your response, and I am grateful beyond words for your thoughtfulness.

5I started with a new therapist. Together we are going to explore the peculiar pathways of my brain. I am seeing this therapist on the advice of a dear friend whose opinion I trust without question. I wish I could have come to the conclusion by myself, but then it’s quite nice to let friends help you every once in a while. Besides, my brain is the thing that means I earn enough money to allow me to – let me check my email – yes, continue to not move into my new flat. I am a recent convert, and like all recent converts something of a zealot. Do, if you can, hire the services of a therapist. It is astonishingly powerful, if you can find one you can get along with. Mine has a dog companion called Eddie who is remarkably skilled in knowing the precise point at which the comforting weight of a canine skull is exactly the thing a fellow needs. Dogs are almost as good as therapists. The both together are a surely a winner.

Other writing this week:

November is National Blog Posting Month, or NaBloPoMo. I’ll be endeavouring to write one blog post per day in the month of November 2019 – some short and sweet, others long and boring.

NaBloPoMo #13

A first draft recursive function to solve a problem I found on codewars. I am happy with the recursion, but I’m finding that it struggles when the initial row is up to 100,000 characters long. I think that means there’s a secret to working this out – or, at least, a more efficient way than just brute-forcing it. Comments welcome!

Problem Description

A coloured triangle is created from a row of colours, each of which is red, green or blue. Successive rows, each containing one fewer colour than the last, are generated by considering the two touching colours in the previous row. If these colours are identical, the same colour is used in the new row. If they are different, the missing colour is used in the new row. This is continued until the final row, with only a single colour, is generated.

My code

class Triangle:
    def __init__(self):
        self.colours = {'R', 'G', 'B'}

    def triangle(self, row):
        if len(row) == 1:
            return row[0]
            new_row = []
            for i in range(len(row) - 1):
                parent_colours = set(row[i:i + 2])
            return self.triangle(new_row)

    def child_colour(self, parent_colours: set) -> str:
        if len(parent_colours) == 1:
            return parent_colours.pop()
            return self.colours.difference(parent_colours).pop()

So: this class has two methods, triangle and child_colour. triangle calls itself until it reaches its exit condition. The exit condition comes when we’ve only got one letter in row – that is to say, we’re down to the bottom level of the triangle.

If we’re not at that point yet, the method works out what the next row would be and passes it to a new instance of the same method.

Before very long, it’s triangles all the way down – until at last one reaches the exit condition. At this point I imagine all the methods snapping back together in exactly the way Terry Pratchett described the Cabinet of Curiosity. A cabinet where the first shelf contains another shelf that shoots off at a right angle, and that shelf branches another, and another, and another – until the answer is found. Then the first shelf draws back, and then the second, and then the third which somehow passes through the sixth and ninth because human brains can’t even see the eighth colour of the rainbow.

And then, at last, in the only drawer in the cabinet, is the answer you were looking for.

Look, he does it much better than I do. This is really just a recommendation to read Making Money. Ignore the code entirely.

November is National Blog Posting Month, or NaBloPoMo. I’ll be endeavouring to write one blog post per day in the month of November 2019 – some short and sweet, others long and boring.

NaBloPoMo #12

I was hoping to build a library. I’m going to write about how far I got, where the barrier is, and what I plan to do next. This follows from the introduction to Munkres I wrote earlier this month.

The algorithm requires manipulation of the elements in a grid as well as it’s rows and columns. I’m going to start this series by explaining how I tried to make the rows and column manipulable[mfn]completely guessed at that, genuinely amazed it’s a real word[/mfn] by extending the pandas class Series.

This is probably going to be moderately technical. I’m going to be walking through the code so there’s no need to go and look for it, but if you’d like to you can find it on Github.

import pandas as pd

class PandasMunkresAccessor:
    def __init__(self, pandas_obj):
        self._obj = pandas_obj
        self.covered = False

    def cover(self):
        Marks all elements in this series as 'covered' and also itself
        self.covered = True

    def uncover(self):
        Marks all elements in this series as uncovered and also itself
        self.covered = False

This is the first class I’m using. It uses a decorator, which is a sort of magic thing we have in Python. I’m going to avoid explaining decorators for the moment[mfn]because I don’t fully understand them myself yet[/mfn] and just say that this is a way of extending an existing class in Pandas – the Series class. It adds two methods and an attribute that I can access through Series.munkres – you can see where the “munkres” part comes from in the second line of code.

The way I’ve modified it is by adding an attribute, covered. There are also quasi “setter” and “getter” methods – one that covers all the objects in the Series and itself, and one that does the reverse.

I’ve added this because part of the algorithm involves covering rows and columns in a grid, and I thought this would be the simplest way to implement that in code. I am not yet sure whether I’m right, so I’m writing tests to check my understanding of how a Series is actually initialised.

(This is by far the best thing about writing code: if you don’t know how a thing works, you can construct a test to check. Most things in life aren’t like that.)

You’ll notice that when the extended Series.cover method is called, it calls another method – .apply. This is a method in the base Series class, and it allows you to apply a function to every element in the series. In this case, I’m applying a method from the MunkresElement class, which is just as well because all the items in the Series are MunkresElements. We know this because when we initialised the object in which we find the Series, we fill it with MunkresElements.

November is National Blog Posting Month, or NaBloPoMo. I’ll be endeavouring to write one blog post per day in the month of November 2019 – some short and sweet, others long and boring.

NaBloPoMo #11

We are more than a third of the way through the month and I’m starting to hit the first barrier. This is a very tiring exercise.

Here’s one I’ve been ruminating on since last weekend.

Excel workbooks are where you should look for your next internal product.

The most effective strategy you can have for building internal, and possibly external tools, is running a workshop for your colleagues to improve their Excel skills. Ask them to bring their problems. Welcome them.

You will find that one team is running a thousand-person development programme with spreadsheets that reference each other in ways that will make your head spin. You will discover convergent evolution in the form of ten different, but functional, versioning systems. You will find out that there is a hole in a firewall because someone once wrote some VBA that needed database access, and you will need a quiet moment by yourself as you question your life choices.

But if you reframe these as opportunities – as low-hanging fruit where business processes can be smarted up, made more streamlined, and more repeatable – then you will have a user-centered roadmap of the internal tools you should be building.

I believe wholeheartedly that spreadsheets, where there is autonomy and power to change fields and do powerful calculations on the fly, are the bleeding edge evidence of what your organisation needs. A tiny example – if your organisation is using 14 spreadsheets to keep track of its room bookings, then you have identified a user need that could be met by the market but instead is being met internally with a custom product.

If you poke that long enough, by the way, the question becomes “Why do people feel they need to meet this user need through a massive, custom-built spreadsheet, the upkeep of which has become 25% of someone’s job, when there’s a bunch of products out there that can meet this need?” and that’s a different but equally important question.

Now, since spreadsheets are highly decentralised in terms of power – the person using them can add columns and remove them – they are quite different from your next step, which is an MVP database-backed service. So the second thing I’d counsel here is that your MVP absolutely must have a way of giving back a slice of the data in a CSV, so that it can be put back in Excel. If you insist instead that the new product will do everything, you’ll get low uptake (because it won’t if it’s an MVP) or you’re angling for a three-year million pound contract and that’s not an MVP, that’s your retirement fund. Stop it.

Your new product will need to almost be a micro service, a little slice where data goes in – possibly even in CSV format – and comes out again, and somewhere else some processing happens. Maybe emails get sent. Maybe some complicated calculation happens.

Or maybe a form that used to be emailed out to everyone in Excel that could instead be offered as a web interface. Basically, carve out a tiny slice of the user’s journey and replace it with something they’ll prefer to use.

In mapping parlance, you’re taking an element of a value chain and moving it to a product space. The more you do this, the more value you’ll be able to move up the value chain – value here being your colleagues’ time.

Of course with the extra time they’ll make more spreadsheets, but then that’s sort of the point of the bleeding edge. It’s always moving.

“Well, in our country,” said Alice, still panting a little, “you’d generally get to somewhere else—if you ran very fast for a long time, as we’ve been doing.”

“A slow sort of country!” said the Queen. “Now, here, you see, it takes all the running you can do, to keep in the same place. If you want to get somewhere else, you must run at least twice as fast as that!”

Lewis Carroll, Through the Looking-Glass

November is National Blog Posting Month, or NaBloPoMo. I’ll be endeavouring to write one blog post per day in the month of November 2019 – some short and sweet, others long and boring.