Site Moved

This site has been moved to a new location - Bin-Blog. All new post will appear at the new location.

Bin-Blog

IT Expo 2006 at Cochin

Tux in Kerala

Taking a short break from the regularly scheduled program, I want to announce the IT Expo 2006 at Cochin, Kerala, India. So, if you are not from Kerala, this post is not for you.

IT Expo 2006 will be held at Townhall, Cochin. This event starts at November 30 and will end by December 02. Be there.

IT Expo 2006 will be held at Townhall, Cochin. This event starts at November 30 and will end by December 02. If you are in Cochin, be there. The Cochin LUG, which I am a part of, will have a stall(#41) in this exhibition.

The exhibition time is from 10:00 AM to 8:00 PM. If you are planning to visit the exhibition, come over and say hi. Just look for the stall named 'ilug-cochin.org' and ask for Binny. I will be there from 3:30 to 8 PM tomorrow and full day on Saturday.

Read more about it and updates on my personal blog. Some posts about this event...

Read More...

Experimenting with CakePHP and Ruby on Rails

I am experimenting with two frameworks that are really popular these days - Ruby On Rails and CakePHP. I will write a comparison between the two when I am done. So far, I think I prefer Ruby on Rails over CakePHP - I still don't understand why.

What they are...

Ruby on Rails

Ruby on Rails

From the site...

Ruby on Rails is an open-source web framework that's optimized for programmer happiness and sustainable productivity. It lets you write beautiful code by favoring convention over convention.

CakePHP

CakePHP

From the site...

Cake is a rapid development framework for PHP which uses commonly known design patterns like ActiveRecord, Association Data Mapping, Front Controller and MVC. Our primary goal is to provide a structured framework that enables PHP users at all levels to rapidly develop robust web applications, without any loss to flexibility.

My Experience

I have already created a small 5 page application on ROR - it is not something that the public can use - so I am not releasing it. However I am creating another somewhat larger application on ROR - which I will release as soon as it is over. Expect it within a month(or so). As I am using DreamHost, I have Ruby on Rails hosting - so hosting won't be a problem.

So far, I have only experimented on CakePHP - I still am looking for a small project to use CakePHP in. Suggestions are welcome.

ActiveRecord

ActiveRecord is an object that wraps a row in a database table or view, encapsulates the database access, and adds domain logic on that data. Both CakePHP and ROR supports this. ORM is something I want in my projects - I don't like using SQL all over the place.

Basically, that means that I can write

$person = new Person();
$person->name_first = 'Binny';
$person->name_last = 'V A';
$person->website = 'http://www.bin-co.com';
$person->save();

instead of

$sql->exec("INSERT INTO Person(name_first,name_last,website) VALUES('Binny','V A','http://wwww.openjs.com/')");
Do you know any PHP library that will provide this feature? Currently I am looking into ADOdb - but I still can't get it to work - yet.

Disadvantages

I still have not encountered any major disadvantages yet. However, the few problems that I have seen are...

CakePHP

  • Documentation is not as good as for ROR - I end up viewing the source to find what I need. This may be because their search engine shows the source at the top of the results.
  • Not enough tutorials. Also there are some errors(typos) in the existing tutorials.

Ruby on Rails

  • I still have not managed to run my project using Apache - I am still using the Brick Server. This is clumsy as I have to keep a terminal window open.
  • Difficult to find hosting - there are many hosting plans that support PHP - but very few that support ROR.
  • Too much hype. Not necessarily a bad thing.

Related Links

Read More...

Del.icio.us and Furl Bookmarklets - Improved

In the last post I created the 'perfect' Digg Bookmarklet - now I will try to do the same for Del.icio.us and Furl bookmarklets. It follows the concepts introduced in the post about meta tags. The principle will be the same as the one used in the Digg bookmarklet - SMP or Selection/Meta/Paragraph approach.

Fetching Data

Getting the Title and URL is done using document.title and document.location.href. To create a suitable description, the following method is used...

  • First, see if any text is selected in the document. If so use that as the description.
  • If nothing is selected, search for the 'description' meta tag. If present use that.
  • If these two methods fails, we use a failsafe - the first paragraph(p tag) is fetched and used.

Installation

To install the bookmarklet, drag the above link to your bookmarks toolbar. This should create a new button on the toolbar. Now visit any page you want to submit to the bookmarking service and hit this button. The bookmarklet will open a new pop up window with all the information filled in automatically.

Del.icio.us

Del.icio.us logo

Bookmarklet

Del.icio.us Bookmarklets

Code

The Del.icio.us bookmarklet code(readable format).

The Original

Original Bookmarklet

Furl

Furl Logo

Bookmarklet

Furl Bookmarklet

Code

The Furl bookmarklet code.

Original

Original Furl Bookmarklet
Read More...

Digg Bookmarklet for Firefox

The effect of my bookmarklet on Digging

I have talked in length about how del.icio.us and furl bookmarklets can be improved - now I want to talk about another similar service that don't even provide a bookmarklet. I am talking about Digg. Okay, I know that Digg is not a social bookmarking site - but it is a site to which you can submit URLs with it's title and description. So the same kind of bookmarklets can be used here too. With that in mind, I will try to create the 'perfect' Digg bookmarklet.

The Digger Bookmarklet - for the impatient. To install the bookmarklet, just 'dragg' the link to your bookmarks toolbar. Now visit any page you want to submit to digg and hit this button. The bookmarklet will open a new window with all the information filled in automatically.

Requirements

The Digg bookmarklet should have the following features...

  • URL must be fetched
  • Title must be fetched
  • The description to be used must be selectable by the user.
  • If the user did not select a description, it must be auto generated.
  • All the inputed values must be editable by the user.

The perfect bookmarklet should work in IE as well as the other browsers. However, I am leaving this out as I hate IE and so should you. Anyway, enabling this feature will make many other features impossible - as IE have a very stupid 488 character limit for bookmarks. This will make complex bookmarklets very hard to create - if not impossible.

Fetching Data

URL

Fetching URL of the current page is easy - just use document.location.href. This will be passed in the URL to the Digg site - to the phase 2 page. This means that URL is not editable after the bookmarklet is clicked. I am sorry about that - if it must be editable, I have to use the phase 1. That is more trouble than it is worth.

Title

Another easy one - javascript has the document.title property that can be used to fetch the title of the document. There is a problem with this - in many sites, the site title is given with the page title - like this "xml2array() - XML Parser for PHP < PHP < Bin-Co". Using the first H1 tag may solve this, but again, that could hold the site title too. Anyway this field is editable - so don't worry too much about it.

Description

This is the hard part - I am going to use this method to fetch the description.

  • First, see if any text is selected in the document. If so use that as the description.
  • If nothing is selected, search for the 'description' meta tag. If present use that.
  • If these two methods fails, we use a failsafe - the first paragraph(p tag) is fetched and used.

I call this the SMP approach - I use this in my custom social bookmarking bookmarklets. But that is another post.

Now all we have to do is create a URL with these data in the query. The keys used by Digg are..

title
The title of the page
bodytext
The description.
URL
The URL of the page.

Please note that you will have to URL encode all the data before using it in the URL.

Bookmarklet

The Bookmarklet - Digger

To install the bookmarklet, drag the above link to your bookmarks toolbar. Now visit any page you want to submit to digg and hit this button. The bookmarklet will open a new window with all the information filled in automatically.

The bookmarklet code(readable format).

By the way, this bookmarklet will not work in IE6. You need a good browser if you wish to use the bookmarklet.

If you have any more ideas to improve this bookmarklet, let me know.

Read More...

Removing Description and Keyword Meta Tag Considered Harmful

Many in the SEO field have commented on the uselessness of the meta tags - primarily of the Keywords meta tag. Many have even recommend it be removed as most of the Search engines ignore it completely. This is because many SEO 'experts' have abuse it a lot trying to game Google. But I will not recommend removing either of these tags. Both have great use - if your visitors are using any of the popular social bookmarking tools like Del.icio.us or Furl.

SEO and Meta Tags

The phrase 'meta tag' became a synonym for SEO.

Earlier, the primary use of these tags were for the SEO benefits it had. It was used so much that the phase 'meta tag' became a synonym for SEO. But lately, most search engines are ignoring it. Now most of the SEO heavy weights do not recommend using these meta tags.

The description tags are still in use as they appear in the SERPs. But most people ignore the keyword meta tag.

The description meta tag appears in the Google search result pages.

Bookmarking Tools and Meta Tags

Social bookmarking services like Del.icio.us or Furl have seen a huge popularity boost in the last few years. Most of us are familiar with the bookmarklets they have provide us. These bookmarklets(or favelets) make it easier to bookmark a page.

Let us take a look at the case of del.icio.us - easily the most popular social bookmarker(is that a word?). It requires 4 inputs about a page...

  • URL(Mandatory)
  • Title(Mandatory)
  • Description
  • Tags

The bookmarklet will try to fetch these data from the page automatically. The URL will be the value of 'document.location.href' and Title will be 'document.title'. So these will be automatically filled out for you.

But what about the rest? Not using tags when bookmarking is a sin against man and nature! I mean, that is the whole point of 'Web 2.0' social bookmarking.

The description field is just as important - if you wish to search through you bookmarks, nothing helps more than the data given in this field.

Description meta Tag

One option is to manually enter the data into these fields. Tags, one can fill out - but what about the description? Are you willing to type out a good description every time you bookmark a page? Not me! The best approach to get this field automatically is to use the meta description field. Just use DOM to get the data and pass it to the posting url.

del.icio.us

Del.icio.us logo

Unfortunately, del.icio.us's bookmarklet don't support this tag. I cannot blame them for that - as usual I place the blame on Microsoft. To be more precise, the blame falls on IE. To be even more precise, it is the fault of IE's inability to handle bookmarklets(or favelets, as it is known in IE) that is more than 488(it differs in different versions) characters in length.

It is not possible to compress the meta tag searching feature in 488 characters - so del.icio.us has left this feature out.

Furl

Furl Logo

Fortunately, furl don't have any such limitations. In the grand tradition of AListApart, furl created a bookmarklet that is just shy of 2000 characters. But this don't support the description meta tag either. What this does is capture the selected text and use it as the description.

Most sites don't have this(description meta) tag. In the sites that have it, it is not properly implemented. They just use the same description through out the site.

There is a good reason as of to why the description meta tag is not supported in the bookmarking bookmarklets(hey, that rhymes). It is because the majority of sites don't support it. Most sites don't have this tag. In the sites that have it, it is not properly implemented. They just use the same description through out the site. Yes, its a sad world we live in.

Anyway, it is not so hard to modify the bookmarklet to include this feature - the hard part is decoding the bookmarklet. You can use some JavaScript beautifier to do that. After that, it is a trivial matter to insert the code to fetch the meta tag. However, this bookmarklet will only work on good browsers - which is a good thing - it will force you to abandon IE. Hey, I can hope, can't I?

Keywords = Tags

Since I spent this much time rambling about meta description, you must have guessed the use of the 'other' meta tag - keyword. Yes, they can be used to tag the page. As you might have known...

Web 1.0 : Keywords
Web 2.0 : Tags

If you think descriptions were bad, keywords are doubly so.

If you think descriptions were bad, keywords are doubly so. They were abused by SEO practitioners everywhere. It is very difficult to find a page with keywords that can act as tags. Anyway, when creating pages, please use keyword that can be used as tags when bookmarking the page.

As it the case of description, keyword can easily be fetched and given to the bookmark posting url. You still have to modify the script as no social networking sites have included this feature in their bookmarklet(with very good reason). A thing to note here is that all ',' must be replaced with a 'space'.

In Conclusion

In this age of sharing data, the description and keyword meta tags have great importance. So use them in your sites - even if you are adviced against it. And when you do use it, don't use it to target search engine spiders. Create it in a way that would be useful to human beings.

Read More...

Links Search - Interactive Sitemaps with JavaScript

Sitemaps generally tend to be a boring collection of links - useful - but boring. When I was working on the Sitemap for OpenJS, I wanted to make it more user friendly. As a result, I created the sitemap filter function. This function takes a few keywords from the user and searches the DOM structure for link texts matching the search term(s). If the search term is not found in a link, that links will be hidden from view. The result is a very cool searching script.

Code

The code is available in GPL. I have created the code as a Object Literal - so it should work with other scripts - unless you want to name a variable 'links_search'.

View source - JS file

Demo

Read More...

Links Search - Interactive Sitemaps

Read More...

Case Conversion using Regular Expressions in Perl

As most of you are already aware, Perl has very powerful regular expression support. You can do things with regular expression in perl that cannot be done in any other language. One good example for this is case conversion using regular expression in perl. You can match a string and change its case when you are printing it back. For example you can convert 'case conversion using regular expressions in perl' to 'Case Conversion Using Regular Expressions In Perl' using just a regular expression.

I recently had the need for this when I was converting one of my old sites, BinnyVA, from pure HTML site to a site with PHP backend. I also wanted to make the code valid when I was converting it - and this involved make the tags and attributes lowercase. For this job, I turned to an old trusted friend of mine - Perl.

I have never used this particular feature of regular expression before - so I had to search for some time to find the answer. Unfortunately, I did not find any articles on this topic - the best I could find was a small reference within a tutorial about perl. So, I am creating a post for this topic - to aid future searchers in the same quest.

As an example, let us take this sentence.

the baby's blood type? human, mostly.

We want to convert it to title case ie.

The Baby's Blood Type? Human, Mostly.

The regular expression to do this is...

s/(\b)([a-z])/\1\u\2/g;

This is what it does...

s/
(\b) #Get word's preceding char must be a word boundary(\b)
([a-z]) #Get the first lowercase letter after the word boundary
/  #The Replacements...
\1  #Put the word boundary back in.
\u\2 #'\u' uppercases the next character
/g;

The full program looks like this...

#!/usr/bin/perl
$_ = 'the baby\'s blood type? human, mostly.';

s/(\b)([a-z])/\1\u\2/g;

print;

Try converting

computer, did we bring batteries? computer?

to

COMPUTER! Did we bring batteries? computer?

We can do this using the regexp...s

(computer), ([a-z])/\U\1\E! \u\2

See the part \U\1\E? This will uppercase every character from the \U escape to \E. In this case, It uppercases the full word 'COMPUTER'.

You can use the following escape sequences to change the case.

\l (Small L)
Lowercase next character
\u
Uppercase next character
\L
Lowercase until \E
\U
Uppercase until \E
\E
End case modification

I tired to do in in other languages like PHP and found it impossible. What about your favorite language? Can you convert the case of a string using just a regular expression?

Filed Under...

Read More...

Subscribe to : Posts