Monday, November 29, 2010

Youtube ETA - Chrome extension

If you have ever tried to watch a youtube video on a slow network connection, you will know the frustration I often face. Wondering when that red progress bar will reach its end. Thanks to a chrome extension like Stop Autoplay, I can let the youtube video open in background tab and let it buffer as I browse other webpages. But still I have to go back to the youtube video's tab to find out if the video is downloaded, can I start watching it?

So I always wished someone had written an extension which will do something about this problem. After going through 3-4 pages of search results on chrome extension website with the query 'Youtube', I figured no such extension exists. This weekend, the itch became unbearable. So I peeked into the Stop Autoplay's short code and with some searching found out there exists a Javascript API to control the youtube player's behavior. It provided the API calls that were sufficient for me to calculate the speed (in bytes-per-sec) at which youtube video is downloading. Combine that with total size and total duration of the video and I had the solution I was looking for.

So I decided to write an extension out of it. You can get it from here

It does following things:
  1. Pauses the video at the start, i.e. disables the autoplay
  2. It calculates an estimated time it would take to download the video completely. Shows it in a red box in the top left corner.
  3. It also prepends a short version of this estimated time to the title of page. So even if you are browsing in other tabs or windows, you can tell how much longer it is going to take, without visiting the youtube page.
  4. There is an instant of time, when the video is not yet downloaded completely, but if you start watching the video after that point, you can be assured that the entire video will be downloaded by the time you reach the end. That way it is guaranteed that you won't have any interruption while watching the video. The extension smartly calculates that instant and informs you by turning the red box into orange. It also adds '*' to the timestamp in title after this point.
Give it a shot. The extension won't yet work with HTML5 player, I will fix that soon though.

Monday, November 15, 2010

Why secure airports when it's planes that fly?

With all the debate going over TSA's naked scanners and intimate pat-downs, I think one simple question is being totally ignored.

Why secure the entire airport when it's only the planes that fly in the sky. The reason we need added security for air travel is their unique vulnerability as compared to other forms of transport. An accident or attack in mid-air can lead to nearly 100% fatality. Also planes can be used as weapons in even more significant disasters as demonstrated by 9/11. So the objective of securing air travel should be to keep the flying objects safe. Anything and anyone that boards the airliner should be thoroughly checked. But why secure the entire airport?

Airport is tens of square miles of area with hundreds of access points. To try to secure this entire area is to make the task at hand enormously difficult than it has to be. There is nothing more special about an airport than is about Grand central railway station. A terrorist group is not going to achieve anything more significant by blasting a bomb at airport gate than he would by blasting it on a railway platform. Consequently, security of airport can be as tight (or loose) as that of a railway station. All the extra vigilance however should be concentrated at the gates where passengers and crew board the airplane - the real vulnerable entity that needs protection.

It is a matter of common sense that smaller the area to protect, more effectively it can be done. Why not apply that to air travel security?

Moreover, securing entire airport varies from country to country. Flights fly to US from all over the world, in multiple hops. Securing the safety of a flight bound to US, then depends on securing the boundaries of all the airports where the flight was boarded. Imagine how behemoth that task is and how easy to breach. Establishing the checks at the doors of the actual plane simplifies that problem by magnitudes.

Friday, October 29, 2010

Mac book red light audio jack problem on Linux

When I upgraded my Macbook (2,1) to Ubunut 10.10 last week, I realized after a while that it wouldn't play any audio through the audio jack. The built-in speakers were working well, but as soon as I plugged in the headphone the built-in speakers would go off (as expected) and the headphone would be quiet too.

Then I got little concerned when I saw the red glow coming out of the audio jack. This macbook is now 4 years old, so I assumed the red light means some malfunction. But after I searched around, I found it was a known issue. The red light wasn't any indicator, but optical audio output. Many mac forums had discussions on this topic. Most of them fixed it by sticking a pin or toothpick into the jack, juggling around a little or shorting some internal probes. They reported that this eventually turns the light off and audio out was switched back to traditional wired output. I tried the same, but no luck. In retrospect, those all posts were with Mac OSX installed. So in their case, the optical audio output was probably turned on in hardware and had no way to turn off in software. Whatever the case, their solution didn't work on my Ubuntu installation.

I figured that, the optical audio output was not turned on in hardware, because when I rebooted the laptop in Mac OSX the red light used to go off and headphones worked. So now it remained to find some software tweak to fix the problem. Eventually I found this thread on ubuntu forums. Following two commands fixed the problem.

# Turns off the optical audio out
amixer set IEC958 off

# Turns on the headphone speakers
amixer set Speaker,1 on

# In case you want to tweak built-in speakers
amixer set Speaker,0 on

If your system is different than mine, it will help to run amixer without any options and see the list of audio channels and their states it prints out.

Hope this trick helps someone.

Ads:

Thursday, October 28, 2010

How to save HTML5 canvas image to Google App Engine

This is a very specific problem and not many would have it. But I had to implement it and came up with a solution that works for me. This is how I did it for 3DTin.

First why it's specific. In a typical case a web app wants to save user submitted images to Google app engine data store. This can be simply done by presenting user with a form and adding an 'input' tag with type 'file'. The submitted image can be extracted in GAE using request.get() and packaged into db.Blob to eventually store into BlobProperty. I am not going to explain this typical case, because it's covered nicely in the GAE's documentation. However, the process is not as straightforward when the image you want to store is not an image file on user's computer, but a dump of HTML5 canvas element in the web app.

An HTML5 canvas element lets you export its content as jpeg or png image with the toDataURL API. This function returns a data URL that contains base64 encoded jpeg/png image. So how do we convert this image data into GAE's db.Blob object?

The solution is to send the base64 encoded data as POST param to GAE app, do some regex matching to extract the exact portion of the data URL that is the encoded image and pass it through the base64 decoder (which is part of standard python library).

Here is client side:


Here is server side code:


Code is also accessible as gist here, in case you can't see the embedded version above.

This code works in 3DTin where a thumbnail of user's canvas is sent to GAE app for storage. It works without problem.

Ads:

Tuesday, October 05, 2010

Silicon Valley and Hi-tech

