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$
}

mardi 29 mai 2012

Using NuGet with mono on Debian

I tried to use NuGet on my Debian installation and I had several issues to solve. Thanks to this and this link, I was finally able to make it work! Here are the steps:

First install mono with all the SDK:
$ sudo apt-get install mono-complete
Install https certificate so that Mono can trust the source for NuGet
$ mozroots --import --sync

Download NuGet command line bootstrapper (NuGet.exe)

Copy MsBuild dll from Microsoft and put it in the same directory as NuGet.exe. You can find this dll in a Windows OS here "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\Microsoft.Build.dll" or you can find it in Windows SDK for .NET framework 4.0

Finally, running this command line should show help information
$ mono --runtime=v4.0.30319 NuGet.exe
And you should be able to download any package with
$ mono --runtime=v4.0.30319 NuGet.exe Install Cassette.Web

jeudi 26 avril 2012

Setup for new rails project with RSpec

I like to use RSpec instead of Test::Unit for my rails projects. Here are the steps I use to setup my projects.
Create new rails project without Test::Unit
rails new MYAPP -T
Add rspec-rails to your Gemfile:
gem 'rspec-rails'
Choose a javascript runtime in the Gemfile:
gem 'therubyracer', :platform => :ruby
Run bundle install:
bundle install
Install rspec in rails:
rails g rspec:install
Let's write the first spec!

mardi 7 février 2012

Debian gem install RMagick

I tried to install RMagick gem on my Debian box and got the following error:
checking for Magick-config... no
Can't install RMagick 2.3.0. Can't find Magick-config in [...]
I installed libmagickcore-dev:
sudo apt-get install libmagickcore-dev
But I still had an error with:
Can't find MagickWand.h
The problem was solved by installing libmagickwand-dev:
sudo apt-get install libmagickwand-dev
Hope that helps!