IET Global grand challenges summit 2013

A while back I had the pleasure of receiving a call from Dr. Ian Nussey OBE a long standing leader of IBM’s university relations programme, Ian was extending an invite to attend the IET Global grand challenges summit being held on the 12th and 13th of March at the IET building Savoy place in London.

Opportunities like this don’t come along every day and i was excited to see that the list of guest speakers contained some of the most eminent academics and industry leaders in the fields of engineering and science.

The theme of the summit was around the grand challenges that exist in todays world and how they can be tackled by some of the staggering advances that are being made in fields such as synthetic biology.

The grand challenges jointly propose by the Royal Academy and the IET had been summarise in a list of 14. The list consisted of…

* Make solar energy economical
* Provide energy from fusion
* Develop carbon sequestration methods
* Manage the nitrogen cycle
* Provide access to clean water
* Advance health informatics
* Engineer better medicines
* Restore and improve urban infrastructure
* Reverse engineer the brain
* Secure cyberspace
* Prevent nuclear terror
* Advance personal learning
* Enhance virtual reality
* Engineer the tools of scientific discovery

Attendees were drawn from a mixture of Academia and various industries.

The summit was arranged around a set of major topics – sustainability, health, education, enriching life, resilience, technology and growth.

Day one started with an introduction by Professor Dame Ann Dowling. Shortly followed by the keynote speech given by Dr J Craig Venter founder of the Venter institute.

Dr. Venter began with an some stats to highlight the challenges we face in a world that is projected to reach a population of 9 billion by 2050 (Something later commmented upon by Bill Gates*) and pointed out that rates of growth are different according to culture, for example the population of India will be greater than China by 2030 at the current rate of increase.
He pointed out that food, fuel and water are the 3 resources that we need to survive and they are of equal importance, all need to be managed as scarce resources.
We use 4-5 billion tons of coal a year and as a result the carbon sinks of this world the oceans and forests are saturated.China the US and Europe together contribute the biggest proportion of CO2 emissions only Europe is currently taking (mostly ineffective- think carbon credits) action to combat this.

Water is a very mismanaged resource, in food production terms the average amount of water needed to produce the food consumed by a single person is 5000 litres a day.70% of water used is in agriculture and farming, for example 1kg of beef takes 15,000 litres of water to produce.

To combat the issues of water scarcity disruptive change is required.

Synthetic life: Control over nature has long been a human goal, “DNA is the software of life” and the Venter institute have compiled a large database of DNA samples collected from oceans around the world. The challenge they undertook was to see if they can create a synthetic chromosone and ‘boot it up’ The process they have developed is to effectively program with DNA, they have developed software to help design and develop ‘biological software’ and inject it into brewers yeast resulting in an altered cell structure. The potential of this technique and flexibility afforded by programming with DNA opens uo the possibilities of designing food or even fuel.
One topical subject at te moment at least in the UK is antibiotic resistance, in the US more people die from bacterial infections than from car accidents.

The Venter institute have now had the first genome based vaccine approved by the FDA for meningitis.
Using the software and hardware created by the institute they can receive samples of a bacteria and create a custom cell based vaccine in 12 hours.

The software and hardware they have developed is known as a Digital Biological Convertor (DBC) and can take a digital representation of the vacine ‘software’ and produce it in an automated manner, essentially it prints it.

Using the digital representation and DBC vaccines could be created and shipped all around the world to be produced in extremely short time scales.

The DBC opens exciting possibilities for developing synthetic life which has implications beyond vaccines, but also raises issues such as Intellectual property management, security, trust and regulatory issues.
After the keynote was the first panel on sustainability consisting of …
Professor Jeffrey Sachs
Alfred Castelan
Angela Belcher
John Longhead
Calestous Juma

