Yos Riady optimize for learning

Excerpts from 'The Personal MBA'

Here are my highlights from The Personal MBA, a fantastic collection of mental models in business and life.

Read on →

Publish-Subscribe in Elixir

Publish-Subscribe in Elixir

Publish-Subscribe is a messaging pattern that works as follows: a group of consumers subscribe to events of a given topic and are notified whenever an event of that topic arrives.

When an event is published into a topic channel, the channel delivers a copy of the message to each of the output channels. The advantage of this is we can decouple the consumers from the producers. Neither party need knowledge of each other to communicate.

In other words, pub-sub is a pattern used to communicate messages between different system components without the components knowing anything about each other’s identity.

Let’s look at an implementation of Publish-Subscribe in Elixir. The full source code is provided below.

Read on →

Recently

Recently

The day you stop practicing is the day you stop improving. Never let yourself be satisfied with how good you are at anything.

Read on →

Merkle Trees in Elixir

Merkle Trees in Elixir

A hash tree or Merkle tree is a tree in which every non-leaf node is labelled with the hash of the labels or values (in case of leaves) of its child nodes. Hash trees are useful because they allow efficient and secure verification of the contents of large data structures.

Hash trees are used in the IPFS file system, BitTorrent protocol, Git, Bitcoin, Ethereum, and a number of NoSQL systems like Apache Cassandra and Riak.

They are used for many kinds of verification, especially of large chunks of data.

Read on →

Recently

Recently

Make it easy for people to do the right things; make it hard for people to do the wrong things.

Read on →

Writing and Publishing Elixir Libraries

Writing and Publishing Elixir Libraries

Let’s walk through the process of writing and publishing an Elixir library from start to finish. For illustrative purposes, we’ll create a pretend simple_statistics statistics toolkit for Elixir.

The full source code is available on Github.

Read on →

Automated REST API Development

Automated REST API Development

You’re building a REST API.

You start by implementing some server endpoints and deploy it to production. You write several official language-specific API clients as well as documentation. Your API announces a public release; other developers start using it. Your day ends on a happy note.

The next day, you want to add a new feature to your API. You notice that you have to do a few things:

  • Update the server implementation to support the new feature.
  • Update the client libraries (one for each supported platform and language.)
  • Update the documentation.
  • All the above must be consistent with each other.

You let out a heavy sigh.

Read on →

Mixins in Elixir

Mixins in Elixir

Let’s demystify the frequently used use keyword in Elixir.

We can use the use keyword in Elixir to package behaviour and implementation for use in other modules, similar to abstract base classes or mixins in other languages. Mixins reduce the amount of boilerplate in your modules, especially for library authors.

Mixins in Elixir are similar on the surface to Concerns in Ruby and Traits in Scala. Before we start, you should be somewhat familiar with behaviours and macros.

Read on →

Syntactic Extension with Elixir Macros

Syntactic Extension with Elixir Macros

An Elixir program can be represented by its own data structures as an abstract syntax tree (AST) of tuples with three elements. For example, the function call run(1, 2, 3) is represented internally as:

{:run, [], [1, 2, 3]}

Macros in Elixir lets you perform syntactic extensions, which are expanded to before a program executes. We use macros to transform our internal program structure by treating code as data, and thus metaprogram.

Many of Elixir’s language features such as if and def are in fact macros, which are translated away into lower-level abstractions during compilation. Armed with the same tools that José utilized to write Elixir’s standard libraries, you can extend Elixir to suit your needs using macros.

Read on →

Recently

Recently

The days are long, but the years are short.

Read on →