Wednesday, May 22, 2013

Parenting

Before I had a child, graduate school was the toughest thing I had ever done. After having a child, graduate school seems trivial.

Parenting is hard. It is relentless: you cannot take a break for a month to recharge. Sometimes, you can't even break for an hour. You have to stay engaged, it takes a lot of energy. Children have vast reserves of curiosity and energy, and they spend all their time exploring and learning. As parents, we have to give them the resources to explore, to engage with the world, and learn as much as they can before they enter it. Small mistakes must be corrected early before they become big ones. And yet, they must be corrected with a gentle voice, with love and with persuasion. All with a child who cannot fully understand you.

And everything gets harder when there are new teeth coming, or when the child falls ill.

The big lesson from parenting is there are few absolutes. There are many styles of parenting, and every child is different. From techniques on sleep-training to meal-time, to potty-training: there is a huge variety of opinion. It helps to see it as just that: opinion. While many people will try to sell their technique as the one true way, realize that their tricks might not work for you. And your trick might not work for them.  If you don't neglect your child, you are probably doing it right. I am not a perfect parent. Nobody is. Everyone starts out being judgmental of parents of poorly behaved children. And then they have kids of their own. Suddenly, others' monsters seem like real angels compared to your own.  The circle is complete...

Parenting tests a relationship like none other. It finds out just how much you love your spouse and how well you resolve conflicts. It is normal to have a conflict every hour. Good parenting requires resolving every issue right away, and giving your child the tools to resolve such a conflict.

While it is difficult, it is the most rewarding experience I have ever had. Every once in a while, your child will do something purely magical. The other day, my son ran up to me yelling, "Kiss Papa", "Kiss Papa", and warmly kissed me on the cheek. Then he ran away, pursuing his next game. Small experiences like these make parenting memorable. Yes, you are sleepless, unwashed and frequently grouchy. But one warm smile from your child, and all the tired nights are worthwhile.


Tuesday, May 21, 2013

Google IO 2013

I attended Google IO this year. It was an amazing experience. I met a friend I hadn't been in touch with for a decade! I met some old friends from UC Santa Barbara and Google.  This is Google IO, so I met a lot of new developers who have excellent Android applications.  The momentum behind Android was breathtaking: development is now mature, developers had very specific questions and they had a great idea of what users wanted.

Scott Kennedy and I gave a talk about the Android application development best practices, using Gmail and Email as an example. The talk was well received, with engaging questions afterwards in the Android booth, and laughs during the talk.

I was struck by how much work is involved in a Google IO talk. Veteran speakers agreed that preparing a Google IO talk takes a lot of time, even for them. Scott and I must have rehearsed the talk well over a dozen times. A few people from my team saw one of the early rehearsals and mentioned that the talk had become a lot better over time. Now that we work so well together, Scott and I are wondering if we should do another talk next year.


Sunday, April 07, 2013

Simple computer program for one year olds

Kids love to use the same things that their parents are using. Rather than buying them toy versions of objects, we use these opportunities to teach them the correct way to use everyday objects.

My son loves to see us use the computer, and wants to use a computer too. So we bought a real adult keyboard at an electronic store, and attached it to a real computer running Linux. The only thing he can do is hit a key and see the computer's reaction.  In most programs, this produces no visible result.

So I wrote a very simple program in Python using Gtk to display a single character from the keyboard in a huge font. This is what the computer looks like when it is running this program:


Lots of advantages to this approach:
  1. The child uses a "real" keyboard and a real computer, something that parents use too.
  2. There is no way to exit, except to Alt-Tab to switch programs.
  3. The child can be rough with the spare keyboard, you just buy a new one.
  4. The computer can be disconnected from the Internet, and put on a spare child account if required.
  5. The program should work on Windows and Mac as well, after you set up Python + Gtk.
The entire program is listed here:
#!/usr/bin/python

import gtk, string, pango

class BigChar():
    """ Create a Gtk window for a single giant textview that accepts all keyboard input. """
    def on_key_press(self, widget, data=None):
        """ Intercept all keypress events and show ascii
            characters. This requires the CAPS_LOCK to be off.  We
            don't intercept CAPS NUM or SCROLL lock, probably
            should."""
        ascii_value = data.keyval
        if (ascii_value >= 97 and ascii_value <= 122):
            self.textBuffer.set_text(string.ascii_uppercase[ascii_value-97])
            start = self.textBuffer.get_start_iter()
            end = self.textBuffer.get_end_iter()
            self.textBuffer.apply_tag_by_name("real_big", start, end)

    def __init__(self):
        """ Create a window with a single giant text view. Disables all chrome.
        """
        self.w = gtk.Window(gtk.WINDOW_TOPLEVEL)
        # No border
        self.w.set_border_width(0)
        self.w.realize()
        # Take over the entire screen
        self.w.fullscreen()

        # Connect the callback on_key_press to the signal key_press.
        self.w.connect("key_press_event", self.on_key_press)
        # Make the widget aware of the signal to catch.
        self.w.set_events(gtk.gdk.KEY_PRESS_MASK)

        # Add a text view to show the key pressed
        self.textView = gtk.TextView()
        # Disable a cursor in the text view.
        self.textView.set_editable(False)
        self.textView.set_can_focus(False)
        # Show the single character in the middle
        self.textView.set_justification(gtk.JUSTIFY_CENTER)
        # This is the place we will write the character to
        self.textBuffer = self.textView.get_buffer()
        # Make the text view huge, blue on white
        fontdesc = pango.FontDescription("monospace 512")
        self.textView.modify_font(fontdesc)
        tag = self.textBuffer.create_tag("real_big", background="white", foreground="red")

        # Make the text view take the entire window
        self.hbox = gtk.HBox(homogeneous=False, spacing=0)
        self.hbox.pack_start(self.textView, expand=True, fill=True)
        self.w.add(self.hbox)

    def show(self):
        """ Show the window"""
        self.w.show_all()


