Course(s) Evaluation

In this blog post I will include my thoughts about the classes TC3045 (Software Quality and Testing) and CB00881 (Smart Citizens)

First of all, these were my first and last classes (because I’m graduating and I’m not planning to do a Masters) using the Flipped Learning method. I found it very interesting because I had a lot of flexibility in terms of homeworks and tasks, at the start of the semester I was working in a full-time job so I have the option to complete all my pending assignments in my free time. To be honest, I should have been more careful about the deadlines and deliveries because I have a considerable amount of accumulated tasks to do at the end of the semester.

About the content of the classes and assignments, they met my expectations, there were some assignments that challenged myself and taught me new things. At the start of the semester, we have to write blogs weekly for CB00881, I wrote a few on time because I don’t have the writing habit developed, I don’t really like writing so much, but I want to. Recently I started to read more blogs about the new technologies, the updates and improvements in the actual ones, and some tutorial blogs to develop something using a language or framework. I want to share some knowledge to the world and start writing some blog stuff and link the code I used to my GitHub repo, I proposed myself that I want to contribute to some Open Source repos in order to thanks all the amazing people that are doing it and all the times I used those repos. I hope I will do it.

Ken is amazing teacher, he really knows how to transmit his knowledge and encourage you to learn. But apart of being a good teacher, he is a great human being, he is always open to talk to you about your thoughts, life, work, feelings and whatever you want, he will listen and he will be there to help.

Anuncio publicitario

Dev Ops Part III

For this part, we’re going to automate pulls of our project to the Linux Server we did set up in Part II.

Make sure you have a GitHub account before start.

Adding 2 factor authentication to GitHub and SSH keys

  • Sign into GitHub and go to Settings
  • Select Security from left menu
  • Click on Enable two-factor authentication and follow the instructions
  • Choose the desired method, I did it with SMS
  • Once you finish, you’ll see a page like this

To add SSH keys do the following:

  • Sign into GitHub and go to Settings
  • Choose SSH and GPG Keys in the left menu
  • Click on the New SSH button
  • Set the title to this new SSH and to generate it we will do the following:

Inside the Virtual Machine, open the terminal app and run the following command

ssh-keygen -t rsa

Follow the prompted instructions to store it in your machine. Once the key is generated, try to clone the repo we previously created in Part II using the SSH method. If it clones without any problem, it means that it worked!

Make any change to the repo and commit it. Try to pull from the VM to ensure it works.

We’re going to automate pulls from our project to keep the website updated. Let’s create a simple shell script.

mkdir cicd_scripts
cd cicd_scripts

/** **/

cd $HOME/Server/devops // This is the path to my project
git pull origin master

/** **/

Now, let’s modify our cronjobs

crontab -e

// Add this at the end of the file

* * * * * sh $HOME/cicd_scripts/

Our server will be doing pulls to the master branch every minute, to keep it updated. Let’s make a small change and commit it.

Open the browser and refresh the page, it has the changes we made! Now you have automated pulls in your server!

How often should we update?

It depends on the project, I’ll go for after midnight, around 2:00 A.M. – 3:00 A.M., to ensure that there is less traffic in the website, unless it is a critical change that has to be updated right now.

How do you ensure (and you should do this) that you do not end up with two copies of your update script running at the same time?

There are tools to accomplish this. One method that I liked is using flock. It came bundled with Ubuntu, basically it is a tool that if a job is running, it creates a lockfile to prevent running more than one instance of a jobs. It is very easy to use it, to add it to our current jobs we just write the following

* * * * * /usr/bin/flock -w 0 $HOME/cicd_scripts/cicd.lockfile sh $HOME/cicd_scripts/ 

We’re telling it to create a lock file inside our scripts folder, it will prevent running our script more than one time

This has to be done for every cron jobs that we create.

Stay tuned for the Part IV post!


DevOps Part II

We are on our first step to become a DevOps expert. We will begin setting up a Linux Server (NodeJS) on a Virtual Machine. I recommend VirtualBox, it is open source and very easy to set up.

Preparing VirtualBox for running Ubuntu

Launch VirtualBox and select «New», the next prompt will appear. Make sure you select Linux and Ubuntu (32|64-bit) version.

Set the RAM

Select the Hard Drive Type

Your VM is almost ready, when you boot it from the first time, it prompts you to select the bootable file, make sure you select the *.iso file you downloaded from the Ubuntu webpage.

Follow the instructions prompted by the OS like creating an Username and Password, when it finished, we’re going to install the required packages for running Node.

