<![CDATA[chryzcode]]>https://chryzcode.hashnode.devhttps://cdn.hashnode.com/res/hashnode/image/upload/v1704235926706/EpPc56J3M.jpgchryzcodehttps://chryzcode.hashnode.devRSS for NodeTue, 15 Sep 2026 12:04:18 GMT60<![CDATA[Google Authentication in Nodejs using Passport and Google Oauth]]>https://chryzcode.hashnode.dev/google-authentication-in-nodejs-using-passport-and-google-oauthhttps://chryzcode.hashnode.dev/google-authentication-in-nodejs-using-passport-and-google-oauthTue, 23 Apr 2024 17:17:29 GMTGoogle authentication is one of the seamless and fastest modes of authenticating users in an application. It saves the user the time of filling out forms with his/her details and verifying email addresses.

In this article, we will implement Google authentication in our NodeJS application.

Create Your NodeJS Application

  • Install Node.js

    You should have Nodejs installed on your laptop and if not, check the Node.js official website, and download/ install the latest and stable release.

    To verify if node.js was successfully installed, paste the command below on your Command Line Interface (CLI) to check the version of node.js installed.

      // terminal
      node --version
    
  • Set up a simple Node.js app

    Create a directory for your application, I will create mine on the desktop using the CLI. I am using the Windows operating system and VS Code editor.

      // terminal 
      cd desktop 
      mkdir my-nodejs-app //create a project directory
      cd my-nodejs-app // navigate to the app directory
      npm init -y // create a default package.json file
      npm install express dotenv passport passport-google-oauth20 express-session // install necessary dependencies
      code . // to open the directory on my code editor (VS Code). You can do it manually.
    
  • Modify package.json file

    Configure the JSON file to get connected to the server.js file, for the application to use the ECMAScript 6 (ES6) modules, and to run a development server using the --watch flag.

      //package.json
      {
        "name": "my-nodejs-app",
        "version": "1.0.0",
        "description": "",
        "type": "module", // add this to use the ES6 
        "main": "server.js", // update this to 
        "scripts": {
          "dev": "node --watch server.js" // script to run a development server
        },
        "keywords": [],
        "author": "",
        "license": "ISC",
        "keywords": [],
        "author": "",
        "license": "ISC",
        "dependencies": {
          "dotenv": "^16.4.5",
          "express": "^4.19.2",
          "express-session": "^1.18.0",
          "passport": "^0.7.0",
          "passport-google-oauth20": "^2.0.0"
        }
      }
    
  • Create the Server

    Create an server.js file in the base of the directory to set up our project server.

      // server.js
    
      // import necessary depenencies
      import "dotenv/config";
      import express from "express";
      import passport from "passport"; 
      import { Strategy as GoogleStrategy } from "passport-google-oauth20";
      import session from "express-session";
    
      // intialize app and define the server port
      const app = express();
      const port = process.env.PORT || 8000;
    
      // a middleware to access json data
      app.use(express.json());
    
      // a view to check if the server is running properly 
      // check `http://127.0.0.1:${port}/` -> http://127.0.0.1:800
      app.get("/", (req, res) => {
        res.send(`My Node.JS APP`);
      });
    
      // a function to start the server  and listen to the port defined
      const start = async () => {
        try {
          app.listen(port, () => console.log(`server is running on port ${port}`));
        } catch (error) {
          console.log(error);
        }
      };
    
      // call the function
      start();
    
  • Generate a Google client Oauth credentials

    You have to generate a Google client Oauth credentials(Client ID and Secret), if you are new to this, check out tutorials on how to go about it.

  • Create a.envfile

    Make sure dotenv dependency is installed and imported into your server.js file. Use the format below to set the .env file.

      //.env
      // make sure these values are correct
      GOOGLE_CLIENT_ID= // your google client id
      GOOGLE_CLIENT_SECRET= // your google client client
      SESSION_SECRET= // any randome secure characters
      PORT= 8000 // define port from the env file
    
  • Createpassport.jsfile

    Create an utils folder in the project directory base and create passport.js file. This is where the connection of our Node.js app to the Google Oauth App created on the Google console takes place. Check the code snippet.

  • Update theserver.js

    The application session(middleware) must be initialized and configured to Google passport. The route for the authentication and the callback needs to be defined. Check the code snippet.

Test your Node.JS Application

  • Run server(dev)

    Based on the custom configuration in the package.json file, to run the development use the command npm run dev

  • Authenticate a user

    Click this link http://127.0.0.1:8000/auth/google if your server is running on port 8000. You should see a page like the one below.

    After selecting an email address, it should return JSON data of that particular account.

Conclusion

I hope you found the article helpful and were able to implement the Google authentication in your Node.js application. You can check out the tutorial source code.

If yes, do well to like and share this piece and comment with me on Linkedin, Twitter and GitHub. And if you like what you read and want to show support, you can buy me coffee😉.

]]>
<![CDATA[JWT Custom Authentication for Django Application]]>https://chryzcode.hashnode.dev/jwt-custom-authentication-for-django-applicationhttps://chryzcode.hashnode.dev/jwt-custom-authentication-for-django-applicationMon, 18 Mar 2024 11:56:43 GMTIntroduction

What is the good of a web application without an efficient authentication system?

In this article, I will share how to create a simple and effective authentication for your Django web application.

By default, Django uses the built-in basic authentication system, i.e. (using an email/ username and password to log in directly) how efficient can this be with an Application Programming Interface(API) without tokens for authentication?

Introducing Simple JSON Web Token (JWT) it provides a JSON Web Token authentication backend for a Django REST Framework application.

Let's start building

  • Create Django Application

    Navigate to the directory of your choice on the terminal and create your Django application.

      cd desktop # navigated to the desktop directory (windows)
      django-admin --version # check if django is installed
      django-admin startproject drf_auth_proj # create django project
      cd drf_auth_proj # naviage to the project directory
      django-admin startapp drf_app # create a django application
    
  • Create a Virtual Environment(optional)

      virtualenv venv # created a virtual environment named venv
      venv\Scripts\activate # activate virtual environment (windows)
    
  • Install Necessary Dependencies

      pip install djangorestframework # install drf(installs django by default)
      pip install djangorestframework-simplejwt # install simple jwt
      # add dependencies to requirements.txt file
      pip freeze > requirements.txt #make sure the virtulal environment is activated
    
  • Application Configuration

    We are adding some configurations in the settings.py file(Django app, dependencies).

      #settings.py
      INSTALLED_APPS = [
          # add 
          'drf_app', # django application
          'rest_framework', # django rest framework
          'rest_framework_simplejwt.token_blacklist', #(JWT BLACKLIST CONFIG)
      ]
    
      # set simple JWT to default authentication
      REST_FRAMEWORK = {
          'DEFAULT_AUTHENTICATION_CLASSES': (
              'rest_framework_simplejwt.authentication.JWTAuthentication',
          )
      }
    
  • Create a URL file in the application directory(drf_app)

      #drf_app/urls.py
      from django.urls import path
      from rest_framework_simplejwt.views import (
          TokenObtainPairView,
          TokenRefreshView,
      ) # import views from JWT 
    
      urlpatterns =  [
          #JWT
          path('token/', TokenObtainPairView.as_view(), name='token_obtain_pair'),
          path('token/refresh/', TokenRefreshView.as_view(), name='token_refresh'),
      ]
    
  • Add the application URL to the project URL file

      # drf_auth_proj/urls.py
      from django.urls import path, include # import include
      urlpatterns = [
    
          path('api/v1/', include('drf_app.urls')), #add app urls file
      ]
    
  • Create customized token-obtain serializer(optional)

    This is to add more data/information to a token. The code below adds/encrypts a user's email, and first and last name to the token.

      # drf_app/views.py
    
      from rest_framework_simplejwt.serializers import TokenObtainPairSerializer
    
      class MyTokenObtainPairSerializer(TokenObtainPairSerializer):
          @classmethod
          def get_token(cls, user):
              token = super().get_token(user)
    
              # Add custom claims based on your user model fields
              token['email'] = user.email
              token['username'] = user.username
              # token['first_name'] = user.first_name
              # token['last_name'] = user.last_name
              return token
    
  • More JWT configurations

    
      from datetime import timedelta
    
      SIMPLE_JWT = {
          "ACCESS_TOKEN_LIFETIME": timedelta(minutes=5), 
          "REFRESH_TOKEN_LIFETIME": timedelta(days=30),
          "ROTATE_REFRESH_TOKENS": True,
          "BLACKLIST_AFTER_ROTATION": True,
          "UPDATE_LAST_LOGIN": False,
    
          "ALGORITHM": "HS256",
          "VERIFYING_KEY": "",
          "AUDIENCE": None,
          "ISSUER": None,
          "JSON_ENCODER": None,
          "JWK_URL": None,
          "LEEWAY": 0,
    
          "AUTH_HEADER_TYPES": ("Bearer",),
          "AUTH_HEADER_NAME": "HTTP_AUTHORIZATION",
          "USER_ID_FIELD": "id",
          "USER_ID_CLAIM": "user_id",
          "USER_AUTHENTICATION_RULE": 
           "rest_framework_simplejwt.authentication.default_user_authentication_rule",
    
          "AUTH_TOKEN_CLASSES": ("rest_framework_simplejwt.tokens.AccessToken",),
          "TOKEN_TYPE_CLAIM": "token_type",
          "TOKEN_USER_CLASS": "rest_framework_simplejwt.models.TokenUser",
    
          "JTI_CLAIM": "jti",
    
          "SLIDING_TOKEN_REFRESH_EXP_CLAIM": "refresh_exp",
          "SLIDING_TOKEN_LIFETIME": timedelta(minutes=5),
          "SLIDING_TOKEN_REFRESH_LIFETIME": timedelta(days=1),
    
          "TOKEN_OBTAIN_SERIALIZER": 
         "rest_framework_simplejwt.serializers.TokenObtainPairSerializer",
          "TOKEN_REFRESH_SERIALIZER": 
          "rest_framework_simplejwt.serializers.TokenRefreshSerializer",
          "TOKEN_VERIFY_SERIALIZER": 
          "rest_framework_simplejwt.serializers.TokenVerifySerializer",
          "TOKEN_BLACKLIST_SERIALIZER": 
           "rest_framework_simplejwt.serializers.TokenBlacklistSerializer",
          "SLIDING_TOKEN_OBTAIN_SERIALIZER": 
         "rest_framework_simplejwt.serializers.TokenObtainSlidingSerializer",
          "SLIDING_TOKEN_REFRESH_SERIALIZER": 
         "rest_framework_simplejwt.serializers.TokenRefreshSlidingSerializer",
          "TOKEN_OBTAIN_SERIALIZER": "drf_app.views.MyTokenObtainPairSerializer", }
    
  • Migrate the changes to the database

      # on the terminal
      python manage.py migrate
    
  • Create Super User

      python manage.py createsuperuser
    
  • Check the Admin Page (optional)

    If you can remember, we did some token blacklist configuration. It saves all tokens generated and makes sure it is used only once.

  • Generate Token

    Make sure the server is running python manage.py runserver. Then, open the Token Obtain Pair URL on a browser and enter the necessary details(username and password).

    • Decode the Token Generated

      Visit the JSON Web Token website https://jwt.io/ and paste any of your tokens there. The email and username field in the image below results from the custom Token Obtain Pair Serializer views.


      Here is the link to the project's repository for reference sake.

      Conclusion

      I hope you found the article helpful and created a JWT authentication for your Django application.

      If yes, do well to like and share this piece and comment with me on Linkedin, Twitter and GitHub. And if you like what you read and want to show support, you can buy me coffee😉.

]]>
<![CDATA[What is SQL and SQLite?]]>https://chryzcode.hashnode.dev/what-is-sql-and-sqlitehttps://chryzcode.hashnode.dev/what-is-sql-and-sqliteFri, 19 Jan 2024 06:23:22 GMTWhy this title/ subject matter?

As a software engineer, I had to use SQLite in a product; I learnt something new and saw the importance of using it because I use PostgreSQL more, and I made a post about it on X(Twitter)

Then, an account replied with a comment seeking clarity about SQL and SQLite.

More detailed content would be more insightful because why not?

What is SQL?

Structured Query Language is a programming language designed and utilized for storing, managing, processing and manipulating relational databases. A relational database uses rows and columns to store data in a tabular form. E.g. MySQL, PostgreSQL, SQLite, Microsoft SQL Server, and Oracle Database.

It was initially known as the Structured English Query Language (SEQUEL).

What is SQLite?

SQLite is a C-language library for implementing a small, fast, self-contained, high-reliability, full-featured SQL database engine (according to www.sqlite.org).

It is a library that binds to many programming languages and provides a relational database management system (RDBMS). The entire database is stored in a single disk file.

Differences between SQL and SQLite

There are quite a lot of differences, but a few basic ones will be outlined:

  • SQL is used by different SQL databases like MySQL, SQLite and PostgreSQL, while SQLite uses SQL

  • SQL is a query language, while SQLite is a database resource.

  • SQL is used to query a Relational Database System, while SQLite is a Relational Database Management System.

  • SQL is a standard for creating relational schema, while SQLite is file-based.

Use Cases of SQL and SQLite

SQL and SQLite might seem to have much in common to the extent of the naming, but they have different use cases. A basic few will be mentioned below:

SQL

  • Management of relational databases

    The Relational Database Management System (RDMS) is software for managing relational databases and was built using the Structured Query Language (SQL). Therefore, the management and maintenance of relational databases can be done with SQL.

  • Performing basic database operations

    SQL uses specific keywords to perform basic database functionalities like Creating, Reading, Updating and Deleting (CRUD) data.

  • SQL for websites

    Most interactive and e-commerce websites, especially those with lots and tons of data, use SQL to fetch, retrieve and store data from their database when needed or required.

  • Integration with other scripting languages

    SQL is integrated and supported by scripting languages like Python and R. Therefore, SQL can be used to manage databases in such languages.

SQLite

  • Websites

    SQLite database engine can be used for storing the data of a website. It has a large bandwidth to operate with high-traffic websites and applications.

  • Fast and quick server-side database integration

    The SQLite database can be the primary or secondary storage engine or database for server-side applications. It is also advisable to use SQLite database for mini-based applications, development environments, and Internal and temporary usage because of its flexibility, simplicity and speed.

    Developers report that SQLite is often faster than a client/server SQL database engine.

  • Experimental SQL language extensions

    The simplicity and modular design of the SQLite database make it a good platform for prototyping new, experimental database language features or ideas.

Conclusion

After going through and reading this article, I hope you were able to know and understand more about what SQL and SQLite are, their differences and use cases.

If yes, do well to like and share this piece and comment with me on Linkedin, Twitter and GitHub. And if you like what you read and want to show support, you can buy me coffee😉.

]]>
<![CDATA[Best Practices For Deploying Django Applications(Production Environment and Hosting)]]>https://chryzcode.hashnode.dev/best-practices-for-deploying-django-applicationsproduction-environment-and-hostinghttps://chryzcode.hashnode.dev/best-practices-for-deploying-django-applicationsproduction-environment-and-hostingTue, 21 Nov 2023 12:36:37 GMTIntroduction

Hosting and deploying projects is a core and important phase of software and web development. What's the joy, happiness and pride in building a project or product and not being able to share it with the world? How can constructive feedback that promotes improvement be gotten? This has been an issue or problem faced by many developers (myself included), especially newbies.

Building a project in a local environment is different from that of a production environment because of a lot of configurations involved which will shared in this article for Django projects using a PostgreSQL database on the Heroku platform.

Why PostgreSQL Database and Heroku?

You might be wondering why a PostgreSQL database and Heroku for deploying and hosting. If you are curious about this continue reading and if not you can skip it.

PostgreSQL Database

The default database for a Django project is SQLite, it is efficient to use in a local environment but not a production environment. These are a few of the reasons that justify the statement aforementioned:

  • The bandwidth of PostgreSQL is wider and stronger.

  • There are lots of hosting platforms that offer PostgreSQL database services.

  • The PostgreSQL database file does not need to be in the project folder or directory before functioning, unlike SQLite. (The Host of the database made it possible).

    • Databases should not be exposed/ revealed publicly(i.e. you can not push your database to a version control system. It needs to be hidden and this makes an SQLite database unavailable for deployment.
  • PostgreSQL is versatile. It can be used in both a local and production environment(Synchronization and unity of data)

There are other options when it comes to the choice of database like Oracle, MySQL, MariaDB etc. but we will not be heading in that direction in this article.

Heroku

There is a need for a hosting and deploying platform and there are quite a variety of them like Render, Fly, BlueHost, AWS, Google Cloud, Railway etc. Below are a few reasons why I chose Heroku despite their change of billing policies which has been for a while now:

  • The configuration process is not difficult and frustrating.

  • Heroku has 3 deployment methods, deploying using the Heroku CLI, GitHub(through the website) and Container Registry. In this article, we will be using GitHub which is the easiest of all.

  • Creation Heroku applications are free but to use addons(resources), like Heroku PostgreSQL you need to add a debit/ credit card and the plans are fair.

Getting started

Prerequisites and Requirements

Here are the prerequisites and requirements to get started deploying your Django application on Heroku:

Configuring settings for static files

What are static files?

They are files that can not be converted, modified, changed or processed when an application is running. Examples are Javascript and CSS files, images etc. To make Heroku serve these files as they ought to be, the following steps need to be taken.

  • Install Whitenoise

    With a couple of lines of config, WhiteNoise allows your web app to serve static files, making it a self-contained unit that can be deployed anywhere without relying on nginx, Amazon S3 or any other external service. (Especially useful on Heroku, OpenShift and other PaaS providers.)#make sure.

      #make sure your project virtual environment is activated
      pipenv install whitenoise
    
  • Configuring whitenoise in settings.py file

      #setting the directory and root of the staticfiles for accesibility
      STATICFILES_DIRS = [os.path.join(BASE_DIR, 'staticfiles')]
    
      #whitenoise configuration
      STATICFILES_STORAGE = "whitenoise.storage.CompressedManifestStaticFilesStorage"
    

Setting Heroku and project up for deployment

To deploy the application, both the Heroku CLI and the website will be used. To verify if you have Heroku installed properly, use the command below;

#check for the version of Heroku installed
heroku -v

#install django-heroku package in your project
pipenv install django_heroku

#install gunicorn
pipenv install gunicorn

# to use postgresql in our django hosted project
pipenv install psycopg2-binary
  • Create a Procfile in your project

    It is a file that specifies the commands that are executed by a Heroku app on startup. Make sure it is located at the base path of the project. Insert the code below into the Procfile

      # it connects to the wsgi file of the project
      web: gunicorn my_project.wsgi --log-file -
    
  • Create an application on Heroku

  • Create a Postgres Database on Heroku

    While on the newly created application click on the Resources tab search and click Heroku Postgres on Add-ons search bar. Choose your desired plan and click on it after it has been created to see the database credentials details.

  • Install django-decouple

    It is a Python library aimed at making it easier for developers to separate their configuration settings from code

      pipenv install python_decouple
    
  • settings.py configuration

      #add this at the begining of settings.py file
      from decouple import config
      import django_heroku
    
      # update these
      SECRET_KEY = config('SECRET_KEY')
    
      # SECURITY WARNING: don't run with debug turned on in production!
      DEBUG = config("DEBUG", default=False, cast=bool)
    
      # the last value is the url of the Heroku app, remove the https:/
      ALLOWED_HOSTS = ["127.0.0.1", "localhost", "my-test-django-project-9a47545252ae.herokuapp.com"]
    
      #update the database from sqlite to postgres
      DATABASES = {
          'default': {
              'ENGINE': 'django.db.backends.postgresql_psycopg2',
              "NAME": config("DB_NAME"),
              "USER": config("DB_USER"),
              "PASSWORD": config("DB_PASSWORD"),
              'HOST': config("HOST"),
              'POST': '5432',
          }
      }
    
      # Activate Django_heroku.
      django_heroku.settings(locals())
    
  • Create .env and .gitignore file

    A .env file is where the secrets and sensitive keys of a project are kept to prevent exposure especially when pushed to GitHub, GitLab etc. Link to a git ignore file

    See to it that both files are located at the base path of the project.

      DEBUG=True
      SECRET_KEY=jferjrjtgotuggfuopfddl #just a sample 
      DB_NAME=#database name
      DB_USER=#user
      DB_PASSWORD=#password
      HOST=#the host
    
  • Delete sqlite database db.sqlite3 and migrate

      python manage.py migrate
    
  • Add .env details

    Go to the application on the Heroku website and click on settings tab and the Reveal Config Vars button to add all the details in the .env files.

  • Deployment

    As said earlier, we will be deploying using the GitHub method on Heroku, so make sure to push your code to GitHub. Navigate to the deploy tab to connect the application to the GitHub repository. Then, scroll down and click the deploy branch button to start the deployment process.

You should have your hosted project running live on Heroku. Hope you enjoyed the hands-on tutorial-based-article

]]>
<![CDATA[Build a Custom Functional Django Project]]>https://chryzcode.hashnode.dev/build-a-custom-functional-django-projecthttps://chryzcode.hashnode.dev/build-a-custom-functional-django-projectMon, 13 Nov 2023 08:08:28 GMTIntroduction

In this article, we will build a note project to cover the major scope and aspects of building real-world projects using Django.

Create a virtual environment

A virtual environment is a tool that helps store dependencies for a specific Django application, not on a global scope on your laptop or computer.

#if you have python installed properly, pip should be available automatically
#pip is a python package manager/ installer
pipenv shell
#the command above should create a virtual environment if ran on your terminal in the project path

Installing Django

pipenv install django

After successfully running the command above a Pipfile and Pipefile.lock file will be created automatically.

  • Pipfile

    Pipfile is the file used by the Pipenv virtual environment to manage project dependencies and keep track of each dependency version.

  • Pipfile.lock

    Pipfile.lock leverages the security of package hash validation in pip. This guarantees you're installing the same packages on any network as the one where the lock file was last updated, even on untrusted networks.

Create note models

from django.db import models
#use django user user model
from django.contrib.auth.models import User

# Create your models here.
#Note model
class Note(models.Model):
    user = models.ForeignKey(User, on_delete=models.CASCADE)
    title = models.CharField(max_length=200)
    body = models.TextField(null=True, blank=True)
    updated = models.DateTimeField(auto_now=True)
    created = models.DateTimeField(auto_now_add=True)

    # ordering notes in list view with the just created or updated ones
    class Meta:
        ordering = ['-updated', '-created']

    # if a note object is called 50 characters of the title will shown
    def __str__(self):
        return self.title[0:50]

Add Django auth URLs

Since we will not be creating custom views authentication add the code below to your project my_project URL file

