Pitney Bowes Software, Kickoff 2012 – Social Media Tool Choices?

I am travelling to the annual Pitney Bowes Software 2012 kickoff and I have a couple of social media app tool choices to make. I have a selection of applications available to me that are all linked in various ways.

- Public
Twitter is good for publishing quotes and interesting questions into the public domain, these cascade to Facebook, LinkedIn and Yammer (with the #yam tag) automatically.

WordPress provides a good channel for larger public facing posts, it also automatically updates and links into Twitter, which in turn updates Facebook and LinkedIn.

Facebook is a good for updating friends on personal things during the event, such as “check out the picture of the view from my hotel room”. I also use this to keep track of my locations and let family know how my travels are progressing.

- Business
Yammer is available to all Pitney Bowes employees and I have well over a 1000 follower on this channel. It is good for posting short updates into the business domain.

SharePoint Blog is a great place to post large content such as meeting minutes, or notes from presentations, but cross linking into other channels is very manual.

Chatter is a recent addition, but the audience is limited to people who use SalesForce within the business.

So I think it’s going to work like this …

- Public
Short quotes and interesting public snippets will go to Twitter (auto linked into yammer with #yam)
Larger public facing updates in the event summarising events will go to WordPress.

- Personal
Facebook is the channel of choice.

- Business
Short quotes and interesting snippets will go to Yammer by default as the audience is much larger then retrospectively into Chatter.
Larger summary and presentation notes will go on SharePoint, cross linked into Yammer, then retrospectively to Chatter.

There is defiantly scope for a tool that can post to single locations and then provide the appropriate cascade and cross linking into other channels. However not all of these applications have trivial APIs. For example posting to SharePoint, Chatter and Yammer is poorly cross linked unlike public services such as Facebook, LinkedIn and Twitter. There is still some way to go in the Business app world to link everything together.

The Internet of Things

Today I met with an organisation that provides communications infrastructure. The discussion quickly came to areas of hot debate around the Internet of things and to what degree that domain is developing and the trends that are emerging.

There was an interesting balance in how the metaphors were explained. The discussion rocked between “we can tell everything you are doing” to “but privacy is important”, I found myself developing a split personality.

However where it got interesting was when the discussion came to integrating mNy different systems. We are sat in a restaurant, they have a point of sale, a security alarm, lighting, heating and yet today all of these systems are separate. I recently encountered the same issue when designing my home cinema, how do I link my TV, with my xbox, and my blue ray player. My solution to date has been a universal remote, but this does not let me connect my PC to my telly, stream audio to the bedroom and integrate my surround sound system.

Each vendor wants to lock you in, and in doing so limits my ability as a general consumer to achieve something which should be common practice today.

Even open systems such as Android lock in, for example in the secure payments space (Google checkout / wallet).

It would be interesting to determine how much time people spend working out how to restrict people doing things, over the time spent helping people exceed their potential.

In the near future machines will have greater privacy than peopole, will be able to control more things than people (electricity, heat, financial transactions .. ) and we will be outnumbered 100-1.

I will let you know if I solve my Home Cinema problem :)

iPad for Business Blog

A friend and colleague at work who co-developed the ‘roll out the iPad to the Sales Team’ Business Case for my company has been running an iPad for Business Blog. If you have an iPad this is a must read source of information.

http://www.ip2b.info/

Recently Moved House

I have recently moved and as such I am going through the process of setting up Broadband. The discussions about setting this up have been very interesting and I thought I would capture some of the dialogue.

BT, we don’t currently supply BT Infinity, that will be available in November for your area. We can offer you 12MB Broadband. However that is on an 18 month contract, and I would not be able to upgrade to BT Infinity at big costs. Also for some reason their packages came out about £5 more than everybody else, and ironically they had the highest line rental. I am still trying to unpick the packages which are far from simple. They also got a little upset when I told them I don’t use the landline as I have a mobile phone.

Sky, I spent quite a while chatting to, we got all the way through to the bit where I mentioned a cable. At this stage the agent on the phone said they only supply a dish. My new property is both very old (1800′s) and listed, so very unlikely this is going to be a success.

Virgin, they were very helpful and their package is really compelling both on price and features. The 3 channel, 1TB Tivo box is a real deal maker. However they need to know what my property is made of, and also need clearance from the Freeholder of the block to go ahead with it all. I have my fingers crossed the Freeholder says ‘yes’ and that they can install it with minimum impact on the property.

Hopefully in 3 weeks time I will have a full Broadband + Phone + TV package to rival the best. However the slightest glitch in the process and I will have to go with 12MB copper wire and no HD TV. So cross all your fingers for me, and I will keep you updated on how I get along.

 

 

Music

Enjoying some of the latest music, there is a trend in some really cool tunes. Much of this is because of the radio stations I listen to on my commute each morning.

Alexandra Stan, Mr Saxobeat http://www.last.fm/music/Alexandra+Stan/Mr.+Saxobeat/Mr.+Saxobeat+%28Extended+Version%29

Calvin Harris, Bounce http://www.last.fm/music/Calvin+Harris/Bounce/Bounce+%28Feat.+Kelis+%28Extended+Mix%29%29

Example, Changed the way you kissed me. http://www.last.fm/music/+noredirect/Example/_/Changed+The+Way+You+Kissed+Me

Finding locations within distance SQLServer Azure

Managed to work out how to search within a circular buffer, and return the distance, as well as all features sorted by distance. The performance is impressive in Azure.

First I needed to create the geography column on the Azure table.

update <table> add SP_Geography geography;
update <table> set SP_Geography = GEOGRAPHY::Point(Y, X,4326);
create spatial index SIndx_SpatialTable_geography_col1 ON <table>(SP_Geography);

Will roll this into a stored procedure, but for now here is the raw SQL.

SqlCommand comm = new SqlCommand();
comm.CommandText = “declare @po geography  = geography::Point(@x, @y, 4326);” +
“declare @bu geography ;” +
“set rowcount @rows;” +
 ”set @bu = (select @po.STBuffer(@radius));” +
“select ID, Name, “+
“SP_Geography.STDistance(@po) Distance, “ +
“SP_Geography.STAsText() Obj “ +
“from <table> where SP_Geography.STIntersects(@bu)=1 order by Distance;” +
“set rowcount 0″;
comm.Parameters.Add(new SqlParameter(“rows”, rows));
comm.Parameters.Add(new SqlParameter(“y”, lon));
comm.Parameters.Add(new SqlParameter(“x”, lat));
comm.Parameters.Add(new SqlParameter(“radius”, radius));

First we create the comment, we then declare a variable of type geography and create a point with EPSG/SRS 4326, in this case the centre of the Bing map I am also rendering. We then create a buffer which we create around the point at a given radius. The rowcount is also dynamic letting us limit the number of returns. We then use an STIntersect on all features in the table against the buffer, ordering all results by distance (so they render form the centre out).

I rolled this into a Web Service with the WebMethod of WithinDistance.  I have also added integrated security between the application and the services, the services require a key which is the hash of a whole load of stuff, including a time dimension and the users id. Resulting in a really nice integration between the web services and the application.

The prototype looks like this, and the points render in realtime as the map is dragged.

Bing Maps and code-behind

I really struggled to automatically integrate Bing Maps into ASPX code behind. I found a solution, although I am not sure its the best available. This is how it is implemented.

In the page, add a ScriptManager to the top of the page.

             <asp:ScriptManager ID=”ScriptManager1″ runat=”server” EnablePageMethods=”true”></asp:ScriptManager>

Then add the div, and script blocks for the map. Note below we are also adding a handler onto the map, for when the map has finished drawing (‘viewchangedend’). The purpose of this, is when the map has moved, or zoomed, we will make a request for another set of data to overlay on the map.

            <div id=’mainDisplay’ style=”position:relative; width:800px; height:400px;”></div>

<script type=”text/javascript” src=”http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=7.0″></script>
<script type=”text/javascript”>

function onviewchange() {
var latlon = map.getCenter();
var resp = PageMethods.MapMoved(latlon.latitude, latlon.longitude, onComplete);
}
function onComplete(result, response, context) {
eval(result);
}

var map = new Microsoft.Maps.Map(document.getElementById(‘mainDisplay’), { credentials: ‘————————});
var attachmapviewchange = Microsoft.Maps.Events.addHandler(map, ‘viewchangeend’, function (e) {onviewchange(e);});
</script>

The PageMethods.XXXX line is the key, what this does is call the code behind method, with the same signature.

Here is the matching code-behind, in this case rendering a pin in the center of the map, each time the map moves. The code is returned to the page, and evaluated. The pin includes the handler to reset the popup and update its location and its title / description. Information on how to do this, is scarce and it took me quite a few attempts. I also found that the line infobox.setLocation(e.entity.getLocation()) does a great job of crashing Visual Studio during debug.

[WebMethod]
public static string MapMoved(float lat, float lon)    {

// Do interesting things here, like make a call to a web service …
javaScript = “map.entities.clear();” +
“var infobox = new Microsoft.Maps.Infobox(map.getCenter(),” +
“{title: ‘Title’,” +
“description: ‘Description’, ” +
“visible: false});” +
“map.entities.push(infobox);”;

javaScript += “var pushpin = new Microsoft.Maps.Pushpin(new Microsoft.Maps.Location(” + lat + “,” + lon + “), null);” +
“Microsoft.Maps.Events.addHandler(pushpin, ‘click’, function(e) { ” +
“infobox.setOptions({visible:true});” +
“infobox.setOptions({title:’ The title ‘});” +
“infobox.setOptions({description:’ Description Contents ‘});” +
“infobox.setLocation(e.target.getLocation());” +
” }); ” +
“map.entities.push(pushpin);”;

return javaScript;
}

Azure Web Application Working :)

