5 Tiny Things I've Learnt in Life

These are 5 random, tiny things I’ve learnt in life. Something to bring a smile to your face, or something to read about & maybe think: “Why don’t I try that out?”.

You don’t have to finish every book.

I think the secret to being a voracious reader is this: don’t force yourself to finish every book. I first heard this on a Naval Ravikant podcast, and it immediately felt the right thing to do. There have been several books I’ve abandoned halfway, or even quarter-way, always with a tinge of regret or guilt. But then for every book I’ve thrown away, there is one that I’ve felt an immediate resonance with: savour those books, recommend them to friends, and remember them in your dreams.

I also think you can substitute book for almost anything else you love doing. Even if you are totally into something, there will always be elements of that hobby or that calling that you don’t like. That’s ok! Forgive yourself for those missed pages, and move on.

The body makes the mind.

In the tiniest of ways, even. Try an experiment (this will sound silly): stand up, spread your arms wide, take a stance like the Vitruvian Man, tilt your head up, close your eyes, and imagine you are one of those star athletes who have placed #1 on the podium after a long, gruelling race. 

How do you feel? I think it’s intuitive to us that the body can make the mind feel bad, the most common example is when we’re ill. But the body (even a change of stance), can make you feel different things. I’m still exploring what this means, but it’s part of what makes somebody who has an active life feel full of energy & life too. Or why things like yoga have an impact. We’re all at the end of the day, mammals, rooted in the physical self (even if we spend all of our time up in the clouds), so it’s good to take care of your body.

Meet every Small Negative with a Positive

If you play cricket, and a friend bowled you out, you still get back on the pitch to field. If it’s basketball, and somebody stole the ball away from you, you still run after them, hoping for a counter. Life throws you curveballs as well, some small and some big. The big ones loom large in our memories, bringing in so much angst, worry, and fear. But it’s the innocuous looking small ones that you should take care of.

Let’s say you have decided to go to the gym every other day. You’re all pumped up for it—the gym bag packed, the protein shake ready—but your boss calls you up for a meeting right as you are leaving the office. The meeting drags on for like 2 hours. You hope you’ll make the gym timings until it becomes obvious you wouldn’t. What do you do? I used to go home, say FML, have a drink, and go off to sleep. I think it’s obvious to everybody who has tried to start a good habit, that every time you fall off the wagon, it’s harder to get back on it. Enough of these days, and you skip gym even when you are feeling tired, or even when you are having a bad day.

Instead, meet a negative with a positive. If you skipped gym a day, that’s ok. Turn up the next day. Shit happens. And the day after that, until you have a good habit that sticks.

The Magic of Compound Interest

Imagine you invest money that grows at 8% every year. At the end of Year 10, your money would have more than doubled.

> a = 100
100
> a = a * 108/100
108
> a = a * 108/100
116.64
> a = a * 108/100
125.97120000000001
> a = a * 108/100
136.048896
> a = a * 108/100
146.93280768
> a = a * 108/100
158.6874322944
> a = a * 108/100
171.38242687795199
> a = a * 108/100
185.09302102818816
> a = a * 108/100
199.9004627104432
> a = a * 108/100
215.89249972727868

I think it’s something we learn in school that seems like mathematics, and not something that’ll ever see use in real life. But it’s the secret behind good & healthy finances: start saving money early (as soon as you start earning!) & do regular monthly savings. You will have a decent kitty when you finally start to retire. I’ve used & recommended Scripbox, but there are so many options now to start.

The magic of compound interest also works with things other than money. Let’s say you were 0.5x of the person you wanted to be right now. And you know you can try to improve at least 1% every day. How much improvement will you have in a year?

> 0.5 * ((101/100) ** 365)
18.89171716644364

Yup! 18 times the man you were before. Of course, this is a silly example. But do become aware that small improvements add up quickly.

Science and Belief

This is probably gonna be the most controversial one, so bear with me. The scientific method where everything in the world is a hypothesis until enough experiments prove it to be fact, and these facts advances the state of human knowledge is a wonderful, wonderful thing. I think we disregard how much science has contributed to human society. It’s a fun activity now to disregard science, and turn to abstract concepts like spirituality & philosophy to try to find answers to our problems. I think that is the wrong thing to do. We should always ground our truths in science, and say no to the growing mysticism around us.

But maybe there is something flawed with the scientific method. If the scientific quest is the search for fundamental truths, then, what if there are truths that depend on someone to believe them first for them to be true?

I turn to fantasy tropes because those are always so accessible. Let’s say magic exists. Like the one in Harry Potter. But it requires somebody to really, really believe that it does for it to work. A scientist, being a skeptic at heart, will never get his experiments to succeed. A witch, living somewhere remote, her heart filled with wonder, will spark a glow in her wand.

