Posts

Setting up node-sass on a mac

I followed the installation instructions for node-sass but it would not run from the terminal. The message was something like 'command not found'. Eventually I worked out that I needed to add  /Users/my_user_name/node_modules/node-sass/bin to the path. To do that see my post on setting the path on macs .

Path environmental variable on mac

To view your paths in terminal type: $ echo $PATH To add a path for the duration of this terminal session type: $ export PATH=$PATH:/my/new/path Note: the $PATH: is important as it adds the new path to your existing one. Without $PATH: the existing path is overwritten with the new one. The disadvantage with this approach is that you modification to the path is lost when the terminal session ends. To add to the path for all users permanently you need to edit the paths file in /etc.  In terminal navigate to /etc. Type $ sudo pico paths Add your path. Type ^x (note: ^ = ctrl key). You'll be prompted to save. Type Y . To view your paths using echo $PATH you'll need to reopen the terminal to see your changes.

Problem deleting directories and files in Windows

I was trying to delete a folder containing some node modules that was extremely deeply nested and kept getting errors to do with the file path being too long when using the standard File Explorer delete tools.  I eventually found a solution at  http://stackoverflow.com/questions/28175200/unable-to-delete-node-modules-folder . Create an empty folder somewhere, e.g. C:\test. Open up a command window and run the command 'robocopy /MIR c:\test <directory to delete>. The directory will now be empty and can itself be deleted. The /MIR switch makes robocopy copy the contents for the source directory (the empty one in this case) to the destination folder and delete any existing directories and folders in it.

Visual Studio keyboard shortcuts

A few handy Visual Studio shortcuts and options: Ctrl + -/+ : Move backwards/forwards through navigation history. Ctrl + Alt + L : Shifts the focus to Solution Explorer. Start typing an items name to navigate to it. Ctrl + ; : Search Solution Explorer for a file. Ctrl + q : Search for menu items. To change vertical scroll bar to map mode: Tools > Options > Text Editor > All languages > Scroll Bars > User map mode for vertical scroll bar. To quickly view a file: Single click it in Solution Explorer or select it with the keyboard. When the focus is in the code editor: Alt + vertical arrow keys : Moves current line up or down. To move several lines, select them then Alt + vertical arrow keys.
I've been having a real struggle trying to set up a demo application in Visual Studio 2015 using Asp.NET Core RC2 and Angular2 RC4. My package.json file (the one npm uses) was only picking up the Angular2 beta releases.  I finally found the solution at  https://github.com/angular/angular/blob/master/CHANGELOG.md in the section for 2.0.0-rc.0. Open a command window and change directory to the root directory of the solution (i.e. \<solution name>\src\<project name). Then run the command:   npm install --save @angular/core @angular/compiler @angular/common @angular/platform-browser @angular/platform-browser-dynamic rxjs@5.0.0-beta.6 zone.js@0.6.12. The dependencies section of my package.json file automagically updated to  "dependencies" : {     "@angular/common" : "^2.0.0-rc.4" ,     "@angular/compiler" : "^2.0.0-rc.4" ,     "@angular/core" : "^2.0.0-rc.4" ,     "@angular/platform-browser&

Null Object Pattern

Image
Null Object Pattern Motivation The Null Object pattern can be used to avoid having checks that objects are not null before using them to avoid throwing NullReferenceExceptions, e.g. if (myObject == null) {    return; } // do something with myObject… Example For example, say we have a device object with a Connect() method that a client wishes to call. If we're getting the device from a repository we have to do a check for null before calling Connect(). If however the repository returns the null object, no null check is required. The null check is done within the repository so the client code does have to worry about it. Null object code public interface IDevice     {         string Name { get ; set ; }         void Connect ();     }     public class RealDevice : IDevice     {         public string Name { get ; set ; }         public void Connect ()         {             Console .WriteLine( "Device i
Windows Workflow on DotNetRocks Listened to Blake Helms on the DotNetRocks podcast ( www.dotnetrocks.com show 1236) talking about Windows Workflow. You don't hear much about workflow these days so it was interesting to hear that it is being used for large scale complex applications. It was also interesting to hear how he was initially dead against using it but then switched once he 'got it'.