Blog

Welcome to my blog. Recent posts:

Windows Server 2008 Hyper-v server stuck at ‘starting windows’

Posted by on 6:40 am in Other | 0 comments

I recently had an issue with a virtual machine I created in Hyper-V stuck at the ‘starting windows’ screen. It wouldn’t even boot the installer – it simply hung after the loading files prompt at the ‘starting windows’ prompt. It turns out the solution was really simple. When I created the virtual machine, I selected Gen2 as the version. This only works for Windows Server 2012 or later, so I went in to the virtual machine settings an disabled Secure boot. This got me past the secure boot failure I was seeing previously, but it appears 2008 and Gen2 virtual machines do not play ball at all. The solution was simply to delete the virtual machine, create a new Gen 1 machine and everything worked as you would...

read more

POST file (and form data) using Fiddler

Posted by on 10:37 pm in JavaScript, Other | 0 comments

I was recently trying to upload a file to a locally developed Node.js API using Fiddler to test some upload functionality. Now uploading a file on its own is trivial in Fiddler, thanks to the ‘Upload file…’ link in the composer window. However, I wanted to add some additional POST data to the request and this stumped me for a while on the exact syntax that fiddler wanted. When you choose a file from the ‘Upload file…’ link you’ll notice that fiddler replaces your body content with something similar to the following: ---------------------------acebdf13572468 Content-Disposition: form-data; name="fieldNameHere"; filename="Panthera.jpg" Content-Type: image/jpeg <@INCLUDE *C:\Users\leejones\Pictures\Panthera.jpg*@> ---------------------------acebdf13572468— 123456 ---------------------------acebdf13572468Content-Disposition: form-data; name="fieldNameHere"; filename="Panthera.jpg"Content-Type: image/jpeg <@INCLUDE *C:\Users\leejones\Pictures\Panthera.jpg*@>---------------------------acebdf13572468— I tried all combinations of prepending and appending form data but my node.js app was receiving none of it. Eventually I stumbled on the solution which is not at all obvious. You need to repeat the Content-Disposition sections for each form field you want to upload: ---------------------------acebdf13572468 Content-Disposition: form-data; name="field1"; value ---------------------------acebdf13572468 Content-Disposition: form-data; name="field2"; value2 ---------------------------acebdf13572468 Content-Disposition: form-data; name="fieldNameHere"; filename="Panthera.jpg" Content-Type: image/jpeg <@INCLUDE *C:\Users\leejones\Pictures\Panthera.jpg*@> ---------------------------acebdf13572468— 123456789101112 ---------------------------acebdf13572468Content-Disposition: form-data; name="field1"; value---------------------------acebdf13572468Content-Disposition: form-data; name="field2"; value2---------------------------acebdf13572468Content-Disposition: form-data; name="fieldNameHere"; filename="Panthera.jpg"Content-Type: image/jpeg <@INCLUDE *C:\Users\leejones\Pictures\Panthera.jpg*@>---------------------------acebdf13572468— The other thing I forgot to do was change the automatically generated name=”fieldNameHere” to the actual parameter name that my node.js app was expecting. Once these niggles had been fixed, it worked like a...

read more

Grunt from the command prompt in Windows

Posted by on 6:14 pm in JavaScript | 0 comments

If you’re planning to play about with Grunt on Windows any time soon, chances are you’ll find a tutorial online which tells you to install grunt globally as follows: npm install –g grunt 1 npm install –g grunt This will run just fine, but when you next run grunt you’ll get the lovely error: 'grunt' is not recognized as an internal or external command 1 'grunt' is not recognized as an internal or external command Whats going on here then? Turns out Grunt itself is no longer installed globally, but its command line interface (CLI) is. The CLI is simply there as a GLOBAL means of launching a locally provisioned grunt. Therefore all you need to do is amend the command to: npm install –save-dev grunt npm install –g grunt-cli 12 npm install –save-dev gruntnpm install –g grunt-cli that way, the next time you run grunt <anytask> 1 grunt <anytask> from the command line, the CLI will invoke the locally installed grunt instance and you should be good to go. If in doubt, just follow the official grunt.js getting started...

