Christian Heilmann

Posts Tagged ‘fun’

A bit of harmless Friday fun – what is your Ninja name?

Friday, October 29th, 2010

Going through my RSS feeds this morning I found this Ninja name translation table:

Ninja translation table

I thought that was a perfect candidate for a YQL table, so I made one. So find out your Ninja name in the YQL console.

Conversion was easy – simply convert the table to a hash, check that the user has not entered any non-alpha characters, lowercase and loop over the different characters with a lookup. You can see the source of the table on github

Yours, mirishikiari.

TTMMHTM: Piano hacks, PHP and Ruby secured, Leisure Suit Larry in Canvas

Friday, October 9th, 2009

Things that made me happy this morning.

All the tools you need to get ready for “talk like a pirate” day

Thursday, September 17th, 2009

Avast! Saturday is the annual talk like a pirate day and my colleague Tom Croucher has done a tremendous job to create a YQL solution for translation of English to Pirate

In essence he used YQL to store a translation data set and allows us to alter it using the update and storage parts of YQL. He has come up with a few great things to use for talk like a pirate day:

A script to include into any page that will automatically convert it to pirate speak:

 

A bookmarklet to translate any web site: piratize (drag it to your links toolbar).

An open YQL table to add to the pirate dictionary.

Using this, I built the following interfaces:

Have a great talk like a pirate day! Sadly enough I’ll be Aarrr-ing down from a plane as I am flying back to the UK on that date.

Rickrolling Google translate with YQL – Rickrollwhisper

Wednesday, August 5th, 2009

This morning I found this wonderful blog post that shows what happens when you run the “never gonna give you up” aka. RickRoll lyrics through an automated translation tool and back into English.

This has been a classic time waster using Babelfish in the past for me and I thought we could knock it up a notch and used YQL and the Google Translation API to automate this process.

Check out Rickrollwhisper to see the results.

Rickrollwhisper

Google Translate is one of the Open Data Tables built by the outside community for YQL and you can use it simply by providing a source text and the language to translate to:

select * from google.translate where q=”this is a test” and target=”de”;

Try it out for yourself or see it in the console.

The result is the text as a translatedText element:




true

185
178
2426


Dies ist ein Test

Using this, I simply took an array of supported languages and took a random one each time I translated the lyrics:

$lyrics = “We’re no strangers to love,
[…]
I just wanna tell you how I’m feeling,
Gotta make you understand”;

$target = getlanguage();
$t = getstuff($lyrics,$target);
$trans1 = ‘

‘.$t.’

‘.

Language: ‘.$target.’

‘;
$target2 = $target;
while($target2 == $target){
$target2 = getlanguage();
}

$t = getstuff($t,$target2);
$trans2 = ‘

‘.$t.’

‘.

Language: ‘.$target2.’

‘;
$result = getstuff($t,’en’);

function getlanguage(){
$languages = array(‘it’,’nl’,’fr’,’de’,’sv’,’pl’,’ro’);
return $languages[rand(0,sizeof($languages)-1)];
}

function getstuff($text,$target){
$root = ‘http://query.yahooapis.com/v1/public/yql?env=’.
‘http%3A%2F%2Fdatatables.org%2Falltables.env&format=json&q=’;
$yql = ‘select * from google.translate where q=”’.$text.’”’.
’ and target=”’.$target.’”’;
$url = $root.urlencode($yql);
$curl_handle = curl_init();
curl_setopt($curl_handle, CURLOPT_URL, $url);
curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT, 2);
curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1);
$buffer = curl_exec($curl_handle);
curl_close($curl_handle);
if (empty($buffer)){
return ‘Error retrieving data, please try later.’;
} else {
$json = json_decode($buffer);
$result = $json->query->results->translatedText;
return $result;
}

}

Maybe I find the time to create the multitranslate as an open table to make this more generic.

TTMMHTM: IE6 not allowed to play, YQL weather and multi query, clever words, and my own geeky facebook vanity url

Tuesday, June 16th, 2009