Author Archives: admin

Something like this

When I said the BBC should be getting involved with open sensors and data, the open citizen kit was the sort of thing i was thinking about

Dear BBC why oh Why oh Why

So this week the BBC launched their own smart phone Weather App I downloaded it and its very nice, it seems to work ok but can’t say I was blown away.

What I was more surprised with was that the BBC have made a Weather App at all. I’m not sure that its something the BBC should even be doing.

Let me explain,a few years ago there was this great project called Backstage that was an early project to open up web data and allow individuals to re-mix and re-interpret products and services.

The BBC provided access to xml feeds and APIs such as its weather and traffic data and encouraged people to play,learn and feed back.

I discovered the project quite late on in its life just as I was starting to learn some programming. it was the 1st time i had joined in with something that was real life and not a project out of a book or trivial academic exerscise and it was  a great learning experience.

At the time I used the Linux KDE3 desktop so I decided to make a desktop widget that would display a summary of the weather and the temperature. If I recall correctly it was done in python,  the biggest obstacle was dealing with the XML. It turned out that the BBC XML feed  was a real stinker putting the entire forecast,temperatures, wind strength etc into 1 tag. This meant i had to learn regular expressionsto be able to extract what I wanted, something that still fills me with dread every time I think i might have to use them.

So I built the Widget and it worked ok, although it tended to crash after a while and also the forecast location was hardcoded into it. Very soon KDE3 was replaced with KDE4 that used a different framework for its desktop widgets. Even though I was too shy to post my code anywhere for fear that it would be critiscised by what I considered to be the ‘proper programmers’ I did start to engage with the community and post to the mailing list occasionally.

So the project wound up and I moved on to other things, started to learn Java through the O.U (Tip: don’t its a massive waste of money) ,move onto Android(Tip: do) and dip my feet into various other technologies that  have taken my fancy.

So when the Weather App was Launched I was surprised that the BBC hadn’t learn’t a lesson from its own Backstage project and also looked at the world around them.   They led the way in opening up  data.  I would have much preferred them to offer something as groundbreaking again. What about encouraging hardware Internet of things type  projects, sensors  such as Thermodo or people running their own weather stations to feed data back to the BBC to improve their own data.

Don’t want to get all Point of View but come on BBC could do better.

3D Printing,this time its personal

There is a lot of Hype around 3D printing at the moment. Some of it is really good such as 3D Printed Solar Cells and some of it is a lot more controversial .

My opinion is that like a lot of new technologies we aren’t quite there yet, prices are coming down,software is getting better and people are finding more and more interesting and innovative uses for 3D printers but I don’t think yet anyone has hit on the killer app. That one thing that will really embed 3D printing in everyones consciousness and be the tipping point that takes it from cool interesting technology to something that is on sale on every high street.

But as well as the growth in mainstream 3D printing there is also more specialist uses. I found out a few days ago that Scientists can now print Human bladders and reading about them on the internet there is a lot of research going on into 3D printing organs that are either difficult or impossible to transplant.

The reason I care about this is because my dad died of bladder cancer.  I don’t know if he would have been able to have a 3D printed bladder if they had been available back in the late 1990s, I don’t know if it would have cured him as I think it was too far advanced by the time he was diagnosed and despite having his bladder removed and then further treatments of chemotherapy  he wasn’t able to recover.

The discussion about 3D printed Bladders did remind me though it is really important that Science and Medicine get the funding that they deserve and that research and treatments keep getting  pioneered and  that schools and universities  are properly resourced to teach next generations of Doctors, scientists and Engineers.

Who knows how long it will take for 3D printed organs to be common place but hopefully soon they will become a practical reality and be able to save lives and remove pain and suffering.

Cuts,Cuts and more cuts

So today you may have seen stories like this one

Science Museum Group says cuts put museums at risk and http://www.guardian.co.uk/science/2013/jun/05/science-museum-northern-outposts-threat-closure  Both of which seem pretty fair and well balanced but there have also been articles like this one:  Outrage as iconic Northern museums face closure to save London Science Museum   With comments in it like “Insane that a London based organisation may be allowed to destroy 3 magnificent Northern Treasures.” and ““Something like 90 per cent of the funding for art galleries and museums goes into London already. It’s an extraordinary amount.”

Last Financial year visitors to the Science museum passed the 3 million mark for the first time ,Numbers are also up at Museum of Science and Industry, and the Railway Museum. Yet as the article on the BBC and guardian sites and the interview with the Director Ian Blatchford says the money from Government has been cut and is likely to be cut even more.  So the Science museum as a group  has been doing more with less.

