A new approach to China

Like many other well-known organisations, we face cyber attacks of varying degrees on a regular basis. In mid-December, we detected a highly sophisticated and targeted attack on our corporate infrastructure originating from China that resulted in the theft of intellectual property from Google. However, it soon became clear that what at first appeared to be solely a security incident--albeit a significant one--was something quite different.

First, this attack was not just on Google. As part of our investigation we have discovered that at least twenty other large companies from a wide range of businesses--including the Internet, finance, technology, media and chemical sectors--have been similarly targeted. We are currently in the process of notifying those companies, and we are also working with the relevant U.S. authorities.

Second, we have evidence to suggest that a primary goal of the attackers was accessing the Gmail accounts of Chinese human rights activists. Based on our investigation to date we believe their attack did not achieve that objective. Only two Gmail accounts appear to have been accessed, and that activity was limited to account information (such as the date the account was created) and subject line, rather than the content of emails themselves.

Third, as part of this investigation but independent of the attack on Google, we have discovered that the accounts of dozens of U.S.-, China- and Europe-based Gmail users who are advocates of human rights in China appear to have been routinely accessed by third parties. These accounts have not been accessed through any security breach at Google, but most likely via phishing scams or malware placed on the users' computers.

We have already used information gained from this attack to make infrastructure and architectural improvements that enhance security for Google and for our users. In terms of individual users, we would advise people to deploy reputable anti-virus and anti-spyware programs on their computers, to install patches for their operating systems and to update their web browsers. Always be cautious when clicking on links appearing in instant messages and emails, or when asked to share personal information like passwords online. You can read more here about our cyber-security recommendations. People wanting to learn more about these kinds of attacks can read this report (PDF) by the U.S.-China Economic and Security Review Commission, as well as a related analysis (PDF) prepared for the Commission, Nart Villeneuve's blog and this presentation on the GhostNet spying incident.

We have taken the unusual step of sharing information about these attacks with a broad audience not just because of the security and human rights implications of what we have unearthed, but also because this information goes to the heart of a much bigger global debate about freedom of speech. In the last two decades, China's economic reform programs and its citizens' entrepreneurial flair have lifted hundreds of millions of Chinese people out of poverty. Indeed, this great nation is at the heart of much economic progress and development in the world today.

We launched Google.cn in January 2006 in the belief that the benefits of increased access to information for people in China and a more open Internet outweighed our discomfort in agreeing to censor some results. At the time we made clear that "we will carefully monitor conditions in China, including new laws and other restrictions on our services. If we determine that we are unable to achieve the objectives outlined we will not hesitate to reconsider our approach to China."

These attacks and the surveillance they have uncovered--combined with the attempts over the past year to further limit free speech on the web--have led us to conclude that we should review the feasibility of our business operations in China. We have decided we are no longer willing to continue censoring our results on Google.cn, and so over the next few weeks we will be discussing with the Chinese government the basis on which we could operate an unfiltered search engine within the law, if at all. We recognise that this may well mean having to shut down Google.cn, and potentially our offices in China.

The decision to review our business operations in China has been incredibly hard, and we know that it will have potentially far-reaching consequences. We want to make clear that this move was driven by our executives in the United States, without the knowledge or involvement of our employees in China who have worked incredibly hard to make Google.cn the success it is today. We are committed to working responsibly to resolve the very difficult issues raised.


Read More Here...

Support Haiti Disaster Relief

Like many of you, we watched in horror as news emerged from Haiti about yesterday's disastrous earthquake. For those of you who publish your blog with Blogger, we built a couple of widgets that make it easy to invite your readers to contribute money to the Red Cross's international disaster relief effort. Pick a size that best fits your sidebar:



After clicking the appropriate button, select which of your blogs you want to add the widget to, then click "Add widget". The Red Cross assures us that 100% of the money raised is going to disaster relief efforts in Haiti — we and they thank you for your support!

Not on Blogger? Be sure to visit the Red Cross's Haiti banners page with banners that you can add manually, or visit Google's page containing information about relief organizations, news and contact info relating to the earthquake.

