I loved this movie, it didn’t start promising but then it developed into something valuable. Continue reading
Author Archives: Smilyan
How to prepare your bicycle for travelling by plane?
Cycling around Iceland – Plan of days and distances
I have read a lot before starting my trip in Iceland, but I struggled to find useful information about a reasonable daily itinerary to go around the island at a reasonable pace.
There are many ways to cycle in Iceland, but yet not as many as in other countries. The roads are few and the good tarmac ones are even less (yet still better from what I read than 5 years ago). The reality is that if you want to cycle around the whole island there are (with few exceptions) only two options. To cycle on road #1 clockwise or counterclockwise. You can extend or shorten the trip by avoiding or adding to your journey the:
- Snaefellsjoekull National Park peninsula
- North-Western fjords
- Coastal line in the North-East (from what I’ve read the roads are poor in the very North-East tip of the island)
Here is my initial plan for going around the island in 18 days. You can shorten the trip by linking the shorter days into single days. I think it will be harder to extend the 18 days to more unless you wild-camp as there is little in between the locations mentioned.
Day | km | Place |
---|---|---|
Day 1 | ~50 | REYKJAVÍK ECO CAMPSITE |
Day 2 | ??? | AKRANES CAMPING SITE |
Day 2 | 112 | BORGARNES CAMPING GROUND |
Day 3 | 78 | Hotel Edda Laugar Saelingsdal |
Day 4 | 128 | Blönduós Camping Grounds, Gladheimar |
Day 5 | 143 | CAMPING SITE HAMRAR |
Day 6 | 93.6 | Husavik Campground |
Day 7 | 54.5 | Bjarg campsite |
Day 8 | 166 | Egilsstaðir Campsite |
Day 9 | 92.3 | BREIÐDALSVÍK CAMPING GROUND |
Day 10 | 64.2 | DJÚPIVOGUR CAMPING GROUND |
Day 11 | 104 | Hofn Camping and Cottages |
Day 12 | ~130 | N/A – Tjaldsvæðið í Svínafelli |
Day 13 | ~75.8 | Camping Site and Cottages Kirkjubær II |
Day 14 | ~102 | Skogafoss |
Day 15 | 110 | Tjaldsvæði Campground |
Day 16 | 111 | SOUTHCENTRAL MOTEL |
Day 17 | 90.1 | GRINDAVÍK CAMPING SITE |
Day 18 | 47.1 | N/A – Keflavik International Airport |
For the sake of presentation I’ve reduced the information in the table, but if you want to see the original table with contact information, notes, etc., please follow the link below.
See the original google spreadsheet
Please note that I didn’t actually follow this plan to the note (as you can see by the posts I’ve been doing on the trip), however it was a very good baseline for me. I am sharing it in the hopes that it will be of use to others as well.
Subscribe to receive the next post in your mailbox
Callbacks VS Promises – Differences – Simple Notes
I thought to discuss simply the differences between callbacks and promises in JavaScript and why promises are becoming so popular.
The classic callback pattern
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
function getDataCallback(apiUrl, callback) { // If the callback is successful // pass the err parameter as "undefined" callback(undefined, {"your": "JSON object"}); // If the callback was unsuccessful // pass the error message callback("No data found"); } getDataCallback('http://your-api.com', function (error, data) { // If err is not undefined if (error) { console.log('There was an error:', error); } else { console.log('It worked', data); } }); |
In the callback you check if there is an error and if not, you process the success. It works and has worked for a while, but there are a few problems with this pattern.
First, you have duplication by having to call the callback function for both a success case and a error case.
Second, you have one function handling multiple cases – the callback has to manually check if there is an error and handle it. Every time you need to manually do that and the code starts to look messy and confusing the more you add.
Third, you can end up (for whatever reason) calling the callback function multiple times for either success or errors. This can cause all sorts of issues.
Promises
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
function getDataPromise(apiUrl) { return new Promise(function (resolve, reject) { // If the callback is successful resolve({"your": "JSON object"}); // If the callback was unsuccessful reject('No data found'); }); } getDataPromise('http://your-api.com').then(function (data) { // Handle successfully returned data console.log('It worked', data); }, function (error) { // Handle errors console.log('There was an error:', error); }); |
You can call each only once and this is a much cleaner way, there are no assumptions (“undefined” means error).
Next, the promise function is called and it has a method available called .then(); The first parameter of .then() always handles the success so you know you will receive whatever you were expecting (in this case our JSON object “data”). The second parameter of .then() handles fails, hence the “error” is passed to receive the respective error.
You could achieve this pattern yourself as well, but promises provide a secure and intuitive way of handling callbacks.
Conclusion
Promises are great as they provide an easy, simple and secure way to handle callbacks in ES6, that is readable and just makes sense. If you want to read more on promises, check this article by Jake Archibald on developers.google.com.
Subscribe to receive the next post in your mailbox
One of the most rewarding things I’ve ever done
Last year I saw an idea that I thought was brilliant and fit well with what I believe in. I decided to apply that idea and today the fruits from it came ripe. I’ve rarely in my life felt more rewarded and glad for a decision. Continue reading
Travelling, currencies, exchange rates and Revolut
I have been travelling enough in the last few years to have realised that currency exchanges are not that easy or user-friendly. You either need to get the currency you need before you arrive in the country – but how do you know how much you will need – or you end up having left-over currency that’s not enough to exchange back. Continue reading
Cycling around Iceland – Part 9
I woke up, got out of bed and went to the showers. It turn out to be a queue for both showers and toilets. Continue reading
Cycling around Iceland – Part 8
It was a beautiful, warm morning. Refreshed after the great day before, the food, the additional rest and Elad’s company I was ready to head to Akureyri. Continue reading
Cycling around Iceland – Part 7
Cycling around Iceland – Part 6
I could hear the raindrops hitting the tent walls. I turned on the other side and hid my face in the sleeping bag. Everything was hurting and the day before drained all my energy. There was no energy left to motivate myself to get out in the rain, pack all the gear and cycle all day through the mountains. Continue reading