Jeffrey Sachs highlighted the fact that conflict centers around the world are largely centered on dry zones and highlighted the increasing numbers of droughts that are occuring. In particular the US drought in 2012  destroyed 20% of the annual crop yield. He also talked about what the developing world needed to do to catch up with the developed world tackling issues of gender and discrimination, environmental degradation, population control and youth jobs.

you can find  more details and videos of the event here

Olympic road race

The London Olympics have been and gone in a flash leaving a bit of a vacuum in their wake, I always enjoy watching the Olympics but even I was surprised to the extent at which I was absorbed by this years events. The obvious explanation was that they were located in and around London only an hour by train.

With them being in such close proximity surely I could get to see a few events live? Unfortunately the ticket allocation gods did not look upon my applications favourably and my attempts at getting track cycling, rowing or athletics event tickets failed miserably.

I have a strong preference to watching sports that the GB team are good at, in particular rowing and cycling both sports that I either do or have done in the past. The mens 8′s were a particular draw as a local rower James Foad was selected for the crew, James was always a star junior rower at Itchen Imperial rowing club in Southampton and I bumped into him at regatta’s and nights out from time to time, so it was fantastic to watch him win a bronze medal on tv but it would have been even better to be there in person.

After failing to get tickets for these events I set my heart on getting to the Mens road race, the opportunity to see some of my cycling hero’s close up was too good a chance to pass up. I’ve been following the Tour De France for years watching Cav and Wiggins road careers take off and so the road race would be one of the highlights of the Olympics for me.

The week before the Olympics I spent a fair amount of time examining the route of the race, in particular the area around Dorking. If I was going to make the trip to watch then it had to Box Hill where the riders would do 9 laps and the majority of the routes climbing. A bit of searching revealed that 10′s of thousands of people were expected to descend on the area. I’d have to get there early to get a decent spot.

An experience shared is always a more enjoyable one so I texted my old rowing doubles partner Pete, who after a bit of negotiation managed to persuade his in-laws to babysit for the day. Pete is about the most affable person I know and he barely batted an eyelid when i surmised that he’d need to get to my house for 5.45am on the Saturday morning if we were to get on Box Hill before the hordes descended (or ascended as was actually the case). We left on time and caught an early train from North Camp near Farnborough, it was fairly even before we got to Guilford just after 7am. From there it was standing room only.

Arriving at Dorking we piled off the train and set off walking briskly for Box Hill, the signage was good and the crowds were all heading in the same direction, arriving at the bottom of the hill for 8am there was already a steady stream of people heading up with tents and caravans filling the nearby fields. We stopped at one of the cycling festivals near the bottom of the hill for a quick breakfast snack, disappointingly they didn’t have a live screen as advertised that cut out an option for watching the final part of the race after the cyclists had left Box Hill and headed for the Mall.

We headed up the hill and about halfway up were told by a sadly misinformed gent that the organisers were turning people back already and he had been sent back down. Preparing ourselves for a bit of a dive through the woods we headed on up the hill, as it turned out no off piste adventures were necessary hopefully the guy who gave us this information didn’t put too many people off and made it up himself.

Once up the top we were happy to discover that there was a live screen, food stalls and toilets (50p a wee or free with a food receipt) provided by the well equipped Smith & Western grill who were making the most of the crowds without ripping them off.

Wandering along the road from the top of the zigzags the road side was filling up quickly with people setting out picnic rugs, chairs and hampers. We managed to find a nice comfy grass verge slightly raised from the road about 300m along and plonked ourselves down to wait.

Everyone was in a festival mood and event organisers and police alike were chatting with spectators, kids were chalking out the names of the GB riders on the roads with the adults lending a helping hand in the spelling department.

 

 

Frequent laps were being made by the police motorbikes who were having fun high five’ing people as they went by.

There were on or two familiar faces in the crowd …

 

When the racing reached us a break had gone very early on, Stuart O’Grady of Australia is on the front

The break was gradually hauled back by the peloton but managed to stay away, on the last lap of box hill the gap was down to 50 seconds, several riders managed to bridge the gap including Phillipe Gilbert.