Read More Here...

Australia's most watched YouTube videos of 2009

Today we announced our first official YouTube most watched lists, a look at 2009 through the videos Australians and people around the world were watching and searching for.

From a singer's debut on the world stage, to newly-weds dancing down the aisle, YouTube has offered people a way to share together in both the big and small moments that touched millions of people around the world this year.

And in addition to global content, some great Aussie-generated content attracted hundreds of thousands of views.

Enjoy!

Most watched YouTube videos in Australia

Top five most watched YouTube videos overall:
Susan Boyle - Singer - Britains Got Talent 2009 (With Lyrics)
I'm On A Boat (ft. T-Pain) - Album Version
Miley Cyrus - The Climb - Official Music Video (HQ)
Miley Cyrus - Party In The U.S.A. - Official Music Video (HD)
Black Eyed Peas "Boom Boom Pow"

Top five most watched Australian-made videos:
Kate Miller-Heidke 'The Last Day On Earth' Official Video
Guy Sebastian - Like it Like That [Official Video]
Jessica Mauboy - Been Waiting [Official Video]
Cassie Davis - Like It Loud [Official Video]
Short Stack - Princess

Top five most watched music videos:
I'm On A Boat (ft. T-Pain) - Album Version
Miley Cyrus - The Climb - Official Music Video (HQ)
Miley Cyrus - Party In The U.S.A. - Official Music Video (HD)
Black Eyed Peas - Boom Boom Pow
Pussycat Dolls - Jai Ho

Top five most watched animal-related videos:
Extreme Sheep LED Art
Bizkit the Sleep Walking Dog
The largest dead snake ever found, over 50 feet.
Piranha Devours a Duck
Slow loris loves getting tickled

Instant celebrities thanks to YouTube:
Susan Boyle - Singer - Britains Got Talent 2009 (With Lyrics)
JK Wedding Entrance Dance
David After Dentist
Greatest freak out ever (ORIGINAL VIDEO)
Inspired Bicycles - Danny MacAskill April 2009

Top five most watched movie trailers:
New Moon Movie Trailer - Official (HD)
Bruno - Official Trailer
Transformers 2: Revenge of the Fallen Official HD Movie Trailer #2 NEW!
'2012' Trailer HD
Paranormal Activity - Official Trailer [HQ HD]

Top five most watched Australian user-generated content:
My Crazy Sister - mychonny
Asian and White Parents - mychonny
Sorry it's been a while - communitychannel
My Victorian Bushfire Campaign - juanmann
Uncomfortable Love Scene - communitychannel

Most watched YouTube videos globally

Susan Boyle - Britain's Got Talent (120+ million views)
David After Dentist (36+ million views)
JK Wedding Entrance Dance (33+ million views)
New Moon Movie Trailer (30+ million views)
Evian Roller Babies (27+ million views)


Read More Here...

Blogger integrates with Amazon Associates

Earlier this year we simplified the process for monetizing your blog by adding a “Monetize” tab in the Blogger app. We started with AdSense, which allows you to add contextual advertising to your pages; more recently we added AdSense for Feeds to help you generate revenue from the distribution of your blog via RSS and Atom. Today we launched a third option: direct integration with Amazon Associates to search Amazon’s product catalog and add links to products that earn you commissions when your readers buy products you recommend.

With this feature, you can search Amazon directly from the Blogger editor and add pictures and links to Amazon products right into your posts. Your readers will earn you commissions whenever they buy the products you recommend, and if you don’t already have an Amazon Associates account, you can sign up for one for free without leaving Blogger.

If you’ve ever written a blog post about a book, recommended a gadget, or reviewed a toy you bought for your kids, you’ve likely gone through the process of drafting the post, opening up a separate window to go to find a site that sells the product, then going back to Blogger to paste the link to the product into the post editor.