read more

Enable high resolutions in Linux VM’s

Posted by on 6:19 am in Other | 0 comments

Something of a n00b post here, but I recently spun up an instance of the rather nice Elementary OS Linux distro and as is common with Linux, especially in a VM, the display mode was set to something horribly low that consumed a fraction of my screen. Thus, time to crack open the terminal and fix the problem: sudo nano /etc/default/grub 1 sudo nano /etc/default/grub Inside the editor change: GRUB_CMDLINE_LINUX_DEFAULT="quiet splash” 1 GRUB_CMDLINE_LINUX_DEFAULT="quiet splash” To: GRUB_CMDLINE_LINUX_DEFAULT="quiet splash video=hyperv_fb:1920x1080" 1 GRUB_CMDLINE_LINUX_DEFAULT="quiet splash video=hyperv_fb:1920x1080" Obviously substitute 1920×1080 for your preferred resolution. Save the file in nano and restart the VM. You should find that the VM restarts at your chosen...

read more

Unable to install Rails on clean Ruby

Posted by on 11:21 pm in Other | 0 comments

I recently set up a clean install of Ruby and wanted to add rails using the usual command line: gem install rails 1 gem install rails However, doing so generates an error relating to the SSL certificate of the RubyGems server: ERROR: Could not find a valid gem 'rails' (>= 0), here is why: Unable to download data from https://rubygems.org/ - SSL_connect retur ned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed ( https://api.rubygems.org/latest_specs.4.8.gz) 1234 ERROR:  Could not find a valid gem 'rails' (>= 0), here is why:          Unable to download data from https://rubygems.org/ - SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed (https://api.rubygems.org/latest_specs.4.8.gz) it appears that there is a (fairly longstanding) issue with the SSL certificate which prevents the download happening. Thankfully, the fix for this is very simple. As it’s the official RubyGems repository, one can simply add the URL without the secure prefix as follows: gem sources -a http://rubygems.org 1 gem sources -a http://rubygems.org You’ll get a warning that this URL isn’t secure, just accept that by hitting ‘y’ and then repeat the install command: gem install rails 1 gem install rails It should now install just fine. I wouldn’t recommend this for other sources, but for the official RubyGems repository and given the limited risk of man-in-the-middle attacks, this should suffice as a...

read more

Enabling RDP on a Linux instance running in Azure

Posted by on 10:31 pm in Azure | 0 comments

This post is a quick instruction on how you can enable the RDP protocol in an Azure linux instance. Why would you want to do this? Well, although you’ll probably want to SSH into the box for the majority of times, there are instances where GUI access is handy. If, like me, you like to consolidate all your RDP session (I personally use the excellent mRemoteNG ) then having this enabled is useful. Thankfully, getting RDP working on an Azure Linux instance is trivial. In my case, I’ll be using Ubuntu 14.04: Update apt-get to make sure your sources are up to date. If you don’t do this then you’ll get 404 errors in the next step sudo apt-get update 1 sudo apt-get update Once your repository is fully up to date, you can install a desktop. I’ll stick with the default, Ubuntu Unity. I’m not a massive fan of Unity but given the little time I’ll spend in here, it will suffuce. sudo apt-get install Ubuntu-desktop 1 sudo apt-get install Ubuntu-desktop This will take several minutes, so go make a coffee. Once you have a desktop environment installed, you can enable RDP: sudo apt-get install xrdp 1 sudo apt-get install xrdp The last thing to do is to open the RDP port on the Azure firewall. By default it isn’t enabled, so log into the Azure portal, select your Linux VM, go to the endpoints tab and add RDP to the list of open endponts Virtual Machines > Your Linux Box > EndPoints > Add > Add standalone Endpoint > Remote Desktop 1 Virtual Machines > Your Linux Box > EndPoints > Add > Add standalone Endpoint > Remote Desktop Once that is done and the Azure configuration has been applied, you should be set to...

read more