The GB boys buried themselves to try and catch the break.

Only the German squad helped on the front, pretty much every other squad who had a shot had a rider in the break and didn’t help. The Germans were trying to get Andre Greipel up to the lead group for a shot at the final sprint against Mark Cavendish. Unfortunately lead group got away and Alexandre Vinokourov who has previously been banned for two years following a positive blood doping in the 2007 Tour De France took the gold medal.

Wiggo did not look impressed.

Despite the disappointment of Cav not winning a medal it was a great day out and I can’t wait to see all the guys back out on the road in the 2014 TDF starting in Yorkshire.

The Challenges of writing an OpenSim client in Unity3D

I thought I’d write a quick article on the possibilities of writing a client for OpenSim using Unity3d, I’m writing this as there has been a lot of discussion around this recently after the Unity3d indie version became free.

I’ve done a fair bit of prototyping and investigation on this in the past, so I’ll share what I’ve discovered and where I have got to.

Firstly I want to make clear a couple of points about the way Unity3d applications can be deployed. One option for creating a client is standalone mode, in this the produced client will be an executable desktop app that works on Windows or OS X. The second and most attractive option for an OpenSim client is deploying as a Web Plugin that can be embedded in any webpage.

Now I’ve made these two options clear I’ll point out the additional difficulties of creating a Web Plugin client. Firstly any Unity3d app deployed as a web plugin is security sandboxed just as a java applet would be. In practical terms what this means is that certain standard API calls in the embedded Mono engine are not allowed. For example one fairly critical class that can’t be used is System.Net.WebRequest. As far as I can tell there is not a list anywhere of API functions that do not work, it’s a case of trial and error and trawling the Unity forums.

The second issue with the web plugin is that you can’t use any additonal C/C++ libraries you can however use c# dlls. The restriction this causes though is that your included c# dlls can’t rely on any platform specific external libs, think System.Drawing and libgdi.

So now lets look at what we need to implement an OpenSim client. First off we’re going to need to communicate with the server so we need libOMV, for creating a standalone unity application using a pre 0.7 libomv libary there is no problem, it works straight out of the box. Why pre 0.7.0 ? Because in 0.7.0 some features of .NET 3.5 have been introduced (see this opensim-dev post for detail) and Unity3d is on a back level version of mono, i’m not sure exactly which but i think it’s around 2.0.

It is possible to work around these changes and get libomv 0.70 working in Unity for a standalone client. However try deploying your simple log on and chat client as a Web Plugin and you will soon find that you don’t even get to the login stage as libOMV uses HttpWebRequest which doesnt work in the browser plugin. The fix for this is to rewrite parts of libOMV to use the unity WWW object instead.

So next up we’ve got the issue of 3D object formats which luckily is solved (in the most part) by the availability of the PrimMesher library written by Dahlia. I spent some time the other week getting this working and shared the Unity side of things with Dahlia who has gone on to get sculpties working as well. The remaining issue with objects is texturing and more specifically the decoding of jpeg2000 images. At the moment I’m decoding these to regular jpegs on the server side before assigning the textures in Unity.

I guess that leads onto the discussion of whether to bother with trying to get libOMV working in the browser, personally i think it’s worth it. Many would disagree as they don’t see a client embedded in the browser as any different from a desktop app, however this argument is neutralized somewhat by the fact that Unity can communicate via javascript with the page it is embedded into, this leaves open the possiblity of widgetized system for things like inventory management, chat etc. etc. and custom widgets for different opensim grids.

The alternative option of course is to write a Unity specific client library and implement the matching iClientApi, this may in fact be a better solution as keeping a forked libOMV version just for unity will be a bit of a pain. The down side of this alternative is that the client won’t work with the main Second Life grid.

So that’s the end of this little brain dump,I hope it has informed anyone thinking of tackling a Unity client for OpenSim and also hope it hasn’t put you off at all.

