Where’s the Alexandra Palace farmer’s market?
…and how can Firebase help you find it?
The North London’s most famous farmer’s market takes place every Sunday from 10 am to 3 pm near the Alexandra Palace.
Locals come here for fruit and vegetables, meat and sausages, cakes and biscuits, and, of course, handmade pies. There’s also a large selection of street food, including vegan Indian food, Chinese dumplings, British beef burgers and even Spanish tortillas. My favourite, though, is the Moroccan chicken wrap.
Because it takes place in the park surrounding the Alexandra Palace, the vibe is very relaxed and it’s full of local people. My wife and I love to go every Sunday with our dog, Nova, for a late lunch, do some groceries and say hi to our neighbours.
Such a big and famous market should be easy to find, you may say
Well, not really.
The problem is that it doesn’t always take place in the park surrounding the Alexandra Palace. Every now and then there’s a weekend event at the Palace and the market needs to be moved to an alternative location nearby Campsbourne School.
My place sits exactly between the park and the school, which means every Sunday, as I step out of the door with Nova’s lead in one hand, I remember I need to double check if the market has been moved or not.
So I pop up my phone to perform this simple task.
❌ Fail 1: Google “Farmers Market”
You first Google “Farmers Market” with the hope it would show you the nearest ones. And that’s correct: the first result is a map with the Alexandra Palace Farmer’s Market pinpoint on it 🎉
But the sad news is the map always shows the official location: the park’s entrance. If there’s an event happening that weekend and the market has been moved to the nearby School, the search result is wrong.
What do you do when you can’t rely on Google search results?
❌ Fail 2: First search result for “Farmers Market”
Eventually, I accepted the Google’s map result card is not reliable, so I just ignore it and directly scroll down to the first result for my “Farmers Market” search which, at the moment of writing this, is the London Farmer’s Market official website. That sounds promising.
Upon entering the website it asks you for your postcode to do a second search itself. Then it shows ALL the farmer’s markets close to your location but in this list it’s impossible to find the Alexandra Palace Farmer’s Market. My guess is the Alexandra Palace Farmer’s Market is not a member of this group of farmer markets.
So yep, this website is also useless.
❌ Fail 3: Google the whole thing: “Alexandra Palace Farmer’s Market”
At this point one may change the search term to a more specific “Alexandra Palace Farmer’s Market”, but that won’t help either.
The first search result, which looks like the market’s official website, gives you all the information about the market except for its location. — 😢
I can go on describing my search process but you get the idea.
🤔 Success (kind of)
In the end, it’s only when you open the third or fourth result when you find a mobile unfriendly website that really tells you where the market is.
Now it’s only a matter of zooming into the tiny text and scroll left and right to know where you need to go. Ez!
I’ve been through this process over the last months. At some point, you get used to it. You know you need to avoid the first results, scroll down and select the second or third one, wait for it to load and there you go.
But this weekend I thought: I wish technology could work for me, anticipating my needs, providing me with the information I need precisely when I need it.
What I need is something that let me know every Sunday at 9 am where the Alexandra Palace Farmer’s Market is.
✅ Success: build your own tool!
So I built an app that shows a notification in my phone every Sunday with the Farmer’s Market location
The app consists of two parts:
- A Firebase Cloud Function that scraps the website, extracts the info I need and sends it over using a push notification.
- A very simple Android client with a push notifications receiver and an Activity.
⚒ Scraping with Firebase Cloud Functions
Apart from the Firebase dependencies, I’m using Cheerio do the scraping and request-promise to make HTTP requests with promise support
What the function does is:
- HTTP request to that third website containing the real location of the market
- Extract the information (contained inside a
<strong>
tag) - Build a message payload with it
- Send the message with Firebase messaging
📱 The Android client
There’s no mystery here. The Android side of the equation is very simple: a FirebaseMessagingService plus an Activity to show cached data.
Here’s my current implementation of the service. The Firebase Messaging documentation is actually very exhaustive and a good starting point to implement yours.
🕘 Get notified every Sunday at 9 am
This is the most interesting part of the whole thing and yet the easiest to achieve.
The previous two parts by themselves were useless for my case. I wanted the app to come to me with the information I need when I need it. I didn’t want to actively request data. I want the data to come to me magically when I’m about to make use of it. And in this case, that’s every Sunday at 9 am.
I receive a notification in my phone every time this function is triggered, so what I needed was something to trigger the function every Sunday morning. A cron job.
In this video, Jen Person explains how to implement simple cron jobs for Firebase Cloud Functions. The video is now deprecated because there’s a better way to do the job she needed, but the third party tool to run cron jobs is still valid.
This tool is https://cron-job.org
Cron-job is a free service that lets you schedule cron jobs in a very flexible way. My job is a simple HTTP call to a cloud function and it gets executed every Sunday at 9 am. The HTTP call runs the function and I end up receiving a push notification with the data I need precisely when I need it.
Final thoughts
We all get used to repetitive tasks very easily. It can be something as trivial as checking where your favourite Sunday Farmer’s Market is or more complex tasks like scheduling annual review meetings in your company.
We find ways to do them without too much effort and accept our fate. We tell ourselves it’s only a ten minutes painful thing to do every now and then, no big deal. Not worth the effort of automating them for sure.
But repetitive tasks are risky and prone to errors. If your team has a list of “10 simple steps to make a release” then you’re just sitting on a time bomb.
Manual repetitive tasks are a risk because people get used to them and stop thinking about what they’re doing. So by automating your most tedious processes you won’t be only gaining time and mental freedom to do something else, you’ll also be investing in stability and safety.
There are many tools out there to help you with automation, like https://zapier.com
Or you can build your own because where’s the fun otherwise?