Blog

20 Apr 2014 . tech .
Look at that text isn’t it tiny oh its on the Lenovo Yoga 2 Pro! Comments

A few weeks back I got my grubby little hands on a Lenovo Yoga 2 Pro i7 8GB 512GB SSD-HD, this was up against the Dell XPS 13 and the Sony Vaio Pro. I have had a play on the Vaio, that is a nice piece of kit, absolutely stunning battery life especially with the additional battery. If you are looking for battery life this is the model but it can get a little pricey. The other alternative the XPS 13 I wasn’t able to get my hands on to see what it was like, but I do know a couple of people who have and that is also good performing, the touch makes little sense to my mind without being able to do the Yoga moves, this comment also applies to the Vaio.

Lets start by a few facts they all have:

  • i7 Chips (same in all)
  • 8gb ram option
  • 256 or 512 SSD hard drives
  • 13”-ish screens

and now the unique features of the models

Vaio:

sony-pro-13

  • Good -- Uber battery at little size/weight, additional connectivity
  • Bad – Cost approx. £1550 (US only for identical spec?)

XPS:

dell-xps-13

  • Okay -- £1300 for for 256 model (to memory, not available at time of posting),Middle of the board battery

Yoga:

 lenovo-yoga-2

  • Good -- Yoga-ness Moves (Tablet/Tent), Ultra high resolution display
  • Okay – Price for spec £1300, £1100 for 256 model (best deal)
  • Bad – Smallest battery capacity

Comparison Conclusion

As you can see there is little to distinguish between these models, price therefore is a big impact as well as desired use case. In my case I wanted something I could use as a tablet for presenting demos since my work is heavily sketch based it is useful to not have to carry around a tablet as well. I also love high definition displays, I am well aware on a 13” device having 3200 by bla bla resolution makes little sense when you have to upscale everything anyway, but it is nice to have and it is noticeable; there is probably a middle ground though, but hey this was the option.

Use of the Yoga 2 Pro

So as I said I got this laptop, tablet flexy thing a few weeks ago, and I have loved it ish. The resolution is great if apps supported, but still is nice and so sharp is amazing. The touch pad isn’t great, you can get used to it, but it isn’t something to brag about and friends coming from other laptops will hate it. Back lit keyboard not automatic, this is weird, it shouldn’t be a gripe, but it is, just weird on such an expensive laptop. Battery life I find is fine, can reliable take off charge for the better part of day with conservative use, if you do any heavy processing e.g. Matlab, Data churning code you will be lucky to get 3hrs.

I got the 512GB model due to it being available, but I do think it is well worth it possibly not worth £200 markup on this model but others I am sure are cheaper or alternative install yourself after. It is nice knowing I have the capacity to take a chunk of files with me anywhere I go.

So the main selling point the yoga ness, I find it useful it validates the touch, but isn’t something for every day. I generally find myself slipping it over once a week, so not much. Having said that take it to a conference and it is great for the plane in the tent mode for a video, or for demos on.


Stuart James  


12 Mar 2014 . code .
Visualise the output of .dot file using GraphViz / dot (Linux) Comments

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
Stuart James  


22 Feb 2014 . tech .
Windows Phone great platform but not quite there Comments

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.

<img style="max-width: 75%;, height: auto; display: block;" title="image"alt="image" src="http://stuartjames.info/Data/Sites/5/media/wlw/image_thumb_27.png" border="0">

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!


Stuart James  


31 Jan 2014 . code .
Getting to grips with the Facebook API with PHP and JavaScript SDK Part 1 Comments

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!


Stuart James  


25 Jan 2014 . code .
Running a process in the background from php Comments

So earlier this week I had a little problem with Apache/PHP killing the task I had running. So after looking around a little online I got some hints and finally came to the conclusion on this line:

echo exec(sprintf("rsh [server] 'nohup %s > %s 2>&1 & echo $! > %s'", 
  "/usr/bin/python2.7 [python script]", 
  "[log file]", 
  "[pid id file]"));

Something to remember, of course this is for Linux


Stuart James