Managing docker images and containers

Docker. Probably one of the best inventions since the sliced bread. It makes the life sooooo easy.

Some useful commands:

List images

docker images

Remove images

docker rmi  <IMAGE ID>

List containers

docker ps -a

Remove containers

docker rm  <CONTAINER ID>

Stop all containers

docker stop $(docker ps -a -q)

Remove all containers

docker rm $(docker ps -a -q)

Accessing to a container’s console

docker exec -it <name of the container> bash


Windows is a bully and HP is his sycophant

I just found the transcription of my conversation with HP’s helpdesk last year, when I was trying to install Linux alongside Windows 8…

Continue reading “Windows is a bully and HP is his sycophant”

MEAN.JS 0.4.2 + Leaflet

MEAN.JS + Leaflet screenshot

MEAN.JS is one of the “Open-Source Full-Stack solutions” for developing MEAN applications freely available. There’s other equally acceptable solutions out there, each of them with their particularities.

MEAN applications are those that integrates MongoDB, ExpressJS, AngularJS and Node.js, and it’s a configuration that it’s being used more and more frequently in the last years. There are many options available, sometimes with very similar names ( from Linnovate, and MEAN.JS as a community-governed project from the same creator: Amos Haviv) or technologies still in development (Angular2 is used in some generators even when it’s still in beta at the moment of writing this article). The speed in which a stack solution, generator, framework, or any other starting point for MEAN development, is released and became outdated is astonishing fast. Sometimes, even updates implies a new approach that requires the change of the structure of the code. This makes very confusing for any coder willing to start learning with the tools available.

Leaflet is an “Open-Source JavaScript library for mobile-friendly interactive maps”. It’s very powerful and easy to use, and with the addition of Stamen we can make eye-candy maps very easily.

So, getting to the point. What’s the easiest way to integrate MEAN.JS and Leaflet? In around 5 minutes, and with a little help of copy-paste, we can have a working example.

Installing MEAN.JS

You will require a working installation of node.js.  That’s out of the scope in this article, but in treehouse is easily explained. You’ll need a reboot in your machine in order to be sure that the folders are properly added to the path.

The best starting point is using the yo scaffolding tool:

npm install -g yo
npm install -g generator-meanjs

Then, we need to create a fresh copy of MEAN.JS. In this example, I will be using MEAN 0.4.2. That’s the version you should initiate if you want to be sure that my tutorial is working. I’ll ask the generator to create all the available examples. They are quite convenient in order to understand how the code should be structured.

yo meanjs

Let’s say you create a project folder named mean-leaf. Then, you’ll need to get into that folder.

cd mean-leaf

You will need a working global installation of Grunt and Bower. So, if you need to install them:

npm install -g grunt-cli
npm install -g bower

We add the angular-leaflet-directive:

bower install angular-leaflet-directive --save

And now, we use Grunt to run the application:


If you have the error “You need to have Ruby and Sass installed and in your PATH for this task to work”, just execute the following and run grunt again:

sudo gem install sass

Adding the Leaflet maps

With the previous steps, MEAN.js should be up and running. Now, we are going to integrate the Leaflet map. More examples can be found in the angular-leaflet-directive Github page, but I found the “Center example” the most appropriate for having an initial taste.

Remember that you’ll need the angular-leaflet-directive installed as mentioned above.

Adding the required JavaScript and CSS files

We’ll need to add the leaflet CSS and JavaScript files to config/assets/default.js. I found quite useful using the CDN versions, so that’s what I’ll show here. The code will be more or less this (just showing the modified sections):

// (...)

