The title is a reference to “Cooking for Engineers”, originally a blog post which spun off into a whole site . It re-imagines recipes as flowchart-like diagrams. The writer of the original blog post jokes that actual engineers would probably hate the approach due to how imprecise it is - using estimated measurements, and timings based on senses (what it looks like, smells like, etc). Well allow me…
Champion In a previous post , I used a simulation to predict how long it would take to complete the Champion of the Sinnoh Region secret mission. It said that I should expect to open around 250 booster packs. I have now completed that mission! And I finally have the Garchomp emblem I was after So how long did it actually take? On my 253rd booster (1265 pack points), I finally pulled the one-star…
15 years ago, I was unemployed. I’d dropped out of university the year before and my job prospects weren’t looking good. I was spending a lot of time on Twitter (presently X). And I noticed some patterns, the ways different users behaved. And I wrote a blog post about it . Some years earlier, when I was in secondary school, I created my first blog on MSN Spaces. It was called “Philosophical…
When Pokemon first took the world by storm, I was 8 years old. Which is to say, I was the perfect age for it. And I was WAY into it. Nearly 30 years later, and something of it is still deeply ingrained in my psyche. So when Pokemon TCG Pocket was released, I was an easy mark. Secret Mission Garchomp is my favourite Pokemon, so when the second expansion — Space Time Smackdown — was release with a…
I woke up from a dream with a question in my head – can we generate any probability with a coin and a six-sided dice? Let’s focus on the dice - what probabilities can we generate with a dice roll? 1 in 6 is easy, if you roll a 1 you win for 1 in 2, if the result is even – 2 , 4 , or 6 – you win for 1 in 3, if the result is divisible by three – 3 or 6 – you win 1 in 4 is less obvious, but since 1/4…
I signed up for Letterboxd . trakt One of the first options, on creating a letterboxd account, is importing data from other services - one of them being trakt . I don’t use trakt directly. For many years, I’ve been using SeriesGuide to keep track of TV shows. I used this in combination with trakt because I could then use the trakt api to get a list of new episodes ‘today’ for completely legal…
I shaved my head. My hair’s been getting thinner for a while now, so I thought I’d try going all in. I’m still getting used to it. But one thing I did expect, was that my head would feel colder now. So I needed a hat. I looked over my save crochet patterns and found this one - Widcombe C2C crochet hat It uses a crochet technique called ‘corner-to-corner’ (c2c) - effectively the fabric is made up…
A while ago, I found a pattern for a tunisian crochet scarf that I kinda liked. The design was straightforward - just three solid blocks; I picked 1 blue, 1 grey, 1 cream. I got maybe 20 rows into it, then got bored. I ended up frogging it. But now I have these three balls of super-soft aran yarn, and what to do with them? I wondered if I could make the pattern more interesting by cycling - blue,…
A temperature blanket is a crochet or knitting project where one makes a blanket over the course of a year, doing a piece a day with the colours based on each day’s temperature. For the full background and design of my blanket, see the previous blog post God laughs When we last left our temperature blanket, it was the end of July, and I said we haven’t made it into the oranges/reds […] it would be…
Advent of Code 2022 was a bit of a miss for me. After getting all the stars in 2021 , I didn’t have quite the same drive, and gave up after day 10. Besides which, I had something more compelling to do - making crochet Christmas ornaments . I wasn’t sure I’d bother at all this year. I was trying to think if there was a way to spice it up - doing it in python is dull, I write python almost every…
Background A temperature blanket is a sort of physical infographic. It’s a year-long knitting or crochet project. You do a piece of the blanket every day, with the colour based on that day’s temperature (weather). Within that basic concept, there’s a lot of room for variation — squares or stripes, different stitch patterns etc. In my case, I chose crochet squares. Research To get a sense of the…
Background At a high level, what we have is a Django-based server, with celery for running tasks. A user submits a workflow, which is translated into a ‘canvas’ of tasks. The tasks are run in a celery worker, often on a different node to the server, and with no access to the server database. As tasks are running, they may post ‘in progress’ updates to the celery result backend. To pull those…
Spring cleaning Around this time of year, I get an urge to clean out my room, get rid of junk, old books and DVDs. One thing I did this year was to throw out all the boxes from wardrobe: the boxes for old technologies — laptops, phones — some things I don’t even own anymore. Anyway. In clearing out my wardrobe, I rediscovered my Pokemon cards. Well, more accurately, I always knew where they were.…
Here is a solution to day 1 (both parts) in 52 characters of AWK { a += ( $ 0 > x ); b += ( $ 0 > z ); z = y ; y = x ; x = $ 0 } END { print a - 1 , b - 3 } Okay, this is going to take some unpacking… Background This is my 4th year doing Advent of Code . For the last couple of years, I used rust, but this year… I dunno, maybe the novelty’s worn off. Last year, I did a few of the early puzzles as…
What I wanted to talk about today is my approach to designing a piece of software, by looking at three projects I’ve worked on 1 But before we get to the example, lets lay out the approach find the ‘core concept’ that is, when you strip it down to the most basic level, ignoring the implementation details, the edge cases, the error handling or whatever, what is the basic mechanism by which…
SQLite This is a pattern I’ve used a couple of times now. Basically I needed to store some key-value type data — like a dict in python — but it needed to be persistent, so that if the program is stopped and restarted, the data is retrievable. In particular, I wanted something light-weight and with no extra dependencies. I’m not dealing with a lot of data, so redis would be overkill. SQLite is…
A wild PR appeared! The problem went like this - you’ve given a string specifying a (unix) user. It can have one of three formats username/uid username uid The string needs to be parsed into a (valid) user id (uid) so that it can be applied ( chown ) to a file. The implementation in the PR was along these lines (simplified for clarity) if ‘/’ in line, split and check that the second part is a…
This is a direct follow on to the Modularity Madness blog. I actually drafted it shortly after writing that post, but for whatever reason never got around to finishing it at the time. Further to my previous post, I wanted to talk a bit more about how the DownloadFn is used, and why it’s defined as a stand-alone function. The basic idea is we have something generating file ‘events’, and these…
Or, the not-so-fast Fourier transform, and what we take for granted in Python. The Project This started with my university 3rd year project. It involved signal processing - taking data from a mass spectrometer and finding the peaks. The peaks correspond to different compounds in whatever is being analysed. Finding peaks is pretty easy, just look for the points where the gradient of the data goes…
The Motivation Since I learned rust, I always want to use it more. But outside of Advent of Code , I usually don’t have an excuse. A few months ago I came across an article about fungus spore simulation (or something). They’d used this simulation to create these cool pictures, and it sparked my interest. It reminded me of the sort of stuff I used to do on this blog. So I had a crack at…
Are you ten years ago Ten years ago, I did a pair of blogs called Life by Numbers , and Life by Numbers: End of Year Review , in which I reviewed a load of stats that I had collected (or that had been collected) about myself. Aggregating data has gotten somewhat easier since 10 years ago, since now I’m getting end-of-year emails from various websites. So, lets review… Music (via Spotify/ Last.fm )…
As expected, as the puzzles get harder, it’s not so easy to solve them with one-liners. So unlike week 1, I don’t have one-liners for every day. If you haven’t read it already, you can find week 1 here . I may refer back to things discussed in that post. Day 10 By this point, you’ve seen all these tricks before print (( lambda x : x [ 1 ] * x [ 3 ])( reduce ( lambda a , x : ( x , a [ 1 ] + ( x - a…
This is my third year doing Advent of Code . As with last year, I’m primarily solving the puzzles with rust. But in this first week, there were a couple of puzzle where I could think of python one-liner solutions. And then I wanted to try and come up with one-liners for the other days. This lead to me using some dirty tricks, which I want to share with you, dear reader. You can see all my…
When people ask how I got into programming, I usually tell them “mostly for maths stuff”. And they look at me, kind of confused. I think people forget (or don’t know) that my degree was in Theoretical Physics. Originally, I was a maths nerd, and programming was just a tool for making doing maths easier. Pythagoras Back in secondary school (high school), we’d just been taught about Pythagoras’s…
The other day a coworker asked me to look at a python script he’d written - make sure there weren’t any major issues ( “little ones are ok” - his words). One thing that immediately jumped out at me was how it was handling exit-on-error print >> sys . stderr , "Something went wrong. Exiting..." sys . exit ( 1 ) Aside from the very retro print >> syntax, compare with this typical bash snippet echo…
As mentioned in an earlier blog, I’ve recently been working on a new project at work. It’s not often one gets to write something wholly from scratch. In this case, I had just read the revised edition of The Pragmatic Programmer , so I had all sorts of ideas in my head about design and best practices. So let’s talk about modularity. Interfaces The task at hand is downloading a file. I defined the…
A little while back, I decided to rewrite an old python tools of mine in rust. This tool uses torrent api , an public api for searching torrents. Now, the torrent api has an aggressive rate limit - it won’t allow more than 1 request every 2 seconds. This means we have to actively limit our requests. The basic workaround goes like this: track when the last request was made when a new request is…
Or, how I learned to stop worrying and love the type annotations. Listen, I didn’t plan on making a whole ‘writing X like Y’ series. But here we are. I’ve recently been working on a new project at work - my first project in pure Python 3. Meaning, I get to play with all the new toys! And as I was writing this code, it struck me that was borrowing a lot of tricks from Rust (and a little Go). Types…
In the previous post , I talked about implementing python-like logging in bash. In that post, I said that it’s generally a bad idea to write code in one language as if it were another. But for bash, I’m willing to make an exception. As I mentioned before, I’m no bash expert. I generally try to avoid it. But there are times when bash really is “the right tool for the job”. So in this post, I’m…
One of the great sins in programming is trying to write code in one language like code from another language. Having said that, I’m a shell scripting newbie. So when I had cause to write some bash, I found myself reaching for some python ‘home comforts’. Okay, so what I actually did wasn’t so bad function log () { echo "log: $@ " > &2 } I think this is a fairly common approach to ‘logging’ in…
qs = lambda l : l and qs ([ x for x in l [: 1 ] if x <= l [ 0 ]]) + [ l [ 0 ]] + qs ([ x for x in l [: 1 ] if x > l [ 0 ]]) Quick Sort This is based off an implementation I saw in haskell, it went something like qsort :: ( Ord a ) => [ a ] -> [ a ] qsort [] = [] qsort ( x : xs ) = qsort [ a | a <- xs , a <= x ] ++ [ x ] ++ qsort [ a | a <- xs , a > x ] Before I explain what’s going on, it might…
YouTube channel, College Humor , has a game show series called ' Um, Actually ' - a game of nerdy corrections, and general nerd trivia. One of the 'shiny questions' involves putting things is order, for example, putting space ships or fictional creatures in order by size. The way the scoring works (as far as I can tell) is you get one point for each item you put in the right 'position'. So if you…
Background At work, we've been working on a Python API for IBM's Spectrum Scale (GPFS) filesystem. The API is well tested, with good coverage. But one thing that's caught us out a couple of times is unicode. For those not familiar, Python 2.7 has both byte strings and unicode strings. In most cases, the two are interchangeable. But there are some quirks, which can lead to bugs if not handled…
Time was when I needed a hair cut, I'd go at noon on a weekday, when the barber's is typically empty. One of the perks of being unemployed. But these days I have to get my haircuts on Saturdays, before noon. Which is bad enough in itself - ideally I'd never see Saturday mornings at all. And to make matters worse, Saturday morning is also when the barbers is at its busiest. Hence, I found myself…
A few months ago, my friend was telling me about this mobile game he wanted to make. He, and some of our other friends, are teachers, and this is a game they play with their students. The students apparently love it. And if there were an app version, they'd be willing to pay 59p for it. Or so they say. Now, as he was explaining the game to me, I thought maybe he was building towards asking for my…
In a previous pair of blogs , I designed some clock widgets for Android, using Zooper . At the end, I said that if I ever got a smart watch I'd remake them for Android Wear . Well, here I am following up on that promise. I've also thrown in a few new designs for good measure. Now, these are mostly concept watch faces - which is to say, they're more 'look at this cool thing you can do', than the…
Let's suppose, for the sake of arguing, that I'm unemployed. It'd pretty great if there were a way I could make a quick buck (or a quick quid, in my case). Obviously, the solution is to make a super addictive mobile game. Then I can just sit back and watch the cash come pouring in. Okay, so that's a pretty terrible plan - making a mobile app of any kind is no trivial thing, and there's no…
In the last blog I talked about making a binary clock widget (for Android) using Zooper , and I made a claim about how individual binary digits can be extracted from a decimal number - what follows is an explanation/proof of why it works. The Claim The n-th digit of the binary representation of a number, x, is a zero if \(x \bmod 2^{n+1} \lt 2^{n}\), or a one otherwise. Proof To start, we express…
A long while back I wrote a couple of blogs about clocks. In the first I talked about decimalising time. Half a year later, I wrote another where I designed a couple of circular binary clocks. I thought I'd try to recreate those clocks for my phone. I had a widget making app - Zooper - installed on my phone, that I'd played with before. I build myself an autumnal homescreen, that looked like this.…
I was watching this year's RI Christmas Lectures , and it reminded me of this game I had when I was much younger. It was, I think, a Christmas present from my grandparents, back in '96. It was called Lights Out , and it looked something like this . Basically, the console had a 5x5 grid of these rubbery, transluscent buttons with little red lights underneath them. When you press a button, that…
If you're a long time follower of this blog you'll probably have noticed I haven't posted much in the last two/three years. This is because I've been busy with university stuff. This blog is sort of related to that. The following section is an edited version of the background I wrote for my final year project report (hence why it's so formal). Enjoy. Background - Dark Matter and DM-ICE According…
I know this blog is a little late to the game. In fact, I started writing it while it was still relevant... but then I got distracted. Such is life. Background You probably already know (or vaguely remember) what the Ice Bucket Challenge is. Basically if you're nominated you have to dump a bucket of ice water over your head, or else you have to donate money to some charity - most commonly ALSA ,…
File this under things I think about when I'm trying to get to sleep. The Question The idea is this - pick a random integer between 0 and 9. If it's prime, stop. If it's not prime, pick another random integer and stick it on the end of the first number. If this new number is prime, stop. If it isn't prime, pick another random integer, and so on. So, for example: 1 -> not prime 2 -> 12 -> not prime…
So it's been about a year since I last blogged. I've been kinda busy with university stuff, and growing my facial hair into something approaching a beard. I might write a blog about it at some point. Anyway, I've got a little free time now - at least until after Christmas - so here we are. Let's waste some time... "This is a real paper, published in a proper journal" So the other day, my dad hands…
The other week I was waiting for my tram, reading Metro, and I see this article - Treegonometry: Formula for perfect Christmas tree discovered In other word, a set of equations that will tell you, for example, how much tinsel, or how many baubles are 'required' for the 'perfect' Christmas tree. Here is the press release, with the actual formulas. Now, I have a few issues with this. For one thing,…
When I'm at university, I have to get the tram twice a day. Now I quite like the trams in Sheffield (at least, more than the trains and buses). But if there's anything I can do to get a little more leg room or personal space, then I'm going to try it. On the way in to university, I get on the tram at the start of the line - i.e. the tram is more or less empty when I get on, so I have pretty much…
There are several ways to divide a burger evenly between three people. Probably the best is to cut it radially (like a pizza). It can be tricky working out exactly where to make the cuts, but if you can pull it off, then all the pieces will be roughly identical (topping distribution notwithstanding). But for the sake of arguing, lets say you want to divide the burger by making two parallel cuts:…
So recently I'd gotten really into this TV show - it's called ' Life ', and it's a 'murder of the week' crime drama starring Damian Lewis. Lewis plays Detective Crews, who was previously in prison for a muder he didn't commit, and he's into zen and such. It's a bit silly. But in an endearing sort of way. Unfortunately, the only way I could watch it (short of buying the DVDs) is to stay up til 4am.…
So I was reading this response to a Daily Mail opinion piece about those 'gay cure' bus adverts, and I see this quote (from the Mail article) “ Since only about one percent of us are [gay], homosexuality is obviously a departure from the norm... Reversing that proportion would spell the end of the human race, which is clearly undesirable. ” There are several things wrong with this statement - some…
I did some stuff like this before. And I figured, while I was updating my network graphs , why not update some of the other graphics? And it helps that I worked out how to easily extract data from Twitter (see previous blog ). The code is here . Again, rate limits apply. Who Do I Follow? This is one of the ones I did before - collect together the bios of the people I follow, then make a word cloud…