Coffee Machine Bot Project

In mid-February, I was discussing with some colleagues in EVRY to hold a hackathon soon. Immediately, I started to think of what I wanted to create independently of the Hackathon discussions. After a while I was fascinated by the idea of creating a coffee machine bot using Microsoft technologies to its full extent. The plan is to use this project to learn new things, and put everything together around the “Coffee Machine Bot” idea.

I have multiple inspirational sources for this Project

  • The fact that software developers consume huge amount of coffee all day (and nights)
  • The great GitHub project “hacker-scripts” (separate commands in the bot)
  • Homer’s fantastic kitchen machines

Basic requirements

  • Using cognitive APIs for voice and face recognition to identify persons
  • Bot should understand multiple languages, such as English, Norwegian and Swedish
  • Using advanced machine learning, analytics and cognitive services to suggest the drink based on drinking habits, time of day, weather, humour and emotion.
  • Commands
    • Rate drink
    • As usual
    • Add to favourites
    • Recommend New
    • Hacker-scripts
  • Back-Office
    • Automatically order new ingredients based on consumption, number of forthcoming workdays.
    • Schedule planned and predictive maintenance
    • Using HR, IFS, SM9 systems to look scheduled overtime and evening/night/weekend. Make sure participating employees had their drinks covered

This weekend I will do some research for the Face API and Emotion API available in Microsoft Azure.


Create team project from command-line with TFS Power Tools

Our department had an interesting challenge the last week. We have an old local on-premise “Team Foundation Server” (TFS) in our data room with two VMware hosts containing a number virtual machines. Due to new company policies we needed to move all domain bound VMs to a new domain. As we feared, this cause a few problems due to old versions and incorrect editions of different software.

The first thing I did was to perform a “Get Latest” on all source code just, in addition to a VM snapshot before we started the actual migration process. We needed to have a “Plan B” if the migration failed. After a few days with migration failures with loads of issues between Sharepoint, Project Server, SQL Server and TFS, we decided to make a clean install and move the source code into new team projects. The problem now was that the old TFS server had about 60 team projects that need to be created manually.

As a lazy programmer, I prefer a command-line utility to help me with this project creation. Luckily, 99% of all team projects didn’t use the Sharepoint site, so for the moment I just have to migrate source code to the version control of the new TFS server.

The command-line tool need for the team project creation is called “TFS Power Tools”, and exists in the latest version of Visual Studio – 2012 and 2013.  Here is the command template I have used for our team projects.

tfpt createteamproject 
	/collection:"http://[IP or Hostname]:8080/tfs/DefaultCollection" 
	/teamproject:"[project name]" 
	/processtemplate:"Microsoft Visual Studio Scrum 2.2" 

Since I found the list of team project directories by using “dir /b” from the DOS-prompt and put this directory list into Excel and generated one command for each project based on the command-line above. All these command where put into a command file (cmd) and run. When this is completed I will add all files from the projects from the “Source Control Explorer” in Visual Studio. Some manual work is needed.

Happy migration!


KiPi 2015 Challenge – Mobile Development

I’m having just some hours left of the first part of my KiPi 2015 Challenge for “Cloud Development“, and the next course path is “Mobile Development”.  This path will contain video sessions on C#, XAML, Universal app development and how Xamarin and Visual Studio can be used for cross-plattform development. These courses are about 32 hours in total watching.



CleanBin – Cleaning up your bin and obj solution folders in Visual Studio

I’m pretty sure every programmer is lazy. What do you do when sending sample code to colleagues or customers by email? Just zipping the Visual Studio solution and send it? Have you ever been stopped by size limitations for attachments on Exchange set by your IT-department? Been there, done that…In addition, until recently I had bad upload capacity on my home broadband, and my synchronization between local disk and Skydrive/Dropbox was awful when there were many new and large files.

This is not a big issue when you have utilities like “Dropbox – public links”, but until recently, I was fed up and created my own utility to clean up unnecessary files from my sample projects. BUT…As mentioned, programmers are lazy and we probably don’t clean the solutions when we close the solution. Therefore I had to create an utility that went through all my source code locally and removed the files under BIN and OBJ folders.

I called this utility CLEANBIN and the main objective was to loop through all my sample code stored on my local drive and remove all files from the BIN and OBJ folder in my Visual Studio solutions.


Happy coding…

ncalc@codeplex – excellent math library

The NCalc codeplex free library is excellent for evaluating mathematical expressions run-time in C#. It has alot of operators, supports functions and parameterized calculations. If you want to define a formula in string format and run-time pass calculated or stored values as parameters, this library is the best free tool I have worked with for a long time.

In my case, the following code gives an idea of the library usage:

string formula = "(2*[A]) + (2 *[B1]) + [B2] + [C]";
var expr = new Expression(formula);
expr.Parameters = new Dictionary<string, object>
        { "A", 100 }, { "B1", 20 }, { "B2", 50 }, { "C", 20 }
Console.WriteLine("Res: '" + formula + "' = " + expr.Evaluate());

The formula has 4 parameters – [A], [B1], [B2], and [C]. The example will use the values stored in the Dictionary. As a result the library will replave the parameters with the values from the dictonary as followed:

(2*100) + (2*20) + 50 + 20 ==> 310

And the result is 310. This is very useful and saves my for a lot of time in the current project at work. The parameters can also be replaced with functions.

Versioning in Entity Framework Code-First

I have used Entity Framework for some projects over the past years, but never taken advantages of the Code-First functionality provided. However, with the stronger presence of Windows Azure and new services in “Microsoft Could”, I see how “Code-First Migrations” will help me versioning and deploying applications and database definitions.

Earlier this week I tried Code-First functionality together with ASP.NET Web API, but it became too complex to get things running, and I decided to take a step back and concentrate on Code-First Migrations.

After some googling and examples found on and MSDN blogs, I found a simple and great “getting started tutorial”. This is a basic tutorial for “Code-First Migrations” and shows most of the available functions, such as

  • Installing latest version of Entity Framework from NuGet Manager
  • Creating a data model in the model classes
  • Creating database from Visual Studio 2012
  • Adding changes through a new migration
  • Switching between different version/migrations
  • Adding custom code in the migration (class model)
  • Rolling back to original version
  • Generating script for full database
  • Make sure program has the latest version of the database

Full source-code.

Next up:

Combining Code-First and ASP.NET Web API

Found a great post by Jon Galloway, explaining how to create POCO/Model classes for the code-First Migration in Entity Framework.

WP8 – GPS Alarm – Part 2 – Calculate Point Distance

In my previous post, I had a short description on an idea of how to create an alarm application based on phone’s and destination GPS position rather than time.

My next piece of code was to calculate the distance between my current location and the destination location. After I put my daughter to bed tonight, I powered up my laptop and googled for 30 minutes and came accross a great post by Dragos Manolescu using the Haversine formula. I haven’t tested this method properly, but it seems to fit into a first version of the application.

My next step will be to create an user Interface for the Application to make the users able to store their target destination GPS positions efficiently.

Source code: ContinuousLocation.rar

I used the example found in previous post for this test.


Happy coding….