The Red Phone

This post is about a kind of project which is closer to what I did back in 2012-2013. Which reminds me that I forgot to celebrate the 10 years anniversary of this blog (I opened it roughly 12 years ago).. Incredible stuff

In any case, the other day I stumpled upon an old rotary phone, a red one, to be precise. I couldn’t help but admire it’s beautiful desig, so I bought it for 35 euros (probably could have found it cheaper, but it was in good condition.

I immediately knew what I wanted to do with this: I wanted to turn it into my house intercom.

I got to work, and disassembled my current intercom first, just to commit to the project. Actually no, but I needed to get a look to the connections to make sure it would work, and after finding out it was probably easy, I dived into the thing – and committed to the project anyways 🙂

I’m not gonna go into too much detail but the current intercom was providing 5 separate lines:

  • shared + signal
  • line for outbound audio
  • line for inbound audio
  • line for buzz
  • line to open the door

On the other end, the phone was using just three lines in input, I didn’t reverse engineer exactly what they were doing, but internally the phone was quite simple and the different components were easily visible:

  • the rotary mechanism
  • the ringing mechanism
  • the receiver connections
  • the switch to cut the connection when the receiver rest in place

I started to hack around some connections, main pain points were:

  • to get the switch to cut out input and output to the receiver, I needed this to avoid the intercom to be active at all times (it would have been broadcasting continuously the audio to and from the outside)
  • try to have the ring work instead of the original buzzer coming on my original intercom (failed)
  • to get the receiver connections right (colors can be misleading)
  • understand how to open the door (there was no opener button on the phone, of course)
very poor quality cabling, and in this case also wrong – the red cable (receiver) connections are all wrong, this was just before I shifted them after realizing the microphone was not working

In the end after a couple of tries I got everything working nicely, using the original buzzer (unfortunately not the beautifully sounding one of the phone) and the rotary mechanism as a button to open the door – exactly, when you turn the rotary selector the door opens. The connection and cable in the next picture is hopefully just temporary while we figure out how to rearrange the rest of the room.. but I love the result

Live test #10 (or more):


Happy 12 years anniversary (more or less) to this blog!

Heroku free plans shut down

Some of my previous projects (fortunately only 2 of them I think) were hosted on heroku and they are not reachable since heroku shut down their free plan. At some point I will move them to my own server, but it will take some time to do so. In the meanwhile, the urls are gonna return an error page – sorry for that.

Mortgage calculator (fixed rate)

Yesterday I made this fixed rate mortgage calculator because I needed a quick way to calculate different options for mortgages for a friend. I found many calculators online but they were either bloated with ads or not providing enough flexibility.

Here is it: mortgage calculator

Screenshot_2023-01-17_11-49-52

As a side note (personal opinion!), I really don’t understand how the typical calculator put emphasis on the monthly payment rather than the total interest money you’re paying in the end. This is very much a disservice for the poorly informed home buyer which looks at a low monthly payments and feels good, when the reality is he’s gonna be paying up to 50% of interest over 30 years of mortgage.. Of course it’s important to be aware of whether you can or cannot afford the mortgage, but in my opinion how much you’re paying for the loaning service is at least equally important. So my tool puts emphasis on how much interest you will pay over the loan lifetime.

Scores!

scores

Scores is a little app I quickly wrote to scrape musical sheets from the internet and to assemble them in a single PDF ready to be downloaded.

Behind the scenes it uses Python-driven Selenium webdrivers to do the scraping and a combination of carefully crafted hacks to make it talk with the frontend. Security was taken into (some) consideration whereas scalability was not – it only handles one request at a time for now.

Intended for (my) personal use only.

Here

 

Estimo App

Just a quick update, some weeks ago I rapidly coded a prototype of this idea of an estimation game, in which you have to guess different facts and the app gives an “accuracy” score. Turned out that the problem of measuring accuracy in guessing is an interesting one and could be solved in many ways. My approach was

score = min(guess,realValue)/max(guess,realValue)

To me this metric is interesting because indicates an “order of magnitude” error, that is if our guess is double or half the actual value, the score is the same.

Of course this formula is only good for positive values, and is not that good if we’re trying to guess bounded values, like if I ask to guess the year of birth of someone: you already have some very clear bounds and you will easily get a score of 95% or so.

The (very basic, only mobile) app is here:

https://estimo-app.herokuapp.com/

I didn’t bother to fix the style for desktop PC – just mobile. Here’s a screenshot:

 

Screenshot_2022-02-22_11-41-39

 

Party Billboard

After moving to NY, we immediately felt the need to organize some parties to meet some new people. Thus, why not designing something to make the party room a bit more “interactive” during the party?

Here’s where the party billboard comes handy: it’s a meme wall easily customizable by everyone at the party:

 

IMG_20220108_202235

 

The top right QR code takes to the customization page in which it’s possible to customize the meme, by entering a text and choosing between a set of default images or specifying a custom publicly reachable URL to an image or GIF.

It was a cool experiment and it was fun to play with at the last party. Can’t wait for the next one!

A live version (with the limitation of 1000 simultaneous parties) is available here.

 

 

 

Virtual Reality (short post)

Some weeks ago I bought an Oculus Quest 2 and beginning experimenting with WebXR technologies. It’s real fun!

Two little projects I’ve put together are these:

1) Painting stuff in 3d: https://greeter.website/pagu-webxr/three/

