Skip to main content

Posts

Roadmap to become an AI engineer

AI is changing the world in many ways, such as: Improving decision making by analyzing large amounts of data and providing insights and predictions.   Enhancing customer service by using chatbots and voice assistants that can interact with human users and provide information, advice, and support.   Innovating new designs and products by using generative algorithms that can create novel shapes and configurations for various applications.   Automating tasks and processes that are repetitive, tedious, or dangerous, such as manufacturing, agriculture, transportation, and healthcare.   Empowering creativity and entertainment by using AI to generate music, art, stories, games, and other forms of media. However, AI also poses some challenges and risks, such as: Introducing bias and discrimination by replicating or amplifying human prejudices and stereotypes in data or algorithms.   Threatening privacy and security by collecting and processing personal or sensitive info...
Recent posts

Generating settings.SECRET_KEY in django

On some occasions, there might be a need to generate a random Secret key for your Django project. The easiest option could be starting a django shell and running the below command - from django.core.management. utils import get_random_secret_key get_random_secret_key () However, this may not be safe to use in a production environment. A better option is to use a defined a set of allowed characters including upper case letters and then use Django to generate a long key. Here is an example of it - a. Define a list of allowed characters lower_plus_numbers = ( list ( chr (o) for o in range ( 0x61 , 0x7B )) + list ( chr (o) for o in range ( 0x30 , 0x3A ))) punctuation = list ( '!@#$%^&*(-_=+)' ) upper_alpha = list ( chr (o) for o in range ( 0x41 , 0x5B )) b. Generate Secret Key from django.utils.crypto import get_random_string key_length = 60 get_random_string( key_length, allowed_chars=lower_plus_numbers + punctuation + upper_alpha, ) c...

What is a zombie process?

A zombie process is a sub-process that finished (normally or otherwise), but it's not yet reaped by its parent (i.e.: its parent didn't collect its exit code). It can't be killed (because it's already dead, hence "zombie"), but it won't consume resources (CPU and memory). However, it is still using a scheduler process id; it's theoretically possible to starve a system of pids (therefore, preventing it to create new processes) launching dummy subprocesses and not reaping them.

Solving ‘Could not resolve host: github.com’ issue

Recently I ran into this issue while trying to clone one of my own repository from GitHub C:\GitHub\FS> git clone https://github.com/<username>/FS.git Cloning into 'FS'... fatal: unable to access 'https://github.com/<username>/FS.git/': Could not resolve host: github.com At first I thought that this could be due to some proxy setting. So I tried to unset it by executing below command - C:\GitHub\FS> git config --global --unset https.proxy But that didn’t fix the problem and I was still getting the same error. As it turned out later, the culprit was my VPN connection. Turning off the VPN fixed the issue. For the records, I was using ‘Surfshark’ on my Windows 10 laptop.

Collect Python project dependencies

Sometimes we need to figure out dependencies of our Python project. I have been using the below two approaches to get it done: Using pipreqs If we want to collect all the dependencies and store them in a project-level 'requirement.txt' file, then pipreqs is an easy and simple solution. This library analyzes the import statements in the project to gather dependencies. First, we need to install pipreqs: pip install pipreqs In order to generate project-level requirement.txt file, run the below command: pipreqs /path/to/your/project/ requirements file would be saved as- ' /path/to/your/project/ requirements.txt ' To read about more advantages of pipreqs over pip freeze , read it from here Using pipdeptree     I have written a more detailed post about visual representation of python packages using 'pipdeptree' library in this blog . 'pipdeptree' provides more advanced options such as listing the dependencies in html format o...

Troubleshooting "BackendDestroyException" in Docker

Setting up Docker in Windows environment is not an easy task. I have seen many people (including me) struggling to get it run on Windows PC. I have installed 'Docker for Desktop' in my laptop which has Windows 10 Pro 64-bit, Version 1909 (OS Build 18363.720). It was running fine with Windows containers. However, when I needed to switch to Linux container, it crashed with below error: Docker.Core.Backend. BackendDestroyException: Unable to stop Hyper-V VM: Service 'Hyper-V Host Compute Service (vmcompute)' cannot be started due to the following error: Cannot start service vmcompute on computer '.'. at Enable- MobyLinuxRequiredService, <No file>: line 103 at <ScriptBlock>, <No file>: line 804    at Docker.Core.Pipe. NamedPipeClient.<TrySendAsync> d__5.MoveNext() --- End of stack trace from previous location where exception was thrown ---    at System.Runtime. ExceptionServices. ExceptionDispatchInfo.Throw()    a...