Suspending processes

Sometimes when I’m running a process in the foreground (most commonly, vim). I unintentionally press Ctrl + z and I get a message like this:

1
[1]+  Stopped                 vim

There might be reasons why you want to do this if you are running in a system that gives you a single terminal, but when running a UI where you can have multiple terminal tabs open, this usually happens by mistake. But no reason to panic, if you want to go back you just have to type this command:

1
fg

As a matter of fact, you can have different jobs running on the background:

1
2
3
4
jobs
[1]   Stopped                 vim
[2]-  Stopped                 vim
[3]+  Stopped                 less Makefile

And reopen them using fg %n. For example:

1
fg %2
Read More

Adjusting the width of Nerdtree navigator

Nerdtree is one of my VIM essentials, but I was always annoyed that it took so much space in the screen. Since I use a vertical monitor, I barely get 80 characters to work on. I recently found that this is easily fixed by adding a configuration to .vimrc:

1
let g:NERDTreeWinSize = 20

Sometimes, when I was browsing through the folders I actually wanted to be able to make it larger so I could see the complete file names. This is also easy to achieve. Move your cursor to Nerdtree and toggle it using:

1
shift + a
Read More

Uploading to an S3 bucket that contains dots using node SDK

I’m trying to host a static site in S3 using AWS. The problem is that for it to work with a custom domain, the bucket needs to be named like the domain. Domain names contains dots and for some reason they are not supported out of the box in the SDK. I was trying to something like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
var fs = require('fs');
var aws = require('aws-sdk');
var bucket = 'my.domain.com';

var bucketParams = {
  params: {
    Bucket: bucket
  }
}
var bucket = new aws.S3(bucketParams);

var uploadData = {
  ACL: 'public-read',
  CacheControl: 'max-age=31556926',
  Key: 'somefile.txt',
  ContentType: 'text/plain'
};
uploadData.Body = fs.createReadStream('somefile.txt');
bucket.upload(uploadData).send();
Read More

Using Gerrit for better collaboration on git projects

I’m working with a small team that is divided in two geographical locations. This separation has made collaboration a little challenging which has compromised the quality of the code base. I’m exploring tools that can help us collaborate better, particularly making it easy to review each others code.

Gerrit promises a platform that makes it possible to create ACLs on top of git repositories, so that code can’t be committed until an official approver checks and approves the code. Ideally, the workflow will look something like this:

  • Carlos makes changes and commits them to his local repository
  • Carlos pushes his changes to Gerrit and creates a code review
  • Luis, as an owner of the project reviews the code and suggests changes
  • Carlos makes the changes, commits them and updates the code review
  • Luis looks at the changes and approves them
  • Carlos can now push the changes to upstream
Read More

Local development with Docker

Docker came with the promise of ending the “works on my machine” syndrome. I have to admit that when I first read about Docker and thought about it, it sounded like they were just bragging. With the little knowledge I had, I thought that the only way to have all developers work in a consistent environment was to start a container and somehow work inside the container. Now that I know a little more, I realize that it is not the answer, and the answer is actually really easy.

Volumes

Docker comes with something called data volumes. These basically allow you to mount a folder from the host system into the docker container. This effectively allows you to have your project folder available in the container. This means that you can keep developing the way you have always done it, and have the code run inside the container.

Read More

SSH to a running docker container

Docker containers are created based on images. If you want to create a new container based on a fedora image and run a terminal on it you can do:

1
docker run -i -t fedora bash

Every time you execute this command a new container will be created based on the fedora image.

Most of the time we run docker containers with servers in a daemonized mode. Here is a very simple example:

1
docker run -i -d fedora bash

In this scenario, we know the container is running, but we can’t really interact with it anymore. If something is not working correctly and we want to debug why, we need to create a new container with a shell and try to reproduce all the steps that led to the error. Well, at least that was the way I used to do it.

Read More

gms.StatusHelper Status from wire: INVALID_AUDIENCE status: null

This weekend I decided to resume work on an Android project I had left behind. Once I had my environment set up I kept getting this error:

1
W GLSActivity: gms.StatusHelper Status from wire: INVALID_AUDIENCE status: null

After some googling I found the problem was that I was trying to call a google service from an app using a signature not registered in my project. I fixed it by going to the developer console for my project:

Read More

Socket Statistics with ss

ss is a replacement for netstat; a program that allows you to analyze the sockets running on a Linux system. In practice, it is useful to investigate if a port is being used and by whom or to investigate which services are running.

In its simplest form, the ss command will list all non-listening sockets:

1
2
3
4
5
6
7
8
[adrian@localhost ~]$ ss
Netid  State   Recv-Q Send-Q       Local Address:Port                          Peer Address:Port
u_str  ESTAB   0      0            /run/systemd/journal/stdout 8313                    * 29127
u_str  ESTAB   0      0            /run/systemd/journal/stdout 9946                    * 30837
u_str  ESTAB   0      0            /var/run/dbus/system_bus_socket 7415                * 25359
u_str  ESTAB   0      0            /var/run/dbus/system_bus_socket  8795               * 18724
u_str  ESTAB   0      0                * 30484                                         * 28442
...
Read More

UI components library with React and Webpack

I’m looking for the best way to create a UI components library. A few weeks ago I explored React with Radium and I have also considered Polymer. This time I want to explore React with Webpack. I already wrote a guide to using Webpack with React. In this article I’m going to focus on creating a component that bundles not only it’s JS and markup, but also it’s styles.

CSS loader

To be able to declare CSS dependencies for our components, we need to use css-loader and style-loader. Installing them is easy:

1
npm install css-loader style-loader
Read More

Using Webpack with React

Webpack is a module bundler similar to Browserify but with a different philosophy. Browserify was born with the goal of making it possible for developers to write CommonJS(node code) in the browser. Webpack allows you to write CommonJS but it also allows you to use other formats that might not be supported by node. One thing that makes it interesting is that since it doesn’t try to comply with CommonJS, it allows developers to declare dependencies on files that are not necessarily JS, which can be helpful to create self contained components.

Getting started with Webpack

Lets create a simple React app using Webpack. We can start by creating our HTML entry point:

1
2
3
mkdir ~/webpack
cd ~/webpack
touch index.html
Read More