a blog about research communication & higher education & open culture & technology & making & librarianship & stuff

New Years's irresolution

Photo by Andrew Hughes on Unsplash I’ve chosen not to make any specific resolutions this year; I’ve found that they just don’t work for me. Like many people, all I get is a sense of guilt when I inevitably fail to live up to the expectations I set myself at the start of the year. However, I have set a couple of what I’m referring to as “themes” for the year: touchstones that I’ll aim to refer to when setting priorities or just feeling a bit overwhelmed or lacking in direction.

Read more...

Build documents from code and data with Saga

!!! tldr “TL;DR” I’ve made Saga, a thing for compiling documents by combining code and data with templates. What is it? Saga is a very simple command-line tool that reads in one or more data files, runs one or more scripts, then passes the results into a template to produce a final output document. It enables you to maintain a clean separation between data, logic and presentation and produce data-based documents that can easily be updated.

Read more...

Why try Rust for scientific computing?

When you’re writing analysis code, Python (or R, or JavaScript, or …) is usually the right choice. These high-level languages are set up to make you as productive as possible, and common tasks like array manipulation have been well optimised. However, sometimes you just can’t get enough speed and need to turn to a lower-level compiled language. Often that will be C, C++ or Fortran, but I thought I’d do a short post on why I think you should consider Rust.

Read more...

Reflections on #aoc2017

Trees reflected in a lake Joshua Reddekopp on Unsplash It seems like ages ago, but way back in November I committed to completing Advent of Code. I managed it all, and it was fun! All of my code is available on GitHub if you’re interested in seeing what I did, and I managed to get out a blog post for every one with a bit more commentary, which you can see in the series list above.

Read more...

Series: Advent of Code 2017

The Halting Problem — Python — #adventofcode Day 25

Today’s challenge, takes us back to a bit of computing history: a good old-fashioned Turing Machine. → Full code on GitHub !!! commentary Today’s challenge was a nice bit of nostalgia, taking me back to my university days learning about the theory of computing. Turing Machines are a classic bit of computing theory, and are provably able to compute any value that is possible to compute: a value is computable if and only if a Turing Machine can be written that computes it (though in practice anything non-trivial is mind-bendingly hard to write as a TM).

Read more...

Series: Advent of Code 2017

Electromagnetic Moat — Rust — #adventofcode Day 24

Today’s challenge, the penultimate, requires us to build a bridge capable of reaching across to the CPU, our final destination. → Full code on GitHub !!! commentary We have a finite number of components that fit together in a restricted way from which to build a bridge, and we have to work out both the strongest and the longest bridge we can build. The most obvious way to do this is to recursively build every possible bridge and select the best, but that’s an O(n!

Read more...

Series: Advent of Code 2017

Coprocessor Conflagration — Haskell — #adventofcode Day 23

Today’s challenge requires us to understand why a coprocessor is working so hard to perform an apparently simple calculation. → Full code on GitHub !!! commentary Today’s problem is based on an assembly-like language very similar to day 18, so I went back and adapted my code from that, which works well for the first part. I’ve also incorporated some advice from /r/haskell, and cleaned up all warnings shown by the -Wall compiler flag and the hlint tool.

Read more...

Series: Advent of Code 2017

Sporifica Virus — Rust — #adventofcode Day 22

Today’s challenge has us helping to clean up (or spread, I can’t really tell) an infection of the “sporifica” virus. → Full code on GitHub !!! commentary I thought I’d have another play with Rust, as its Haskell-like features resonate with me at the moment. I struggled quite a lot with the Rust concepts of ownership and borrowing, and this is a cleaned-up version of the code based on some good advice from the folks on /r/rust.

Read more...

Series: Advent of Code 2017

Fractal Art — Python — #adventofcode Day 21

Today’s challenge asks us to assist an artist building fractal patterns from a rulebook. → Full code on GitHub !!! commentary Another fairly straightforward algorithm: the really tricky part was breaking the pattern up into chunks and rejoining it again. I could probably have done that more efficiently, and would have needed to if I had to go for a few more iterations and the grid grows with every iteration and gets big fast.

Read more...

Series: Advent of Code 2017

Particle Swarm — Python — #adventofcode Day 20

Today’s challenge finds us simulating the movements of particles in space. → Full code on GitHub !!! commentary Back to Python for this one, another relatively straightforward simulation, although it’s easier to calculate the answer to part 1 than to simulate. import fileinput as fi import numpy as np import re First we parse the input into 3 2D arrays: using numpy enables us to do efficient arithmetic across the whole set of particles in one go.

Read more...

Series: Advent of Code 2017