Before I started work at the Science Museum I never realised how much thought and hard work goes into all the new exhibits and how much hard work there is that never gets seen by the public.

I work in an office with Content developers who are real Proper Scientists whose job is to turn difficult Scientific and technical concepts into  short passages of  text and images that won’t bore or overwhelm the visitors but hopefully will give them a much better understanding of this crazy world we live in, the technology that impacts our lives and what makes our own bodies work.

The New Media Department that I work in helps the content developers and  Curators bring to life ideas and concepts that can’t be expressed in words and picture alone by getting creative and as I said in a previous post Bringing the Rainbow but never forgetting the message.

Then all of the exhibits we install have to be kept operational and safe by our A.V and mechanical maintenance  teams and as the museum is open 10am - 6pm 364 days a year plus many days we open later and for that is no mean feat.

So this is the point that it gets political, Sorry.  The Science museum isn’t going to be closed down to save money as it is controlled by an act of parliment The 1983 National heritage act which sets out what the Board of Trustees must do so without changing that, which I can imagine would be massively complex and messy and would be a such a bad P.R move for the government I can’t imagine that even David Cameron would be stupid enough to do that.

However I get the feeling that the Government knows this and also knows that the other museums are located in the North of England, an area of which the Conservatives don’t have a good historical record of giving a stuff about.

So I really hope that people in Manchester,Bradford and York aren’t thinking that the Science Museum in London is some evil entity intent on destroying their museums because it is nothing like that.  People who work in Museums love museums, its not a competition thing, no other museum benefits if one closes.  I don’t know what will happen if the Government spending cuts go through, I don’t know if I will still have a job or what the effects will be in our office,the Science museum London or the group as a whole but I do know one thing and that is the reason for the possible cuts aren’t down to decisions made in South Kensington but decision made in Westminster.

Parsing XML with PHP

This post really is one of those that is as much for my benefit than anyone else’s but it may just be some use to other people.

I have seen a lot of tutorials that try to explain XML parsing but none have really hit the spot for me,so I thought another may be useful.

I think what was always missing was the part after getting the xml, there always seems to be some magic wand waving and out pops the needed data.

I have been working on a very simple HTML5 weather App recently that takes a RSS feed processes it and displays just the current weather condition and temperature, told you it was simple.

I managed to get the Parsing of the Weather Feed done by following a article that described exactly how to parse the Yahoo weather feed that I am using. I sort of understood the process,but not fully.  The next stage was to use the HTML5 geolocation API and then send this to the Yahoo Boss placefinder to return a WOEID that I could plug into the weather feed url, to provide the  local weather, really a necessitiy for a mobile App.

By modifying the example found at:

http://developer.yahoo.com/boss/search/boss_api_guide/codeexamples.html  to work with the placefinder  as shown below.

    <?php  
    require("OAuth.php");  

    $url = "http://yboss.yahooapis.com/geo/placefinder";  

    $cc_key  = "My Consumer Key";  
    $cc_secret = "My Consumer Secret";  

    $args = array();  

    $args["location"] = "51.5082629, -0.1547288";
    $args["gflags"] = "R";

    $consumer = new OAuthConsumer($cc_key, $cc_secret);  
    $request = OAuthRequest::from_consumer_and_token($consumer, NULL,"GET", $url,  
    $args);  
    $request->sign_request(new OAuthSignatureMethod_HMAC_SHA1(), $consumer, NULL);  

    $url = sprintf("%s?%s", $url, OAuthUtil::build_http_query($args));  
    echo $url;
    $ch = curl_init();  
    $headers = array($request->to_header());  
    curl_setopt($ch,CURLOPT_ENCODING , "gzip");   
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);  
    curl_setopt($ch, CURLOPT_URL, $url);  
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);  
      
    //print_r("Request Headersn");  
    //print_r($headers);  
      
    $rsp = curl_exec($ch); 
    
    $xml = simplexml_load_string($rsp);
 
    print_r("nHere is the XML response for Placefindern");  
    print_r($rsp);  

//Below is the parsed WOEID value
$woeid = $xml->placefinder[0]->results[0]->result->woeid;
echo $woeid;
?>

This gives the following xml response