[Node.js] connection.session.store cannot read property of undefined

Posted by on 11:32 pm in JavaScript | 0 comments

I recently ran into a problem whereby when attempting to use session-mongoose for session storage via MongoDB in a Node.js application, I was being hit with the error: connection.session.store cannot read property of undefined 1 connection.session.store cannot read property of undefined After Googling this with Bing and some other search engine jiggery-pokery I came up blank. Lots of references from a few years back which were down to a number of factors, but nothing relevant to my particular error. Looking at my code: var MongoSessionStore = require('session-mongoose')(session); var sessionStore = new MongoSessionStore({ url: credentials.mongo.development.connectionString }); app.use(require('express-session')({ store: sessionStore })); 12345 var MongoSessionStore = require('session-mongoose')(session); var sessionStore = new MongoSessionStore({ url: credentials.mongo.development.connectionString }); app.use(require('express-session')({ store: sessionStore })); And looking at the Github page for session mongoose there was nothing obviously wrong with what I was doing. Thus I started poking around in the node_modules folder to try and find out what is going on. It turns out that as Express and Connect have been largely decoupled, the Session middleware I no longer party of the connect object. However, session-mongoose hasn’t been updated to reflect this and thus it was still referencing connect.session.store. The Session object is no longer a property on the connect middleware, so the simple fix was to change the passed in parameter to session-mongoose function to connect.Store (/node_modules/session-mongoose/index.js:266). As is often the case, Node.js is still a very immature technology and the rate of change if its components and add-ins continues to cause compatibility and dependency problems, despite the best efforts of NPM.  ...

read more

Unable to open formatted failed request trace log files on an Azure VM

Posted by on 10:06 pm in Asp.net, Azure, Cloud | 0 comments

I recently had a problem whereby I couldn’t view failed request trace logs on an Azure hosted VM. The XML would open, but the XSLT wouldn’t be applied which made the page unreadable. My first thought was that freb.xsl file was missing or corrupt somehow, but after deleting the containing IIS log folder, which causes IIS to regenerate the file it was clear this wasn’t the fault. After a bit of digging I came to the conclusion that it must be permissions based and stumbled upon this post. Even though I wasn’t getting the content blocked error message, the default internet security settings on azure VM’s are set to high. Therefore, to resolve this you (rather bizarrely) need to add the about:internet page to the trusted sites list: Internet Options Security Tab Click Sites Enter about:internet in the ‘Add this website to the zone” text box and click the add button Close IE and re-open the trce log XML I’m not really sure why about:internet specifically fixes this, but it worked for...

read more

Go to definition disabled in Visual Studio 2013

Posted by on 9:09 pm in Asp.net | 0 comments

I recently ran in to the odd problem of the ‘Go To Definition’ content menu entry being disabled. F12 also didn’t work which made code navigation a major problem. I have no idea why, but the following solution fixed it for me: Close Visual Stidio In the solution directory, ensure hidden files are enabled Delete the hidden .sou file that contains all the user options Restart visual studio and re-build your solution The downside to this is that it deletes all your user specific settings for the solution (e.g. in an asp.net application you will lose custom start pages, IIS settings and so on). If anyone knows a way to fix this without deleting the file, please contact...

read more

Unable to create new MVC project in Visual Studio 2013

Posted by on 11:06 pm in Asp.net, MVC | 0 comments

I recently had a problem in Visual Studio 2013 whereby I couldn’t create a new MVC project. When I tried, an empty solution would be created and a dialog box would be shown with the following: System cannot find the file specified (0x80070002) After a bit of digging about, it appears this occurs when there is an issue with Nuget – either a faulty installation or its somehow been corrupted. Thankfully fixing it was as simple as you’d imagine. In visual Studio 2013 go to: Tools=> Extensions and Updates => Installed => Nuget Package Manager for Visual Studio 2013 => Uninstall Close VS when you’re asked to restart it and then download a fresh copy from here by ruinning the VSIX file: Nuget from the Visual Studio Gallery Once the installation is complete, it should be working again… Hope that...

read more