GIS: The math to convert from EPSG:3857 to WGS-84

During my latest project, I was given a shapefile and I was told to make a web GIS interface to handle it. I found a Node.js plugin to open the file and load the GeoJSON data onto a Google Map, but then I noticed something was odd: the coordinates were very big numbers, definitely not longitude/latitude pairs.

After installing a GIS software and a lot of googling I found out about the existence of many standards for coordinate values.

(more…)

Emulate Thread.sleep() in JavaScript

When you’re writing code in JavaScript and you need your function to wait some time, you usually use setTimeout(callback, millis). The problem with this function is that only the callback will be delayed, while the code next to it will run normally. How do you actually stop the execution of the application for a certain amount of time, like Java’s Thread.sleep() does?

You can do that thanks to ES8.

(more…)

Web push notifications with Node.js, Angular and Express

I’m currently working on the development of a very basic PWA. During the first day I’ve managed to correctly implement the code to handle geolocalization and access to the camera. After that, it was time to take a look at push notifications. I’ve started reading about them and mocked some quick code to test. It was then that I realized the process will not be as easy as I hoped.

But after three long and painful days I’ve finally managed to make them work.

(more…)

Kotlin doesn’t have a ternary operator

Every developer, one day or another, came across a situation where a variable should get a value or another based on a simple condition. In most programming languages you are able to write something like variable = (condition) ? <then> : <else>, in which if condition is true then variable takes the value of <then>, else it takes the value of <else>. Pretty straightforward.

In Kotlin, you can’t.

(more…)

Implementing RSA Cryptography in Kotlin

I needed to implement RSA-2048 cryptography into the Android application I’m currently writing. After a lot of trial and error, I’ve finally came up with a working solution, which I’m going to share here.

The application is a messaging service, so everything here will be applied to strings.
I’m going to split the code and remove some parts to make it easier to read and explain.

(more…)

Let’s jump on the train

It’s February 2018. I’ve finally decided I wanted my own blog. I want my personal space, where I can write anything that crosses my mind.

This will be a place where anything can be written. I will be the only author. I don’t know if anyone will ever read these pages. I don’t even know if I’ll publish anything besides this introductory post.

But I’ll give it a go. Maybe I’ll like it. You can never say.