<?xml version="1.0" encoding="UTF-8"?>
<bossresponse responsecode="200">
  <placefinder start="0" count="1" request="location=51.5082629%2C%20-0.1547288&amp;gflags=R">
    <results>
      <result>
        <quality>70</quality>
        <latitude>51.508292</latitude>
        <longitude>-0.154723</longitude>
        <offsetlat>51.508292</offsetlat>
        <offsetlon>-0.154723</offsetlon>
        <radius>400</radius>
        <name>51.5082629, -0.1547288</name>
        <line1>51.5082629, -0.1547288</line1>
        <line2>London</line2>
        <line3>W1K 7</line3>
        <line4>United Kingdom</line4><house></house><street></street><xstreet></xstreet><unittype></unittype><unit></unit>
        <postal>W1K 7</postal>
        <neighborhood>W1</neighborhood>
        <city>London</city>
        <county>London</county>
        <state>England</state>
        <country>United Kingdom</country>
        <countrycode>GB</countrycode>
        <statecode>ENG</statecode>
        <countycode>LND</countycode>
        <uzip>W1K 7</uzip><hash></hash>
        <woeid>26352766</woeid>
        <woetype>11</woetype></result></results></placefinder></bossresponse>



The item that we are intersested in is at the very bottom of the output

<woeid>26352766</woeid>

I think one of the problems I have had in understanding how to parse XML is that I was expecting to be able to enter a command a supply the XML  tag as  a parameter and get the data back, well it doesn’t quite work like  that.

I think the best way to think about it is whenever the word parse is used is to swap it for ‘get the data from the xml’, in my head.

So lets crack on.

To Parse the XML we are going to use simpleXML , there are other ways to parse XML in PHP but for files that aren’t hundreds of Megs simpleXML is regarded to be the best, it was introduced in PHP5 to address the need of an XML parser that is easy to use.

So first stage  is to create a simplexml object :

$xml = simplexml_load_string($rsp);

The next step is to create a path to the woeid in the xml object, probably the easiest way to do this is to work backwards.

Ignoring all of the other data and just concentrating on the <woeid> tag we can see the structure of the XML looks something like

<placefinder>

<results>

<result>

<woeid>26346525</woeid>

</result>

</results>

</placefinder>

In the xml file the <bossresponse responsecode=”200”> is the route tag. All xml files have a route tag which must contain all the other contents of the xml file, so we don’t need to refer to it when getting the woeid.

Looking through the xml response. the tag placefinder only contains further levels of tags no any actual data so we need to think of it as an array that contains other arrays hence referring to it as placefinder[0]. The same is trued for results. the result tag contains the woeid tag and the woeid tag contains the actual data we want, so both of those can be referred to directly.

$woeid = $xml->placefinder[0]->results[0]->result->woeid;


And that is all there is to it. If you are struggling to understand hot to parse xml feeds with php I would encourage you to have a go,read a few different articles and look at Stack overflow if you want more information

Same old blog, New Title

I changed the title of this blog. Why? Because I wanted to,that’s why. Why bring the rainbow?

I went to museums showoff last night and Kat Nilsson who is the head of Contemporary science at the Science museum gave a talk about how a lot of modern scientific objects that are offered to the museum are boring grey boxes.

A lot of the objects do quite incredible things but they aren’t always the most interesting to look at, this is where new media come in to help bring the objects to life and help with the interpretation of the objects.

This made me think a bit. When I started this blog I was in a different place to where I am now in my head. I was thinking a lot about what I was doing with my life and where I was going, both literally and physically.

Now I am much happier and have a much better idea of what I want to do both now and in the future so I decided to have a change.

I decided that bring the rainbow pretty well sums up the idea of turning the grey boxes into something more interesting, enlightening and well just more colourful.

Been busy

Time flies when you are having fun. And I have been having fun.  Since my last post I have moved to London to start a job as New Media engineer at the Science museum. fI  The museum is a great place to work, the work is really rewarding and the people I work with are so inspiring.  On a Sunday evening I now look forward to getting up on the Monday to see what the following week will have in store.

When I’m not working I now play Roller Derby for the London Rollergirls.  So its been a busy few months, but I’ve been on holiday for the last week. Not gone anywhere just stayed in London and relaxed. I’ve  taken the chance to have some long  lie-ins and explore London a bit more

With all these changes over the past few months I haven’t had much chance to work on my personal projects much, but now I am settled in a flat I’m planning on getting a bit more organised a putting some time aside to get back into working on some android and online projects.

After a few visits I’ve joined the London Hackspace So going to make some time to go there especially to play with  a few hardware ideas i want to work on.

Anyway its late, time for sleep.

Cruelty to cats

When I play Roller Derby, I go to training. A coach will give us various drills to do, she will explain what we are doing, how to do it, break it down into smaller steps,explain why we are doing the drill and what the aim of the drill is trying to achieve. Sometimes it will be to develop a skating skill such as a stop, a turn or a jump. Sometimes it will be to execute a strategy to give our team the advantage over the other team.

