Pratyush Mittal
Hobby coder and a stock investor.
Co-founder Screener.in

17th July 2022

Weekly Updates - 9

We had some trivial engineering challenges over last 2 weeks.

Reducing diff speed from 30+ seconds to 300ms
We have a wiki feature at Screener. It allows anyone to modify and add key-insights for companies. In the backend, we use Google's diff-match-patch library. It generates diffs between multiple versions and merges them.

The Python version of the library had a long processing time for some edits. The moderation page was taking over 30 seconds to load.

We found a faster version of the library which is a wrapper around the C++ version. It had a few issue around installation. We fixed those issues and used this library.

While I did expect the loading times to improve, I didn't expect the C++ version to be 100x faster. The page loads in less than 500ms now. Yay!


Forgot Password not working for social logins - Django
We recently discovered that users using social logins (login with Google) were not receiving emails for password reset. The issue was this code:
user = UserAccount.objects.create_user(
    email=email,
    password=None,
    display_name=name,
)
Setting password as None disables password based logins. However, I didn't expect it to not send any email on clicking forgot password. Reading through Django's source code highlighted this issue. We fixed it with:
password = UserAccount.objects.make_random_password()
user = UserAccount.objects.create_user(
    email=email,
    password=password,
    display_name=name,
)


Improved rendering on mobile
We also refactored a lot of base templates on Screener. The text stuck to mobile walls sometimes due to the missing padding. We simplified the templates and fixed the rendering.

Tools and Books

I use MailBrew to generate personalised email digests. It sends me an email every morning of the Tweets of my favourite people. It also includes updates from HackerNews, Lobster, Pinboard network and any RSS feed I provide.

- Feed43 comes helpful when the websites don't have an RSS feed. I use it to generate feeds for MySQL release notes and new feature phones by Nokia. The free version works pretty well for my use case.

- The Mythical Man-month is a book recommended by all the senior programmers, but hardly anyone reads it. I expected it to be dry, outdated and hard. Surprisingly, it is one of the most easy and useful books.

Each chapter starts with a photograph and a quote. Both of them picked very carefully. And they set the theme for the chapter. They also serve as the summary.

The book acknowledges the hard-problem of maintaining the code quality. And it provides some solutions. Solutions that are easy to adapt for a small team like us.

I posted a short summary about it in this blog post.

Thanks for reading. See you again soon :). Will hopefully add a comments feature on the blog in coming days.