from django.contrib import admin
from django.urls import path, include


urlpatterns = [
    path('admin/', admin.site.urls),
    path('', include('my_app.urls')),
#Django auth default url
    path('', include('django.contrib.auth.urls')),
]

Create migration

The command below creates a file which will have a database schema based on the models in the models.py file in the migration folder.

python manage.py makemigrations

#This should be the response diplayed after running it on the terminal
#Migrations for 'my_app':
  #my_app\migrations\0001_initial.py
    #- Create model Note

Create database

To create the project database run the command below. This command also creates necessary tables like notes and schemas like user , sessions etc.

python manage.py migrate

#and you can run the server
python manage.py runserver

Create a superuser

In a Django project, there are superusers and normal users and the major difference between them is that superusers have access and permission to the project admin page to manage the project's models and data.

python manage.py createsuperuser

Add notes model to Django admin

To access your notes models and play around it using the Create, Read, Update, Delete (crud) functions on the Django admin, the notes model needs to be registered on the admin.py file.

from django.contrib import admin
from .models import Note

# Register your models here.
admin.site.register(Note)

To have a view of the Django admin page make sure the server is up and running and open this link on the browser http://127.0.0.1:8000/admin/. You can only log in with a superuser account.

The CRUD functions can now be done on the Notes models.

Create custom application interfaces and functions

Instead of using the Django admin page, a custom interface and functions for the project will be created.

  • Create forms(forms.py)

    The file forms.py will be created customarily in the application folder my_app

      from django import forms
      from .models import Note
    
      #create a form based on the Note model
      class noteForm(forms.ModelForm):
          class Meta:
              model = Note
              #form fields/inputs that will be shown
              fields = ['title', 'body']
              #added a css class and html placeholder to the form inputs
              #the form-control css class is from bootstrap
              widgets={
                      'title':forms.TextInput(attrs={'class':'form-control', 'placeholder':'Note title'}),
                      'body':forms.Textarea(attrs={'class':'form-control',  'placeholder':'Start writing...'}),
              }
    
  • Create the project functions(views.py)

      from django.shortcuts import render, redirect
      from .models import Note
      #import the noteform
      from .forms import noteForm
      from django.contrib.auth.decorators import login_required
      from django.contrib.auth.models import User
    
      # Create your views here.
    
      #login_required makes sure a user is authenticated before a view
    
      #get all the notes of the currently logged in user
      @login_required(login_url='login')
      def myNotesList(request):
          context = {}
          notes = Note.objects.filter(user=request.user)
          context['notes'] = notes
          return render(request, 'note-list.html', context)
    
      #add a new note
      @login_required(login_url='login')
      def addNote(request):
          context = {}
          form = noteForm
          if request.method == 'POST':
              note = Note.objects.create(
                  user = request.user,
                  title = request.POST.get('title'),
                  body = request.POST.get('body')
              )
              return redirect('view-note', pk=note.pk)
          context['form'] = form
          return render(request, 'add-note.html', context)
    
      #edit a specific note
      @login_required(login_url='login')
      def editNote(request, pk):
          note = Note.objects.get(pk = pk)
          if request.user.id == note.user.id:
              form = noteForm(instance=note)
              if request.method == 'POST':
                  form = noteForm(request.POST, instance=note)
                  if form.is_valid():
                      form.save()
                      return redirect('view-note', pk=note.pk)
              context = {'form':form}
              return render(request, 'edit-note.html', context)
          return redirect('notes-list')
    
      #view a specific note
      @login_required(login_url='login')
      def viewNote(request, pk):
          context = {}
          note = Note.objects.get(pk = pk)
          if request.user.id == note.user.id:
              context['note'] = note
              return render(request, 'view-note.html', context)
          return redirect('notes-list')
    
      #delete a specific note
      @login_required(login_url='login')
      def deleteNote(request, pk):
          note = Note.objects.get(pk=pk)
          if request.user.id == note.user.id:
              note.delete()
              return redirect('notes-list')
          return redirect('notes-list')
    
      ##delete the logged in user account
      @login_required(login_url='login')
      def deleteUser(request):
          user = request.user
          user.delete()
          return redirect('login')
    
    • Create URLs patterns

        #urls.py
        from django.urls import path
        from . import views
      
        urlpatterns =[
            path('', views.myNotesList, name='notes-list'),
            path('add-note/', views.addNote, name='add-note'),
            path('edit-note/<str:pk>/', views.editNote, name='edit-note'),
            path('view-note/<str:pk>/', views.viewNote, name='view-note'),
            path('delete-note/<str:pk>/', views.deleteNote, name='delete-note'),
            path('delete-user/', views.deleteUser, name='delete-user'),
        ]
      

      Add the Login and Logout Redirect URL

      This piece of code is to be in the settings.py and its purpose is to redirect a user to a certain URL/page after logging in or logging out.

        #settings.py
        import os
      
        #where your static files will be located e.g css, ja and images
        STATIC_ROOT = os.path.join(BASE_DIR, 'static')
      
        LOGIN_REDIRECT_URL = "notes-list"
        #we can access the login url through the Django defauly auth urls
        LOGOUT_REDIRECT_URL = "login"
      

Create template and static files(.html and .css)

This should be an overview of how the static and template files should be arranged.

  • Create styles.css file

    This is the file where we write the stylings of the app(CSS).

    • Create a static folder in the application folder my_app

      • Inside the static folder create a css folder

        • Then create the styles.css file inside the css folder.

            * {
              margin: 0;
              padding: 0;
            }
          
            body {
              font-family: "Montserrat", sans-serif;
              background-color: #1f2124;
              color: white;
            }
            .fa.fa-google {
              margin-right: 7px;
            }
          
            .page-header {
              text-align: center;
              font-size: 30px;
              font-weight: 600;
              color: orange;
            }
          
            .login-page-container {
              margin-top: 40px;
            }
          
            .login-container {
              border: 3px solid #252629;
              border-radius: 8px;
              margin-left: auto;
              margin-right: auto;
              margin-top: 50px;
              width: 30%;
              height: 40vh;
            }
          
            .login-container > p {
              text-align: center;
              font-size: 22px;
              margin-top: 15px;
            }
          
            .login-btn {
              margin-left: auto;
              margin-right: auto;
              display: block;
              width: 65%;
              margin-top: 70px;
            }
          
            .login-btn:hover {
              background-color: #252629;
            }
          
            .notes-container {
              margin-left: auto;
              margin-right: auto;
              margin-top: 60px;
              display: block;
              border: 3px solid #252629;
              width: 500px;
              border-radius: 8px;
            }
          
            .note-title {
              margin-left: 15px;
              font-size: 18px;
              padding: 15px;
              color: white;
              text-decoration: none;
            }
          
            .note-title > a {
              margin-left: 15px;
              font-size: 18px;
              color: white;
              text-decoration: none;
            }
          
            .note-title > a:hover {
              margin-left: 10px;
              color: orange;
              text-decoration: none;
            }
          
            .note-header {
              margin-top: 20px;
              padding-left: 30px;
              padding-right: 50px;
              color: orange;
              border-bottom: 3px solid orange;
            }
          
            .note-header > a {
              text-decoration: none;
              color: orange;
            }
          
            .note-logo {
              margin-right: 15px;
            }
          
            .note-count {
              font-size: 19px;
              float: right;
              padding-right: 10px;
            }
          
            .note-created {
              display: flex;
              justify-content: right;
              align-items: center;
              font-size: 10px;
            }
          
            .note-list {
              border-bottom: 1px solid #252629;
              height: 60px;
            }
          
            .note-list:hover {
              background-color: #252629;
            }
          
            #add-note-icon {
              display: flex;
              justify-content: right;
              align-items: center;
              font-size: 30px;
            }
          
            label {
              display: none;
            }
          
            .a-note-title {
              color: orange;
              text-align: center;
              padding: 10px;
            }
          
            .btn.btn-secondary {
              justify-content: right;
              align-items: center;
              background-color: rgba(255, 166, 0, 0.576);
            }
          
            #back-to-notes-list {
              font-size: 30px;
              /* padding: 8px; */
            }
          
            .note-detail-header {
              padding-left: 10px;
              padding-right: 10px;
            }
          
            .icons > a {
              color: white;
              text-decoration: none;
            }
          
            .note-detail-header > a {
              color: white;
              text-decoration: none;
            }
          
            .icons {
              display: flex;
              align-items: center;
              justify-content: right;
            }
          
            #edit-note {
              font-size: 20px;
            }
          
            #delete-note {
              font-size: 20px;
            }
          
            .note-body {
              padding: 10px;
              margin-left: 7px;
              margin-right: 7px;
              display: block;
            }
          
            .markdown-support-note {
              margin-top: 10px;
              color: orange;
              text-align: center;
            }
          
            .dev-info {
              display: flex;
              justify-content: space-between;
              align-items: center;
              margin-top: 100px;
              font-size: 25px;
              color: orange;
            }
          
            .dev-info > span > a {
              text-decoration: underline !important;
              color: orange !important;
            }
          
            .dev-info > a > i {
              font-size: 40px;
              color: orange;
            }
          
            @media all and (min-width: 100px) and (max-width: 600px) {
              .notes-container {
                width: 100%;
              }
          
              .login-container {
                width: 100%;
              }
            }
          
  • Create the custom views template

    Create a template folder in the application folder my_app and

    • Create registration folder

      • Create login.html file

          {% extends 'base.html'%}
          {% load static %}
          <title>{% block title %}Sign In || My Note App{% endblock %}</title>
          {% block content %}
        
          {% if user.is_authenticated %}
          <p></p>
          {% else %}
          <div class="login-page-container">
              <h3 class="page-header" >Sign In</h3>
              <div class="login-container">
                  <p>My Notes App</p>
                  {% if not user.is_authenticated %}
              {% if messages %} {% for message in messages %}
              <div class="text-center alert alert-{{ message.tags }}">{{ message|safe }}</div>
              {% endfor %} {% endif %} {% if form.errors %}
              <p style="font-size: 20px; margin-left: 25px">Your username and password did not match. Please try again.</p>
              {% endif %}
              <form action="" method="post">
                {% csrf_token %}
                <div class="mb-3">
                  <label id="login-label" for="username" class="form-label">Username:</label>
                  <input id="login-form" type="text" class="form-control" name="username" id="username" placeholder="Username" />
                </div>
                <div class="mb-3">
                  <label id="login-label" for="password" class="form-label">Password:</label>
                  <input
                    id="login-form"
                    type="password"
                    class="form-control"
                    name="password"
                    id="password"
                    placeholder="Password"
                  />
                </div>
                <div id="login-btn">
                  <input class="btn btn-secondary" type="submit" value="Login" />
                </div>
              </form>
              <h5 style="text-align: center; bottom: -50px; position: relative;">
                Yet to have an account? <a href="register/">Sign up</a>
              </h5>
              {% else %}
              <br /><br />
              <p style="font-size: 30px; text-align: center; font-weight: 600">You are already logged in.</p>
              {% endif %}
              </div>
          </div>
          <p class="markdown-support-note">markdown supported</p>
          {% endif %}
          {% endblock %}
        
    • Create add-note.html

        {% extends 'base.html' %}
        <title>{% block title %}Add note || My Note App{% endblock %}</title>
        {% block content %}
      
        <div class="notes-container">
          <h4 class="a-note-title">Add a note</h4>
          <form method="POST">
            {% csrf_token %} {{ form.as_p }}
            <button class="btn btn-secondary sm" type="submit">save</button>
          </form>
        </div>
      
        {% endblock %}
      
    • Create base.html

      This file contains the <head>base.html</head> and the nav of all the template pages. Get the code from this link base.html

    • Create edit-note.html

        {% extends 'base.html' %}
        <title>{% block title %}Edit note|| My Note App{% endblock %}</title>
        {% block content %}
      
        <div class="notes-container">
            <h4 class="a-note-title" >Edit note</h4>
            <form method="POST">
            {% csrf_token %}
            {{ form.as_p }}
            <button class="btn btn-secondary sm" type="submit">save</button>
        </form>
        </div>
      
        {% endblock %}
      
    • Create note-list.html

        {% extends 'base.html' %}
        <title>{% block title %}Note list || My Note App{% endblock %}</title>
        {% block content %}
        <div class="notes-container">
          <div class="note-header">
            <h5>
              <span class="note-logo">&#9782;</span>{{request.user}}'s note
              <span class="note-count">{{notes.count}}</span>
            </h5>
            <a href="{% url 'add-note' %}"><span id="add-note-icon" class="material-icons">add_circle</span></a>
          </div>
          {% for note in notes %}
          <div class="note-list">
            <div class="note-title">
              <a href="{% url 'view-note' note.pk %}">{{ note }}</a>
              <small class="note-created">{{note.created}}</small>
            </div>
          </div>
      
          {% endfor %}
        </div>
        {% endblock %}
      
    • Create view-note.html

        {% extends 'base.html' %}
        <title>{% block title %}Note || My Note App{% endblock %}</title>
        {% block content %}
        <div class="notes-container">
          <div class="note-detail-header">
            <a href="{% url 'notes-list' %}"><span id="back-to-notes-list" class="material-icons">chevron_left</span></a>
            <span class="icons">
              <a href="{% url 'edit-note' note.pk%}"><span id="edit-note" class="material-icons">edit</span></a>
              <a href="{% url 'delete-note' note.pk%}"><span id="delete-note" class="material-icons"> delete </span></a>
            </span>
          </div>
          <h4 class="a-note-title">{{note}}</h4>
          <div class="note-body">{{ note.body}}</div>
        </div>
      
        {% endblock %}
      

