Photo by Lysander Yuen on Unsplash

In an earlier article, I demonstrated how to use using MagicMock to stub a method. In that example though, there was one inherent problem. Once you patch that method using the string representation, future patches will become ineffective/not work at all. Let me demonstrate this with an example.

Assume I want to mock to return a custom MagicMock, I could do it like this using the decorator.

Writing tests is essential in any programming language irrespective of the framework in use. In one of the recent projects in Python/Django which is relatively new to me, I had to write a substantial amount of tests. Some of these tests execute code which talks to the internet. And in the Python ecosystem, MagicMock is there to help us.

How to mock an external API and return value when the function is chained. Here is my application code

Connecting to Salesforce’s REST endpoint is fairly straightforward from a Ruby on Rails application. However, there are few steps you have to take. Before starting, ensure that you have full administrator privileges in Salesforce.

1. Create a Connected App

First thing we need to do is to create a Connected App. Its more like a bridge between the Salesforce resources and the outside world. Here is where you can also limit the scope what resources can be shared, their granularity etc.,

Photo by Lukasz Szmigiel on Unsplash

When we started using Clickhouse, the concepts of MergeTree and SummingMergeTree was very confusing. Not only should one understand what each mean, it is extremely crucial to know when to use what as using a wrong one for the other would either result in Resolution/Data loss or would incur huge amount of storage space.

The Problem

Assume CompanyX has a fleet of Trucks running on the streets. The current speed of each truck is being sent every second to a live server. …

Materialized Views are not something very new if you are familiar with Database views and have worked with Time series/Analytical database. However, when used in Clickhouse, they are blazing fast. So fast, that not many databases in the similar domain can even come closer to it.

Why is Clickhouse very very fast?

The reasons that could be termed for the speed as given in their website are,

  1. Column oriented database.
  2. Extremely efficient indexes.
  3. Compression out of the box.
  4. Query execution dependent on CPU and I/O instead of a conventional query optimizer.
  5. Ability to scale both horizontally and vertically.

Not only…

Photo by Clark Young on Unsplash

GCP is right up there in the top three race to cloud infrastructure only behind Amazon Web Services and Microsoft Azure. It has almost everything you need from classical VM instances, Serverless, Hosted Kubernetes, Docker container registries, ML, Vision - almost everything!

In this article, I am going to focus on how you might get milked out with a fat invoice every month if you aren’t careful enough. We learnt the hard way shelling out thousands of dollars a month only to realize you can achieve the same with a different infrastructure provider with almost one tenth the cost.


Photo by Kelly Sikkema on Unsplash

With the development community leaning a lot towards front-end, and framework like Rails mostly moving to mostly serve back-end, it is important to keep this separation clean and straightforward in a Production environment as well.

To make this work via nginx is not straightforward, yet doable. But why should one fiddle a lot with a syntax that is difficult to learn for a developer and is not clean enough. Plus, nginx still does not support https out of the box.

Enter Caddy

If you are still using nginx for your web server, you would be pleasantly surprised to know Caddy which comes…

Photo by Erik Eastman on Unsplash

In one of the projects I worked on, I had written close to thousands (sic) of Regex as they help in having a strong foundation in Natural Language Processing besides the existing libraries available.

However, one of the most important piece in Regex is that it could get complicated so fast when you have to cover a lot of different scenarios. For the untrained eye, this could look totally like a foreign language, however, when you have the knack of identifying the right one, things become easier.

I am going to list the most common Regex patterns you might end…

Photo by Xiong Yan on Unsplash

Refactoring is nothing but restructuring the existing code such that the existing behavior that is accessed through the outside world, remain the same. It’s often referred to as “under the hood” changes.

Why would someone want to refactor when the external behavior is not going to change. There may be many reasons behind this. Some of the common reasons yet not exhaustive reasons could be

  1. Improving run-time of the program
  2. Fixing Memory leaks
  3. Improving Modularity
  4. Improving Cohesion/Reduce coupling
  5. Making code more readable
  6. Reducing cyclomatic complexity
  7. Removing unwanted/unused variables
  8. Improving Memory Consumption
  9. Reducing number of parameters/arguments
  10. Improving code coverage

As I…

Photo by Brian Yurasits on Unsplash

One of the sexy features of capistrano if you had used it with Rails is how super simple it is deploy a Rails project. The DSL (Domain Specific Language) it uses is very straightforward for even a beginner to understand. However, with time, Rails at least in our experience has moved mostly to serve the backend alone with the Front end being taken over by the likes of Vue, React etc.,

In case of Vue, we now end up building the script for in the production machine itself. And if you want to deploy it in cost effective machines (that…

Bragadeesh Jegannathan

Founder & CEO, Francium Tech

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store