Installing NodeJS & Git

First we need the curl package, open the Terminal app and type

sudo apt-get install curl

Next step is to download Node source, type the following command

curl -sL | sudo -E bash -

Once finished, let’s install NodeJS by running the next command

sudo apt-get install -y nodejs

Finally, verify that node and npm are correctly installed by checking the version of each one

node -v
npm -v

Our next step is to install git, so we run the next command

sudo apt-get install git

And like node and npm, let’s verify the installation by checking the version

git --version

Now let’s create a repository for serving a simple webpage using node and express. In a new folder run npm init, and fill the prompted options. This will let us install node packages using npm. Install express by running npm install express. Let’s write some HTML and JavaScript.


In the package.json file, add a new script for running our development server.

"scripts": {    
"start": "node src/index.js"

Run the script typing npm run start and open the browser in http://localhost:8080, you should see the following

It works!

Remember to add git to the project.

Now, we’re going to write a small cron job in our Virtual Machine, type the following

crontab -e

Select your desired terminal editor and you’ll be able to edit or add cron jobs

At the end of the file we will write the cronjob, add something simple like this

* * * * * echo 'Hello Cron!' > $HOME/cron.txt

This task will be running every minute and overwrite the file with ‘Hello Cron!’, close the file and save it. Next go to your home directory in one minute and see that the file is created

Amazing! We wrote our first cronjob in Linux. This is the part II of a series of five posts

A Bigger Brother

Our personal data is being collected every day by the technology we use. We know there are privacy terms (that many of us doesn’t read, just accept them) telling us the use that they will give to our data, and maybe they use it for another purposes that are not established in the terms. In other words, the companies that we granted the access to our data know who we are and what are we are doing, and maybe they’re sharing it with another companies. Remember that fantastic clothes you were searching one hour ago, that was transformed in a recommendation add about that items linking to an online store (probably Amazon), or searching about cool places in a city in Europe that became in an add linking to a page where you can get tickets to travel. Look into the section «My Activity» in Google Maps to know where you were being at a certain time.

That data was capture probably using a device (smartphone or computer), now imagine more data being capture as you move, what places you like to frequent more, what kind of transportation you use more and what streets you use to move and being categorized as a «probably burglar» or a «good citizen», well now that’s possible and is being tested in the streets of Amsterdam, it is being used to reduce the number of crimes in the city and to make them more secure.

The data is being capture using small traffic lights that detect the MAC address of smartphone or the device you have connected to the internet. You can say you are smart enough and leave the device at home, but probably the identify you using facial recognition with the smart cameras of the city, and let’s be honest, we can live without our smartphone, everything is so connected nowadays that we have to use our gadgets to do (or even in an easier way) a lot of things.

You can see this article for read more about this.


Testing the code is a fundamental part while developing an application, it ensures maintainability, usability and scalability. There are several test tools and frameworks for every ecosystem and programming language that makes the stage of deploying easier.

The method of «test && commit || revert» described by Kent Beck, called my attention, because it enforces the developer to write good tests because if a tests fails it returns the code to the last green commit (all passing tests), that’s why it has to check the code meticulously to ensure it won’t fail and also to save the last state of the code where it worked perfectly. Basically the command runs the nexts operations.

git commit -ma "Test worked" // if passed
git reset --hard // if not

In the experience I had testing my applications it always has been present the part that I do the commit, and then the tests fails in an specific case, so I go back and fix it, and then commit again but because of that fix another part crashed, and so on and so on, so definitely I will try this technique for making me more productive.

An area that is very important for me in the team is the DevOps, it’s impressive how you can speed the development and deployment of a project when you have a well structured CI/CD. I have a little experience in the DevOps area, setting up the CI/CD scripts and the pipelines for the VCS. It is very delightful seeing the tests passing in a deployment process, making newest versions of the application more maintainable and ready-to-deploy. DevOps is an area that every software company has to have.

Resultado de imagen para deployment software memes


The public transport system

In the past few weeks I used the public bus transport system frequently in Guadalajara after two years and a half (I got my first car and used bus a very few times) because of the fuel crisis we were suffering, I ran out of gasoline and the Uber prices were about 3-4 times the base price. I don’t have any problem using this kind of transportation like many people do (some people find like the bus is for the poor).

I would like to start using the public bus more often if it has better units. Let’s be honest, the vast majority of buses in the city are old, rusty, dirty and they left a lot of smog all the way (some are regulated, some not) and if there were a better distribution of the routes. My fist day waiting for the bus, it took like 30-40 minutes to the bus to pass, and I saw another route in the same street passing 7 times, around 5 minutes per bus. Those things have to be improved, because the main benefit of more people using the buses is less traffic in our city, which results in less contamination, less time that takes to go from one point to another.

We have to adopt the culture of the more developed countries and start using the public transport more, because of it benefits to our city and environment. Also, the government has to start changing the units for ones that uses renewable energy (e.j. electricity), regulate and apply fines to those ones that left a lot of smog. There are even cool apps that notifies you in what time a bus route is going to arrive at your bus top, one is Transit (, in México is only available in CDMX, but probably will expand to more cities.

MiBici is a public prepaid bike system that right now is very used in Guadalajara, I find it very useful for short distances, also the user is doing exercise while using it, not to mention that is also eco-friendly. A month ago was implemented in my natal city, Mazatlán, making it the first city in the state, and the pretend to expand to the rest of the cities. Both systems can work with an application. Grin is another transporting app, but this uses scooters.

With all this stuff of everything connected maybe will see new ways of transportation in the next year, and let’s hope they use renewable energy and are eco-friendly.

The gasoline crisis

On January 2019 there were a crisis in Guadalajara. Nearly the 90% of the distribution of gasoline was cut as a consequence of the battle versus the «huachicoleros»

El Colegio de México (México: El Colegio de México, versión electrónica <>, consultado el 20 de mayo de 2017), señala que el término huachicolero alude a la ‘persona que se dedica a bajar fruta de los árboles utilizando un cuachicol o huachicol’ y al ‘delincuente que se dedica a robar gasolina perforando los oleoductos que la conducen

– Academia Mexicana de la Lengua,

A lot of people were frustrated because in order to fill gasoline, they had to wait a minimum of 2 hours in a gas station, (this time takes in consideration that the station was opened and the pipe already discharging gasoline at the time they arrived). So basically you had the variables in order to gasoline.

Gas Station Opened
Pipe Discharging Gasoline
Number of liters discharged enough to fill all the cars before you

Not to mention that the vas majority of gas stations were rationalizing the gasoline, they were dispatching by car just 20 liters, and in some cases, 40.

The people living in Guadalajara saw the caos that this fight was causing, but was for a good cause, right? Besides that, we also realized how attached are we to this fuel, I can’t imagine what would have happened if it had been a vital product, like water or food.

These past days made me wonder that the caos around the city would have been less if more citizens had electric cars, but the caos itself shouldn’t be considered as a reason to switch to an electric car, that switching has to come by oneself, to realize that is time to switch to a renewable energy. But another thing comes in my mind, I think our city is not prepared to handle a considerable number of electric cars around the city. I just saw the charging station that is located in the parking of Plaza Andares, it is the only location that I know, but you know how it is, is the government starts to see that the number of electric cars in the city is increasing, and by request of the citizens, the number of charging stations in the city will increase to meet the demand.

But for now, let’s hope another gasoline crisis does not hit our city

Unit Testing in Node

Writing unit tests in Node is very easy, we are going to use 2 tools for doing that: Mocha and Chai.

Mocha is a feature-rich JavaScript test framework running on Node.js and in the browser, making asynchronous testing simple and fun

Chai is a BDD / TDD assertion library for node and the browser that can be delightfully paired with any javascript testing framework.

First of all, make sure you have installed Node in your computer, you can get it here:

In your workspace folder, run the next command to init a node package, and complete the requested parameters.

npm init

Run the following command to install Mocha and Chai as a dev dependency

npm install --save-dev mocha chai

Let’s write a simple function that adds 2 numbers

const add2Numbers = (x, y) => {
return x + y;

Let’s write the test for that function

// First we have to require chai
const chai = require("chai");

describe("add2Numbers()", () => {
// Description of the test
it("should add 2 numbers", () => {
const x = 1;
const y = 2;

const sum = x + y;

const sumByFunction = add2Numbers(x, y);

// Our assert function

Next step is to run our tests, go to package.json, and add the «directories» property if not set already. Inside directories, we add another key named «test» that will have the value of the directory where we are saving our test files. Also, we need to add our test script, that will be just «mocha».

"directories": {
"test": "test"
"scripts": {
"test" : "mocha"

So far, our project structure should look like this.

- package-lock.json
- package.json
- tests
- - example.test.js

We do the tests running the next command

npm test

The output should look like this

✓ should add 2 numbers
1 passing (11ms)

So far so good! Now you know how to write tests in Node.

You can find the code here