Blog

12 May 2013 . .
Opening a bottle of Beer with a sheet of Paper, it only takes 3 pieces! Comments

image

 

So the title lies when I state it only takes three pieces of paper, if you have the skills (and possible muscle) I lack then you can do it in one! How cool is that!!!

 

Hopefully you will be more successful than me. Also I am not necessarily advocating drinking, so www.drinkaware.co.uk.


Stuart James  


12 May 2013 . .
C++ + Visual Studio 2012 (VS2012) + Win8 , converting projects up some conflicts I found Comments

Having loved the ability to compile VS2010 projects inside the VS2012 shell as a way of delaying the update, I thought it was time to stop delaying ( 1 Year late ).

std::cout << "Minimum value for int: " << std::numeric_limits<int>::min() << std::endl;
std::cout << "Maximum value for int: " << std::numeric_limits<int>::max() << std::endl;

Generates error:

error C2059: syntax error : '::' [path]\source.cpp

There is a good chance if you have these lines and are including the windows header you will hit an error. The Windows team put in a solution to the #define min conflict in <minwindef.h>.

So instead of

#include <windows.h>

You use a #define to avoid this

#define NOMINMAX
#include <windows.h>

Another issue I found was with an annoying char define, again from the Windows team in <rpcndr.h>.

#define small char

This one doesn’t have the ability to comment out for so if you have a small function with something like:

AnObj small = large.resize(val);

Generates error:

error C2628:'AnObj' followed by 'char' is illegal (did you forget a ';'?) [path]\source.cpp

You will have to suffer and change the name, in some ways it teaches you (me) for not being very specific, still annoying though. Hopefully this is all the conversion errors I’ll hit.


Stuart James  


11 May 2013 . .
S3 Push and Pull – Backup a EC2 Instance or just some data Comments

I stumbled across a great tool to just push and pull data from an S3 bucket last week wrapped into one light weight executable. Requires .NET 2.0 or Mono so on Linux becomes a little heavy weight.

 

So start by pulling down the latest version:

http://s3.codeplex.com/

 

So to get started you need to configure your bucket, this is stored in the registry so you will need to consider the security implications, but it does allow you to set a password. For simplicity I’ll avoid this and assume that you don't mind it being visible to users/hackers!

Navigate to where you downloaded and  run the command

s3 auth

 

image

 

As you can see you get the option to password protect or not is easy and hopefully there isn’t any problems following this through to configure your bucket ID and Key.

 

Now you are ready to start shifting some data!

s3 get <bucket [/folder]> <path>

Some good options are

/backup /sync /nogui

Should be fairly clear what these options do.

If you still are a little stuck try this for a full set of options.

s3 help


Stuart James  


29 Mar 2013 . .
The old Windows 8 argument on a non-touch laptop Comments

We have already heard many arguments about Windows 8 with and without touch, the new “metro” UI and the missing start button. I dont intend to add anything to this I think it really comes down to your personal preference. In my case I found it awkward to use so wanted a solution to make things better.

My solution is that developed by StarDock this was brought to my attention by Paul Thurrott on Windows Weekly.

Start8

Start8

ModernMix

ModernMix

ModernMix works amazing allowing you to be able to run “Metro” apps in Windows. I have always played games in Windows so the idea of using full screen will take me a long time to grasp, and ModernMix allows me to completely avoid that!


Stuart James  


29 Mar 2013 . .
Boost Graph Visualisation using dot and Graphviz Comments

Debugging graphs can sometimes be annoying a useful way is to visualise it. No problem Boost has not only a graph solution but a way to visualise it too.

It is really simple first the header,

#include <boost/graph/graphviz.hpp>

Define the name of each node, easily done by an array

const std::string names [] = {"A", "B", "C", "D", "E" } ;

or via a vector

std::vector<std::string> names;
for (int i = 0 ; i < _nodes.size() ; i++){
    std::stringstream ss;
    names.push_back(ss.str());
}

Then save it out

std::ofstream dmp;
dmp.open("dmp.dot");
boost::write_graphviz(dmp,g, boost::make_label_writer(&names[0]));

And then the result:

 

Graph_Dot_Undirected Graph_Dot_Directed

Left undirected graph, right directed hence the arrow heads.


Stuart James