Friday, January 28, 2011

Notifications in Chrome

Some of us would be familiar, and piqued, by the recent suggestion in our Gmail windows: "Click here to enable mail notifications in Chrome". Choose to, and whichever tab you might be browsing on, any new mail or chat message is reported in a tiny corner bottom right of the screen. This nifty addition surprised me enough to find out more about the concept, and its other possible applications.

Notifications to the desktop are nothing new, but notifications on the browser are.
The OSX folks have had something called Growl notifications in place, which requires installation, then could be accessed through the windows.fluid object built into Safari on Mac.

Google, with their support for Web Notifications, and their W3C recommendation in general, have tried standardizing this concept.
Here's a small working example for the same:

PS: Try it, in baby steps, on Jash. FUN!
<script type="text/javascript">
(function() {
var notificationStatus;

setupNotifications = function() {
if(window.webkitNotifications) {
if(window.webkitNotifications.checkPermission() == 0 ) { //permission granted
notificationStatus = 'Permission granted';
} else if(window.webkitNotifications.checkPermission() == 1 ) { //permission unknown
//notificationStatus = 'Permission not granted yet';
notificationStatus = "Unknown, click to <a href='javascript:window.webkitNotifications.requestPermission(setupNotifications);'>enable web notifications</a>.";
window.webkitNotifications.requestPermission(setupNotifications);
} else { //permission denied
notificationStatus = 'Permission denied';
}
} else alert('Not supported');

if(!!document.getElementById("notificationStatus"))
document.getElementById("notificationStatus").innerHTML = notificationStatus;
}

notifyMe = function() {
//permission already granted
if(window.webkitNotifications.checkPermission() == 0 ) {
var popup = window.webkitNotifications.createNotification(
"myicon.ico",
"You nailed it",
"My good sir, by delving into this notification thingy you open yourself to plenty of bobfoolery"
);
//ondisplay is one of the three events for the notification API
// ondisplay, onerror, oncancel
popup.ondisplay = function() {
setTimeout(function () {popup.cancel();}, 6000);
//we keep a timeout for the notification, since they don't have one by default
};
popup.show(); //this displays the notification
}
}
window.onload = setupNotifications;
})();
</script>
A simplified concept, a small API, and user security considerations - the spec has its bases covered. Presently these notifications only work on the Chrome browser across Windows and Linux.
For the old crowd, things were ridiculous, with the programmers having to resort to annoying and invasive hacks like window.alert. This new feature would give online tools like e-mail clients, calendering software, task managers, monitoring systems, etc. an elegant and consistent way to notify users.

However, not everybody is gaga over it. After some toying around, even I am a bit skeptical about the specs and the architecture: The notifications take a while to associate with their tab. They aren't a welcome experience to deal with when your friends start firing messages in your gmail chat window. Moreover, with the proliferation of these (among Tier 1 sites, to merely begin with) we can only anticipate an avalanche of these, since the recommendation suggests no way to restrict or control the notifications.

Thursday, January 13, 2011

Lightweight gmail

See my gmail inbox above - that's all there is. Pretty light.
How it got so is an inspired tale, having its origins from Matt Cutts' blog (a popular netizen who leads the Google Webspam team). This helps me twofold
* Lighter page
* More relevant inbox

It's the label-and-archive strategy.

Step I> Fix on a scheme

First thing to work out is whether
- I want my email and chats as different entities, or together. Personally, I'd like to keep them separately.
- I want my emails sifted chronologically, or by mail providers, or by family/friends/office. Let's call them sort-order aka "distinctions". For me, chronological distinction is convenient. I'd also like to keep my stupid chain mail forwards away from more important mails.
- Which emails might be overlapping distinctions. For example, I had several joke-of-the-day kinda forwards, that I wouldn't give a damn about; but alongside were other forwards that were important conversations.

Step II> Get your search filters right

This one is a custom affair. I decided to have my emails and chats for past couple of years filtered in separate boxes, while all else (2008 and earlier) went into a single huge box.
Here's a sample of the way my search filters went
for email: before:2011/01/01 after:2009/12/31 -is:chat
for chats: before:2011/01/01 after:2009/12/31 is:chat
for joke-a-day forwards: fw has:attachment -is:important -label:professional

Step III> Label and Archive

- Once I had the result from mail search, I did "Select All" by clicking on the dropdown arrow next to the select checkbox above mails, and then again clicking on "Select all * conversations" link that now appears.
- Then I applied an appropriate label, say "2010 emails", and finally
- Pressed the "Archive" button.

Back in Inbox
This one is easy. If you want your mail to appear back in your inbox, just click the appropriate label (say, "2010 emails"), and in case you want to see some/all in your Inbox, just select those (or all), and click Move To > Inbox

Unlabel My Email
Even easier.
- See those labels listed on the page (which generally lie on bottom left)? If you click on their dropdown, you'll find a "Remove Label" link.
- Or you could goto Label > Manage Labels, and Show/Hide/Delete them through there
- Or just select all those emails you don't want under that label, click on Labels in the bar above, untick the labels you don't want, then click Apply.

Wednesday, January 12, 2011

Fix your PHP!

The exclamation should be taken to its intended effect. A critical PHP vulnerability was identified in the PHP engine (PHP 5.3.4) - which allows an easy, creative, orchestrated DDoS attack. This affects both Windows and Linux. VERY SERIOUS.
"Due to the way the PHP runtime handles internal conversion of floating point numbers, it is possible for a remote attacker to bring down a web application simply by adding a specific parameter to a query string in their web browser.
This vulnerability is present on all versions of PHP including PHP 4.x and 5.x, on all Intel-based 32-bit PHP builds."
I'm merely being the information inspector here - source being a Zend newsletter.

Go Party at Wikipedia's 10


Jan 15th will now trump other days, like your cat's birthday. Wikipedia's 10 anniversary is not a small affair - as they themselves have made evident through their Anniversary page. Celebrations across the planet.
Mumbai (VJTI, Matunga)
New Delhi (IIT, Hauz Khas)
Lucknow (Fun Republic Mall, Gomti Nagar)