Finally managed to setup a fully working Azure application with forms based security. It runs as a WebRole, and connects across to SQLAzure for all user authentication and registration. It was hard work to tie everything together and required quite a few steps to complete. I wanted to capture the key elements in here so an aggregate of all the different bits of information is useful to somebody.

First of all the web.config, this includes some interesting bits to setup the  form validation, email and SQLAzure link. It was also the section that resulted in the most head scratching. It you get this right first, then as you add features to the site they are less likely to break or throw odd exceptions.

Here is the section that sets up the SQLAzure connection string

  <connectionStrings>
<add name=”MyLocalSQLServer” connectionString=”Server=tcp:<server>.database.windows.net;Database=<database>;Uid=<user>@<server>;Pwd=<password>;Encrypt=yes;”/>
</connectionStrings>

Things to watch out for include, the AzureSQL firewall, you will need to enable your development machine, as well as the Azure services. Additionally information on how to setup the database can be found here How To: Use Forms Authentication with Local SQL Membership with the essential resource being the sql scripts here Updated ASP.NET scripts for SQL Azure.

Next we add the email configuration for our validation steps, in this case we use Gmail as our SMTP gateway.

  <system.net>
<mailSettings>
<smtp deliveryMethod=”Network” from=”@gmail.com“>
<network defaultCredentials=”false” host=”smtp.gmail.com” port=”587″ userName=”<your account>@gmail.com” password=”<your password>” enableSsl=”true” />
</smtp>
</mailSettings>
</system.net>

