Category: Development

  • How to assert.throws on an async function with a callback

    Recently, I was writing a module that took a callback, and needed to write a test, asserting on an exception. Here’s how to do it: it(‘throws error if myParam is less than 10’, function(done) { var fn = function(){ myModule.doSomething(8, function(err) { if (err) throw err }); } assert.throws( function() { fn() }, /Value is…

    Continue reading

  • Removing $id from JSON returned by WebApi

    If you’re using the default JSON formatter (ie- haven’t set another one up) your outputted JSON may look something like this: [ { $id: “1”, FirstName: “John”, LastName: “Smith”, }, { $id: “2”, FirstName: “Sarah”, LastName: “Harris”, }, { $id: “3”, FirstName: “Michael”, LastName: “Jones”, }, { $id: “4”, FirstName: “Harry”, LastName: “Green”, } ]…

    Continue reading

  • Unit tests failing when run all together with FakeItEasy

    While running my tests, I noticed that if I ran my test suite all together, some would fail, giving the exception: API restriction: The assembly has already loaded from a different location This issue was happening both in ReSharper test runner, and using the NUnit test runner Debugging, the exception was being thrown on my…

    Continue reading

  • Git Error – bad config file line 1 in .git/config

    Last night, just before leaving the office, my development VM decided to crash unexpectedly. Upon starting the machine the machine the following morning, and trying a git pull, I got the following error: bad config file line 1 in .git/config I CD’d into my .git directory, and opened up config in notepad There was nothing…

    Continue reading

  • Useful way of exploring a StackTrace with Visual Studio 2012

    I was shown a really handy way of viewing a StackTrace in Visual Studio 2012 today Steps are simply: Copy stack trace (from yellow screen of death for example) In Visual Studio, press ctrl + shift + e For example: at MyProject.Web.Controllers.ErrorController.MyMethod() in d:\Projects\MyProject\Web\Controllers\ErrorController.cs:line 23   at lambda_method(Closure , ControllerBase , Object[] )   at…

    Continue reading

  • Using custom options with KnockoutJS Drag and Drop

    I was recently doing some work involving Knockout and needed to implement drag / drop (with jQuery UI draggable and droppable) I stumbled across this post from Wilsonhut that shows how to use custom binding to attach drag and drop functionality to your view model. Since that post (and previous posts in the series) covers that in…

    Continue reading

  • Worst ever version control system

    I once worked for a company, who, when I asked if they used a ‘version control system’ their lead developer eagerly replied “YES – At the end of every day, I copy my directory, zip it, and rename it with todays date” The best part was “To make it easy to find, we cleverly use the…

    Continue reading

  • Visual Studio 2012 Typo in CSS intellisense – Rigth

    Just thought I’d post this quickly: Typo noticed in Visual Studio 2012 CSS intellisense:

    Continue reading

  • Syntax error using Yahoo YUI Compressor .net port – works using java version

    Recently, I was tasked with creating a minified version of a web applications Javascript files. I settled on the Yahoo YUI Compressor, in particular, the .net port of it When I tried to compress a particular file (the jquery.caret plugin), it would throw up a syntax error. This error only occurred using the .net port…

    Continue reading

  • Equivalent of LINQ projection / select with Javascript

    Not strictly an ‘equivilent’ but a way of achieving the same. For example, consider the following array: var products = [{ id: 1, name: “Product One”}, { id: 2, name: “Product Two”}, { id: 5, name: “Another Product”} ]; Say, for example, we just wanted a list of IDs from this array. With .net, using…

    Continue reading

  • Incremental / Sequential int IDs with MongoDB using an IdGenerator

    I blogged about using incremental ids with mongodb previously, so have a read of that for more information. Although it’s not ideal, we can use sequential / incremental IDs with MongoDB.Sometimes (when migrating legacy systems for example) we just can’t get away from using ints for id’s. While working on implementing MongoDB with N2CMS recently,…

    Continue reading

  • TFS – Forgot to untick the Preserve pending changes locally checkbox when shelving

    Coming from using Git, I am used to using a stash in this scenario: Working on a piece of functionalityHigh priority change comes in on the branch I’m working on that would affect the above work In this instance, I would tend to stash my changes. After googling, I discovered the TFS equivalent is Shelving.…

    Continue reading

  • GUI Bug on TFS Shelve changes screen

    When resizing the screen, you would also expect to see the file list to resize with it? Apparently not….

    Continue reading

  • Create a standalone EXE to run a Node.js application

    Download Advanced BAT to EXE converter (http://www.battoexeconverter.com/) Download Node.exe from Joyent http://nodejs.org/dist/v0.8.2/node.exe Now we’re ready to bundle the node.js executable and our js files into a single exe file. As for our BAT command, all we need is: CD %MYFILES%/ node test.js %MYFILES% is the variable given to the location of embedded files (more on…

    Continue reading

  • Node RailwayJS app – Deploying to Heroku – ENOENT, open ‘/app/log/production.log

    I’m currently working on a project involving a node.js app, using RailwayJS, deploying to Heroku. After doing my git push Heroku Everything seemed ok, however, the app was not running. I ran Heroku logs and was shown: app[web.1]: listening on port 32168 within production environment app[web.1]: app[web.1]: events.js:48 app[web.1]: throw arguments[1]; // Unhandled ‘error’ event…

    Continue reading

  • Fix Homebrew – You have no /usr/bin/cc (Xcode)

    I recently did a fresh install of OS X Lion on my Macbook Pro I installed XCode, homebrew, and git. After trying to install mysql via homebrew: brew install mysql I received this error: Error: Failed executing: ./configure –prefix=/usr/local/Cellar/readline/6.2.2 –mandir=/usr/local/Cellar/readline/6.2.2/share/man –infodir=/usr/local/Cellar/readline/6.2.2/share/info –enable-multibyte If `brew doctor’ does not help diagnose the issue, please report the bug:…

    Continue reading

  • Running node.js on Windows

    Download node.exe http://nodejs.org/#download At the time of writing, the version was  v0.5.4 (unstable) Don’t worry about it being unstable, you wouldn’t dream of running it on Windows in production, would you Put it somewhere sensible For me, I have node.exe on the root of C:\ Some people have a subfolder, such as “tools” where they’ve…

    Continue reading

  • Review of nightmare with Elance provider (WebHouse)

    I’ve used eLance for various outsourcing projects for a number of years. (Great for small tasks, and an extra pair of hands until the 25th hour in a day is discovered!) Sure, I’ve had my fair share of problems, however, all have been amicably resolved, talking with eLance and the contractor. WebHouse (Md. Zakir Hossain…

    Continue reading

  • JoeBlogs wrapper moved to GitHub

    Following from my plea for help for JoeBlogs I finally got round to learning Git. The project has now been moved to GitHub: http://www.github.com/alexjamesbrown/joeblogs I will eventually move the Wiki / Docs to the page also. If anyone would like to become a contributor, please contact me on GitHub

    Continue reading

  • Create a Google Chrome Extension

    I’ve been meaning to look into creating a Google Chrome extension for a while. Earlier this week, I successfully RickRoll’d Rob Ashton on twitter, which in turn, after a RT, RickRoll’d several others. Many of whom replied with tweets like @alexjamesbrown @RobAshton You bastards! 😉 — Anders Ljusberg (@CodingInsomnia) March 24, 2011 @alexjamesbrown @RobAshton Damn…

    Continue reading

  • Hosting a website on Amazon S3

    Firstly, Create bucket Enable website on bucket Change bucket policy Upload index document Domain DNS settings Log in to the Amazon S3 Management Console Create bucket if you haven’t done so already, you’ll need to create a bucket. This bucket needs to be the same as your URL you want to host. For example mydomain.com…

    Continue reading

  • Excluding ID field doesn’t work with FindAndModify

    While playing with incremental IDs with Mongo DB the other day, I stumbled across a bug in mongodb. Consider the following command: db.sequence.findAndModify({ query: {"_id": "customer"}, update : {$inc : {"seq":1}}, fields:{"_id":0}, upsert:true, new:true}) Notice the fields:{"_id":0}, part (highlighted) According to the documentation, this should prevent the id from being returned, however when I try…

    Continue reading

  • MongoDB – Incremental IDs

    I’ve been reading a lot recently on MongoDB and the use of incrementing an ID This article offers an in depth look: http://shiflett.org/blog/2010/jul/auto-increment-with-mongodb Taking this a little further, and from reading the findAndModify documentation I put together the following: db.sequence.findAndModify({ query: {“_id”: “customer”}, update : {$inc : {“seq”:1}}, upsert:true, new:true}) Here is what this command…

    Continue reading

  • View XML in Google Chrome

    Sometimes, I need to be able to view an XML document in a browser. While IE supports this natively, you’ll need an extension for that in Chrome. The one I use is XML Tree by Alan Stroop. After installing it, it simply “just works” Viewing any server side XML page displays nice and hierarchically, similar…

    Continue reading

  • Joe Blogs Wrapper V2 – Help required

    I’m on the verge of being able to release a second, much improved version of the Joe Blogs WordPress & MetaWeblog API Wrapper. Some very brief details below, and a cry for help (or several cries!) New Features / Improvements Friendlier API Instead of having to deal with the XML-RPC interfaces directly, I’ve added a…

    Continue reading