Rob Lockyer Blog and Portfolio

Rust: 2, Rob: 0

I’m starting to play around with some Rust programming in my spare time. I’m enjoying it so far, but these two things were tripping me up for a while. Lets say you have an API call which returns you an immutable vector. The API call is from a REST API; the results are paginated. So every time you call this function you end up with another vector. In many cases you just want to append these all together and operate on the whole dataset once you have the full collection. In most languages you might create an empty vector before starting your loop and then append the resulting vector on each iteration of the loop. C++ makes this a bit complicated, since insert requires three iterators:

#include <vector>
#include <iostream>

struct Person{
    int age;

int main() {
    std::vector<Person> all_people{ {34}, {35}, {36} };

    // I know this is kind of a dumb example, this closure's kind of pointless in this simple case
    auto append_people = [&all_people](const std::vector<Person>& some_people){
        all_people.insert(std::end(all_people), std::begin(some_people), std::end(some_people));

    const std::vector<Person> other_people{ {37}, {38}, {39} };

    for(auto &person : all_people) {
        std::cout << "Age:" << person.age << std::endl;

I’m used to C++; stuff like this doesn’t bother me anymore, even though I’ve seen better APIs in the standard libraries of other languages. It took me a lot of searching and experimenting before I realized how to even get this to compile in Rust! There were two things I was missing.

use std::vec;

pub fn main() {
    struct Person{
        age : i32,

    let mut all_people : Vec<Person> = vec![Person{age: 34}, Person{age: 35}, Person{age: 36}];
    // I know this is kind of a dumb example, this closure's kind of pointless in this simple case
    let mut append_people = |some_people : Vec<Person>| {

    let other_people : Vec<Person> = vec![Person{age: 37}, Person{age: 38}, Person{age: 39}];

    for person in all_people {
        eprintln!("Age: {} ", person.age);

In Rust if your closure implicitly pulls a variable like all_people into its scope and modifies it, then it seems like your closure must be marked as mutable. Here’s what you get when you neglect to do this.

15 |     append_people(other_people);
   |     ^^^^^^^^^^^^^ cannot borrow as mutable

This isn’t terribly surprising, but I didn’t come across anything mentioning this in the Rust Book. Here’s the other thing that was tripping me up. I was trying to use .append(), but that only works with mutable values. Here’s what you get in that case:

11 |         all_people.append(some_people);
   |                           ^^^^^^^^^^^
   |                           |
   |                           expected `&mut Vec<Person>`, found struct `Vec`
   |                           help: consider mutably borrowing here: `&mut some_people`

The API I was calling does not return a mutable value, so I had to use .extend() instead.

In most ways this is simpler and less verbose than the C++ implementation, you just have to get used to interpreting the errors the Rust compiler is throwing at you. In the end you get some very nice guarantees that seem well worth the hassle.

Unity Workshop

Ran an introduction to Unity3D tutorial earlier tonight at MUN. Thanks to Mike of GameDev NL for organizing, and to MUN CS society for their assistance and providing the space!

Cube Quest

  • Stream available here
  • Content available here

Danube Bicycle Trip

Back in May we went on a bicycle trip along the austrian section of the Danube river. We planned the entire trip ourselves instead of going through a tour group. Friends have asked me so many quesions about it I figured I’d share our expeiences here in case anyone else out there is trying to plan a similar excursion, or is just interested in the details.

To prepare for our trip we packed everything into MEI Voyageur Packs. these bags are the maximum size that can be used as carry on everywhere. I’d seen them reviewed on when we got the panniers for our bikes we were able to take the metal support rods out and pack the bags and all into the panniners. We used the rolling method to fit everything, I had a small amount of space left over, in retrospect I would have taken more biking clothes and less regular wear. The area is so popular with bicyclists that you really don’t look out of place in most resturants in your gear, and it’s tricky to air dry things when you’re on the move almost every day. I brought a small baggy of detergent powder with me to wash clothes in the sink, we were somewhat concerned it might be mistaken for cocaine but that wasn’t an issue, your milage may vary!

The view from Veste Oberhaus

We flew into Munich, then got a bus to the train station. There was a public transit desk in the airport we bought tickets from. We missed our first train but the tickets seemed to be for a time window rather than a specific train so we just waited for the next one. We took that train to Passau and stayed at the IBB Hotel for two nights. We enjoyed exploring Veste Oberhaus, a huge castle on a cliff overlooking the river. We didn’t have enough time to do the whole thing, that castle’s been there a long time so there’s a lot of history to get caught up on. We walked up the stairs to it, quite a climb in the heat! We were able to walk everywhere we wanted in Passau from our Hotel.

Here’s an overview of everywhere we bicycled from then on. This isn’t a GPS track so we actually did diverge from this route significantly at times, but at least it shows where we stayed, and what side of the river we were on at any given time. We didn’t have a GPS or cell phone service so I used to download offline maps, I also exported the map above as KML and imported it into so I could see our intended route. We found the signage very good, and whenever the signs and this route disagreed we found trusting the signs to be more reliable.

Picking up the bikes

After those two nights we rented our bikes panniers, helmets, and locks from Fahrradklink Passau. For $556.76 CAD total. Would have been cheaper if we had paid cash. We then rode to Inzll. Before getting to Inzell we stopped for lunch in Obernzell, you had to ride right through a street with a bunch of restaurants. we usually stopped somewhere vaguely halfway and had a beer and some lunch at a restaurant that was basically on the bike path.

View from our room in Inzell

Inzell is a tiny little community of maybe five houses, and you have to take a small bike ferry across the river to get there. I think there’s only one place to stay but it’s a nice cabin on the river with a campground, so you could tent here if you like. I think we had three large beer each, supper, breakfast, and our room for a total $203.92CAD. We only stayed in Inzell for that night. Like I said, it’s fairly small, naturally beautiful, but not much to do there, unless you’re looking for some solitude, and relaxation. From there we biked to Linz. On the way we stopped in Aschach for lunch.

Town Square in Linz

We stayed in Linz two nights in an air bnb. It was just outside the downtown area of Linz, a neat little bachelor apartment. We ate at Royal Bombay Palace just around the coner, fantastic Indian food. There was a bike rack just outside the apartment that you could see from the window, I was somewhat worried about leaving the bikes out there overnight, you could easily bring them into the apartment if you felt like it since it’s on the ground level. Linz is one of the bigger cities along the way so there’s lots to see. The Ars Electronica was really cool, you can get a 3D body scan for free which was entertaining.

The next leg of our trip from Linz to Grein was our longest ride. We also were committed to visiting the concentration camp Mauthausen along the way. It’s at the top of a huge hill, the steepest climb of our whole trip. I think it’s free to get in, and the audio guides were only a couple of dollars. It was worth the climb to experience this. There’s also a cafeteria here we ate in, you could probably ride down into town for lunch, but we were hungry, and emotionally exhausted after the tour. Test your bikes breaks before heading back down the hill, you’re going to need them!

In Grein we stayed here. It’s up a pretty steep hill so there may be better alternatives in retrospect, but it was fairly close to all the restaurants and was very inexpensive. It’s an old couples house they rent rooms in, they don’t speak a word of english, but they seemed very sweet, we still jokingly refer to them as Nan and Pop.

We didn’t get to really explore Grein at all, we left immediately the next morning taking the bike ferry across the river and then rode on to Melk. We made it into Melk with just barely enough time to check into the hotel and run up a ton of stairs to the Melk Abby. Really glad we didn’t miss that tour because it was pretty amazing. We stayed at Hotel Stadt Melk right next to the Abby, the hotel had a bike shed out back to securely store the bikes. The Abby Dominates your view as you bike into Melk, so its not something you’re going to miss! Above you can see a map showing the Abby, our Hotel and the stairs we had to run up.

The Vineyards of Wachau Valley

The next day we headed into Krems. Now you’re in the Wachau Valley. An area dominated by vinyards, most well known for their Rieslings. On our way we stopped at Restaurant Heinzle for lunch, I tried catfish for the first time, we both really enjoyed our meals here. I think one of our biggest regrets here is the hotel we booked in Krems, it was cheap, and all we really needed, but we shouldn’t have sacrificed on location. We should have stayed much closer to the older area of Krems where it would have been more fun to walk around and explore. You pass through this area on your way into Krems, so we got to see it, but wandering around on foot there would have been nice. You can also visit Aggstein Castle on your way to Krems, but we skipped it since the climb was about 300 meters, makes a good argument for using an electric bike, or just being much more fit than we are.

The Vineyards of Wachau Valley

We then left Krems and went into Tulln. We stopped at Bärndorf Hut along the way and had some great Goulash, they make it different there. It’s basically like a spicy beef stew. This place was super busy, popular with bicyclists. It’s built next to a power plant which replaced a nearby nuclear plant that was finished, but never entered service.

We stayed at Hotel Nibelungenhof in Tulln. I think it was our most expensive hotel, but its location was good. In Tulln we checked out the gardens and went and wandered around the old cobblestone streets, and got some ice cream here. The next day we headed into Klosterneuburg to drop off our bikes. The place we dropped our bikes off at looks like a nice hotel and we considered staying there but decided to take the train directly into Vienna instead.

We stayed three nights in Vienna at Harry’s Home Wien. It was a great location because it was directly on a public transport hub, and inside a large mall as well. The fast food Indian restaurant in the mall (Chutney Indian Food) was awesome too. The major thing we seen here was the Schönbrunn Palace this is a whole day excursion, of course there’s a tour of the palace to do, but the gardens there are enormous, and contain the oldest zoo in the world, as well as several other attractions. We could have done more in Vienna, but we used this as an opportunity to finally relax on our vacation! I also think it would have been cool to have our bikes in Vienna, it’s an extremely bike friendly city. However, there’s no shortage of public transportation so you’ll be fine here either way.

The whole trip was about $3200 per person, or $200 per day. Those numbers aren’t super accurate but I think I captured most of our expenses. Note that this also includes two days we spent visiting our friends in England. I won’t detail that here, since you could be flying in from anywhere, and you may not have awesome friends in England.

We used this book to help plan the trip, this guy also has an interesting blog about his experiences that helped with our planning.

This is the most popular bicycle route in all of Europe, so there are a lot of companies that book whole tours for you, they might even be cheaper than doing it yourself. We noticed that many of the tours were bringing their own packed lunches around which is a good way to make the trip cheaper, but we found half the fun was stopping at random restaurants and having a beer and lunch.

Hope this helps someone out there planning their own trip, I’d love to hear from you!

Automatic Slack Notifications from Windows

I often execute long running scripts on my development machine and want to get notified when their done, even when I’m not in the room. I’d prefer to do this without installing anything extra, because nobody hates software more than software developers. I’m already running Slack, so one practical way to do this is by exploiting Slack’s Incoming Webhooks. Unfortunately, all Slack’s examples for web hooks use cURL and I’m developing on Windows 10. There are solutions for getting cURL on Windows, but I’d prefer something that works on a fresh install. This is where Powershell’s Invoke-RestMethod comes in.

First, lets set up the Incoming Webhooks integration in slack. Log into the web app, and click on your team’s name in the top left corner. Select Team settings from the dropdown.

In the menu on the left select Configure Apps. In the Apps Directory search bar at the top search for Incoming Webhooks.
Then hit Add Configuration.
In the dropdown select a default channel you’d like your automated posts to go to, don’t worry, you can change this programmatically in the future. Next hit the big green button: Add Incoming Webhooks integration
The next page you get has documentation and some settings you can adjust. Most of the settings here are just defaults which can be overridden by your scripts. The only thing we’re interested in at the moment is the Webhook URL. Copy it to your clipboard.
Go to the search bar in Windows 10 by hitting the Windows key and typing Powershell ISE to open the integrated powershell editor. Hit File > New to create your new script. Fill it with the following, but make sure you relplace the -Uri argument with your own Webhook URL

$payload = @{
	text = 'Hello World'
$json = $payload | ConvertTo-Json
Invoke-RestMethod -Uri -Method POST -Body $json

In PowerShell ISE hit the green Run Script button to test your script out, you should get ok as a return value, and you should see your message in Slack. Make sure you check the right channel!

You can do a lot more interesting stuff with this once you get the basics working, such as sending different notifications when builds fail or succeed. This script can be called on the command line with your Webhook URL and a bool to indicate success or failure:

param (

$message = 'Build Failed'
$emoji = ':rage:'

	$message = 'Build Succeeded'
	$emoji = ':nerd_face:'

$payload = @{

$json = $payload | ConvertTo-Json
$response = Invoke-RestMethod -Uri $uri -Method POST -Body $json

You can invoke it from plain old windows shell like so:

powershell -command .\buildStatus.ps1 0

I’d love to hear about the awesome things you automate after trying this out!


A Procedural Planet Generator

Progeny was the capstone project of my engineering degree at Memorial University. It was a group project where I worked with Chad Levesque, Shawn Josey, and Andrew Carter. Each group worked with a project advisor from a relevant industry. Source Studio proposed the concept for our project as “a library for procedural generation of 3D art assets for games”. We focused on creating large-scale planetary bodies; we felt it would offer a great demonstration of the strengths of procedural techniques. A big thanks to Source Studio for use of their game engine, as well as the expert advise of Alex Brown. Above is a video demonstrating the project in action.

We also did presentations. Our team came second in that competition, loosing out to what was admittedly a pretty sweet robotics project.

Cataclysmic Cosmos

Orbital Tower Defence Game

This is a computer game Andrew Carter and I developed for our software design course at Memorial University. We developed the game in Java, so it should run on most machines; though we tested it primarily in windows. I’ve included the game, and some of the documentation we produced so you can get an idea for how we developed it.