Lazy Hacker Babble

Just some random babblings from a lazy hacker…

Archive for the 'Web' Category

Chrome OSX with Bookmark Manager

Posted by hsin on 15th January 2010

The latest dev channel build of Google Chrome now have a basic bookmark manager and cookie manager.

With a bookmark manager, even though it is very basic, Chrome for OS X has the basic set of features that I feel makes up a browser and might can make Chrome my default browser on OS X soon.

Posted in Google, OSX, Software | No Comments »

Android 2.1 SDK released

Posted by hsin on 12th January 2010

For those who has been asking for the 2.1 SDK since the Nexus One launch, the new SDK can be downloaded here: http://developer.android.com/sdk/android-2.1.html

Posted in Google, Programming | No Comments »

Google APIs

Posted by hsin on 5th January 2010

“Eat your own dog food” is not an uncommon term in Silicon Valley. It means for a company to use the product they built themselves. If a company offers an email product to customers then they should also be using that same email product. It’s not always easy to eat one’s own dog food especially when that dog food provide a critical business functionality or is fairly new. Email, for example, has become vital for companies and they depend on it to be scalable, stable and reliable, but if you’re eating your own dog food you might be using the pre-production version which might not be 100% stable or it’s missing some functionality and which you need to build yourself. Because of this, even though many tech company talk about eating their own dog food, but don’t really pull it off.

I find Google to be very serious about eating their own dog food. Everything released to the public is also used internally and this includes their APIs. Often companies release APIs but don’t use them internally because they have direct access to the underlying technologies. Google does use their own APIs and during my first two months here, I’ve been learning a lot of the APIs in order to do my work. There are some amazing stuff out there and they are all listed at code.google.com.

Specifically, I’ve been learning the Google Data APIs. There is an amazing amount of access to APIs to allow developers to build sophisticated applications so I encourage everyone to try them out!

Posted in Google, Programming | No Comments »

Programmatically authenticating to Google App Engine with Python

Posted by hsin on 11th December 2009

Even before joining Google, I was already a fan of two of its services: Google App Engine and Google Apps for Domains. Apps itself brings a lot of value and combined with app engine, it’s especially powerful for small business and start-ups. Apps provides the most essential IT pieces for a business (email, office suite, calendaring) and Google App Engine (GAE) allows the business to build their own software on Google’s infrastructure without the heavy initial investment in hardware and IT infrastructure. This post focuses on just GAE specifically how you can programmatically access app engine from a python script.

The code to authenticate against the production instance of GAE is actually fairly well documented by Google on the GAE site. The issue I ran into is that before I push my code live, I wanted to test it on a development instance. GAE makes setting up a development server easy and comes with its own web server and datastore (database), but the one area where the development environment is different from production is how authentication is handled. The development server doesn’t do real authentication. It just sets the right cookie that simulate that you’ve already logged in. I wanted to write my code with minimal differences between how it calls production and how it calls the localhost. Authentication to your application on production means that you need to get a token from the Google servers, but this doesn’t exists on the dev environment. Looking at how the developer instance handled the login screen, I was able to do the following:

#!/usr/bin/python

import cookielib
import urllib
import urllib2

# Setup to be able to get the needed cookies that GAE returns
cookiejar = cookielib.CookieJar()
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cookiejar))
urllib2.install_opener(opener)

# Set ‘prod’ based on how your system determines whether to connect to prod or localhost.
if prod:
   # This is the setup to construct the login URL for authentication on prod.
   authreq_data = urllib.urlencode({‘Email’: ‘<login_email_address>’,
                                     ‘Passwd’: ‘<login_password>’,
                                     ’service’: ‘ah’,
                                     ’source’: ‘<your_app_name>’,
                                     ‘accountType’: ‘HOSTED_OR_GOOGLE’})

    # Authentication server
    token_uri = ‘https://www.google.com/accounts/ClientLogin’

    # This is where you want to go after log in.  Replace:
    target_uri = ‘http://auth_example.appspot.com/home’
    ## Get an AuthToken from Google Accounts
    auth_req = urllib2.Request(token_uri, data=authreq_data)
    auth_resp = opener.open(auth_req)
    auth_resp_body = auth_resp.read()
    auth_resp_dict = dict(x.split(‘=’)
                          for x in auth_resp_body.split(\n) if x)
    authtoken = auth_resp_dict[‘Auth’]

    authreq_data = urllib.urlencode({‘continue’: target_uri,
                                     ‘auth’: authtoken})
    login_uri = (‘http://<location_of_prod_GAE>/_ah/login?%s’
                 % authreq_data)
