Gabo Esquivel - Javascript Developer Software Developer and Web Technology Consultant

Automatic Node.js Version Switching

When working on multiple Node.js projects it is important to configure your development environment to automatically switch to right node version for a particular project. You can automate this task on many different ways. I opted for using using a module called avn that works both with nvm and n for automatic Node.js version switching. In my case I use nvm as my version manager. In order to achieve automatic version switching with avn you need to add a .node-version at the root of your projects specifying the node version required.

After installing avn, when you cd into a directory with a .node-version file, avn will automatically detect the change and use your installed version manager to switch to that version of node. If that node version is not available you have install it, avn won’t try to do so, it will only attempt to switch to that version and notify you if it is not available on your environment.

It is important to mention that as good practice you should always specify that node version on the package.json file on the engines attribute "engines" : { "node" : "0.12.7" } }

On Continuous Delivery

Continuous delivery is practice in software development in which development teams work in a way that allows companies to update their systems at any point in time or continuously through automated processes, the system’s code base is always deployable and tested.

Why is it important?

Continuous delivery is a more efficient way to build software as it enables a team to get constant feedback on the application’s changes and updates, allowing you detect problems early and consequently reducing costs and deployment frictions. It also gives the team a realistic view of development progress instead of relying on perceptions.

It gives a company the ability to react quickly and respond to change. Having fluid a process of software development allows you to make changes on your strategy more easily and rapidly.

Cortical Touch: JavaScript Development and Consulting

After years of working as an independent software contractor I decided to partner up with web specialists in Costa Rica and start a software consulting firm specialized in JavaScript Applications. The name of the company is Cortical Touch. Our vision is to become one of the best modern web firms.

At Cortical Touch we develop custom software using lightweight agile methodologies working closely with you to meet your business goals. We are experienced and skilled JavaScript, Agile, DevOps and Web specialists supporting you during implementation of strategic milestone projects, whether you are starting from scratch or need help improving an existing code base.

How to Keep Up With JavaScript and Open Source

The JavaScript development ecosystem is vibrant and it´s rapidly growing, there’s a myriad of libraries, frameworks and tools that are constantly evolving and every day new solutions, techniques and modules are published. The language itself is evolving quickly with new ECMAScript versions, native browser support for those specifications and a stack transpilers and polyfills.

This is not a specific to JavaScript, technology in general evolves fast and open source even faster. The following is a list of useful resoures and tips to keep up to date.

Films and Documentaries Worth Watching

This is a curated list of films and documentaries related to the internet, programming and hacking. If you are a web developer or consider yourself a problem solver you will probably enjoy them. These films contain historical and philosophical content on subjects related to programming, the internet, the evolution of human consciousness, activism, social action, environmental causes, open source and free software movements.

Unit Testing: Mocks, Stubs and Spies

In unit testing isolation is key. The class/object/function you are testing is called the System Under Test (SUT) and the SUT often interacts with other part of the system, these parts are called Collaborators or Depedencies. When testing the simulation of the collaborators/dependencies and behaviors of these dependencies allows you to to test the units in isolation. Gerard Meszaros author of xUnit Test Patterns uses the term “Test Double” as the generic term for any kind of pretend object used in place of a real object for testing purposes. The name comes from the notion of a Stunt Double in movies.

Mocks, Stubs, Spies, Dummies and Fakes are types of test doubles that will help you to accomplish the goal of isolation. There are several libraries that provide tools to easily create these objects in your tests. Sinon.js is a javascript library that provides standalone test spies, stubs and mocks with no dependencies that work with any unit testing framework.

Software Unit Testing

Testing a web application is critical to ensure the program does what is supposed to do and that new functionality and changes don’t brake existing parts of the application. Well-tested applications are more easily extended.

Testing can be defined as:

Taking measures to check the quality, performance, or reliability of (something), especially before putting it into widespread use or practice.

“Oxford Dictionary”

There are 3 main levels of testing and they are complementary:
Scenario Testing / End-to-End Testing (E2E) : test the whole application by pretending to be a user.
Functional Tests / Medium Level Tests: a piece of functionality is tested in isolation, by simulating external dependencies.
Unit Tests: focused on application logic, tests the smallest unit of functionality, typically a method/function.

Unit testing works by isolating small “units” of code so that it can be tested from every angle. Any kind of dependency that is slow, untested, hard to understand or initialise should be stubbed or mocked so you can focus on what the unit of code is doing, not what its dependencies do. Tests should ideally be written by developers, the same person who writes the functionality, not a QA team. Demoting unit testing to a lower level of priority is almost always a mistake.

In-Place Editing With Contenteditable and AngularJS

In-place editing provides an easy way to let the user edit parts of a page without having to be redirected to an edit page. Instead, the user can just click around on a page an edit the elements he or she wishes to change – without reloading the page. When the user hovers over an editable area, the background color of the element changes. When clicked, the text becomes editable.

You can make an element editable by adding the contenteditable attribute in your markup. This attribute has three possible values: true, false, and inherit. Specifying inherit will make the element editable if it’s immediate parent is editable.

1
<div class="editable" contenteditable="true"></div>

The following directive uses contenteditable attribute and ng-model for data binding.

See the Pen Editing Page Elements with contenteditable by Gabo Esquivel (@gaboesquivel) on CodePen.

 

Node.js HTTPS and SSL Certificate for Development

HTTPS is the HTTP protocol over TLS/SSL and HTTPS is required to protect your data. It is the most popular network protocol for establishiing secure connections for exchanging documents on the internet. It is basically HTTP carried over a TCP socket, which has been secured using SSL. Transport Layer Security (TLS) and Secure Sockets Layer (SSL) are cryptographic protocols designed to provide communication security. In this post I’ll show how to create a self-signed SSL certificate and set up an express 4.0 project that uses it for local development purposes.

Self-Signed SSL Certificate

There are two kinds of certificates: those signed by a ‘Certificate Authority’, or CA, and ‘self-signed certificates’. A Certificate Authority is a trusted source for an SSL certificate, and using a certificate from a CA allows your users to be trust the identity of your website. In most cases, you would want to use a CA-signed certificate in a production environment – for testing purposes, however, a self-signed certicate will do just fine.

Reasons to Use AngularJS in Web Applications

 

 

First, a quick introduction. AngularJS is an open-source web application framework for creating single page web apps. It was created by Miško Hevery and Adam Abrons back in 2009 and it’s now maintained by Google and community.

AngularJS is built around the belief that declarative programming should be used for building user interfaces and wiring software components, while imperative programming is excellent for expressing business logic. The framework adapts and extends traditional HTML to better serve dynamic content through two-way data-binding that allows for the automatic synchronization of models and views. As a result, AngularJS de-emphasizes DOM manipulation and improves testability & performance.

AngularJS is winning the frontend framework war. There are other high quality alternatives out there, but few have gained so much developer support, they love developing with it. Even conservative companies now see Angular as an investment and they are paying for AngularJS trainings and tools. This graph of Google Search Trends shows the interest over time: