Wednesday, June 12, 2013 | 10:04 AM

Play Cube Slam, a real-time WebRTC video game

Author Picture By Justin Uberti, Chromium team

Cross-posted with the Chromium Blog

Cube Slam is a Chrome Experiment built with WebRTC, an open web technology that lets you communicate in real-time in the browser (and in this case, play an old-school arcade game with your friends) without downloading and installing any plug-ins. In this post, we wanted to explain a bit about how Cube Slam works.

Cube Slam uses getUserMedia to access your webcam and microphone (with your permission, of course), RTCPeerConnection to stream your video to a friend, and RTCDataChannel to transfer the bits that keep the gameplay in sync. If you and your friend are behind firewalls, RTCPeerConnection uses a TURN relay server (hosted on Google Compute Engine) to make the connection. When there are no firewalls in the way, however, the entire game happens directly peer-to-peer, reducing latency for players and server costs for developers.


CubeSlame Game Over screen

Cube Slam is the first large-scale application to use RTCDataChannel, which provides an API similar to WebSocket, but sends the data over the RTCPeerConnection peer-to-peer link. RTCDataChannel sends data securely, and supports an "unreliable" mode for cases where you want high performance but don't care about every single packet making it across the network. In cases like games where low delay often matters more than perfect delivery, this ensures that a single stray packet doesn't slow down the whole app.

RTCDataChannel only supports unreliable mode in desktop Chrome today. We're working on implementing the latest WebRTC spec, where we'll use the standard SCTP protocol to support reliable mode. WebRTC will also be available on Chrome for Android later this year, and you can try it now by flipping “Enable WebRTC Android” in chrome://flags. Several browsers are currently working on implementing WebRTC, and we’re looking forward to the day when you can have a Cube Slam face-off against your friends on any browser and any device.

To learn more about the tech in Cube Slam, you can check out our technology page and source code. Disable the shields! Destroy the screen! Have fun!

Justin Uberti is one of the co-creators of the WebRTC initiative, and leads the WebRTC engineering team at Google. Previously, Justin helped create Google+ Hangouts.

Posted by Ashleigh Rentz, Editor Emerita

Tuesday, June 11, 2013 | 9:01 AM

Race across screens and platforms, powered by the mobile web

Author Picture By Pete LePage, Chromium team

Cross-posted with the Chromium Blog

You may have seen our recent demo of Racer at Google I/O, and wondered how it was made. So today we wanted to share some of the web technologies that made this Chrome Experiment “street-legal” in a couple of months. Racer was built to show what’s possible on today’s mobile devices using an entirely in-browser experience. The goal was to create a touch-enabled experience that plays out across multiple screens (and speakers). Because it was built for the web, it doesn’t matter if you have a phone or a tablet running Android or iOS, everyone can jump right in and play.

   
Racer required two things: speedy pings and a consistent experience across screens. We delivered our minimal 2D vector drawings to each device’s HTML5 Canvas using the Paper.js vector library. Paper.js can handle the path math for our custom race track shapes without getting lapped. To eke out all the frame rate possible on such a large array of devices we rendered the cars as image sprites on a DOM layer above the Canvas, while positioning and rotating them using CSS3’s transform: matrix().

Racer’s sound experience is shared across multiple devices using the Web Audio API (available in latest iOS and Android M28 beta). Each device plays one slice of Giorgio Moroder’s symphony of sound—requiring five devices at once to hear his full composition. A constant ping from the server helps synchronize all device speakers allowing them to bump to one solid beat. Not only is the soundtrack divided across devices, it also reacts to each driver’s movements in real time—the accelerating, coasting, careening, and colliding rebalances the presence of every instrument.

To sync your phones or tablets, we use WebSockets, which enables rapid two-way communication between devices via a central server. WebSocket technology is just the start of what multi-device apps of the future might use. We’re looking forward to when WebRTC data channels—the next generation of speedy Web communication—is supported in the stable channel of Chrome for mobile. Then we’ll be able to deliver experiences like Racer with even lower ping times and without bouncing messages via a central server. Racer’s backend was built on the Google Cloud Platform using the same structure and web tools as another recent Chrome Experiment, Roll It.

To get an even more detailed peek under the hood, we just published two new case studies on our HTML5 Rocks site. Our friends at Plan8 wrote one about the sound engineering and Active Theory wrote one about the front-end build. You can also join the team at Active Theory for a Google Developers Live event this Thursday, June 13, 2013 at 3pm GMT for an in depth discussion.

Pete LePage is a Developer Advocate on the Google Chrome team and helps developers create great web applications and mobile web experiences.

Posted by Ashleigh Rentz, Editor Emerita

| 8:00 AM

Google BigQuery new features: bigger, faster, smarter

Author Picture By Felipe Hoffa, Cloud Platform team

Google BigQuery is designed to make it easy to analyze large amounts of data quickly. Today we announced several updates that give BigQuery the ability to handle arbitrarily large result sets, use window functions for advanced analytics, and cache query results. You are also getting new UI features, larger interactive quotas, and a new convenient tiered pricing scheme. In this post we'll dig further into the technical details of these new features.

Large results

BigQuery is able to process terabytes of data, but until today BigQuery could only output up to 128 MB of compressed data per query. Many of you asked for more and from now on BigQuery will be able to output results as large as the largest tables our customers have ever had.

To get this benefit, you should enable the new "--allow_large_results" flag when issuing a query job, and specify a destination table. All results will be saved to the new specified table (or appended, if the table exists). In the updated web UI these options can be found under the new "Enable Options" menu.

With this feature, you can run big transformations on your tables, plus get big subsets of data to further analyze from the new table.

Analytic functions

BigQuery's power is in the ability to interactively run aggregate queries over terabytes of data, but sometimes counts and averages are not enough. That's why BigQuery also lets you calculate quantiles, variance and standard deviation, as well as other advanced functions.

To make BigQuery even more powerful, today we are adding support for window functions (also known as "analytical functions") for ranking, percentiles, and relative row navigation. These new functions give you different ways to rank results, explore distributions and percentiles, and traverse results without the need for a self join.

To introduce these functions with an advanced example, let's use the dataset we collected from the Data Sensing Lab at Google I/O. With the percentile_cont() function it's easy to get the median temperature over each room:

SELECT percentile_cont(0.5) OVER (PARTITION BY room ORDER BY data) AS median, room
FROM [io_sensor_data.moscone_io13]
WHERE sensortype='temperature'

In this example, each original data row shows the median temperature for each room. To visualize it better, it's a good idea to group all results by room with an outer query:

SELECT MAX(median) AS median, room FROM (
  SELECT percentile_cont(0.5) OVER (PARTITION BY room ORDER BY data) AS median, room
  FROM [io_sensor_data.moscone_io13]
  WHERE sensortype='temperature'
)
GROUP BY room

We can add an additional outer query, to rank the rooms according to which one had the coldest median temperature. We'll use one of the new ranking window functions, dense_rank():

SELECT DENSE_RANK() OVER (ORDER BY median) rank, median, room FROM (
  SELECT MAX(median) AS median, room FROM (
    SELECT percentile_cont(0.5) OVER (PARTITION BY room ORDER BY data) AS median, room
    FROM [io_sensor_data.moscone_io13]
    WHERE sensortype='temperature'
  )
  GROUP BY room
)

We've updated the documentation with descriptions and examples for each of the new window functions. Note that they require the OVER() clause, with an optional PARTITION BY and sometimes required ORDER BY arguments. ORDER BY tells the window function what criteria to use to rank items, while PARTITION BY allows you to define multiple groups to be analyzed independently of each other.

The window functions don't work with the big GROUP EACH BY and JOIN EACH BY operators, but they do work with the traditional GROUP BY and JOIN BY. As a reminder, we announced GROUP EACH BY and JOIN EACH BY last March, to allow large join and group operations.

Query caching

