Sunday, October 01, 2017

Connecting Redux states and actions to a React component

Connecting states and actions from a Redux store to a React component is quite straightforward. While many developers use shortcut techniques to do it, I prefer to use the following format:

What this is saying basically is that somewhere we have a component called ProductList, and I would like to expose an action creator, called fetchProducts, and a state (possibly a state altered by this action creator), called products.

Note that I made use of an ES6 technique called object destructuring to shorten state.products into products, as I am only interested in that particular state. This technique is so common in this context that it is perfectly conventional to map states like this.

Tuesday, August 29, 2017

Installing Python Quantlib 1.9 on Ubuntu 64 bit

I compiled QuantLib for Python using SWIG and packaged it for public consumption. Installation is easy for those who want to get started quickly. Just follow this link.

Friday, July 28, 2017

Python decorators explained in 2 minutes

Python decorators seem to confuse most newbies. But in reality they are just a fancy way of wrapping functions and modifying their behaviour as a consequence. They are functionally similar to Java annotations.

The code below describes a decorator in its simplest form.

It can be rewritten as per below, using the pie syntax:

Saturday, July 22, 2017

My philosophy about technology architectures

I get asked this question often: how would I build an effective IT strategy in a way that will deliver both short- and long-term business value? I believe that it always boils down to these three mantras:

A. Learn once, write anywhere
This is rule number one. Very similar to the KISS (Keep It Simple Stupid) mantra. Don't spruce up a high variance tech all over the place to sound hip. Go for technology frameworks that do not need isolated niche skills. Instead go for technologies that talent can be easily transferrable elsewhere.

B. Fast deployment and Immutable Infrastructure

You want to scale up (or down!) quickly and cost-effectively? Then you have to build your stack in a way that is easy to adapt to changes and features while catering for growth. Do not grow vertically. Grow horizontally, ideally using commodity hardware. What am I saying here? Look into DevOps philosophies, continuous integration and deployment pipelines.

C. Loose Coupling Technology (don't put all your eggs in same basket)

This is perhaps one of those concepts that if misunderstood, will pave the way to long-term failure. We have all heard about vendor locking, and you already probably know that this can lead to a growing technical debt in the future. One can also transpose this concept to the choice of technology - whether how host your infrastructure, or which tech to use to power and code your application. Bottomline is to avoid technologies that are tightly coupled with specific systems (example: does your current stack work only on NOSQL systems? Can your application be transferred to the cloud?)

If you are like me, you have probably worked on a multitude of different technology stacks, way before they were called "stacks". From Linux to Windows, from open-source to proprietary systems, from monolith to service oriented architectures, etc. One needs to take into consideration other business processes when starting to think what architecture suits you best - consider HR processes, operation processes, marketing processes, etc.

Remember, there is no such as thing as 'best practice' in the real world, but more of a 'best fit'.

Thursday, March 30, 2017

Simple effective way to take Docker backups

The title might seem contradictory for Docker noobs - backup Docker? What the..? While most people use Docker to achieve an immutable infrastructure there are many reasons why you would still need to backup your docker containers.

Let's say you are running MySQL on a docker container for instance. And let's also say that you are running a custom docker image and you are not using any docker repository to store this image. Furthermore, I will presume that your data volume is not ephemeral and you want to back it up as well.

The following code will backup the docker container and save it as an image for later reuse:

If you want to restore this docker image you can follow these steps:

What about data volumes? To list data volume mounts of a running docker container:

This means that /mysql_data inside container is mounted on the host's /var/mysql and we can simply backup this directory from the host.

Monday, March 20, 2017

Best way for effective Postgresql database backups

Unfortunately the Internet is littered with ineffective methods of backing up your precious PostgreSQL database. Most methods use the pg_dumpall technique - this is inherently faulty for mission critical databases as it only creates plain text backups which would limit the restore options.

A better way is to use custom format backups coupled with global data backups (such as user accounts, permissions, etc):

Friday, March 03, 2017

Deploying Apps on Github Pages

While is a great way to simulate web applications while in development, I find it more convenient to eventually deploy the Free Code Camp challenges to Github Pages. Examples of web applications I have deployed so far:
  1. Wikipedia Viewer
  2. JS Calculator
  3. Tic Tac Toe Game
  4. Pomodoro Clock
It’s really simple. Once you create a github pages account and create a new repository, just follow these steps to deploy the app on github pages: