File upload from a Nuxt.js client to an AdonisJS RESTful API server using axios

Preamble AdonisJs documentation shows how to upload files to the server using the HTML5 <form> element. But there are cases where axios comes more handy. So let us see how to upload files from a Nuxt.js client application to an AdonisJS RESTful API server with axios. I shared this project on my Github profile. Project setup In my demo, the client and server code are set apart. My client application is handled by Nuxt. [Read More]

Linux commands

Preamble This article is going to be updated and become longer as the time goes on. I am listing some of the commands I rarely use but I do not want to forget. Of course, I gleaned most of them on the web, sorry for not being able to mention the resources for each listed one below. Emacs Git Fast copy data 1. Emacs Set JS indentation to 2 in Vue. [Read More]

Nuxt.js deployment on Gitlab

How to deploy your Nuxt.js application on Gitlab for continuous integration? First create a Gitlab CI YAML file and name it .gitlab-ci.yml with the following commands: image: node before_script: - npm install cache: paths: - node_modules/ pages: script: - npm run generate artifacts: paths: - public only: - master Then in nuxt.config.js, add these configuration lines: /** * Gitlab */ router: { base: '/whatEverName/', }, generate: { dir: 'public', }, After running the CI job, and on the project’s repository, go to Settings then Pages and click on https://namespace. [Read More]

PHP unit testing

These are the steps to install and set the necessary tools to run unit tests in PHP projects: Installing Composer on Ubuntu 16.04 LTS: curl -sS | php sudo mv composer.phar /usr/local/bin/composer Installing PHPUnittest: { "require-dev": { "phpunit/phpunit": "^7" } } Install xdebug on Ubuntu 16.04 LTS. Run the tests: ./vendor/bin/phpunit --bootstrap vendor/autoload.php tests/EmailTest.php Run the code coverage: ./vendor/bin/phpunit --coverage-html . tests/EmailTest.php Setting phpunit.xml file I created the phpunit. [Read More]

A slightly improved version of bubble sort algorithm

My wicked brain gave birth to an improved version of the classic bubble sort algorithm. Here it is. This document is not about explaining the bubble sort algorithm as it already exists a good literature out there about it, and it is a classic algorithm studied and known by all CS students all over the world. There are, obviously, two improved versions of bubble sort algorithm; and thanks to a question asked the Code Review website regarding the first one of them which is: [Read More]

How to install OpenCV 4.0 for Python3.6.5 on Ubuntu 18.04 LTS

I know OpenCV 4.0.0 will rather be released on July 2018, but the installation procedure I describe here will not change. In fact, I already I installed and tested OpenCV 4.0.0-pre on Ubuntu 18.04 (to be continued soon) I want to share my own experience regarding this procedure. Whenever I tried this or that tutorial related to installing a recent OpenCV version for Python3.x, I stumble on errors which are not recovered by those tutorials. [Read More]

Python decorators

What are the origins and goals of Python decorators? How to implement them and why are they useful? Introduction Even when dealing with scientific and technical subjects, your subjectivity rules over you. I mean, each person has her own style in learning and explaining ideas. This subjective aspect is shaped not only by your intellectual capacities but more importantly by your personality. By personality, I mean how you see and interpret things. [Read More]

Installing Selenium drivers on Ubuntu

Here is a common exception raised when trying to invoke selenium’s webriver component for browser automation launching. Here is how to fix it. For a professional need, I installed selenium testing framework on Ubuntu 17.04 LTS within a virtual environment I created using the recommended method I found on the documentation: pip install selenium Chrome I then tried to launch my website on Chrome: from selenium import webdriver driver = webdriver. [Read More]

Do not make a direct use of function parameters

Today, I have answered a question on Code Review website. The OP’s code sample itself was simple, but a user commented my answer stating that he never heard about function’s parameters should not be used directly. Following my answer to this question, I wrote this: “Whatever the programming language you use, do not use the parameters inside your function” and I explained what I meant: def my_function(param): par = param # Now work with "par" instead of "param" A user was curious about the last section of my thread and commented: “Is your point on ‘do not use function params directly, no matter what language’ (paraphrased) definitely correct? [Read More]

Tkinter best practices

Tkinter is the standard Python interface to Tk/Tcl GUI toolkit. Programmers often wonder how to structure their tkinter program. In this article, I am going to answer to a question posted on StackOverflow which contributions drift away from some of software engineering fundamentals. I see many questions posted on StackOverflow and CodeReview asking for tkinter best practices and improvements. While many of the contributions to those questions are interesting, they also teach bad and even harmful coding habits that result in scalability and maintenance issues. [Read More]