Flask + MongoDB Tutorial

In this tutorial, I’ll demonstrate how can you use Flask together with MongoDB.


We’ll use the following structure for our project

__init__.py # Flask app
database.py # Main database class
job.py # Job DB model
routes.py # Main page routes
main.html # Main page HTML template
requirements.txt # Requirements for running the application
Continue reading “Flask + MongoDB Tutorial”

Mongo Shell By Example

Start the mongo shell

Start the mongo shell by running mongo

Note: this will connect using the default port 27017. Use -p for specifying a different port.

You should get an output similar to the following

MongoDB shell version v4.0.3
connecting to: mongodb://
Implicit session: session { "id" : UUID("2323-8as8-23aa-8fsa") }
MongoDB server version: 4.0.3

From this moment on, everything you’ll type will be executed in the mongo shell.

Continue reading “Mongo Shell By Example”

Python: Pipenv Tutorial

What is Pipenv?

A package management tool which makes combined use of

  • pip – Python package manager
  • virtualenv – Tool for creating isolated Python environments so you can easily use different packages in different projects
  • Pipefile – records the package versions used in a given project so you can easily install them on any other system you want. Also considered as the replacement of Python requirements files

So basically with one short pipenv command you can install a package in a virtual environment and record it in pipfile and pipefile.lock files.

Continue reading “Python: Pipenv Tutorial”

OpenStack: Testing Upgrades with Tobiko

What is Tobiko?

Tobiko is an OpenStack upgrade testing framework. It aims to provide tooling and methods for easily developing upgrade type tests.

Note: At this moment it also provides you with several built-in networking tests.

If you are familiar with OpenStack you might wonder why the current OpenStack testing framework (Tempest) is not used for that purpose.

Continue reading “OpenStack: Testing Upgrades with Tobiko”

Algorithms: Basic Exercises – Part 1

In this post, you’ll find a collection of basic exercises for you to practice ‘Algorithms’ which is a fundamental topic in Computer Science. Each exercise includes a solution but for the absolute beginners, I recommend to try and solve the questions by yourself, without peeking at the solution. This is the best way to master algorithms over time. Enjoy!

Index equal to the value

Given a sorted array T of integers, write an algorithm (using pseudocode) that searches for T[i] = i

In case of success, it will return the value of i, otherwise, it will return -1.

Continue reading “Algorithms: Basic Exercises – Part 1”

Linear Programming: Graphical Method

In this post, we’ll see how to solve a Linear Programming problem using the graphical method.

The graphical method consists of two main phases:

  1. Finding the solution space (the space where we have all the valid solutions) by drawing each constraint.
  2. Finding the optimal solution – a solution that will give us the maximum value for the objective function.

Let’s solve the following problem:

Continue reading “Linear Programming: Graphical Method”

jQuery Datatable Ajax: Change cell’s HTML after data is processed

The Problem

You generated a table using jQuery Datatable without loading the page, using Ajax. You wish to change the HTML of cells in a certain column after the data is processed. How to do it?

For the sake of this example, we’ll say we want to switch the data in the first column of the table into a hyperlink.

Continue reading “jQuery Datatable Ajax: Change cell’s HTML after data is processed”