BigQuery now remembers values that you've previously computed, saving you time and the cost of recalculating the query. To maintain privacy, queries are cached on a per-user basis. Cached results are only returned for tables that haven't changed since the last query, or for queries that are not dependent on non-deterministic parameters (such as the current time). Reading cached results is free, but each query still counts against the max number of queries per day quota. Query results are kept cached for 24 hours, on a best effort basis. You can disable query caching with the new flag --use_cache in bq, or "useQueryCache" in the API. This feature is also accessible with the new query options on the BigQuery Web UI.

BigQuery Web UI: Query validator, cost estimator, and abandonment

The BigQuery UI gets even better: You'll get instant information while writing a query if its syntax is valid. If the syntax is not valid, you'll know where the error is. If the syntax is valid, the UI will inform you how much the query would cost to run. This feature is also available with the bq tool and API, using the --dry_run flag.

An additional improvement: When running queries on the UI, previously you had to wait until its completion before starting another one. Now you have the option to abandon it, to start working on the next iteration of the query without waiting for the abandoned one.

Pricing updates

Starting in July, BigQuery pricing becomes more affordable for everyone: Data storage costs are going from $0.12/GB/month to $0.08/GB/month. And if you are a high-volume user, you'll soon be able to opt-in for tiered query pricing, for even better value.

Bigger quota

To support larger workloads we're doubling interactive query quotas for all users, from 200GB + 1 concurrent query, to 400 GB of concurrent queries + 2 additional queries of unlimited size.

These updates make BigQuery a faster, smarter, and even more affordable solution for ad hoc analysis of extremely large datasets. We expect they'll help to scale your projects, and we hope you'll share your use cases with us on Google+.


The BigQuery UI features a collection of public datasets for you to use when trying out these new features. To get started, visit our sign-up page and Quick Start guide. You should take a look at our API docs, and ask questions about BigQuery development on Stack Overflow. Finally, don't forget to give us feedback and join the discussion on our Cloud Platform Developers Google+ page.



Felipe Hoffa has recently joined the Cloud Platform team. He'd love to see the world's data accessible for everyone in BigQuery.

Posted by Ashleigh Rentz, Editor Emerita

Wednesday, June 5, 2013 | 9:15 AM

Making Google’s CalDAV and CardDAV APIs available for everyone

Author PhotoBy Piotr Stanczyk, Tech Lead

In March we announced that CalDAV, an open standard for accessing calendar data across the web, would become a partner-only API because it appeared that almost all the API usage was driven by a few large developers. Since that announcement, we received many requests for access to CalDAV, giving us a better understanding of developers’ use cases and causing us to revisit that decision. In response to those requests, we are keeping the CalDAV API public. And in the spirit of openness, today we’re also making CardDAV – an open standard for accessing contact information across the web – available to everyone for the first time.

Both of these APIs are getting other updates as well:

In addition, the CalDAV API now has a new endpoint:
https://apidata.googleusercontent.com/caldav/v2


Piotr Stanczyk is the Tech Lead of the Google Calendar APIs group. His current focus is to provide next generation Calendar APIs which make developers’ lives easier. He also participates in CalConnect consortium.

Posted by Scott Knaster, Editor


Tuesday, June 4, 2013 | 4:00 PM

Hacking for change at Google

Author PictureBy Patrick Copeland, Google.org

Cross-posted with the Google.org Blog

On June 1st and 2nd, thousands of developers from across the U.S. came together at nearly 100 different locations to participate in the first ever National Day of Civic Hacking. Using public data recently released by the government on topics like crime, health and the environment, developers built new applications that help address social challenges.


At the Googleplex in Mountain View, we hosted nearly 100 developers, statisticians, data scientists, and designers, who stayed long into the night hacking together prototypes that show how data on health and the environment can be used to enrich lives. Fusion Tables and Google App Engine were used to prototype, and groups relied on BigQuery as a workhorse to crunch the biggest datasets. Participants used Google+ Hangouts to connect with hackathons in other states and collaborated with Google Apps and platforms.