css: [

// (...)

js: [

// (...)

This works the same with any other external CSS or JavaScript file you want to add.

Using the directive

In the file modules/core/client/app/config.js we need to add the directive to the dependences. We will just add it to the array in line 7:

// (...)

var applicationModuleVendorDependencies = ['ngResource', 'ngAnimate', 'ngMessages', 'ui.router', 'ui.bootstrap', 'ui.utils', 'angularFileUpload', 'leaflet-directive'];

// (...)

Now, we need to add the JavaScript to /config/assets/default.js. Is the same file we used previously, but now we’re adding a line in the client > lib > js section. After the changes, it will be something like this:

// (...)

js: [

// (...)

Inserting a map

We will add the following code somewhere in our view /modules/core/client/views/home.client.view.html to insert the map:


 <leaflet center="center" markers="markers" url-hash-center="yes" tiles ="tiles" height="400"></leaflet>
 <form class="text-center">
 Latitude :
 <input type="number" step="any" ng-model=""> Longitude :
 <input type="number" step="any" ng-model="center.lng"> Zoom :
 <input type="number" step="any" ng-model="center.zoom">



But that’s is not enough. We need do some modifications to the code of the controller modules/core/client/controllers/home.client.controller.js (be very careful with the indentation here, WordPress is breaking the code and it’s important):

'use strict';

angular.module('core').controller('HomeController', ['$scope', 'Authentication',
 function($scope, Authentication) {
 // This provides Authentication context.
 $scope.authentication = Authentication;

angular.extend($scope, {
 center: {
 lat: 51.528308,
 lng: -0.3817736,
 zoom: 7
 defaults: {
 scrollWheelZoom: false
 tiles: {
 Name: 'Stamen Toner Lite',
 url: 'http://stamen-tiles-{s}{z}/{x}/{y}.{ext}',
 options: {
 ext: 'png',
 attribution: 'Map tiles by <a href="">Stamen Design</a>, <a href="">CC BY 3.0</a> &mdash; Map data &copy; <a href="">OpenStreetMap</a>'

This should be enough. Just run grunt and visit your website. If you have errors with eslint and the indentation, just edit modules/core/client/controllers/home.client.controller.js and make the modifications displayed in the console.

The result should be something like the following screenshot:

MEAN.JS + Leaflet screenshot

The example used for this article, and many others, are available in the angular-leaflet-directive examples gallery, and also in their Github.


UEFI and Linux

The UEFI (Unified Extensible Firmware Interface) is an example of a good idea developed, enforced, and implemented in the wrong way. What was meant to help us protecting our computer, turned into some kind of kidnapper that prevented us to use the OS of our choice.

Installing a different OS to the provided by the manufacturer is a, sometimes impossible, sometimes painful, task. Some manufacturers simply don’t contemplate the use of anything different from Windows 8 or 10 in their machines (ajem, HP, ajem), forcing us to press the Boot-order-selection key during the booting of OUR devices in order to being able to start, let’s say, Linux. Every single time. I repeat. Every. Single. Time. And it’s curious how, no matter which procedure you use, and how many times you change the UEFI boot order, Windows always comes to the top.

Although I have not been able to fix this problem in my HP machine (well, I know the solution, not buying HP products anymore), I successfully managed to fix it in 2 Lenovo machines. The procedure is quite easy -but use it under your own responsibility. Presuming that Linux has been installed in UEFI mode correctly (there are different methods to check this, but the easiest is to check if you have a boot/efi folder using the command df -h –local | grep /boot), you just need to install boot-repair:

sudo add-apt-repository ppa:yannubuntu/boot-repair
sudo apt update
sudo apt install boot-repair

Just the quick setup should do the magic. However, in my experience, it was not so easy, and the machine was still booting into Windows. I had to boot into Windows and execute the following command in the command line with administrative privileges:

bcdedit /set {bootmgr} path \EFI\ubuntu\shim64.efi

That seems to work in the Lenovo machines, but not for HP (such a surprise).

The easiest way to work with a remote server

For many reasons, you can find yourself working with a server where many and constant changes need to be done. This usually implies doing a modification to a file, uploading it, testing it, modifying something again, uploading, and repeating.

There’s many different approaches to manage this routine.

The 1st option is editing from the terminal. This is not bad, as Vim, Nano (I previously wrote how to activate markdown in Nano), and other command line editors are powerful options and allow us to fulfill most of the tasks. However, it can be a headache editing several files, not being able to use the mouse’s scroll wheel (that is there to be used!), or the beautify plugin.

Another option that works perfectly fine requires the creation of Grunt tasks. However, we could lack a little bit of flexibility if we do many different tasks. Also, we still need to spend some extra time creating connections and uploading the files.

We could also install a X server and access through remote desktop to our server, but that will imply an use of extra resources (memory, space, and bandwidth… And therefore, money) that could be used for more interesting things.

At the moment, the way I’m using to bypass all this trouble and make my life easier, consists in using SSHFS and Fuse. Basically, I will have my remote drive mounted like a local drive, and I can use all the editors I want, and I can use drag’n’drop to easily play with my files. Something similar can be done using the FTP protocol, but this is inherently insecure. That’s why I decided to use SFTP in this case, which is FTP implemented under SSH.

So… How I do it? Easy. First, SSH access is needed. If you can connect to the server through SSH to your server, you can use sftp to transfer files from/to your server, as they explain in DigitalOcean.

SFTP is pretty cool by itself, but we can make it awesome. Oh, laziness, the mother of the best inventions… SSHFS will be the responsible to mount the remote folder in our system. The installation is a piece of cake in Ubuntu and derivatives:

sudo aptitude update
sudo aptitude install sshfs
sudo adduser $USERNAME fuse
mkdir ~/Desktop/sftp

reboot is required to complete the process.

Then, for mounting the remote folder a simple command line is required:

sshfs ~/Desktop/sftp

And for unmounting:

fusermount -u ~/Desktop/sftp

My suggestion is to mount the folder the first time as

sshfs ~/Desktop/sftp

in order to find out which folder is mounted as default, as it depends on the server and user configuration.

If you have some error like

fusermount: failed to open /dev/fuse: No such file or directory

there’s a easy workaround:

sudo mknod -m 666 /dev/fuse c 10 229

You can create an alias, or a .bashrc entry to automatise this task every time you boot your computer, but I rather prefer to do it manually when I consider is the moment. That’s why I created 2 easy scripts:

# Mount sftp folder
sshfs TheUser@YourIP:/home/TheUser ~/Desktop/sftp
echo "Done"

# Unmount sftp folder
fusermount -u ~/Desktop/sftp
echo "Done"

Cool, isn’t it? Just remember to be careful, I’m not responsible if something goes wrong. If you want to know a little bit more, you can visit damontimm‘s website, where I took much of the information from.

How to add ‘Open File/Folder as Root’ in Elementary OS Freya

Elementary OS Freya. Simple. Elegant. But there is still some things I miss, like the option to open a folder or a file with root permissions from the file explorer. With these easy steps this issue can be easily solved:

1.- Install gksu in order to be able to prompt for superuser permissions from the window manager.

sudo apt-get install gksu

2.- Create the “open folder as root” contractor.

sudo touch /usr/share/contractor/folder-openasroot.contract && gksudo scratch-text-editor /usr/share/contractor/folder-openasroot.contract

3.- Add this to the contractor:

[Contractor Entry]
Name=Open folder as root
Description=Open current folder as root privilege
Exec=gksudo pantheon-files %U

4.- Create the “open file as root” contractor.

sudo touch /usr/share/contractor/file-openasroot.contract && gksudo scratch-text-editor /usr/share/contractor/file-openasroot.contract

5.- Add this code to the contractor:

[Contractor Entry]
Name=Open file as root
Description=open file as root with scratch
Exec=gksudo scratch-text-editor %U

And… Done!

Arduino up and running in 1 minute 20 seconds

Sorry guys, only if you are using Linux you can have Arduino up and running after only 1:20 (approx) , and the only thing you need to do is to write 1 single code in the terminal:

sudo apt-get install arduino

setupandrunning from Jumy Elerossë on Vimeo.


Open the Arduino IDE, press “Add” on the screen that appears, reboot the computer, open again the Arduino IDE, connect your board to your PC, select the serial port under “Tools > Serial port”, select your board model from “Tools > Board” and.. Presto!

You can upload the blink example (any other component but the Arduino board is required) just selecting it at “File > Examples > 01. Basics > Blink” and press “Upload”.

Do you need something easier?

Installing Microsoft Truetype core fonts

Microsoft’s arm is really long. There is many Microsoft users and it is really easy to find a document or a website using proprietary fonts included in Windows. Sometimes this can be a problem if we want to see that document or website as the designer intended, as usually are not included by default in Linux.

Usually, just installing the Microsoft True Type Core Fonts for the Web solves the problem. This package includes:

  • Andale Mono
  • Arial Black
  • Arial (Bold, Italic, Bold Italic)
  • Comic Sans MS (Bold)
  • Courier New (Bold, Italic, Bold Italic)
  • Georgia (Bold, Italic, Bold Italic)
  • Impact
  • Times New Roman (Bold, Italic, Bold Italic)
  • Trebuchet (Bold, Italic, Bold Italic)
  • Verdana (Bold, Italic, Bold Italic)
  • Webdings

sudo apt-get install ttf-mscorefonts-installer
sudo fc-cache -f -v

You will need to accept the license in order to allow the installation to complete.

If you are using Ubuntu, you need to activate the Multiverse repository previous to installation.

However, we can also use the package ttf-liberation, which includes fonts developed by Fedora with the same metrics than the Microsoft ones. The fonts included in this package are:

  • Liberation Mono
  • Liberation Sans
  • Liberation Serif

sudo apt-get install ttf-liberation
sudo fc-cache -f -v

HP’s Beats Audio and Linux

I’m not writing now about all the problems with the HP laptops and Linux. I’m not going to say that Microsoft is a bully and HP is his sycophant. Not today.

If you have one of those HP laptops with Beats Audio and you managed to install Linux, you will realise that the sound is… Well… Crap.

This is how you solve it:

1.- Install alsa-tools-gui:

sudo apt-get install alsa-tools-gui


If you have any problem, try adding this repository:

sudo add-apt-repository ppa:diwic/hda && sudo apt-get update && sudo apt-get install hda-jack-retask

2.- Launch hda-jack-retask:


3.- Select the codec beginning by IDT and remap these pins (you need to check “Show unconnected pins”):

  • 0x0d (Internal Speaker, Front side) to “Internal speaker”
  • 0x0f (“Not connected” but is the under-display speakers) to “Internal speaker”
  • 0x10 (“Not connected” but is the subwoofer) to “Internal speaker (LFE)”

Click on “Apply now”. Un-mute the sound and increase and decrease the sound volume. Now run this in a different terminal to be sure that everything is workign fine:

speaker-test -c5 -l1 -twav

If something goes wrong, just reboot. If everything is working fine, press on “Install boot override”.

In the case those overriding pins are not correct, you can try your own configuration until everything goes all right.



Spotify for Linux


Spotify has updated the instructions for Linux. Take a look to it:

Continue reading “Spotify for Linux”