Given we now have email setup, the way to configure your login processes is very well covered in this article Membership, Roles and Profile Part 11

Next we enable the forms authentication, defaulting the login to login.aspx

    <authentication mode=”Forms” />
<authorization>
<deny users=”?” />
<allow users=”*” />
</authorization>

We add the Membership provider so that the login and registration processes link to our SQLAzure database.

    <membership defaultProvider=”MySqlMembershipProvider” >
<providers>
<clear/>
<add name=”MySqlMembershipProvider”
connectionStringName=”MyLocalSQLServer”
applicationName=”<application name>”
type=”System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=————————-”
requiresQuestionAndAnswer=”false”/> <!– Switch off the need for security questions, remember to remove the fields in the registration form–>
</providers>
</membership>
</system.web>

The last step is to make sure users can access both the Verify.aspx page and the CSS files by adding locations to exclude these files.

  <location path=”Verify.aspx”>
<system.web>
<authorization>
<allow users=”*”/>
</authorization>
</system.web>
</location>
<location path=”Brand.css”>
<system.web>
<authorization>
<allow users=”*”/>
</authorization>
</system.web>
</location>

In future posts I will go through configuring the Login process, as well as implementing Bing maps, code-behind examples.

An unproductive day working with oAuth

I have been trying to connect a simple C# client application to Yammer in order to test the oAuth integration.  I thought I was doing well by getting the code so simple as to really understand what is happening.  But I keep hitting ‘hard’ problems.  For example, this is all the code, and I think I fully understand it. Here is the C#, basically replicating the specification for oAuth and meeting the requirements of Yammer.

