mardi 31 décembre 2013

Installing globally Karma test runner on Debian

I was not able to install Karma test runner for JavaScript on my Debian squeeze. It kept failing with the error message:

npm ERR! System Linux 3.11-2-amd64
npm ERR! command "/usr/bin/nodejs" "/usr/bin/npm" "-g" "install" "karma"
npm ERR! cwd /home/ma
npm ERR! node -v v0.10.24
npm ERR! npm -v 1.3.10
npm ERR! path /usr/local/lib/node_modules/karma/node_modules/lodash/dist/lodash.compat.js
npm ERR! fstream_path /usr/local/lib/node_modules/karma/node_modules/lodash/dist/lodash.compat.js
npm ERR! fstream_type File
npm ERR! fstream_class FileWriter
npm ERR! code ENOENT
npm ERR! errno 34
npm ERR! fstream_stack /usr/lib/nodejs/fstream/lib/writer.js:284:26
npm ERR! fstream_stack Object.oncomplete (fs.js:107:15)

By default, Debian installs node.js with the name nodejs although the usual name for the node command is node. For some reason, this causes an issue with the npm install of karma. I then created a symbolic link node which points to nodejs:

sudo ln -s /usr/bin/nodejs /usr/bin/node
This solved the issue and I was able to install karma without any problem with the command:
sudo npm -g install karma

jeudi 28 novembre 2013

How to use solarized colorscheme for vim on a Nitrous box

I'm a happy user of Nitrous.IO for my Ruby on Rails development. As a vim user and a fan of the solarized colorscheme, I had to find a way to set it up for my Nitrous box.

I was not able to setup the full solarized colorscheme for vim so I had to use the degraded 256 colorscheme. To do so, I added the following lines in my .vimrc:

set background=dark
let g:solarized_termcolors=256
color solarized

I can now enjoy using my favorite colorscheme on my favorite editor!

lundi 25 février 2013

Powershell script parameters with complex default value

I needed to create a Powershell script with some parameters having a non-trivial default value and I didn't find any quick reference to do that. In here, I have a parameter having the current week number as a default value:

param
(
  [int] $week = $(Get-Date -UFormat %V)
)

MSTest ReSharper live templates

When developing in Visual studio with MSTest, I like using ReSharper live templates to quickly create my test classes and methods.

To create a test class, I map the following template to "tc":

[TestClass]
public class $TestClass$
{
    $END$
}

To create a test initialize, I map "ti" to:

[TestInitialize]
public void TestInitialize()
{
    $END$
}

And to create a test method, I use "tm" with:

[TestMethod]
public void $TestName$()
{
    $END$
}