I grew up with a dream of doing something in the "Hi-tech" industry. Back then I imagined it will be some breakthrough scientific work like inventing a perpetual energy machine or engineering a space elevator... something that will fall under the category of rocket science.

They say Silicon valley "is home to many of the world's largest technology companies". No doubt, any young technologist like me had his eyes set on Silicon Valley. So when I compare the nature of today's so-called "hi-tech" hot companies, namely Facebook, Twitter... I can't help but wonder where is the Science and Technology in them?

This morning I read Sarah Lacy's Techcrunch article "Silicon Valley at a Cross Roads: Entertainment or Science?" and it all made sense.

She put into the words the very question that lingered in my mind.
Will it [Silicon Valley] follow the Web 2.0 path further down the road of media and entertainment or go back to its roots of hardcore science and technology?
According to her the valley made a choice between real hi-tech and Web 2.0 (that would lead to media innovation), back in early 2000s.

But in the early 2000s, the Valley was at a crossroads. Was the future cleantech or Web 2.0? Put another way, was the future starting a new stack or continuing to iterate on top of the mostly-built out one? The cleantech camp was championed by a lot of top Valley names– most famously John Doerr– who saw it as the most important way to change the world and an undeniably huge market that required real innovation. The Web 2.0 camp was championed largely by the PayPal Mafia’s angel investors like Reid Hoffman and Peter Thiel, and a handful of other angels and mentors like Marc Andreessen. Many of them prized the fact that Web companies were the opposite of cleantech: Thanks to decades of technology build out they were cheap and low-tech to start, utterly changing everything about these companies from the size of the exit you needed to have a good return to how quickly you could know if you had something or not.
Ultimately, Web 2.0 won the Valley’s heart and hype....
She then makes a logical guess about future that the valley will continue down "a path where San Francisco becomes the center of Web media, the way New York was the center of news media and LA was the center for entertainment media. These businesses are easier to understand, quicker to evaluate and more likely to produce a series of newsy blog posts"

I have to say, her post brought a moment of clarity to me this morning. You should read the entire article. Few people have the ability to observe a big industry over a long period of time and make sense about where it came from and where it is leading. Sarah Lacy is one of them.

My understanding and my hope is that even though Silicon Valley takes the route of a media industry, their will be "real" hi-tech innovation somewhere in the world. I feel confident about it when I read about Elon Musk's Tesla and SpaceX, Richard Branson's Virgin Galactic, or the Mega Machines episodes on Discovery channel that show behemoth engineering projects in China, Japan, S Korea. I also find promise in the grassroot culture of "Makers" that is taking shape in the form of Maker faire and the new industry of personal manufacturing that is evolving in the form of 3D printing. Hopefully we will build on top of the Web infrastructure that Silicon Valley provides and the true hi-tech innovation will take place in this virtual world and not in a specific physical valley.

Wednesday, July 07, 2010

Indirect experiments

I like how some advanced experiments in science are fantastically indirect. Take for example this experiment of measuring mass of proton (source).

For each hydrogen atom, the team replaced the atom's electron with a particle called a muon, which is 200 times more massive than an electron.
"Because the muon is so much heavier, it orbits very close to the proton, so it is sensitive to the proton's size," said team member Aldo Antognini, of the Paul-Scherrer Institute in Switzerland.
Muons are unstable, and they decay into other particles in just 2.2 microseconds. The team knew that firing a laser at the atom before the muon decays should excite the muon, causing it to move to a higher energy level—a higher orbit around the proton. The muon should then release the extra energy as x-rays and move to a lower energy level.
The distance between these energy levels is determined by the size of the proton, which in turn dictates the frequency of the emitted x-rays.
But based on the accepted proton radius, the experiment failed to produce x-rays at the anticipated frequency.

Saturday, July 03, 2010

ReaderScope 2.0.6 - Find Comments

If you didn't notice, in recent releases the Digg and Reddit social beacons were missing. They were removed some time ago to make space for a better method of discovering comments. I had released a stand-alone app FindComments few weeks ago. It uses ContextVoice to find comments from all sources (Twitter, Digg, Reddit, and many more). In v2.0.6 that app is integrated with ReaderScope. You will see a new icon on the action panel, which you can tap to find comments on the current news item from all over the web.


Try it on some popular news stories from Slashdot or XKCD to see how it works.

Monday, June 07, 2010

ReaderScope 2.0

ReaderScope 2.0 is out in the Market today.

As explained in last post, the rules of free have changed in this version. Instead of giving a crippled version for unlimited time at no cost; now ReaderScope will be available in its full glory but for limited time - 5 days. After that you can buy the Value Pack for $2.49 and unlock the expired version.





Enjoy!

Wednesday, June 02, 2010

ReaderScope upcoming changes

Last weekend I released ReaderScope 1.9.8. It has some changes that should fix crashes that some users have reported in comments at Android market. These crashes went unnoticed for such a long time, because I didn't see them myself during my testing and they were not captured by the built-in crash reporting mechanism. But I found about them last week, thanks to Android market's new crash report collection mechanism. One frequent crash was happening in the background download service and it wasn't captured by RS's crash handler. It should be fixed in v1.9.8. So thumbs up to Android team for adding this new facility to Market.

But this post is mainly about what's coming next. For starters, the version number will now graduate to 2.x. And then there will be a key change in the way free version of ReaderScope works.

Right now you can download ReaderScope from various market places for FREE. It has the basic look, with what is known as Legacy color scheme. It has Ads below the news screen. It has a handy widget, but it cannot be refreshed unless the app is unlocked with Value pack. The value pack is available for $2.49. Once you buy it and enter the unlock code, you get full access to 3 additional themes, no Ads, fully functional widget and ability to see favicons against your feeds.