Here are a few highlights from the hackathon that stood out as useful, visually stunning, and informative ways to use public data:
  • Eat Healthy for Less, the winner of our Mountain View hackathon, is a mobile web application that uses the Consumer Pricing Index to suggest healthy recipes that can be made on a budget.
  • Data+, a reimagining of how we access data, can make exploring public datasets more intuitive and easily understandable for everyone.
  • Detoxic.org is a web experience and Android app that shows you toxic sites and landfills nearby that you might not know about so that you can take civic action against toxic waste.
Many of the ideas have great potential, and we are encouraging participants to continue their work. We hope that the National Day of Civic Hacking will be a catalyst for innovation in this space, and encourage you to keep track of our tools for civic developers at g.co/civicdevelopers.


Congratulations and thanks to everyone who participated!


Patrick Copeland is director of engineering at Google.org, where he works to build systems that leverage Google's reach to help people around the world.

Posted by Scott Knaster, Editor

| 9:00 AM

A classic boardwalk game rolls from your phone to your computer—using only your browser

Author Photo By Pete LePage, Developer Advocate and Boardwalk King

Cross-posted from the Chromium Blog

Last week we launched Roll It, a Chrome Experiment that links phones to computers and gets people out of their chairs and swinging. We wanted to share how we built a physical game experience with no dedicated hardware. It requires just the web, your computer and a phone.

Here’s a look at the APIs and browser-based features we used to create it.


Roll It is a three-dimensional (3D) experience, from the swing of your phone’s accelerometer right up to the virtual models rendered on your computer’s HTML5 Canvas. On the phone side, we hooked into browser events like DeviceOrientation and DeviceMotion to detect the speed and direction of a swing. On the computer side we rendered our scene using Three.js and plugged in Physijs to add physics to the ball and environment.

To sync the phone to the computer we employed WebSockets which enable rapid two-way communication between devices via a central server.

For extra stability we built our backend on Google Cloud Platform:
We couldn’t have brought this experiment to life without a great team. The theme for Roll It was composed by Mr. Tim Healey. Legwork Studio developed the interfaces and game environment, and teamed up with Mode Set for the development.

To dig deeper into the technology behind Roll It, check out the HTML5 Rocks Case Study, or join the team for a Google Developers Live event this Friday, June 7, 2013 at 5pm GMT for an in-depth discussion.


Pete LePage is a Developer Advocate on the Google Chrome team and helps developers create great web applications and mobile web experiences.

Posted by Scott Knaster, Editor

Friday, May 31, 2013 | 12:19 PM

Fridaygram: supporting nonprofits, yawning dogs, Easter egg in space

Scott
Maya
By Maya Amoils, Google.org, and Scott Knaster, Developer Relations

Throughout this month, we’ve asked developers around the world to sign up for Be Mindful in May, a one-month meditation campaign that challenges participants to learn about meditation while simultaneously dedicating their efforts to a global cause: providing clean water to people in developing nations. So far the campaign has raised over $75,000 AUD for this important issue, and the Google Developers team has raised $1700 AUD.

The money raised through Be Mindful in May will go to charity:water, an organization that’s helping to bring clean, safe drinking water to the nearly 1 billion people who struggle every day without it.



To help support nonprofits like charity:water, last month we released the One Today mobile app as a limited pilot in the US. One Today introduces users to new projects each day across a wide range of issues, and enables users to donate $1 to the cause. One Today users can amplify their impact by matching their friends’ donations. If you’re in the US, you can join the One Today pilot by requesting an invite.

From making a difference in the world to wacky science, studies suggest that dogs yawn in response to humans. And not only that: further research shows that sometimes, dogs yawn in empathy with humans yawning, while other times, dogs yawn because they’re feeling stress, as when they’re listening to their owners. Much more research involving yawning dogs and people will be necessary to fully sort this out.

Finally, if you’re previewing the new Google Maps, you might be interested in this cool Easter egg. And if you’re not on the new Google Maps, you can request an invite. It’s really nice, and might even keep you from yawning.


