Andy Crouch - Code, Technology & Obfuscation ...

Using NVM To Manage Node Versions Across Projects

Photo: Unsplash - Brennan Angel

A lot of the projects I am picking up as part of my work recently has been around Node and JavaScript. This ecosystem is one that I have studied from the sidelines. While I have used JavaScript for well over 15 years, it has always been in the browser. So some of the future posts here over the next few weeks will be useful snippets and brain dumps of stuff I am learning.

One thing that most developers agree on is the speed at which the JavaScript community moves. The rate at which package versions are upgraded and at which frameworks change can cause problems for one project. If you are managing more than one project then you need a way to manage multiple versions of Node. The answer is to install NVM - Node Version Manager.

How you install NVM depends on your platform. The Github page has detailed instructions that I will not repeat here. Once installed you will need to source the NVM file from your shell rc file (.bashrc, .zshrc etc):

source /usr/share/nvm/

(Note - The installation path may vary on your machine).

(nvm is not natively supported on Windows but there is an NVM-Windows package.)

Using nvm is really easy:

To install a new Node version for the local user you can execute nvm install version:

nvm install 12.13.0
nvm install 11.10.1

To switch between Node versions then you execute nvm use version:

nvm use 12.13.0
nvm use 11.0.1

It really is that simple.

If you want to force a given version for a project then you can create a .nvm file in the root directory of the project. In the file, you just add the Node version number the project should use wrapped in single quotes. Then when you switch to the project you can just run:

nvm use

The project Node version will be used.

If you want to use nvm to see what versions of Node are available then you can use:

nvm ls-remote

Nvm also has some aliases which target the latest versions of both the stable and unstable:


So running the following will install the latest version of Node:

nvm use node

You can, of course, uninstall versions using:

nvm uninstall 11.0.1

If you want to check the version of node you are running you can use

nvm current.

Nvm is a really useful tool to manage Node versions. I hope to see more people using it to set Node version information at a project level. This will speed up the process of getting a project running locally.

If you have thoughts around this subject please contact me via twitter or email.

Running Linux On A Thinkpad P52

Photo: Lenovo

A new job is as good as an excuse as you get to treat yourself to a new laptop. For over 12 years I have used custom-built laptops from PC Specialist as they provide great specs. Their costs are hard to beat and when on startup budgets they give the best bang for your buck. But, I have forever been a Thinkpad fan. I have owned a few over the years for side projects and personal use. I currently own a T430 which apart from a battery upgrade is still in everyday use. I was planning on switching full time to Linux, as I no longer needed Windows, so I decided to invest in a new Thinkpad.

I opted for a P52 on which I have installed Manjaro i3. The machine is a 6 core i7 with 16gb and a 512gb SSD. The screen is a 15 inch full HD affair which is powered by a combined Intel graphics card and an Nvidia Quadro P1000.

There is a raft of reviews about the P52 online about installing Linux. The Arch wiki as a great entry as a starting point and seemed like it was a good fit.

Before you begin you have to ensure that your BIOS is updated. Many articles from about a year ago mention bricked machines. You also need to ensure that your BIOS setting for graphics is set to hybrid. Follow the instructions in the Arch wiki article. I then installed Manjaro i3 community edition. I reformatted the whole drive and installed the non-free drivers. I then rebooted and everything worked except the trackpad and the TrackPoint. So I installed the Synaptics package and rebooted and I had a working machine.

sudo pacman -S xf86-input-synaptics

The next thing was to figure out the graphics situation. Manjaro had installed the Bumblebee driver. This provides Optimus two-card switching to provide the best battery performance. It does this by the Intel card being used most of the time offloading high resolution and 3D responsibilities to the NVidia card. There is just one problem and that is the external monitor ports are all hardwired to, you guessed it, the Nvidia card. At present, there appears to be no easy way around easily switching between cards. Bumblebee did not want to output anything via the Nvidia card no matter what I tried. It was time to install an Nvidia driver. So I opened the Manjaro Settings Manager and selected the Hardware Configuration option. I scrolled down to the Nvidia drivers that are available to install and right mouse clicked the one I needed and selected “Install”. After a lengthy process, I rebooted and then hit the command line to try out switching manually via Optimus-manager.

optimus-manager --switch nvidia    # Use Nvidia graphics

optimus-manager --switch intel    # Use Intel graphics

optimus-manager --switch auto    # Use other graphics

This works but anytime you switch you will be ejected from your graphical session. This means you get to sign back in again! Not ideal. Nvidia needs to update their drivers for Linux to solve this. I created some aliases for these commands:

alias switch-nvidia="optimus-manager --switch nvidia    # Use Nvidia graphics"
alias switch-intel="optimus-manager --switch intel    # Use Intel graphics"
alias switch-auto="optimus-manager --switch auto    # Use other graphics"

You need to watch out for is the power consumption and heat generation on running the Nvidia card only. There is a guide .

That left the only thing known not to work as the fingerprint reader. This is a shame but not a deal-breaker for me.

On the whole, this is a great laptop for the price paid. It is well built and has a great screen and keyboard. It feels like it will last forever without being heavy or bulky. Manjaro boots in seconds and was pain-free to set up and get a good working environment. I recommend the P52.

If you have any questions or suggestions related to the P52 please contact me via twitter or email.

Include A README

Photo: Brennan Angel