Starting with 2.x, you will be able to access the full functionality of ReaderScope right out of the box, when you install the free app from any market place. The default color scheme will be changed from Legacy to Night (which so far I've heard is most popular), but you can change to others if you want. There will be no ads. You will have fully functional widget (If you are like me, you will read half of your news via the widget). The favicons will be visible.


So what's the catch? The free version will expire in 5 days. You can buy the Value pack for $2.49 and unlock it.

In addition, support for Android 1.5 will be dropped.

Why this change?

There are couple of reasons.

1. The default (legacy) color scheme is super dull. And yet, that's the first impression users get when they download the free app. I have read many users complaining about the "awful" UI of ReaderScope, and I believe part of it is the dull color scheme. So even though some pretty color schemes are hidden in the app, users don't know about them until they dig down 2 layers of settings and see the theme previews.

2. The admob code can make the UI sluggish on slow networks. When the app starts, the admob jar downloads an Ad over network. So if the network is slow, this request can sometimes add to the startup time of the app. And the worse part is, it happens even when you have unlocked the app. With the unlocked app, you won't see the ads, but I don't have control over admob code and make it stop fetch that one ad at startup. With 2.x, admob jar will be completely removed.

3. Dropping support for 1.5 had to be done someday. Only after that features from 1.6+ SDKs could be used. I hope, the users stuck with 1.5 will soon get updated by their carriers (or they will start using cyanogen like me ;).

The 2.x version will make no difference to users who have already bought the value pack, they will keep getting updates as usual. Others who have been using the app without the Value pack, will see a 5 day expiration notice upon upgrade. They will need to buy the value pack within that time.

However, if you are happy with the way free ReaderScope is right now, you will have an option. You will find v1.9.8 apk available for download here. Obviously, it won't get any fixes/features, but the app is quite stable as it is today and you can use it for free if you want. However if you want ongoing fixes and features, you will have to upgrade to 2.x and buy a value pack within 5 days.

First 2.x release should hit the market around next week. Till then please, let me know your feedback on this change.

Tuesday, April 27, 2010

Mutt, Gmail, gdata, notify-send: A Perfect Email solution

Ever since I started working on my own, GMail has become my primary email account. I was mostly satisfied with the default web interface. However, the heavy javascript interface takes eternity to load on my slow network. The basic HTML interface is slim but doesn't have keyboard shortcuts, so it's useless. Moreover recently I found the GMail tab hogging most amount of memory in Chrome task manager. That gave me the final push to switch to a local email client.

I have used Thunderbird and Evolution in the past, but they are not light weight by any means. I had tried Mutt before, but left it because I didn't get hang of all its shortcuts. Nonetheless I decided to give Mutt another try.

Here are my basic requirements from the email setup:
1. Light weight - Should launch quickly when I want to check the mail. Should do only the bare minimum network I/O required to fetch new messages.
2. Notifications - Should check the mailbox at regular intervals and notify me using desktop's default notification system.
3. Access to GMail contacts
4. Ability to Archive messages or move them to other GMail folders.

So far I have figured out how to do all of the above and then some. So here are my solutions numbered same as corresponding requirements above.

1. Setting up GMail IMAP has become significantly easy. All you have to do it create a .muttrc file in your home directory and start mutt. A simple google search will tell you what to put in that file. As you kick off mutt from command line, it will fetch the contents of your gmail inbox seamlessly (except if you've skipped the password in .muttrc, then it will ask you to enter it).

2. Mutt does not support notifications. Apparently it doesn't fit into the design philosophy of its developers. But a brave soul has created a patch if you are interested in building your custom mutt. As for me, I didn't go that route. I setup an alternate script that uses GMail's gdata interface to check the new messages and delievers the alerts using notify-send (on my linux box) or growlnotify (on my Mac OSX). I took a simple script from here and added my modifications. You can get my version here. It reads the username and password from your .muttrc files. It does some rudimentary checks to find if it's on Linux or Mac OSX and accordingly calls notify-send or growlnotify; you might have to tweak the paths to suite your system.
[Now that I searched for it, I found many easy to use solutions for notifications. Nonetheless I enjoyed writing the script, so that's a plus for me.]

3. There is one straight forward solution for accessing GMail contacts from mutt - Goobook. It also uses the gdata interface, but it is a well packaged pypi project and once installed all you need to do is put set query_command = "goobook query '%s'" in your .muttrc.


4. If you delete messages from mutt, they are archived on your GMail server after you sync (keyboard shortcut $). GMail labels are virtual folders and they are visible from mutt as IMAP folders. Just press c and then TAB. If you want to move a message from your inbox to a specific folder, press s (for save) while you are viewing the message, you will be prompted for folder to save the message to. Press ? to get the list of IMAP folders and choose the one you want. I guess it's not possible to apply multiple labels to a message in this setup. The way I understand it is, GMail first designed labels and when they offered IMAP support they exposed labels as virtual folders over IMAP. So for any IMAP client they are folders and a single message cannot reside in multiple folders at the same time. (I might be wrong, give a shout if you know so).


A small tip for managing .muttrc. I use two machines a linux desktop and a Macbook with Mac OSX. I have set up both to use mutt. So instead of having duplicate copies of .muttrc, I have stored a common copy in my ~/Dropbox/config folder and I just source ~/Dropbox/config/.muttrc from my ~/.muttrc.


Hope you find my tips useful. If you have any of your own, feel free to put them in comments.

Ads:
Taming The Email Beast
Linux Administration Handbook (2nd Edition)
Unix and Linux System Administration Handbook (4th Edition)

Sunday, April 18, 2010

Are you the Matt Damon of your game?

This is generally a technical blog, but some observations, although non-technical, are too interesting to not write about. I love Hollywood movies and I like Matt Damon ones a lot. Until last night however I didn't realize the most interesting pattern in the roles Matt Damon has portrayed over the years. It struck me after I watched Rounders last night.

Count the number of movies in which Matt Damon has played a character who is the absolute genius of his field. Here is a list.
  1. Good Will Hunting A Math Prodigy
  2. The Rainmaker A talented lawyer who wins his first case barely out of the law school and against a behemoth Insurance company.
  3. Rounders A genius poker player
  4. The Talented Mr. Ripley A murderer who is unusually talented in covering his tracks
  5. The Legend of Bagger Vance A prodigy Golf player
  6. The Bourne {Identity, Supremacy, Ultimatum} A one of a kind CIA operative who is absolutely unbeatable
He has a thing about playing a genius, doesn't he? And no doubt he is very good at it too. All his characters are thoroughly entertaining and deeply inspirational at the same time.

Hoping to see his latest movie soon - Green zone.

Saturday, April 17, 2010

ReaderScope 1.9 - OAuth

For past month or so, some of you (ReaderScope users) might be facing problems if you were using AutoLogin. This happened after I updated the login mechanism in v1.8.2 to support Google Reader authentication changes. I won't go into the details, but AutoLogin is very likely to fail in the new scheme of authentication. So I advised some of you who sent me the error reports to switch to Username/Password login. It was a temporary solution.

Today I am glad to announce that starting with v1.9 ReaderScope supports OAuth login for Google Reader - the right way to login without password (compared to other password less alternatives at least).

This has been possible only after Google Reader team enabled OAuth login for their service a few weeks ago. I have been working since to get ReaderScope working with OAuth. Not all the time was spent on OAuth, but in order to implement OAuth I had redesign entire networking layer of ReaderScope (which I am glad I did because I could improve some things along the way).

Finally RS with OAuth is ready. If you were still using AutoLogin, then after upgrading to v1.9 you will get a warning message that AutoLogin is no longer supported and you will be automatically logged out. On restart you will be taken to Login screen where you can start doing OAuth login.

If you are using username/password, then after upgrading to v1.9 you will get a message informing that a new password less login option is available. You won't be forcefully logged out though. You can choose to logout and relogin.

I have been testing most of the functionality in past couple of days. But I won't be surprised if some holes were left out. Please report any problems you might face or sent crash reports if you get any.

Enjoy the upgrade!

Wednesday, March 17, 2010

New app "Find Comments"

Over the weekend I found a simple API from ContextVoice. It was something I was looking for a long time. A service that when given a URL of a news story, returns reader comments from all over the web.

It didn't take long to put together a simple app around this API.

FindComments is really simple.

1) Install app
1.1) Do NOT look for a new icon in the launcher. You won't find it.
2) Browse any news story or blog post in the browser.
3) Press Menu > Share Page
4) Press "Find Comments"