Fridaygrams provide a chance for us to focus on fun and interesting stuff that’s not necessarily related to writing code. Sometimes we even get to feature inspiring content, like this week’s information about helping nonprofits.

Maya Amoils is a member of the Google.org marketing team where she works on a number of the team's charitable giving initiatives. Maya holds a BA in Science Technology & Society from Stanford University. Outside of work, you can find her biking around the Bay Area or making playlists on Spotify.

Scott Knaster is the editor of Google Developers Blog. He likes family time, technology, and watching the San Francisco Giants win baseball games.

Friday, May 24, 2013 | 11:20 AM

Fridaygram: Galapagos images, smart dog, timely entanglement

Author Photo
By Scott Knaster, Google Developers Blog Editor

On Fridaygram we love to celebrate amazing new Street View images. This week we announced new panoramic views of the Galapagos Islands, collected with with the Street View Trekker in partnership with the Charles Darwin Foundation (CDF) and the Galapagos National Parks Directorate (GNPD). These images will go live on Google Maps later this year, but you can see a preview below and on the Official Google Blog.


giant turtle

The Maps team’s 10-day adventure included lots of interaction with local wildlife, but didn’t take place entirely on land. The team worked with the Catlin Seaview Survey to collect underwater ocean images too. And in addition to being beautiful and fun, these pictures have a practical use: they act as a visual record that can be compared to changes observed in the future.

Speaking of wildlife, do you have a smart dog? And does your smart dog know 1000+ words, plus have a basic comprehension of grammar? Meet Chaser, a 9-year-old border collie who has been taught to recognize the names of 1000 objects, as well as the meaning of some verbs and prepositions. In tests, Chaser correctly (most of the time) responded to commands such as “take ball to Frisbee”, or even “to Frisbee take ball”. If only our friends and family were that helpful.

Finally, there’s some typically mind-blowing news from the world of quantum physics. We already know that quantum particles can share a connection called entanglement, which allows one particle to reflect the state of another no matter how far apart they are. Now an experimental discovery shows that particles can be entangled even if they don’t exist at the same time. We agree with experimenter Jeremy O'Brien of the University of Bristol, who said “It’s really cool”.


Fridaygram is about randomly cool and nerdy stories that we hope will amuse you and possibly inspire your weekend. Around here we’re still feeling the Google I/O afterglow, so we’re going to recommend you spend some time this weekend watching some of the many session videos from I/O. If that’s not your thing, maybe you’d like this brief but inspiring video that kicked off the conference.

Friday, May 17, 2013 | 4:30 PM

Google I/O 2013: For the developers

Author PhotoBy Scott Knaster, Google Developers Blog Editor


“Google I/O is an annual developer conference featuring highly technical, in-depth sessions, and showcasing the latest from Google's product teams and partners.”
   – official description


Google I/O 2013 has just ended, and even more than usual, this one was for you, our developers. This year, we focused on providing new tools and services you’ve been asking for, plus a few surprises that we hope inspired and delighted you.




Although we put developer announcements first this year, we didn’t skimp on the cool stuff for everyone: we refreshed the look of the Google+ stream, launched expanded Hangouts, totally revamped Google+ photos, announced Google Play Music All Access, showed off conversational search, and demoed some amazing Chrome Experiments.

Of course, Google I/O isn’t just about announcements. It’s our chance to share what’s new with you in those highly technical, in-depth sessions and for you to meet and interact with our engineers and other Googlers, in person and via the Internet. Once again this year, all sessions were recorded and are being posted to Google Developers Live (GDL) for you to peruse whenever it’s convenient for you.

We love putting on Google I/O, and that’s one reason we created GDL. With GDL, we don’t have to pack all our presentations into a 3-day conference. You’ll find new programs on GDL every week, from the same people who present at Google I/O. Just like during I/O, you can watch live or see recordings whenever you want. You can subscribe to the Google Developers channel on YouTube to be notified when new programs are posted.

Whether you came to San Francisco, participated in I/O Extended, or watched our live streams, we thank you for your attention and dedication. Here’s to Google I/O 2014!

