Development

This category is for all things relating to scripting or programming languages, as well as software construction, design and development.

Using Cortana with a fake GPS driver on Windows 10

I’ve mentioned before that I like to offload some of my development and productivity tasks to Virtual Machines running on Microsoft Azure. On these machines I like to run Visual Studio, Office and any other apps I need so I can be productive anywhere.

One of the apps that helps me be productive is Cortana, so I was pleased to get her up and running on my Windows 10 VM.

Cortana can helpfully give you reminders and recommendations based on location, but can you guess what the problem is when using Cortana on a VM in Azure?

Location in Redmond

The location services think I am currently located in Redmond, Washington. Oh dear.

The cross devices functionality of Cortana gets very confused because of this. When I’m using my phone she thinks I’m in Leeds, but if I switch to using the VM she thinks I have suddenly appeared in the United States.

I had a think about how best to approach this issue, and currently I’m trying out a solution which seems to work well: using a homemade Fake GPS driver.

FakeGPS Sensor Driver

I went through the code in the Windows DDK and found an example for creating a GPS driver. Rather than getting the data from a real hardware devices, I hard coded the latitude and longitude. Once I had it set up in exactly the way I wanted, it was just a matter of compiling the C++ for Windows 10 and getting it installed.

Location in Leeds

Now this Fake GPS driver simply returns the geolocation coordinates which I want, and Cortana thinks that I’m in Leeds. Sorted!

This isn’t a perfect solution. For example you have to switch your OS to run in Test Mode, and obviously the location doesn’t automatically change depending on where you are. However my initial use shows me it’s way more useful than just letting the OS guess the location from the IP address.

Cortana on Windows 10

If people are interested in trying out this solution for themselves, I’ll share the code on GitHub. It shouldn’t be too tricky to add an interface to set the location as required.

Let me know in the comments.

Highlights from Build 2015

The Build 2015 conference has just taken place in San Francisco.

Like last year, this has been another huge event for Microsoft, and a big deal for the people who build solutions using their technologies.

There have been way more interesting things happening than I can possibly cover in one article, but I have decided to cover the three most important to me:

.NET, Windows and Azure.

An exciting future for .NET and Open Source

The future of .NET is the continued push to an open source .NET Core, which is at the centre of both the latest ASP.NET runtime and the Universal Windows app platform. In the future, this will expand and include other application types. In my opinion, they’ve picked the right place to start.

Applications running on the CoreCLR can be developed and deployed on cloud and server-based infrastructures running different operating systems including Windows, Linux and OS X. I have been watching the development efforts on GitHub for a while now, and I’ve set it up on my own machines running both Windows and Linux. It sure is a sight to see.

As well as the core runtime itself going open source, other technologies like Roslyn have enabled products that many wouldn’t have guessed would see the light of day. Having an open source compiler platform has enabled Visual Studio Code – a new cross platform text editor with Intellisense – to be built.

I was lucky enough to see Visual Studio Code before it was announced, and it changed the way I thought about collaboration with Mac users instantly. I’ll have more on this new text editor soon.

Visual Studio Code

With the RC of Visual Studio 2015 there have been some big improvements in the languages supported including both the more traditional C# and Visual Basic, and (my personal favourite) F#.

The Visual F# improvements in ‘every day’ activities are dramatic for anyone who has been using the language. This is all thanks to the new open source attitude, and the amazing community around F# who have helped to develop the Visual F# tools on GitHub.

This new world of cross-platform and open source .NET technology is going to enable some amazing scenarios for .NET developers like myself.

Windows 10’s application platform takes shape

The aforementioned Universal Windows app platform is really taking shape now. Gone are the days of very prescriptive (and maybe too forward-looking) design patterns of Windows 8, and in is the ‘do what’s right for your applications‘ model that has been working well for some for a while.

Universal Windows apps scale from the smallest phones and Internet of Things devices up to the large screens of the Xbox One and the Surface Hub. The most ‘universal’ of these apps are built with just one binary which includes a scalable UI. This allows you to even have the ‘desktop’ app experience when used on a landscape 5.7 inch phone, or when plugged into an external screen using an amazing new Continuum for Phones feature.

For app developers there are some interesting (and controversial) new ways for software venders to build for Windows. The biggest of which are the bridges from Android and iOS. These two are extremely important for the phone and work especially well for iOS games which don’t rely too heavily on the operating specific UI elements. Combined with the bridges for ‘classic windows’ apps and websites using Microsoft Edge, the Store should get a lot more apps on this Windows 10 wave of releases.