Starting today, you can search the Amazon product catalog without leaving the Blogger interface and insert links to the products you find into your posts. Not only is the process of linking to products more efficient, but Amazon makes it easy for you to earn money whenever your readers actually buy the products you write about. This is known as an “affiliate program”, and it’s designed to let you recommend products you like to your audience — if they buy the product, you’ll earn a commission on that purchase. (For more on affiliate programs in general, here is a good overview at ProBlogger from this summer, and Darren’s “11 Lessons Learned” post about Amazon Associates is a good review of how to get the most out of the program.)

To get started, click on the Monetize tab for your blog and click “Amazon Associates”. Walk through the setup wizard, and add the Product Finder once you’re done.



Now for the fun part: when you are writing a post on Blogger, you’ll see an Amazon gadget to the right of your post editor (the “Product Finder”). You can search the Amazon product catalog from within Blogger — type in the name of the product you are writing about, and insert a link to the product, an image of the product, or an iframe containing the image, price details and a “buy it now” button. Every link that’s created contains your unique Associates ID, ensuring that Amazon will credit you for any purchases that result from readers clicking the link on your blog.



If you’re an existing Amazon Associate, completing this setup simply makes the Product Finder available on Blogger for you — you continue to earn the same referral rate from Amazon. New Associates receive the same referral rate from Amazon that they would have received if they signed up directly. If you’re not interested in earning a referral, you can still install the Product Finder: from the “Amazon Associates” page under the Monetize tab, click “I'll do this later — show me more Amazon options” and then click “Add the Product Finder” button.

A quick note about trust: affiliate programs work well when readers trust you. You should avoid promoting products simply because of the referral fee you might earn — readers may lose some of that trust if they sense your posts exist solely to make you money. You may also want to disclose to your readers that you will earn a commission on their purchase — some readers even prefer knowing that you benefit from their business.

There’s more information about this integration at Amazon.com, and the Amazon Associates blog has some more details. This integration is the result of months of collaboration between the engineers at both companies, and we’re very excited to share the results of this collaboration with you. Happy blogging!

Read More Here...

Our views on Mandatory ISP Filtering

At Google we are concerned by the Government's plans to introduce a mandatory filtering regime for Internet Service Providers (ISP) in Australia, the first of its kind amongst western democracies.* Our primary concern is that the scope of content to be filtered is too wide.

We have a bias in favour of people's right to free expression. While we recognise that protecting the free exchange of ideas and information cannot be without some limits, we believe that more information generally means more choice, more freedom and ultimately more power for the individual.

Some limits, like child pornography, are obvious. No Australian wants that to be available – and we agree. Google, like many other Internet companies, has a global, all-product ban against child sexual abuse material and we filter out this content from our search results. But moving to a mandatory ISP filtering regime with a scope that goes well beyond such material is heavy handed and can raise genuine questions about restrictions on access to information.

The recent report by Professors Catharine Lumby, Lelia Green, and John Hartley, Untangling The Net: The Scope of Content Caught By Mandatory Internet Filtering, has found that a wide scope of content could be prohibited under the proposed filtering regime. Refused Classification (or RC) is a broad category of content that includes not just child sexual abuse material but also socially and politically controversial material -- for example, educational content on safer drug use -- as well as the grey realms of material instructing in any crime, including politically controversial crimes such as euthanasia. This type of content may be unpleasant and unpalatable but we believe that government should not have the right to block information which can inform debate of controversial issues.

While the discussion on ISP filtering continues, we should all retain focus on making the Internet safer for people of all ages. Our view is that online safety should focus on user education, user empowerment through technology tools (such as SafeSearch Lock), and cooperation between law enforcement and industry partners. The government has committed to important cybersafety education and engagement programs and yesterday announced additional measures that we welcome.

Exposing politically controversial topics for public debate is vital for democracy. Homosexuality was a crime in Australia until 1976 in ACT, NSW in 1984 and 1997 in Tasmania. Political and social norms change over time and benefit from intense public scrutiny and debate. The openness of the Internet makes this all the more possible and should be protected.

The government has requested comments from interested parties on its proposals for filtering and we encourage everyone to make their views known in this important debate.



