14. December 2015

node.js concurrency evaluation

I have been using node.js for a decent amount of time now and I had this hypothesis which I needed to validate 

For a node.js server running on multi core system, if I flood the server with n concurrent requests, to compute something expensive, it would handle the traffic better if the computation can be chunked in such a way that the server can compute those n computations, concurrently.

more

26. April 2015

Chaining async tasks

Method chaining is a pretty common pattern in object oriented programming. JQuery does an amazing job at it but its all about sychronous tasks. Then there are promises, they have the then method which helps in chaining async requests but its not customizable and also quite verbose. So I created my own project ~ Chaining Tatum (No pun intended with the versatile actor Channing Tatum, big fan!)

19. April 2015

Setting up MOSH on Koding.io

Using a remote server for development is so much cooler for obvious reasons. Using MOSH on top of it naturally makes the experience much better.

Koding.com + MOSH = Ecstasy

Here is how you can get mosh to work on koding.com

  1. SSH into the koding server from your client machine. If you haven’t added ssh keys yet checkout their tutorial.

    ssh <username>@<username>.koding.io
  2. Setup uncomplicated firewall in the remote machine.

    sudo apt-get install ufw
    sudo ufw status verbose
    sudo ufw enable
  3. Open up critical ports first viz. HTTP, SSH and 56789 for koding.

    sudo ufw allow ssh
    sudo ufw allow http
    sudo ufw allow 56789/tcp
  4. Open up the port (60001 is used by mosh in most cases) on the remote machine for the client machine to access it via udp.

    sudo ufw allow 60001/udp
  5. Connect the remote machine by running the mosh command from the client machine. This will automatically ssh into the remote server and start the mosh-server.

    mosh <username>@<username>.koding.io

That’s it, you are done.

02. April 2015

Random Ramblings

Astrology vs Machine Learning ~ 2 Apr 2015

Is astrology an age old machine learning (ML) algorithm that is predicting the future, just like ad networks, that predict the click thru rate of an ad for the current user? Have I been ignorant all this while, failing to find the logic of causation in astrology, without realizing that:

Correlation does not imply causation

the premise on which ML exists.

more

28. May 2014

Schemaless scheduling for repeated events

Consider a case where one wants to schedule repeated events in a calendar. For example - a yearly birthday or a fortnightly appointment with the dentist. Though, these cases are quite simple and most of the current solutions such as — Google Calendar, handles them quite well, the problem arises when you want to integrate a system like this with your own application.

This stackoverflow question — Calendar Recurring/Repeating Events - Best Storage Method — gives a good picture of the complexity of the problem.

One thing that I observed, is that you could draw parallels between this problem and the problem of selecting elements in a DOM tree. The latter been solved already using css selectors. So I started developing a language inspired by CSS Selectors but tailored for selecting dates.

This language ultimately gave me a lot of flexibility in terms of writing repetition logic and applying filters. Moreover this setup din’t require any complex schema and thus no schema migrations, with every new feature. Its just one rule, defining any convoluted logic as you may like and still taking up only a single row in the table.

The rules for the language (Named it SHEQL) and a parser prototype has been open sourced and is also available via npm. Though the prototype has been written in javascript one could easily write a version in python or some other language.