However the Yammer API endpoint (https://www.yammer.com/oauth/request_token) returns 500?

Don’t really know where to go from here, falling down at the first hurdle. Also all Google references are now exhausted. My only option appears to be using a 3rd party library. But its such a simple concept, I don’t really want to use other stuff .. I want to know what I am doing wrong.

        public static void getRequestToken()
        {
            // Create the random string
            string oauth_nonce = Convert.ToBase64String(new ASCIIEncoding().GetBytes(DateTime.Now.Ticks.ToString()));
            TimeSpan ts = DateTime.UtcNow – new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
            // Get the timestamp in the format required
            string oauth_timestamp = Convert.ToInt64(ts.TotalSeconds).ToString();

            //http://vimeo.com/api/docs/oauth
            // Build the base string, being careful to URI encode, and sort the parameters (by alpha)
            string baseString = “GET” + “&”;
            baseString += Uri.EscapeDataString(“https://www.yammer.com/api/v1/users“) + “&”;
            baseString += Uri.EscapeDataString(“oauth_consumer_key=” + “xxxxxxxxxxxxxxxxxxxxxxxxx”) + “&”;
            baseString += Uri.EscapeDataString(“oauth_nonce=” + oauth_nonce) + “&”;
            baseString += Uri.EscapeDataString(“oauth_signature_method=” + “HMAC-SHA1″) + “&”;
            baseString += Uri.EscapeDataString(“oauth_timestamp=” + oauth_timestamp) + “&”;
            baseString += Uri.EscapeDataString(“oauth_version=” + “1.0″);

             // Hash and build the signature from the base string.
            string keyToSign = Uri.EscapeDataString(“xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx”) + “&”;
            HMACSHA1 hash = new HMACSHA1( new ASCIIEncoding().GetBytes(keyToSign));
            string oauth_signature = Convert.ToBase64String(hash.ComputeHash(new ASCIIEncoding().GetBytes(baseString)));
            oauth_signature += “%26″;

             // Build the Auth header
            string header = “OAuth “;
            header += “oauth_consumer_key=\”" + “xxxxxxxxxxxxxxxxxxxxxxxxx” + “\”,”;
            header += “oauth_signature_method=\”" + “HMAC-SHA1″ + “\”,”;
            header += “oauth_timestamp=\”" + oauth_timestamp + “\”,”;
            header += “oauth_nonce=\”" + oauth_nonce + “\”,”;
            header += “oauth_signature=\”" + oauth_signature + “\”,”;

            HttpWebRequest hwr = (HttpWebRequest)WebRequest.Create(“https://www.yammer.com/oauth/request_token“);
            hwr.Method = “GET”;
            hwr.Headers.Add(“Authorization”, header);
            hwr.ContentType = “application/x-www-form-urlencoded”;

            // Send it
            try
            {
                HttpWebResponse rsp = hwr.GetResponse()  as HttpWebResponse;
                Console.Write(rsp);
            }
            catch (WebException e)
            {
                // Bang with a 500 Error?
                Console.Write(e);
            }
         }

 

OpenLayers Proof of Concept Demo

I recently built a quick prototype combining CSV to KML conversion, custom layers, customer controls, and clustering / filtering to build a simple interface for visualising a pipeline of concepts. Here are the final mockups of the cluster view and the filter options.

Clustering based on similarity of terms in the title.

Filtering can be applied on the name (drop down box), or from the tag cloud that is automatically generated from the title of the features.

Follow

Get every new post delivered to your Inbox.

Join 99 other followers