From a user’s view, Windows 10 has really rounded out, with the latest Insider Preview feeling a lot more polished than any of the previous builds. Seeing HoloLens run standard Windows Universal apps was a big deal too.

I’ll have more thoughts on these in the future as the Insider Preview continues, and more information for HoloLoens is released at E3.

Microsoft <3 Docker and other Azure improvements

Azure, and the Microsoft Cloud in general, continue to amaze me. Microsoft has managed to embrace this new way of building (and selling) software in at breakneck speed. Additional services were added throughout the platform all the way from storage and networking, to analytics and machine learning. Way too many for this article.

Two of the biggest highlights were the ability to run the complete Azure Stack locally, and Azure’s new Data Lake features too, something which Amazon has had a lot of success with.

Microsoft <3 Docker

For me though, the most interesting changes were around Docker support across Windows and Azure. Docker has been on my radar for a while, but I have yet to use it in production. I have plans to do so in the not too distant future.

Microsoft Future Vision 2015

I’ve always been inspired by the Microsoft ‘Future Vision’ videos which depict a not-too-distant vision of productivity. This year’s entry has not been a disappointment, with a number of interesting UI concepts explored.

The best thing to do is watch the video above to see them all, but I’ve picked four of my favourites below.

Augmented Reality + Tactile Controls

I’m not really what to call this, so I’m just going to call it a ‘holographic puck’. In this instance, a round hardware device can be rotated to make selections on a holographic UI which has been augmented over the top of Kat’s vision.

By mixing the feel of tactile controls with the holographic interfaces you can avoid the strange experience of ‘tapping thin air’ while still providing the users with the infinite possibilities of augmented reality.

Holographic puck

I really like this concept, and it’s not too unrealistic considering the holographic technology coming in Windows 10. Later in the video you see the same hardware device used to transfer the data collected in the first scene.

Flexible Digital Notebooks

Opening the flexible computer

My favourite concept from the whole video is shown when our hero attends a café. The tea selection is shown on this flexible display, and when Kat opens it all of her personal stuff is automatically available to her.

While I think the folding doesn’t look as amazing as it could be (give me a proper notebook style folding, please) – it is a great example of the kind of computers we will be using in the future, and something I really want.

Flexible computer

Being a massive notebook and stationery nerd, I really love the idea of having a flexible notebook computer like this. I hope it happens in the not-too-distant future. The Surface line of computers already has rich inking capability, so it’s only going to get better over time.

Wearable Computing Devices

Throughout the video only one computer looks like it belongs exclusively Kat. The screen on her wrist is probably the equivalent of the smartphone today, being a general purpose communication and computing device.

Wrist computer

This is quite a way off the current Microsoft Band, but the technology sector is certainly going this direction. My Band has already helped give me the motivation to be fitter and healthier, and while we don’t really see much in the way of health statistics in this video, it can certainly be inferred from the way things are going.

Large Table-like Displays

Large table

I also love this large table computer concept. When Kat needs to get some real work done, she just uses her wearable computer to hand off to a bigger computer in a shared workspace.

I’m sure this kind of keyboard-free interaction will be best suited to a world where voice interaction has been perfected. Though I’m sure a software keyboard could be provided. You can even see Kat use a Bluetooth headset (Bragi Dash?) to work with Cortana-like assistant in the top left of the UI.

Captivated by Her

When reading an article about how design is shaping the new Microsoft, I stumbled upon a video by Kat Holmes from last year.

In this video, Kat talks about how conversations power innovation and new experiences. She goes on to discuss how the movie Her both validated and shaped Microsoft’s thinking around their Cortana digital assistant.

Like Kat I have found the movie Her to have a fascinating look at the future of human and computer interaction, primarily through verbal communication and relationship building. While the movie certainly takes the relationship part of the equation to the extreme, I firmly believe that this kind of trust between digital agents and ourselves will eventually enable a new kind of human excellence.

her

Microsoft also collaborated with Vice’s Motherboard to produce a couple of short documentary videos titled Captivated by Her. They’re well worth watching if you’re interested in how human emotion inspires and shapes technology.

Holographic Computing is Coming

Microsoft HoloLens