Our note application should be up, running and functional. I hope you enjoyed reading this article and building along side.

]]>
<![CDATA[Building a Custom Django Project/ Application(Folders and Files 2)]]>https://chryzcode.hashnode.dev/building-a-custom-django-project-applicationfolders-and-files-2https://chryzcode.hashnode.dev/building-a-custom-django-project-applicationfolders-and-files-2Sat, 04 Nov 2023 03:02:37 GMTIntroduction

What is a project or application that is not custom-made and per the intent of the developer or client?

A dream project or application is primarily engineered from the thought or what can be called inspiration.

In addition, this article will convey custom-made Django folders and files, the continuation of The Django Project Folder and Files Structure and Architecture 1.

Building Custom Django Application

Create an application URL file

Firstly, a urls.py file needs to be created in the Django application my_app because it is not always provided by Django(default).

The code below gives the file its full potential apart from its name; without it, the Django server will throw an error. The code below helps to initiate the process of creating the URL pattern of the application.

#the application url file
from django.urls import path

urlpatterns = [

]

Connect the application URL file to the project URL file.

In the project folder, my_project there is a URL file that needs to connect with the URL file of all the project's applications.

from django.contrib import admin
from django.urls import path, include


urlpatterns = [
    path('admin/', admin.site.urls),
#added the application url as the project base url pattern
    path('', include('my_app.urls')), 
]

include needs to be imported, and can be called the connection conjunction key in this case.

Connect the app to the project.

All Django applications need to be connected to the project, done in the settings file. settings.py

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',

    # put the name of the application
    'my_app',
]

Create our first Django web page.

We will override the default Django web page to a simple custom-based one. These changes will be made through the application views.py and urls.py files.

#the application urls.py file
from django.urls import path
#import everything in the application views file
from my_app.views import *

urlpatterns = [
    #base url pattern connected to customHomePage view
    #you can name a url path using the python keyword name
    path('', customHomePage, name='custom_home_page')
]
  • Django custom view using HttpResponse

    The view returns an HttpResponse object that contains the generated response. Each view function is responsible for returning an HttpResponse object.

#the application views.py file
from django.shortcuts import render
#import HttpResponse
from django.http import HttpResponse

#a simple function-based function
def customHomePage(request):
    #HttpResonse is to render contents/ strings on the page
    return HttpResponse('My Django application custom home page')
  • Django custom view using Template

    This requires creating an HTML template file and connecting to the view to render content on the web page.

def customHomePage(request):
    # return render(request, template_name='customHomePage.html')
    return render(request, 'customHomePage.html')

Your Django server http://127.0.0.1:8000/ should display the page shown below.

I hope you created your Django custom-made project with less difficulty and ease.

]]>
<![CDATA[The Django Project Folder and Files Structure and Architecture 1]]>https://chryzcode.hashnode.dev/the-django-project-folder-and-files-structure-and-architecture-1https://chryzcode.hashnode.dev/the-django-project-folder-and-files-structure-and-architecture-1Fri, 27 Oct 2023 21:33:35 GMTIntroduction

Django is an extensive framework of the language Python. Therefore, on this note, it should not be surprising that a Django project will include many significant files and folders if needed. This article will address the default folders and files provided by Django.

You might want to read this article of mine, How to Create a Django Project and Project, for the project sample that will be examined in this article or, better still, clone it from the GitHub website Django sample project.

Overview of the Django Project

  • Image of the Project

    Below is an image of the Django project and application. Specifically, this is the project's image from a code editor, VSCode.

The Application Folder(my_app)

This is a Django application folder, and it is possible to have more than a Django application based on the project's scope, but our sample project is one application-based. It hosts all the files and folders related to the application and even more, if the files are imported into other applications.

  • Migrations folder

    This is the folder where the schema files for creating and updating a database are kept. This is the command for making migrations. python manage.py makemigrations

    • The Init file __init__.py

      An experienced Python developer should know the work of this file. It is a Python file that marks a directory as a Python package. It is used to initialize the package when imported(i.e., it helps connect files from a Django folder/ application to one another).

      This file is for displaying your models on the project admin page. It is always in a Django application by default. It makes it easy for one to test models using a page/form created by the Django framework.

  • The Admin file admin.py

    This file is for displaying your models on the project admin page. It is always in a Django application by default. It makes it easy for one to test models using a page/form created by the Django framework.

  • The Models file models.py

    This is where you carve the tables and schema for the project and application database.

  • The Tests file tests.py

    For writing tests, check for errors and see that the codes run perfectly.

    Check one of my articles on Why Write Tests?

  • The Views file views.py

    The File for the application functions and rendering/ displaying data content on the project web application.

The Project Folder(my_project)

The folder that hosts files and folders related to the project in general. All applications in the project must be connected to this folder.

  • The Pycache folder __pycache__

    This folder consists of interpreted and optimized versions of codes. When executed, it converts to bytecode and ends with either a .pyc or .pyo extension.

  • The Asynchronous Server Gateway Interface (ASGI) file asgi.py

    It is for sending requests to asynchronous-capable Python programming language frameworks and applications. It allows developers to write web applications that can handle multiple requests at once without blocking the main thread.

  • The settings file settings.py

    This file is where the major configuration of the project and application resides; without it, the project will be unable to run.

  • The URLS file urls.py

    This file connects all the URL files in the application folder together. It provides different and unique major URL patterns (parameters) for the project.

  • The Web Server Gateway Interface (WSGI) file wsgi.py

    It is a mediator responsible for communicating between a web server and a Python web application. It explains how the web server communicates with the app and how it can be chained to process a request.

  • The SQLite Database.

    The database of the project. It is where the database schema is located.

  • The Manage file manage.py

    This file powers and engineers Django-based commands when written from the command line(e.g., python manage.py runserver , python manage.py createsuperuser ).


I hope you could understand more about the Django project and application folder and file, structure and architecture.

Continuation...

]]>
<![CDATA[How to Create a Django Project and Application.]]>https://chryzcode.hashnode.dev/how-to-create-a-django-project-and-applicationhttps://chryzcode.hashnode.dev/how-to-create-a-django-project-and-applicationFri, 20 Oct 2023 23:32:07 GMTIntroduction.

This article is a guide on how to create your (first) Django project and application.

A Little about Django.

The web framework for perfectionists with deadlines.

Django is a high-level Python web framework that encourages rapid development and clean, pragmatic design. Built by experienced developers, it takes care of much of the hassle of web development, so you can focus on writing your app without needing to reinvent the wheel. It’s free and open source.

Copied from the Django official website.

Interested in reading a little about Python, check out one of my articles The Language: Python.

Get started

Prerequisites and Requirements

Here are the prerequisites and requirements to get started in creating your Django application :

  • Install Python.

    Paste this command on your terminal. The command below is to verify if you have Python properly installed. It should provide the version of Python you installed.

      python --version
    
  • Install Django.

    The same thing applies to Django.

      django-admin --version
    

Create a Django Project.

I believe you have Python and Django installed. Navigate to the directory of your choice on your terminal, desktop is my choice of directory for my new Django project

cd desktop

and paste the command below to create your project, my_project is the name of my Django project.

django-admin startproject my_project

To check the files or folders in your project

#for MacOS
ls my_project

#for Windows
dir my_project

Create a Django Application

To create your Django application, copy and paste the command below on your terminal to change your directory to the newly created project.

#to change directory
cd my_project

#to create a django app
django-admin startapp my_app

Note: It is possible to have multiple applications based on the scope of the project.

Run and Test the Django Project

To check if our Django project is up and running, paste this code below on your terminal. The command is to run your server(app/project) locally.

python manage.py runserver

If the image below is the same as yours, then you have successfully created your Django project/ application.

The warning about unapplied migrations is related to the database, which will not be covered.

cmd image

To view the locally hosted project on your browser, click this link http://127.0.0.1:8000/. This is the local server link to your Django application, and this should be the view of your project on the browser.

localhost hosted website

Congratulations on creating your (first) Django application.

*Continuation...

]]>
<![CDATA[Data Protection and Security]]>https://chryzcode.hashnode.dev/data-protection-and-securityhttps://chryzcode.hashnode.dev/data-protection-and-securityThu, 01 Jun 2023 12:19:15 GMTIn our world today, data has turned out to be a very powerful tool and asset in the technological field and beyond. Data is at the core of every business. It is nearly impossible for a business to operate in today’s modern, digital world without producing, managing, analyzing and storing data about its operations, its services and products, and its customer base. This shows and depicts the importance of data and how it should be collected, processed and protected at all stages by a designed system preventing data breaches, data leaks and cyber-attacks which have turned out to be on the increase.

The rate at which data is being created and stored is high and unprecedented, making data protection and security increasingly become expedient and important. In addition, most business organisation and companies, if not all make use of data and also depend on it to operate, and a short period of downtime or data breach, a small amount of data loss can cause a major disaster for a business.

The rate at which cybercrime is happening is so alarming and this is a threat and challenge to the world of business and finance, health, technology and many more. To prevent, reduce and contain such threats and challenges, there are steps and processes to be taken to aid the protection and security of data which will be shared and discussed below.

Why is a Data Security/ Protection Strategy Essential?

Data Security/ Protection Strategy is important due to how essential data is to every and any organisation.

The absence or lack of good data security can lead to data loss, data leakage or data breakage which can bring about consequences for the business, company or organisation. It compromises the trust and integrity of the company to its customer.

Data are prone to attacks, incidents may occur either due to engineering errors, such as sending data to an external service, unknown to the security team; or through a malicious data theft act and without a good data security/ protection strategy a business empire can be so vulnerable till it crumbles and crashes.

The implications of a data breach or data loss incident can bring organizations to their knees. Failure to protect data can cause financial losses, loss of reputation and customer trust, and legal liability, considering most organizations today are subject to some data privacy standard or regulation. Data protection is one of the key challenges of digital transformation in organizations of all sizes.

An organization’s reputation can also be tainted, either from the data leaked from the data breakage or data loss itself or by the failure of the company's security.

Forms of Risks.

Data leakage or breaches, cyber attacks or data loss comes into being in either of the two forms mentioned below

  • Internal risks

    Internal risks include errors in IT configuration or security policies, the lack of strong passwords, poor authentication, and user access management, and unrestricted access to storage services or devices. A growing threat is malicious insiders or compromised accounts that have been taken over by threat actors.

  • External risks

    External risks include social engineering strategies such as phishing, malware distribution, and attacks on corporate infrastructure such as SQL injection or distributed denial of service (DDoS). These and many security threats are commonly used by attackers to gain unauthorized access to sensitive data and exfiltrate it.

Firstly, what is Data Protection?

Data protection is the process of protecting and securing sensitive information and data from damage, loss, corruption, compromise and attacks.

What is Data Security/ Protection Strategy?

A data security/ protection strategy is a mapped-out plan or defined design that includes measures taken, maintained and implemented for the sole purpose and reason of protecting data and reducing risk. This is accomplished by setting controls, authentication, encryption, and backups. It also defines which types of data should be backed up, how data should be recovered when a cyber hazard or attack occurs, which storage mediums/channels should be used and a lot more.

Best Practices of Data Protection/ Security Strategy.

  • Monitoring and Reviewing

    This helps the organisation to have a great view and track the activities of data flow and lifecycle to be transparent at various levels including the data collection/ creation, processing, storage, transmission, destruction, controls and liable risk which aids and helps in the protection and response to threats and cyber-attacks and data breaches and to also identify all valuable data assets, its associated level of risk and to test their security risk.

    In doing this, the weaknesses of an organisation's data flow system which may lead to the compromise of information can be discovered and worked upon to evade any form of breach.

  • Confidentiality, Integrity and Availability

    This known as the CIA triad is one of the major and main elements and factors that ensure the protection of data if properly defined and maintained. Information and data collected from clients must be secured, safe and free of any data leakage and breach. It must also be available when needed to be utilised by the organisation.

  • Data Lifecycle Management

    Data lifecycle management is a framework and structure that regularise the data processes and flow until it is destroyed or deleted.

  • Data Risk Management

    Data Risk Management involves the standards that identify breaches and attacks and create alerts for necessary steps to be taken to manage and mitigate the situation. Flow tracks data risks over time including a detailed remediation proposal. This includes sensitive data exposure risks, data mishandling, data access, networking risks, cloud configuration issues, and more.

  • Data Protection Policies and Procedures

    The policy and procedures of an organization are one of the basic and primary components of data protection. This defines the data protection of an organisation and how it is implemented and maintained. It tends to prevent and control data breaches internally and externally. The availability and presence of a policy that is laid out clearly and accessible to people will allow for more consistent data security and protection.

  • Data Access Management Controls

    Access management refers to the access shared by the company in getting, and fetching using data/ information from the company's database or system to users, staff, etc. It ensures authorised and unauthorised data. Strong data access control is a key requirement for both external auditors as well as regulatory enforcers such as the GDPR. External auditors mostly examine this.

  • Data Backup and Recovery

    Data backup tends to be helpful while experiencing data leaks or failures in the system. A data protection strategy should define which types of data should be backed up, how data should be recovered when a disaster occurs, and which storage mediums should be used.

  • Cybersecurity Management

    This involves the extensive protection of organisations' assets and data from cyber attacks company’s data as it flows across company networks. The policies and procedures laid down involve physical approaches to security management, such as password management, testing and training awareness for company employees, and comprehensive management reporting. An important factor in this strategy is the availability and activation of tools to protect against attacks and threats. Access by external cyber attacks presents organisations with unacceptable financial risk, which can lead to or result in the beginning of a great fall or crash.

  • Map Server Workload Data Flows

    Data flow mapping is an important element in identifying the threats and risks to which data is exposed. A standard data pathway should be defined. addition to actual data flows, any potential data pathways must also be defined. Data flows also encompass the entire chain from creation to transmission, processing, storage, archiving, and destruction.

  • Standards and Regulatory Compliance

    The standards set by the industry help to establish and maintain protection of organisations or companies' data protection and security.

    Regulatory compliance agencies define measures designed to protect data, which organizations are obliged by law to comply with. Each regulation is relevant to certain businesses, industries, and locations.

  • Tracking of All Available Data

    The presence and availability of a data inventory comprise and encompass all the information the organization stores or processes by the organization. This also involves data collection and processing, storage location, usage and sharing policies. This allows you to map your data systems and facilitate management.

  • Risk Analysis Conduction

    Some regulations require companies to proactively identify risks and take measures to mitigate them. Risk assessments are essential for making your organization accountable and allowing you to identify potential threats or deficiencies. Your business infrastructure is a complex web, with many pathways for transferring data—each pathway poses a potential risk, and you must protect the data even when being used by a third party.

    Perform a risk analysis to identify individual risks across your network. This will help inform your data protection policies.

]]>
<![CDATA[Machine Learning Pipeline Architecture]]>https://chryzcode.hashnode.dev/machine-learning-pipeline-architecturehttps://chryzcode.hashnode.dev/machine-learning-pipeline-architectureMon, 24 Apr 2023 08:00:42 GMTIntroduction.

In this article, a lot will be shared in the context and regards to machine learning pipeline architecture.

In our world, today, with how data is important and accessible, training a machine-learning model is highly possible. The presence of machine learning cannot be undermined especially in the field of automation, detection, prediction and technological assistance.

The creation and application of machine learning and models vary depending on the need and intended solutions. A view to machine learning (Models on Production) i.e(models on production environment) is administered through a certain infrastructure, Machine Learning Pipelines which we are going to explore today.

What is Machine Learning?

Machine learning is a subdivision/ subset of data science, a field of knowledge studying the extraction of value and meaningful insight from data. Meanwhile, machine learning suggests techniques and systems that train algorithms and programs on data to solve problems and make decisions with no or minimal rules, programming patterns and human intervention.

What is a Machine Learning Pipeline?

A machine learning pipeline is a technical infrastructure used to administer and automate machine learning processes and workflow, formatting raw data to intended output and valuable information.

Benefits of Machine Learning Pipeline Architecture.

Here are some of the benefits of machine learning pipeline architecture:

  • Flexibility

    It is possible to make over workflows without changing the rest and other parts of the system (computation units and components) for better implementation.

  • Extensibility

    It is easy and intuitive to create new functionalities, processes and components when the system is segregated into pieces.

  • Scalability

    The availability of component/ computation segregation and separation provides the ability to scale if there is an issue. Each part of the computation is presented through a standard interface.

  • Bugs Prevention

    Automated pipelines can prevent bugs. Manual machine learning workflow bugs might be really difficult to debug since inference of the model is still possible, but simply incorrect. With automated workflows, these errors can be prevented.

  • Less Cost

    It reduces the expenditure and costs of data science projects and products.

  • Less Consumption of Time

    It frees up development time for data scientists and increases their job satisfaction and experience. This improves efficiency and reduces the time spent getting set up on a new project and processes to update existing models.

Why does Machine Learning Pipeline Architecture Matter?

As algorithms start and begin to aid and enable machines to learn through data, it tends to be beneficial to both individuals and organisations in various aspects.

Below are a few reasons why machine learning pipeline architecture matter:

  • Timely Analysis And Assessment

    It helps to understand and come up with strategic options and alternatives by analysing and assessing real-time data of the same or related environment.

  • Real-Time Predictions

    Machine learning algorithms have been so beneficial to businesses by the provision of real-time predictions which tends to be closely accurate if not aiding in decisions making, implementation/ administration etc.

  • Transformation of Industries

    Machine learning has led to the transformation of industries with its ability and expertise to provide valuable insights in Real-Time environments and situations.

Adoption and When to Use Machine Learning Pipeline Architecture.

There are a lot of advantages provided by the machine learning pipeline but it is not to be used in every data science product or project, it depends on the intended purpose and how vast it is.

However, situations or circumstances whereby continuous updating of models requires fine-tuning, e.g.(models with real-time data, especially users or been used in software or an application).

Pipelines have also become very much essential as machine learning projects and products grow. If the dataset or resource requirements are large, it allows for easy infrastructure scaling. If repeatability is important, this is provided through the automation and the audit trail of machine learning pipelines.

Adoption of Machine Learning Pipeline.

As aforementioned, industries, companies and products/ projects with massive amounts of data tend to use the machine learning pipeline as it helps in the fast, easy and efficient implementation of tasks.

Here are a few industries that have adopted the technologies of the machine learning pipeline:

  • Financial services

    Businesses and financial industries and companies use machine learning technology to discover important insights into raw data and information. It is also used to prevent cyber attacks and fraudulent activities through detection, alert and cyber surveillance.

  • Government

    Collecting/creating, processing, storage, transmission and control of national data is a huge task and especially protection and public safety are of importance. Machine learning also helps in the efficiency of the various sector by mining multiple data sources for insights.

  • Healthcare

    In the healthcare field, machine learning technologies have helped in the analysation of data and information to diagnose medical illnesses and improve scientific treatment patterns.

  • Mining Industry

    Machine learning technologies have helped the mining industry by sourcing and analyzing resources (energy sources, minerals etc.). It has also made the process more efficient, cost-effective and less time-consuming.

Machine Learning Pipeline Architecture and Stages.

A machine learning pipeline comprises several stages. Data is processed in all stages for the cycle to run, and it is transmitted from one stage to the other. i.e., the output of a processing unit supplied as an input to the next step. There are different stages but we are checking out the four main and major stages Pre-processing, Learning, Evaluation, and Prediction.

  • Pre-processing

    Data processing is a process of basic transformation of data. Transforming raw data collected from users into an understandable and consumable format for the model. The outcome product of data pre-processing is the final dataset used for training the model and testing purposes.

  • Learning

    This process involves the extraction of the pre-processing output result(model understandable format) for the appropriate application in a new setting or circumstances. The aim is to utilize a system for a specific input-output transformation task.

  • Evaluation

    This involves assessing the performance of the model using the test subset of data to understand prediction accuracy. The predictive implementation of a model is evaluated by comparing predictions on the evaluation dataset with true values using a variety of metrics.

  • Prediction

    The model's performance to determine the outcomes of the test data set was not used for any training or cross-validation activities. The best model on the evaluation subset is selected to make predictions on future/new instances.

Machine Learning Pipeline Infrastructure/ Model Preparation Process.

Machine learning Infrastructure consists of the resources, processes, and tooling essential to the operation, training, development and deployment of machine learning models. Every stage of its workflow is supported by machine learning infrastructure and is the base of its model. There is no specific infrastructure because it depends on the model available in a product or project.

