Thursday, January 28, 2010

Google live search is shockingly stupid

Can't beleive how dump the Google live search is!
Ok, I searched for "REST or RPC" which are the 2 technical terms for protocols, so I was looking for find the answer which one I should be using in my application.

So, Google added results from live twitter stream on the first page, some of them go like this "I should go get some rest"
or "the rest of the album is..."

Com'on Google, my son can write a smarter search engine - just filter out the VERY common words or at least don't show results for words that can have more than one meaning if you don't know which one of the meanings I am searching for.

What's the name for such words anyway, (words with more than one meaning)? I forgot, I better go Google it.

Thursday, January 21, 2010

Programming discussions tips

A convenient way to follow the latest discussions of the most
popular php and javascript projects is to keep an eye on the
mailing lists.

One good place to watch the latest lists is on this discussions site
It's updated in real time as soon as any new message arrives to any of the many programming lists they track.

There is also a way to reply, you just need to register and you good to go.

Friday, January 15, 2010

Enhances Search Results on Yahoo Serp pages

Just want to bookmark this page.
It contains valuable info on how to enhance the site markup to allow extra cool snippets on yahoo search results page - right on SERPS.

I especially like the Discussion, News and Video section, but Documents and Events and even Games look very promising too. The Games, however require them to be written in flash. I am not 100% sure but at least the example on Yahoo site is in flash.

It would be cool if Javascript games were also allowed.

Very interesting: at the bottom of the page there is a link to "Build a Custom App", so basically Yahoo also allows to build custom app and have it included in enhances SERP.

in reference to: SearchMonkey - Getting Started (view on Google Sidewiki)

Yahoo allows microformats to hint discussion

Very interesting. Yahoo allows to add
a microsofmat or RDF to indicate that a blog with comments or a forum discussion takes place.
Yahoo will then include this data in the enhanced search results page.

http://developer.search.yahoo.com/help/objects/discussion

in reference to:

"Description Display blog or forum information directly in Yahoo! Search. Add code to indicate to Yahoo! that a discussion exists on your page, and when we next crawl your site, we'll take care of the rest. From your markup, we’ll be able to extract structured data from your site and render it automatically in an enhanced result in search results."
- SearchMonkey - Discussion (view on Google Sidewiki)

Wednesday, January 13, 2010

2 Interfaces cannot contain the same method names

Impotrant: 2 Interfaces cannot contain the same method name and be
implemented in the same class

For example:

interface LampcmsResourceInterface
{
/**
* Returnes id of user (USERS.id)
* who owns the resource
*
* @return int
*/
public function getOwnerId();

public function getResourceId();

}


and then a
interface Zend_Acl_Resource_Interface
{
/**
* Returns the string identifier of the Resource
*
* @return string
*/
public function getResourceId();
}

This is not a problem as long as you don't try to implement
both in the same class.

You may assume that if your class has a method

getResourceId() then you can safely say it implements both LampcmsResourceInterface and Zend_Acl_Resource_Interface
but this is not true

if you try to write a class like this

class MyResource implements LampcmsResourceInterface, Zend_Acl_Resource_Interface
{

protected $resourceID = 100;

public function getResourceId(){

return $this->resourceID;
}



}

You will get fatal error when you try to instantiate this class:

Fatal error: Can't inherit abstract function Zend_Acl_Resource_Interface::getResourceId() (previously declared abstract in LampcmsResourceInterface)

The best course of action now would be to
change the LampcmsResourceInterface to only have one required method getOwnerId();

Then if you need an object that MUST have getOwnerID() and getResourceId()

just make a class and declare it as implements LampcmsResourceInterface, Zend_Acl_Resource_Interface

Thursday, January 7, 2010

Correct way to handle deleted messages and posts

The right way to delete message is to just mark it as deleted in the database.
Sure, we can also delete a record from MESSAGE_BODY if we keep a separate table just for message bodies.

Don't just mark it as deleted, but actually use a timestamp value for the 'deleted_ts' column.

The reason for that is that we will them be able to spot that the message has been deleted and not just 'does not exist'.

One advantage of knowing that it has actually been deleted and not just 'not found' is that we will be able to return a 410 response code instead of the normal 404

The difference between 410 and 404 is that search engines will not attempt to retry getting the same page again and again. The 410 basically says 'gone permanently' instead of just 'not found'

It may actually cause Google to delete this page from Google cache very fast.
Actually we can even give Google another hint to remove such page from cache. When we catch the 410 exception we may add an extra meta tag NOCACHE or NOARCHIVE, whatever it is that Google understands as 'don't use cached version'

This can be very helpful. And of cause by marking message as deleted instead of actually deleting it, we are not breaking the 'next', 'previous' navigation.

The 'next'/'previous' nav is another story, and maybe we actually should not use the 'next'/'prev' links of deleted pages because if many messages have been deleted we don't want to point to 'prev' which has also been deleted, we want to point to the first non-deleted page, but that will require a different logic. Later...

Also when we know that timestamp of when the message has been deleted we can show it to the user on the 410 page. So, we not only sending 410 response code but we can also show 'message was deleted on Dec 12, 2009' for example

This is also extremely helpful to the user.

Monday, January 4, 2010

Google's official paid links ban policy

Very interesting post (from google employee) about their take on paid links:

http://www.mattcutts.com/blog/how-to-report-paid-links/

It also explains how to report paid links to google, which is great!

Sunday, January 3, 2010

You can have your blog included on Google news

You know you can have your own news included
in the Google news.

I did not know that, but here it is:

http://www.google.com/support/news_pub/bin/answer.py?hl=en&answer=40787


