Monday, 11 September 2017

Playing with Google Cloud Services

Late last night I wanted to build a simple but humorous website (the details of which shall remain veiled from you). The website simply needed to serve up a random image, i, (from a collection of N) and then serve a title that I had associated with said i. That is, show an image and a caption.

Being an engineer, I knew I simply must over-engineer this simple challenge. I also wanted to use it as an opportunity to learn a little about the Google Cloud Services products (Google's answer to Amazon Web Services).

I spent some time perusing the vast litany of products that Google Cloud Services provides; from storage, to compute, to SQL to container hosting to VM hosting; it's all there. I didn't see anything missing (yet).

My initial design looked something like the following (artwork courtesy of yours truly).
My Website 1.0
The general idea was that I would have some sort of Google Cloud Function that would house the business logic of my project. It would simply get a random number in a given range and then request an image with that number from Google Cloud Storage and return its url. I would house the captions in a database (in this initial design I chose Spanner since that seemed hip and cool and in the news but then I realised it was expensive so opted for postgres later). This initial design was missing where the html would actually be served from as we will find out later.

Google Cloud Storage was the most impressive thing so far. It was really easy to setup and get used to; it was easy to understand and striaghtforward to use.

I realised fairly quickly that Google Cloud Function was not appropriate for what I was doing. What I should be using was Google App Engine (known as GAE). This thing was built literally for hosting websites (mine was not static). I followed the initial hello world tutorial and realised it only needed a tiny bit of tweaking for me to use it for my website.
After about 2 hours I was serving some simple HTML from GAE (using a Go application) that would simply generate a random number in a given range and then serve the image with that name from my GCS. Simple.

Now I wanted to serve the captions for these images. Initially you could see that I wanted to put them in a database (Postgres because I don't like MySql). Postgres is still in beta on Google Cloud Services. Getting Postgres in a usable state was tremendously hard. I was able to create the tables through an interactive prompt launched from the GAE website but it was very difficult to get my GAE connected to the same instance - I spent 1 hour jerking around with certificates and keys to only get hangs. I could at some point connect interactively with psql from my GAE prompt but not reliably - not sure what was going on. There are tutorials on GAE for connecting to postgres from Java and Python (which seems to need a proxy!?) but nothing for Go (yet). So I was kinda stuck up a creek without a paddle.

So I just mashed the captions into the code and put out version 0.1.

The end design looking something like this:

The diagram is actually pretty inaccurate since the go code doesn't actually talk to GCS but it just generates the URL and the browser downloads it.

The whole process was pretty cool all in all. I was able to get up and running without spending a penny (1 year of $300 for free when you sign up woo) and jump around the different products easily. The integration between the Postgres/GAE stuff was terrible. It was really hard to work out how to get the auth setup. I also didn't take enough time to setup the interactive tools locally - my internet was spotty - and using the web based tmux console was very painful and slow. But it was fun to bash something out from my browser that hit GCS and used Go without having to download a megalith of tools that I would never look at again.

ICV?

Saturday, 25 March 2017

Chat Apps

This xkcd really struck a chord with me. Current chat apps on my phone are:

  • Slack
  • Allo
  • Hangout
  • Whatsapp
  • Facebook Messenger
  • SMS
Spoilt for choice...

Sunday, 15 January 2017

Magic List of Things to Consider if you're going Cycling?


  • Bike
  • Lock
  • Jersey
  • Shorts
  • Sunglasses
  • Helmet
  • Garmin
  • Garmin Cable
  • Water bottle
  • Inner tube
  • Puncture repair kit
  • pump
  • shoes
  • Multi tool
  • Spanner

Saturday, 29 October 2016

Why I am excited about the new macbook

I am not normally a super mac fanboy; it's true that I am typing this on a Macbook pro now but I did't buy it myself - it was provided for me. But I still love it and definitely would buy it as my next laptop.

Apple just released their latest line in the Macbook Pro series and I think it's really cool. Whenever you mention it your nearest (most likely, vim using) colleague will poo-poo it and complain that it has lost the escape key. However, in its place is something much more exciting. I really like the idea of the customizable screen at the top.

In the past most keyboards were fairly standard. There was the 99% of keyboards that were your standard qwerty (maybe with a few extra buttons for power or volume or media control) as well as was the gamer keyboards that used to have loads of custom buttons everywhere but no one ever took the time to properly hook those up to all their apps and doing so was tedious and error prone. Now applications will be able to provide great hardware shortcuts for all those common tasks using the screen at the top of the keyboard. It has been made accessible for the everyman.

Have you ever watched someone at an airline check in desk? Or watched someone use a trading terminal? They don't really look at the keyboard, they mash out keystrokes and shortcuts like it's an extension of their body. They don't interact with the computer as much as work with the computer. They work together to get the job done. This is how I see the button bar will be great for the Macbook. It will become second nature to zip through Photoshop or Chrome using that button bar along the top. You won't need to remember every changing or inconsistent keyboard combinations (RIP the backspace key in Chrome) but instead you'll naturally reach for the virtual key in the Macbook screen. You will work better with your Macbook and get every day tasks done that much faster. Maybe you'll have all your favourite internet shortcuts up there within a fingers reach, or maybe you'll be able to whizz through your photo albums after vacation without lifting your fingers for the mouse or keyboard. I know from my job that these special keys become second nature after a few goes of using them as they simply make everything faster and more natural.

I'm sure there will be some interesting apps that come out around everyday tasks that will become that little bit less mundane or tedious.

Having said all that, are we still in an age where the Caps lock key is still a thing? Really?

Do you collaborate or cooperate?

Some thought provoking reading on whether your organisation is working together in a collaborative mode or a cooperative mode. Never really thought about it like that before.

Tuesday, 16 August 2016

Why would you not differentiate member variables?

Another post from the llvm mailing list, this time on the topic of member variable naming conventions.

I remember hacking away on some llvm code and having a terrible time with this. It can also lead into dangerous ambiguities when you use local variables that actually hide member variables. The whole naming convention they use is insane. I wonder if they use any static analysis tools?

Can we just autofill city and state? Please!

Coming from a country that is not the US where zip/postal codes are hyper specific, it always drives me nuts when you are filling in a form ...