freeswitch

Home VOIP system using FreeSwitch and a Linksys 3102 voice gateway (UK Guide)

This is a basic HOWTO for setting up a home VOIP system using the excellent FreeSwitch telephony platform and a LinkSys SPA3102 voice gateway. (skip to the HOWTO section if you just want to get on with it)

First of all a quick introduction to FreeSwitch for those who haven’t come across it before…

(the following mercilessly wrenched from freeswitch.org)

FreeSWITCH is an open source telephony platform designed to facilitate the creation of voice and chat driven products scaling from a soft-phone up to a soft-switch. It can be used as a simple switching engine, a PBX, a media gateway or a media server to host IVR applications using simple scripts or XML to control the callflow.

We support various communication technologies such as Skype, SIP, H.323, IAX2 and GoogleTalk making it easy to interface with other open source PBX systems such as sipXecs, Call Weaver, Bayonne, YATE or Asterisk.

Okay, so we’ve established what FreeSwitch does. The one thing it doesnt do is connect you to your BT telephone line, we need a piece of hardware for that. In this case the Cisco LinkSys SPA3102 which again according to the blurb on the Cisco site ….

The SPA3102 Voice Gateway allows automatic routing of local calls from mobile phones and land lines to Voice over Internet Protocol (VoIP) service providers, and vice versa.

Why would I want to run a home VOIP system?

Well for one as stated in the product blurb line above you can setup the voice gateway to use a VOIP service provider for making calls from your landlines, this is easy to do and will save you a bunch of cash especially if you regularly make long distance calls.

I have other reasons though some important to me and others just hacks i want to play around with here’s a short list

* When I’m working at home I want to be able to make and receive all my landline calls from the softphone I have running on my laptop (I’m using X-Lite) , then i can use my headset which i find most comfortable especially when on long conference calls. Using a softphone on my laptop allows me more freedom to change volume levels which can vary a lot on international conference calls.

* If I’m away from home and with internet access somewhere i want to still be able to answer my home phone.

* I want control of the time of day our phone rings, my daughter Lucy gets put to bed at around 7pm and frequently wakes up when the phone rings in the evening.

* I want control over who rings, with held numbers will go straight to voicemail hopefully cutting out the dreaded sales calls.

* Most of the rest is covered by fun hacks i have in mind

ok discussion over.

HOWTO

(disclaimer this is a UK guide for BT landlines, plus if you break anything don’t blame me)

What you’ll need

1. a Cisco Linksys SPA3102 (cost £50-£60)

2. An RJ11 socket to BT plug adaptor, Maplins code AR34M

3. An RJ11 plug to BT master socket adaptor with ring capacitor, Maplins code VD36P

4. An ethernet cable

Install FreeSwitch

FreeSwitch needs to be installed on a machine on your home network. You can install it on pretty much any platform Windows,Linux, Mac etc.

Follow the install guide on the FreeSwitch site.

When you have FreeSwitch installed start it up with the default configuration and use a softphone such as X-lite to check the install. In X-lites SIP Acount settings enter the IP address details for the server you installed FreeSwitch on. Use 1001 as the username and 1234 as the password (this is a default account that comes already set up with FreeSwitch), save these settings and X-Lite should register with FreeSwitch. Now dial 3000 on the X-Lite number pad and you should be connected to the default conference call number on your FreeSwitch server.

Setup the Linksys 3102 voice gateway

For this section I mostly refered to Andrew Oakley’s excellent setup guide in addition to the FreeSwitch SPA3102 HOWTO however I’m regurgitating bits from both here for the sake of completeness.

Firstly as with Andrews guide i’m assuming you already have a wireless broadband router.

Now get out the instructions that came with your SPA3102, put them in a drawer, do not look at them they are evil and will confuse you (disclaimer – read the safety stuff in there first)

