Friday 5 April 2013

Prompting the user to download a Data URI and specifying the name it should take

The following Javascript code allows you to prompt the user to download a Data URI and suggest it's name. It works in Chrome, check for other browsers you wish to support.

function downloadWithName(uri, name) {

 function eventFire(el, etype){
  if (el.fireEvent) {
   (el.fireEvent('on' + etype));
  } else {
   var evObj = document.createEvent('Events');
   evObj.initEvent(etype, true, false);
   el.dispatchEvent(evObj);
  }
 }

 var link = document.createElement("a");
 link.download = name;
 link.href = uri;
 eventFire(link, "click");
}

For example, calling
downloadWithName("data:,Hello%2C%20World!", "helloWorld.txt")
will prompt the user to download a text file called helloWorld.txt containing "Hello World".

Friday 11 January 2013

Generating all binary arrays of a given length in Coffeescript / Javascript

The following Coffeescript code generates an array containing every possible binary array of a certain length:

@allVectors = (n) ->
    vectors = []
    return vectors if n == 0
    vectors[0] = [0]
    vectors[1] = [1]
    return vectors if n == 1
    for i in [0..n-2]
        count = vectors.length
        for j in [0..count-1] 
            vectors[j+count] = vectors[j][..] #Copy the array to a new location
            vectors[j].push 0 #In the first copy add a 0 on the end
            vectors[j+count].push 1 #In the second copy add a 1 on the end
    return vectors

For example, calling allVectors(2) will return [[0,0],[0,1],[1,0],[1,1]].

This runs in O(n2^n) time. Can you do it faster? Got a prettier implementation? Lets see them in the comments!

(Here it is compiled into Javascript for any old school coders around:)

allVectors = function(n) {
  var count, i, j, vectors, _i, _j, _ref, _ref1;
  vectors = new Array();
  if (n === 0) {
    return vectors;
  }
  vectors[0] = new Array();
  vectors[1] = new Array();
  vectors[0][0] = 0;
  vectors[1][0] = 1;
  if (n === 1) {
    return vectors;
  }
  for (i = _i = 0, _ref = n - 2; 0 <= _ref ? _i <= _ref : _i >= _ref; i = 0 <= _ref ? ++_i : --_i) {
    count = vectors.length;
    for (j = _j = 0, _ref1 = count - 1; 0 <= _ref1 ? _j <= _ref1 : _j >= _ref1; j = 0 <= _ref1 ? ++_j : --_j) {
      vectors[j + count] = vectors[j].slice(0);
      vectors[j][vectors[j].length] = 0;
      vectors[j + count][vectors[j + count].length] = 1;
    }
  }
  return vectors;
};

Monday 30 April 2012

New TEDxOxford Site Launched!

I'm very excited to announce that my team and I at TEDxOxford are launching the brand new TEDxOxford website! We have teamed up with the awesome guys at Oxford-based One Ltd to launch our new site and we're super excited about it! Please check out the new site and give any feedback you have in the comments below!

In the TED spirit of ‘ideas worth spreading’ TEDxOxford is all about the power of imagination and innovation. Christopher Toumazis (Keble College, Oxford University) was inspired to launch the conference and was joined by a bunch of other equally quirky and inspired Oxford University students from across the colleges who felt that there was a definite gap for TED in the university scene.

After months of extensive preparation and marketing tactics that ranged from simple business cards with 260911 put in student’s pigeon holes, to a red balloon clad Oxford (and more specifically a balloon adorned Radcliffe Camera), the first event happened at the T.S Eliot theatre in Merton College Oxford on the 26th of September 2011.

TEDxOxford 2011 was a truly fantastic day with speakers ranging from PR dynamo Kelly Cutrone (now to be seen on this season’s America’s Next Top Model), Creation Records founder Alan McGee to Oxford Professor of Mathematics Marcus du Sautoy and the leading regenerative medicine expert Aubrey de Grey. See photos from the event on Facebook.

This year TEDxOxford 2012 (in line with the much used but very apt cliché) is going to be bigger and better than ever! It is going to be held in November at the Oxford Playhouse (date tbc) and is going to be an unforgettable day.

The TEDxOxford 2012 line up is already looking incredible and it promises to be an experience that is not only focused on ideas – but also providing a more interactive experience for attendees with multiple workshops happening in the breaks between speakers.

Tuesday 6 March 2012

Google Drive Exists (And We Have Proof!)

Digging around the Chromium bugs website this evening resulted in the discovery of this screenshot posted by a Googler on the 28th of February 2012 which, although intended to display an alignment bug on the page accidentally includes information relating to the fabled Google Drive.

The screenshot is of the extensions page and features an entry for an extension titled "Google Drive (by Google)", with an attached description of "Save web content to Google Drive".

This is one of the first pieces of firm proof beyond rumour that indicates that the Google Drive is truly in development and will be launched soon.

Since the extension is used for clipping web content to the Google Drive it seems that the 'GDrive' will likely be a combination of advanced bookmarking of web content as well as used for storing traditional desktop files. This makes sense, since files are required by enterprise for legacy reasons but unifying an interface for web content (cloud documents) and traditional files and folders would ease the transition from files to the cloud.

Doing a little more digging reveals that the extension was first referred to by a Googler in August 2011 here so the extension has been in testing for some time, perhaps we could expect a Summer launch marking one year after they started testing internally? Let us know your predictions in the comments below!

For more of the latest discoveries about Google follow me on Twitter or subscribe for updates!

Bonus: The window in this screenshot doesn't feature a minimize button, what kind of a system could this Googler be running on? Perhaps an advanced version of ChromiumOS with window management..? Let us know your thoughts in the comments below!

Tuesday 7 February 2012

Facebook Launches Advertising on Photos

Following the recent mainstream roll out of the Facebook Timeline it seems Facebook has decided to roll out a new Photos UI to go with it.

The new user interface has a very Lightbox feel to it with nicely placed 'Like' and 'Tag' buttons when the image is rolled over. It breaks away from the more traditional vertical layout that many websites use to place comments on the right, perhaps in a bid to focus users to spend more time considering the social interaction around a photo rather than the photo itself.

Controversially, the new comments-on-side interface allows a large blank space for advertising on photos. This will inevitably add a very large new revenue stream, especially given the amount of time the average Facebook user spends browsing photos on the Social Networking site.

ComScore and BuddyMedia recently put together this excellent report on social media which included the following chart which makes it pretty clear why Facebook is keen to run as many adverts as possible on users photos.

Since it's recent IPO many are speculating that Facebook may make some unpopular commercial changes in order to boost income which may cause it to go the same way as MySpace.

Of course it is only a matter of time before this change is rolled out to all of Facebook and the people cry out in revolt as they do at every change. Give it one week and people will probably no longer notice but I'll bet this change will pay off significantly in terms of new revenues.

Thursday 21 July 2011

Baidu Browser is Google Chrome Copy-Cat including Angry Birds Rip-Off


Baudi, China's search dominator has launched their very own browser today. Look familiar?

The new browser is a clear rip off of Chrome, albeit it inspired by an older version which still featured the large app icons in the tab bar.

The best thing? It even comes with it's own Angry Birds rip off (see screenshot below) with even more annoying music than the original (and that is really saying something...)

Will it see favour with the Chinese public? Only time will tell..


Google tests new Autocomplete UI


As part of the eternal UI testing we've seen lately Google is testing a new style of autocomplete on their UK version of the site.

It's unclear what place the greyed out words will have with this new interface, since although they are both being shown together right now I can't see that being final implementation.