Now, this is a contrived example, just to expound on the premise. But a more concrete, real example is when we think of how little science understands the mind, and how to mould and discipline it. Let’s say, these spiritual gurus of old Hindu yore have a point, and they’ve discovered a way to calm the mind, build a more successful life, make us a 100% more productive as a society. But it requires you to believe some things first. Some things that might even sound mystical. Should a good scientist pursue this path or not?

I’m of half minds about this, a part of me feels that this frustration is because of course there are things science can’t answer yet—there always will be—even when we think there are no more fundamental discoveries to be made. There have been 15 year gaps in the Wikipedia scientific timeline for example. What if we are going to a 15 year slump? What if good, rigorous science can explain the mind better than these weird theories of belief?

Maybe the middle ground here is to explore what these old philosophers had to teach about the mind. Maybe with a skeptic’s eye, but faithfully following their set discipline, even if they sound mystical and ridiculous. Wake up in the morning and do yoga after bowing down to the sun? What difference is that going to make? Well, a good scientist won’t know until he tries it out.


PS. I talk about feelings and emotions here, this might sound sappy to a few of you macho folks. I have just one advice for you in that case: grow up.

A mini-trip to Humayun's tomb

Today I woke up early (on a Sunday, nevertheless) and went to Humayun’s tomb to take some photos. It’s been a long time since I took out my camera (a Fuji X-E3), so this felt good!

Humayun’s tomb is one of the first big Mughal tomb projects, and as you can probably see from the photos, it’s a fore-runner to more famous ones like the Taj Mahal. The whole complex has a bunch of other ruins as well, and I particularly liked Isa Khan’s tomb — it’s a lot more colourful than typical Mughal buildings. Anyways, here are some of the photos I took.

Reminds you of a more famous something?
Lots of little windows like this everywhere, and beautiful shadows and light.
These are the corridors of Isa Khan’s tomb.
Parrots, sparrows, and squirrels, all after the same bounty.
Imagine this in its heydays. These were built to inspire.

A Plug for Razzle & Next

My last post (a year ago, sigh) was about how to configure a JavaScript application from scratch. Since then, I’ve built an isomorphic Node and React app that’s doing pretty well in production and learnt a lot of lessons along the way.

If you are looking for the “Rails” of the JS world, I have two suggestions for you:

  • Razzle: more configurable SSR solution that comes with most batteries included!
  • Next: lovely DX, super-fast defaults, and amazing traction (they have a collaboration with Google), but a bit less customisable.

My app was built in Razzle, but if I was to start today, I’d probably choose Next instead!

Bootstrapping a modern full-stack JavaScript Application using Express & React

The Why

There are several reasons to pick a full-stack JavaScript dev environment in 2019. First off, JavaScript is ubiquitous, it’s got pretty much all the big names in web software aligned behind it: Facebook, Google & Microsoft all have investments in both server and client-side JavaScript frameworks. Who would have thought that we would live in a world where we’ll write code in an editor built by Microsoft, in a framework developed by Facebook, and using design systems inspired by Google. Frankly, it truly is the golden age of client-side web development.

The story on the server-side for JavaScript doesn’t look that rosy, but NodeJS has come a long, long way from its initial demo, and for most web applications that serve an API backend, it’s a solid choice, especially combined with web frameworks such as Express.

And on both ends, JavaScript in general has evolved a lot as a language with first-class support for classes, async/await, spread operators, and string literals. In fact, even coming from a developer-friendly language like Ruby, JavaScript feels nice now, not like five years ago. And some features (like type hinting and automatic formatting) enabled by projects like Babel and Prettier make editing JavaScript code feel like living in the future. In fact, if you haven’t edited JavaScript in VSCode before, do try it out.

The Choices

Well, you’re convinced and ready to jump into full-stack JavaScript. How do you do it? If you come from the Ruby/Rails world like I do, you’re in for a rude shock. Rails picks a lot of default choices for you: there is an emphasis on convention over configuration, and all its moving parts are designed (& tested) to work well together. JavaScript is… not like that. It has a ton of developers actively working on several libraries every day, leading to good examples of what not to do when including dependencies.

So in fact the first step in building full-stack JavaScript is deciding what goes into the stack. At Lucideus, for a new product called Safe Assure, here’s how we made those technology decisions. Each product and technology chosen ideally has to be:

  • mature technology (developed for at least 2 years), as part of the principle to use boring technology.
  • actively maintained, and have updates within the last month, and a history of frequent updates without the developers taking off on long vacations.
  • ideally sponsored by a large organisation that won’t die tomorrow (Google & the like preferred, but Airbnb, Palantir et. al. are acceptable), and,
  • have developer mindshare, as measured by a healthy number of stars on Github.

Based on these criteria, here’s what we chose for the frontend:

& for the backend web framework, we chose to build a simple Express API endpoint. There are of course a lot of default choices (in so much as the community as accepted them as the de-facto default) that come with choosing to build a JavaScript SPA that require configuration as well, amongst them:

  • Webpack (which is used to bundle & minify JavaScript, CSS, and images)
  • & how to deploy this application, for which we chose to build a Docker image that combines the server & client parts of the app, for eventual deployment to a managed Docker cluster.

Note: in future versions, we might explore building an auto-generated and configured GraphQL backend instead of the Express app, probably using Hasura’s excellent frontend for Postgres, but that’s a post for another day.

The Application Structure

Let’s start with a sane application structure. We’re essentially building two apps: a frontend SPA client app, and a backend API that the client consumes to display data from a database. So let’s make:

  • src/
    • client/
    • server/

We also need tests, so a folder for that. Note: we prefer integration tests, so these are independent of the client and server, and indeed will only work if both components are present and running:

  • src/
    • client/
    • server/
  • test/

Eventually when we deploy the app for distribution, we also need a dist/ folder, so let’s create that too:

  • src/
    • client/
    • server/
  • test/
  • dist/

Inside the client/ folder, we start with a simple SPA application:

  • client/
    • images/
    • components/
      • All React components of our SPA
      • App.js
        • The main App/ component.
    • index.html
      • The HTML entry-point of the client-side app, this is what webpack injects assets into & loads in the browser.
    • index.js
      • The JavaScript entry-point of the client-side app.
    • styles.css
      • Generic styles and imports that remain outside of components. This is usually used only for @imports & special things like @tailwind directives.

Note: as our app expands, we might logically create more folders, for e.g. sub-components inside the components/ folder by business theme or any other organisational unit we might choose.

The server folder uses the folder structure generated by the excellent express-generator. Note: we choose to configure it with the EJS view template (i.e. express -v ejs) . It looks like this:

  • server/
    • bin/www
      • The JavaScript entry point of the server application. Makes sure the ports configured are available and loads the app.
    • public/
      • fonts/
      • images/
      • Both these folders will be empty when developing, but we’ll use this in the deployment step to link the client and server applications correctly.
    • routes/
      • api/
        • <endpoint>.js
        • This is the /api/* endpoints that you would configure. Each file would be a separate route.
      • index.js
        • This is the default route that will just serve views/index.ejs. We’ll use this during the deployment step.
    • views/
      • error.ejs
        • Used when there is a 40*, 50* error in the application.
      • index.ejs
        • Copied in by the deployment process to load the client-side SPA.
    • app.js
      • This is called by boot/www during the startup process and sets up the main Express app. You also configure the API routes here.

That’s it for now! In Part 2 of this article, we’ll look at configuring Webpack correctly to minify & remove un-used CSS, and process images and fonts.

Designing Koal

14 years ago, I had simple ambitions to make a website for amateur writing. Then life got in the way until it didn’t, and Koal was reborn. Why I’m making Koal is intensely personal: reading is a big part of my life and a lot of what I’ve read—and some of the best bits—have been from amateur authors who are either nameless or forgotten.

Every year I notice sites that host these stories either disappearing, turning uglier, harder to access, or hiding these gems behind a paywall. It’s important to me that this trend be reversed, that there exists a free site, unencumbered with ads, where these authors can be read in peace. A place that is distraction-free, and hopefully even beautiful.

This is entirely a one-person effort, and this is a log of my work to date:

  • Because I’ve turned a bit rusty with server-side programming in Rails, I decided to use the latest Rails as a backend and then plugged away at it until I got comfortable enough to use Rails as a server-side HTML framework, and StimulusJS (when needed) to sprinkle JavaScript interactivity.
  • I’ve been using Product Hunt Makers as a build log, and it’s been working great. Getting high-fives and comments from other makers is great!
  • After I got the basic scaffold working, I decided to write importers for the most common story sites. Right now I have SOL & Fel converters working. Next importer to be built is a Fanfiction/Fictionpress importer.
  • Once I got the site live by using a bare basic design layout, I decided to spend some time improving the UI design of the site. It’s taking quite a bit of time to relearn some UI design fundamentals, get up to basic with modern CSS & Tailwind, and then get familiar with Sketch so that I can translate what I see inside my head to a page.

This is where I’ve reached as of now: having sketch design files that need to be converted to HTML.

First up, the home page:

Koal Home.png
This is the home page. As more stories get filled in, I hope to develop features stories as well with this layout.

Now, the story page:

Koal Story.png
A story detail page. More work needs to be done with the typography here.

This is much simpler, and I’d like to do more work to make the typography shine here.

I’m reasonably happy with what I have now. So immediate next steps:

  • Convert this to HTML.
  • Play around with the Pexel API to get great live covers.
  • Get this design live!

& after that:

  • Write an importer for Ficsave’s Fanfiction/Fictionpress EPUB export, and import some more great stories into Koal.
  • And write an EPUB export tool to get clean EPUB versions of all these stories.