else:  # authenticate against the local dev server
    target_uri = ‘http://localhost:8080/home’
    authreq_data = urllib.urlencode({‘email’: ‘test@example.com’,
                                     ‘continue’: target_uri,
                                     ‘action’: ‘Login’})
    login_uri = (‘http://localhost:8080/_ah/login?%s’ % authreq_data)

# Okay, we’re done at this point with the difference.  From this point everything else
# should be the same for either prod or dev.

# Do the actual login and getting cookies.
serv_req = urllib2.Request(login_uri)
opener.open(serv_req)

# Rest of code here.
 

That all there is to it!

Posted in Google, Programming | 2 Comments »

Moving on from Yahoo.

Posted by hsin on 30th October 2009

Well, the time has come for me to say goodbye to Yahoo! There are definitely some things I’ll miss, but it is time to move on. I had a great experience here and learned a helluva lot. Now I’m looking forward to applying those skills I’ve developed at my next job. I’m not going far. Just up to the street to Google.

Posted in Google, Yahoo | 1 Comment »

Google Update open source

Posted by hsin on 2nd July 2009

Couldn’t remember if I wrote this, but awhile back Google open source’d its software update engine, Google Updates. The project name is Omaha.

The OSX update engine is a subset of this project.

Posted in Google, Programming | No Comments »

Firefox 3.5 icon with version number

Posted by hsin on 1st July 2009

firefox

Download the image here.

Firefox 3.5 is out and since those of us working on the web usually have multiple versions of the browser installed, having an icon with the version number on it makes it easier to identify the instance we’re loading.

This is inspired by http://browserversionicons.com/firefox/

With the icon from Mozilla.

Instructions for running multiple instances of Firefox are here.

Posted in Firefox, Programming, Web | No Comments »

Google Apps for Business

Posted by hsin on 9th June 2009

I’ve been using Google Apps for Domains (don’t confuse it with just apps I.e. Docs) and it is excellent. It is a great solution for small businesses or start-ups especially those with limited IT budgets.

Recently Google added support with Blackberry and with today’s announcement that they are adding Outlook sync, the barriers to business adoption continue to fall.

Posted in Google, Software, Web | No Comments »

G1 Android

Posted by hsin on 24th May 2009

I’ve done an unsual amount of traveling (for me) this past month. I spent two weeks in Taiwan and after returning to the states for a week I traveled to Seattle. These trips allowed me to test my travel gears including the Android G1 phone and the iPhone.

I have had the G1 for awhile but no phone service for it. Since it is unlocked I decided to get a SIM card for it in Taiwan and use it while I was there. Getting and installing the card was super simple and I did it at a 7-11 store. It was a matter of putting the card in and turning it on.

As a phone device I found it to be excellent. Sound was clear and it was easy to use. The screen was sharp and overall responsive. One annoyance was that it accidentally dial too easily unless you lock the touch screen. The other annoyance was that the contact list was not easy to navigate and search. I am not sure why Google struggles with contacts on both its site and the phone.

The camera on the G1 is super especially compared to the iPhone. With 3MP and autofocus, it is a real camera. Its excellent intergration with Google means that it can hold its own as a PIM. Add to it the wifi and browser capabilities and you have a nice portable computer that fits into your pocket. For traveling, the G1 is very well suited.

The screen can be a bit larger as it’s current size limits its use as a portable dock reader. The UI of its apps are not as uniform, and Android is not as polished as the iPhone. Its marketplace needs to be improved so more apps get built. Battery life is short and needs improvement for it to be a true road warrior.

The experience of using the G1 vs IPhone is like using a PC vs Mac. The advantage of a open platfom is variety but initially a less polished user experience.

Posted in Gadgets, Google | No Comments »

3 pixels vs 4 pixels

Posted by hsin on 21st March 2009

Doug Bowman’s post on leaving Google had a quote that has gotten picked up by many bloggers as representative of what is wrong with the engineering culture:

“I had a recent debate over whether a border should be 3, 4 or 5 pixels wide, and was asked to prove my case.”

He doesn’t give much more context about this debate, but it reminded me of some of my own experiences where I got involved with almost the exact same debate. In my case, the cause of the debate was almost always because there were multiple designers. Either it was two more more designers arguing about the width or it was after a product launch that the next designer decide that the width decision should be thrown out.

What drove engineers nuts was that because decisions are so arbitrary anyone can override the design at any time. Maybe Google is on the extreme end to demand numerical metrics to back up any decision, but for most engineers it was mainly that they wanted to understand the reasoning for a change. Otherwise, engineers would spend their entire lives changing the size of borders.

Posted in Google, Main, Programming, Web | No Comments »