Promise – finally

The finally method of a Promise  allows you to execute code after a promise has been settled. If the promise succeeds or fails the finally method is called. This is useful if you want to run some code regardless of the outcome of the promise. The promise finally method is similar to the finally method in a try catch finally block.

Continue reading Promise – finally

Introduction to Django

Django is a python framework that lets you quickly and easily build secure data driven websites.

Django uses the Model-View-Template (MVT) architecture, which has three components:

  • Models are used for managing the data.
  • View handle the application logic , they fetch data from the models and display the results in the templates.
  • Template handles the presentation of data in a particular format as specified by the View.

Installing django is easy using pip which is a package management solution.

You will need python installed on your system, To install Django, we recommend that your first create a virtual environment and then run the command

pip install django

Django is now installed, now you need to create an project, you can create an project using the following command startproject PROJECT_NAME

Which will create a  folder named PROJECT_NAME with files inside it belonging to your project, now you need to create an app, a Django project can use one or more apps. Create the app by first changing directory into the newly created project directory, then run the following command

python startapp app_name
Web App

We need to connect our app to the project, we do this by modifying the file present in the Project folder

In the file add your app name to the INSTALLED_APPS list


next inside the apps folder, create a folder called “templates”, this will be where you store your app template files.

Next we need to connect the urls of the app to the project urls, to do this open the file in the app directory and add the following contents

from django.conf.urls import url
from . import views

urlpatterns = [     
url(r'^$', views.home, name='home'),

the urlpatterns is a list of urls, each url consists of 3 parts

r’^$’ is the regular expression used to call the view function when the url matches the given regular expression

views.home is the views function that will be called for this url

name=’home’  you can also optionally provide a name for your url

Next in the file in the project directory add the following import statement

from django.conf.urls import include

Next add the following url to the urlpatterns list

url(r'', include('app.urls')),

The above code matches the url with the regular expression, if it matches, the includes function is used to include the app file to handle the request.

Next we need to add some logic to the code, for this we add code in the file. This is where the logic of the app resides.

def home(request):
return render(request, 'home.html', {})

In the above block of code we create a function called home, which takes in the request object, it then returns the home.html page 

Next create a directory called templates inside the app directory and place a html file called “home.html” inside it, write any html content within the file.

Now in the terminal or command prompt run the command

python runserver

The above command will start a webserver and if you open the url localhost:8000 in a browser , Django will get the url, see that it matches the “home” url pattern, it will then call the home view function, the function will then return the home.html file to the browser which you can view.

Django can do a lot more than what is mentioned in this post, If you would like to learn more about Django, then the official documentation is a good place to start.

Native vs Hybrid App Development

Hybrid Apps normally use one code based comprised of web technologies like HTML, CSS and javascript and run in on a webview. The advantages of Hybrid apps are that now you only need to maintain one codebase for multiple platforms – Android, iOS and the Web.

Native apps are built using the specific programming language for the platform, so for Android you would use Java or Kotlin . For iOS , you would use Swift or Objective C.

Continue reading Native vs Hybrid App Development

An Introduction to WebWorkers

JavaScript is single threaded, all your code runs on the main thread. Now if you run some CPU intensive task like compressing a large file, the browser will become unresponsive while it performs the task. To overcome this, we use WebWorkers.

WebWorkers are external JavaScript files that run in a separate thread, so that you main thread can remain free to process user input.

Continue reading An Introduction to WebWorkers

Introduction to IndexedDB

Relational Databases like MySQL are great for storing , updating and reading data. Though they come with two disadvantages. 

  • Since the databases reside on the server, fetching and updating data depends on the quality of the user’s internet connection. If the user has slow internet, it will take much longer to data to be fetched and updated.
  • Also when the user loses connectivity, there is no way to connect to the database until the connection is restored

IndexedDB is a JavaScript-based object-oriented database which runs client-side on your browser, so it works in bad networks or when the user is offline. IndexedDB stores data as key value pairs, key can be any string, value can be any object. IndexedDB also indexes  data stored so that you can perform high performance searches on the data. IndexedDB also supports transactions

Continue reading Introduction to IndexedDB

An introduction to ES6

ES6 also know as ECMAScript 2015 and JavaScript 6 is the 6th major release of the ECMAScript language specification.

ECMAScript is a Standard for scripting languages and JavaScript is the most popular implementation of the ECMAScript Standard. ES6 introduces some new features which makes programming in JavaScript better.

Continue reading An introduction to ES6