We will then work on that drill,depending on what it is we work individually,pairs or small groups. Repeating the drill, helping each other to develop the skill, discussing our limitations and encouraging improvements. Often as we work on the drill we will discover things that work well,things that don’t work and how to overcome or bypass these. Finally we come together as group and feedback thing we have learnt to the entire group so we can all learn and improve.

At our ordinary training sessions  the coach will be one of our own coaches, occasionally I will attend boot camps and be coached by top U.K or U.S coaches who will impart cutting edge strategy currently been used by top WFTDA Derby Leagues.

Essentially what I am doing when I train is copying what the coach does. From the copying comes adaptation, changing the move or strategy to suit a different situation or physical limitation. Finally by either accident,design or good fortune occasionally something new will happen, the new thing might not always be really new, maybe someone else somewhere has discovered the same thing, maybe the new thing works better than the original maybe it doesn’t, but it all starts with copying.

Copying is one of the most natural ways of learning, its how we learn to talk,its how a lot of stuff is taught in school and a lot of life lessons are learnt that way. I learn by doing,so just reading an article doesn’t work very well for me, but if i type in the code, it sinks in better.  Copying is how products develop, after the Wright brothers cracked the basics of flying most aeroplanes have copied the same basic idea, but improved slowly over time.

When I am writing Apps, I’ve really shied away from copying anything, even if its just a  few lines of code from a tutorial or book, It has felt like cheating.

Probably this is partly from reading stories pretty much every day about all the legal fights over  stupid patents   that always seem to be in the news, partly out of genuine respect for the work other people do.

I’m starting to realise that there are only so many ways of getting data from a database or showing text on a screen and its not sensible to come up with something original for every small problem.  That’s not to say its okay to rip off somebody’s hard work,ideas,code, artwork en masse.

While browsing the Google Play store a few days ago I came across an App, that had a very similar function to my E number knowledge App. A closer look and the interface was almost identical to mine. At first I was absolutley outraged and disgusted that somebody couldn’t be bothered to think up an original product and could only go around ripping off the work of developers such as myself.

Then Shock horror I realised that the App in question had been available for well over a year, a lot longer than my App, panicking I started to worry that I was the one that had ripped off somebody else maybe I had seen that App and subconsciously  without realising it copied the interface. Fortunately a quick look at my App showed I had changed the layout before release quite a bit, it was just that when i was developing it the interface was similar so it had got inplanted in my head what it looked like.

So no more worrying about copying the nuts and bolts,  There may be more than one way to skin a cat, but I like my cats cute and fluffy.

Here’s my plan think big,copy small.

Show and Tell Friday (Part 2)

Right now onto the part where I get the Twilio part of the App working. I had already signed up for the service. The sign up is free and there it is possible to test your App using a test number along with a PIN, sadly for SMS apps this only works in the U.S. So i paid the $20 and  chose the number that I wanted to use.

There isn’t much to write about the Twilio part of the code I just used the Replying to text messages  quickstart guide as an example, output the training schedule in place of "<?php echo $name ?>, thanks for the message! ” then ready to test.  I had to tweak the code in my php that limited the output to 160 characters as it wasn’t working properly (I said it was a hack) Twilio won’t send the message if it goes over 160 characters rather than send the incomplete message, but it does give a message on the Developer console.

So thats it then, simple App working, could do loads more with it but done what I wanted to do, brushed up on my php, learnt how to interact with Google Calendar and explored a coll communications platform. Happy Days

Glue everywhere

When I was young something i enjoyed for a while was building airfix kits, little model planes. Think my parents bought me one because it was a wet day,I was off school and had nothing to do.  Surprisingly it was really enjoyable to make.  Following  the instructions, taking the pieces of the plastic frame in order and then glueing them together into a finished model. When I made it, I was so proud, that i had completed the entire thing from start to finish, It looked fantastic.

Later on i started painting the models, buying several tiny pots of paint for each model, painting the plastic components while they were still on the frame, then carefully assembling them.

I can’t remember how long I did this hobby for. Maybe two or three years and made around 10 - 15 models, so I wasn’t massively obsessed and it wasn’t a massive passion just a hobby.  At some point I do remember looking back at the the first model I made,  comparing it with my later ones that were neatly painted, no visible glue,decals carefully applied, it was terrible,glue smeared everywhere, parts not aligned correctly, not painted, looked awful and certainly wouldn’t fly.

Guess what I am saying is, don’t be afraid to do something, take pride in your work, make the best you can.  When you look back at it in a few years time it you may think that your early work was a stinking mess but you need to to go through that practise to be able to make the good stuff. Make stuff that is rubbish and realise that its a step on the way to making the good things.

I know that a lot of the stuff i’m doing at the moment is covered in glue and its got a long way to go but I still need to do it,