Author: Alex
-
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…
-
Scam Warning – Email with subject ACTION REQUIRED: A document has arrived for your review/approval (Document Flow Manager)
Received this email earlier this week… After some googling, I have determined that it’s a scam, and there’s usually a zip file attached. GMail had removed this zip file though I think. This message is for the designated recipient only and may contain privileged, proprietary, or otherwise private information. If you have received it in…
-
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”, } ]…
-
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…
-
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…
-
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…
-
Dorset Sports Cars Review – I took them to court, and won
In July 2012, I bought a car (BMW 335d) from Dorset Jaguar & Sports Cars.I naturally tried to haggle on the listed price, but was assured that it was in immaculate condition, so wouldn’t budge. Based on their assertions I bought the car, paid the deposit and arranged to collect the car the following week.I…
-
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…
-
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…
-
Visual Studio 2012 Typo in CSS intellisense – Rigth
Just thought I’d post this quickly: Typo noticed in Visual Studio 2012 CSS intellisense:
-
Did you report to “John Smith” at your last role?
Recently, I had a conversation with a recruiter who apparently had the ultimate contract on offer for me. The conversation moved swiftly on from telling me how great the job was to this: Recruiter: So your last contract, did you report to <John Smith>? Me: No. –awkward silence– Recruiter: Ah, ok, who was it then?…
-
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…
-
Download emails from GMail in a specific label with GMVault
I recently wanted to download around 20,000 emails from a specific label in my gmail account. To do this, I used GMVault. I’m not going to talk through the basics of setup / using this as it’s already talked about at length on the GMVault site. However, in order to get it to download only…
-
Gmail reply all graduated from Labs– ‘r’ shortcut doesn’t reply all
I recently noticed that while replying to an email in google apps (or gmail for that matter) it wasn’t defaulting to Reply All – despite me enabling this lab. Upon further inspection, I noticed this was no longer an option in the Labs.Fearing that it had been removed altogether, I had a look over the…
-
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…
-
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,…
-
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.…
-
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….
-
Returning my iPhone5
So, I’ve had and used my iPhone5 for around a week now, and I’ve decided to exercise my right to return it. Why? Lightning cable By far the biggest disappointment Apple have ever dished out.Fine, if there’s some technical reason to change the connector, then do it. But do so in a gracious manner, and…
-
Parallels 8 Upgrade – Moving windows in Windows 7 snapping back
I recently upgraded my copy of Parallels desktop from version 7 to version 8. As soon as I had done, I noticed the supposed “improved multi-monitor support” wasn’t all it was cracked up to be. If I had a window open, and dragged it to the other monitor (either from external to macbook, or vice…
-
MacBook Pro with SSD – Hanging / Crashing when using Windows 7 & Parallels
Just a quick blog to see if anyone else out there is experiencing hanging / crashing when using: Macbook Pro OSX Mountain Lion SSD (256mb Crucial CT064M4SSD1) Parallels – Windows 7 Guest OS Only started noticing the problem since I installed the SSD Every now and then, the whole system will sort of freeze. Won’t respond to…
-
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…
-
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…
-
Online hotel booking sites & credit card reservations – beware!
Recently, I was working on a project with a similar business model to hotel booking websites such as LateRooms.com and Booking.com: The customer reserves a “room” from a third party. The customer pays at the hotel. Failure to show, results in customers card being charged. I was intrigued about how the others got this process…
-
Apple store rip off
Same product $49.95 on the US Apple store, £69.95 on the UK store