A bit like something out of their Future Vision videos, Microsoft’s Windows Holographic software and HoloLens hardware look to enable many of the augmented reality dreams technologists like myself have been imagining for years.

Truly I’m excited about this platform, and I’m keen to try out the product as soon as I possibly can, but I still have a large amount of questions.

What happens if you put your hand ‘in front’ of a hologram?
If you have a virtual 80 inch TV screen – what resolution does it have?
Can you stream Xbox games to it?
How long does the battery last?
Can other people hear the audio from the speakers located on the side?
How hot is the air that comes out of the vents?
How well does it work with glasses?
Will there be a holographic version of PowerShell?

It may be a while until all our questions are answered, but until then I’m going to simply imagine the possibilities this new form of computing will bring. Check out the videos below and have a look at Microsoft’s website to get an idea of what’s coming.

As someone who is always trying to simplify and keep things minimalistic, I always question new technologies to decide if they’re really worth investing in. One part of my believes I already have enough computing devices, but another part yearns to try new technology and find new ways to interact with the digital world. The HoloLens definitely seems like something I’m going to want to experience.

Will it be a success? Only time will tell. But future versions of the hardware will no doubt be smaller, and have better field of view. One day this kind of thing will simply be built into a normal pair of glasses – but that’s a little way off.

More to come soon.

Remote Desktop to the Cloud

Remote Desktop for Windows Desktop

For the last six months I’ve been using an Windows 8.1 virtual machine running in Microsoft Azure for various day-to-day developer activities. It has ended up being extremely useful to have a full Windows machine that’s accessible from any place and any device.

Azure

The VM I’m using is A2 Standard and running Windows 8.1, set up with my Microsoft account so all my apps are working on it properly – from Windows Store to Office 365.

Most importantly it also provides an always-on development platform for all my applications even when my main PC is being reinstalled with the Windows 10 technical preview builds. I have access to Visual Studio, F# Interactive, Node.js and all my usual scripting tools in PowerShell at any time.

Remote Desktop for Windows Phone

The remote desktop client for Windows Phone is truly brilliant too, with support for a virtual mouse pad enabling me to get access to applications like Visual Studio or Outlook at any time. True it’s a little fiddly, but it’s really powerful.

Azure’s Virtual Machines suite me as I have a number of credits every month, and nowhere at home to keep a server that could be on 24/7. Overall I’m really pleased with the service.

Initial thoughts on the Windows 10 Technical Preview

Now that the second preview build of the Technical Preview of Windows 10 is out, I decided the time was right to share some of my initial thoughts on this early preview for Windows 10.

Windows 10 Universal Apps

First of all, it’s important to understand that, for casual computer use, I was very happy using Windows 8.1 on my Surface Pro 2, both on the touch screen and when plugged into a monitor, keyboard and mouse. I didn’t just “put up with Windows 8” like many folk seem to. I embraced it and it changed the way I used a computer.

I embraced Windows 8 and I loved using full-screen apps at home

Simplicity is something I am always striving for. For example, I don’t have any icons on my desktop and I only pin the minimal amount of apps to my taskbar. The majority of the apps I used at home were ‘modern’ full screen apps. This means that I could have Xbox Music playing in the background with no icon in the task bar or any other visible UI unless I have it snapped to the screen. I understand that for some users this was mind-blowingly hard to understand, but I liked the simplicity.

Windows 10 Taskbar

With Windows 10, performing a task, like listening to music, means that there is an icon in the task bar. This is better for the majority of users, but for me it takes some getting used to.

Using Windows 10 is already better for multitasking and getting things done

The first two builds of the Technical Preview have been focused squarely on the experience in the enterprise, and specifically, use with a keyboard and mouse inside of the desktop environment. Here are where things really shine in Windows 10.

Unlike the way I was using full screen Windows 8 apps at home, I use multiple screens and desktop applications when I’m at work. Three screens means I can multi-task between development applications like Visual Studio, SQL Management Studio and PowerShell at the same time, but I still have to minimize and swap windows around when switching to communication and note taking applications like OneNote and Outlook.

Windows 10 Task View

Windows 10 includes some fantastic virtual desktop features which help around this, and I’m really looking forward to running Windows 10 at work. I could use the Task View to switch between these two logical tasks rather than minimising multiple windows.