Thursday, May 16, 2013 | 2:51 PM

Get started with App Engine for PHP: scalable, secure and reliable

Author PhotoBy Andrew Jessup, Product Manager

Cross-posted from the Google Cloud Platform Blog

At Google I/O, we announced PHP as the latest supported runtime for Google App Engine in Limited Preview. PHP is one of the world's most popular programming languages, used by developers to power everything from simple web forms to complex enterprise applications.

Now PHP developers can take advantage of the scale, reliability and security features of App Engine. In addition, PHP runs well with other parts of Google Cloud Platform. Let's look at how this works.

Connecting to Google Cloud SQL from App Engine for PHP

Many PHP developers start with MySQL when choosing a database to store critical information, and a wide variety of products and frameworks such as WordPress make extensive use of MySQL’s rich feature set. Google Cloud SQL provides a reliable, managed database service that is MySQL 5.5 compatible and works well with App Engine.

To set up a Cloud SQL database, sign into Google Cloud Console - create a new project, choose Cloud SQL and create a new instance.



After you create the instance, it's automatically associated with your App Engine app.


You will notice Cloud SQL instances don’t need an IP address. Instead they can be accessed via a compound identifier made up of their project name and instance name, such as hello-php-gae:my-cloudsql-instance.

From within PHP, you can access Cloud SQL directly using the standard PHP MySQL libraries - mysql, mysqli or PDO_MySQL. Just specify your Cloud SQL database with its identifier, such as:
<?php

$db = new PDO(
  'mysql:unix_socket=/cloudsql/hello-php-gae:my-cloudsql-instance;dbname=demo_db;charset=utf8',
  'demo_user',
  'demo_password'
);

foreach($db->query('SELECT * FROM users') as $row) {
  echo $row['username'].' '.$row['first_name']; //etc...
}
Methods such as query() work just as you’d expect with any MySQL database. This example uses the popular PDO library, although other libraries such as mysql and mysqli work just as well.

Storing files with PHP and Google Cloud Storage

Reading and writing files is a common task in many PHP projects, whether you are reading stored application state, or generating formatted output (e.g., writing PDF files). The challenge is to find a storage system that is as scalable and secure as Google App Engine itself. Fortunately, we have exactly this in Google Cloud Storage (GCS).

The first step in setting up Google Cloud Storage is to create a bucket:


With the PHP runtime, we’ve implemented native support for GCS. In particular, we’ve made it possible for PHP’s native filesystem functions to read and write to a GCS bucket.

This code writes all prime numbers less than 2000 into a file on GCS:

<?php

$handle = fopen('gs://hello-php-gae-files/prime_numbers.txt','w');

fwrite($handle, "2");
for($i = 3; $i <= 2000; $i = $i + 2) {
  $j = 2;
  while($i % $j != 0) {
    if($j > sqrt($i)) {
      fwrite($handle, ", ".$i);
      break;
    }
    $j++;
  }
}

fclose($handle);
The same fopen() and fwrite() commands are used just as if you were writing to a local file. The difference is we’ve specified a Google Cloud Storage URL instead of a local filepath.

And this code reads the same file back into memory and pulls out the 100th prime number, using file_get_contents():

<?php

$primes = explode(",",
  file_get_contents('gs://hello-php-gae-files/prime_numbers.txt')
);

if(isset($primes[100]))
  echo "The 100th prime number is ".$primes[100];

And more features supported in PHP

Many of our most popular App Engine APIs are now supported in PHP, including our zero-configuration Memcache, Task Queues for asynchronous processing, Users API, Mail API and more. The standard features you’d expect from App Engine, including SSL support, Page Speed Service, versioning and traffic splitting are all available as well.

Open today in Limited Preview

Today we’re making App Engine for PHP available in Limited Preview. Read more about the runtime in our online documentation, download an early developer SDK, and sign up to deploy applications at https://cloud.google.com/appengine/php.


Andrew Jessup is a Product Manager at Google, working on languages and runtimes for Google App Engine.

Posted by Scott Knaster, Editor