Updated: December 16, 2009 at 5:00 PM
* Germany and Italy have mandatory ISP filtering, however in both cases they are of a clearly limited scope. In Germany, the scope is child abuse material and in Italy, it is child abuse material and unlawful gambling sites. Australia's proposed regime would uniquely combine a mandatory framework and a much wider scope of content, the first of its kind in the democratic world.

Read More Here...

Rotgutonix Chemical Sensor let’s you know if your drink is adulterated

Rotgutonix.jpg
Chemical Sensor
Finally we have something really cool to protect us from those notorious freshman days. If you’ve ever made enemies or endeared someone of the opposite sex to a limit of getting them to spike your drink then you need to get hold of the Rotgutonix Chemical Sensor. Make sure that it’s placed in your glass and that you make a careful observation of the readings displayed on its screen. The device will give you detailed information on the contents of your glass and will mark it with crossbones if it feel that it’s been adulterate
I wouldn’t suggest the Rotgutonix Chemical Sensor for those who like adding water to their drink. They’d probably see a lot of crossbones these days.

Read More Here...

What You Need To Know About JavaScript Scope

Understanding scope in programming is key to appreciating how your variables interact with the rest of your code. In some languages, this can be quite straightforward, but JavaScript’s anonymous functions and event handling features, along with a couple of little quirks, mean that handling scope in your applications can become frustrating.

This article discusses how JavaScript handles scope and how various JavaScript libraries provide methods for dealing with it and how they smooth out a few bumps. We’ll also look at how you can get back to basics and do some interesting scope wrangling without a library, a useful approach if you’re writing code that needs to stand alone.

JavaScript Scope

You Are Here

So what is “scope”? We might say that it refers to your current location. If you run some JavaScript like…

view plaincopy to clipboardprint?
  1. var iAmGlobal = 5 * 5;

… then you’re running in the global scope, the big wide world, where you can’t go any further out. For something like…

view plaincopy to clipboardprint?
  1. function doSomething() {
  2. var inner = 5 * 5;
  3. };

… you’re now boxed in by this function, running within its scope. The phrase “boxed in” is appropriate; take a look at this code:

view plaincopy to clipboardprint?
  1. var g = “global”;
  2. function go() {
  3. var l = “local”;
  4. }
  5. go();
  6. alert(l); // throws a reference error

You’ll see that when we run the go function, the l variable is contained within that function’s scope. It cannot be accessed from a higher level scope.

How it Works

As well as variable scope, JavaScript uses the this keyword to get a reference to the current execution context. That rather terrifying term boils down this: at any point in your JavaScript code, you can ask “Help! Where am I?” and get back an object reference. This reference is for the current context, the object that “owns” the currently executing code.

Now, you might think, given what we’ve just learned about scope, the owner of the current code would be the scope in which it is executed. After all, in JavaScript, even functions are objects and can be passed around in variables. But no. Take this function, for instance:

view plaincopy to clipboardprint?
  1. function go() { console.debug(this); }
  2. go();

This gives you a reference to the top-level execution context; in a browser, that’s the browser window itself.

There are a few exceptions to this. For example, if we create a JavaScript object and then call a method on it, then the scope is bound to the object:

view plaincopy to clipboardprint?
  1. var myObject = {
  2. go: function() {
  3. console.debug(this);
  4. }
  5. };
  6. myObject.go(); // console.debugs a reference to myObject

Similarly, when using functions as constructors, you see the same behavior:

view plaincopy to clipboardprint?
  1. function MyClass() {
  2. this.go = function() {
  3. console.debug(this);
  4. }
  5. }

  6. var instance1 = new MyClass();
  7. var instance2 = new MyClass();

  8. instance1.go(); // console.debugs a reference to the MyClass instance1
  9. instance2.go(); // console.debugs a reference to the MyClass instance2

However, notice in this case that the reference is to the individual object instance rather than the class definition, which contrasts with the previous object literal example in which we will always receive a reference to the same object.

