WordPress: only homepage works, permalinks not working

This is annoying. Ported a WordPress installation from a web server to my Mac, but the homepage is the only WordPress page that loads. No permalinks work.

The solution, in my case, and hopefully for others too, was very simple:

mod rewrite was disabled. Whoops.

sudo nano /etc/apache2/httpd.conf

Remove the # from in front of the mod rewrite line. There’s a good chance that’ll be the problem!

Installing Mono on Mac OSX with Homebrew

Whenever I end up wasting my own time trying to get something working, I like to post about it. Simply because, inevitably, I had problems finding blog posts that might’ve helped me. This is one of those occasions.

I’ve been trying to install Mono on Mac OSX (Yosemite) using Homebrew. Homebrew is pretty nifty, generally.

I used brew install mono – everything seemed ok. However, when I tried to run mono from the terminal, the command was not recognised.

I spent a little while googling around, some of the advice suggested adding the path to mono to /etc/paths.

Eventually, it became apparent that running brew doctor might help. It did. It explained mono wasn’t linked properly.

Running brew link mono didn’t work, for permission related reasons. It turns out that Homebrew requires your account to own various folders in order for certain operations to work. Eventually, this did the trick:

chown -R $USER /usr/local

Running that, and then attempting to link mono, did the trick.

TypeScript is really, really good.

I recently abandoned my trusty old Windows 8.1 laptop in favour of a Macbook.

This was for a couple of reasons – firstly, the Windows machine had been degenerating over time to the point where the sound no longer worked, sleep mode caused problems, plugging a charger in would cause the system to hang, and so on. All things that I could’ve dicked around with and potentially resolved, but it was getting old and I saw a good deal for a Macbook online.

Anyway – I’m now using a Mac. Which is weird, as a (primarily) C# developer professionally. Luckily, I do lots of Javascript in my spare time, which has lead me to start playing around with TypeScript and Visual Studio Code – the new IDE that I didn’t know about. Which as it turns out, is also very, very good.

TypeScript: http://www.typescriptlang.org/
VS Code: https://code.visualstudio.com/

Why is TypeScript so good? It’s just very easy to use and the benefits, especially when coupled with a smart IDE like VS Code, are immediate. You get all the compile-time validation benefits of a strongly typed language like C# without them being enforced at every opportunity.

This is a significant efficiency benefit when working on a reasonably large Javascript codebase. As an example, I’m currently writing a game engine in Javascript, which is thousands of lines of code. Porting it to TypeScript, and using type annotations (where they make sense) has significantly increased my productivity and reduced errors.

The workflow change hasn’t been massive either – I simply use the built-in task runner provided by VS Code to compile the TypeScript, and ensure it generates source maps for js > ts in order to be able to debug in-browser.

Using TypeScript in this way eliminates a whole host of mistakes and potential pitfalls that can lead to wasted time and effort.

Debugging the Seed() method – Entity Framework migrations

This one has been fun. I’ve had a couple of issues when attempting to seed the ASP.NET Identity database using Entity Framework Code First migrations.

You would normally run the migrations via the Package Manager Console when developing locally, but this has an unfortunate side-effect – you can’t debug in the normal manner. If you have problems with your Seed method not working, as I have, it makes it rather difficult to figure out. Additionally, Console.WriteLine(), Debug.WriteLine(), Trace.WriteLine() etc don’t output to the Package Manager Console.

The solution? Open another instance of Visual Studio and attach the debugger to the original instance. Sorted.

Azure Blob Storage – connection string issue

More fun with the Azure API, this time with blob storage. Azure blob storage allows you to store large amounts of binary files or data, accessible (in full CRUD fashion) via a REST API along with some provided libraries for various languages, including .NET.

Microsoft provide an Azure storage emulator that runs locally on your development machine, and I had a bit of trouble connecting to it. The particular error I was getting was generated by this line of code:

var storageAccount = CloudStorageAccount.Parse(storageConnectionString);

The error itself was:

"No valid combination of account information found."

It turned out that the connection string for my storage account was formatted incorrectly for local development, despite conflicting things I’d read online – all you need, in fact, is this!

UseDevelopmentStorage=true

Easy!