if __name__ == '__main__':
    # Create a bigchar window, and show it.
    bigchar = BigChar()
    bigchar.show()
    gtk.main()



Tuesday, March 19, 2013

Sound Sleep: Free application for Android

Frustrated by existing sleep-time applications, I wrote a simple application to play music on an Android phone. The application is called Sound Sleep and it is available for free on the Play Store.

To use the application, create a subdirectory called "sleeping" under the "music" directory in the SD-card or external storage. Put night-time sleep music in this subdirectory. Many music file formats (mp3, ogg, ...) are supported. All directory names are case insensitive.

Start the application. The top half of the screen starts and stops night-time music.

The bottom half starts/stops white noise.


Since the application allows tapping anywhere, it is perfect for clumsy night-time use. It works on all Android devices starting with version 1.5, so give it a try!

Monday, February 25, 2013

Adding photography grid lines in GIMP

In photography, the "Rule of thirds" suggests places for optimal visual interest. You divide the photo into nine equal parts, like a tic-tac-toe board. The rule says that the most important visual elements must be at the dividing lines, or along the lines of the tic-tac-toe. This is an easy rule, and helps to determine how best to crop an image, or to judge a composition.

GIMP, the free image editor, allows the user to create guide lines. These are lines shown for reference while editing an image. They do not modify the underlying image, and can be dragged out from the ruler or created using a menu item. Gimp also allows certain edits to stick to guide lines. This is useful if you are adding text, or adding layers as it makes it easy to align visual elements in an appealing manner.

I find it helpful to create rule of thirds guide lines to evaluate photographs. Rather than manually drag out guide lines, I have written a GIMP script to automatically create such rule-of-thirds guide lines. This is what the result looks like.


To use, download the rule-of-thirds script and copy it to your local scripts directory. On my machine, this is $HOME/.gimp-2.6/scripts. The exact location depends on your platform (Windows/Linux/Mac) and Gimp version. You can find out the exact location by going to [Menu] -> Edit -> Preferences -> Folders -> Scripts.

Now start gimp and navigate to [Menu] -> Filters -> Script-Fu -> Refresh scripts.

Once it is refreshed, the rule of thirds guide lines should be available under [Menu] -> Images -> Guides -> Photography.


Tuesday, February 12, 2013

Customers want control over their mobile device

Disclaimer: I'm a Google employee.

"The average consumer doesn't care about whether their mobile device is locked down"

I've heard this argument very often. However, the data just doesn't support it. Over the last week, the hacker group evasi0n released a program to jailbreak an iOS device. iOS devices (iPhones and iPads) are closed down: Apple chooses which programs can be installed by device owners. A jailbreak removes this restriction, and allows the device owner to install any program of their choice on their device.

The initial justification for such unprecedented control was that the phone network could not handle poorly written applications. This argument was bogus even when the iPhone came out. At that time, arbitrary applications could be executed on existing phones. Palm Treo and Blackberry both allowed the device owner to choose which applications to run. Not all applications were passed through careful scrutiny: the device owner could write his own application and run it on the device. With the advent of Android, this argument is even more hollow. Google sells Android devices on which the user can not just install any application, but also install any system software.

Other justifications claim that users want a third-party to control their experience and are willing to submit control of their own devices. The data suggests otherwise. The hack by evasi0n was downloaded by four million unique devices in just five days. We don't have any concrete numbers for iOS 6.x devices, but let's try to use people's estimates to arrive at how significant the five million figure is.

Apple announced the number of iOS devices in October 2011: 250 Million.
Rough numbers for devices runing iOS version 6.x: 100 Million.

So 5% of the total user base chose to jailbreak their device within the first four days. There are lots of caveats: the figures are all guess-work (the fact that the numbers are nice round figures should also make you suspicious). We don't know the exact number of 6.x devices, and Jay Freeman, the creator of Cydia, admits that many jailbreakers weren't counted because the jailbreak servers crumbled under the heavy load.

Even so, 5% of the users want control over their own device. And that's within a week of the jailbreak being available. A very conservative estimate is that another 5 million users jailbreak their device. So 10% of the users choose to control their own device. (This is again a rough guess, since total iOS version 6.x devices is a moving target.)

Keep in mind that the entire idea of a jailbreak is somewhat scary. I suspect most users would hesitate to download a program from an unknown website and run it on a costly phone or tablet. Put another way, the number of users who want to jailbreak their device is larger than the ones that do perform the jailbreak.

When one in ten of your users wants something, it isn't a fringe phenomenon anymore. They are sending you a strong message: that they want control over their own device.