An afternoon wasted and an exercise in partition frustration

…or “What to do if you lose Mac OS after resizing your Windows Bootcamp partition”

TLDR; Scroll to the bottom of the post where I outline the steps I took to make my Mac partition bootable again without any data loss.

I was meant to spend this afternoon completing an assignment for my course due Thursday. Instead, I nearly lost all of my programming projects dating back to when I began to take programming seriously at age twelve. This is your typical “always have and check backups story”; something I thought I was immune to – until now, at least.

It began when I decided I needed to expand my Mac’s Windows 10 Bootcamp partition. I thought this would be an easy task; I’d shrink my APFS partition from Mac OS, as Disk Utility would be the beast utility to accomplish that task, and then expand my Windows partition from Windows, as I don’t trust Mac OS to expand NTFS. Shrinking the APFS partition went swimmingly, it took about 15 minutes and apart from Disk Utility freezing, seemed to complete without a hitch.

The next step was to expand my Bootcamp NTFS partition to fill the unallocated space on the SSD. I decided to undertake this task in Windows, rather than booting a Linux live USB. The first tool I tried was the built-in Windows Disk Management, however it quickly became apparent that it cannot resize a currently mounted partition, like the Windows C: drive. So off to the internet I went, in search of a partitioning tool that could somehow accomplish this task. I landed on EaseUS Partition Master, it was a program I had heard of before and it seemed to be fairly reputable. It advertised itself as a safe way to manage partitions. This turned out, in my case, to be false.

Continue reading “An afternoon wasted and an exercise in partition frustration”

Introducing PTData–easily obtain Victorian public transport data in a tabular format

Update 29/5/21: I currently no longer work on PTData and have taken it offline. Let me know if you would find some use in it!

Today marks the public release of my newest project, PTData. PTData makes obtaining data from the PTV API easy by displaying it in a tabular format, linking the data together via clickable links, and making all of it available for download as CSV. PTData can currently request lists of routes, lists of stops, lists of departures and a service’s stopping pattern, with more features planned for the future.

My initial intention for this project was to make it easier to import bus timetable data into Excel. Copy/paste just wasn’t formatting into the cells correctly for me, so that led to me entering in the times manually. This quickly became a tedious and frustrating process, which was what initially spurred me to start the project. Almost exactly two weeks later, and here we are.

The site sports quite a simple design as it currently stands, and that for the most part has been intentional. In ways I’m nostalgic for the bare-bones web design trends of the early 2000s, but at the same time it serves the practical purpose of being information-dense. In regards to the technology powering the site, I’ve kept it quite simple as to help with getting the site off the ground as quick as possible. The site itself is written in Ruby, utilising the Sinatra web framework and Dylan Shaw’s ruby-ptv-api gem. As for why I chose Ruby and Sinatra, it’s pretty much what I’m most comfortable with for developing web applications of this nature. I can see myself changing languages and frameworks going forward should the need arise.

There is currently no dedicated database storing the information from PTV permanently, although I do have the rendered pages being cached by nginx and then later Cloudflare to ease load on the API. I do plan to integrate a database eventually, and this would open a whole world of opportunities in regards to working with the data. On a surface level, it would allow for the rendering of a traditional ‘timetable’ view, but going further it would make possible some interesting analysis. Average delay per route, how time of day affects the network, etc.

The site’s code is open-source over at, and I do welcome any issue reports, ideas, or pull requests. The codebase is very rudimentary as it currently stands, however I do quickly see it becoming a rather complex project with numerous backend services performing different tasks.

By now you’re probably wondering what I’m going to use it for. For a long time I’ve wanted to perform an analysis on the bus timetables and connections in the Latrobe Valley. From experience I’ve found the inter-modal and inter-route connections to be quite poor, but with this tool I can now state with exact numbers just how bad it actually is. Stay tuned for a future blog post…

Working with composite primary keys and Entity Framework Core scaffolded controllers

A recent uni assignment has required me to implement an ASP.NET Core REST API using EntityFrameworkCore on a pre-existing database. Whilst EF Core tends to generate controllers for models with single primary keys just fine, I’ve found that it has no support for composite primary keys. This requires you to alter your controller classes to add the support manually, which in my case involved the following;

  • Alter the paths of the individual Get, Put, and Delete endpoints to contain two (or more, depending on how many keys are in your composite) parameters, and then alter the method parameters to match. This requires careful consideration as there are many different ways you can structure the parameters in your route.
  • Alter every usage of _context.nameOfModelHere.FindAsync to contain all components of your primary key. Look at the model’s Entity definition in your database context class, specifically the usage of entity.HasKey, to determine the order in which to list the components in your key to FindAsync.
  • Alter the nameOfModelHereExists method to take the correct amount of parameters for your key. Adjust the body of the method accordingly to check all parts of the key; I just added && at the end of the existing equality expression, and added more equality expressions.
    • Alter all usages of nameOfModelHereExists appropriately.
  • In the Put method, alter the second if statement to check all the components of your primary key, rather than just id.
  • In the Post method, adjust the CreatedAtAction call in the return statement to contain all the components of your primary key.
  • I would also recommend updating all the auto-generated comments that EntityFramework put in to keep things consistent.
Continue reading “Working with composite primary keys and Entity Framework Core scaffolded controllers”