Visualise the output of .dot file using GraphViz / dot (Linux) 

Something I managed to miss from earlier Graph related posts, was how to visualise the graph using GraphViz

With your output .dot file you can simply call:

dot -Tps filename.dot -o outfile.ps

Will generate ps file for the jpg version you can simply modify the line to:

dot -Tjpeg filename.dot -o outfile.jpg

Simple an easy?


outfile_mg
Gravatar
Posted by Stuart James Wednesday, March 12, 2014 10:50:00 AM Categories: HowTo Trips

Windows Phone great platform but not quite there 

Choosing a Phone platform is a big issue, people spend vast amount of time contemplating what to choose and which phone to have. I recently got the opportunity to explore Windows Phone as an alternative to Android, I have also indirectly experienced iOS.

image

So let me start, my experience may be tainted by the phone. I used a very low end phone and have been now using for almost two months, the former is the concerning part. To be fair I therefore am unable to contrast speed or camera with any other phone since when you spend £100 on a phone you can’t expect much.

So this is my chosen phone the entry level Nokia 520, £100 or ~£80 network locked.

Basic Tech Specs:

  • Primary camera sensor size: 5 MP
  • Display size: 4'' WVGA (800x480)
  • Processor name: Qualcomm Snapdragon™ S4

What works great…

Microsoft Integration-ish

So given this is a Microsoft platform I was surprised how little it actually did. Windows Phone has seem to go with the approach of complete App isolation, I am sure in defence of this is a massive security bonus. I am surprised there isn’t a way for an app to get access to credentials even via generation of another unique access token based on the permissions you give to the phone. I spent a lot of time signing into all the different products/services. On the plus side there is easy access to all of these services.

Simple UI

image

The tile/metro/modern UI is a much discussed argument, some love, some hate. I personally really like the interface I think it works incredible well and provides instant access to the items you want most. This is of course if you keep it clean and organised. In contrast to my predecessor phone the Samsung Note (original) I found generally I didn’t loose much “glance” information despite smaller screen and resolution.

Search Button

image

Now I have often heard said people are irritated by the search button, whereas I found it useful there are countless times I grab my phone to search for something this combined with the voice to text working 60% on long queries 90% on bi-gram queries was enough to keep me satisfied.

What’s missing

Swipe Down Network Info (always)

image

On the home screen there is a nice feature where you swipe down from the top you get network information e.g. signal strength, internet speed(GPRS,HSDPA..). Unfortunately this doesn’t seem to always apply. For example search wonder why a page is loading slowly when in the browser swipe down and nothing.

Sound Control

image

This is a big pain to me something that I feel is severely broken. To contrast on Android you have two sound volumes, one for media and one for alerts/calls. Now this may seem petty, but is so incredible useful. For example I may want to listen to music and not have incredible loud ring tones. Having said this, I believe this is fixed in WP 8.1!

Background App Persistence

image

So one app that I was hoping would be significantly better on Windows Phone was Skype. What I found was it was as unreliable and annoying as the one on Windows 8. Messages don’t come through then pile in, and calls are occasional and inconsistent. This isn’t the only app that suffers from this phenomenon WhatsApp, Line therefore it has led me to conclude something is going wrong in the background state. This probably has big battery bonus making my cheap Nokia last almost two days on a single charge. It does lead to frustration.

More things…

There are many other things, the only major one I didn’t touch on was keyboard the Windows Phone keyboard is simple and not changeable something another element I miss about android. This leads to the text selector being a nightmare sometimes working perfect but trying to edit a letter or word can be a challenge.

Who is this phone / platform for?

This is an amazing business phone simple elegant and does what it says on the tin. I am convinced Windows Phone will only get better, and 8.1 will surely be a leap along that line. For anyone on iOS I think they would find Windows Phone great, with many benefits. The only big problem for iOS users is style, there aren’t to my knowledge any (to use a common vernacular for iPhone) sexy Windows Phone phones. This could be solved by third parties building them but I am not sure Nokia has it in them, with the recent trend away from Windows Phone from third party this is going to be a challenge.

Catch up or leap frog?

As I alluded to above this phone is really playing catch-up I am hoping they pull something out the hat but with the “apparent” delay of WP 8.1 therefore making it hard to believe 8.2/9 will be available this year, it is going to be a struggle. I believe Android is now a very solid platform, so much so it has moved to what gadgets(toys) come with an android phone than what is new. Give it a year.. I do expect great things from Google.

Conclusion

This platform/phone has it’s place and it is good at what it does, but for many it wont cut it. I had high hopes when I started using Windows Phone fulltime after Christmas, as time went on I have found myself waiting to get back onto Android. So my conclusion is really get this phone if you or the person you are recommending to likes the simple phone experience this stereotypically is parents and other senior family members.  If you are iPhone move, Nokia has great cameras and the platform just works. For me its back to android in a few months!

Gravatar
Posted by Stuart James Saturday, February 22, 2014 6:23:25 PM

Getting to grips with the Facebook API with PHP and JavaScript SDK Part 1 

For a research project we are working with peoples Facebook data amongst other social data, this required writing an application to inspect user content utilising the public API. This process shone some light on the privacy of Facebook. A lot of stories in recent years have focused primarily on how Facebook changes its privacy settings but not enough has been focused on the vulnerability of apps to the privacy intentions of the user.

