pratham RSS

Home
Archives
Random
Contact

Search Site

Powered by Tumblr
Aug
13th
Wed
permalink

Wikipedia “Did you mean” script.

Wikipedia search fails for the simplest of spelling mistakes. This Greasemonkey script adds a “Did you mean” option to Wikipedia search. Install it here.

Aug
2nd
Sat
permalink
Jul
27th
Sun
permalink

Nested Twitter Replies.

I’ve always found it difficult to follow Twitter conversation threads. So I’ve written a Greasemonkey script to automatically retrieve and display nested replies. The script recursively follows the “in reply to [user]” and gets the entire conversation thread. Install it here.

Note that Twitter links replies to the last update made by the original poster, so some threads may appear broken.

May
4th
Sun
permalink

The infamous IE “Operation Aborted” bug fixed.

The “Operation Aborted” bug is a pretty embarrassing one, even by IE’s low standards.

Very broadly, this is how the bug is triggered.

  • The HTML file is being parsed.
  • Script is executing.
  • The script attempts to add, or remove an element from an unclosed non-parent DOM element.

IE8 b1 now has sort of fixed this, by converting this from a complete runtime crash to a (non-modal) exception.

Feb
12th
Tue
permalink

7 segment ASCII captcha.

A captcha is a security measure to test if the user is human or not. The idea is to make it easy for humans to read and tough for robots to do so.

The 7-segment display technique can be used to create a lightweight captcha. Here is a simple Javascript example to do so.

var segments = new Array (
  ' _ | ||_|',
  '     |  |', 
  ' _  _||_ ',
  ' _  _| _|', 
  '   |_|  |', 
  ' _ |_  _|',
  ' _ |_ |_|', 
  ' _   |  |', 
  ' _ |_||_|', 
  ' _ |_|  |'
);

var draw = function (n) {
  segment = segments [n];

  segment = segment.substring (0, 3) + '<br>' + 
    segment.substring (3, 6) + '<br>' + 
    segment.substring (6, 9);

  segment = segment.replace (/ /g, '&nbsp;');
  document.write ('<div style="float:left">'+segment+'</div>');
};

With some CSS adjustments, this is what the numbers would look like.

   
  |
  |
 _ 
 _|
|_ 
 _ 
 _|
 _|
   
|_|
  |
 _ 
|_ 
 _|
 _ 
|_ 
|_|
 _ 
  |
  |
 _ 
|_|
|_|
 _ 
|_|
  |
 _ 
| |
|_|

Note that the font needs to be Monospace based for the number to be displayed correctly.

Jan
29th
Tue
permalink
Jan
27th
Sun
permalink
Jan
5th
Sat
permalink

Meebo and the blinking favicon.

Meebo uses a cool blinking favicon as a notification for various events (messages, buddy login, signout). Here is a simple function to mimic the behaviour.

toggle = function () {
  favicon = document.getElementsByTagName ('link') [0];
  head = document.getElementsByTagName ('head') [0];

  url1 = 'http://google.com/favicon.ico';
  url2 = 'http://yahoo.com/favicon.ico';

  n = document.createElement ("link");
  n.setAttribute ('href', (favicon.href==url1) ? url2 : url1);
  n.setAttribute ('type', 'image/x-icon');
  n.setAttribute ('rel', 'shortcut icon');

  head.removeChild (favicon); head.appendChild (n);

  setTimeout (toggle, 500);
};
setTimeout (toggle, 500);

This assumes that the favicon link tag is the first link tag, you might make have to make changes if that is not the case.

If you’re using Firefox, you might actually see the toggling Google and Yahoo favicons on this page.

Nov
29th
Thu
permalink
Nov
18th
Sun
permalink

Hash marks as AJAXified permalinks.

The hash mark (or the fragment identifier) has become the choice for constructing AJAXified permalinks.

The question mark query string ( For eg. http://google.com/search?q=SomeSearchQuery ) was designed for this purpose. But this forced a reload of the page, not an option for most AJAX apps. The hash mark (fragment identifier) is a link to a part of a document, hence a completely client side action which does not force a reload.

Gmail is the latest AJAX app to go the hash-permalink way.

Nov
7th
Wed
permalink

Yubnub Pseudo-protocol?

Linking is a lot of work. For example, the HTML code to link to the google results for india is <a href=”http://www.google.com/search?q=india”></a>

What if I could write something like <a href=”yubnub:g india”></a> ?

I managed to find rubnub, but it requires a Firefox extension. I am looking for a cross-browser cross-setup type of solution which works on most browsers.

Note: Yubnub is a command line for the web.

Oct
27th
Sat
permalink

Adding post-only comments on Tumblr.

Here’s a useful Javascript hack if you want to add post-only (not displayed on the home page) comments to your Tumblr blog.

if (location.href.indexOf ('post') != -1) {
 elem = document.createElement ('script');
 elem.setAttribute ('src', 'http://js-kit.com/comments.js');
 elem.setAttribute ('type','text/javascript');
 document.getElementsByTagName ('head') [0].appendChild (elem);
}

It uses the JS-Kit comment widget, and “loads” the javascript only if the word “post” is found in the URL. It works in Firefox 2, Opera 9 and IE6 (with an ugly CSS hack).

Update: Tumblr now has a block:Permalink block to render comments or other post-level widgets.