Hooking up all the cabley stuff

  • Do not connect the SPA3102 to the mains yet.
  • Unplug your phones/extension wiring from your BT master wall socket (the first BT wall socket where the telephone line first enters your house).
  • Connect your SPA3102′s LINE socket to your BT master wall socket, using either a known-good RJ11-BT cable (eg. an old modem cable) OR using the supplied RJ11-RJ11 cable plus an RJ11-BT adaptor (eg. Maplins code AR34M).
  • Plug the master socket adaptor (eg. Maplins code VD36P) into the SPA3102′s PHONE socket.
  • Plug your BT phone(s) into the master socket adaptor.
  • Check to make sure your SPA3102 is turned off (unplugged from the mains). When turned off, the SPA3102 connects the LINE to the PHONE socket directly, and we are going to test this connection.
  • Lift the phone handset. You should hear a dial tone. Try calling a telephone number. If this doesn’t work, your cabling is wrong.
  • Use a mobile phone to ring your normal home landline number. Your landline phone should ring as normal.If this is all working you can now plug in the power adaptor and turn on the router
  • Connecting the SPA3102 to your network


    Connect an ethernet cable from your computer to the SPA3102′s ethernet socket.

    In a browser go to 192.168.1.1 you should see the SPA3102′s web interface, if not check your computer is set to use DHCP to get its ip address.

    In Router – WAN Setup change Connection Type to Static IP. Change the Static IP, Netmask, Gateway and Primary DNS to the correct values. For instance, on my networks all computers are 192.168.0.something and the broadband router is 192.168.0.1, so I use 192.168.0.7 as my Static IP, 255.255.255.0 as the netmask, 192.168.0.1 as both the gateway and primary DNS.

    click on advanced then WAN Setup again. set Enable WAN Web Server to YES.

    Now Submit All Changes.

    Unplug the ethernet cable you used and reconnect your computer to your home network.

    Use the ethernet cable to connect the SPA’s internet port up to a spare ethernet port on your home broadband router.

    Now from your browser you should be able to connect to the SPA3102 admin panel by using the static IP address you set. In my case 192.168.0.7

    in the SPA web interface Click Admin login – Advanced – Voice – Regional and make the following changes:

    Dial tone: 350@-19,440@-22;10(*/0/1+2)
    Ring back: 400@-20,450@-20;*(.4/.2/1+2,.4/2/1+2)
    Busy tone: 400@-20;10(.375/.375/1)
    Reorder tone: 400@-20;10(*/0/1)
    SIT 1 tone: 950@-16,1400@-16,1800@-16;20(.330/0/1,.330/0/2,.330/0/3,0/1/0)
    MWI dial tone: 350@-19,440@-22;10(.75/.75/1+2)
    CWT1 cadence: 30(.1/2)
    CWT2 cadence: 30(.25/.25,.25/.25,.25/5)
    CWT frequency: 400@-10
    Ring 1 cadence: 60(.4/.2,.4/2)
    Ring 2 cadence: 60(1/2)
    Ring 3 cadence: 60(.25/.25,.25/.25,.25/1.75)
    Ring 4 cadence: 60(.4/.8)
    Ring 5 cadence: 60(2/4)
    Time Zone: GMT
    FXS Port Impedance: 370+620||310nF
    Caller ID Method: ETSI FSK With PR(UK)
    Daylight Saving Rule: start=3/1/7/2:0:0;end=10/1/7/2:0:0;save=1:0:0

    now go to admin->advanced->Voice->PSTN and set the following…

    Proxy and Registration

    Proxy: [FreeSwitch host name or IP]

    Subscriber Information

    Display Name: PSTN Line

    The FreeSwitch user ID

    User ID: 1000

    The FreeSwitch password for the user

    Password: 1234

    Dial Plans

    If you want a different extension than 1001 to be dialed change it here

    Dial Plan 1: (<:1001>S0)

    (xx.) basically means dial on the phone line of the SPA3102

    Dial Plan 2: (xx.)

    VoIP-To-PSTN Gateway Setup

    I want incoming VoIP requests to be dialed on the phone line aka: the (xx.) rule

    Line 1 VoIP Caller DP: 2

    VoIP Caller Default DP: 2

    FXO Timer Values (sec)

    I read some place to set this to 3 for caller ID to work, but I just wanted it to instantly forward and start ringing ext 1001

    PSTN Answer Delay: 0

    PSTN-To-VoIP Gateway Setup

    set PSTN CID For VoIP CID to Yes so that caller-id is forwarded

    FreeSwitch Configuration

    FreeSwitch on linux and Mac gets installed under /usr/local/freeswitch by default, im not sure where it goes on Windows so i’ll use $FREESWITCH_HOME for examples

    Create a file called 00_spa3102.xml  in the directory $FREESWITCH_HOME/conf/dialplan/default/

    The contents of this file are…

    <include>
    <extension name=”To PSTN”>
    <condition field=”destination_number” expression=”(.*)”>
    <action application=”bridge” data=”sofia/internal/${destination_number}@[IP address of your SPA3102]:5061″ />
    </condition>
    </extension>
    </include>

    Edit the file $FREESWITCH_HOME/conf/directory/default/1000.xml

    remove the following lines to ensure the caller id is passed through

    <variable name=”effective_caller_id_name” value=”Extension 1001″/>
    <variable name=”effective_caller_id_number” value=”1001″/>

    Now you can start up FreeSwitch with $FREESWITCH_HOME/bin/freeswitch

    Testing

    You should have a softphone such as X-Lite configured with the user 1001 from when you tested your FreeSwitch install earlier.

    To test everything is setup correctly dial your house phone from your mobile. The call should come through to X-Lite for you to answer.

    Try using X-lite to dial your mobile too, this should also go through.

    Next steps

    When you have everything working your next steps depend on what you want to acheive. Most of the config you’ll need will involve changes to the FreeSwitch dialplan that we created above. A next easy step would be to add a voicemail service, there are examples of doing voice mail amongst many other things on the FreeSwitch Dialplan wiki page

    Visualizing live shipping data in OpenSim (Isle of Wight Ferries)

    A couple of months back i spent some time writing a module for OpenSim, the purpose of this module being to allow you to connect directly to an MQTT messaging server from within the OpenSim scripting language. Thereby enabling real-time Publish Subscribe messaging in a 3d environment.

    Adding messaging capability to the scripting language opens up a raft of possibilities for integrating other live systems with in world objects, for previous demonstrations I have implemented chat between virtual worlds and also
    synchronous presentations across words and opensim regions amongst other things.

    For this one I heard of some live data available from one of our local master inventors Andy Stanford-Clark on the positions of Ferries around the Southampton, Portsmouth and the Isle of Wight. He was publishing these message onto his MQTT microbroker which meant with my module for OpenSim i could show the positions of all the local shipping in near real-time along with the name of the ship and other information like course speed and cargo type.

    In order to show this data i first terraformed an island within the IBM opensim grid to look like the Isle of Wight and surrounding sea. I did this by creating an image in photoshop and then using OpenSims terrain import feature. The image was based on a satellite photo of the area.

    This is the resulting opensim island

    aerial shot of opensim model of the isle of wight, uk

    The next step was to write a script for the ships, this script took the description of the object(ferry) it was assigned to and used it to subscribe to the information for that ship. Each description is the pubsub topic for the ship e.g. ferries/Isle Of Wight/Red Cat 1

    The script listens for incoming messages then moves the ship object to the correct location on the simulated region by converting latitude and longnitude into an X Y position. It also takes the bearing and makes the ship face in the correct direction.

    here’s a couple more shots of the ferries in action

    ferries from afar

    ferries close up

    The Ferries currently live on the IBM internal opensim grid (sorry only accessible to folks inside the IBM firewall :( )

    XML Parsing in OpenSim: Example – reading RSS feeds

    In OpenSim you’re not just restricted to using LSL for scripting, it’s also possible to use c#. This opens up the possiblilities for far more powerful scripts that can access c# in built libraries.

    For example I’ve previously mentioned that the string processing methods in Second Life are not very flexible when it comes to reading formatted data. Thus the reason I implemented the osParseJSON method to make Web APIs easier to use.

    Obviously another common data format is XML, in this case I don’t have to implement any new OpenSim script functions because the XML capabilities are available natively in c#.

    Here is a simple example of reading the RSS feed for my blog, and reading out the entries in chat.


    //c#
    // displays the contents of an RSS 2.0 feed

    string URL = “http://robsmart.co.uk/feed”;
    System.Xml.XmlDocument xDoc = new System.Xml.XmlDocument();
    LSL_Types.LSLString requestID;

    public void default_event_state_entry()
    {
    llSay(0,”RSS reader current Feed is ” + URL);
    getFeedContent();

    }

    public void getFeedContent()
    {
    requestID = llHTTPRequest(URL, new LSL_Types.list(), “” );
    }

    public void default_event_touch_start(LSL_Types.LSLInteger total_number)
    {
    // read out the RSS feed.
    displayFeed();

    }

    public void displayFeed()
    {
    System.Xml.XmlNodeList items = xDoc.GetElementsByTagName(“item”);

    for(int i=0;i < items.Count ; i++)
    {
    string title = items[i].SelectSingleNode(“title”).InnerXml;
    string link = items[i].SelectSingleNode(“link”).InnerXml;

    string description=”no description available”;

    if(items[i].SelectSingleNode(“description”)!=null)
    description = items[i].SelectSingleNode(“description”).InnerXml;

    llSay(0,title + “\n” + description + “\n”);
    }
    }

    public void default_event_http_response(LSL_Types.LSLString request_id, LSL_Types.LSLInteger status, LSL_Types.list metadata, LSL_Types.LSLString body)
    {
    if (requestID == request_id)
    {
    // store the xml
    xDoc.LoadXml(body);

    // process the xml
    llOwnerSay(“loaded feed”);
    }
    }

    OpenSim Web 2.0 contribution

    As described over on Eightbar I have made my first contribution to the OpenSim opensource project. The contribution is in the form of a new scripting function called osParseJSON. This function allows a c# script in OpenSim to consume the JSON notation provided by many of the major Web 2.0 APIs provided by services such as Flickr and Google translation.

    The following example is a script that uses the Google Translate API to let an OpenSim avatar translate ther conversations between 23 different languages.

    (disclaimer – please read the terms of conditions of the Google translate API and abide by them)


    //c#
    // This script is written as an example use of the osParseJSON method
    // it uses the Google translate API
    // ensure you have read the terms and conditions of the Google translate API
    // http://code.google.com/apis/ajaxlanguage/documentation/

    LSL_Types.key requestID;
    string sourceLang = "en";
    string targetLang = "fr";

    public void default_event_state_entry()
    {
    llSay(0,"translator running say '/1 sentence' to translate something");
    llSay(0,"translator running say '/2 source langage' to change target language e.g. '/2 fr'");
    llSay(0,"translator running say '/3 target langage' to change source language e.g. '/3 en'");
    llSay(0,"translator running say '/4 help', to list languages");
    llListen(1, "", NULL_KEY, "");
    llListen(2, "", NULL_KEY, "");
    llListen(3, "", NULL_KEY, "");
    llListen(4, "", NULL_KEY, "");
    }

    public void default_event_touch_start(LSL_Types.LSLInteger total_number)
    {
    llSay(0,"translator running say '/1 sentence' to translate something");
    llSay(0,"translator running say '/2 source langage' to change target language e.g. '/2 fr'");
    llSay(0,"translator running say '/3 target langage' to change source language e.g. '/3 en'");
    llSay(0,"translator running say '/4 help', to list languages");
    }

    public void default_event_http_response(LSL_Types.LSLString request_id, LSL_Types.LSLInteger status, LSL_Types.list metadata, LSL_Types.LSLString body)
    {
    if (requestID == request_id)
    {
    // the Google JSON string returned wil be of the format
    // {"responseData": {"translatedText":"Bonjour"}, "responseDetails": null, "responseStatus": 200}
    // call the osParseJSON method so we can read the contents
    System.Collections.Hashtable response = (System.Collections.Hashtable) osParseJSON(body);
    System.Collections.Hashtable responsedata = (System.Collections.Hashtable) response["responseData"];

    llSay(0,(string)responsedata["translatedText"]);
    }
    }

    public void default_event_listen(LSL_Types.LSLInteger channelIn, LSL_Types.LSLString name, LSL_Types.LSLString id, LSL_Types.LSLString message)
    {
    if(channelIn==1)
    {
    string toTranslate = (string) message;
    requestID = llHTTPRequest( "http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&q="+toTranslate+"&langpair="+sourceLang+"%7C"+targetLang, new LSL_Types.list(), "" );

    }
    else if(channelIn==2)
    {
    sourceLang = (string) message;
    }
    else if(channelIn==3)
    {
    targetLang = (string)message;
    }
    else if(channelIn==4)
    {
    llOwnerSay("LANGUAGE (CODE)");
    llOwnerSay("* Arabic (ar)");
    llOwnerSay("* Bulgarian (bg)");
    llOwnerSay("* Chinese (zh)");
    llOwnerSay("* Croatian (hr)");
    llOwnerSay("* Czech (cs)");
    llOwnerSay("* Danish (da)");
    llOwnerSay("* Dutch (nl)");
    llOwnerSay("* English (en)");
    llOwnerSay("* Finnish (fi)");
    llOwnerSay("* French (fr)");
    llOwnerSay("* German (de)");
    llOwnerSay("* Greek (el)");
    llOwnerSay("* Hindi (hi)");
    llOwnerSay("* Italian (it)");
    llOwnerSay("* Japanese (ja)");
    llOwnerSay("* Korean (ko)");
    llOwnerSay("* Norwegian(no) ");
    llOwnerSay("* Polish (pl)");
    llOwnerSay("* Portuguese (pt-PT)");
    llOwnerSay("* Romanian (ro)");
    llOwnerSay("* Russian (ru)");
    llOwnerSay("* Spanish (es)");
    llOwnerSay("* Swedish (sv)");

    }
    }

    Google ate my blog

    A couple of days ago friends at work started telling me that Google was flagging my blog here at robsmart.co.uk as an infested host of nastiness brimming with malware. This was a bit of a shock and kind of an egg on your face moment as I consider myself savvy with this sort of stuff.

    However it turns out the slightly old version of WordPress i was running was open to a couple of SQL injection attacks, and i had been a bit lax in updating to the current version. Googles recent policy of scanning sites for security breaches and then flagging and removing them from search results has brought this to my attention.

    So as a solution I deleted my old wordpress install and installed the latest version, one of the issues i found was a line of obfuscated javascript code embedded in the WordPress theme i was using.

    So now I’m all cleaned and security hitch free (promise).

    But what about the problem of Google flagging and blocking my site. Well to fix that I used the Google Webmaster tools.

    The first step was to add the robsmart.co.uk domain to the webmaster dashboard.

    The next step was verifying it belonged to me.

    verify ownership

    For this i simply made a blank html file as instructed and uploaded it to my website.

    next stage was to go to the overview tab and look at the problems listed. I’d completely replaced the wordpress install including the theme and been through each of the pages listed to check they were clean.

    after that i hit the “request a review” option

    The review happened within 24 hours, i’m now just waiting for the results to propagate back through the google search engine.