Here are some of the major components of machine learning pipeline architecture:

  • Model Selection

    Model selection refers to the process of choosing the model that best generalizes for a specific task or different data. It includes accuracy, interpretability, complexity, training time, scalability, and trade-offs.

  • Data Ingestion

    This refers to the process of extracting and transferring large data in an automated way from multiple sources.

  • Model Testing

    Model testing refers to the process where the performance of a fully trained model is evaluated on a testing set. It involves explicit checks for behaviours that are expected of the model.

  • Model Training

    It is the process of feeding a machine learning algorithm with data to help identify and learn good values for all attributes involved.

  • Visualisation and Monitoring

    It refers to the process of tracking and understanding the behaviour of a deployed model to analyze performance.

  • Machine Learning Inference

    Machine learning inference is the process of running live data into a machine learning algorithm to calculate output such as a single numerical score.

  • Model Deployment

    Model deployment is the process of implementing a fully functioning machine learning model into production where it can make predictions based on data.

Software/ Applications for Building Machine Learning Pipelines.

  • Azure Machine Learning Pipelines

    Azure ML pipeline helps to build, manage, and optimize its workflows. It is an independently deployable workflow of a complete ML task.

  • Google ML Kit.

    Deploying models in the mobile application(Andriod and IOS) via API, there is the ability to use the Firebase platform to leverage ML pipelines and close integration with the Google AI platform.

  • Amazon SageMaker

    It builds, trains, and deploys machine learning models for any use case with fully managed infrastructure, tools, and workflows. One of the key features is that you can automate the process of feedback about model prediction via Amazon Augmented AI.

  • Kubeflow Pipelines

    Kubeflow Pipelines is a platform for building and deploying portable, scalable machine learning (ML) workflows based on Docker containers.

  • TensorFlow

    TensorFlow is a free, open-source and end-to-end(E23) platform software library for machine learning developed by Google. It makes it easy for you to build and deploy ML models.

Machine Learning Pipeline Tools.

  • Data Obtainment

    Database: PostgreSQL, DynamoDB.

    Distributed Storage: Apache Spark/Apache Flink.

  • Data Scrubbing / Cleaning

    Scripting Language: SAS, Python, and R.

    Processing in a Distributed manner: MapReduce/ Spark, Hadoop.

    Data Wrangling Tools: R, Python Pandas.

  • Data Exploration / Visualization

    Python, R, Matlab, and Weka.

  • Data Predictions

    Machine Learning algorithms: Supervised, Unsupervised, Reinforcement, Semi-Supervised, and Semi-unsupervised learning.

    Important libraries: Python (Scikit learn) / R (CARET).

  • Result Interpretation

    Data Visualization Tools: ggplot, Seaborn, D3.JS, Matplotlib, Tableau.

]]>
<![CDATA[Message Broker: Memphis.Dev]]>https://chryzcode.hashnode.dev/message-broker-memphisdevhttps://chryzcode.hashnode.dev/message-broker-memphisdevMon, 03 Apr 2023 16:20:33 GMTFirstly, what is a message broker?

A message broker is an architecture pattern, software or server that facilitates, provides and enables the connection, communication and exchange of information between applications, systems and services for message validation, transformation, and routing. It translates information and messages between interdependent applications even if there is a contrast in the language or executed and administered platforms.

What is Memphis.Dev?

You might be hearing this for the first time but Memphis{dev} is a product and an example of a message broker.

Memphis is an open-source application that enables and promotes excellent engagement, processing and communication(end-to-end support) with data, data-driven applications and streamlined pipelines.

A cloud-native message broker with an ecosystem that enables less cost-effective and fast/ rapid development of modern queue-based use classes that require large volumes of streamed and enriched data, modern protocols and zero ops for data-oriented developers and data engineers.

Why Memphis.Dev?

  • Opensource

    Memphis is an open-source product that enables the public(people) to contribute to its development. This serves as an advantage as end users can use their experience to bring about improvements, evolvement and enhancement for the software/ service. It also permits an active and strong community that will yield an intuitive process while using.

  • Support of Major Programming Languages

    Memphis supports major programming languages which increases the privilege and opportunity for more usage among data engineers.

    Memphis Software Development Kit (SDK) includes Python, Go, Node.js, Typescript, Nest.JS.

  • Easy and Fast to Use

    Memphis provides a higher level of ease of use, while other message brokers like Kafka, RabbitMQ, NATS, and other MQs are HARD to deploy, manage, secure, update, onboard, and tune. Memphis has been designed to be deployed as production-ready in 3 minutes. It also has Graphic User Interface (GUI) and Command Line Interface (CLI) for the users to choose from based on their preferences.

  • Accurately Real Time

    Memphis processing engine provides true real-time processing with a full cover for all three needed layers -

    Ingestion, transformation, enrichment.

  • Schema Support

    Schemaverse is a Schema management with versioning, GitOps, validation, enforcement, and zero trust. Schema management with support for Avro, Protobuf, JSON, and GraphQL.

  • Less Expensive/ Cost

    Cost optimization and efficiency are one of Memphis' main building blocks. Implementation costs are close to zero due to the self-optimization that takes place when Memphis gets deployed, and SDKs and client connectivity are built in a low-code manner.

Get started with using Memphis

]]>
<![CDATA[Introducing CVBuild 🎉]]>https://chryzcode.hashnode.dev/introducing-cvbuildhttps://chryzcode.hashnode.dev/introducing-cvbuildSat, 11 Mar 2023 12:04:04 GMTCVBuild is a platform where you can build your resume and online portfolio for free.

Check out more information here https://cvbuild.onrender.com/.

]]>
<![CDATA[3 Simple Methods To Do Reverse Email Lookup]]>https://chryzcode.hashnode.dev/3-simple-methods-to-do-reverse-email-lookuphttps://chryzcode.hashnode.dev/3-simple-methods-to-do-reverse-email-lookupThu, 15 Dec 2022 15:01:33 GMTWe are in a world where data is vital, in one way or another other you consumed/used, created, or accessed some form of data. It is very pertinent any data accessed needs to be accurate, accessible quickly and straightforward.

In this article, we'll learn one of the best ways to source accurate data using emails. Emails are very unique and highly difficult to manipulate, imagine getting desired information about a company through its official email, how secure and accurate can that be?

This is where reverse email lookup comes in, proceeding we will know what it is all about, how it can be used and a detailed guide on starting.

What is a reverse email lookup?

A reverse email lookup is a data enrichment process used to uncover more information relating to an email address. A process that allows getting a lead's email address based on their data

Examples:

  • Finding the owner of the email address

  • The country they are based in

  • Job information and social media accounts associated with the email

  • Phone number, physical address, profile pictures and many more

  • The staff associated with the email

What is Reverse Email Lookup used for?

There is no limitation to sourcing information from performing a reverse email lookup, a lot can be achieved. In this section, I'll break down the different use cases where you may require data and information about an individual or entity using their personal or work emails.

Reverse Lookup of Personal & Generic Emails

The information available through a reverse lookup of personal emails is usually based on whatever platforms, social media accounts, and so on that the email is used on, be it their names, location, date of birth, educational background, connections and more. Below are some popular cases of reverse email lookup using personal or generic emails.

  1. Scams and Fraud Prevention

    Reverse Email Lookup prevents scams and fraud due to verification of whether the email sender is legit or not. It brings about security.

  2. Know One Personality Better

    An email search can provide more information about a person, like interests, and social media handles. It provides information that makes one prepared, influencing the rate of confidence, conversations and bonding.

  3. Verification of Economics Transactions

    In a world where online transaction (cashless policy) and E-commerce shopping is on the high, verifying the record of customers, buyers, and transactions goes a long to curbing scams and loss to the minimum.

Reverse Lookup of Work and Professional Emails

Another valuable use case where a reverse lookup can be beneficial is verifying work and professional emails. In the same way that personal emails can tell you a lot about a person's professional data like past and present jobs, skills and capabilities, location and more. These details can be used to determine if the person is a good fit for a particular job

  1. HR Talent Identification

    The hiring process will be less stressful, faster and more effective for HR by screening candidates through personal information using a simple email search.

  2. Lead Generation

    Another great use case is in sales and lead generation. Using a reverse email lookup, a sales team can qualify leads accurately, thus cutting down time wasted work on leads and instead, focusing on getting sales quicker and more efficiently.

  3. Credit Risks Analysis

    Obtaining the record of a customer using reverse email lookup before any online transaction can help identify the risk level for companies investing or loaning.

How Can I Do a Reverse Email Lookup? - 3 Simple Methods

To understand what Reverse Email Lookup is all about, let's look into diverse ways in which this can be processed. There are major ways to be covered, ranging from free to paid to a highly-efficient, automated method. It is up to you to choose which one suits you well.

  1. FREE Reverse Email Lookup (Google & LinkedIn Search)

The most basic and straightforward way to perform a reverse email lookup is to use Google. As you would do a normal Google search, you can do the same with email addresses. All you have to do is simply input your email in the search bar, and it will return search results with information related to that email.

However, this method is very manual and can be time-consuming if you happen to be dealing with a large number of email addresses. Most importantly, it's not guaranteed to return an accurate result as an email might not be crawled successfully by Google.

Another great free alternative to Google is LinkedIn. LinkedIn is a de-facto platform to get information about the professional profile of a person. However, you can’t perform a reverse email lookup directly on LinkedIn. But you can derive the person's name and company through its email prefix and domain, which you can then use to perform the search according to these two queries.

  1. Paid Reverse Email Lookup Tools

If you want a more efficient and reliable solution to handle large datasets of email addresses then you may want to consider going for a paid reverse email lookup tool. With paid tools, you can quickly gather the data you need which are all scattered online and present them in a manner easy to use. In addition, you can do searches more quickly and accurately, with all the information properly presented in a dashboard or sheet, ready for you to use and act upon.

There are a lot of paid reverse email lookup tools and services available, so it's up to you to choose what works best for you. One great tool is Spokeo. Spokeo lets you make reverse lookups involving names, addresses and phone, thereby allowing you more ways to obtain data and more data points to utilize.

  1. Automated Reverse Email Lookup Using An API

If you still want something better, something that can integrate seamlessly with your existing business system or application, you can consider going for a reverse email lookup API. With an API, a reverse email lookup process can practically run on its own within your application. The data obtained from the email search can then be fed back automatically into your application, allowing you to utilize the data points immediately for your business without worrying about the lookup process itself.

Proxycurl is an excellent tool for obtaining and enriching data about people and companies. One of its many services includes a Reverse Work Email Lookup API which you can use to programmatically pull data into your applications. They excel in data relating to the professional world, a more valuable type of data widely sought after. Another attractive feature of Proxycurl is its agile, lightweight pricing structure, at a cost of as low as $0.03 per search. No bulky monthly subscription that ties you down every month so you only get to pay as you use (or pay as you go if you'd like).

Conclusion

Now you know all about reverse email lookup, what it is used for, its capabilities and the different tools available out there depending on your use case. Will you now choose to integrate it into your current business workflow, or start using it personally to protect yourself against certain risks or fraud?

Give Proxycurl’s Reverse Work Email Lookup API a try today, send an email to find out more.

Credit to Nubela

]]>
<![CDATA[The Truth in Tech]]>https://chryzcode.hashnode.dev/the-truth-in-techhttps://chryzcode.hashnode.dev/the-truth-in-techSat, 13 Aug 2022 18:39:42 GMTHello techies,

Today's article title sounds a little weird, right?

I decided to share this based on my personal experience, what I see on social media platforms, especially on Twitter, the conversation I have had with techies and newbies and wanting more people to get this right.

Shall we 🚀