To give you an understanding I though I would work through an example of how you can easily create an app and access more than probably expected about your data and your friends. To note before anyone complains I realise that you are required to install the application for it to have any meaning, but I will give an example of where what happens is not possibly what you would expect to counter this.

During testing of our app for the project a collection of colleagues installed a test version to make sure when used in the wild it would perform as expected. A user had their privacy settings so that friends of the user could not see the their friends unless they were in common. This I am sure is common for a lot of people on Facebook, what happened with the app though is it got full access to her friends list, now may sound strange to highlight this since it asked for permission to do this, but when you consider that this user is sharing more with a random installed app than with their actual friends? I am doubtful this is was what was originally intended by this user.

Anyway, back to the example. This is worked through using Facebook Developer interface with Facebook PHP SDK.

The Facebook API is incredible simple but also incredible confusing at the same time -- what you would expect from a major corporation’s software. 

So I will break this down into several steps that I will cover over a series of articles in general I will try to address 2 aspects per article:

  1. Authenticating a user / Getting them to install your app
  2. What the app can see of my feed
  3. What the app can see of my friends
  4. Photos galore
  5. Having some fun with the API
  6. The monkey in the closet

A couple of notes on what this will tell you how to do and what it wont. I am writing this app as an external entity to Facebook and less intended to be nested into the Facebook site via their canvas approach. To achieve a nested app you will probably want to do things a little different and probably exploit javascript.

1. Authenticating a user / Getting them to install your app

Facebook apps are simple to write once you get a handle on the paths required is simple to adjust to do more. So to get someone to install your app you need a link[Ref: Facebook PHP SDK examples].

To get started, you need to direct the perspective user to Facebook

Firstly create an object with your app credentials and see if you have a user, this follows SDK example

require 'api/utils/facebook.php';
$facebook = new Facebook(array(
  'appId'  => 'xxxx',
  'secret' => 'xxxx',
));
$user = $facebook->getUser();
if ($user) {
  try {
    // Proceed knowing you have a logged in user who's authenticated.
    $user_profile = $facebook->api('/me');
  } catch (FacebookApiException $e) {
    error_log($e);
    $user = null;
  }
}

Now you can either do something with the $user or detect NULL and push them to add your app

if ($user) {
  $_GET["id"] = $user_profile['id'];
  $logoutUrl = $facebook->getLogoutUrl();
} else {
  $statusUrl = $facebook->getLoginStatusUrl();
  $pageURL = 'http';
  if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
  $pageURL .= "://";
  if ($_SERVER["SERVER_PORT"] != "80") {
    $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
  } else {
    $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
  }

  $params = array(
     scope => 'read_stream,user_photos',
     redirect_uri => $pageURL."?type=0"
  );
  $loginUrl = $facebook->getLoginUrl($params);
}

So to highlight a couple of differences between the PHP SDK example and the above code. This code requests permissions and secondly specifies redirect url. These are both useful since you need to request your permissions here as well as in the app settings. Here you can see we have requested read_stream and user_photos there is a list of available of facebook basic and extended permissions available at https://developers.facebook.com/docs/reference/login/extended-permissions/. Also to note by providing the return url you can specify any properties you want so in my example I had multiple modes of using the app requesting different permissions defined by type.

Ok so now we have done all this we can now push a user to the App using the $loginUrl. As I mentioned earlier my scenario is external to Facebook you would probably want to automatically request permissions if you are in the canvas.

<a class="btn" href="<?php echo $loginUrl; ?>">Install my app it’s awesome!</a>


2. What the app can see of my feed

To continue my previous rant I’ll give you some examples of what you can do with Facebook exposing more than you possible more than you expected.

Completely public details:

https://graph.facebook.com/706861067

or

https://graph.facebook.com/StuartAaronJames

Returns:

{
   "id": "706861067",
   "name": "Stuart James",
   "first_name": "Stuart",
   "last_name": "James",
   "link": "http://www.facebook.com/StuartAaronJames",
   "gender": "male",
   "locale": "en_GB",
   "username": "StuartAaronJames"
}

To get a bit further you need a token, easily acquired via making an app or the development site on Facebook. So now to get a grip with the api to get a user feed simple extend the url with /feed and your token. If you don’t have that user yet you can view their public feed.

https://graph.facebook.com/706861067/feed?access_token=XXXX

Facebook is great for JavaScript developers returning information in JSON format. So you can utilise

var jsonObject=JSON..parse(response);

Then iterate over the response contains two components an array of data items in the “data” tag and paging information to get the next and previous via the “paging” tag.

To get started with this and see what your profile will return follow these simple steps

  1. Sign up as Facebook Developer (Sadly my memory of this process is vague having done it several years ago, it is barely more than clicking yes on developers.facebook.com)
  2. Navigate to https://developers.facebook.com/tools/explorer/ and grab your key
  3. Navigate to https://graph.facebook.com/me/feed?access_token=XXXX
  4. Replace XXXX with your token

You will see the JSON response and you can figure out how to parse your profile feed into something more meaningful.

To Come…

The next article will cover:

  1. What the app can see of my friends
  2. Photos galore

And will hopefully include more pictures!

Gravatar
Posted by Stuart James Friday, January 31, 2014 12:01:00 PM Categories: API Articles HowTo Programming
Stuart James