Category Archives: Development

Random stuff I want to remember

Windows 10 Home password expiration.

Today I had a couple of Windows 10 Home machines had their passwords expire. 

To turn off the Windows 10 password expiration

net accounts /maxpwage:0

From http://www.thewindowsclub.com/customizing-the-password-policy-in-windows-7

Upgrading npm on Windows

I was installing jspm on a new machine and after I installed node 4.3.1 it was running npm I was trying to upgrade npm.  I tried a bunch of different commands I found on stack overflow but this command from the npm site (I feel like Colonel Sanders looking for the Nashville Hot Chicken Recipe) did the trick on both Windows and the Mac.

npm install [email protected] –g

From: https://docs.npmjs.com/getting-started/installing-node

http-server

In my recent javascript library/framework exploration I found myself needing a quick way to server html without having to have gulp or more permanent web server.  I found http-server fits the bill nicely. 

npm install –g http-server

http-server –o –c-1

-o opens browser window after starting the server

-c-1 disables caching

From: https://github.com/indexzero/http-server

VisualStudio Code fix for icons not appearing

When VisualStudio code was announced I went out and installed it right away on my Mac and Windows machines.  One my home development machine I was unable to see the icons.  I was thinking that it was due to my 4K display and an High DPI issue but it turns out not to be the case.

image

In reading the Reacting to feedback, common issues, and our first update post on the Visual Studio Code bug it was due to the svg file extension being associated to something other than image/svg+xml in my case due to Inkscape it was set to application/svg. 

svg

Changing the Content Type to image/svg+xml made the icons visible.

image

There is a FAQ with several fixes and workarounds for Visual Studio Code at https://code.visualstudio.com/Docs/FAQ

Display Collection+JSON in the browser

In the last year I have become enamored with Hypermedia APIs and the Collection+JSON API in particular that I first came across in Mike Amundsen’s book Building Hypermedia APIs with HTML5 and Node.  It seems to be a perfect fit for many of the APIs that I have been working on.  Glenn Block created the CollectionJson.Net library to make it easy to create Collection+JSON based ASP.NET Web APIs. 

However when I browse to a WebAPI endpoint that returns a Collection+JSON result in Internet Explorer or Firefox I get a prompt to download the file. 

image

image

Chrome displays the raw JSON result in a more friendly manner.

image

Continue reading

Cool Development Utility – xip.io

I stumbled across a mention of a free service xip.io that spared developers the hassle of editing their host file for every new development web site they needed to setup.  Having had to edit the host file many times this really appealed to me.  So I went to find out what type of black magic enabled this.

What I found was a very simple and brilliant solution from Basecamp (formally 37signals).  xip.io is a public custom dns service that given a [**domain name**].[**ip address**].xip.io returns the **ip address** specified. 

For example

**www.gabrewer.com.192.168.1.10.xip.io** resolves to **192.168.1.10** 
**dev.gabrewer.com.192.168.1.10.xip.io** resolves to **192.168.1.10** 
**dev.www.gabrewer.com.192.168.1.10.xip.io** returns **192.168.1.10** 

Since this is a hosted service it works for all devices that have an Internet connection including tables, phones and other Internet connected devices.

I always love it when I find a nice piece of engineering that simplifies my development experience.

My first pull request – WebApiContrib.Formatting.CollectionJson

In my latest project I am using the great Collection+Json ASP.NET Web API library that Glenn Block put up on GitHub a while ago.  After using it for a while I decided to refactor my code and use something other than an int for my type identifiers.  When I changed to use the generic type, I discovered an issue with the code that had added the generic identifier capability to the library.  The Create method was still retuning an int instead of the generic TId.

So I wrote up the issue on GitHub and Glenn Block immediately responded asking if I was going to submit a Pull Request.  I am still relatively new to git and am still trying to grok it.  But since I had already forked the repository and updated the code, I figured this would be as good time as any to figure how to submit a pull request. 

Even though it was a one line change to the return type of the Create method, I realized that there were no unit tests for the CollectionJsonController class taking a generic identifier value.  So I decided I should fix that as well and created a XUnit test for this scenario by cloning the existing tests with just a Controller that used a string for the identifier.  Once I had the tests and the code working, I went about figure out how to submit my first pull request.

I found an excellent resource that made the process relativity straight forward and painless.  https://www.openshift.com/wiki/github-workflow-for-submitting-pull-requests 

You can find my first pull request (modest as it may be) at

https://github.com/WebApiContrib/WebApiContrib.Formatting.CollectionJson/pull/12#issuecomment-22815387

Nice JavaScript library for formating numbers and currency

In my continuing effort to really learn JavaScript, I was working on putting together a shopping cart application using JavaScript.  One of the things I needed to do was format some of values as currency. 

So I started looking around at the various techniques to accomplish this and ran across accounting.js a tiny JavaScript for number, money and currency formatting that seemed to fit the bill nicely. 

Now I can just do this.

accounting.formatMoney(12345678);    <span class="rem">// $12,345,678.00</span>

https://josscrowcroft.github.com/accounting.js/