The tech world is very vast with lots of tools, talents, opportunities, setbacks, professions, hack tips, fast-growing and developing technologies and many more. The tech world dynamically evolves.

For you to grasp a better understanding a Journey type illustration will be used.

Starting in the tech world is a journey that requires self-determination, sacrifices and many more.

To successfully reach the destination of a journey, you should count the cost(requirements). People do embark on journeys at times not because it interests them but because of peer pressure and many more.

The start of a journey for the wrong reason is no failure but finding purpose along the way is the deal.

It is okay to start in the wrong field or change fields but what is more important is getting a good field because there is no perfect field.

Take a break now and ask yourself these:

  • Why am I in tech, is it attached to purpose?
  • Have I counted the cost, can I pay it?

    How did that go, I hope it went well. You may be passionate about tech and be in the wrong field, that is highly possible.

As aforementioned there are a lot of fields, always do to make research on a field before jumping into one.

Little tips for you.


  • Ask those who are in the field
  • Surf out answers on the Internet e.t.c
  • Count the cost: This varies a lot because a few factors determine this:

    • Your Personality: Some people can withstand the heat of writing codes while some prefer no code and some others product design and many more.

    • Your Location: There are parts of the world where certain fields don't thrive and it can affect opportunities, sometimes resources e.t.c.

    • The Monetary/Financial Cost: There are some tech fields where the cost of learning is free or less cost, freelancing is attainable but note that this applies to specific fields.

      Along the process, you'll have to spend money on necessities that can't be put attended to or acquire some basic equipment which can be so challenging at times.

Have in mind being in a good field will also be tedious and challenging like having a vehicle tire deflated. Nothing comes easy.

  • Getting a Tech Role

    You'll surely get a job in tech if you are persistent and this also varies a lot based on:

    • How skilful you are,
    • Your location,
    • Your connection(e.g social media presence),
    • The tech field and position e.t.c

      You might have come across similar posts like this

      I started learning frontend 5 months ago and I just secured a junior role or an internship.

      Yeah, this is highly possible and it is not a constant event that happens to everyone. One can have his first full-time opportunity after a year or two.

      Being a freelancer to clients found online or your physical location can also be of help and motivation before landing your first tech role.

NB: Please don't believe or dwell a lot on everything you see on social platforms to save yourself from low self-esteem, frustration etc.

  • Technologies

    As much as there are a lot of tech fields, so also there lots of technologies in specific fields. A choice is to be made here as well and I bet you'll like the most suitable technology. I'll just advise you to make research on the job opportunities, how vast it's been used, ask the experts e.t.c.

This article has come to a stop, thanks for reading through this article and I hope you found it useful, you can connect with me on;

Bye.

]]>
<![CDATA[The Choice: Python or JavaScript]]>https://chryzcode.hashnode.dev/the-choice-python-or-javascripthttps://chryzcode.hashnode.dev/the-choice-python-or-javascriptSat, 06 Aug 2022 10:02:04 GMTHi techies 👋,

At the end of reading this article, you should have a personal choice of a programming language between the two giants Python and Javascript or others.

For the sake of newbies/ new techies, a simple definition or explanation will be made concerning the two languages Python and Javascript.

Definition of Python and Javascript

Python

Python is a high-level, interpreted, general-purpose programming language. Its design philosophy emphasizes code readability with the use of significant indentation.

It was built by Guido van Rossum and first appeared on 20 February 1991.

Do you want to know more? Kindly visit the Python official website https://www.python.org/.

Javascript

JavaScript often abbreviated JS, is a programming language that is one of the core technologies of the World Wide Web, alongside HTML and CSS, mostly used for the client side for webpage behaviour, often incorporating third-party libraries.

It was created by Brendan Eich and first appeared on December 4, 1995.

Do you want to know more? Kindly surf the Internet for more detailed information.

Does a Perfect Programming Language Exist?

You might have come across some posts on different platforms on comparison between programming languages, difficulty in choosing a programming language and many more.

Firstly, no programming language is perfect and that's why versions are still released for improvement.

A programming language could also be perfect based on personal choices.

The choices of people differ based on the goal one is willing to achieve, inevitable attached experience, situation or environment and many more.

Let's dig this a little for more clarity and understanding.

Features of Python and Javascript

Each language has its strength, uniqueness or features, some are stated below.

Python

  • Easy to code

Python is a high-level programming language. Python is very easy to learn the language as compared to other languages like C, C#, Javascript, Java, etc.

  • Free and Open Source

Python language is freely available at the official website and you can download it from the given download link below click on the Download Python keyword. Download Python Since it is open-source, this means that source code is also available to the public. So you can download it, use it as well as share it.

  • Object-Oriented Language

One of the key features of python is Object-Oriented programming. Python supports object-oriented language and concepts of classes, object encapsulation, etc.

  • GUI Programming Support

Graphical User interfaces can be made using a module such as PyQt5, PyQt4, wxPython, or Tk in python. PyQt5 is the most popular option for creating graphical apps with Python.

  • High-Level Language

Python is a high-level language. When we write programs in python, we do not need to remember the system architecture, nor do we need to manage the memory.

  • Extensible feature

Python is an Extensible language. We can write some Python code into C or C++ language and also we can compile that code in C/C++ language.

  • Python is Portable language

Python language is also a portable language. For example, if we have python code for windows and if we want to run this code on other platforms such as Linux, Unix, and Mac then we do not need to change it, we can run this code on any platform.

  • Interpreted Language

Python is an Interpreted Language because Python code is executed line by line at a time. like other languages C, C++, Java, etc. there is no need to compile python code this makes it easier to debug our code. The source code of python is converted into an immediate form called bytecode.

  • Large Standard Library

Python has a large standard library that provides a rich set of modules and functions so you do not have to write your own code for every single thing. There are many libraries present in python such as regular expressions, unit-testing, web browsers, etc.

  • Dynamically Typed Language

Python is a dynamically-typed language. That means the type (for example- int, double, long, etc.) for a variable is decided at run time not in advance because of this feature we don’t need to specify the type of variable.

Javascript

  • Scripting Language

JavaScript is a lightweight scripting language made for client-side execution on the browser. Since it is not designed as a general-purpose language and is specially engineered for web applications.

  • Interpreter Based

JavaScript is an interpreted language instead of a compiled one. In that sense, it is closer to languages like Ruby and Python. The browser interprets JavaScript’s source code, line by line and runs it. In contrast, a compiled language needs to be compiled into a byte-code code executable. Java and C++ are examples of compiled languages.

  • Event Handling

An event is an action or an occurrence in a system that communicates about said occurrence so that you can respond to it somehow.

JavaScript enables you to handle events and even generate custom events.

  • Light Weight

JavaScript isn’t a compiled language, so it doesn’t get converted to byte-code beforehand. However, it does follow a paradigm called Just-In-Time (JIT) Compilation. Meaning it gets converted to bytecode just as it’s about to run. This enables JS to be lightweight. Even less powerful devices are capable of running JavaScript.

  • Case Sensitive

JavaScript is highly case-sensitive. All keywords, variables, function names and other identifiers can and must only follow a consistent capitalisation of letters. E.g.:

var hitCounter = 5
var hitcounter = 5

Here variables hitCounter and hitcounter are both different variables because of the difference in the case. Also, all keywords such as “var” are case-sensitive.

  • Control Statements

JavaScript is equipped with control statements like if-else-if, switch-case, and loops like for, while, and do-while loops. These control statements make it a powerful programming language, enabling its user to write complex logic.

  • Objects as first-class citizens

All non-primitive data types in JavaScript are actually objects, i.e. data types like Arrays, Functions, Symbols etc. inherit all the properties of the Object prototype.

The term first-class citizen means “being able to do what everyone else can do”. In JavaScript Objects prototype is the base prototype of all. They can be passed as reference, returned in a function, and assigned to variables for manipulation. This concept is also extended to functions as Object is also the prototype of functions.

  • Functions as First-class citizens(supports functional programming)

What do we mean by functions as first-class objects/citizens? Functions that return a function are called Higher Order Functions, which JavaScript supports. Functions as first-class citizens simply mean functions enjoy similar behaviour from the JavaScript interpreter as that of objects or any other variable. This means we can pass them into arguments (pass by reference), return them by another function, and assign them to a variable as a value.

  • Dynamic Typing

JavaScript is a dynamically typed language. It means that the JS interpreter does not require an explicit declaration of the variables before they are used. E.g.:

var dynamicType = “a string”
dynamicType = 5

Here we can see the same variable dynamicType can contain either a string or an integer with the same variable declaration. That is, the variable type does not need to be declared during creation or assignment.

There are also more factors to be considered in choosing.

  • Tech Field

There are lots of tech fields and each field has a more suitable language for operation, Examples:

  • Data Science: Python
  • Full Stack Development: JavaScript
  • Job Opportunity

Based on research and observation, JavaScript tends to be more popular and it creates more job openings for JavaScript developers.

Thanks for reading through this article and I hope you found it useful, you can connect with me on;

Bye.

]]>
<![CDATA[Tutorial - How to build your own LinkedIn Profile Scrapper in 2022]]>https://chryzcode.hashnode.dev/tutorial-how-to-build-your-own-linkedin-profile-scrapper-in-2022https://chryzcode.hashnode.dev/tutorial-how-to-build-your-own-linkedin-profile-scrapper-in-2022Thu, 28 Jul 2022 19:38:21 GMTHello techies,

Having entered into the mid-year of 2022, I have found a way to build a LinkedIn Profile Scrapper to help get user data and I want to share it with you all, hoping it might be of benefit to you.

Basically, this tutorial will help you out in building a tool that can fetch data of users that interest you on the LinkedIn platform.

Starting out, this is the breakdown of what this tutorial will cover.

  • What is Linkedin?
  • Have an Active Linkedin Account.
  • Set Up your Code Workspace - Code Editor, Python programming language, Selenium Webdriver.
  • Tutorial(coding).

Firstly, what is Linkedin?

LinkedIn is one of the largest professional network platforms where you can get job opportunities, connect and build professional relationships with your fellow colleagues in your field.

Have an Active Linkedin Account.

Here is the foremost and most important step, If you have one you can skip through else kindly visit https://www.linkedin.com/ and as of now here is the visual interface

68747470733a2f2f7265732e636c6f7564696e6172792e636f6d2f636872797a6875622f696d6167652f75706c6f61642f76313635383038313438362f746563682d77726974696e672d746573742f6c696e6b6564696e5f686f6d65706167655f747369637a702e706e67.png

Then go ahead and click the Join Now where there is a red mark and this will the display rendered, the SignUp page to create an account.

68747470733a2f2f7265732e636c6f7564696e6172792e636f6d2f636872797a6875622f696d6167652f75706c6f61642f76313635383038313438352f746563682d77726974696e672d746573742f6c696e6b6564696e5f7369676e75705f757630796b6a2e706e67.png

Kindly fill the form with your details, your email and password and submit. You should get a verification mail from LinkedIn, kindly follow the instruction given to verify your Linkedin account.

Setup your Code Workspace.

Firstly, a code editor is also pertinent and there are varieties of them but to save you time and undergoing stress, I recommend using Visual Studio Code(vscode), visit https://code.visualstudio.com/ and download the build compatible with your device operating system.

68747470733a2f2f7265732e636c6f7564696e6172792e636f6d2f636872797a6875622f696d6167652f75706c6f61642f76313635383038313439302f746563682d77726974696e672d746573742f7673636f64655f776562736974655f6a72337267732e706e67.png

