Mailgun Inline Images with Python

Mailgun’s API is really nice and super-simple to use. However, I was having issues getting it to send inline images in my emails. I think the example in the documentation (here) is wrong. My files were coming through as attachement with a filename of “inline” rather than the actual filename. The actual filename was correctly coming through in the img cid tag but because the attachments had the wrong filename, they weren’t being shown.

My solution, which seems to be working, is to use MultiDict (which can be imported from werkzeug if you’re using Flask) and create the files part of the API call like this where the filename and file object are contained in a tuple:

files=MultiDict([("inline", ("test1.jpg", open("files/test1.jpg"))),
("inline", ("test2.jpg", open("files/test2.jpg")))])

Seems to work!

ECMWF Python urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed

Just posting this for future Googlers:

I was getting this error trying to access ECMWF’s data through their web API. On Mac, I couldn’t make the suggested solution work.

I thought I’d re-install Python to see if that helped but noticed during the install the following text:

Certificate verification and OpenSSL

**NEW** This variant of Python 3.6 now includes its own private copy of OpenSSL 1.0.2. Unlike previous releases, the deprecated Apple-supplied OpenSSL libraries are no longer used. This also means that the trust certificates in system and user keychains managed by the Keychain Access application and the security command line utility are no longer used as defaults by the Python ssl module. For 3.6.0, a sample command script is included in /Applications/Python 3.6 to install a curated bundle of default root certificates from the third-party certifi package ( If you choose to use certifi, you should consider subscribing to the project’s email update service to be notified when the certificate bundle is updated.

The bundled pip included with the Python 3.6 installer has its own default certificate store for verifying download connections.

Clearly Python does something different around certificates now. So I ran the “Install Certificates.command” found in /Applications/Python 3.6 and suddenly everything started working fine.

Wriggle Discounts Super-Lister!

We have a pretty cool start-up here in Bristol called Wriggle whose aim is to help local restaurants fill free tables by offering discounts through the Wriggle mobile app (and now website). The additional advantage for these businesses is that people pay up front so it also avoids the problem of “no-shows”. It’s a bit like Groupon but more local and with less spammy offer for underwear and beauty treatments.

The Wriggle app will show you what deals you can get near you but I wanted to know what the best deal is in terms of the discount itself so I built a quick Angular application – The Wriggle Discounts Super Lister! – that pulls the data from Wriggle’s underlying API and allows me to resort the data by % saving or saving in ┬ús. I can also sort by popularity to see what deals other people are snatching up (mostly Pizzarova at the moment!) or by deals that are running out that I might want to snap up before they’re gone.

Just another random little toy project! Click on the screenshot to check it out. I’m particularly proud of the loading gif…

wriggle discount super lister

What are you actually selling when you sell?

At the core, all successful businesses sell some combination of money, status, power, love, knowledge, protection, pleasure, and excitement. The more clearly you articulate how your product satisfies one or more of these drives, the more attractive your offer will become.

Josh Kaufman absolutely nailed it with the quote above taken from his excellent book The Personal MBA. It’s so important to understand between the lines the needs of your customers and explicitly show them how buying what you’re selling will meet a need or solve a problem in one of these areas.

People don’t buy products, they buy solutions to problems.

That last sentence is so fundamental, I’m gonna let it sit there in a paragraph of its own! Nobody buys anything just for the sake of having it – they’re looking for some sort of physical or metaphysical return on their investment.

For a single product there may be quite different needs/desires to meet between different customers – that’s great – now you know that your pitch needs to be different for each of them! Look at the quintessential salesperson, the used car dealer – to them the same car could be any number of things – “safe and reliable”, “top of the range”, “lovely colour”, “nippy in the corners”, “roomy in the back” – depending on their assessment of who the customer is. It may even be all of the above when selling to mum, dad and the kids!

So work it out, know which of these underlying things your selling when you’re selling and make sure your potential customer knows why your product offers them more in these areas than someone else’s.

Here are a few examples of where different sectors fit into this model. Try to identify which fit with your own business.

Money – financial services, advertising, coupons
Status – fashion, luxury goods
Power – headhunters, political fundraising!
Love – dating, deodorants, cars, gyms, trashy magazines!
Knowledge – consultancy,
Protection – insurance, safety features
Pleasure – games, hobbies, ice cream
Excitement – theme parks, gadgets, dating

Firebase Upgrade News from Google I/O

I haven’t had as much time as I’d like to play with Firebase recently but I was interested to read about the upgrades they announced yesterday at Google I/O.

First off, they’ve re-designed the UI into Google style:


But there’s a whole host of new features too…

Google Cloud Messaging has been re-branded Firebase Cloud Messaging (a vote of confidence in the Firebase brand). It’s free and unlimited and supports messaging on iOS, Android and web apps. They’ve also dropped in Firebase Notifications on top of that.

The new Firebase Analytics platform for iOS and Android draws heavily on Google Analytics and is sure to be a hit with app developers for ease of implementation (looks like you pretty much drop in a reference and it’s up and running) and they’ve made it easy to integrate your app with Google’s 2010 mobile ads acquisition AdMob.

Firebase Remote Config also looks really interesting for app devs, allowing you to change app configuration remotely without an app update and segmented by user groups. Nifty.

They are a few more interesting features too. It’s all in the announcement on the Firebase blog.

This page in the Firebase docs is a useful starting point for working out which features are useful to app developers or web developers.

The {.co} Top Four Books for New Businesses / Start-Ups

I’ve read a lot of books about new business processes and start-ups in the past year or two. Here are four that bring insights every few pages rather than the ones that stretch out a single insight into a whole book (you know who you are!).

The Personal MBA
Josh Kaufman’s “The Personal MBA” is dense with useful information for whichever aspect of business you’re currently concerned with – finances, product development, sales & marketing, all of the above! – it’s all in here with lots of concise single-topic chapters rather than long general groupings making it an ideal reference book to return to as your business develops or fresh problems arrive on your desk.

Do Purpose
I’ve believed for a while now that humans are narrative-driven beings. David Hieatt is a man who knows how to tell a good story. He started his career at Saatchi (advertising is just story-telling!) and went on to create the successful outdoor clothing brand Howies and subsequently luxury jeans brand Hiut Denim. Do Purpose is his condensed manifesto for creating meaningful businesses – businesses that serve their customers and make the world better (and, sure, hopefully make a profit). An easy-read that only takes a couple of hours. One that I turn to when my enthusiasm needs a shot in the arm.

The Lean Startup
One of the reasons I’ve enjoyed playing with Angular is the power it gives you to rapidly take an idea from paper to a working (or semi-working) prototype. Taking and applying the concepts of “Minimum Viable Product”, iterative design, continuous deployment and measuring the impact of your changes on your early customers, this book opened my eyes to a new way of turning around innovation quickly and efficiently.

The Idea in You
A book full of case-studies of people who’ve taken a spark of inspiration and carried it through to a successful business – some small lifestyle businesses, others much larger – as well as plenty of practical exercises and encouragement to help you take your big idea, evaluate its pros and cons and work out how to stop dreaming and start doing.

Bonus book: If those last two sound good to you, it might also be worth checking out Sprint: How to solve big problems and test new ideas in just five days by Jake Knapp who developed this five day process for developing and testing ideas in his work at Google and Google Ventures.

Plotting Historical Parking Data Using Angular and NVD3

I was looking for a good and free charting component I could use in Angular. I’ve played around with some raw D3 in the past but I didn’t want to re-invent the wheel that much. Fortunately I found the NVD3 library which works on top of D3 to simplify common charting tasks line line charts, bar charts, etc and, even better, somebody’s already created an Angular directive on top of that.
…click here to read the rest…

The OpenStreetMap Geocoding API

It’s pretty common that we want to convert between a given address or postcode, a lat/long coordinate or a place name. For example to show the user’s current city or town we’d need to get their lat/long from their browser through the HTML Geolocation API and then we’d need to somehow work out what town or city that corresponds to. Or to search on a map for a certain town or city, we need to convert that into coordinates that we can use to set our map centre.
…click here to read the rest…