ASP.NET and Web Tool 2012.2 Released Today

The ASP.NET and Web Tools 2012.2 update was released today.  There were many updates including some big additions like OData support and SignalR.   Some of the things that jump out at me form the release notes.

“Paste JSON as a .NET class. Using this Special Paste command to paste JSON into a C# or VB.NET code file, and Visual Studio will automatically generate .NET classes inferred from the JSON.”

“Mobile Emulator support adds extensibility hooks so that third-party emulators can be installed as a VSIX. The installed emulators will show up in the F5 dropdown, so that developers can preview their websites on a variety of mobile devices. Read more about this feature in Scott Hanselman’s blog entry on the new BrowserStack integration with Visual Studio.”

ASP.NET Web API OData

ASP.NET Web API OData gives you the flexibility you need to build OData endpoints with rich business logic over any data source”

“ASP.NET SignalR

ASP.NET SignalR makes it simple to add real-time web capabilities to your ASP.NET application, using WebSockets if available and automatically falling back to other techniques when it isn’t.”

Related Blog Posts

ASP.NET and Web Tools 2012.2 Release Notes
ScottGu – Announcing release of ASP.NET and Web Tools 2012.2 Update
Scott Hanselman – Released: ASP.NET and Web Tools 2012.2 in Context
Jon Galloway – Announcing the ASP.NET and Web Tools 2012.2 Release!
Web Tools 2012.2 and Web Essentials

Web Platform Installer crash when viewing Products or Applications

Today when I was trying to setup WordPress on my Windows 8 development machine the IIS Manager would crash with an System.OutOfMemoryException exception.

Exception:System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.<br> ---&gt; System.Reflection.TargetInvocationException: An exception occurred during the operation, making the result invalid.<br>Check InnerException <span style="color: #0000ff">for</span> exception details. ---&gt; System.OutOfMemoryException: Out of memory.

After doing a quick Bing search turn up this article on the IIS.NET Forums and after clicking “Get New Web Platform Components” problem solved.

Node.js, JQuery and Mocha on Windows 8 x64 and PowerShell

Since the Microsoft Patterns and Practices symposium, I have been wanting to get started learning Node.js.  So I added the JumpStart Node.js to my Safari Books Online bookshelf and installed Node.js from http://nodejs.org/

The sample in the first chapter uses a Mongo db provider (MongoLab) but I decided to install mongo locally instead.  It installed easily using the Windows Quick Start.

I was on a roll until I got to the next chapter and tried to get the modules installed.  The sample uses Mocha for its unit tests.  It also uses jQuery.  Both proved to be a challenge to get working on my Windows 8 machine.

First issue is that Mocha requires a UNIX make command.  To get this I installed Cygwin with the development tools selected as specified in this StackOverflow post.  I then added the Set-Alias make “c:\cygwin\bin\make.exe” to my PowerShell profile.

That allowed the npm install mocha to succeed.

My Node.js sample uses jQuery so the next error I ran into was that jQuery install was not succeeding.  It failed on the Contextify dependency.  After a little goggling with Bing, I found that there are two development tools you need for Node.js development on Windows.  Python 2.7 and Visual C++. 

I had Python 2.7 installed but it wasn’t in the path, so that was a simple fix.  If figured that the C++ dependency would be an issue since I do a bunch of C++ development.  But when I ran the npm install contextify, I received.

error MSB8008: Specified platform toolset (v110) <span class="kwrd">is</span> not installed or invalid.
Please make sure that a supported PlatformToolset <span class="kwrd">value</span> <span class="kwrd">is</span> selected.

So back to StackOverflow and this helpful post pointed to the fact that if you have Visual Studio 2012 installed you need to set the VisualStudioVersion environment variable to 11.0 for MSBuild to pick the correct version.  So I added $env:VisualStudioVersion=”11.0” to my default PowerShell profile and Wallah!   npm install jquery succeeded.

So now I had jQuery, Mocha and Should all installed, so I typed in make test hoping for the best and no such luck.

./node_modules/.bin/mocha: line 2: dirname: command not found
./node_modules/.bin/mocha: line 4: uname: command not found

module.js:340
    <span class="kwrd">throw</span> err;
          ^
Error: Cannot find module <span class="str">'C:\mocha\bin\mocha'</span>
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:280:25)
    at Module.runMain (module.js:492:10)
    at process.startup.processNextTick.process._tickCallback (node.js:244:9)
Makefile:2: recipe <span class="kwrd">for</span> target `test' failed
make: *** [test] Error 1

It couldn’t find the dirname and uname commands so it was looking in the c:\mocha\bin\mocha directory.  At least this was a simple one.  Adding cygwin bin to the path corrected the error and my test finally ran!

So to summarize the steps I followed to get Mocha and jQuery working on Windows 8 x64 were.

  • Install Cygwin with development tools and add it to the path
  • Add Set-Alias make “c:\cygwin\bin\make.exe” to my PowerShell profile.
  • Install Python 2.7 and add it to the path
  • Add $env:VisualStudioVersion=”11.0” to my PowerShell profile. (If you have Visual Studio 2012 installed)