Submitting Your Content: Google News
Print

If you'd like your news site or blog to be included in Google News, please send us the URL and we'll be happy to review it. Please note, however, that we can't guarantee we'll be able to include your site in Google News.

Shocking rel nofollow abuse by major players

nofollow is sort of like reverse cloaking: it presents different
content to the search engine than to the average user:

To the average user it looks like a link, yet to the search engine it looks like
it's not a link.

This is indeed a reverse cloaking - a reverse because it's initiated not by
a user with the purpose to trick, scam, screw! the search engine, but it was invented
by a search engine with a purpose to screw the user.

What do you think? Do you think I'm right?

Anyway, the nofollow originally was made popular by google, so other search
engines agreed that it was a good idea and decided to follow suit.


nofollow abuse:
digg
twitter
stubledupon

but also: (just a random example) http://stackoverflow.com/users/191837/kevin-peno
On personal pages of registered user!

How lame is that! If admin suspects that a user is a spammer, he should
just remove the user.

Also, stackoverflow has such thing as ;reputation;
so they at the very least should remove nofollow from
members with decent reputation!

I like the stackoverflow but I wold not give them
my time of day and contribute anything to them
if all I get in return is a lame 'nofollow' link
back to me.


===============

Also on github.com

How lame is that - accounts on github are basically
open source software projects. If I contribute an open
source project, then the least you can do is give me a fully
normal link, not a nofollow shit.

you want me as another user of github, you want me
to link to you, yet you treat me like a spammer?
No, thank you. You can keep your github to yourself
and I will just setup my own site to host my own project.

-----------------

At least DIGG has some in-house algorythm that would remove nofollow links
once they establish a repuration for your resource, but it's not clear
how this works. Once thing is clear that if your have many diffs (like 100+)
then the nofollow is gone. What is not clear is what they take into account
They should take into account the user who submitted the diggs - an old
user who has not been flagged as spammer and submitted certain number of diggs should
be able to submit dofollow links.

By the way, do you know why they call it dofollow? You know, there is no such thing as
dofollow attribute,.... it's just because the other way to describe links without a nofollow tag
is to call them nonofollow link. And that sounds pretty stupid.

========================

The right way to use nofollow is ONLY in comment or user submitted content like
a forum. Even then, a system should be in place that would allow good members to
post good links. Period! Don't slap a cookie-cutter nofollow attribute on all
links!

==============

Who else got it wrong? Probably the blogger. They are right to add nofollow to links
in comments, but they probably should not be slapping the nofollow to links
to other members who commented. I mean if it's a spam fighting technique, then
Blogger should be able to develop the best anti comment spam in the world, after all
they have access to real-time blog comments from millions of users.

If a user is a spammer, then blogger can just remove the whole user's account, making
all the hard work the user made in adding comments totally useless.

==================


Who's got it right? youtube! Then don't slap nofollow to links to user accounts from comments,
to links to friends and subscribers.

They even allow 1 normal link to your external website from youtube account page. More than one
link is OK, you can just add it by the way of editing the HTML of your channel description
but all such links are indeed nofollow links.

Who else got it right? livejournal does not add nofollow links to members from the comment pages
but it also does not add nofollow to any links in comments. This creates comment spam problem on
livejournal which they fight by letting user to require captcha on their comment pages.

=======================================


Who else is abusing it? Some forum software like vbulletin usually adds nofollow
to all incoming posts and there is no way to use any intelligent algorythm to
no add nofollow from trusted members.

also they seem to add a nofollow link even to links from personal profile pages
and many webmasters don't even allow viewing a profile page for not logged in user.

=======================

Once forum sofware that is pretty good with not abusing nofollow is simplemachines forum
The link from profile page is a normal link and is usually seen by not logged in user

require_once inside the method in php class

I've heard on some discussion list that if you have
require_once inside one of your methods in a php class then php will still evaluate
this require_once statement at compile time.

What these people were trying to say is that you should not have require_once or any other
similar statement inside your methods because it will slow down your script since php
will have to look at every such statement and make sure that there files are actually available.

I don't know, but I think it's a myth.

I took one of the classes from Zend, the Zend_Acl class
and inside the add() method there is a statement:

if (!$role instanceof Zend_Acl_Role_Interface) {
require_once 'Zend/Acl/Exception.php';
throw new Zend_Acl_Exception('addRole() expects $role to be of type Zend_Acl_Role_Interface');
}

So I just changed the require_once 'Zend/Acl/Exception.php';
to require_once 'nd/Acl/Exception.php';
This of cause points to non-existent php file, and would raise an error.

But php loaded my Acl class just fine. Not only it loaded my Acl class fine, but it even allowed
me to call the add() method. So as long as my script did not
pass this test: if (!$role instanceof Zend_Acl_Role_Interface)
php did not complain at all.

So there you have it, a proof that php does not care about your require_once statements until it actually executes these statements.

So, don't worry about this silly issue then - it is OK to have require_once inside the methods
but it's just as OK to completely rely on autoloader.

Personally I always use autoloader, so when I decided to use Zend_Acl class my first instinct was to just comment out all the require_once statements since they really hurt my eyes. Hey, I am not used to seeing require_once in my classes at all - that's what the spl_autoload and __autoload are for.

But then I though that I am going to be a good programmer and will not mess with an existing class - if I need some changes in the class, then I will extended like any good programmer should. And that what lead me to this test - I just wanted to be sure that having require_once inside the method will not cause any type of performance penalty. And it did not.

OK, I said too much already about this tiny issue.

Bye now.