Wednesday, January 30, 2013

Using nvm to manage multiple active node.js versions

Today I had to install a different version of node.js on my laptop, because the program I wanted to try required a newer version than the one I had.

After googling a bit, I found nvm developed by Tim Caswell. It is a "simple bash script to manage multiple active node.js versions", (nvm stands for Node Version Manager). It helped me to quickly solve my problem.

I followed the installion instructions and in 3 steps I had the last version of node (v0.8.18) up and running.

This is what I did:

First I show you the very old version that was installed on my laptop for a previous pet project:
$ node --version
v0.5.11-pre
I cloned nvm repository from GitHub:
$ git clone git://github.com/creationix/nvm.git ~/.nvm
Initialized empty Git repository in /home/bscuser/.nvm/.git/
remote: Counting objects: 557, done.
remote: Compressing objects: 100% (327/327), done.
remote: Total 557 (delta 290), reused 471 (delta 219)
Receiving objects: 100% (557/557), 76.33 KiB | 8 KiB/s, done.
Resolving deltas: 100% (290/290), done.
And followed Tim's instructions by, first, sourcing the nvm.sh script
$ . ~/.nvm/nvm.sh
and then using nvm to install the current version of node
$ nvm install v0.8.18
######################################################################## 100,0%
Now using node v0.8.18
Once it finished, the node version was:
$ node --version
v0.8.18
As I plan to be using the program that needed this newer version of node for a while, I added the following lines to my .bashrc file:
. ~/.nvm/nvm.sh
nvm use v0.8.18
so I have the v0.8.18 version every time I open a console.

nvm has many other useful options that I plan to use. Thank you very much Tim for sharing it.

Tuesday, January 29, 2013

Monday, January 28, 2013

Articles and Posts read

Inspiring
Pure possibility
Big Problems, Little Solutions: For the New Occupy, Size Is Everything
Grace Hopper

Learning and software craftsmanship
Ruby Dependencies, Notifications, and Adjustments
Thoughts on "Arguments and Results", Part 1
Preferring objects over class methods in OOP
“The best minds of my generation are thinking about how to make people click ads”
The Year of the MOOC
Rise and Fall of the Third Normal Form
Quality is Not Job 0xff: There is No Good Enough
A Programmer’s Thanksgiving
Who's Afraid Of Legacy Code?
Debugging Heisenbugs
Some things I've learnt about programming
Programming, Motherfucker
Looking inside the black box
Seams: Some thoughts
Book Club: The Readability of Tests – Growing Object Oriented Software (Steve Freeman/Nat Pryce)
Book Club: Growing Object Oriented Software – Chapter 7 (Steve Freeman & Nat Pryce)
OO: Micro Types
Software Development and Lifelong Learning
Quotes of the day: Constraints on programming
airbnb: Our JavaScript Style Guide
Isn’t It Ironic?

Agile and Lean
Caso de estudio: Como Spotify organiza, de manera ágil, su departamento de desarrollo software

C++
Continuous Integration for C++ using Hudson

JavaScript
Testing JavaScript with PhantomJS

Entrepreneurship and Management
Preventers, Not Managers
Respect and the 40-hour work week
El arte de compartir: cómo conseguir que difundan tus contenidos en redes sociales
La deuda técnica. Todo el mundo debería saber que la mala calidad software al final se paga

Software Development in Spain
El drama de las pequeñas consultoras
La copia de la web del Senado hecha por un programador

Science
The paper was rejected, but do the readers care?
Blind Patient Reads Words Stimulated Directly Onto Retina: Neuroprosthetic Device Uses Implant to Project Visual Braille

Rebooting Spain
¿Dónde está el interruptor de la revolución industrial en España?
Modernizar España

Spain and Europe
Un investigador español agradece en un artículo científico al INEM la financiación recibida
El ataque alemán desahucia a España
El ministerio 'concede' las becas doctorales FPI tras cuatro meses de retraso

Wednesday, January 16, 2013

How to access the first element of an Json::Value array

To access the first element of an Json::Value array the following code may not work:
...
double x = point[0].asDouble()
...
Instead you have to write:
...
double x = point[0u].asDouble()
...
To find out why just check the following fragment of the Json::Value documentation:
const Value & operator[] (int index) const
Access an array element (zero based index)
You may need to say 'value[0u]' to get your compiler to distinguish this from the operator[] which takes a string.

Tuesday, January 15, 2013

How to move files or directories in Subversion without losing their history

Sometimes we need to move files or directories in our code to a better location.

So far, we were doing it using the Move option in Eclipse.

However, this was wrong, let's see why:

Our code is under Subversion, a version control system.
The way we were moving things was interpreted by Subversion as if we had deleted them and the added new ones. That means that all the history of the moved item is lost and that's not what we intended.

To keep the history of the item when moving it, we must use Subversion to move it.

This is how it's done from the console:
$ svn move source destiny
This command moves the file/directory in your working copy or in the repository keeping its history. It's equivalent to an svn copy followed by svn delete.
The only limitation is that you can only move files within a single repository and the destiny must be a working copy, that is, it must be already included in your repository (to know more).

So from now on, anytime we want to move files or directories in our code to a new location, we'll use svn move.