If you ever feel the need to host a database on a server and do not have the resources to do so, you can setup the database locally on a laptop and expose the service to the outside world using ngrok. Please be aware that using ngrok has it’s own advantages and disadvantages and the connectivity isn’t as reliable as compared to AWS RDS. However, it’s faster to implement and cost effective for running POC’s and test apps for demo or test purposes.

Image for post
Image for post

Question: What is ngrok?

Answer: Ngrok exposes local servers behind NATs and firewalls to the public internet over secure tunnels. Ngrok creates HTTP/TCP tunnels on random URLs/ports. The free plan comes with some basic features and you can read more about it on the ngrok website. …


Image for post
Image for post

Over time as you create pull requests and move your changes from temporary branches over to the dev or master branch, a lot of branches can pile up on your local system and can be noisy when you are trying to list all the branches.

If you’re using GitHub, it conveniently gives you the option to delete the temporary branch after merging into dev or master. But, the local git repository still shows the remote and local branches even though they have been deleted from GitHub. When branches get deleted on origin, your local repository won’t take notice of that. …


There are so many ways of hosting custom JAR files and importing them for your projects. You could use a Nexus server, store them in GitHub or even install them locally on all machines. But in a production environment, you may not have access to the build server to go and install custom JAR files. Adding them to your Nexus server in that case (if available) might seem like a good idea, but it comes with a drawback that every developer will have to setup a local Nexus server to keep the build process in sync with the production setup.

However, there is an easy alternative that works well with Mulesoft and Maven. The solution is to store the custom JAR files into the Exchange repository. The exchange repository comes with your own Organization ID where you could host private JAR files that may only be accessible using your account credentials. The account credentials can be saved in your ~/.m2/settings.xml …


Here are instructions to install and run mcrypt on Debian 10 with PHP 7.3+

Image for post
Image for post

Check PHP Version

$ php -version
PHP 7.3.9-1~deb10u1 (cli) (built: Sep 18 2019 10:33:23) ( NTS )

Check if mcrypt is installed

$ php -m | grep mcrypt

Install pre-requisites

sudo apt-get install php-dev libmcrypt-dev php-pear

Install mcrypt PHP module

$ sudo pecl channel-update pecl.php.net
Updating channel "pecl.php.net"
Update of Channel "pecl.php.net" succeeded

$ sudo pecl install channel://pecl.php.net/mcrypt-1.0.2
...
...
Build process completed successfully
Installing '/usr/lib/php/20180731/mcrypt.so'
install ok: channel://pecl.php.net/mcrypt-1.0.2
configuration option "php_ini" is not set to php.ini location
You should add "extension=mcrypt.so" to php.ini

Add mcrypt.so to the php.ini…


Ever feel the need to sort a JSON by keys, OR sorting a dictionary by keys? Python doesn’t allow that.

Question: Is there an alternative?

Answer: Yes!

Image for post
Image for post
Sorting JSON or dictionary by keys in Python

You cannot sort a dictionary by keys, but if the need is to print it out, you could covert it to a JSON and the resulting JSON output can be sorted by keys. Likewise, if you have JSON that you’d like to sort, you can first convert it to a dictionary and then convert it back to JSON and this time sort it by keys. And this is true for a multi-dimentional dictionary and JSON.

Converting dictionary to a sorted JSON

sorted_json = json.dumps(dict_data, sort_keys=True) # This JSON will be sorted recursively

Converting unsorted JSON to sorted JSON by keys

import jsondict_data = json.loads(unsorted_json)
sorted_json = json.dumps(dict_data, sort_keys=True) # This JSON will be sorted recursively


Image for post
Image for post
Using psycopg2 PostgreSQL library with Python

Using python/psycopg2 and wondering how life would be so much easier if you could get the query results to be a dictionary and you could get the value by using a keyword on the dictionary. psycopg2 by default returns results as a tuple so you have to use row[0], etc. to get the values. e.g. the code looks something like this

qSelect = "SELECT first_name, last_name, address FROM employee"cursor.execute(qSelect)results = cursor.fetchall()
for row in results:
print("First Name: {}".format(row[0]))
print("Last Name: {}".format(row[1]))
print("Address: {}".format(row[2]))


With the ease of deployment that SaaS services bring, most organizations are moving their infrastructure in the cloud. The ease of deployment can also lead to increasing costs if you do not plan ahead of time. Spinning up a new database for every new customer can easily be automated today, but down the line that would increase the hosting costs. At the same time, sharing customer data within a common database could result in leaking sensitive information across customers which could harm your reputation as a software provider.

Question: What are we trying to learn from this article?

  1. How to create a database with 3 layers of security — postgres as root, table owner for DML and DDL, end/api users with DML…


Anyone ever told you to have several layers of security to protect your application? Damn right. As an application developer or a DB admin, how can you ensure that you’ve setup the right set of security principles for your database? This article will help you answer some of those questions and hopefully make you feel secure about your database and maybe help you have a sound sleep at night.

Image for post
Image for post

Segregate privileges

The general principle of segregating privileges to the database is that “If you shouldn’t be using it, you shouldn’t have access to it”. …


I am sure you’ve all been in a situation where you’d like to implement a counter to track website hits, database reads, API exceptions, etc. There are various ways this can be implemented with each one having their own pros and cons. I’ll briefly go over them and explain alongside, so just follow along.

Single Threaded Counter

This is the simplest and most efficient implementation considering you have a single threaded application. But in the modern world, this is a rarity so won’t be used often, but I’ll still mention it for the sake of it.

class SingleThreadCounter(object):
def __init__(self):
self.value = 0

def increment(self):
self.value …

MuleSoft is one of the technologies that has been growing by leaps and bounds over the last couple of years and invariably will continue it’s growth as more and more companies are onboarding the idea of using SAAS products and microservice architecture. I’ve spent most of my professional career integrating software, services, automating procedures and and reducing redundant, manual procedures for the end users using the products.

Moving over and starting to use MuleSoft v/s traditional point to point integration has brought in a level of efficiency that is unparalleled. Spinning up a process/middle-layer API which took a couple of days now takes a couple of hours and you are up and running. I am definitely going to invest a lot of time and resources in MuleSoft for the future integrations so here’s the first tutorial which is the beginning of a series to explain standard MuleSoft components and best practices. …

About

Verma Varun

Mastering automation, improving efficiency and connecting systems.

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