Testing emit event in Vue.js using Jest and Vue Test Utils

Often we need to design a custom component which needs to communicate data with its parent. One way to achieve this is to rely on the emit event through the v-model directive. The aim of this article is to show how to test emit event using Vue Test Utils and Jest. For this purpose, let us implement the below user interface which consists of a label Vuetify component reflecting what is being typed within the input field: [Read More]

How to use Moment.js with AdonisJs

Preamble I decided to write this article following a question published yesterday on the AdonisJs community forum solliciting if there is a tutorial that shows how to use Moment.js in AdonisJs. I answered to that question yesterday, but I would like to share the information with others here. Do not try to install Moment.js because Adonis.js uses it internally. This means you can take any Moment.js instance and apply on it any Moment. [Read More]

Effective file streaming using AdonisJs

Preamble The majority of upload libraries/frameworks process files multiple times when streaming to an external service such as Amazon S3. Their upload workflows are usually designed like so: Process request files then save them to the tmp directory. Move each file from the tmp directory to the destination directory. Use the external service’s SDK to finally stream the file to the external service. This process wastes server resources reading/writing single files multiple times. [Read More]

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 https://getcomposer.org/installer | 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]