Unfortunately the Windows team couldn’t get everything done in time for the first preview. The biggest things that are missing for me are around using the touch screen, and modern apps in full screen. The good news is that we do know that future builds will include features like Continuum, that are specifically designed for hybrid computers like the Surface.

Touch screen is still coming, and hopefully it will be as great as the desktop

With two builds already, it seems that the velocity is pretty fast. I’m looking forward to getting my hands on new features. Windows 10 is shaping up to be one of the most important versions of Windows ever – in terms of both the features and the speedy development process.

Windows 10 has an improved Console

Windows 10 Console

It’s true, the Windows command line is making a comeback.

With Windows 10, a number of ‘experimental’ options have been added to the console host which work with both the classic cmd.exe and PowerShell. This includes features like CTRL-C and CTRL-V for copy and paste, plus new text selection hotkeys, resizing, transparency and more.

And, by the looks of Microsoft’s UserVoice forum, this looks like just the beginning:

In the dawn of time, the original Windows console was created. For millenia, geeks and developers (typically both) steeled their nerves and leveraged the console’s utility. After a (very) short time, a great lacking was noticed. And so, legions of ever intrepid command line mavens migrated to other platforms and other consoles, ‘til but a stalwart few remained. Now, today, with a small rumbling, the ancient, weary console heaves a great sigh and rises. The journey to legitimacy has begun.

WE’RE BACK!

If these kinds of features are important to you, don’t forget to give your feedback to Microsoft so that they know that the command line is still relevant in 2014.

Windows 10 Technical Preview

As a big user of software and services in the Microsoft ecosystem, finding out about the next version of Windows is always exciting. Yesterday, we got our first official look at Windows 10, and while we didn’t learn about many features which hadn’t already been leaked, we did finally get to hear Microsoft’s plan for its next generation Windows platform.

Windows 10 Product Family

The official picture above teases how this single release of Windows will feature multiple interfaces the operating system itself, scaling from the Xbox One and the large Perceptive Pixel multi-user business display, all the way down to embedded devices, phones and small tablets.

From a developer point of view, Windows 10 will support a new universal app model that spans across multiple devices. This means that an application can be written only once to run across all of these environments, end-users will only have to purchase the application once to use it everywhere. Universal apps for Windows 10 will probably be very similar to the ones announced at Build earlier this year.

Windows 10 Start Menu

New features like Task View and Snap Assistant are included in the technical preview, but the more obvious user interface changes look like they are still to come. For example, Continuum is a set of features which enable hybrid devices to switch between touch and desktop modes automatically, just by attaching or removing the keyboard.

Windows 10 Task View

Today, along with many other Windows enthusiasts, I signed up for the new Windows Insider Program. This new program is similar in concept to the Windows Phone Developer Preview, but it will also provide opportunities to provide feedback directly to the Windows team.

Trust me, I’m going to provide as much feedback as possible.

String Hashing in F#

I recently wrote a small program to convert some strings into a ‘unique enough‘ hash which could be used as a short reference.

Whenever I’m trying to come up with an idea of how to handle these kinds of functions, I tend to turn to my favourite language, F#. This allows me to do rapid prototyping in a very functional way.

Below is the prototype version of this hashing program:

open System
open System.Text
open System.Security.Cryptography

let encode (alpha:string, number:int) =

    let b = alpha.Length

    let rec enc (s:string, n:int) =
        match n with
        | x when x <= 0 -> s
        | _ -> enc (s + alpha.[n % b].ToString(), n / b)

    match number with
    | 0 -> alpha.[0].ToString()
    | _ -> enc ("", number)

let md5Int (input:string) =

    let clean (str:string) =
        str.ToLowerInvariant()
           .Trim()

    let computeHash (str:string) =
        let bytes = Encoding.Unicode.GetBytes(str)
        use crypto = new MD5CryptoServiceProvider()
        crypto.ComputeHash(bytes)

    let convert (bytes:byte[]) =
        let i = BitConverter.ToInt32(bytes, 0)
        Math.Abs(i)

    convert (computeHash (clean input))

let hash (input:string) =

    let a = "ABCDFGHJKLMNPQRSTVWXYZ0123456789"
    let i = md5Int input

    encode(a, i)

Once I have this program created, it’s very easy to use in F# Interactive like so:

> hash "Here is a test string!";;
val it : string = "1W2ALLB"
> hash "The hash is much smaller, which is great.";;
val it : string = "5DAF5T"
>