Voila!

Available in Android Market, AndAppStore, Slideme.

Here are screenshots. Give it a spin.



ReaderScope users, give it a try. Would you like to see this integrated tightly with ReaderScope?

Monday, March 15, 2010

@font-face-lift

I always found that customizing the look of one's website is greatly constrained by the inability to customize the typeface. Traditionally browsers use pre-installed fonts and with the CSS font-family property, you can provide a list of typefaces that you would like your text to be rendered with (Trebuchet MS, Verdana, Sans-Serif, monospace, for instance). But this list is merely a suggestion. You don't have complete control over how your web page is going to look like in X browser on Y platform.

On last friday however I found that it is about to change now (at least in my hopes). I stumbled upon a blog post which had its text rendered in a very beautiful font. After some digging through its source, I discovered the @font-face CSS property.

It's not that this is some brand new thing in latest CSS spec, but it seems to have become of practical use only in latest browsers. You can learn more about how to use it in this post. I am going to talk about my experience with it and how it is still not perfect.

If you are reading this post in an RSS reader, go on and open it up on my blog at this point. You will see it rendered in a beautiful font. But not all of you may be. What it should ideally look like is:


But is that what you see?

The snapshot above is of Safari 4.0.4 on Mac OS X. I believe it looks the same on latest Chrome versions of Linux and Mac OS X. It looks similar in Chrome on Windows XP, but on my eeepc it looks very light for some reason. It won't look anything like it at all in Firefox on any OS. That really disappointed me, but the fault here is not of Firefox, but of my blogging site blogger.com.

After a lot of debugging of why Firefox wasn't loading @font-face, I found that Firefox does not allow a webpage to load fonts that are served on a different domain. Blogger does not allow the user to host any arbitrary file, so I host my font files on www.altcanvas.com. That offends Firefox and instead of loading the custom fonts (Junction, Santana), it falls back to Trebuchet MS. You can find more details about Firefox's policy on this matter in this article.

I spent whole friday doing fun-font research for my blog. But it stoked me enough that I started redesigning www.altcanvas.com too, which desperately needed a facelift anyway.

So over the weekend with the help of two new fonts (Junction and Comfortaa) and my recently learnt CSS tricks, I redesigned my website. Check out the new look of http://www.altcanvas.com

Again the ideal look is like this:


Don't know what you will get to see. But this time, Firefox's rendering will look  just like what you see above. That's because the fonts are now hosted under the same domain that is serving the web-pages.

What I also found was, even if all modern browsers successfully show custom fonts defined with @font-face, their rendering differs. For instance, the Junction font is only available in Regular font-weight and no bold variant is available. So the bold text doesn't look any different from normal text when viewed in webkit browsers (Chrome, Safari), but Firefox (and I believe IE too) smartly creates a bold variant of the typeface. Also I guess, the final look is affected by the OS platform, screen resolution, Anti-Aliasing settings, etc. (The 'e's look poor for Junction font in IE.)

So in conclusion, we have a new powerful tool. It's not perfect, but it's pretty good.

If you want to customize typeface of your own website or blog, I highly recommend fontsquirrel's free @font-face kits.

Ads:
* CSS: The Missing Manual
* Head First HTML with CSS & XHTML
* Fonts & Encodings

Friday, March 12, 2010

ReaderScope 1.8.{2,3} - new authentication and global share

I released 1.8.2 couple of days ago. The only change it had was the new login mechanism. Google reader team announced on fougrapi group (that stands for "Friends of the Unofficial Google Reader API") that Google Reader soon will be discontinuing the old SID-based login mechanism. Thanks to them for announcing this well before the actual change is supposed to happen (sometime in April). ReaderScope accordingly has been updated to follow the new rules.

This change is almost painless for username/password based logins. However the  AutoLogin is a little hairy issue. The library used to get AutoLogin working is unsupported and undocumented. There is an official way to do AutoLogin kind of thing on Android 2.0 devices, but it requires access to actual device to test and still I hear it's not well documented. Besides the devices at versions <2.0 are going to be there for  a long time. Therefore I got the undocumented and unsupported library to get working somehow with the new auth mechanism. However the changes I had to make were only little short of hocus-pocus. So I was very skeptical about how it was working. I released a preview on ReaderScope mailing list. So far the feedback of the preview release and actual 1.8.2 has been positive. I haven't seen anyone reporting issues due to failed logins. I have strategic log statements to detect if things go wrong with authentication. So just mail me the logs if you see suspicious behavior. Settings > Logs. Menu > Email.