With event handlers, things get a little more confusing. If you specify an event handler inline in HTML, then you end up with it referencing the global window object. However, if you use JavaScript to wire your events, then you get a reference to the DOM object that raised it; for example, a click handler on a button would have the button element as the reference.

Event handlers are a common situation in which you would want to bind a function to a different scope; many JavaScript libraries provide features to help do just that. Let’s take a look at some common options.

Libraries

Many developers use JavaScript libraries to avoid having to deal with browser inconsistencies and to take advantage of the many shortcuts they offer. Scope handling is something most libraries give a helping hand with, so let’s take a look at what a few of the major players offer.

Prototype

Prototype comes with a bind method that allows a developer to specify the bound context for a function.

view plaincopy to clipboardprint?
  1. var products = ['Shoes', 'Sweater', 'Jeans', 'Wig'];

  2. function showCount() {
  3. for(var i = 0; i < number; i++) {
  4. document.body.innerHTML += this[i] + ‘. ’;
  5. }
  6. }

  7. var fn = showCount.bind(products);
  8. fn(2); // outputs Shoes. Sweater. to the document

It also supports passing arguments that are “remembered” when you call the function, and these can be used to create shortcut functions; basically a version of a function that defaults to passing in certain arguments:

view plaincopy to clipboardprint?
  1. var showOne = showCount.bind(products, 1);
  2. var showFour = showCount.bind(products, 4);
  3. showOne(); // outputs Shoes.
  4. showFour(); // output Shoes. Sweater. Jeans. Wig.

See Prototype’s Function.curry for more information on this particular aspect of Function.bind. The second useful feature of Prototype’s scope handling is bindAsEventListener. This is very similar to bind but ensures that the first argument passed to the event handler is the event object.

view plaincopy to clipboardprint?
  1. Event.observe(
  2. $(‘showCountButton’),
  3. ‘click’,
  4. showCountHandler.bindAsEventListener(products, 2)
  5. );

Here we’re using Prototype’s event functions to set up an event listener when the showCountButton is clicked. We’re passing our products array as the context, which the function is bound to, but in this case the showCountHandler would look something like this:

view plaincopy to clipboardprint?
  1. function showCountHandler(e, number) {
  2. for(var i = 0; i < number; i++) {
  3. document.body.innerHTML += this[i] + ‘. ’;
  4. }
  5. Event.stop(e);
  6. }

So we have the products array as this, but we also have the e event object automatically passed as the first parameter, which we can later use to stop the default event.

The two Prototype methods for binding context are handy because they’re used in exactly the same way, so you have a very simple and consistent method of taming your context.

Ext JS

Ext JS is farther reaching than either Prototype or MooTools in that it provides a full end-to-end framework for UI and application creation. This means it also provides correspondingly more features to control scope. To compare it with Prototype, let’s look at how to bind to a particular context:

view plaincopy to clipboardprint?
  1. var fn = showCount.createDelegate(products, 4);

This is identical in usage to Prototype’s bind method. But is there a difference when dealing with event handlers?

view plaincopy to clipboardprint?
  1. Ext.get(‘showCountButton’).on(‘click’,
  2. showCountHandler.createDelegate(products, 4)
  3. );

That’s right: there is no difference. Ext JS will normalize the event object into an Ext.EventObject for you and then append your additional arguments after that. However, there are two caveats to this. First, Ext doesn’t just pass the event object to the handler, but also passes the source of the event (in this case, the showCountButton) and any options that were passed to the on method. So, our handler now looks like this:

view plaincopy to clipboardprint?
  1. function showCountHandler(e, source, options, number) {}

However, there is a shortcut to using createDelegate, and it involves understanding the arguments of the on method. We can do this like so:

view plaincopy to clipboardprint?
  1. Ext.get(‘showCountButton’).on(‘click’, showCountHandler, products, { number: 4 });

The third argument of on is the scope under which the handler should run, which eliminates the need to use createDelegate. However, in order to pass further parameters, we have to use the options parameter. So our handler in this case would be:

view plaincopy to clipboardprint?
  1. function showCountHandler(e, source, options) {
  2. number = options.number;
  3. }

This is not quite as elegant on the handler side of things, but it’s useful to know that Ext JS provides a variety of methods for accomplishing similar things, and you can use them accordingly when building your applications.

MooTools

The MooTools library provides two methods that are essentially like replacements for Prototype versions: bind and bindWithEvent, a.k.a. bindAsEventListener. However, on top of these familiar features, it provides a couple more that lend some extra flexibility. My favorite is Function.create:

view plaincopy to clipboardprint?
  1. var fn = showCount.create({
  2. bind: products,
  3. arguments: 4
  4. });

This is nice and succinct, and to turn this into an event handler, we do this:

view plaincopy to clipboardprint?
  1. showCount.create({
  2. bind: products,
  3. arguments: 4,
  4. event: true
  5. });

We can pass additional options, such as delay, which defers the execution of the function by a specified number of milliseconds, and periodical, which fires the function every time the specified interval elapses.

One library conspicuous in its absence is jQuery, which doesn’t offer any context binding facility. But JavaScript does have built-in features that allow you to manage context in many scenarios, and it also provides relatively simple methods of building your own solutions to more complicated problems.

On Your Own

I’m no snob: leveraging the hard work of the great developers who have spent a lot of time on their libraries makes total sense. They will have worked through all of the bugs and edge cases so that you don’t have to. On the other hand, understanding what’s happening on the JavaScript level is important, not only as an academic exercise but also for those occasions when you can’t rely on a library.

Sometimes offering standalone and library-independent scripts is best; for example, if you would like to make your code available publicly and for widespread use. By relying on a library, you restrict the use of the code to people who use that library.

Let’s take a look at how scope and context can be handled without using a library.

Call and Apply

JavaScript functions have two methods available to them that are of particular interest for handling context. Let’s look at call:

view plaincopy to clipboardprint?
  1. showCount.call(products, 4);

Apply is very similar but is used when you don’t know how many arguments you will be passing. It takes an array as its second parameter:

view plaincopy to clipboardprint?
  1. showCount.apply(products, [4]);

Both of these achieve the same goal, but your usage case will determine which would work best for you.

Event Handler Scope

We saw in the explanations of scope how event handlers cause problems, and we also saw how the various JavaScript libraries provide means of getting around this. If you’re stuck with bare-bones JavaScript, then you simply have to write your own means of scoping event handlers, and we’ll look at how to do that now.

Call and apply trigger the function immediately: that’s not what we’re after. Instead, we want to return a new function, which will then be called when the event fires. So:

view plaincopy to clipboardprint?
  1. Function.prototype.bindContext = function() {
  2. // when adding functions using prototype, ”this” is the
  3. // object which the new function was called on
  4. var callingFunction = this;

  5. // pass the desired scope object as the first arg
  6. var scope = arguments[0];

  7. // create a new arguments array with the first arg removed
  8. var otherArgs = [];
  9. for(var i = 1; i < arguments.length; i++){
  10. otherArgs.push(arguments[i]);
  11. }

  12. // return a function remembering to include the event
  13. return function(e) {
  14. // Add the event object to the arguments array
  15. otherArgs.push(e || window.event);
  16. // Array is in the wrong order so flip it
  17. otherArgs.reverse();

  18. // Now use apply to set scope and arguments
  19. callingFunction.apply(scope, otherArgs);
  20. }
  21. }

This is a basic implementation with no error handling, but it provides a useful base to expand on and for understanding the overall approach. Dealing with event handler scope is essential for most JavaScript applications, and no developer should be tied to a single framework, so an appreciation for handling this problem at a low level is useful for every coder.

Conclusion

When building any large JavaScript application, a solid understanding of scope is not only useful but pretty much necessary. While using a common JavaScript library is a useful shortcut, it’s certainly never bad to get back to basics and roll your own solution in order to gain more control of JavaScript scope.


Read More Here...

Blog Archive