Monte Carlo Method

In this essay I will talk about a term you might've come across when reading scientific literature or research papers. Idea is to develop gut feeling (intuition) for what the text is saying when Monte Carlo Method is mentioned.

Prerequisites

Monte Carlo Method (MCm) builds on top of other topics and concepts, taking time to understand them will make learning about MCm quite easy.

  1. Randomness in computers
  2. Law of Large Numbers
  3. System or Process Model
  4. Probability Distribution (Function)
  5. Deterministic Computation (Function)
  6. Markov Chain

Read more…

Link Preview & Open Graph Protocol

Notice how on posting a link on some sites or some messenger apps, a link preview shows up?

One might think the site/app crawls the webpage for this information but that's not the case. There is lot more interesting tech at play here.

Simply put

Open Graph Protocol

Let's take a deeper look and answer three questions

  1. What is Open Graph Protocol?
  2. How can I create custom link previews?
  3. Can I create dynamic link previews?

Read more…

FP for Sceptics: Intuitive guide to map/flatmap

Backbone of Functional Programming

map & flatmap form the backbone of Functional Progamming. It is very important be comfortable with these two concepts and this guide will help you develop an intuition for them.

This guide is language agnostic but I expect you to be familiar with basic programming concepts like functions, types, data type/objects and list.

Nomenclature

Let me introduce you to some basic terms we will be using to talk about map/flatmap.

  • Types are data constructs and they can be Basic Types like Int, String etc.
  • Container is a special type which contains another type. For example a List of Ints.
  • Function is a function whose input is of Type 1 and output is of Type 2. Type 1 & Type 2 can be same type.

Visualize

Though I have defined three terms it will be easier to think about them visually.

Basic types (Int, String etc) will be represented by shapes

Basic Types.

Read more…

Ent's snappy guide to Emacs

Introduction

I have used many editors over time and one "System" that I really enjoyed was Emacs. However I did not understand how it worked under the hood and it led to some fun times. This post is an attempt to log my experience with learning and understanding the "missing bits" in a single place.

This guide is consolidation of knowledge & experience of 2-3 days of intense focus learning & modifying Emacs.

Purpose

The aim of this guide is to quickly:

  • Bootstrap your understanding to a level where you can start thinking in terms Emacs' terminology and use that knowledge to searching the internet for new questions you might have.
  • Develop a rudimentary understanding of how to customize Emacs.
  • Setup an aesthically pleasing UI with usable setup.

This guide IS NOT about the basics of text editors like:

  • What are text editors? What is Emacs or Vim?
  • Which editor should I use?
  • How to navigate using either editor?
  • How to read/write elisp. I have a basic understanding of lisp/clojure but otherwise I haven't bothered with learning it for this.

Read more…

Second Static Website

Static Website Hosting

I really like the low footprint and utility of Static Websites. This website is built using Nikola.

In this post I will talk about some issues I faced with deploying a second static website and how I eventually solved it.

Github Pages

I have long enjoyed the awesomeness of User Github Pages and am quite happy with it.

However as soon as I tried to create a second independent static website with custom domain, Github was having nothing of it.

After spending lot of time scouring the web for how to make it work between Github & Namecheap, my DNS provider, I had nothing to show for it.

Read more…

Dependency Mock Server & Black Friday Preparation

Last year while preparing for Black Friday our team had an interesting challenge:

Some of our downstream services1 had proper setup to provide environments/APIs to load test.

This meant will have to configure our systems based on hopeful estimates based on last minute estimates and until then, we would could only sit idle. This wasn't appealing for obvious reasons of doing a hackjob and having a firefighting mode during Black Friday/Cyber Week.

Proposed Solution: Dependency Mock Server

The solution I came up with and which we used was to have a Mock Server that served endpoints similar to our dependencies and return dynamic responses based on request payload.

Server with Three Dependencies

Read more…

OT: Mapping thoughts, Memex & Zettelkasten.

Off Topic are posts where I talk about the human side of things.

Vannevar Bush, As We May Think

Have you read Vannevar Bush's article As We May Think? In that article he discusses an interesting concept:

"A System becoming an extension of human knowledge and memory which may be consulted with exceeding speed and flexibility."

Now this might not seem groundbreaking to us for we have Computers, Internet and Search Engines (Google, DDG, etc.). However it's important to know that Hypertext, which is the backbone of internet, was created thanks to the inspiration taken from Memex, which is the name of the system Bush proposed.

Read more…

Visual guide to polling in Functional Programming (Scala)

In this post, let's look at how to poll a system using a Stream.

To make it easier/interesting, I will explain it using a visual approach.

Let's use the following problem statement.

  • We have API for a queue1 that can be queried using pollFn function.
  • We need to process data returned by queue using process function.
  • There may or may not be data at the time of querying.

Read more…

FP for Sceptics: Option Type in Practice

In previous post we defined FP & error handling

Functional Programming (FP) is based around mathematical concepts like Type Theory - We define our system in terms of ADTs, data flow & functions.

FP promotes using types for error handling

  • Option
  • Either
  • Monad
  • etc.

Previous post also explained Option type and how it works.

ADTs in Practice took a practical system1 and designed ADTs for it.

In this post, we will reuse the same system but try to figure out where Option type makes most sense to use.

Option Type: Where to use it?

Read more…

FP for Sceptics: Introduction to Option Type

Functional Programming (FP) is based around mathematical concepts like Type Theory - We define our system in terms of ADTs, data flow & functions1.

We first implement "Happy Path" and then implement handlers for "Unhappy Path" (error handling). In ADTs in Practice we used "Exceptions" (IO.raiseError) for error handling.

However FP promotes using types for error handling, such as:

  • Option
  • Either
  • Monad
  • etc.

In this post we will start by looking at the simplest of these:

Option type denotes presence (Some(value)) or absence (None) of a value.

Option has Some(value) & None. What are two ways of using it?

Read more…