Today in 1.8.3, I also fixed a bug which would have caused auth problems if anyone was upgrading from pre-1.2.5 installation.

With the new authentication done, I have a very exciting feature implemented in 1.8.3.

When you share the news item now, you will have option to trigger the global sharing apps. They could be your favorite Twitter, Facebook, Email clients. The most useful one I found was "Read It Later" which lets you save the news item to your InstaPaper account for reading later. These are the same apps that you see when you "Share Page" from browser.


I remember someone had requested this feature once long time ago. I am sorry it took so long to implement. But now that it is here, I am sure you will enjoy it.

Ads:
Hello, Android: Introducing Google's Mobile Development Platform (Pragmatic Programmers)
Professional Android Application Development (Wrox Programmer to Programmer)
Android Wireless Application Development

Tuesday, March 09, 2010

Portable apps for iPhone, Android, Pre, n900 - Can Processing.js help?

I don't know. But if you want to find out, then I have something for you.

Processing.alt

Visit this website from your desktop browser. You will see an IDE. Write some processing code to create a sketch and save it when you are done.

Visit the same website from your iPhone/Android/n900/Pre browser. You will get a simple viewer interface. Find your sketch under My Sketchbook and run it.

Processing is a well known language to create sketches, animations, games. It is a simplified dialect of java. The resulting sketches are in the form of bytecode and can be run on desktop or in java applets. In Summer of 2008, John Resig (jQuery fame) ported Processing to javascript. Processing.js uses the HTML5 canvas element to render the sketches.

The modern browsers that ship with today's smart phones support HTML5 element. So it is very much plausible to get your Processing sketch/game working on all the modern smart phones without any knowledge of native app development for each platform. Processing.js has a potential to become an uber-portable library for mobile development.

That was the idea I started out with about a month ago. After several iterations, I ended up with a website that you see now. It is an IDE when opened from desktop browser. You can write Processing code, run it, save it, share it for others to see in the Gallery. There are also some samples you can find in Gallery right now. Try them out.

The same website acts as a viewer for your processing sketch when opened from a mobile phone. You can view the shared sketches from the Gallery or you can login and find your saved sketches in My Sketchbook.

One great advantage of Processing.js is, it can intermix javascript with Processing code. So in the samples you will find how javascript is used to automatically find  the kind of browser and adjust the dimensions of the sketch accordingly.

I have tested the site on Android HTC Magic and Nokia n900. A friend told me it worked as expected on his iPhone too. Also I am treating Palm Pre's user agent as mobile platform. So on these four platforms you should see the mobile interface of the website. But in case if you don't, let me know and I'll see what is wrong.

As you will see that running Processing code on smartphones is indeed possible, but is fairly sluggish. However I believe the future is not far when the phones will become more powerful, browsers will become more optimized and Processing.js can also be tuned for speed. We already have two gadgets with 1GHz processors - Nexus One and iPad.

The IDE also has a lot of scope for innovation. But before jumping ahead of myself, I decided to open it as beta. I would like to hear your thoughts and suggestions on this idea.

So try it out and leave your opinion in the comments.

P.S. For logging in to save your sketches, use your GMail account. You don't need to login to browse through the Gallery.


Ads:
Processing: A Programming Handbook for Visual Designers and Artists
Learning Processing: A Beginner's Guide to Programming Images, Animation, and Interaction (Morgan Kaufmann Series in Computer Graphics)
Processing: Creative Coding and Computational Art (Foundation)

Saturday, March 06, 2010

ReaderScope 1.8.1 - rethinking features

In the release-early-release-often model, as the software product evolves over time, new features get added consistently. The same happened with ReaderScope for over 7 months. It started with very basic functionality and went through many iterations to reach at its current state.

Adding lot of new features however has couple of risks. First one is affecting the performance. I try to keep that under control after completing a round of new features. Memory footprint analysis and some latency measurement checks have helped to keep the ReaderScope UI very responsive over time. The second downside of features is loosing the direction, unknowingly causing a feature creep. So once in a while, it is essential that the software developer steps back a little and reviews the direction his/her software is going in. That's what I am doing in this post.