You can also read the blog post on my company’s blog (in italian): https://blog.dmnk.cloud/index.php/2021/04/01/realta-virtuale-oculus-quest-2/

2) The cubes game: https://app.dmnk.cloud/the-cubes-game/three/

Also here we’ve posted to the company’s blog (still in italian): https://blog.dmnk.cloud/index.php/2021/04/19/the-cubes-game-un-piccolo-gioco-in-realta-virtuale/

JS Genetic Curve Fitter

While I was working on Coronamap.it, in the new section dedicated to analysis, I felt the need to do some curve fitting, that is I had a series of points and I wanted to find a curve which best fit the points, given some constraints. Of course I expected this to be a well known and well solved problem, only to discover that of course yes it is, but it’s actually something not necessarily easy to do. It’s a complex problem which requires to search in a large space of solutions, and as that not an easy task to be done in JS (which I required). Fortunately, I found an implementation in JS which used a genetic algorithm approach, so I decided to rewrite another one from scratch using my old project JSGenetic. If it does not make any sense to you, it’s because it does not have any – except that I love to make this kind of stuff.

So enough for the story, let’s talk about the library:

Example here

Usage:

var cf = GeneticCurveFitter(points, functionGenerator, 3, { //3 is the number parameters you need to tune to find the fitting curve
    RANGES: [
        [1, 2000], //one range for every parameter - if not specified, they fall back to [-1000,1000] which is kind of silly
        [1580000000000, 1590000000000],
        [10000000, 1000000000]
    ]
});
functionGenerator

is a function which gets the generated parameters in input and returns the function which you want to optimize. Easier to explain with an example:

//polynomial functionGenerator
function polyGen(coeffs) {
  return function(x) {
    var result = 0;
    for(var i=0; i<coeffs.length; i++) {
      result += coeffs[i]*Math.pow(x,i);
    }
    return result;
  }
}

//gaussian from the example
var gaussGen = function (coeff) {
    return function (x) {
        return coeff[0] * Math.exp(-((x - coeff[1]) * (x - coeff[1])) / (2 * coeff[2] * coeff[2]));
    }
}

After initializing the object, it can be easily run like this:

var resultFn =   cf.fit();

which returns the best fit function it could find. The process takes some seconds and the time can vary by CPU power and number of coefficients to find. The returned function also has an helper method to generate a chart from it (read: to sample it) which goes like this:

var samples = resultFn.toDataset(startX,endX,numberOfSamples);
//samples is in the form [{x:,y:}, ...]

There are also other methods to better control the evolution of the coefficients: here are the library’s returned methods:

{
        step: step, //make a single step of the genetic algoritm, or N steps if you call cf.step(N)
        fit: fit, //already described before
        getCurrentSolution: getCurrentSolution, //gets current solution
        getCurrentFitness: getCurrentFitness,//gets current error
        getCurrentCoefficients: getCurrentCoefficients //get raw coefficients as an array
}

That’s all! Enjoy.

Update on Coronamap: Coronamap analysis

We added to coronamap the capability of loading custom analysis coded by users in JS.

A list of the analyses can be found here.

Analysis are sorted by points, which you can give by liking them when opened. You can also fork any analysis and modify it as you wish. Everything is in beta, we’re still working on improving the system.

The creation of new analyses can be made from the Coronamap Analysis Editor.