Secondly, as aforementioned we will be using the Python programming language. Visit the Python official website https://www.python.org/, hover over the downloads that is marked in the image below and download the build that is compatible with your device.

68747470733a2f2f7265732e636c6f7564696e6172792e636f6d2f636872797a6875622f696d6167652f75706c6f61642f76313635383038313438362f746563682d77726974696e672d746573742f707974686f6e5f646f776e6c6f61645f773764716a752e706e67.png

Here are resources to install Python on different operating systems.

Mac Operating System

  • https://www.youtube.com/watch?v=A66ALenHdT0

Windows Operating System

  • https://www.youtube.com/watch?v=AwIXfaGEN4c

Linux Operating System(Ubuntu)

  • https://www.youtube.com/watch?v=7H-DcdSmV0U

If you installed the Visual Studio Code Editor(vscode), here is also a resource on how to set up Python extensions for your code editor.

  • https://www.youtube.com/watch?v=SxzzFwzPYqo

Lastly, we will need the Selenium Webdriver. In this tutorial, we will use the Selenium Webdriver to connect with the Chrome browser to use our Linkedin Profile Scrapper. Here is a tutorial to help you out with the installation https://www.youtube.com/watch?v=WnWQgUerR0c.

Tutorial(coding)

This is the last part of the tutorials and we'll start with writing of codes.

Firstly, we need to install the Python package that we'll be using, linkedin-scrapper with the Package Installer for Python(pip). Pip is is used to install Python based packages and libraries.

pip install --user linkedin_scraper

I spoke about the Selenium Webdriver before now, so it is time we need to set the set the path.

export CHROMEDRIVER=~/chromedriver

Here we export into the CHROMEDRIVER variable the path of the Selenium Webdriver downloaded. To avoid errors at this point, it is advisable you create a folder for project and include both the Webdriver and Python file for easy path configuration.

from linkedin_scraper import Person, actions
from selenium import webdriver
driver = webdriver.Chrome()

Before writing this code, kindly make sure you have the linkedin-scrapper package installed.

To check or confirm kindly run this on your terminal pip freeze. This will help show all the Python packages you have installed on your device alphabetically, there you can search for the Linkedin Scrapper package for certainty.

We import some libraries/classes from both the Linkedin Scrapper and the Webdriver from Selenium.

A variable driver is created where the Selenium Webdriver is defined.

A driver using Chrome is created by default. However, if a driver is passed in, that will be used instead.

email = "some-email@email.address"
password = "password123"

We earlier created a Linkedin account, now is the time to utilize it in the program(code).

An email and password variable is created and should be defined with validated Linkedin account details else error will be inevitable.

actions.login(driver, email, password)  
person = Person("https://www.linkedin.com/in/olanrewaju-alaba/", driver=driver)

If you can recollect the actions class was imported from Selenium. We are going to use this to login with our Linkedin account details using the Webdriver.

The Person class installed is used to defined the profile of a particular Linkedin Profile by using the profile's url path.

Note:

  • if email and password isnt given, it'll prompt in your terminal.

  • The account used to log-in should have it's language set English to make sure everything works as expected

You might want to also get data from a Company Linkedin Profile.

from linkedin_scraper import Company
company = Company("https://ca.linkedin.com/company/google")

Instead of importing the Person class, you'll import the Company class or both. You'll use the Company class to define a company variable using the url pattern in the code snippet above with the company name on LinkedIn.

Here is the final piece of code to get our Linkedin Profile Scrapper working.

person.scrape()
#or
company.scrape()

This code snippet above will get(scrape) the data of the specified Linkedin Profile of a person or company. After scrapping the data, the browser powered/engineered by the Webdriver will close but to continue in this process;

person.scrape(close_on_complete=False)
#or
company.scrape(close_on_complete=False)

By default close_on_complete is set to True, so it is important to set it to False to the keep the browser on.

Our Linkedin Profile Scrapper is now perfectly built to fetch data, you can go ahead to test this program.

For those who are willing to learn more about the linkedin-scrapper package, let move ahead to explore a little more.

Person

A Person object can be created with the following inputs:

Person(linkedin_url=None, name=None, about=[], experiences=[], educations=[], interests=[], accomplishments=[], company=None, job_title=None, driver=None, scrape=True)
  • linkedin_url: This is the linkedin url of their profile

  • name: This is the name of the person

  • about: This is the small paragraph about the person

  • experiences: This is the past experiences they have. A list of linkedin_scraper.scraper.Experience

  • educations: This is the past educations they have. A list of linkedin_scraper.scraper.Education

  • interests: This is the interests they have. A list of linkedin_scraper.scraper.Interest

  • accomplishment: This is the accomplishments they have. A list of linkedin_scraper.scraper.Accomplishment

  • company: This the most recent company or institution they have worked at.

  • job_title: This the most recent job title they have.

  • Driver

This is the driver from which to scraper the Linkedin profile. A driver using Chrome is created by default. However, if a driver is passed in, that will be used instead.

For example

  • scrape When this is True, the scraping happens automatically. To scrape afterwards, that can be run by the scrape() function from the Person object.

  • scrape(close_on_complete=True) This is the meat of the code, where execution of this function scrapes the profile. If close_on_complete is True (which it is by default), then the browser will close upon completion. If scraping of other profiles are desired, then you might want to set that to false so you can keep using the same driver.

Company

A Company object can be created with the following inputs:

Company(linkedin_url=None, name=None, about_us=None, website=None, headquarters=None, founded=None, company_type=None, company_size=None, specialties=None, showcase_pages=[], affiliated_companies=[], driver=None, scrape=True, get_employees=True)
  • linkedin_url: This is the linkedin url of their profile

  • name: This is the name of the company

  • about_us: The description of the company

  • website: The website of the company

  • headquarters: The headquarters location of the company

  • founded: When the company was founded

  • company_type: The type of the company

  • company_size: How many people are employeed at the company

  • specialties: What the company specializes in

  • showcase_pages: Pages that the company owns to showcase their products

  • affiliated_companies: Other companies that are affiliated with this one

  • get_employees: Whether to get all the employees of company.

  • Driver

This is the driver from which to scraper the Linkedin profile. A driver using Chrome is created by default. However, if a driver is passed in, that will be used instead.

Hi, this is where this tutorial will be put to a stop, I hope you learned a lot and had fun.


Thanks for reading through this article and I hope you found it useful, you can connect with me on;

Bye.

]]>
<![CDATA[Linting your Code]]>https://chryzcode.hashnode.dev/linting-your-codehttps://chryzcode.hashnode.dev/linting-your-codeSat, 05 Mar 2022 14:31:21 GMTHello techies👋,

This article will be addressing an underrated process just as last week's, Why Write Tests? but it will be centred on Linting.

Firstly, what is linting?

Linting is an automated checking of source code for programmatic and stylistic errors.

We all tend to make little mistakes like wrong indentation(whitespace), omitting necessary symbols etc. This is where the importance of linting comes in.

Let's talk a little about the importance,

  • As aforementioned, it helps to syntactically correct codes, saves debugging stress
  • It formats and properly arrange the codes, making them readable and more accessible(neat code)

Linting Tools

These are tools(packages) used to lint codes.

There are a lot of linting tools and they are actually connected to programming languages. A linting tool can only lint specific languages not all.

Examples of linting tools

These are some languages and some of their linting tool.

- Python

  • PEP
  • Black

- HTML and CSS

  • Prettier

- Javascript

  • JSLint
  • ESLint

- PHP

  • Phplint

- Java

  • Checkstyle
  • Lightrun

- Flutter

  • Flutter lints

Thanks for reading through this article and I hope you found it useful, you can connect with me on;

Bye 👋.

]]>
<![CDATA[Why Write Tests?]]>https://chryzcode.hashnode.dev/why-write-testshttps://chryzcode.hashnode.dev/why-write-testsFri, 25 Feb 2022 19:57:32 GMTHello 👋 techies,

This week's article will be addressing a very important, essential and one of the most underrated sections in the tree of software development, which is Testing.

With my little observation most developers especially junior developers tend to know nothing about writing tests and nearly all companies including average companies take testing in their developing process.

Firstly, what is test?

Test is a program created with a major aim to source out bugs and possible errors in another piece of code or program.

Reasons Why Test is Underrated.

  • Some developer sees testing as a waste of time, which can be really and truly time-consuming.
  • Some developers don't attempt because it can be boring and frustrating while writing
  • Some developers can't just find a solid reason why they must write code for a piece of code or set of codes

Why write tests?

Why does testing sound as important as this.

  • Testing is one of the laid down processes in software development.
  • Most companies values testing, knowing how to write tests makes it a plus and advantage for a developer.
  • Tests actually save one from time wastage and stress due to bugs.

Thanks for reading through this article and I hope you found it useful, you can connect with me on;

Bye 👋.

]]>
<![CDATA[Hack Cascading Stylesheet - CSS]]>https://chryzcode.hashnode.dev/hack-cascading-stylesheet-csshttps://chryzcode.hashnode.dev/hack-cascading-stylesheet-cssFri, 18 Feb 2022 23:57:46 GMTHello techies👋,

This week article will help in sharing short tips and hacks to be better at writing Cascading Stylesheet (CSS).

CSS Hackers shall we 🚀

Helpful Tips and Hacks.

  • Learn the basic components and properties of CCS (like display, flex, grid etc.) and don't bother trying to learn everything because it is not possible.
  • Use fewer CSS frameworks like (Bootstrap, TailwindCSS) and write more CSS.
  • Build projects(challenges) from platforms like frontend mentor etc.
  • CSS arts can be challenging but can be helpful
  • Make specific research on components and researches
  • Clone web pages interface
  • Maximise the use of browser developer tools

Thanks for reading through this article and I hope you found it useful, you can connect with me on;

Bye 👋.

]]>
<![CDATA[Why Work Hard When You Can Work Smart?]]>https://chryzcode.hashnode.dev/why-work-hard-when-you-can-work-smarthttps://chryzcode.hashnode.dev/why-work-hard-when-you-can-work-smartSat, 12 Feb 2022 12:59:55 GMTHello techies 👋,

This week article will be addressing a very significant aspect of a developer career which is working ethics and this can be toxic most times. This article has a lot to share, so I urge you to read to the end.

Shall we begin 🚀

Every developer always have a goal to build something(a side project) even if been employed at an organization or not, this can surely be achieved but if not controlled well, it can lead to burnout affecting our mental health and many more.

All this points down to having a goal and aim and approaching it with a better procedure and below are helpful tips.

Helpful Tips to Working Smart.

  • Always have a weekly goal and break it down to its smallest form for daily implementation.
  • Allocate your working hours well in contrast to your responsibilities and health status; are you a parent, how conversant are you with your health and body e.t.c.
  • There is never always enough time to code. A day can't be enough so also weeks at times. So always give yourself a break.
  • Debugging can be strenuous, if the process is yet to yield out result after a long process, it is advisable you sleep or shut down the computer and find other things to do.
  • Maximise the use of Google, Stack Overflow, YouTube and other helpful sources while stuck.
  • You need to have a proper observation of yourself. What are the things that aid your productivity? Listening to music etc.
  • Always drink water while working because coding at times can dehydrate.
  • Always have enough rest.
  • Meeting with your fellow developers either physically or virtually tends to improve productivity.
  • Your sitting position also helps, you should put that into consideration

Thanks for reading through this article and I hope you found it useful, you can connect with me on;

Bye 👋.

]]>