There is one feature in ReaderScope that I added few months back that I am not sure helps the main direction of the app. It is the tabbed interface. When I added it, my intent was to cater news from channels besides Google Reader. I put the Google News feeds under the News tab and was planning to add more feeds from popular news channels too. The third tab was Social. It had only a single feed for Twitter account. It smartly parsed the Twitter messages and extracted the news items pointed by the embedded links. (I love the Twitter feature and it's not going away, read below... actually nothing is going away for that matter).

Over time I have realized that the tabs are not serving any useful purpose for most of the userbase. I would rather spend time improving the Google Reader specific functionality than supporting the half baked extra tabs.

Therefore starting from v1.8.1 the tabs are disabled by default. You will only see the labels and feeds from your Google Reader account just like old days. The "Social Channels" label (which was part of the Social tab) will now appear at the bottom of your Google Reader List. If you want you can configure it to appear at the top or be invisible altogether (Settings > Customize Layout).


And for some reason if you like the tabs, you still have option. Go to Settings > Miscellaneous > Enable Tab Interface. You will get the old interface back.

One more feature is the favicons. Favicons are pretty if you read the feeds that do have favicons. However, not all users may have subscribed to feeds that publish favicons. Out of my 250+ feeds at least 150+ show valid favicons. But for some users most of their feeds may not be publishing any favicons. For them the favicon placeholder appears empty. If they are using dark themes then these placeholders appear as white rounded squares. Understandably, those users would like to turn off the favicon feature. Now they can. Head over to Settings > Value Pack > Load FavIcons and uncheck the box if you  want. (The favicon feature concerns only the Value Pack users. You haven't got one yet? It's only $2.49, hurry!)

I hope these changes simplify the UI for you. Let me know how you like it.

v1.8.1 also has one crash fix. There was a bug which could lead to crash if you immediately quit the app after starting it. It was specific to Value pack owners. It is fixed in this version.

Friday, February 26, 2010

ReaderScope 1.8 - Random

Just pushed out v1.8 of ReaderScope. Added a new feature after a long optimization-bugfix cycles in v1.7.x.

When I added home screen widget in ReaderScope, I realized how convenient it was to directly jump to the news items from the home screen, instead of opening the app and sliding through two screens. Typically during a news reading session we want to go through all the new items in all our favorite feeds. We don't necessarily care in what order. So to ease this use case, ReaderScope 1.8 introduces "Random".

When you open RS you will see a new label named "Random" at the top. When you tap on the arrow next to this label, you will directly jump to a news item. You can then use down arrow button to go to the next randomly chosen news item.


Now here is a killer. When you tap on the widget on home screen, you will be taken directly to the news item which will also have up-down arrows. It will work the same way mentioned above. In other words, you may go through all your unread news items without opening the full ReaderScope app. Just place the widget on home screen. (Note that, the full widget functionality is only available if you have the value pack installed. It's just $2.49. What are you waiting for? :)

Go ahead, update to v1.8 and let me know what you think.

And yes, do you want a FREE unlock code for the value pack. The Promotional Offer #2 is on for this weekend. First 5 people who twit about ReaderScope will get FREE unlock codes in email. It's not necessary to say only nice things, just twit your opinion about @readerscope and you will qualify for the offer. You can do this from inside the app too. Just go to Settings -> Spread the Word and you will know what to do.

P.S. I also fixed a database update issue in this release, which may concern few users who are upgrading from very old RS version (like  pre1.3)

Android fragmentation : How big a deal is it?

I came across this Infoworld story via slashdot the other day, with a sensational headline: "Google Android - a Universe of Incompatible Devices". The actual headline of the article is even more catchy "Google Android's self destruction derby begins".

The job of headlines is to attract readers. But the truth is hardly black or white. Furthermore the claims made in the article don't address specific issues that developer may or may not face. After spending past 8-9 months developing ReaderScope, I think I can better judge these fragmentation issues from developer's point of view. I have both positive and negative opinions in this matter, but all are based on my first hand experience.

  • Backward compatibility : All the Android platform versions are backward compatible. If you developed an app for Android 1.5, then it will still work on latest and greatest Android 2.1. It may look blurry on high DPI devices, but it will work nonetheless. I have hardly heard any case otherwise. Therefore, It doesn't make sense to call all the Android devices incompatible.
  • Games : I believe Game developers are the most affected by fragmentation issues. But even then I think their major concern is differing screen sizes and input controls. Hence I don't think release of 2.0, 2.1 would have affected them if they had already updated their games for all three screen sizes as per the guidelines in 1.6.
  • Standard UI : If your app is not a game and/or you are using standard UI widgets, then it doesn't take much effort to qualify your app on newer SDK versions. I didn't have to make any specific changes to ReaderScope for 2.0 and 2.1 platforms. I know of people using it on these newer phones and aren't having any platform specific issues. I however hit a problem when I started supporting 1.6. Some users started seeing crashes when ReaderScope was writing to SDCard, it later became clear that it was due to a newly introduced permission in 1.6.
  • Google published a chart on Jan 4th this year that shows current distribution of platform versions. It seemed like a great step to alleviate this problem. Unfortunately, they haven't updated that chart ever since. Nexus one was released on Jan 5th, so that chart is pretty outdated IMO. I think Google can certainly do a better job there to help the fragmentation problem.
  • It's shocking that there are still so many Android 1.5 users. I heard from a user in Russia, that they won't be upgrading from 1.5 until May this year. That's way too long. I don't know what's the update schedule in India, but OTA updates are unheard of in India, because the phone didn't come with mandatory data plan. (Thanks to cyanogen, my Magic is running a ROM somewhere between 1.6 and 2.0.) Android 1.5 R3 came back in April 2009. So 1.5 is getting over a year old. It's high time Google/their partners start updating these poor souls.
  • The backward compatibility is a huge win, but the biggest disadvantage of fragmentation is you cannot use new features introduced in newer versions. I don't want to code live wallpapers (introduced in 2.1), but there are some great improvements in 1.6 and 2.0 that I would like to use, but can't because then I would have to drop support for 1.5 users. There is some reflection witchcraft that can help in this case, but it may not be worth it.
  • There is one surprising thing that I recently discovered by accident. The browser shipped in v1.6 doesn't support HTML5 offline caching feature. It is only supported in 2.0+ browsers. I believe that's is an important feature and iPhone seems to have had it for a long time. That's a key feature for cross platform web apps.

That's pretty much I can think of till now. Let me know in comments what are your opinions on this matter.

Ads:
Professional Android 2 Application Development
Android Programming Tutorials: Easy-To-Follow Training-Style Exercises on Android Application Development
Android Application Development: Programming with the Google SDK

Sunday, February 14, 2010

on Dropbox

I have been using Dropbox for a few weeks now. There are several solutions to address our storage issues and I have found all those solutions inadequate in one way or another. Dropbox seems to have solved most of those problems for me.

There are two important things we want to do with our data (besides creating and consuming it, of course): Sharing and Backup.

Sharing We need to share our data either with others or with ourselves but on a different computer. When we want to share data with others the first thing comes to mind is Email. If your data is of specific type, say image or video, you can use services that specialize in handling those types of data (Flickr, Picasa, Youtube). If it is the documents that you want to share, you will think of Google Docs or Zoho. If it is any arbitrary kind of data, then you may need a network drive. If the other individual you want to share the data with is in the same household or if you yourself want to access the data from different machine in the same household, you would use a NAS box. Mount that shared storage as NFS or CIFS drive on your computers. Here you need some administration expertise and need to maintain it over time.

Backup No one wants to loose their data. But we know our computers are anything but immortal. The solutions I mentioned above for sharing data, also serve as backup solutions. Moreover, if you are tech savvy, you can use mirrored RAID hard drives.

I've found that Dropbox satisfies both of the above needs and requires zero setup and maintenance efforts on user's part. Dropbox is a service provider that provides storage as a service. After you install the Dropbox software on your computer (Windows, Linux or Mac OSX), it will appear as just another folder on your computer. You can create, delete, rename a file in your Dropbox drive on one machine and the action will reflect almost immediately on other machine (depending upon the network speed). That's all. Now let me enlist what all complicated things this simple setup has solved.

  • You don't have to worry about NFS/CIFS or what data sharing protocol the service uses and if the OS on your different machines will talk that protocol or not. Dropbox uses some proprietary (!! yes, I'll come to that later) protocol and provides free clients for all platforms that seamlessly talk that protocol.
  • You can share data with others if they have Dropbox account. Imagine telling your mom that she can copy the photos she has taken in this folder on her desktop and her son will see it instantly on the opposite face of the planet. No need to upload them to Picasa or whatever.
  • Dropbox has an option called "Enable LAN sync". This is killer. If you want to share your data between a laptop and desktop that are in the same LAN, Dropbox will sync the data without going over network. I tried this yesterday - actually unknowingly, because I expected my Macbook to take much longer to sync a week's worth of git history and it did it almost instantly. I am not sure if this will work if you are not connected to Dropbox servers. The daemon on desktop might have to exchange some meta data with Dropbox servers, but the actual data transfer takes place entirely on your internal LAN, and hence is very fast. This makes Dropbox a solid alternative to a NAS box.
  • When you sign up, you get 2GB of data for free to start with. For more storage you need to pay an yearly amount. (Don't know about you, but it will take a while for my shareable data to exceed 2GB.) Moreover you will get 250MB for every person that signs up through your referral. Furthermore, it's a data storage and not a version tracking repository. So you can free some space if you hit the limit by deleting unwanted files. (I am not 100% sure if that actually frees space or not. When I have lot of data to delete I will test it)
  • Offline availability: If your ethernet/wifi connection breaks, the NAS share on your machine will be inaccessible to you. That's not the case with Dropbox. You can still access the files in your Dropbox folder even when you are offline - just that they won't be up to date.
Dropbox talks a proprietary protocol. The client daemons are closed source too. These days "open" has become such a fashion statement that few people care to find its relevance in a given context. Here are two aspects of the Dropbox service that make me feel safe when putting my data in it.

  • Lock in - This is a major issue with document storage services like Google Docs or online MS Office. You need to make sure that they have the ability to export their document in a format that can be opened by other software of your choice. Creately is a great product, but I don't want to use it to draw my flowcharts because it saves the doc in a proprietary format. I can only export it as PNG image. I would have used it, if it had an option to export to SVG. By the nature of its service Dropbox doesn't have lock-in problem. Your files are stored as raw data, so there is no worry of format lock in.
  • Evil/Bankruptcy - In case Dropbox goes bankrupt overnight, or gets bought by someone evil and shuts down their servers except for paid customers, do we loose our data? The "Offline Availability" feature of Dropbox will let you access your data on your local machine, even if the Dropbox server is not reachable. Now it is arguable, if Dropbox can plant a malware in their proprietary daemon to sabotage your data or make it inaccessible. I leave it to you to decide if a popular service provider will do such a thing on purpose. (If you think it can, you may want to stop using Gmail)

I hear Dropbox has an iPhone app, but without iPhone I can't check it out. But they are soon publishing Android and Blackberry apps, so I will review it then. They do have mobile-friendly web site though.

So overall, I think Dropbox is a great service to solve our storage worries.

Having said that, there are some minor issues that I've found or don't know enough about that may concern some of you.

  • Dropbox can share files across Linux and Windows, but I don't know how that affects access control bits on those files. I can see the -rwx- fields on my files alright even when I put them in Dropbox. I don't know if they affect when the file is modified from a Windows machine (I don't use Windows myself). I have been using Dropbox as my Git repo for few weeks and I haven't found any problems doing that.
  • On a Windows machine, the installer is little unclear when dealing with multiple accounts. I installed it from an Admin account on my parents' laptop, but it didn't show up in my parents' account that have no admin privileges. I had to temporarily give admin rights to those accounts, install Dropbox and revoke the rights later. It worked alright after that.
I have used the service only for a month, so I may or may not find things in future that may change my impression of the service. Never say never. But so far, I've found Dropbox to be the best solution for data sharing and backup.

(There is a competing service named Sugarsync, but I haven't tried it. I think it lacks support for Linux, so no-go for me.)

Friday, January 29, 2010

iLikeIt

Two days have passed after the announcement of iPad. A lot has been said, written, twitted about Apple's latest product. But I have something to add too.

There are three things I would like to say about iPad, that I haven't seen emphasized elsewhere. That's what this post is about.

1. One plane of interaction.

iPad will be the first product of its kind - a laptop size screen (almost) and a laptop size keyboard (virtual albeit) merged in one plane. All the laptops (and desktops) that we've ever used in our lives, have had two planes of interaction. A horizontal plane that takes keyboard input and a vertical plane that emits monitor output. With iPad these two planes are going to merge. I don't know if it is good or bad, but I think it's the first time and don't know how our brains will react to that change. We definitely imagined this is how our future interfaces will be, but now that such a product is here, we will actually know if that is what we want. Will we find it awkward that we now are doing both input and output in the same plane. I don't know. From the promos, it seems apple did a great job in keeping the keyboard simple. Let's see how that works out.

2. It's Apple Inside Out

It's the first time Apple has delivered a product that runs on a processor built by Apple themselves. That means, it's the first time that each and every part of iPad has been designed and built inside Apple. I think it's interesting in various aspects. 

It's every product designer's fantasy that he/she has control over every tiny piece of their product's component (own the whole stack). However only few in the computing industry have achieved that status. Think of Sony, Nintendo. Apple has joined their ranks. However, Sony and Nintendo's products are niche (gaming consoles or music gadgets), whereas Apple is building general purpose computing products. Moreover Apple gets design, they have a style and they have established a fan following. What this means is Apple is now all too powerful. They can use that power to reach newer heights in product design. On the flip side however, they can use this power to restrict access to their system. They have already shown it in the form of iPhone app store. Apple products excel in user interface, but they block every other kind of interface.

3. Future is here

Criticize whatever you want in Apple products, but one thing is undeniable - they are pushing consumer electronics into the future. And not just with lab prototypes, but with main-stream, mass-manufactured, affordable products. Designers have always thought of products like iPad, something that feels like a simple slate rather than a powerful computer. Few have created their own prototypes of the concept or even niche products (take graphics tablets from Wacom, Microsoft Surface), but Apple will deserve the credit for bringing such a futuristic product to our kitchens.


Footnote: 
In case you are wondering about where I am on the Apple fanboy scale:


I like Apple's products, though I won't call myself a Apple fanboy. I think they are the best designers of computing industry. I have owned only two Apple products so far, a 4th generation iPod and a Macbook. I've been pretty happy with them. I have never owned an iPhone, mostly because it is too restricted a device to play with. Android is the best choice for smart phones in today's date - open enough to play with and with good enough design that gets the job done.


Ads:
CaseCrown Faux Suede Zip Sleeve Case (Black) to Carry the Apple iPad Wifi / 3G Model 16GB, 32GB, 64GB
Apple iPad Soft-Shell Eva Foam Case by Protec (Silver)
Archos 9 PC Tablet (Black)

Thursday, January 28, 2010

ReaderScope v1.7 - Widget, new Icons and .... Ads

Last night I released ReaderScope v1.7.

It now comes with a simple yet useful home screen widget.


You can tap on the news and it will be opened in the regular viewer that you see in the main app. The icon in the upper left corner, opens the full app. The icon in the lower right corner refreshes the news items in the widget. This refresh icon however, will only work with the Value pack (previously known as Theme pack, it costs only $2.49)



v1.7 comes with more stylized icons. They are also made DPI specific, so users with high DPI devices (Droid, Nexus One), will see better icons now.



And last but not the least. In this version I added an Ad-bar on the news reading screen. It is part of the basic free app. You can get rid of it by installing the Value pack.

[If you have donated to ReaderScope in the past, you are entitled to a free unlock code of the value pack. I've sent them yesterday to all the three donors. If you haven't received them or having any troubles using them, please let me know.]

Let me know what you think of the new widget, icons and the ads.

Cheers!

Wednesday, January 27, 2010

on Git: tips for SVN users and Git in Dropbox cloud

I gave in to the hype of Distributed VCS and decided to learn Git about 6 months ago (No, it's not a hype, even for single person projects). I started managing my latest projects with Git. Learning Git was not a cake walk, but I put my faith in Git's promise of power and climbed the beginning slope of the learning curve. If you are switching to git after using Subversion for years, then this slope can be steeper. But now I am comfortable with my Git setup and starting to see the glimpses of power that git has to offer.

Here are few tips for subversion users shifting to Git, which could have saved me some agony when I was new.

1. How can I do svn revert in Git?
Believe it or not, but you do that with git checkout . When I first learned that, I was shocked. (And the best part is, the manpage of git-checkout talks about this functionality only in 3rd paragraph and in not so clear words). Over time you will find out that "checkout" is highly overloaded sub-command in git. Besides reverting your changes, it is used to switch to new branch, or create a new branch altogether. Its semantics are nothing like svn checkout. (The closest git analogue of svn co would be git clone, but not exactly)

2. What's all about branching being easy in Git?
Once your projects starts to grow beyond certain size, you appreciate the ease of branch management that Git provides. But it takes little effort to understand it. In Subversion, the central repository lies on a web server or a backed up disk partition. You as a user, "checkout" a local copy of it. In Git as well, there can be a center repository (but it's not necessary), however you do not checkout code from it. You as a user "clone" the entire repository. Because the entire repository is available locally, creating, deleting and switching between branches is very fast. Others don't see your branches unless you create a corresponding remote branch on central repository (check git push and --track option of git checkout to find out more about it)

3. Here are two useful git subcommands that I wish were more publicized, rather than documented like corner cases.

stash
When you start using multiple branches, more often than not you are faced with a situation where you have some uncommitted code in branch B, but to fix a customer reported crash you want to immediately switch to branch A. When I first faced this situation, all I could find was do a commit and switch the branch. After some later point I accidentally  came across 'git stash' and found how handy it was.

cherry-pick
You are working on some new feature in branch B and you find a critical bug while doing it. You find the  fix for it and you want to release it immediately without waiting for this feature to complete. Your releases are built from branch A (from which you create B). Commit your fix in branch B (don't include any feature code in that commit), then git the SHA id of that commit to cherry-pick.

4. git mergetool
Git has the most intuitive conflict resolution mechanism in the form of git-mergetool. Actually, I am not sure if it's git or (g)vimdiff that deserves the credit (or both). After doing merges across branches, if you end up with conflicts, then use git mergetool --tool=vimdiff (git may automatically prompt you for this). I have done some merges with Perforce in the past (they call it crossport, integrate, etc.), and suffice it to say it was bad enough for me to avoid that task altogether. But the three windowed diff view makes this task as intuitive as possible.

5. Best Git GUI I've found so far: Git-cola

6. Book recommendation: Progit (It's Free. It explains different use cases with examples and that helps a lot)


Now on to the second part of the post. Something that I discovered recently. First understand that, you don't need any central repository to git-fy your project. You have a directory of source files and you want to start tracking it with git, just do git init and you are good to go. git-add, git-commit, git branching all can be done after this point.


However, in little bigger use cases you need a central repository. In my case, I work on same project from two different machines located at two different locations. I could create my git repository on USB key and carry it around with me. But it's not reliable - media corruption, physical loss, theft - you get the point. So it's advisable to have your central repo in cloud.

I rented such service from repositoryhosting.com for $6 per month. They provide many other project management tools in the package too, but I primarily used it for git. Recently I started using Dropbox. Although Dropbox storage resides in cloud, they have done perfect job of exporting it as native file system. More importantly it works on all three platforms. So for all practical purposes (that I have covered in last two weeks at least), it's a native file system, but magically synced across different machines. So I just created the git clone of my git repositories in one of the folders inside Dropbox. I can now push and pull to/from this repository on different machines. See this post for detailed instructions.

Dropbox comes with 2GB of free storage and by doing some referrals you can stretch it up to 2.5GB. It's plenty for versioning source code files, don't you think? Be careful not to version big files though (release binaries for instance), you won't be able to free up space by removing them once they are in the repository.

I hope you found the git tips useful. Hoping to explore more of git.