Over the last week, I have looked at the code for 4 projects. Each of these is for clients for my new consultancy, Platform Eight (more on that another time). There is a common thread I have seen across the projects and that is a complete lack of documentation.

Now I know that as developers we hate documentation and I get that. The dream of writing code that is so prose-like that no documentation is required is still just a dream. This post isn’t a rant about a lack of functional documentation or schematics. Agile rightly attempts to limit this.

What every project does need though is an up to date, relevant README

A README file is a file written using Markdown syntax. It is used to convey some basic information about your project. Details such as how to clone it, required software or libraries and how to build and get the project running. The README is usually found in the root of the project folder. Git-based source control systems such as GitHub use this content. They display it when you land on the projects hosting page.

Now stop and think about how you mentally feel when searching for projects on GitHub. Do you trust the projects that have no details on their page? Or do you find yourself more trusting of the pages with lots of helpful details and screenshots?

Private, commercial, projects are no different. Git allows me to see who has worked on a project. Their reputation to me is influenced in the same way as you are influenced when landing on a GitHub project. The impact of a reputation for software teams and dev houses is even greater. When being paid to start a project with a view to handing it back, the lack of a README or any basic project document is damaging. I would advise any client to demand this document in any agreed contract or agreement or withhold payment until it is produced.

Why? Well, there are a couple of trains of thought here. The first is developer productivity. If a developer takes over a project they want to be up and running with the code ASAP. They do not need to spend their time figuring out how they need to configure their machine. What version of the stack should they be running? Which libraries and versions need to be installed? Some frameworks make this a trivial matter. But some allow you to set up projects and environments in various ways. Again this matters if you transfer a project between developers or teams and you are paying a day rate. You are effectively doubling your costs. The other thought is that if the developer(s) can not be professional enough to add a README then what state is the code in? That might seem a harsh comment and is not always the case but it carries merit.

As always you might want to think of it from an investment point of view as well. If you have to go through a Due Diligence process with no basic documentation then you will need to defend that.

Here is a great template from GitHub. If you need to, go and copy it and fill in the blanks. Don’t be the developer or team that tries to hide or use your project knowledge for financial or reputational gain. It just makes you look bad.

If you have thoughts around this subject please contact me via twitter or email.

Leaving Open Energy Market

Photo: Andrew Neel - Unsplash

Five years ago today I joined Open Energy Market. The plan was to create a new technology-focused commercial energy buying platform. It was an industry that managed their data in spreadsheets. There was no transparency for clients in either costs or the value in their data. There was zero competition between the suppliers. It seemed like an opportunity to build something new in an industry that could still be disrupted.

Five years on and the company is still growing from strength to strength. At one of our regular company days recently we took the time to sit back and look at what we have achieved. The market is saturated with brokers of varying sizes but we now just sit outside the top ten. We manage a significant percentage of commercial consumption in the UK and have launched products new to the market which customers are keen to buy into. None of the ten top brokers is providing access for customers to their data in the way we have. They know that in doing so it will reveal the high costs and charges they have hidden for years.

I have been very fortunate to work with some great people over the last five years. As the company has grown we have brought in some very experienced people who have added real value. From the early days in a small, mouldy office in Surbiton to our current offices in Guildford and Bromesgrove change has been a steady constant, always for the better. Some of the early team have gone, some have even left to found their own companies.

Yesterday marked my last day at Open Energy Market. Five years is a long time to lead the development of one product. Taking the prototype through the early customer lead iterations through to the investment last year. Moving beyond the excitement of investment and into the next stage of the companies growth. I am proud of the technology we have built in such a changing environment. I am also aware of the opportunity in front of the company and the longer-term company plans. Now felt like the right time to pass the reins on to the right person to lead these second phase.

Personally, my proudest achievement is the technology team I built. A small team that grew over a few years and which seems like a second family. Some I have worked with before, all I hope to again in the future. A remote team that showcased all the benefits of such teams. Finding great people regardless of location that is so productive that collectively you can achieve great things. From my early compadre Saurabh through to Clare, Andrew, Irene, Liam, Paul, Manish and Reena I thank you all. You have made the last five years fun and rewarding journey for me. Our discussions, planning, realisations and technical achievements have made me think in ways I may never have. I hope you all got as much from me as I from you.

I wish Chris and the whole Open Energy Market team all the best for the exciting times that lay ahead. I will be following their progress closely.

I am going to take a small amount of time before embarking on my next roles. I am keen to continue working with small teams and early startups as the energy and excitement they generate is addictive. I will now have time to provide advice and support where needed and take up some of the opportunities presented to me.

If you wish to discuss an opportunity please contact me via twitter or email.

Browser Design Mode

Photo: Agnieszka Boeske - Unsplash

A super busy week (for reasons that will become clear in next weeks post) led me to almost not posting this week. But, I was on Twitter tonight and saw a Tweet gaining a lot of attention and I can see why.

By executing the following code in the developer tools of your browser (or in a script)

document.designMode = "on"

you can directly edit the content of the web page you are on. Just like a CMS editor. The property defaults to “off”.

This may not seem a massive thing. I can think of many times this would have saved me so much editing via development tools when sat with a user.

The full feature details can be viewed here. I did read in a couple of associated articles that for IE the on/off values for the property need to be capitalised.

The changes you make can not be saved from what I can see and do not show up in the diff tools provided by developer tools. It is still really handy and I will make a lot of use of this.

If you have any great tips for front end development then please contact me via twitter or email.