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]

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]

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]

Cryptojacking: cryptography in service of the Devil

A new revenue stream has been implemented by the end of the last year. Maybe cryptojacking did not get yet the hype it deserves but it has been already widely used. Most Internet consumers are not aware of it though its intentions are far from being innocent. It may also generate inequalities among Internet users. Definition Cryptojacking is about using the user’s device processor, with or without his consent, to mine cryptocurrency when visiting a given webpage which is not necessarily compromised but can do that on purpose. [Read More]

Vigenère cipher simplified implementation

This is not an other dissertation on Vigenère cipher. This encryption algorithm is profusely discussed in cryptography literature. Here is rather a simplified yet efficient implementation of it. The goal of this article is not to about debating the theory of Vigenère cipher. I rather just want to focus on its implementation after I have seen several awkward ways of proceeding to it on different online programming forums. This question on Code Review website is an example of such implementations where code duplication is obvious but which the pre-existing answers did not address. [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]